@@ -6,6 +6,8 @@ import { Subject } from 'rxjs/Subject';
6
6
import { Component , Input , Output } from '@angular/core' ;
7
7
import { KeyCodes } from 'app/shared/models/constants' ;
8
8
import { FunctionAppService } from '../shared/services/function-app.service' ;
9
+ import { FileUtilities } from '../shared/Utilities/file' ;
10
+ import { GlobalStateService } from '../shared/services/global-state.service' ;
9
11
10
12
type DownloadOption = 'siteContent' | 'vsProject' ;
11
13
@@ -22,7 +24,9 @@ export class DownloadFunctionAppContentComponent {
22
24
public currentDownloadOption : DownloadOption ;
23
25
public includeAppSettings : boolean ;
24
26
25
- constructor ( private _translateService : TranslateService , private _functionAppService : FunctionAppService ) {
27
+ constructor ( private _translateService : TranslateService ,
28
+ private _functionAppService : FunctionAppService ,
29
+ private _globalStateService : GlobalStateService ) {
26
30
this . close = new Subject < boolean > ( ) ;
27
31
this . downloadOptions = [ {
28
32
displayLabel : this . _translateService . instant ( PortalResources . downloadFunctionAppContent_siteContent ) ,
@@ -38,22 +42,15 @@ export class DownloadFunctionAppContentComponent {
38
42
downloadFunctionAppContent ( ) {
39
43
if ( this . context ) {
40
44
const includeCsProj = this . currentDownloadOption === 'siteContent' ? false : true ;
41
-
42
- // https://github.com/eligrey/FileSaver.js/blob/00e540fda507173f83a9408f1604622538d0c81a/src/FileSaver.js#L128-L136
43
- const anchor = document . createElement ( 'a' ) ;
44
- anchor . style . display = 'none' ;
45
- document . body . appendChild ( anchor ) ;
45
+ this . _globalStateService . setBusyState ( ) ;
46
+ this . closeModal ( ) ;
46
47
this . _functionAppService . getAppContentAsZip ( this . context , includeCsProj , this . includeAppSettings )
47
48
. subscribe ( data => {
48
49
if ( data . isSuccessful ) {
49
- const url = window . URL . createObjectURL ( data . result ) ;
50
- anchor . href = url ;
51
- anchor . download = `${ this . context . site . name } .zip` ;
52
- anchor . click ( ) ;
53
- window . URL . revokeObjectURL ( url ) ;
50
+ FileUtilities . saveFile ( data . result , `${ this . context . site . name } .zip` ) ;
54
51
}
55
- anchor . remove ( ) ;
56
- } ) ;
52
+ this . _globalStateService . clearBusyState ( ) ;
53
+ } , ( ) => this . _globalStateService . clearBusyState ( ) ) ;
57
54
}
58
55
}
59
56
0 commit comments