diff --git a/src/components/backend-ai-session-list.ts b/src/components/backend-ai-session-list.ts index e49c12979b..d4afa77b32 100644 --- a/src/components/backend-ai-session-list.ts +++ b/src/components/backend-ai-session-list.ts @@ -1271,7 +1271,6 @@ export default class BackendAISessionList extends BackendAIPage { }, refreshTime); } this._listStatus?.hide(); - console.log(err); if (err && err.message) { this.notification.text = PainKiller.relieve(err.title); this.notification.detail = err.message; diff --git a/src/components/lablup-notification.ts b/src/components/lablup-notification.ts index cf4e4b7197..d8c50fcba8 100644 --- a/src/components/lablup-notification.ts +++ b/src/components/lablup-notification.ts @@ -177,30 +177,46 @@ export default class LablupNotification extends LitElement { * * @param {boolean} persistent - if persistent is false, the snackbar is hidden automatically after 3000ms * @param {object} log - Log object that contains detail information + * @param {string} key - notification key. If it already exists, the notification will be updated. * */ - show(persistent = false, log: Record = Object()) { + show( + persistent = false, + log: Record = Object(), + key: string, + ) { if (this.text === '_DISCONNECTED') { return; } const shouldSaveLog = Object.keys(log).length !== 0; if (shouldSaveLog) { - console.log(log); this._saveToLocalStorage('backendaiwebui.logs', log); } + const messageDetail = { + open: true, + type: shouldSaveLog ? 'error' : null, + message: this.text, + description: this.text ? undefined : this.detail, + to: shouldSaveLog ? '/usersettings?tab=logs' : this.url, + duration: persistent ? 0 : undefined, + // closeIcon: persistent, + }; + const event: CustomEvent = new CustomEvent('add-bai-notification', { detail: { - open: true, - type: shouldSaveLog ? 'error' : null, - message: this.text, - description: this.text ? undefined : this.detail, - to: shouldSaveLog ? '/usersettings?tab=logs' : this.url, - duration: persistent ? 0 : undefined, - // closeIcon: persistent, + key: + typeof key === 'undefined' && messageDetail.type === 'error' + ? `_no_key_from_lablup_notification:${JSON.stringify(messageDetail)}` + : key, + ...messageDetail, }, }); - document.dispatchEvent(event); - this._spawnDesktopNotification('Backend.AI', this.text, ''); + + // Ignore the event if the message is 'Network disconnected because it is handled by `NetworkStatusBanner` component. + if (messageDetail.message !== 'Network disconnected.') { + document.dispatchEvent(event); + this._spawnDesktopNotification('Backend.AI', this.text, ''); + } } // /** @@ -325,7 +341,6 @@ export default class LablupNotification extends LitElement { * @param {string} logMessages - Message to save * */ _saveToLocalStorage(key, logMessages) { - console.log(logMessages); const previous_log = JSON.parse(localStorage.getItem(key) || '{}'); let current_log: Array = [];