mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Add edit button to model file column, prepare placeholder for Pintura start #234
This commit is contained in:
parent
3ae503fded
commit
8fb20c2543
1 changed files with 46 additions and 5 deletions
|
@ -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 {
|
|||
<Table data={this.state.configs}>
|
||||
<TableColumn checkbox onChecked={(index, event) => this.onConfigChecked(index, event)} width='30' />
|
||||
<TableColumn title='Name' dataKey='name' />
|
||||
<TableColumn title='Configuration file(s)' dataKey='fileIDs' modifier={(fileIDs) => this.getListOfFiles(fileIDs, 'all')} />
|
||||
<TableColumn title='Model file(s)' dataKey='fileIDs' modifier={(fileIDs) => this.getListOfFiles(fileIDs, 'xml')} />
|
||||
<TableColumn title='Configuration file(s)' dataKey='fileIDs' modifier={(fileIDs) => this.getListOfFiles(fileIDs, ['json', 'JSON'])} />
|
||||
<TableColumn
|
||||
title='Model file(s)'
|
||||
dataKey='fileIDs'
|
||||
modifier={(fileIDs) => this.getListOfFiles(fileIDs, ['xml'])}
|
||||
editButton
|
||||
onEdit={(index) => this.startPintura(index)}
|
||||
/>
|
||||
<TableColumn
|
||||
title='# Output Signals'
|
||||
dataKey='outputLength'
|
||||
|
|
Loading…
Add table
Reference in a new issue