1 /* eslint-disable @typescript-eslint/no-unused-expressions */
3 * ============LICENSE_START========================================================================
4 * ONAP : ccsdk feature sdnr wt odlux
5 * =================================================================================================
6 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
7 * =================================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software distributed under the License
14 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
15 * or implied. See the License for the specific language governing permissions and limitations under
17 * ============LICENSE_END==========================================================================
19 import { AddSnackbarNotification } from '../../../../framework/src/actions/snackbarActions';
20 import { Action } from '../../../../framework/src/flux/action';
21 import { Dispatch } from '../../../../framework/src/flux/store';
23 import { maintenanceEntriesReloadAction } from '../handlers/maintenanceEntriesHandler';
24 import { MaintenanceEntry, spoofSymbol } from '../models/maintenanceEntryType';
25 import { maintenenceService } from '../services/maintenenceService';
27 export class BaseAction extends Action { }
29 export class LoadAllMainteneceEntriesAction extends BaseAction { }
31 export class AllMainteneceEntriesLoadedAction extends BaseAction {
33 constructor(public maintenenceEntries: MaintenanceEntry[] | null) {
40 export class UpdateMaintenanceEntry extends BaseAction {
41 constructor(public maintenenceEntry: MaintenanceEntry) {
46 /** Represents an async thunk action creator to add an element to the maintenence entries. */
47 export const addOrUpdateMaintenenceEntryAsyncActionCreator = (entry: MaintenanceEntry) => (dispatch: Dispatch) => {
48 maintenenceService.writeMaintenenceEntry(entry).then(result => {
49 result && window.setTimeout(() => {
50 // dispatch(loadAllMountedNetworkElementsAsync);
51 dispatch(new UpdateMaintenanceEntry(entry));
52 dispatch(new AddSnackbarNotification({ message: `Successfully ${result && result.created ? 'created' : 'updated'} maintenance settings for [${entry.nodeId}]`, options: { variant: 'success' } }));
54 dispatch(maintenanceEntriesReloadAction);
58 /** Represents an async thunk action creator to delete an element from the maintenence entries. */
59 export const removeFromMaintenenceEntrysAsyncActionCreator = (entry: MaintenanceEntry) => (dispatch: Dispatch) => {
60 maintenenceService.deleteMaintenenceEntry(entry).then(result => {
61 result && window.setTimeout(() => {
62 dispatch(new UpdateMaintenanceEntry({
71 dispatch(new AddSnackbarNotification({ message: `Successfully removed [${entry.nodeId}]`, options: { variant: 'success' } }));
73 dispatch(maintenanceEntriesReloadAction);
77 // Hint: since there is no notification of changed required network elements, this code is not aware of changes caused outiside of this browser.