X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Fcomposer%2Fsrc%2Fsrc%2Fstores%2FComposerAppStore.js;h=ff24cbb926f748e4c882771380c15a43b47f7e74;hp=4f278680ca85c5775a773fbf16deeeb802c99fbc;hb=6620bca06b9874e68e8bc11ce28b7a6eeda5cc03;hpb=4e7b00465d087292dc6127bc892a5fa3a64365b6 diff --git a/skyquake/plugins/composer/src/src/stores/ComposerAppStore.js b/skyquake/plugins/composer/src/src/stores/ComposerAppStore.js index 4f278680c..ff24cbb92 100644 --- a/skyquake/plugins/composer/src/src/stores/ComposerAppStore.js +++ b/skyquake/plugins/composer/src/src/stores/ComposerAppStore.js @@ -41,6 +41,9 @@ import React from 'react'; //Hack for crouton fix. Should eventually put composer in skyquake alt context import SkyquakeComponent from 'widgets/skyquake_container/skyquakeComponent.jsx'; let NotificationError = null; + +import utils from '../libraries/utils'; + class ComponentBridge extends React.Component { constructor(props) { super(props); @@ -122,9 +125,11 @@ class ComposerAppStore { this.fullScreenMode = false; this.panelTabShown = 'descriptor'; //File manager values - this.files = []; + this.files = false; this.filesState = {}; this.downloadJobs = {}; + this.containers = []; + this.newPathName = ''; //End File manager values this.bindListeners({ onResize: PanelResizeAction.RESIZE, @@ -163,7 +168,9 @@ class ComposerAppStore { closeFileManagerSockets: FileManagerActions.closeFileManagerSockets, openFileManagerSockets: FileManagerActions.openFileManagerSockets, openDownloadMonitoringSocketSuccess: FileManagerActions.openDownloadMonitoringSocketSuccess, - getFilelistSocketSuccess: FileManagerActions.getFilelistSocketSuccess + getFilelistSocketSuccess: FileManagerActions.getFilelistSocketSuccess, + newPathNameUpdated: FileManagerActions.newPathNameUpdated, + createDirectory: FileManagerActions.createDirectory }); this.exportPublicMethods({ closeFileManagerSockets: this.closeFileManagerSockets.bind(this) @@ -201,14 +208,24 @@ 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(); } editCatalogItem(item) { let self = this; + self.closeFileManagerSockets(); if (item && item.uiState) { item.uiState.isOpenForEdit = true; if (item.uiState.type !== 'nsd') { @@ -456,18 +473,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: normalizedData.id + }, + filesState: filesState + } + } else { + newState = { + files: false + } + } + + this.setState(newState); } function normalizeTree(data) { let f = { @@ -507,7 +533,7 @@ class ComposerAppStore { let type = data.type || this.item.uiState.type; let path = data.path; let url = data.url; - this.getInstance().addFile(id, type, path, url); + this.getInstance().addFile(id, type, path, url, data.refresh); } updateFileLocationInput = (data) => { let name = data.name; @@ -519,14 +545,16 @@ class ComposerAppStore { }); } addFileSuccess = (data) => { - let path = data.path; - let fileName = data.fileName; - let files = _.cloneDeep(this.files); - let loadingIndex = files.data[path].push({ - status: 'DOWNLOADING', - name: path + '/' + fileName - }) - 1; - this.setState({files: files}); + if(!data.refresh) { + let path = data.path; + let fileName = data.fileName; + let files = _.cloneDeep(this.files); + let loadingIndex = files.data[path].push({ + status: 'DOWNLOADING', + name: path + '/' + fileName + }) - 1; + this.setState({files: files}); + } } startWatchingJob = () => { @@ -539,7 +567,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 = []; @@ -615,7 +643,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); @@ -644,6 +671,25 @@ class ComposerAppStore { files: files }) } + newPathNameUpdated = (event) => { + const value = event.target.value; + this.setState({ + newPathName: value + }) + } + createDirectory = () => { + console.log(this.newPathName); + this.sendDownloadFileRequst({ + id: this.item.id, + type: this.item.uiState.type, + path: this.item.name + '/' + this.newPathName, + url: utils.getSearchParams(window.location).dev_download_server || window.location.protocol + '//' + window.location.host, + refresh: true + }); + this.setState({ + newPathName: '' + }) + } } export default alt.createStore(ComposerAppStore, 'ComposerAppStore');