From c5b8756512cb6dfbb0093514af7924cb3e78699b Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Tue, 19 Dec 2023 17:13:25 +0530 Subject: Delete wt/odlux directory New directory for odlux is sdnr/wt-odlux Issue-ID: CCSDK-3971 Change-Id: Ia0f8ba38d913a3d3bcde999b871794c65d5e575e Signed-off-by: Ravi Pendurty --- .../src/actions/maintenenceActions.ts | 77 ------- .../src/assets/icons/maintenanceAppIcon.svg | 50 ----- .../src/components/editMaintenenceEntryDialog.tsx | 207 ----------------- .../src/components/refreshMaintenanceEntries.tsx | 113 ---------- .../src/handlers/maintenanceAppRootHandler.ts | 39 ---- .../src/handlers/maintenanceEntriesHandler.ts | 35 --- sdnr/wt/odlux/apps/maintenanceApp/src/index.html | 26 --- .../src/models/maintenanceEntryType.ts | 33 --- .../apps/maintenanceApp/src/pluginMaintenance.tsx | 44 ---- .../src/services/maintenenceService.ts | 72 ------ .../apps/maintenanceApp/src/utils/timeUtils.ts | 45 ---- .../maintenanceApp/src/views/maintenanceView.tsx | 246 --------------------- 12 files changed, 987 deletions(-) delete mode 100644 sdnr/wt/odlux/apps/maintenanceApp/src/actions/maintenenceActions.ts delete mode 100644 sdnr/wt/odlux/apps/maintenanceApp/src/assets/icons/maintenanceAppIcon.svg delete mode 100644 sdnr/wt/odlux/apps/maintenanceApp/src/components/editMaintenenceEntryDialog.tsx delete mode 100644 sdnr/wt/odlux/apps/maintenanceApp/src/components/refreshMaintenanceEntries.tsx delete mode 100644 sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceAppRootHandler.ts delete mode 100644 sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceEntriesHandler.ts delete mode 100644 sdnr/wt/odlux/apps/maintenanceApp/src/index.html delete mode 100644 sdnr/wt/odlux/apps/maintenanceApp/src/models/maintenanceEntryType.ts delete mode 100644 sdnr/wt/odlux/apps/maintenanceApp/src/pluginMaintenance.tsx delete mode 100644 sdnr/wt/odlux/apps/maintenanceApp/src/services/maintenenceService.ts delete mode 100644 sdnr/wt/odlux/apps/maintenanceApp/src/utils/timeUtils.ts delete mode 100644 sdnr/wt/odlux/apps/maintenanceApp/src/views/maintenanceView.tsx (limited to 'sdnr/wt/odlux/apps/maintenanceApp/src') diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/actions/maintenenceActions.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/actions/maintenenceActions.ts deleted file mode 100644 index 740abff85..000000000 --- a/sdnr/wt/odlux/apps/maintenanceApp/src/actions/maintenenceActions.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-expressions */ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -import { AddSnackbarNotification } from '../../../../framework/src/actions/snackbarActions'; -import { Action } from '../../../../framework/src/flux/action'; -import { Dispatch } from '../../../../framework/src/flux/store'; - -import { maintenanceEntriesReloadAction } from '../handlers/maintenanceEntriesHandler'; -import { MaintenanceEntry, spoofSymbol } from '../models/maintenanceEntryType'; -import { maintenenceService } from '../services/maintenenceService'; - -export class BaseAction extends Action { } - -export class LoadAllMainteneceEntriesAction extends BaseAction { } - -export class AllMainteneceEntriesLoadedAction extends BaseAction { - - constructor(public maintenenceEntries: MaintenanceEntry[] | null) { - super(); - - } -} - - -export class UpdateMaintenanceEntry extends BaseAction { - constructor(public maintenenceEntry: MaintenanceEntry) { - super(); - } -} - -/** Represents an async thunk action creator to add an element to the maintenence entries. */ -export const addOrUpdateMaintenenceEntryAsyncActionCreator = (entry: MaintenanceEntry) => (dispatch: Dispatch) => { - maintenenceService.writeMaintenenceEntry(entry).then(result => { - result && window.setTimeout(() => { - // dispatch(loadAllMountedNetworkElementsAsync); - dispatch(new UpdateMaintenanceEntry(entry)); - dispatch(new AddSnackbarNotification({ message: `Successfully ${result && result.created ? 'created' : 'updated'} maintenance settings for [${entry.nodeId}]`, options: { variant: 'success' } })); - }, 900); - dispatch(maintenanceEntriesReloadAction); - }); -}; - -/** Represents an async thunk action creator to delete an element from the maintenence entries. */ -export const removeFromMaintenenceEntrysAsyncActionCreator = (entry: MaintenanceEntry) => (dispatch: Dispatch) => { - maintenenceService.deleteMaintenenceEntry(entry).then(result => { - result && window.setTimeout(() => { - dispatch(new UpdateMaintenanceEntry({ - [spoofSymbol]: true, - mId: entry.mId, - nodeId: entry.nodeId, - description: '', - start: '', - end: '', - active: false, - })); - dispatch(new AddSnackbarNotification({ message: `Successfully removed [${entry.nodeId}]`, options: { variant: 'success' } })); - }, 900); - dispatch(maintenanceEntriesReloadAction); - }); -}; - -// Hint: since there is no notification of changed required network elements, this code is not aware of changes caused outiside of this browser. \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/assets/icons/maintenanceAppIcon.svg b/sdnr/wt/odlux/apps/maintenanceApp/src/assets/icons/maintenanceAppIcon.svg deleted file mode 100644 index 8b99a5e7f..000000000 --- a/sdnr/wt/odlux/apps/maintenanceApp/src/assets/icons/maintenanceAppIcon.svg +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/components/editMaintenenceEntryDialog.tsx b/sdnr/wt/odlux/apps/maintenanceApp/src/components/editMaintenenceEntryDialog.tsx deleted file mode 100644 index 9ab147ca7..000000000 --- a/sdnr/wt/odlux/apps/maintenanceApp/src/components/editMaintenenceEntryDialog.tsx +++ /dev/null @@ -1,207 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-expressions */ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -import * as React from 'react'; - -import Button from '@mui/material/Button'; -import Dialog from '@mui/material/Dialog'; -import DialogActions from '@mui/material/DialogActions'; -import DialogContent from '@mui/material/DialogContent'; -import DialogContentText from '@mui/material/DialogContentText'; -import DialogTitle from '@mui/material/DialogTitle'; -import TextField from '@mui/material/TextField'; - -import { connect, Connect, IDispatcher } from '../../../../framework/src/flux/connect'; - -import { FormControl, InputLabel, MenuItem, Select, Typography } from '@mui/material'; -import { - addOrUpdateMaintenenceEntryAsyncActionCreator, - removeFromMaintenenceEntrysAsyncActionCreator, -} from '../actions/maintenenceActions'; -import { MaintenanceEntry } from '../models/maintenanceEntryType'; - -export enum EditMaintenenceEntryDialogMode { - None = 'none', - AddMaintenenceEntry = 'addMaintenenceEntry', - EditMaintenenceEntry = 'editMaintenenceEntry', - RemoveMaintenenceEntry = 'removeMaintenenceEntry', -} - -const mapDispatch = (dispatcher: IDispatcher) => ({ - addOrUpdateMaintenenceEntry: (entry: MaintenanceEntry) => { - dispatcher.dispatch(addOrUpdateMaintenenceEntryAsyncActionCreator(entry)); - }, - removeMaintenenceEntry: (entry: MaintenanceEntry) => { - dispatcher.dispatch(removeFromMaintenenceEntrysAsyncActionCreator(entry)); - }, -}); - -type DialogSettings = { - dialogTitle: string; - dialogDescription: string; - applyButtonText: string; - cancelButtonText: string; - enableMountIdEditor: boolean; - enableTimeEditor: boolean; -}; - -const settings: { [key: string]: DialogSettings } = { - [EditMaintenenceEntryDialogMode.None]: { - dialogTitle: '', - dialogDescription: '', - applyButtonText: '', - cancelButtonText: '', - enableMountIdEditor: false, - enableTimeEditor: false, - }, - [EditMaintenenceEntryDialogMode.AddMaintenenceEntry]: { - dialogTitle: 'Add new maintenence entry', - dialogDescription: '', - applyButtonText: 'Add', - cancelButtonText: 'Cancel', - enableMountIdEditor: true, - enableTimeEditor: true, - }, - [EditMaintenenceEntryDialogMode.EditMaintenenceEntry]: { - dialogTitle: 'Edit maintenence entry', - dialogDescription: '', - applyButtonText: 'Save', - cancelButtonText: 'Cancel', - enableMountIdEditor: false, - enableTimeEditor: true, - }, - [EditMaintenenceEntryDialogMode.RemoveMaintenenceEntry]: { - dialogTitle: 'Remove maintenence entry', - dialogDescription: '', - applyButtonText: 'Remove', - cancelButtonText: 'Cancel', - enableMountIdEditor: false, - enableTimeEditor: false, - }, -}; - -type EditMaintenenceEntryDIalogComponentProps = Connect & { - mode: EditMaintenenceEntryDialogMode; - initialMaintenenceEntry: MaintenanceEntry; - onClose: () => void; -}; - -type EditMaintenenceEntryDIalogComponentState = MaintenanceEntry & { isErrorVisible: boolean }; - -class EditMaintenenceEntryDIalogComponent extends React.Component { - constructor(props: EditMaintenenceEntryDIalogComponentProps) { - super(props); - - this.state = { - ...this.props.initialMaintenenceEntry, - isErrorVisible: false, - }; - } - - render(): JSX.Element { - const setting = settings[this.props.mode]; - return ( - - {setting.dialogTitle} - - - {setting.dialogDescription} - - { this.setState({ nodeId: event.target.value }); }} /> - {this.state.isErrorVisible && Name must not be empty.} - { this.setState({ start: event.target.value }); }} /> - { this.setState({ end: event.target.value }); }} /> - - Active - - - - - - - - - ); - } - - private onApply = (entry: MaintenanceEntry) => { - this.props.onClose && this.props.onClose(); - switch (this.props.mode) { - case EditMaintenenceEntryDialogMode.AddMaintenenceEntry: - entry && this.props.addOrUpdateMaintenenceEntry(entry); - break; - case EditMaintenenceEntryDialogMode.EditMaintenenceEntry: - entry && this.props.addOrUpdateMaintenenceEntry(entry); - break; - case EditMaintenenceEntryDialogMode.RemoveMaintenenceEntry: - entry && this.props.removeMaintenenceEntry(entry); - break; - } - }; - - - private onCancel = () => { - this.props.onClose && this.props.onClose(); - }; - - static getDerivedStateFromProps(props: EditMaintenenceEntryDIalogComponentProps, state: EditMaintenenceEntryDIalogComponentState & { initialMaintenenceEntrie: MaintenanceEntry }): EditMaintenenceEntryDIalogComponentState & { initialMaintenenceEntrie: MaintenanceEntry } { - if (props.initialMaintenenceEntry !== state.initialMaintenenceEntrie) { - // eslint-disable-next-line no-param-reassign - state = { - ...state, - ...props.initialMaintenenceEntry, - initialMaintenenceEntrie: props.initialMaintenenceEntry, - }; - } - return state; - } - -} - -export const EditMaintenenceEntryDIalog = connect(undefined, mapDispatch)(EditMaintenenceEntryDIalogComponent); -export default EditMaintenenceEntryDIalog; \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/components/refreshMaintenanceEntries.tsx b/sdnr/wt/odlux/apps/maintenanceApp/src/components/refreshMaintenanceEntries.tsx deleted file mode 100644 index e8bd635dd..000000000 --- a/sdnr/wt/odlux/apps/maintenanceApp/src/components/refreshMaintenanceEntries.tsx +++ /dev/null @@ -1,113 +0,0 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -import * as React from 'react'; - -import Button from '@mui/material/Button'; -import Dialog from '@mui/material/Dialog'; -import DialogActions from '@mui/material/DialogActions'; -import DialogContent from '@mui/material/DialogContent'; -import DialogContentText from '@mui/material/DialogContentText'; -import DialogTitle from '@mui/material/DialogTitle'; - -import { connect, Connect, IDispatcher } from '../../../../framework/src/flux/connect'; - -import { maintenanceEntriesReloadAction } from '../handlers/maintenanceEntriesHandler'; -import { MaintenanceEntry } from '../models/maintenanceEntryType'; - -export enum RefreshMaintenanceEntriesDialogMode { - None = 'none', - RefreshMaintenanceEntriesTable = 'RefreshMaintenanceEntriesTable', -} - -const mapDispatch = (dispatcher: IDispatcher) => ({ - refreshMaintenanceEntries: () => dispatcher.dispatch(maintenanceEntriesReloadAction), -}); - -type DialogSettings = { - dialogTitle: string; - dialogDescription: string; - applyButtonText: string; - cancelButtonText: string; - enableMountIdEditor: boolean; - enableUsernameEditor: boolean; - enableExtendedEditor: boolean; -}; - -const settings: { [key: string]: DialogSettings } = { - [RefreshMaintenanceEntriesDialogMode.None]: { - dialogTitle: '', - dialogDescription: '', - applyButtonText: '', - cancelButtonText: '', - enableMountIdEditor: false, - enableUsernameEditor: false, - enableExtendedEditor: false, - }, - [RefreshMaintenanceEntriesDialogMode.RefreshMaintenanceEntriesTable]: { - dialogTitle: 'Do you want to refresh Maintenance Entries?', - dialogDescription: '', - applyButtonText: 'Yes', - cancelButtonText: 'Cancel', - enableMountIdEditor: true, - enableUsernameEditor: true, - enableExtendedEditor: true, - }, -}; - -type RefreshMaintenanceEntriesDialogComponentProps = Connect & { - mode: RefreshMaintenanceEntriesDialogMode; - onClose: () => void; -}; - -type RefreshMaintenanceEntriesDialogComponentState = MaintenanceEntry & { isNameValid: boolean; isHostSet: boolean }; - -class RefreshMaintenanceEntriesDialogComponent extends React.Component { - render(): JSX.Element { - const setting = settings[this.props.mode]; - return ( - - {setting.dialogTitle} - - - {setting.dialogDescription} - - - - - - - - ); - } - - private onRefresh = () => { - this.props.refreshMaintenanceEntries(); - this.props.onClose(); - }; - - private onCancel = () => { - this.props.onClose(); - }; -} - -export const RefreshMaintenanceEntriesDialog = connect(undefined, mapDispatch)(RefreshMaintenanceEntriesDialogComponent); -export default RefreshMaintenanceEntriesDialog; \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceAppRootHandler.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceAppRootHandler.ts deleted file mode 100644 index ced7f2160..000000000 --- a/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceAppRootHandler.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -// main state handler - -import { combineActionHandler } from '../../../../framework/src/flux/middleware'; - -import { IMaintenanceEntriesState, maintenanceEntriesActionHandler } from './maintenanceEntriesHandler'; - -export interface IMaintenanceAppStoreState { - maintenanceEntries : IMaintenanceEntriesState; -} - -declare module '../../../../framework/src/store/applicationStore' { - interface IApplicationStoreState { - maintenance: IMaintenanceAppStoreState; - } -} - -const actionHandlers = { - maintenanceEntries: maintenanceEntriesActionHandler, -}; - -export const maintenanceAppRootHandler = combineActionHandler(actionHandlers); -export default maintenanceAppRootHandler; diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceEntriesHandler.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceEntriesHandler.ts deleted file mode 100644 index c3fe51e80..000000000 --- a/sdnr/wt/odlux/apps/maintenanceApp/src/handlers/maintenanceEntriesHandler.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -import { createExternal, IExternalTableState } from '../../../../framework/src/components/material-table/utilities'; -import { createSearchDataHandler } from '../../../../framework/src/utilities/elasticSearch'; - -import { MaintenanceEntry } from '../models/maintenanceEntryType'; -export interface IMaintenanceEntriesState extends IExternalTableState { } - -// create elastic search material data fetch handler -const maintenanceEntriesSearchHandler = createSearchDataHandler('maintenance'); - -export const { - actionHandler: maintenanceEntriesActionHandler, - createActions: createmaintenanceEntriesActions, - createProperties: createmaintenanceEntriesProperties, - reloadAction: maintenanceEntriesReloadAction, - - // set value action, to change a value -} = createExternal(maintenanceEntriesSearchHandler, appState => appState.maintenance.maintenanceEntries); - diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/index.html b/sdnr/wt/odlux/apps/maintenanceApp/src/index.html deleted file mode 100644 index c84aecee1..000000000 --- a/sdnr/wt/odlux/apps/maintenanceApp/src/index.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - Minimal App - - - -
- - - - - - \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/models/maintenanceEntryType.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/models/maintenanceEntryType.ts deleted file mode 100644 index 27cdc8c12..000000000 --- a/sdnr/wt/odlux/apps/maintenanceApp/src/models/maintenanceEntryType.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -/** Represents the elestic search db type for maintenence enrties */ - - -export const spoofSymbol = Symbol('Spoof'); - -/** Represents the type for an maintenence entry. */ -export type MaintenanceEntry = { - mId: string; - nodeId: string; - description?: string; - end: string; - start: string; - active: boolean; - [spoofSymbol]?: boolean; -}; - diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/pluginMaintenance.tsx b/sdnr/wt/odlux/apps/maintenanceApp/src/pluginMaintenance.tsx deleted file mode 100644 index 0f686cb84..000000000 --- a/sdnr/wt/odlux/apps/maintenanceApp/src/pluginMaintenance.tsx +++ /dev/null @@ -1,44 +0,0 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -// app configuration and main entry point for the app - -import React, { FC } from 'react'; - -import applicationManager from '../../../framework/src/services/applicationManager'; - -import { maintenanceAppRootHandler } from './handlers/maintenanceAppRootHandler'; - -import { MaintenanceView } from './views/maintenanceView'; - -const appIcon = require('./assets/icons/maintenanceAppIcon.svg'); // select app icon - -const App : FC = () => { - return ; -}; - -export function register() { - applicationManager.registerApplication({ - name: 'maintenance', - icon: appIcon, - rootComponent: App, - rootActionHandler: maintenanceAppRootHandler, - menuEntry: 'Maintenance', - }); -} - - diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/services/maintenenceService.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/services/maintenenceService.ts deleted file mode 100644 index 5fdccc349..000000000 --- a/sdnr/wt/odlux/apps/maintenanceApp/src/services/maintenenceService.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -import { DeleteResponse, PostResponse } from '../../../../framework/src/models/elasticSearch'; -import { requestRest } from '../../../../framework/src/services/restService'; -import { convertPropertyNames, replaceUpperCase } from '../../../../framework/src/utilities/yangHelper'; -import { MaintenanceEntry } from '../models/maintenanceEntryType'; - -import { convertToISODateString } from '../utils/timeUtils'; - - -export const maintenenceEntryDatabasePath = 'mwtn/maintenancemode'; - -/** - * Represents a web api accessor service for all maintenence entries related actions. - */ -class MaintenenceService { - - /** - * Adds or updates one maintenence entry to the backend. - */ - public async writeMaintenenceEntry(maintenenceEntry: MaintenanceEntry): Promise { - const path = '/rests/operations/data-provider:create-maintenance'; - - const query = { - 'id': maintenenceEntry.mId, - 'node-id': maintenenceEntry.nodeId, - 'active': maintenenceEntry.active, - 'description': maintenenceEntry.description, - 'end': convertToISODateString(maintenenceEntry.end), - 'start': convertToISODateString(maintenenceEntry.start), - }; - - const result = await requestRest(path, { method: 'POST', body: JSON.stringify(convertPropertyNames({ 'data-provider:input': query }, replaceUpperCase)) }); - return result || null; - } - - /** - * Deletes one maintenence entry by its mountId from the backend. - */ - public async deleteMaintenenceEntry(maintenenceEntry: MaintenanceEntry): Promise<(DeleteResponse) | null> { - const path = '/rests/operations/data-provider:delete-maintenance'; - - const query = { - 'id': maintenenceEntry.mId, - 'node-id': maintenenceEntry.nodeId, - 'active': maintenenceEntry.active, - 'description': maintenenceEntry.description, - 'end': convertToISODateString(maintenenceEntry.end), - 'start': convertToISODateString(maintenenceEntry.start), - }; - const result = await requestRest(path, { method: 'POST', body: JSON.stringify(convertPropertyNames({ 'data-provider:input': query }, replaceUpperCase)) }); - return result || null; - } -} - -export const maintenenceService = new MaintenenceService(); -export default maintenenceService; \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/utils/timeUtils.ts b/sdnr/wt/odlux/apps/maintenanceApp/src/utils/timeUtils.ts deleted file mode 100644 index 0fde5fcad..000000000 --- a/sdnr/wt/odlux/apps/maintenanceApp/src/utils/timeUtils.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -export function convertToGMTString(dateString: string): string { - const date = new Date(dateString); - const pad = (n: number) => (n < 10) ? '0' + n : n; - - return date.getUTCFullYear() + - '-' + pad(date.getUTCMonth() + 1) + - '-' + pad(date.getUTCDate()) + - 'T' + pad(date.getUTCHours()) + - ':' + pad(date.getUTCMinutes()) + - '+00:00'; -} - -export function convertToLocaleString(rawDate: string | number): string { - const date = new Date(rawDate); - const pad = (n: number) => (n < 10) ? '0' + n : n; - - return date.getFullYear() + - '-' + pad(date.getMonth() + 1) + - '-' + pad(date.getDate()) + - 'T' + pad(date.getHours()) + - ':' + pad(date.getMinutes()); -} - -export function convertToISODateString(rawDate: string | number): string { - const date = new Date(rawDate); - const displayDate = date.toISOString(); - return displayDate.replace(/\.[0-9]{2}/, '.'); -} \ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/views/maintenanceView.tsx b/sdnr/wt/odlux/apps/maintenanceApp/src/views/maintenanceView.tsx deleted file mode 100644 index d54d63c04..000000000 --- a/sdnr/wt/odlux/apps/maintenanceApp/src/views/maintenanceView.tsx +++ /dev/null @@ -1,246 +0,0 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -import React from 'react'; - -import { faBan } from '@fortawesome/free-solid-svg-icons'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import AddIcon from '@mui/icons-material/Add'; -import EditIcon from '@mui/icons-material/Edit'; -import Refresh from '@mui/icons-material/Refresh'; -import RemoveIcon from '@mui/icons-material/RemoveCircleOutline'; -import { Divider, MenuItem, Theme, Typography } from '@mui/material'; -import { WithStyles } from '@mui/styles'; -import createStyles from '@mui/styles/createStyles'; -import withStyles from '@mui/styles/withStyles'; - -import MaterialTable, { ColumnType, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; -import { connect, Connect, IDispatcher } from '../../../../framework/src/flux/connect'; -import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; - -import EditMaintenenceEntryDialog, { EditMaintenenceEntryDialogMode } from '../components/editMaintenenceEntryDialog'; -import RefreshMaintenanceEntriesDialog, { RefreshMaintenanceEntriesDialogMode } from '../components/refreshMaintenanceEntries'; -import { createmaintenanceEntriesActions, createmaintenanceEntriesProperties, maintenanceEntriesReloadAction } from '../handlers/maintenanceEntriesHandler'; -import { MaintenanceEntry } from '../models/maintenanceEntryType'; -import { convertToLocaleString } from '../utils/timeUtils'; - -const styles = (theme: Theme) => createStyles({ - button: { - margin: 0, - padding: '6px 6px', - minWidth: 'unset', - }, - spacer: { - marginLeft: theme.spacing(1), - marginRight: theme.spacing(1), - display: 'inline', - }, -}); - -const MaintenanceEntriesTable = MaterialTable as MaterialTableCtorType; - -const mapProps = (state: IApplicationStoreState) => ({ - maintenanceEntriesProperties: createmaintenanceEntriesProperties(state), -}); - -const mapDispatcher = (dispatcher: IDispatcher) => ({ - maintenanceEntriesActions: createmaintenanceEntriesActions(dispatcher.dispatch), - onLoadMaintenanceEntries: async () => { - await dispatcher.dispatch(maintenanceEntriesReloadAction); - }, -}); - -const emptyMaintenenceEntry: MaintenanceEntry = { - mId: '', - nodeId: '', - description: '', - start: convertToLocaleString(new Date().valueOf()), - end: convertToLocaleString(new Date().valueOf()), - active: false, -}; - -type MaintenanceViewComponentProps = Connect & WithStyles & {}; - -type MaintenenceViewComponentState = { - maintenenceEntryToEdit: MaintenanceEntry; - maintenanceEntryEditorMode: EditMaintenenceEntryDialogMode; - refreshMaintenenceEntriesEditorMode: RefreshMaintenanceEntriesDialogMode; -}; - -let initialSorted = false; - -class MaintenenceViewComponent extends React.Component { - - constructor(props: MaintenanceViewComponentProps) { - super(props); - - this.state = { - maintenenceEntryToEdit: emptyMaintenenceEntry, - maintenanceEntryEditorMode: EditMaintenenceEntryDialogMode.None, - refreshMaintenenceEntriesEditorMode: RefreshMaintenanceEntriesDialogMode.None, - }; - - } - - getContextMenu(rowData: MaintenanceEntry): JSX.Element[] { - let buttonArray = [ - this.onOpenPlus1hEditMaintenenceEntryDialog(event, rowData)}>+1h, - this.onOpenPlus8hEditMaintenenceEntryDialog(event, rowData)}>+8h, - , - this.onOpenEditMaintenenceEntryDialog(event, rowData)}>Edit, - this.onOpenRemoveMaintenenceEntryDialog(event, rowData)}>Remove, - ]; - return buttonArray; - } - - render() { - const addMaintenenceEntryAction = { - icon: AddIcon, tooltip: 'Add', ariaLabel:'add-element', onClick: () => { - const startTime = (new Date().valueOf()); - const endTime = startTime; - this.setState({ - maintenenceEntryToEdit: { - ...emptyMaintenenceEntry, - start: convertToLocaleString(startTime), - end: convertToLocaleString(endTime), - }, - maintenanceEntryEditorMode: EditMaintenenceEntryDialogMode.AddMaintenenceEntry, - }); - }, - }; - - const refreshMaintenanceEntriesAction = { - icon: Refresh, tooltip: 'Refresh Maintenance Entries', ariaLabel: 'refresh', onClick: () => { - this.setState({ - refreshMaintenenceEntriesEditorMode: RefreshMaintenanceEntriesDialogMode.RefreshMaintenanceEntriesTable, - }); - }, - }; - - const now = new Date().valueOf(); - return ( - <> - ( - rowData.active && (Date.parse(rowData.start).valueOf() <= now) && (Date.parse(rowData.end).valueOf() >= now) && || null - ), - }, - { property: 'active', title: 'Activation State', type: ColumnType.boolean, labels: { 'true': 'active', 'false': 'not active' } }, - { property: 'start', title: 'Start Date (UTC)', type: ColumnType.text }, - { property: 'end', title: 'End Date (UTC)', type: ColumnType.text }, - ] - } idProperty={'mId'}{...this.props.maintenanceEntriesActions} {...this.props.maintenanceEntriesProperties} asynchronus createContextMenu={rowData => { - return this.getContextMenu(rowData); - }} > - - - - - ); - } - - public componentDidMount() { - - if (!initialSorted) { - initialSorted = true; - this.props.maintenanceEntriesActions.onHandleRequestSort('node-id'); - } else { - this.props.onLoadMaintenanceEntries(); - } - - - } - - private onOpenPlus1hEditMaintenenceEntryDialog = (event: React.MouseEvent, entry: MaintenanceEntry) => { - // event.preventDefault(); - // event.stopPropagation(); - const startTime = (new Date().valueOf()); - const endTime = startTime + (1 * 60 * 60 * 1000); - this.setState({ - maintenenceEntryToEdit: { - ...entry, - start: convertToLocaleString(startTime), - end: convertToLocaleString(endTime), - }, - maintenanceEntryEditorMode: EditMaintenenceEntryDialogMode.EditMaintenenceEntry, - }); - }; - - private onOpenPlus8hEditMaintenenceEntryDialog = (event: React.MouseEvent, entry: MaintenanceEntry) => { - // event.preventDefault(); - // event.stopPropagation(); - const startTime = (new Date().valueOf()); - const endTime = startTime + (8 * 60 * 60 * 1000); - this.setState({ - maintenenceEntryToEdit: { - ...entry, - start: convertToLocaleString(startTime), - end: convertToLocaleString(endTime), - }, - maintenanceEntryEditorMode: EditMaintenenceEntryDialogMode.EditMaintenenceEntry, - }); - }; - - private onOpenEditMaintenenceEntryDialog = (event: React.MouseEvent, entry: MaintenanceEntry) => { - // event.preventDefault(); - // event.stopPropagation(); - const startTime = (new Date().valueOf()); - const endTime = startTime; - this.setState({ - maintenenceEntryToEdit: { - ...entry, - ...(entry.start && endTime ? { start: convertToLocaleString(entry.start), end: convertToLocaleString(entry.end) } : { start: convertToLocaleString(startTime), end: convertToLocaleString(endTime) }), - }, - maintenanceEntryEditorMode: EditMaintenenceEntryDialogMode.EditMaintenenceEntry, - }); - }; - - private onOpenRemoveMaintenenceEntryDialog = (event: React.MouseEvent, entry: MaintenanceEntry) => { - // event.preventDefault(); - // event.stopPropagation(); - const startTime = (new Date().valueOf()); - const endTime = startTime; - this.setState({ - maintenenceEntryToEdit: { - ...entry, - ...(entry.start && endTime ? { start: convertToLocaleString(entry.start), end: convertToLocaleString(entry.end) } : { start: convertToLocaleString(startTime), end: convertToLocaleString(endTime) }), - }, - maintenanceEntryEditorMode: EditMaintenenceEntryDialogMode.RemoveMaintenenceEntry, - }); - }; - - private onCloseEditMaintenenceEntryDialog = () => { - this.setState({ - maintenenceEntryToEdit: emptyMaintenenceEntry, - maintenanceEntryEditorMode: EditMaintenenceEntryDialogMode.None, - }); - }; - - private onCloseRefreshMaintenenceEntryDialog = () => { - this.setState({ - refreshMaintenenceEntriesEditorMode: RefreshMaintenanceEntriesDialogMode.None, - }); - }; -} - -export const MaintenanceView = withStyles(styles)(connect(mapProps, mapDispatcher)(MaintenenceViewComponent)); - -- cgit