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 Button from '@mui/material/Button';
21 import Dialog from '@mui/material/Dialog';
22 import DialogActions from '@mui/material/DialogActions';
23 import DialogContent from '@mui/material/DialogContent';
24 import DialogContentText from '@mui/material/DialogContentText';
25 import DialogTitle from '@mui/material/DialogTitle';
27 import { connect, Connect, IDispatcher } from '../../../../framework/src/flux/connect';
28 import { alarmLogEntriesReloadAction } from '../handlers/alarmLogEntriesHandler';
29 import { Fault } from '../models/fault';
31 export enum RefreshAlarmLogDialogMode {
33 RefreshAlarmLogTable = 'RefreshAlarmLogTable',
36 const mapDispatch = (dispatcher: IDispatcher) => ({
37 refreshAlarmLog: () => dispatcher.dispatch(alarmLogEntriesReloadAction),
40 type DialogSettings = {
42 dialogDescription: string;
43 applyButtonText: string;
44 cancelButtonText: string;
45 enableMountIdEditor: boolean;
46 enableUsernameEditor: boolean;
47 enableExtendedEditor: boolean;
50 const settings: { [key: string]: DialogSettings } = {
51 [RefreshAlarmLogDialogMode.None]: {
53 dialogDescription: '',
56 enableMountIdEditor: false,
57 enableUsernameEditor: false,
58 enableExtendedEditor: false,
60 [RefreshAlarmLogDialogMode.RefreshAlarmLogTable]: {
61 dialogTitle: 'Do you want to refresh the Alarm Log?',
62 dialogDescription: '',
63 applyButtonText: 'Yes',
64 cancelButtonText: 'Cancel',
65 enableMountIdEditor: true,
66 enableUsernameEditor: true,
67 enableExtendedEditor: true,
71 type RefreshAlarmLogDialogComponentProps = Connect<undefined, typeof mapDispatch> & {
72 mode: RefreshAlarmLogDialogMode;
76 type RefreshAlarmLogDialogComponentState = Fault & { isNameValid: boolean; isHostSet: boolean };
78 class RefreshAlarmLogDialogComponent extends React.Component<RefreshAlarmLogDialogComponentProps, RefreshAlarmLogDialogComponentState> {
79 render(): JSX.Element {
80 const setting = settings[this.props.mode];
82 <Dialog open={this.props.mode !== RefreshAlarmLogDialogMode.None}>
83 <DialogTitle id="form-dialog-title" aria-label={`${setting.dialogTitle.replace(/ /g, '-').toLowerCase()}-dialog`}>{setting.dialogTitle}</DialogTitle>
86 {setting.dialogDescription}
90 <Button aria-label="dialog-confirm-button" onClick={() => {
92 }} color="inherit" > {setting.applyButtonText} </Button>
93 <Button aria-label="dialog-cancel-button" onClick={() => {
95 }} color="secondary"> {setting.cancelButtonText} </Button>
101 private onRefresh = () => {
102 this.props.refreshAlarmLog();
103 this.props.onClose();
106 private onCancel = () => {
107 this.props.onClose();
111 export const RefreshAlarmLogDialog = connect(undefined, mapDispatch)(RefreshAlarmLogDialogComponent);
112 export default RefreshAlarmLogDialog;