Skip to content

Commit

Permalink
fix: altered no nsdoc file warning message
Browse files Browse the repository at this point in the history
Signed-off-by: Stef3st <[email protected]>
  • Loading branch information
Stef3st committed Feb 13, 2024
1 parent f38bf48 commit 148eed8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
14 changes: 14 additions & 0 deletions packages/compas-open-scd/src/compas-services/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ export function createLogEvent(element: Element, reason: any): void {
}
}

export function createNSDocLogEvent(element: Element, fileName: string): void {
if (element) {
element.dispatchEvent(
newLogEvent({
kind: 'warning',
title: get('compas.warning.nsdoc'),
message: get('compas.warning.nsdocDetails', {
fileName: fileName,
}),
})
);
}
}

export function getWebsocketUri(settingsUrl: string): string {
if (settingsUrl.startsWith('http://') || settingsUrl.startsWith('https://')) {
return settingsUrl
Expand Down
9 changes: 6 additions & 3 deletions packages/compas-open-scd/src/compas/CompasNsdoc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { newLoadNsdocEvent } from '../Setting.js';

import { createLogEvent } from '../compas-services/foundation.js';
import {
createLogEvent,
createNSDocLogEvent,
} from '../compas-services/foundation.js';
import { CompasSclValidatorService } from '../compas-services/CompasValidatorService.js';
import { CompasNSDocFileService } from '../compas-services/CompasNSDocFileService.js';

Expand Down Expand Up @@ -39,8 +42,8 @@ async function processNsdocFile(
component.dispatchEvent(newLoadNsdocEvent(nsdocContent, filename));
localStorage.setItem(checksumKey, checksum);
})
.catch(reason => {
createLogEvent(component, reason);
.catch(() => {
createNSDocLogEvent(component, filename);
});
} else {
console.debug(`Loading NSDoc File '${nsdocId}' skipped, already loaded.`);
Expand Down
4 changes: 4 additions & 0 deletions packages/compas-open-scd/src/translations/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,10 @@ export const de: Translations = {
server: '???',
serverDetails: '{{type}}: {{message}}',
},
warning: {
nsdoc: 'Fehler beim Laden des NSD-Prozesses',
nsdocDetails: 'Datei kann nicht geladen werden: {{fileName}}',
},
changeset: {
major: '???',
minor: '???',
Expand Down
4 changes: 4 additions & 0 deletions packages/compas-open-scd/src/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,10 @@ export const en = {
server: 'Error communicating with CoMPAS Ecosystem',
serverDetails: '{{type}}: {{message}}',
},
warning: {
nsdoc: 'Process NSD loading error',
nsdocDetails: 'Cannot load file: {{fileName}}',
},
changeset: {
major: 'Major change',
minor: 'Minor change',
Expand Down

0 comments on commit 148eed8

Please sign in to comment.