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==========================================================================
19 import { Action } from '../../../../framework/src/flux/action';
20 import { Dispatch } from '../../../../framework/src/flux/store';
22 import { connectService } from '../services/connectService';
23 import { NetworkElementConnection } from '../models/networkElementConnection';
24 import { AddSnackbarNotification } from '../../../../framework/src/actions/snackbarActions';
25 import { updateCurrentViewAsyncAction } from './commonNetworkElementsActions';
27 /** Represents the base action. */
28 export class BaseAction extends Action { }
30 /** Represents an action creator for a async thunk action to mount a network element/node. */
31 export const mountNetworkElementAsyncActionCreator = (networkElement: NetworkElementConnection) => (dispatch: Dispatch) => {
32 return connectService.mountNetworkElement(networkElement).then((success) => {
34 dispatch(updateCurrentViewAsyncAction());
35 dispatch(new AddSnackbarNotification({ message: `Requesting mount [${networkElement.nodeId}]`, options: { variant: 'info' } }));
37 dispatch(new AddSnackbarNotification({ message: `Failed to mount [${networkElement.nodeId}]`, options: { variant: 'warning' } }));
40 dispatch(new AddSnackbarNotification({ message: `Failed to mount [${networkElement.nodeId}]`, options: { variant: 'error' } }));
45 /** Represents an action creator for a async thunk action to unmount a network element/node. */
46 export const unmountNetworkElementAsyncActionCreator = (nodeId: string) => (dispatch: Dispatch) => {
47 return connectService.unmountNetworkElement(nodeId).then((success) => {
49 dispatch(updateCurrentViewAsyncAction());
50 dispatch(new AddSnackbarNotification({ message: `Requesting unmount [${nodeId}]`, options: { variant: 'info' } }));
52 dispatch(new AddSnackbarNotification({ message: `Failed to unmount [${nodeId}]`, options: { variant: 'warning' } }));
55 dispatch(new AddSnackbarNotification({ message: `Failed to unmount [${nodeId}]`, options: { variant: 'error' } }));