diff options
author | Stone, Avi (as206k) <as206k@att.com> | 2018-04-12 16:36:39 +0300 |
---|---|---|
committer | Stone, Avi (as206k) <as206k@att.com> | 2018-04-12 16:36:39 +0300 |
commit | 9b2ceb347a3371819fcad6bbe2268203afecaf4e (patch) | |
tree | fbb5ea2c147d71dfeeec0882b215423e7b7206b4 /public/src/app/store | |
parent | 72dc8e3298d3e4315cdd9717b778671cb0b625bc (diff) |
DCAE-D fe initial commit
DCAE-D fe initial commit
Change-Id: Ica8ccb7c7ef769c969664d1e168d205eb9fc67f2
Issue-ID: SDC-1218
Signed-off-by: Stone, Avi (as206k) <as206k@att.com>
Diffstat (limited to 'public/src/app/store')
-rw-r--r-- | public/src/app/store/store.ts | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/public/src/app/store/store.ts b/public/src/app/store/store.ts new file mode 100644 index 0000000..a9f2431 --- /dev/null +++ b/public/src/app/store/store.ts @@ -0,0 +1,98 @@ +import { Injectable } from '@angular/core'; +import { observable, computed, action, toJS, reaction } from 'mobx'; +import { findIndex } from 'lodash'; + +@Injectable() +export class Store { + @observable sdcParmas; + @observable isOwner; + @observable mcUuid; + @observable cdump; + @observable tabsProperties; + @observable tabIndex = 0; + @observable isEditMode = false; + @observable loader = false; + @observable cdumpIsDirty = false; + @observable expandAdvancedSetting = []; + @observable generalflow; + @observable vfiName; + // error dialog + @observable displayErrorDialog = false; + @observable ErrorContent = []; + + // rule-engine + @observable tabParmasForRule; + @observable ruleList = new Array(); + @observable ruleEditorInitializedState; + @observable isLeftVisible; + @observable inprogress; + + @action + updateRuleInList(rule) { + console.log('current list:', toJS(this.ruleList)); + console.log('new rule', rule); + const ruleIndex = findIndex(this.ruleList, function(ruleFromList) { + console.log( + `find match rule: list - ${ruleFromList.uid}, rule - ${rule.uid}` + ); + return ruleFromList.uid === rule.uid; + }); + if (ruleIndex > -1) { + console.log('update rule'); + this.ruleList[ruleIndex] = rule; + } else { + console.log('new rule'); + this.ruleList.push(rule); + } + } + + @action + updateRuleList(listOfRules) { + this.ruleList = listOfRules; + console.log(toJS(this.ruleList)); + } + + @action + removeRuleFromList(uid) { + this.ruleList = this.ruleList.filter(item => item.uid !== uid); + } + + @action + resetRuleList() { + this.ruleList = new Array(); + } + + @action + changeStateForEditor(data) { + this.ruleEditorInitializedState = data; + } + + @action + setTabIndex(value) { + this.tabIndex = value; + } + + @action + setTabsProperties(nodes) { + this.tabsProperties = nodes.map(tabItem => { + return tabItem.properties.map(x => { + if (!x.assignment) { + x.assignment = {}; + x.assignment.value = ''; + } else if (typeof x.assignment.value === 'object') { + x.assignment.value = JSON.stringify(x.assignment.value); + } + return x; + }); + }); + nodes.map(() => { + this.expandAdvancedSetting.push(false); + }); + console.log('tabsProperties: %o', this.tabsProperties.toJS()); + } + + @computed + get configurationForm() { + return this.tabIndex >= 0 ? this.tabsProperties[this.tabIndex] : null; + } +} |