Skip to content

Commit f2455e9

Browse files
committed
Add filtering view and download results. Fixes view part of #3
1 parent a50c890 commit f2455e9

File tree

1 file changed

+45
-2
lines changed
  • viplab-standalone-frontend-vue/src/pages/viplab

1 file changed

+45
-2
lines changed

viplab-standalone-frontend-vue/src/pages/viplab/App.vue

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@
489489
<h3>Files to Download</h3>
490490
<ul>
491491
<li
492-
v-for="artifact in returnedUnmodifiedArtifacts.artifacts"
492+
v-for="(artifact) in filteredDownloadArtifacts(returnedUnmodifiedArtifacts.artifacts)"
493493
:key="artifact.identifier+'Download'"
494494
>
495495
<a
@@ -1426,7 +1426,50 @@ export default {
14261426
},
14271427
filteredArtifacts(artifactsArray) {
14281428
const availableMIMEtypes = ['text/plain', 'text/uri-list', 'application/json', 'image/png', 'image/jpeg', 'application/x-vgf', 'application/x-vgf3', 'application/x-vgfc', 'text/csv', 'application/vnd.kitware'];
1429-
const filtered = artifactsArray.filter((artifact) => (availableMIMEtypes.indexOf(artifact.MIMEtype) > -1));
1429+
let filenamefilter = [];
1430+
// TODO replace with es2020 syntax
1431+
if (typeof this.json.metadata !== 'undefined') {
1432+
if (typeof this.json.metadata.output !== 'undefined') {
1433+
if (typeof this.json.metadata.output.ignore !== 'undefined') {
1434+
if (typeof this.json.metadata.output.ignore.visualization !== 'undefined') {
1435+
filenamefilter = this.json.metadata.output.ignore.visualization.map(filename => {
1436+
let w = filename.replace(/[.+^${}()|[\]\\]/g, '\\$&'); // regexp escape
1437+
return new RegExp(`^${w.replace(/\*/g,'.*').replace(/\?/g,'.')}$`);
1438+
}
1439+
);
1440+
}
1441+
}
1442+
}
1443+
}
1444+
const filtered = artifactsArray.filter((artifact) => (availableMIMEtypes.indexOf(artifact.MIMEtype) > -1)).filter(artifact => {
1445+
let valid = true;
1446+
filenamefilter.forEach(filterregex => (valid = valid && !filterregex.test(artifact.path)));
1447+
return valid;
1448+
});
1449+
return filtered;
1450+
},
1451+
1452+
filteredDownloadArtifacts(artifactsArray) {
1453+
let filenamefilter = [];
1454+
// TODO replace with es2020 syntax
1455+
if (typeof this.json.metadata !== 'undefined') {
1456+
if (typeof this.json.metadata.output !== 'undefined') {
1457+
if (typeof this.json.metadata.output.ignore !== 'undefined') {
1458+
if (typeof this.json.metadata.output.ignore.download !== 'undefined') {
1459+
filenamefilter = this.json.metadata.output.ignore.download.map(filename => {
1460+
let w = filename.replace(/[.+^${}()|[\]\\]/g, '\\$&'); // regexp escape
1461+
return new RegExp(`^${w.replace(/\*/g,'.*').replace(/\?/g,'.')}$`);
1462+
}
1463+
);
1464+
}
1465+
}
1466+
}
1467+
}
1468+
const filtered = artifactsArray.filter(artifact => {
1469+
let valid = true;
1470+
filenamefilter.forEach(filterregex => (valid = valid && !filterregex.test(artifact.path)));
1471+
return valid;
1472+
});
14301473
return filtered;
14311474
},
14321475
},

0 commit comments

Comments
 (0)