1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
import {Injectable} from "@angular/core";
import {ITreeNode} from "angular-tree-component/dist/defs/api";
import * as _ from 'lodash';
import {NgRedux} from "@angular-redux/store";
import {AppState} from "../../../shared/store/reducers";
import {FeatureFlagsService, Features} from "../../../shared/services/featureFlag/feature-flags.service";
import {ServiceInstanceActions} from "../../../shared/models/serviceInstanceActions";
@Injectable()
export class DrawingBoardTreeService {
constructor(private store: NgRedux<AppState>){}
isVFModuleMissingData(node: ITreeNode, serviceModelId : string): boolean {
if(node.data.type === 'VFmodule' &&!_.isNil(this.store.getState().service.serviceInstance[serviceModelId].vnfs) && !_.isNil(this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.parent.data.vnfStoreKey])){
if(!_.isNil(this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.parent.data.vnfStoreKey].vfModules)
&& !_.isNil(this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.parent.data.vnfStoreKey].vfModules[node.data.modelName])
&& !_.isNil(this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.parent.data.vnfStoreKey].vfModules[node.data.modelName][node.data.dynamicModelName])){
return this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.parent.data.vnfStoreKey].vfModules[node.data.modelName][node.data.dynamicModelName].isMissingData;
}
}
return false;
}
isVNFMissingData(node : ITreeNode, serviceModelId : string) : boolean {
if(node.data.type == 'VF' && !_.isNil(this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.data.vnfStoreKey])){
return this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.data.vnfStoreKey].isMissingData;
}
}
isViewEditFlagTrue():boolean{
return FeatureFlagsService.getFlagState(Features.FLAG_1902_NEW_VIEW_EDIT, this.store);
}
/**********************************************
return all drawing board context menu options
***********************************************/
generateContextMenuOptions() : TreeNodeContextMenuModel[]{
return [
new TreeNodeContextMenuModel('edit', 'context-menu-edit', 'Edit', 'edit-file-o'),
new TreeNodeContextMenuModel('duplicate', 'context-menu-duplicate', 'Duplicate', 'copy-o'),
new TreeNodeContextMenuModel('showAuditInfo', 'context-menu-showAuditInfo', 'Show audit info', 'eye-o'),
new TreeNodeContextMenuModel('addGroupMember', 'context-menu-addGroupMember', 'Add group members', 'plus'),
new TreeNodeContextMenuModel('delete', 'context-menu-delete', 'Delete', 'trash-o'),
new TreeNodeContextMenuModel('remove', 'context-menu-remove', 'Remove', 'trash-o'),
new TreeNodeContextMenuModel('undoDelete', 'context-menu-undoDelete', 'Undo Delete', 'undo-delete')
];
}
/*******************************************************************
delete or remove all service child's on delete existing service
*******************************************************************/
deleteActionService(nodes : ITreeNode[], serviceModelId : string){
if(!_.isNil(nodes)){
for(let node of nodes){
node.data = node;
if(!_.isNil(node.children)){
node.children.map((child)=>{
child.data = child;
child.parent = node;
});
}
let menuActionsName : string = node.data.action === ServiceInstanceActions.Create ? 'remove' : 'delete';
if(!_.isNil(node.data.menuActions) && !_.isNil(node.data.menuActions[menuActionsName])){
node.data.menuActions[menuActionsName]['method'](node, serviceModelId)
}
}
}
}
/*******************************************************************
undo delete all service child's on undo delete existing service
*******************************************************************/
undoDeleteActionService(nodes : ITreeNode[], serviceModelId : string){
if(!_.isNil(nodes)){
for(let node of nodes){
node.data = node;
if(!_.isNil(node.children)){
node.children.map((child)=>{
child.data = child;
child.parent = node;
});
}
if(!_.isNil(node.data.menuActions) && !_.isNil(node.data.menuActions['undoDelete'])){
node.data.menuActions['undoDelete']['method'](node, serviceModelId)
}
}
}
}
/***********************************************************
return true if should add line hover the instance name
***********************************************************/
isTextDecoration(node) : boolean{
return !_.isNil(node.data) && !_.isNil(node.data.action) && node.data.action.split('_').pop() === 'Delete';
}
/******************************************
should create object of instances action
******************************************/
generateServiceActionObject(nodes){
let obj = {};
let index = 0;
for(let node of nodes){
obj[index] = {};
index++;
}
}
}
export class TreeNodeContextMenuModel {
methodName: string;
dataTestId: string;
label: string;
iconClass: string;
constructor(methodName: string,
dataTestId: string,
label: string,
iconClass: string) {
this.methodName = methodName;
this.dataTestId = dataTestId;
this.label = label;
this.iconClass = iconClass;
}
}
|