397
397
ref =" outPartcontent"
398
398
class =" outPartcontent"
399
399
>
400
- <Promised :promise =" getContentFromS3(artifact.url, false)" >
401
- <!-- Use the "pending" slot to display a loading message -->
402
- <template v-slot :pending >
403
- <p >Loading...</p >
404
- </template >
405
- <!-- The default scoped slot will be used as the result -->
406
- <template v-slot =" data " >
407
- <div >
400
+ <div v-if =" promiseError.get(artifact.url)" >
401
+ Error: {{ promiseError.get(artifact.url).message }}
402
+ </div >
403
+ <div v-else-if =" isLoading.get(artifact.url)" >
404
+ Loading...
405
+ </div >
406
+ <div v-else-if =" !isLoading.get(artifact.url)" >
408
407
<ace-editor-component
409
408
:isParameter =" false"
410
409
:isMustache =" false"
411
410
:readonly =" true"
412
411
:lang =" (artifact.MIMEtype == 'application/json') ? 'json' : 'text'"
413
412
:item =' {
414
413
"identifier" : "Editor" + artifact.identifier,
415
- "content" : base64url(data ),
414
+ "content" : s3Contents.get(artifact.url ),
416
415
"path" : artifact.path
417
416
}'
418
417
:ref =" artifact.path"
419
418
></ace-editor-component >
420
- </div >
421
- </template >
422
- <template v-slot :rejected =" error " >
423
- <p >Error: {{ error.message }}</p >
424
- </template >
425
- </Promised >
419
+ </div >
420
+
426
421
</div >
427
422
<div v-else-if =" artifact.MIMEtype == 'text/csv'" >
428
423
<div v-if =" artifact.plots" >
445
440
</div >
446
441
</div >
447
442
<div v-else-if =" artifact.MIMEtype == 'image/png' || artifact.MIMEtype == 'image/jpeg'" >
448
- <Promised :promise =" getContentFromS3(artifact.url, true)" >
449
- <!-- Use the "pending" slot to display a loading message -->
450
- <template v-slot :pending >
451
- <p >Loading...</p >
452
- </template >
453
- <!-- The default scoped slot will be used as the result -->
454
- <template v-slot =" data " >
455
- <img
456
- :src =" data"
457
- :ref =" artifact.path" />
458
- </template >
459
- <template v-slot :rejected =" error " >
460
- <p >Error: {{ error.message }}</p >
461
- </template >
462
- </Promised >
443
+ <img
444
+ :src =" artifact.url"
445
+ :ref =" artifact.path" />
463
446
</div >
464
447
<div v-else >
465
- <Promised :promise =" getContentFromS3(artifact.url, false)" >
466
- <!-- Use the "pending" slot to display a loading message -->
467
- <template v-slot :pending >
468
- <p >Loading...</p >
469
- </template >
470
- <!-- The default scoped slot will be used as the result -->
471
- <template v-slot =" data " >
472
- <!-- Render ViPLabGraphics whose files need to be downloaded from S3 -->
473
- <!-- show viplab grid plot -->
474
- <div >
448
+
449
+ <div v-if =" promiseError.get(artifact.url)" >
450
+ Error: {{ promiseError.get(artifact.url).message }}
451
+ </div >
452
+ <div v-else-if =" isLoading.get(artifact.url)" >
453
+ Loading...
454
+ </div >
455
+ <div v-else-if =" !isLoading.get(artifact.url)" >
456
+ <div >
475
457
<div
476
458
v-if =" artifact.MIMEtype === 'application/x-vgfc'"
477
459
ref =" outPartcontent"
478
460
class =" outPartcontent"
479
461
>
480
-
481
- <grid-plot :plotData =" data" ></grid-plot >
462
+ <grid-plot :plotData =" s3Contents.get(artifact.url)" ></grid-plot >
482
463
</div >
483
464
<!-- show viplab 2d plot -->
484
465
<div
485
466
v-if =" artifact.MIMEtype === 'application/x-vgf'"
486
467
ref =" outPartcontent"
487
468
class =" outPartcontent"
488
469
>
489
- <plot-2d :plotData =" data " ></plot-2d >
470
+ <plot-2d :plotData =" s3Contents.get(artifact.url) " ></plot-2d >
490
471
</div >
491
472
</div >
492
- </template >
493
- <template v-slot :rejected =" error " >
494
- <p >Error: {{ error.message }}</p >
495
- </template >
496
- </Promised >
473
+ </div >
474
+
497
475
</div >
498
476
</div >
499
477
</b-tab >
@@ -559,8 +537,6 @@ import CsvPlot from '../../components/csv-plots/CsvPlot.vue';
559
537
560
538
import AnsiOutput from " ../../components/AnsiOutput.vue" ;
561
539
562
- import {Promised } from " vue-promised" ;
563
-
564
540
const Handlebars = require (' handlebars' );
565
541
566
542
import {ValidationObserver } from " vee-validate" ;
@@ -578,7 +554,6 @@ export default {
578
554
VtkComponent,
579
555
Plot2d,
580
556
CsvPlot,
581
- Promised,
582
557
ValidationObserver,
583
558
AceEditorComponent,
584
559
AnsiOutput
@@ -597,7 +572,10 @@ export default {
597
572
asForm: true ,
598
573
isPartParameters: 0 ,
599
574
waitingResponse: false ,
600
- statusMessage: { " timestamp" : " 2022-04-21T06:30+01:00" , " message" : " Waiting..." }
575
+ statusMessage: { " timestamp" : " 2022-04-21T06:30+01:00" , " message" : " Waiting..." },
576
+ s3Contents: new Map (),
577
+ isLoading: new Map (),
578
+ promiseError: new Map (),
601
579
};
602
580
},
603
581
watch: {
@@ -666,7 +644,7 @@ export default {
666
644
}
667
645
}
668
646
return false ;
669
- }
647
+ },
670
648
},
671
649
methods: {
672
650
// Make the function wait until the connection is made...
@@ -707,8 +685,13 @@ export default {
707
685
this .$store .commit (" updateDataTemplate" , data);
708
686
} else if (Object .keys (this .$store .state .jsonTemplate ).length > 0 ) {
709
687
console .log (" 2" )
710
- this .json = this .$store .state .jsonTemplate ;
711
- this .dataTemplate = this .$store .state .dataTemplate ;
688
+ if (data && (data === " {{ data }}" || data === " " )) {
689
+ this .json = this .$store .state .jsonTemplate ;
690
+ this .dataTemplate = this .$store .state .dataTemplate ;
691
+ } else {
692
+ this .json = JSON .parse (base64url .decode (data));
693
+ this .$store .commit (" updateDataTemplate" , data);
694
+ }
712
695
} else {
713
696
console .log (" 3" )
714
697
this .json = {};
@@ -718,7 +701,11 @@ export default {
718
701
if (token && token !== " {{ token }}" && token !== " " && this .$store .state .token .length === 0 ) {
719
702
this .$store .commit (" updateToken" , appDiv .getAttribute (" data-token" ));
720
703
} else if (this .$store .state .token .length > 0 ) {
721
- this .token = this .$store .state .token ;
704
+ if (token && (token === " {{ token }}" || token === " " )) {
705
+ this .token = this .$store .state .token ;
706
+ } else {
707
+ this .$store .commit (" updateToken" , appDiv .getAttribute (" data-token" ));
708
+ }
722
709
} else {
723
710
this .token = " " ;
724
711
}
@@ -933,8 +920,6 @@ export default {
933
920
document .getElementById (" submit" ).disabled = false ;
934
921
}
935
922
936
- console .log (" displayResult " + this .returnedOutputJson )
937
-
938
923
// if the first result came back, set the whole object, else, only add the new artifacts to the existing object
939
924
// use JSON.parse(JSON.stringify(...)) to make sure a copy of the data is made, such that not only a reference is used
940
925
if (this .returnedOutputJson === " " ) {
@@ -1116,32 +1101,51 @@ export default {
1116
1101
return value;
1117
1102
}
1118
1103
});
1104
+
1105
+ for (let a in this .returnedOutputJson .artifacts ) {
1106
+ let currentArtifact = this .returnedOutputJson .artifacts [a]
1107
+ if (currentArtifact .type === " s3file" ) {
1108
+ if (currentArtifact .MIMEtype === " text/plain" || currentArtifact .MIMEtype === " application/json" ) {
1109
+ this .getContentFromS3 (currentArtifact .url )
1110
+ } else if (currentArtifact .MIMEtype === " application/x-vgf" || currentArtifact .MIMEtype === " application/x-vgf3" || currentArtifact .MIMEtype === " application/x-vgfc" ) {
1111
+ this .getContentFromS3 (currentArtifact .url , true )
1112
+ }
1113
+ }
1114
+ }
1119
1115
1120
1116
// TODO: Vars nicht überschreiben, sondern ergänzen für intermediate
1121
1117
this .outputFiles = base64url .decode (result .result .output .stdout );
1122
1118
this .errorFiles = base64url .decode (result .result .output .stderr );
1123
1119
},
1124
- /** get content from s3 if it is an image, process differently */
1125
- async getContentFromS3 (url , image ) {
1126
- const response = await fetch (url, {
1127
- method: ' GET' ,
1128
- });
1129
- var test = null ;
1130
- if (image) {
1131
- test = await response .blob ().then (imageBlob => {
1132
- let imagesrc = URL .createObjectURL (imageBlob);
1133
- return imagesrc;
1134
- });
1135
- } else {
1136
- test = await response .text ();
1137
- }
1138
-
1139
- if (response .status >= 200 && response .status < 300 ) {
1140
- return Promise .resolve (test);
1141
- } else {
1142
- return Promise .reject (new Error (" Unable to complete request for: " + url));
1143
- }
1120
+ /** get content from s3 */
1121
+ async getContentFromS3 (url , isViPLabGraphics = false ) {
1122
+ this .isLoading .set (url, true )
1123
+ this .promiseError .set (url, null )
1144
1124
1125
+ fetch (url, { method: ' GET' })
1126
+ .then ((response ) => {
1127
+ if (response .ok ) {
1128
+ return response .text ();
1129
+ }
1130
+ throw new Error (' Something went wrong' );
1131
+ })
1132
+ .then ((responseText ) => {
1133
+ if (! isViPLabGraphics) {
1134
+ this .s3Contents .set (url, base64url (responseText));
1135
+ } else {
1136
+ this .s3Contents .set (url, responseText);
1137
+ }
1138
+ })
1139
+ .catch ((error ) => {
1140
+ console .log (" catch" )
1141
+ this .promiseError .set (url, error);
1142
+
1143
+ })
1144
+ .finally (() => {
1145
+ this .isLoading .set (url, false );
1146
+ this .$forceUpdate ();
1147
+ });
1148
+
1145
1149
},
1146
1150
/** return base64 image src for img-tag*/
1147
1151
imagesrc : function (base64Image , mimetype ) {
@@ -1433,7 +1437,7 @@ export default {
1433
1437
let 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" ]
1434
1438
let filtered = artifactsArray .filter (artifact => (availableMIMEtypes .indexOf (artifact .MIMEtype ) > - 1 ));
1435
1439
return filtered;
1436
- }
1440
+ },
1437
1441
},
1438
1442
created () {
1439
1443
this .loadJsonFromFile ();
0 commit comments