Merge v1.1 into master_vca_intg
[osm/UI.git] / skyquake / plugins / composer / src / src / stores / ComposerAppStore.js
index 30352a5..75276d2 100644 (file)
@@ -122,9 +122,10 @@ class ComposerAppStore {
                this.fullScreenMode = false;
                this.panelTabShown = 'descriptor';
                //File manager values
-               this.files = [];
+               this.files = false;
                this.filesState = {};
                this.downloadJobs = {};
+               this.containers = [];
                //End File  manager values
                this.bindListeners({
                        onResize: PanelResizeAction.RESIZE,
@@ -201,8 +202,17 @@ class ComposerAppStore {
        }
 
        updateItem(item) {
+               const self = this;
+               let containers = [];
+               let cpNumber = 0;
                if(!document.body.classList.contains('resizing')) {
-                       this.setState({item: _.cloneDeep(item)});
+                       containers = [item].reduce(DescriptorModelFactory.buildCatalogItemFactory(CatalogDataStore.getState().catalogs), []);
+
+                       containers.filter(d => DescriptorModelFactory.isConnectionPoint(d)).forEach(d => {
+                               d.cpNumber = ++cpNumber;
+                               containers.filter(d => DescriptorModelFactory.isVnfdConnectionPointRef(d)).filter(ref => ref.key === d.key).forEach(ref => ref.cpNumber = d.cpNumber);
+                       });
+                       this.setState({containers: containers, item: _.cloneDeep(item)});
                }
                SelectionManager.refreshOutline();
        }
@@ -341,21 +351,13 @@ class ComposerAppStore {
                this.setState({showJSONViewer: false});
        }
 
-       toggleCanvasPanelTray(event) {
+       toggleCanvasPanelTray() {
                const layout = this.layout;
-               const attrMap = event.target.attributes;
-               let panelEvent = null;
-               for(let k in attrMap) {
-                       if(attrMap[k].name == 'data-event') {
-                               panelEvent = attrMap[k].nodeValue;
-                       }
-               }
-               if ((layout.bottom > 25) && ((panelEvent == this.displayedPanel) || panelEvent == 'arrow')) {
+               if (layout.bottom > 25) {
                        this.closeCanvasPanelTray();
                } else {
                        this.openCanvasPanelTray();
                }
-               this.setState({displayedPanel: panelEvent})
        }
 
        openCanvasPanelTray() {
@@ -465,18 +467,27 @@ class ComposerAppStore {
                let self = this;
                let filesState = null;
         if (self.fileMonitoringSocketID) {
-                       filesState = addInputState( _.cloneDeep(this.filesState),data);
-                       // filesState = _.merge(self.filesState, addInputState({},data));
-                       let normalizedData = normalizeTree(data);
-                       this.setState({
-                               files: {
-                                       data: _.mergeWith(normalizedData.data, self.files.data, function(obj, src) {
-                                               return _.uniqBy(obj? obj.concat(src) : src, 'name');
-                                       }),
-                                       id: self.files.id || normalizedData.id
-                               },
-                               filesState: filesState
-                       });
+               let newState = {};
+               if(data.hasOwnProperty('contents')) {
+                       filesState = addInputState( _.cloneDeep(this.filesState),data);
+                               // filesState = _.merge(self.filesState, addInputState({},data));
+                               let normalizedData = normalizeTree(data);
+                               newState = {
+                                       files: {
+                                               data: _.mergeWith(normalizedData.data, self.files.data, function(obj, src) {
+                                                       return _.uniqBy(obj? obj.concat(src) : src, 'name');
+                                               }),
+                                               id: self.files.id || normalizedData.id
+                                       },
+                                       filesState: filesState
+                               }
+               } else {
+                       newState = {
+                               files: false
+                       }
+               }
+
+                       this.setState(newState);
         }
                function normalizeTree(data) {
                        let f = {
@@ -548,7 +559,7 @@ class ComposerAppStore {
                let self = this;
                let ws = window.multiplexer.channel(id);
                let downloadJobs = _.cloneDeep(self.downloadJobs);
-               let newFiles = {};
+               let newFiles = false;
                ws.onmessage = (socket) => {
             if (self.files && self.files.length > 0) {
                 let jobs = [];
@@ -624,7 +635,6 @@ class ComposerAppStore {
        openFileManagerSockets(i) {
                let self = this;
                let item = i || self.item;
-               this.files = {data:[]};
         // this.closeFileManagerSockets();
                this.getInstance().openFileMonitoringSocket(item.id, item.uiState.type).then(function() {
         //     // self.getInstance().openDownloadMonitoringSocket(item.id);