Skip to content

Commit

Permalink
Fix: frontend works with intermediate results
Browse files Browse the repository at this point in the history
  • Loading branch information
aseeland committed Sep 12, 2023
1 parent 98ef7db commit 0c5e5a9
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions viplab-standalone-frontend-vue/src/pages/viplab/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1054,10 +1054,20 @@ export default {
// process connected vtu/vtk & csv files
let connectedVtks = {};
let { artifacts } = this.returnedOutputJson;
// let created = false;
// isNew flag to ensure that connected files are only added once
artifacts.forEach( (artifact) => {
if (artifact.basename) {
connectedVtks[artifact.basename] = artifact;
connectedVtks[artifact.basename].isNew = false;
}
});
// sort result artifacts alphabetically to make sure that connected files are in correct order
artifacts.sort((a, b) => a.path.localeCompare(b.path));
artifacts.sort((a, b) => {
let a_path = a.path ?? a.basename;
let b_path = b.path ?? b.basename;
return a_path.localeCompare(b_path);
});
// get basenames for collections of files
let outputConfig = [];
Expand Down Expand Up @@ -1088,12 +1098,14 @@ export default {
connectedVtks[currentBasename].urlsOrContents = [];
connectedVtks[currentBasename].plots = currentConfig.plots;
connectedVtks[currentBasename].xlabel = currentConfig.xlabel;
connectedVtks[currentBasename].isConnected = true;
connectedVtks[currentBasename].isNew = true;
}
}
// group results according to the available basenames
for (let a = 0; a < artifacts.length; a += 1) {
if ((artifacts[a].MIMEtype === 'application/vnd.kitware' || artifacts[a].MIMEtype === 'text/csv') && !artifacts[a].artifacts) {
if ((artifacts[a].MIMEtype === 'application/vnd.kitware' || artifacts[a].MIMEtype === 'text/csv') && !artifacts[a].isConnected) {
const { path } = artifacts[a];
const lastIndex = path.lastIndexOf('/');
const filenamePart = path.substr(lastIndex + 1, path.length);
Expand All @@ -1102,7 +1114,6 @@ export default {
const currentBasename = basenames[base];
// filename has to start with basename
if (filenamePart.startsWith(currentBasename)) {
// console.log(currentBasename + " - " + filenamePart);
connectedVtks[currentBasename].type = artifacts[a].type;
connectedVtks[currentBasename].MIMEtype = artifacts[a].MIMEtype;
connectedVtks[currentBasename].basename = currentBasename;
Expand Down Expand Up @@ -1130,7 +1141,7 @@ export default {
// delete all vtk and csv artifacts that are part of a collection
artifacts = this.returnedOutputJson.artifacts;
let b = artifacts.length - 1;
while (b > 0) {
while (b >= 0) {
if (artifacts[b].inCollection) {
artifacts.splice(b, 1);
}
Expand All @@ -1140,7 +1151,9 @@ export default {
// add vtk/csv collections
const connectedFilesKeys = Object.keys(connectedVtks);
for (let c = 0; c < connectedFilesKeys.length; c += 1) {
this.returnedOutputJson.artifacts.push(connectedVtks[connectedFilesKeys[c]]);
if (connectedVtks[connectedFilesKeys[c]].isNew && connectedVtks[connectedFilesKeys[c]].urlsOrContents.length > 0) {
this.returnedOutputJson.artifacts.push(connectedVtks[connectedFilesKeys[c]]);
}
}
}
Expand All @@ -1160,9 +1173,9 @@ export default {
}
});
// TODO: Vars nicht überschreiben, sondern ergänzen für intermediate
this.outputFiles = this.outputFiles.concat(base64url.decode(result.result.output.stdout));
this.errorFiles = this.errorFiles.concat(base64url.decode(result.result.output.stderr));
this.$forceUpdate();
},
/** get content from s3 */
async getContentFromS3(url, isViPLabGraphics = false) {
Expand Down

0 comments on commit 0c5e5a9

Please sign in to comment.