/
models-configure.ts
376 lines (318 loc) · 13.1 KB
/
models-configure.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
import { property, html, customElement, css } from 'lit-element';
import { PageViewElement } from '../../components/page-view-element';
import { SharedStyles } from '../../styles/shared-styles';
import { store, RootState } from '../../app/store';
import { connect } from 'pwa-helpers/connect-mixin';
import { goToPage } from '../../app/actions';
import { renderNotifications } from "../../util/ui_renders";
import { showNotification } from "../../util/ui_functions";
import { ExplorerStyles } from './model-explore/explorer-styles'
import './configure/configuration';
import './configure/setup';
import './configure/new-setup';
import './configure/parameter';
import './models-tree'
import { fetchIOAndVarsSNForConfig, fetchAuthorsForModelConfig, fetchParametersForConfig,
fetchMetadataNoioForModelConfig, addParameters, addCalibration, addMetadata,
addInputs, addAuthor } from '../../util/model-catalog-actions';
import { parameterGet, processesGet, regionsGet } from 'model-catalog/actions';
import { showDialog, hideDialog } from 'util/ui_functions';
import "weightless/slider";
import "weightless/progress-spinner";
import "weightless/tab";
import "weightless/tab-group";
import '../../components/loading-dots'
const sortByPosition = (a,b) => {
let intA = Number(a.position);
let intB = Number(b.position);
return (intA < intB) ? -1 : (intA > intB? 1 : 0);
}
@customElement('models-configure')
export class ModelsConfigure extends connect(store)(PageViewElement) {
@property({type: Boolean})
private _hideModels : boolean = false;
@property({type: Boolean})
private _editing : boolean = false;
@property({type: Boolean})
private _creating : boolean = false;
@property({type: Object})
private _regions : any = null;
@property({type: Object})
private _models : any = null;
@property({type: Object})
private _versions : any = null;
@property({type: Object})
private _configs : any = null;
@property({type: Object})
private _model: any = null;
@property({type: Object})
private _version: any = null;
@property({type: Object})
private _config: any = null;
@property({type: Object})
private _setup: any = null;
@property({type: Object})
private _configParameters : any = {};
@property({type: Object})
private _setupParameters : any = null;
@property({type: Object})
private _configMetadata : any = null;
@property({type: Object})
private _setupMetadata : any = null;
@property({type: Object})
private _configAuthors : any = null;
@property({type: Object})
private _setupAuthors : any = null;
@property({type: Object})
private _configInputs : any = null;
@property({type: Object})
private _setupInputs : any = null;
private _url : string = '';
private _selectedModel : string = '';
private _selectedVersion : string = '';
private _selectedConfig : string = '';
private _selectedSetup : string = '';
static get styles() {
return [ExplorerStyles,
css `
.cltrow wl-button {
padding: 2px;
}
.card2 {
margin: 0px;
left: 0px;
right: 0px;
padding: 10px;
padding-top: 5px;
height: calc(100% - 40px);
background: #FFFFFF;
}
.twocolumns {
position: absolute;
top: 120px;
bottom: 25px;
left: 25px;
right: 25px;
display: flex;
border: 1px solid #F0F0F0;
}
.left {
width: 30%;
padding-top: 0px;
border-right: 1px solid #F0F0F0;
padding-right: 5px;
overflow: auto;
height: 100%;
}
.left_closed {
width: 0px;
overflow: hidden;
}
.right, .right_full {
width: 70%;
padding-top: 0px;
overflow: auto;
height: 100%;
}
.right_full {
width: 100%;
}
wl-slider > .value-edit {
width: 47px;
}
input.value-edit {
width: 100%;
background-color: transparent;
border: 0px;
text-align: right;
font-size: 16px;
font-weight: 400;
family: Raleway;
}
input.value-edit::placeholder {
color: rgb(136, 142, 145);
}
input.value-edit:hover {
border-bottom: 1px dotted black;
margin-bottom: -1px;
}
input.value-edit:focus {
border-bottom: 1px solid black;
margin-bottom: -1px;
outline-offset: -0px;
outline: -webkit-focus-ring-color auto 0px;
}
th > wl-icon {
vertical-align: bottom;
margin-left: 4px;
--icon-size: 14px;
}
.inline-new-button {
line-height: 1.2em;
font-size: 1.2em;
}
.inline-new-button > wl-icon {
--icon-size: 1.2em;
vertical-align: top;
}
.info-center {
text-align: center;
font-size: 13pt;
height: 32px;
line-height:32px;
color: #999;
}
li > a {
cursor: pointer;
}
.ta-right {
text-align: right;
}
.input-range {
width: 50px !important;
color: black;
}
.details-table {
border-collapse: collapse;
width: 100%;
}
.details-table tr td:first-child {
font-weight: bold;
text-align: right;
padding-right: 6px;
}
.details-table tr:nth-child(odd) {
background-color: rgb(246, 246, 246);
}
`,
SharedStyles
];
}
protected render() {
return html`
<div class="twocolumns">
<div class="${this._hideModels ? 'left_closed' : 'left'}">
<div class="clt">
<wl-title level="4" style="margin: 4px; padding: 10px;">Models:</wl-title>
<models-tree active></models-tree>
</div>
</div>
<div class="${this._hideModels ? 'right_full' : 'right'}">
<div class="card2">
<wl-icon @click="${() => this._hideModels = !this._hideModels}"
class="actionIcon bigActionIcon" style="float:right">
${!this._hideModels ? "fullscreen" : "fullscreen_exit"}
</wl-icon>
<div class="cltrow_padded">
<div class="cltmain">
<wl-title level="3" style="margin: 0px">
${this._creating ? 'Creating a new ' + (this._config ? 'setup' : 'configuration') + ' for '
: (this._editing ? 'Editing ': '')}
${this._setup ?
this._setup.label
: (this._config ?
this._config.label
: (this._version ? this._version.label : 'Select a model configuration or setup on the left panel.')
)}
</wl-title>
${!this._version ? html`
<wl-text>
You can create custom configurations of a model, by fixing parameter
values or input datasets or by constraining the ranges that parameters can take.
</wl-text>
<wl-title level="4">
Select a model from the left panel, and edit the parameters and files accordingly.
</wl-title>
` :''}
</div>
</div>
${this._config || this._setup ? html`<div style="font-size: 13px; padding: 0px 10px;">
<p>
Model configurations are customizations of the model that use a subset of all the processes
and functions that are possible with the general model software.
Model set ups are manual configurations of a model for a specific geographical area or region,
where some of the input data or parameters are constrained or fixed.
</p>
<p>
You can create a new model set up or do further customization of an existing one by editing
the parameters to constrain their values further or to set defaults, fix input data files
by providing a URL to them, and edit the descriptions of the model configuration to reflect the changes.
</p>
</div>` : ''}
<div style="padding: 0px 10px;">
<models-configure-configuration class="page" ?active="${this._selectedConfig && !this._selectedSetup && !this._creating}"></models-configure-configuration>
<models-configure-setup class="page" ?active="${this._selectedSetup && !this._creating}"></models-configure-setup>
<models-new-setup class="page" ?active="${this._selectedConfig && this._creating}"></models-new-setup>
</div>
</div>
</div>
</div>
${renderNotifications()}
`
}
private _configParametersLoading : Set<string> = new Set();
firstUpdated () {
store.dispatch(processesGet());
store.dispatch(regionsGet());
}
stateChanged(state: RootState) {
if (state.explorerUI) {
let ui = state.explorerUI;
// check whats changed
let modelChanged : boolean = (ui.selectedModel !== this._selectedModel);
let versionChanged : boolean = (modelChanged || ui.selectedVersion !== this._selectedVersion)
let configChanged : boolean = (versionChanged || ui.selectedConfig !== this._selectedConfig);
let calibrationChanged : boolean = (configChanged || ui.selectedCalibration !== this._selectedSetup);
this._editing = (ui.mode === 'edit');
this._creating = (ui.mode === 'new');
super.setRegionId(state);
if (modelChanged) {
this._selectedModel = ui.selectedModel;
this._model = null;
}
if (versionChanged) {
this._selectedVersion = ui.selectedVersion;
this._version = null;
}
if (configChanged) {
this._selectedConfig = ui.selectedConfig;
this._config = null;
this._configMetadata = null;
this._configAuthors = null;
this._configParameters = {};
this._configParametersLoading = new Set();
this._configInputs = null;
}
if (calibrationChanged) {
this._selectedSetup = ui.selectedCalibration;
this._setup = null;
this._setupMetadata = null;
this._setupAuthors = null;
this._setupParameters = null;
this._setupInputs = null;
}
if (state.modelCatalog) {
let db = state.modelCatalog;
this._models = db.models;
this._versions = db.versions;
this._configs = db.configurations;
this._regions = db.regions;
// Set selected resource
if (!this._model && db.models && this._selectedModel && db.models[this._selectedModel]) {
this._model = db.models[this._selectedModel];
}
if (!this._version && db.versions && this._selectedVersion && db.versions[this._selectedVersion]) {
this._version = db.versions[this._selectedVersion];
}
if (db.configurations) {
if (!this._config && this._selectedConfig && db.configurations[this._selectedConfig]) {
this._config = db.configurations[this._selectedConfig];
}
if (!this._setup && this._selectedSetup && db.configurations[this._selectedSetup]) {
this._setup = db.configurations[this._selectedSetup];
}
}
}
}
}
}