Fixes style on export file dialogs
This commit is contained in:
parent
b8e08869e5
commit
1eb9126d8c
|
@ -87,12 +87,14 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
|
||||||
|
|
||||||
advancedClicked(dmp: DmpListingModel) {
|
advancedClicked(dmp: DmpListingModel) {
|
||||||
const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
|
const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
|
||||||
maxWidth: '400px',
|
maxWidth: '500px',
|
||||||
data: {
|
data: {
|
||||||
message: "Download as:",
|
message: "Download as:",
|
||||||
XMLButton: "XML",
|
XMLButton: "XML",
|
||||||
documentButton: "Document",
|
documentButton: "Document",
|
||||||
pdfButton: "PDF"
|
pdfButton: "PDF",
|
||||||
|
jsonButton: "JSON"
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
|
@ -102,6 +104,8 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
|
||||||
this.downloadXml(dmp.id);
|
this.downloadXml(dmp.id);
|
||||||
} else if (result == "doc") {
|
} else if (result == "doc") {
|
||||||
this.downloadDocx(dmp.id);
|
this.downloadDocx(dmp.id);
|
||||||
|
} else if (result == "json") {
|
||||||
|
this.downloadJson(dmp.id)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -199,6 +203,16 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadJson(id: string) {
|
||||||
|
this.dmpService.downloadJson(id)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(response => {
|
||||||
|
const blob = new Blob([response.body], { type: 'application/json' });
|
||||||
|
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
||||||
|
FileSaver.saveAs(blob, filename);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
getFilenameFromContentDispositionHeader(header: string): string {
|
getFilenameFromContentDispositionHeader(header: string): string {
|
||||||
const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
|
const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
|
||||||
|
|
||||||
|
|
|
@ -504,7 +504,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
||||||
|
|
||||||
advancedClicked() {
|
advancedClicked() {
|
||||||
const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
|
const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
|
||||||
maxWidth: '400px',
|
maxWidth: '500px',
|
||||||
data: {
|
data: {
|
||||||
message: "Download as:",
|
message: "Download as:",
|
||||||
XMLButton: "XML",
|
XMLButton: "XML",
|
||||||
|
|
|
@ -26,6 +26,10 @@ h4 {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h4 > span {
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
.title h4 {
|
.title h4 {
|
||||||
padding-left: 30px;
|
padding-left: 30px;
|
||||||
line-height: 2em;
|
line-height: 2em;
|
||||||
|
|
|
@ -95,7 +95,7 @@
|
||||||
</button>
|
</button>
|
||||||
</div> -->
|
</div> -->
|
||||||
<div *ngIf="this.formGroup.enabled">
|
<div *ngIf="this.formGroup.enabled">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="!formGroup.valid" class="text-uppercase mr-2">
|
<button mat-raised-button type="submit" [disabled]="!formGroup.valid" class="text-uppercase dark-theme mr-2" color="primary">
|
||||||
{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}
|
{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -314,7 +314,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
|
|
||||||
advancedClicked() {
|
advancedClicked() {
|
||||||
const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
|
const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
|
||||||
maxWidth: '400px',
|
maxWidth: '500px',
|
||||||
data: {
|
data: {
|
||||||
message: "Download as:",
|
message: "Download as:",
|
||||||
XMLButton: "XML",
|
XMLButton: "XML",
|
||||||
|
|
|
@ -109,12 +109,13 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
advancedClicked() {
|
advancedClicked() {
|
||||||
const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
|
const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
|
||||||
maxWidth: '400px',
|
maxWidth: '500px',
|
||||||
data: {
|
data: {
|
||||||
message: "Download as:",
|
message: "Download as:",
|
||||||
XMLButton: "XML",
|
XMLButton: "XML",
|
||||||
documentButton: "Document",
|
documentButton: "Document",
|
||||||
pdfButton: "PDF"
|
pdfButton: "PDF",
|
||||||
|
jsonButton: "JSON"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
|
@ -124,6 +125,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
this.downloadXml(this.dmp.id);
|
this.downloadXml(this.dmp.id);
|
||||||
} else if (result == "doc") {
|
} else if (result == "doc") {
|
||||||
this.downloadDocx(this.dmp.id);
|
this.downloadDocx(this.dmp.id);
|
||||||
|
} else if (result == "json") {
|
||||||
|
this.downloadJson(this.dmp.id)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -170,6 +173,16 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadJson(id: string) {
|
||||||
|
this.dmpService.downloadJson(id)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(response => {
|
||||||
|
const blob = new Blob([response.body], { type: 'application/json' });
|
||||||
|
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
||||||
|
FileSaver.saveAs(blob, filename);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
getFilenameFromContentDispositionHeader(header: string): string {
|
getFilenameFromContentDispositionHeader(header: string): string {
|
||||||
const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
|
const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue