dev tools: allow download

This commit is contained in:
Denys Vuika
2018-09-01 10:08:52 +01:00
parent 8005ca19f9
commit a278ae149e
2 changed files with 25 additions and 1 deletions

View File

@@ -9,6 +9,13 @@
(click)="saveChanges()">
<mat-icon>save_alt</mat-icon>
</button>
<button
mat-icon-button
color="primary"
title="Download"
(click)="download()">
<mat-icon>cloud_download</mat-icon>
</button>
<button
mat-icon-button
color="primary"

View File

@@ -26,7 +26,9 @@ export class AcaDevToolsComponent implements OnInit {
const schemaUri = routeData.schemaUri;
const getSchema = this.http.get(routeData.schemaPath);
const getConfig = this.http.get(routeData.configPath, { responseType: 'text' });
const getConfig = this.http.get(routeData.configPath, {
responseType: 'text'
});
forkJoin([getSchema, getConfig]).subscribe(
([schema, config]) => {
@@ -69,4 +71,19 @@ export class AcaDevToolsComponent implements OnInit {
sessionStorage.removeItem('aca.extension.config');
window.location.reload(true);
}
download() {
const element = document.createElement('a');
element.setAttribute(
'href',
'data:text/plain;charset=utf-8,' + encodeURIComponent(this.code)
);
element.setAttribute('download', 'plugin.json');
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
}