@@ -7,12 +7,14 @@ import '@material/mwc-button';
7
7
import { newWizardEvent } from '../foundation.js' ;
8
8
import { TextFieldBase } from "@material/mwc-textfield/mwc-textfield-base" ;
9
9
import { dispatchEventOnOpenScd } from "./foundation.js" ;
10
+ import { Switch } from "@material/mwc-switch" ;
10
11
11
12
export type CompasSettingsRecord = {
12
13
sclDataServiceUrl : string ;
13
14
sclValidatorServiceUrl : string ;
14
15
cimMappingServiceUrl : string ;
15
16
sclAutoAlignmentServiceUrl : string ;
17
+ useWebsockets : 'on' | 'off' ;
16
18
} ;
17
19
18
20
export function CompasSettings ( ) {
@@ -23,7 +25,8 @@ export function CompasSettings() {
23
25
sclDataServiceUrl : this . getCompasSetting ( 'sclDataServiceUrl' ) ,
24
26
sclValidatorServiceUrl : this . getCompasSetting ( 'sclValidatorServiceUrl' ) ,
25
27
cimMappingServiceUrl : this . getCompasSetting ( 'cimMappingServiceUrl' ) ,
26
- sclAutoAlignmentServiceUrl : this . getCompasSetting ( 'sclAutoAlignmentServiceUrl' )
28
+ sclAutoAlignmentServiceUrl : this . getCompasSetting ( 'sclAutoAlignmentServiceUrl' ) ,
29
+ useWebsockets : this . getCompasSetting ( 'useWebsockets' )
27
30
} ;
28
31
} ,
29
32
@@ -32,10 +35,15 @@ export function CompasSettings() {
32
35
sclDataServiceUrl : '/compas-scl-data-service' ,
33
36
sclValidatorServiceUrl : '/compas-scl-validator' ,
34
37
cimMappingServiceUrl : '/compas-cim-mapping' ,
35
- sclAutoAlignmentServiceUrl : '/compas-scl-auto-alignment'
38
+ sclAutoAlignmentServiceUrl : '/compas-scl-auto-alignment' ,
39
+ useWebsockets : 'on'
36
40
}
37
41
} ,
38
42
43
+ useWebsockets ( ) : boolean {
44
+ return this . compasSettings . useWebsockets === 'on' ;
45
+ } ,
46
+
39
47
/** Update the `value` of `setting`, storing to `localStorage`. */
40
48
setCompasSetting < T extends keyof CompasSettingsRecord > ( setting : T , value : CompasSettingsRecord [ T ] ) : void {
41
49
localStorage . setItem ( setting , < string > ( < unknown > value ) ) ;
@@ -72,6 +80,10 @@ export class CompasSettingsElement extends LitElement {
72
80
return < TextFieldBase > this . shadowRoot ! . querySelector ( 'mwc-textfield[id="sclAutoAlignmentServiceUrl"]' ) ;
73
81
}
74
82
83
+ getUseWebsockets ( ) : Switch {
84
+ return < Switch > this . shadowRoot ! . querySelector ( 'mwc-switch[id="useWebsockets"]' ) ;
85
+ }
86
+
75
87
valid ( ) : boolean {
76
88
return this . getSclDataServiceUrlField ( ) . checkValidity ( )
77
89
&& this . getSclValidatorServiceUrlField ( ) . checkValidity ( )
@@ -89,6 +101,7 @@ export class CompasSettingsElement extends LitElement {
89
101
CompasSettings ( ) . setCompasSetting ( 'sclValidatorServiceUrl' , this . getSclValidatorServiceUrlField ( ) . value ) ;
90
102
CompasSettings ( ) . setCompasSetting ( 'cimMappingServiceUrl' , this . getCimMappingServiceUrlField ( ) . value ) ;
91
103
CompasSettings ( ) . setCompasSetting ( 'sclAutoAlignmentServiceUrl' , this . getSclAutoAlignmentServiceUrlField ( ) . value ) ;
104
+ CompasSettings ( ) . setCompasSetting ( 'useWebsockets' , this . getUseWebsockets ( ) . checked ? 'on' : 'off' ) ;
92
105
return true ;
93
106
}
94
107
@@ -122,6 +135,11 @@ export class CompasSettingsElement extends LitElement {
122
135
label = "${ translate ( 'compas.settings.sclAutoAlignmentServiceUrl' ) } "
123
136
value = "${ this . compasSettings . sclAutoAlignmentServiceUrl } " required >
124
137
</ mwc- textfield>
138
+ <mwc- for mfield label= "${ translate ( 'compas.settings.useWebsockets' ) } " >
139
+ <mwc- switch id= "useWebsockets"
140
+ ?checked= ${ this . compasSettings . useWebsockets === 'on' } >
141
+ </ mwc- switch>
142
+ </ mwc- for mfield>
125
143
126
144
<mwc- butto n @click = ${ ( ) => {
127
145
if ( this . reset ( ) ) {
@@ -137,7 +155,7 @@ export class CompasSettingsElement extends LitElement {
137
155
width : 20vw ;
138
156
}
139
157
140
- mwc-textfield {
158
+ mwc-textfield , mwc-formfield {
141
159
margin : 10px ;
142
160
width : 100% ;
143
161
}
0 commit comments