/* * Copyright (C) 2017 Red Hat, Inc. * SPDX-License-Identifier: LGPL-2.1-or-later */ import cockpit from "cockpit"; import React from "react"; import { Badge } from "@patternfly/react-core/dist/esm/components/Badge/index.js"; import { Button } from "@patternfly/react-core/dist/esm/components/Button/index.js"; import { Card, CardBody, CardHeader, CardTitle } from '@patternfly/react-core/dist/esm/components/Card/index.js'; import { ExclamationTriangleIcon } from '@patternfly/react-icons'; import { journal } from "journal"; import "journal.css"; import "cockpit-components-logs-panel.scss"; const _ = cockpit.gettext; /* JournalOutput implements the interface expected by journal.renderer, and also collects the output. */ export class JournalOutput { constructor(search_options) { this.logs = []; this.reboot_key = 0; this.search_options = search_options || {}; } onEvent(ev, cursor, full_content) { // only consider primary mouse button for clicks if (ev.type === 'click') { if (ev.button !== 0) return; // Ignore if text is being selected - less than 3 characters most likely means misclick const selection = window.getSelection().toString(); if (selection && selection.length > 2 && full_content.indexOf(selection) >= 0) return; } // only consider enter button for keyboard events if (ev.type === 'KeyDown' && ev.key !== "Enter") return; cockpit.jump("system/logs#/" + cursor + "?parent_options=" + JSON.stringify(this.search_options)); } render_line(ident, prio, message, count, time, entry) { let warning = false; if (prio < 4) { warning = true; } const full_content = [time, message, ident].join("\n"); return (