From d572b9c6a53908ca3b1c888435ba1bdea9040a83 Mon Sep 17 00:00:00 2001 From: Jakob Junck <jakob.junck@gmail.com> Date: Thu, 28 Nov 2024 21:45:08 +0100 Subject: [PATCH] Selecting OCELs seems to work. Trying to do so with one of permitted types results in an server sided error: Http failure response for http://127.0.0.1:40000/importing/loadEventLogFromFile: 500 Internal Server Error list index out of range --- example_files/example.xmlocel | 33 +++++++++++++++++++ .../header-bar/header-bar.component.html | 4 +-- .../header-bar/header-bar.component.ts | 27 +++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 example_files/example.xmlocel diff --git a/example_files/example.xmlocel b/example_files/example.xmlocel new file mode 100644 index 0000000..6ee0185 --- /dev/null +++ b/example_files/example.xmlocel @@ -0,0 +1,33 @@ +<log> + <event-types> + <event-type name="create-order"> + <attributes> + <attribute name="total-items" type="integer"/> + </attributes> + </event-type> + </event-types> + <object-types> + <object-type name="order"> + <attributes> + <attribute name="item" type="integer"/> + </attributes> + </object-type> + </object-types> + <events> + <event id="e1" type="create-order" time="2023-10-16T15:30:00Z"> + <attributes> + <attribute name="total-items">1</attribute> + </attributes> + <objects> + <relationship object-id="o1" relationship="order"/> + </objects> + </event> + </events> + <objects> + <object id="o1" type="order"> + <attributes> + <attribute name="item" time="1970-01-01T00:00:00Z">1</attribute> + </attributes> + </object> + </objects> +</log> \ No newline at end of file diff --git a/src/frontend/src/app/components/header-bar/header-bar.component.html b/src/frontend/src/app/components/header-bar/header-bar.component.html index df96389..33d1f7a 100644 --- a/src/frontend/src/app/components/header-bar/header-bar.component.html +++ b/src/frontend/src/app/components/header-bar/header-bar.component.html @@ -221,8 +221,8 @@ #fileUploadOCEL type="file" class="d-none" - (change)="handleSelectedEventLogFile($event, false)" - accept=".xes" + (change)="handleSelectedOCELFile($event, false)" + accept=".xml, .xmlocel, .json, .jsonocel, .sqlite, .sqlite3" /> <input diff --git a/src/frontend/src/app/components/header-bar/header-bar.component.ts b/src/frontend/src/app/components/header-bar/header-bar.component.ts index ae1dfa4..3112d6c 100644 --- a/src/frontend/src/app/components/header-bar/header-bar.component.ts +++ b/src/frontend/src/app/components/header-bar/header-bar.component.ts @@ -30,6 +30,7 @@ export class HeaderBarComponent implements OnDestroy { @ViewChild('fileUploadProcessTree') fileUploadProcessTree: ElementRef; @ViewChild('fileUploadProject') fileUploadProject: ElementRef; @ViewChild('fileUploadEventLogRetry') fileUploadEventLogRetry: ElementRef; + @ViewChild('fileUploadOCELRetry') fileUploadOCELRetry: ElementRef; @ViewChild('eventLogSelectionRetryModal') eventLogSelectionRetryModal: ElementRef; @@ -80,6 +81,32 @@ export class HeaderBarComponent implements OnDestroy { this.fileUploadOCEL.nativeElement.click(); } + handleSelectedOCELFile(e, isRetry = false): void { + console.log("Debug: We are importing an OCEL file.") + const fileList: FileList = e.target.files; + if (fileList.length > 0) { + console.log("Debug: fileList.length > 0. Sending", fileList[0], fileList[0]["path"]) + let backendCall; + if (!environment.electron) { + console.log('Debug: Electron is not the detected environment, using uploadEventLog.'); + backendCall = this.backendService.uploadEventLog(fileList[0]); + } else { + console.log('Debug: Electron environment detected, using loadEventLogFromFilePath.'); + backendCall = this.backendService.loadEventLogFromFilePath(fileList[0]['path']); + } + this.loadingOverlayService.showLoader( + 'Importing OCEL. For large logs this can take up to several minutes' + ); + backendCall.subscribe(() => { + this.loadingOverlayService.hideLoader(); + }); + } + + // reset form + if (isRetry) this.fileUploadEventLogRetry.nativeElement.value = ''; + else this.fileUploadEventLog.nativeElement.value = ''; + } + handleSelectedEventLogFile(e, isRetry = false): void { const fileList: FileList = e.target.files; if (fileList.length > 0) { -- GitLab