2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt odlux
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
18 import * as React from "react";
20 import { Connect, connect, IDispatcher } from '../../../../framework/src/flux/connect';
21 import { MaterialTable, MaterialTableCtorType } from '../../../../framework/src/components/material-table';
22 import Refresh from '@mui/icons-material/Refresh';
24 import { EventLogType } from '../models/eventLogType';
25 import { IApplicationStoreState } from "../../../../framework/src/store/applicationStore";
26 import { createEventLogProperties, createEventLogActions } from "../handlers/eventLogHandler";
27 import RefreshEventLogDialog, { RefreshEventLogDialogMode } from '../components/refreshEventLogDialog';
29 const EventLogTable = MaterialTable as MaterialTableCtorType<EventLogType & { _id: string }>;
31 const mapProps = (state: IApplicationStoreState) => ({
32 eventLogProperties: createEventLogProperties(state),
33 eventLog: state.eventLog.logEntries
36 const mapDispatch = (dispatcher: IDispatcher) => ({
37 eventLogActions: createEventLogActions(dispatcher.dispatch)
40 type EventLogComponentProps = Connect<typeof mapProps, typeof mapDispatch>;
41 type EventLogComponentState = {
42 refreshEventLogEditorMode: RefreshEventLogDialogMode
44 let initalSorted = false;
46 class EventLogComponent extends React.Component<EventLogComponentProps, EventLogComponentState> {
47 constructor(props: EventLogComponentProps) {
51 refreshEventLogEditorMode: RefreshEventLogDialogMode.None
55 render(): JSX.Element {
57 const refreshEventLogAction = {
58 icon: Refresh, tooltip: 'Refresh Event log', ariaLabel:'refresh', onClick: () => {
60 refreshEventLogEditorMode: RefreshEventLogDialogMode.RefreshEventLogTable
66 <EventLogTable stickyHeader title="Event Log" tableId="event-log-table" idProperty="_id" customActionButtons={[refreshEventLogAction]}
68 { property: "nodeId", title: "Node Name" },
69 { property: "counter", title: "Counter" },
70 { property: "timestamp", title: "Timestamp" },
71 { property: "objectId", title: "Object ID" },
72 { property: "attributeName", title: "Attribute Name" },
73 { property: "newValue", title: "Message" },
74 { property: "sourceType", title: "Source" }
75 ]} {...this.props.eventLogActions} {...this.props.eventLogProperties} >
77 <RefreshEventLogDialog
78 mode={this.state.refreshEventLogEditorMode}
79 onClose={this.onCloseRefreshEventLogDialog}
85 private onCloseRefreshEventLogDialog = () => {
87 refreshEventLogEditorMode: RefreshEventLogDialogMode.None
94 this.props.eventLogActions.onHandleExplicitRequestSort("timestamp", "desc");
96 this.props.eventLogActions.onRefresh();
101 export const EventLog = connect(mapProps, mapDispatch)(EventLogComponent);
102 export default EventLog;