diff --git a/src/scenario/scenario.js b/src/scenario/scenario.js index 8e2ceda..59b7804 100644 --- a/src/scenario/scenario.js +++ b/src/scenario/scenario.js @@ -396,14 +396,18 @@ class Scenario extends React.Component { * File modification methods ############################################## */ - getListOfFiles(fileIDs, type) { + getListOfFiles(fileIDs, types) { let fileList = ''; for (let id of fileIDs){ for (let file of this.state.files) { - if (file.id === id && (type === 'all' || file.type.includes(type))) { - fileList = fileList + '\n' + file.name; + if (file.id === id && types.some(e => file.type.includes(e))) { + if (fileList === ''){ + fileList = file.name + } else { + fileList = fileList + ';' + file.name; + } } } } @@ -414,6 +418,37 @@ class Scenario extends React.Component { return fileList; } + startPintura(configIndex){ + let config = this.state.configs[configIndex]; + + // get xml / CIM file + let files = [] + for (let id of config.fileIDs){ + for (let file of this.state.files) { + if (file.id === id && ['xml'].some(e => file.type.includes(e))) { + files.push(file); + } + } + } + + if(files.length > 1){ + // more than one CIM file... + console.warn("There is more than one CIM file selected in this component configuration. I will open them all in a separate tab.") + } + + let base_host = 'aaa.bbb.ccc.ddd/api/v2/files/' + for (let file of files) { + // endpoint param serves for download and upload of CIM file, token is required for authentication + let params = { + token: this.state.sessionToken, + endpoint: base_host + String(file.id), + } + + // TODO start Pintura for editing CIM/ XML file from here + console.warn("Starting Pintura... and nothing happens so far :-) ", params) + } + } + /* ############################################## * Render method ############################################## */ @@ -438,8 +473,14 @@ class Scenario extends React.Component { this.onConfigChecked(index, event)} width='30' /> - this.getListOfFiles(fileIDs, 'all')} /> - this.getListOfFiles(fileIDs, 'xml')} /> + this.getListOfFiles(fileIDs, ['json', 'JSON'])} /> + this.getListOfFiles(fileIDs, ['xml'])} + editButton + onEdit={(index) => this.startPintura(index)} + />