From baa97f189f7fb117b1ca9b83352cf59952f639ee Mon Sep 17 00:00:00 2001 From: Edward Moyse Date: Fri, 29 Nov 2024 16:38:24 +0100 Subject: [PATCH 1/3] Improve output, better messaging if file missing --- .../src/managers/url-options-manager.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/phoenix-event-display/src/managers/url-options-manager.ts b/packages/phoenix-event-display/src/managers/url-options-manager.ts index b5639ba1..3e11ebe6 100644 --- a/packages/phoenix-event-display/src/managers/url-options-manager.ts +++ b/packages/phoenix-event-display/src/managers/url-options-manager.ts @@ -77,23 +77,24 @@ export class URLOptionsManager { } if (!this.urlOptions.get('file') || !this.urlOptions.get('type')) { - console.log('Setting and config from defaults'); file = defaultEventPath; type = defaultEventType; } else { - console.log('Setting and config from urlOptions'); file = this.urlOptions.get('file') ?? ''; type = this.urlOptions.get('type')?.toLowerCase() ?? ''; + console.log('Default file(',defaultEventPath,') was overridden by URL options to: ', file ); + } - console.log('Loading ', file, 'of type', type); - // Load config from URL + console.log('Try to load event file: ', file, 'of type', type); + // Try to load config from URL const loadConfig = () => { if (this.urlOptions.get('config')) { this.eventDisplay.getLoadingManager().addLoadableItem('url_config'); fetch(this.urlOptions.get('config') ?? '') .then((res) => res.json()) .then((jsonState) => { + console.log("Applying configuration ", this.urlOptions.get('config'), " from urlOptions"); const stateManager = new StateManager(); stateManager.loadStateFromJSON(jsonState); }) @@ -141,7 +142,12 @@ export class URLOptionsManager { * @returns An empty promise. ;( */ private async handleJiveXMLEvent(fileURL: string) { - const fileData = await (await fetch(fileURL)).text(); + const fileData = await (await fetch(fileURL).then((response) => { + if (response.status >= 400 && response.status < 600) { + throw new Error("Bad response from server"); + } + return response; + })).text(); if (!this.configuration.eventDataLoader) { this.configuration.eventDataLoader = new JiveXMLLoader(); } From fbe001a88a8cdbc3b606f5e68fb50bf8ff2d053a Mon Sep 17 00:00:00 2001 From: Edward Moyse Date: Fri, 29 Nov 2024 16:39:12 +0100 Subject: [PATCH 2/3] Fix for #570 - togglestate is only saved if true, so absence is false --- .../src/managers/ui-manager/phoenix-menu/phoenix-menu-node.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/phoenix-event-display/src/managers/ui-manager/phoenix-menu/phoenix-menu-node.ts b/packages/phoenix-event-display/src/managers/ui-manager/phoenix-menu/phoenix-menu-node.ts index 01a15618..562c1312 100644 --- a/packages/phoenix-event-display/src/managers/ui-manager/phoenix-menu/phoenix-menu-node.ts +++ b/packages/phoenix-event-display/src/managers/ui-manager/phoenix-menu/phoenix-menu-node.ts @@ -206,8 +206,8 @@ export class PhoenixMenuNode { this.childrenActive = jsonObject['childrenActive']; this.toggleState = jsonObject['toggleState']; - // eslint-disable-next-line - this.toggleState !== undefined && this.onToggle?.(this.toggleState); + + this.onToggle?.(this.toggleState); for (const configState of jsonObject['configs']) { const nodeConfigs = this.configs.filter( From dfd23bac097034554e99ee448955b7a5ad9bd7e1 Mon Sep 17 00:00:00 2001 From: Edward Moyse Date: Fri, 29 Nov 2024 16:50:11 +0100 Subject: [PATCH 3/3] Linting fixes --- .../src/managers/url-options-manager.ts | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/phoenix-event-display/src/managers/url-options-manager.ts b/packages/phoenix-event-display/src/managers/url-options-manager.ts index 3e11ebe6..74cb7e47 100644 --- a/packages/phoenix-event-display/src/managers/url-options-manager.ts +++ b/packages/phoenix-event-display/src/managers/url-options-manager.ts @@ -82,8 +82,12 @@ export class URLOptionsManager { } else { file = this.urlOptions.get('file') ?? ''; type = this.urlOptions.get('type')?.toLowerCase() ?? ''; - console.log('Default file(',defaultEventPath,') was overridden by URL options to: ', file ); - + console.log( + 'Default file(', + defaultEventPath, + ') was overridden by URL options to: ', + file, + ); } console.log('Try to load event file: ', file, 'of type', type); @@ -94,7 +98,11 @@ export class URLOptionsManager { fetch(this.urlOptions.get('config') ?? '') .then((res) => res.json()) .then((jsonState) => { - console.log("Applying configuration ", this.urlOptions.get('config'), " from urlOptions"); + console.log( + 'Applying configuration ', + this.urlOptions.get('config'), + ' from urlOptions', + ); const stateManager = new StateManager(); stateManager.loadStateFromJSON(jsonState); }) @@ -142,12 +150,14 @@ export class URLOptionsManager { * @returns An empty promise. ;( */ private async handleJiveXMLEvent(fileURL: string) { - const fileData = await (await fetch(fileURL).then((response) => { - if (response.status >= 400 && response.status < 600) { - throw new Error("Bad response from server"); - } - return response; - })).text(); + const fileData = await ( + await fetch(fileURL).then((response) => { + if (response.status >= 400 && response.status < 600) { + throw new Error('Bad response from server'); + } + return response; + }) + ).text(); if (!this.configuration.eventDataLoader) { this.configuration.eventDataLoader = new JiveXMLLoader(); }