Enables uploading of XML files with different (or no) file type

This commit is contained in:
Aaron Louie 2020-01-14 16:29:34 -05:00
parent 60841c85b6
commit 91f5a3782a
2 changed files with 9 additions and 2 deletions

View File

@ -62,7 +62,7 @@
<input matInput disabled [value]="getFileName()" type="text">
<mat-icon matSuffix>folder_open</mat-icon>
</mat-form-field>
<input hidden (change)="onFileSelected($event)" #fileInput type="file" id="file" accept="text/xml">
<input hidden (change)="onFileSelected($event)" #fileInput type="file" id="file" accept=".bpmn,.xml,application/xml,text/xml">
</ng-container>
<ng-container *ngIf="openMethod === 'url'">
<mat-form-field>

View File

@ -76,7 +76,7 @@ export class AppComponent implements AfterViewInit {
if (this.openMethod === 'url') {
this.diagramComponent.loadUrl(this.diagramUrl);
} else {
if (this.diagramFile && this.diagramFile.type === 'text/xml') {
if (this.diagramFile && this.isXmlFile(this.diagramFile)) {
this.readFile(this.diagramFile);
} else {
this.handleImported({
@ -254,4 +254,11 @@ export class AppComponent implements AfterViewInit {
Version: ${fileMeta.version}
`;
}
private isXmlFile(file: File) {
return file.type === 'text/xml' ||
file.type === 'application/xml' ||
file.name.slice(-5) === '.bpmn' ||
file.name.slice(-4) === '.xml';
}
}