Skip to content

Commit ebd72c1

Browse files
author
Flurb
committed
Beautiful review comments fixed
Signed-off-by: Flurb <[email protected]>
1 parent 448ea5e commit ebd72c1

File tree

3 files changed

+18
-25
lines changed

3 files changed

+18
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
/out-tsc/
2222

2323
/public/cim/
24+
!/public/cim/README.md

src/compas/CompasImportFromApi.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@ import {customElement, html, LitElement, TemplateResult} from "lit-element";
22

33
import '@material/mwc-button';
44

5-
import {newOpenDocEvent, newWizardEvent} from "../foundation.js";
5+
import {newOpenDocEvent, newPendingStateEvent, newWizardEvent} from "../foundation.js";
66

77
import {createLogEvent, handleError, handleResponse, parseXml} from "../compas-services/foundation.js";
88
import {dispatchEventOnOpenScd} from "./foundation.js";
99

1010
import '../WizardDivider.js';
1111
import './CompasSclTypeList.js';
1212
import './CompasScl.js';
13-
import { CompasSettings } from "./CompasSettings.js";
1413
import { CompasCimMappingService } from "../compas-services/CompasCimMappingService.js";
1514

1615
@customElement('compas-import-from-api')
1716
export default class CompasImportFromApiElement extends LitElement {
1817
private async processCimFile(name: string) {
19-
const url = CompasSettings().compasSettings.importFromApiUrl;
20-
21-
const doc = await fetch(url + '/' + name + '.xml')
18+
const doc = await fetch('/public/cim/' + name + '.xml')
2219
.catch(handleError)
2320
.then(handleResponse)
2421
.then(parseXml);
@@ -40,19 +37,27 @@ export default class CompasImportFromApiElement extends LitElement {
4037
return html `
4138
<filtered-list>
4239
<mwc-list-item
43-
@click=${() => this.processCimFile('cim-eq-hoorn-v3')}>
40+
@click=${() => dispatchEventOnOpenScd(newPendingStateEvent(
41+
this.processCimFile('cim-eq-hoorn-v3')
42+
))}>
4443
cim-eq-hoorn-v3
4544
</mwc-list-item>
4645
<mwc-list-item
47-
@click=${() => this.processCimFile('cim-eq-makkum')}>
46+
@click=${() => dispatchEventOnOpenScd(newPendingStateEvent(
47+
this.processCimFile('cim-eq-makkum')
48+
))}>
4849
cim-eq-makkum
4950
</mwc-list-item>
5051
<mwc-list-item
51-
@click=${() => this.processCimFile('cim-eq-winselingseweg-voorbeeld')}>
52+
@click=${() => dispatchEventOnOpenScd(newPendingStateEvent(
53+
this.processCimFile('cim-eq-winselingseweg-voorbeeld')
54+
))}>
5255
cim-eq-winselingseweg-voorbeeld
5356
</mwc-list-item>
5457
<mwc-list-item
55-
@click=${() => this.processCimFile('EQ-entsoe-voorbeeld')}>
58+
@click=${() => dispatchEventOnOpenScd(newPendingStateEvent(
59+
this.processCimFile('EQ-entsoe-voorbeeld')
60+
))}>
5661
EQ-entsoe-voorbeeld
5762
</mwc-list-item>
5863
</filtered-list>

src/compas/CompasSettings.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export type CompasSettingsRecord = {
1313
sclValidatorServiceUrl: string;
1414
cimMappingServiceUrl: string;
1515
sclAutoAlignmentServiceUrl: string;
16-
importFromApiUrl: string;
1716
};
1817

1918
export function CompasSettings() {
@@ -24,8 +23,7 @@ export function CompasSettings() {
2423
sclDataServiceUrl: this.getCompasSetting('sclDataServiceUrl'),
2524
sclValidatorServiceUrl: this.getCompasSetting('sclValidatorServiceUrl'),
2625
cimMappingServiceUrl: this.getCompasSetting('cimMappingServiceUrl'),
27-
sclAutoAlignmentServiceUrl: this.getCompasSetting('sclAutoAlignmentServiceUrl'),
28-
importFromApiUrl: this.getCompasSetting('importFromApiUrl'),
26+
sclAutoAlignmentServiceUrl: this.getCompasSetting('sclAutoAlignmentServiceUrl')
2927
};
3028
},
3129

@@ -34,8 +32,7 @@ export function CompasSettings() {
3432
sclDataServiceUrl: '/compas-scl-data-service',
3533
sclValidatorServiceUrl: '/compas-scl-validator',
3634
cimMappingServiceUrl: '/compas-cim-mapping',
37-
sclAutoAlignmentServiceUrl: '/compas-scl-auto-alignment',
38-
importFromApiUrl: '/public/cim'
35+
sclAutoAlignmentServiceUrl: '/compas-scl-auto-alignment'
3936
}
4037
},
4138

@@ -75,16 +72,11 @@ export class CompasSettingsElement extends LitElement {
7572
return <TextFieldBase>this.shadowRoot!.querySelector('mwc-textfield[id="sclAutoAlignmentServiceUrl"]');
7673
}
7774

78-
getImportFromApiUrlField(): TextFieldBase {
79-
return <TextFieldBase>this.shadowRoot!.querySelector('mwc-textfield[id="importFromApiUrl"]');
80-
}
81-
8275
valid(): boolean {
8376
return this.getSclDataServiceUrlField().checkValidity()
8477
&& this.getSclValidatorServiceUrlField().checkValidity()
8578
&& this.getCimMappingServiceUrlField().checkValidity()
86-
&& this.getSclAutoAlignmentServiceUrlField().checkValidity()
87-
&& this.getImportFromApiUrlField().checkValidity();
79+
&& this.getSclAutoAlignmentServiceUrlField().checkValidity();
8880
}
8981

9082
save(): boolean {
@@ -97,7 +89,6 @@ export class CompasSettingsElement extends LitElement {
9789
CompasSettings().setCompasSetting('sclValidatorServiceUrl', this.getSclValidatorServiceUrlField().value);
9890
CompasSettings().setCompasSetting('cimMappingServiceUrl', this.getCimMappingServiceUrlField().value);
9991
CompasSettings().setCompasSetting('sclAutoAlignmentServiceUrl', this.getSclAutoAlignmentServiceUrlField().value);
100-
CompasSettings().setCompasSetting('importFromApiUrl', this.getImportFromApiUrlField().value);
10192
return true;
10293
}
10394

@@ -131,10 +122,6 @@ export class CompasSettingsElement extends LitElement {
131122
label="${translate('compas.settings.sclAutoAlignmentServiceUrl')}"
132123
value="${this.compasSettings.sclAutoAlignmentServiceUrl}" required>
133124
</mwc-textfield>
134-
<mwc-textfield id="importFromApiUrl"
135-
label="${translate('compas.settings.importFromApiUrl')}"
136-
value="${this.compasSettings.importFromApiUrl}" required>
137-
</mwc-textfield>
138125
139126
<mwc-button @click=${() => {
140127
if (this.reset()) {

0 commit comments

Comments
 (0)