Merge changes from topics "VID-11", "VID-10", "VID-9"
[vid.git] / vid-webpack-master / src / app / shared / storeUtil / utils / service / service.actions.ts
1 import {ServiceInstance} from "../../../models/serviceInstance";
2 import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
3 import {Action, ActionCreator} from "redux";
4
5 export enum ServiceActions {
6   CREATE_SERVICE_INSTANCE = 'CREATE_SERVICE_INSTANCE',
7   UPDATE_SERVICE_INSTANCE = 'UPDATE_SERVICE_INSTANCE',
8   DELETE_ALL_SERVICE_INSTANCES = 'DELETE_ALL_SERVICE_INSTANCES',
9   UPDATE_MODEL  = 'UPDATE_MODEL',
10   ADD_SERVICE_ACTION = 'ADD_SERVICE_ACTION',
11   DELETE_ACTION_SERVICE_INSTANCE = "DELETE_ACTION_SERVICE_INSTANCE",
12   UNDO_DELETE_ACTION_SERVICE_INSTANCE = "UNDO_DELETE_ACTION_SERVICE_INSTANCE",
13   CHANGE_SERVICE_IS_DIRTY = "CHANGE_SERVICE_IS_DIRTY",
14   UPGRADE_SERVICE_ACTION = "UPGRADE_SERVICE_ACTION",
15   UNDO_UPGRADE_SERVICE_ACTION = "UNDO_UPGRADE_SERVICE_ACTION"
16 }
17
18 export interface CreateServiceInstanceAction extends Action {
19   serviceUuid?: string;
20   serviceInstance?: ServiceInstance;
21 }
22
23 export interface UpdateServiceInstanceAction extends Action {
24   serviceUuid?: string;
25   serviceInstance?: ServiceInstance;
26 }
27
28 export interface DeleteServiceInstanceAction extends Action {
29   serviceUuid?: string;
30 }
31
32 export interface DeleteServiceInstanceAction extends Action {
33   serviceUuid?: string;
34 }
35
36 export interface UpdateServiceModelAction extends Action {
37   serviceHierarchy?: any;
38 }
39
40 export interface AddServiceAction extends Action{
41   serviceUuid: string;
42   action: ServiceInstanceActions;
43 }
44
45 export interface UpgradeServiceAction extends Action{
46   serviceUuid: string;
47 }
48
49 export interface UndoUpgradeServiceAction extends Action{
50   serviceUuid: string;
51 }
52
53 export interface DeleteActionServiceInstanceAction extends Action {
54   serviceId?: string;
55 }
56
57 export interface UndoDeleteActionServiceInstanceAction extends Action {
58   serviceId?: string;
59 }
60
61 export interface ChangeServiceDirty extends Action {
62   nodes: any[];
63   serviceId : string;
64 }
65
66 export const addServiceAction: ActionCreator<AddServiceAction> = (serviceUuid : string, actionName : ServiceInstanceActions) => ({
67   type: ServiceActions.ADD_SERVICE_ACTION,
68   serviceUuid: serviceUuid,
69   action : actionName
70 });
71
72
73 export const deleteAllServiceInstances: ActionCreator<DeleteServiceInstanceAction> = () => ({
74   type: ServiceActions.DELETE_ALL_SERVICE_INSTANCES
75 });
76
77 export const createServiceInstance: ActionCreator<CreateServiceInstanceAction> = (serviceInstance, serviceUuid) => ({
78   type: ServiceActions.CREATE_SERVICE_INSTANCE,
79   serviceInstance: serviceInstance,
80   serviceUuid: serviceUuid
81 });
82
83 export const updateServiceInstance: ActionCreator<UpdateServiceInstanceAction> = (serviceInstance, serviceUuid) => ({
84   type: ServiceActions.UPDATE_SERVICE_INSTANCE,
85   serviceInstance: serviceInstance,
86   serviceUuid: serviceUuid
87 });
88
89 export const updateModel: ActionCreator<UpdateServiceModelAction> = serviceHierarchy => ({
90   type: ServiceActions.UPDATE_MODEL,
91   serviceHierarchy: serviceHierarchy
92 });
93
94
95 export const deleteActionServiceInstance: ActionCreator<DeleteActionServiceInstanceAction> = (vnfStoreKey, serviceId) => ({
96   type: ServiceActions.DELETE_ACTION_SERVICE_INSTANCE,
97   serviceId: serviceId
98 });
99
100 export const undoDeleteActionServiceInstance: ActionCreator<UndoDeleteActionServiceInstanceAction> = (vnfStoreKey, serviceId) => ({
101   type: ServiceActions.UNDO_DELETE_ACTION_SERVICE_INSTANCE,
102   serviceId: serviceId
103 });
104
105 export const changeServiceIsDirty: ActionCreator<ChangeServiceDirty> = (nodes, serviceId) => ({
106   type: ServiceActions.CHANGE_SERVICE_IS_DIRTY,
107   nodes: nodes,
108   serviceId : serviceId
109 });
110
111 export const upgradeService: ActionCreator<UpgradeServiceAction> = (serviceUuid : string) => ({
112   type: ServiceActions.UPGRADE_SERVICE_ACTION,
113   serviceUuid
114 });
115
116 export const undoUpgradeService: ActionCreator<UndoUpgradeServiceAction> = (serviceUuid : string) => ({
117   type: ServiceActions.UNDO_UPGRADE_SERVICE_ACTION,
118   serviceUuid
119 });