35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
|
import { Input, Component, Inject } from 'ng-metadata/core';
|
||
|
const templateUrl = require('./download-tarball-modal.component.html');
|
||
|
const styleUrl = require('./download-tarball-modal.css');
|
||
|
|
||
|
declare const FileSaver: any;
|
||
|
|
||
|
/**
|
||
|
* Initial Screen and Choice in the Config App
|
||
|
*/
|
||
|
@Component({
|
||
|
selector: 'download-tarball-modal',
|
||
|
templateUrl: templateUrl,
|
||
|
styleUrls: [ styleUrl ],
|
||
|
})
|
||
|
export class DownloadTarballModalComponent {
|
||
|
@Input('<') public loadedConfig;
|
||
|
|
||
|
constructor(@Inject('ApiService') private ApiService) {
|
||
|
|
||
|
}
|
||
|
|
||
|
private downloadTarball() {
|
||
|
const errorDisplay: Function = this.ApiService.errorDisplay(
|
||
|
'Could not save configuration. Please report this error.'
|
||
|
);
|
||
|
|
||
|
// We need to set the response type to 'blob', to ensure it's never encoded as a string
|
||
|
// (string encoded binary data can be difficult to transform with js)
|
||
|
// and to make it easier to save (FileSaver expects a blob)
|
||
|
this.ApiService.scGetConfigTarball(null, null, null, null, true).then(function(resp) {
|
||
|
FileSaver.saveAs(resp, 'quay-config.tar.gz');
|
||
|
}, errorDisplay);
|
||
|
}
|
||
|
}
|