Skip to content

Commit a455c6e

Browse files
author
Dennis Labordus
committed
First steps, adding the service calls.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent bb69fdc commit a455c6e

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/compas-services/CompasValidatorService.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export function CompasSclValidatorService() {
1010

1111
return {
1212
validateSCL(type: string, doc: Document): Promise<Document> {
13-
const saaUrl = getCompasSettings().sclValidatorServiceUrl + '/validate/v1/' + type;
14-
return fetch(saaUrl, {
13+
const svsUrl = getCompasSettings().sclValidatorServiceUrl + '/validate/v1/' + type;
14+
return fetch(svsUrl, {
1515
method: 'POST',
1616
headers: {
1717
'Content-Type': 'application/xml'
@@ -24,5 +24,19 @@ export function CompasSclValidatorService() {
2424
.then(handleResponse)
2525
.then(parseXml);
2626
},
27+
28+
listNsdocFiles(): Promise<Document> {
29+
const svsUrl = getCompasSettings().sclValidatorServiceUrl + '/nsdoc/v1';
30+
return fetch(svsUrl).catch(handleError)
31+
.then(handleResponse)
32+
.then(parseXml);
33+
},
34+
35+
getNsdocFile(id: string): Promise<Document> {
36+
const svsUrl = getCompasSettings().sclValidatorServiceUrl + '/nsdoc/v1/' + id;
37+
return fetch(svsUrl).catch(handleError)
38+
.then(handleResponse)
39+
.then(parseXml);
40+
},
2741
}
2842
}

src/compas/CompasNsdoc.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {createLogEvent} from "../compas-services/foundation.js";
2+
import {CompasSclValidatorService} from "../compas-services/CompasValidatorService.js";
3+
4+
function processNsdocFile(id: string, nsdocId: string, checksum: string) {
5+
console.info(`Found NSDoc File '${nsdocId}' with ID '${id}'.`);
6+
}
7+
8+
export async function loadNsdocFiles(): Promise<void> {
9+
await CompasSclValidatorService().listNsdocFiles()
10+
.then(response => {
11+
Array.from(response.querySelectorAll("NsdocFile") ?? [])
12+
.forEach(element => {
13+
const id = element.querySelector('Id')!.textContent ?? '';
14+
const nsdocId = element.querySelector('NsdocId')!.textContent ?? '';
15+
const checksum = element.querySelector('Checksum')!.textContent ?? '';
16+
processNsdocFile(id, nsdocId, checksum);
17+
});
18+
})
19+
.catch(reason => {
20+
createLogEvent(reason);
21+
});
22+
}

src/menu/CompasSettings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {newWizardEvent, Wizard, WizardInput} from '../foundation.js';
55

66
import {CompasSettingsElement} from "../compas/CompasSettings.js";
77
import {retrieveUserInfo} from "../compas/CompasSession.js";
8+
import {loadNsdocFiles} from "../compas/CompasNsdoc.js";
89

910
import "../compas/CompasSettings.js";
1011

@@ -42,4 +43,6 @@ export function compasSettingWizard(): Wizard {
4243

4344
// When the plugin is loaded we will also start retrieving the User Information and prepare the Timeout Panels.
4445
retrieveUserInfo();
46+
// And we will start loading the Nsdoc Files from the Compas Backend Service.
47+
loadNsdocFiles();
4548

0 commit comments

Comments
 (0)