if (!download_host) {
download_host = api_server + ':' + utils.getPortForProtocol(req.protocol);
}
-
+ var input = {
+ 'external-url': download_host + '/composer/upload/' + req.query['package_id'] + '/' + req.file.filename,
+ 'package-type': package_type,
+ 'package-id': package_id,
+ 'package-path': package_path + '/' + req.file.filename
+ }
return new Promise(function(resolve, reject) {
Promise.all([
rp({
resolveWithFullResponse: true,
json: true,
body: {
- input: {
- 'external-url': download_host + '/composer/upload/' + req.query['package_id'] + '/' + req.file.filename,
- 'package-type': package_type,
- 'package-id': package_id,
- 'package-path': package_path + '/' + req.file.filename
- }
+ input: input
}
})
]).then(function(result) {
</div>
{viewButtonTabs}
<div className="CanvasPanelBody panel-body" style={{marginRight: this.props.layout.right, bottom: this.props.layout.bottom}} >
- {hasNoCatalogs ? null : viewFiles ? <FileManager files={this.props.files} type={this.props.type} item={this.props.item} filesState={this.props.filesState} /> : bodyComponent}
+ {hasNoCatalogs ? null : viewFiles ? <FileManager files={this.props.files} type={this.props.type} item={this.props.item} filesState={this.props.filesState} newPathName={this.props.newPathName} /> : bodyComponent}
</div>
{
isDescriptorView ?
panelTabShown={self.state.panelTabShown}
files={self.state.files}
filesState={self.state.filesState}
+ newPathName={self.state.newPathName}
item={self.state.item}
type={self.state.filterCatalogByTypeValue}
/>
let html = (
<div className="FileManager">
<PanelWrapper style={{flexDirection: 'column'}}>
- {self.props.files && self.props.files.id && buildList(self, self.props.files) }
+ <Panel className="addFileSection" style={{backgroundColor: 'transparent'}} no-corners>
+ <div className="inputSection">
+ <TextInput placeholder="some/path" value={this.props.newPathName} label="create a new directory" onChange={FileManagerActions.newPathNameUpdated} />
+ <Button label="Create" onClick={FileManagerActions.createDirectory} />
+ </div>
+ </Panel>
+ {self.props.files && self.props.files.id && buildList(self, self.props.files) }
</PanelWrapper>
</div>
)
function contentFolder(context, folder, path, key, inputState, updateFn, sendDownloadFileRequst, deleteFn) {
let type = context.props.type;
let id = context.props.item.id;
- const onboardDropZone = createDropZone.bind(this, FileManagerUploadDropZone.ACTIONS.onboard, '.ComposerAppAddFile.' + path.replace('/', '-'), type, id, path);
+ const onboardDropZone = createDropZone.bind(this, FileManagerUploadDropZone.ACTIONS.onboard, '.ComposerAppAddFile.' + path.replace(/\//g, '-'), type, id, path);
return (
<Panel title={path} key={key} itemClassName="nested" no-corners>
<div className="folder">
<div className="inputSection">
<label className="sqTextInput" style={{flexDirection: 'row', alignItems:'center'}}>
<span>Upload File</span>
- <Button className={'ComposerAppAddFile ' + path.replace('/', '-')} label="BROWSE"/>
+ <Button className={'ComposerAppAddFile ' + path.replace(/\//g, '-')} label="BROWSE"/>
</label>
</div>
)
constructor() {
this.generateActions('getFilelistSuccess', 'getFilelistError', 'updateFileLocationInput','sendDownloadFileRequst', 'addFileSuccess', 'addFileError','deletePackageFile','deleteFileSuccess','deleteFileError','openDownloadMonitoringSocketSuccess', 'openDownloadMonitoringSocketError',
'getFilelistSocketSuccess',
- 'openFileManagerSockets', 'closeFileManagerSockets');
+ 'openFileManagerSockets', 'closeFileManagerSockets','newPathNameUpdated', 'createDirectory');
}
}
},
addFile: function() {
return {
- remote: function(state, id, type, path, url) {
+ remote: function(state, id, type, path, url, refresh) {
return new Promise(function(resolve, reject) {
console.log('Adding file');
console.log(id, type, path, url);
let splitUrl = url.split('/');
let fileName = splitUrl[splitUrl.length -1];
+ let packagePath = refresh ? path + ((path[path.length - 1] == '/') ? '' : '/') : path + '/' + fileName;
$.ajax({
beforeSend: Utils.addAuthorizationStub,
- url: 'api/file-manager?api_server=' + utils.getSearchParams(window.location).api_server +'&package_type=' + type + '&package_id=' + id + '&package_path=' + path + '/' + fileName + '&url=' + url,
+ url: 'api/file-manager?api_server=' + utils.getSearchParams(window.location).api_server +'&package_type=' + type + '&package_id=' + id + '&package_path=' + packagePath + '&url=' + url,
success: function(data) {
resolve({
data:data,
path: path,
- fileName: fileName
+ fileName: fileName,
+ refresh: refresh
});
},
error: function(error) {
//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);
this.filesState = {};
this.downloadJobs = {};
this.containers = [];
+ this.newPathName = '';
//End File manager values
this.bindListeners({
onResize: PanelResizeAction.RESIZE,
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)
data: _.mergeWith(normalizedData.data, self.files.data, function(obj, src) {
return _.uniqBy(obj? obj.concat(src) : src, 'name');
}),
- id: self.files.id || normalizedData.id
+ id: normalizedData.id
},
filesState: filesState
}
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;
});
}
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 = () => {
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');