@@ -23,33 +23,28 @@ async function getFiles(urls: { download: string, filename: string }[]): Promise
2323
2424 // Reference : https://www.c-sharpcorner.com/article/download-multiple-file-as-zip-file-using-angular/
2525 const zip = new JSZip ( ) ;
26- urls . forEach ( ( element , index ) => {
27- fetch ( element . download )
28- . then ( ( res ) => res . blob ( ) )
29- . then ( ( blob ) => zip . file ( element . filename , blob ) )
30- . then ( ( ) => {
31- if ( index === urls . length - 1 ) {
32- zip . generateAsync ( { type : 'blob' } )
33- . then ( ( content ) => {
34- if ( content ) {
35- FileSaver . saveAs ( content , 'vrt-test-run.zip' ) ;
36- }
37- } ) ;
38- }
39- } ) ;
40-
41- // Downloads multiple images as individual files, kept it here for reference
42- // Reference : https://github.com/robertdiers/js-multi-file-download/blob/master/src/main/resources/static/index.html
43- /*
44- urls.forEach(function (e) {
45- fetch(e.download)
46- .then(res => res.blob()) // Gets the response and returns it as a blob
47- .then(blob => {
48- FileSaver.saveAs(blob, e.filename);
49- });
26+ for ( const eachUrl of urls ) {
27+ const response = await fetch ( eachUrl . download ) ;
28+ const blob = await response . blob ( ) ;
29+ zip . file ( eachUrl . filename , blob ) ;
30+ }
31+ await zip . generateAsync ( { type : 'blob' } )
32+ . then ( ( content ) => {
33+ if ( content ) {
34+ FileSaver . saveAs ( content , 'vrt-test-run.zip' ) ;
35+ }
5036 } ) ;
51- */
37+ // Downloads multiple images as individual files, kept it here for reference
38+ // Reference : https://github.com/robertdiers/js-multi-file-download/blob/master/src/main/resources/static/index.html
39+ /*
40+ urls.forEach(function (e) {
41+ fetch(e.download)
42+ .then(res => res.blob()) // Gets the response and returns it as a blob
43+ .then(blob => {
44+ FileSaver.saveAs(blob, e.filename);
45+ });
5246 });
47+ */
5348}
5449
5550async function getDetails ( id : string ) : Promise < TestRun > {
0 commit comments