a31f0660
root
sevc-controllet i...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
<link rel="import" href="../../bower_components/polymer/polymer.html" />
<link rel="import" href="../../bower_components/paper-material/paper-material.html" />
<link rel="import" href="../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../../bower_components/paper-menu/paper-menu.html">
<link rel="import" href="../../bower_components/paper-item/paper-item.html">
<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../../bower_components/iron-icons/iron-icons.html">
<link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
<link rel="import" href="../../bower_components/paper-input/paper-textarea.html">
<link rel="import" href="../../bower_components/paper-button/paper-button.html">
<link rel="import" href="../items-vslider-controllet/items-vslider-controllet.html" />
|
0f6424fe
root
update new data-s...
|
19
|
<script src="../../../DEEPCLIENT/js/deepClient.js"></script>
|
a31f0660
root
sevc-controllet i...
|
20
21
22
23
24
25
|
<dom-module id="datalet-selection-controllet">
<template>
<style is="custom-style">
|
e0e4a976
Renato De Donato
data-sevc-control...
|
26
27
28
29
30
|
:host {
--paper-dropdown-menu-icon: {
color: #2196F3;
};
}
|
a31f0660
root
sevc-controllet i...
|
31
32
33
34
35
|
#datalet_selection_container {
display: flex;
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
|
0f6424fe
root
update new data-s...
|
36
|
margin-top: 8px;
|
a31f0660
root
sevc-controllet i...
|
37
38
39
40
41
42
|
}
#datalet_selection_inputs {
position: relative;
height: 100vh;
margin-left: 32px;
|
e0e4a976
Renato De Donato
data-sevc-control...
|
43
44
|
/*width: 344px;*/
min-width: 258px;
|
a31f0660
root
sevc-controllet i...
|
45
46
47
48
49
50
|
}
#datalet_selection_labels {
position: relative;
height: 100vh;
margin-left: 32px;
|
e0e4a976
Renato De Donato
data-sevc-control...
|
51
52
|
/*width: 344px;*/
min-width: 258px;
|
a31f0660
root
sevc-controllet i...
|
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
}
#datalet_selection_column {
position: relative;
width: 100%;
margin-left: 32px;
}
#datalet_selection_datalet {
position: relative;
height: 100vh;
width: 100%;
/*margin-left: 32px;*/
/*margin-top: 32px;*/
/*margin-bottom: 32px;*/
}
#datalet_selection_comment{
width: 100%;
|
e0e4a976
Renato De Donato
data-sevc-control...
|
72
|
/*height: 112px;*/
|
a31f0660
root
sevc-controllet i...
|
73
74
75
76
77
78
79
80
81
82
83
84
85
|
margin-bottom: 32px;
}
#datalet_selection_datalet_placeholder {
padding: 16px;
}
.inputs{
position: relative;
/*margin-left: 16px;*/
/*margin-right: 16px;*/
}
|
e0e4a976
Renato De Donato
data-sevc-control...
|
86
87
88
89
|
/*.input_name{*/
/*height: 16px;*/
/*padding: 16px;*/
/*/!*background-color: #B6B6B6;*!/*/
|
a31f0660
root
sevc-controllet i...
|
90
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
91
92
93
94
|
/*background-color: #2196F3;*/
/*color: #FFFFFF;*/
/*font-weight: 700;*/
/*}*/
|
a31f0660
root
sevc-controllet i...
|
95
96
|
.input_header{
|
e0e4a976
Renato De Donato
data-sevc-control...
|
97
98
99
|
height: 32px;
padding-top: 16px;
/*padding: 16px;*/
|
a31f0660
root
sevc-controllet i...
|
100
101
102
103
104
105
|
background-color: #B6B6B6;
text-align: center;
font-weight: 700;
}
.info_button {
|
e0e4a976
Renato De Donato
data-sevc-control...
|
106
|
/*background-color: red;*/
|
a31f0660
root
sevc-controllet i...
|
107
|
position: absolute;
|
e0e4a976
Renato De Donato
data-sevc-control...
|
108
|
top: 18px;
|
a31f0660
root
sevc-controllet i...
|
109
110
111
112
|
right: 0px;
}
paper-textarea {
|
e0e4a976
Renato De Donato
data-sevc-control...
|
113
|
display: inline-block;
|
a31f0660
root
sevc-controllet i...
|
114
|
height: 48px;
|
e0e4a976
Renato De Donato
data-sevc-control...
|
115
116
117
118
|
/*padding: 0px 8px;*/
width: 210px;
padding-left: 8px;
padding-bottom: 8px;
|
a31f0660
root
sevc-controllet i...
|
119
120
121
|
--paper-input-container-focus-color: #2196F3;
}
|
e0e4a976
Renato De Donato
data-sevc-control...
|
122
123
124
125
126
|
#datalet_selection_comment paper-textarea {
padding-bottom: 0px;
width: calc(100% - 16px);
}
|
a31f0660
root
sevc-controllet i...
|
127
|
paper-dropdown-menu {
|
e0e4a976
Renato De Donato
data-sevc-control...
|
128
|
/*display: inline-block;*/
|
a31f0660
root
sevc-controllet i...
|
129
|
height: 48px;
|
e0e4a976
Renato De Donato
data-sevc-control...
|
130
131
132
133
|
width: 210px;;
/*padding: 0px 8px;*/
padding-left: 8px;
padding-bottom: 8px;
|
a31f0660
root
sevc-controllet i...
|
134
135
136
137
138
139
140
141
142
|
--paper-input-container-focus-color: #2196F3;
}
paper-item.iron-selected {
background-color: #2196F3;
color: #FFFFFF;
}
paper-icon-button {
|
e0e4a976
Renato De Donato
data-sevc-control...
|
143
144
145
|
/*display: inline-block;*/
color: #2196F3;
/*color: #FFFFFF;*/
|
a31f0660
root
sevc-controllet i...
|
146
|
--paper-icon-button-ink-color: #2196F3;
|
e0e4a976
Renato De Donato
data-sevc-control...
|
147
|
margin: 0px;
|
a31f0660
root
sevc-controllet i...
|
148
149
150
151
152
153
154
155
156
|
/*padding: 0px;*/
}
paper-button {
/*display: block;*/
position: absolute;
bottom: 16px;
right: 11px;
|
a31f0660
root
sevc-controllet i...
|
157
158
159
160
161
162
163
164
165
166
167
|
height: 48px;
width: 172px;
background-color: #00BCD4;
color: white;
font-weight: 700;
padding: 16px;
}
paper-button:hover {
background-color: #00AABF;
}
|
0f6424fe
root
update new data-s...
|
168
169
170
171
|
paper-button[disabled] {
background-color: #B6B6B6;
}
|
a31f0660
root
sevc-controllet i...
|
172
173
|
</style>
|
0f6424fe
root
update new data-s...
|
174
|
<iron-ajax id="selectedDatalet_request" on-response="_handleSelectedDatalet"></iron-ajax>
|
a31f0660
root
sevc-controllet i...
|
175
176
|
<div id="datalet_selection_container">
|
e0e4a976
Renato De Donato
data-sevc-control...
|
177
|
<items-vslider-controllet id="vslider" datalets-list-url={{dataletsListUrl}} preselected-datalet={{preselectedDatalet}}></items-vslider-controllet>
|
a31f0660
root
sevc-controllet i...
|
178
179
180
181
|
<paper-material id="datalet_selection_inputs" elevation="5">
<div class="input_header">INPUTS</div>
|
e0e4a976
Renato De Donato
data-sevc-control...
|
182
|
<template is="dom-repeat" items="{{inputs}}" index-as="ddl_index">
|
a31f0660
root
sevc-controllet i...
|
183
|
<div class="inputs">
|
e0e4a976
Renato De Donato
data-sevc-control...
|
184
185
186
187
188
189
190
|
<!--<div class="input_name">-->
<!--{{item.name}}-->
<!--<div class="info_button">-->
<!--<paper-icon-button id="info_button" on-click="_showInfo" icon="info-outline" title="{{item.name}} info"></paper-icon-button>-->
<!--</div>-->
<!--</div>-->
<paper-dropdown-menu id={{ddl_index}} label={{item.name}}>
|
a31f0660
root
sevc-controllet i...
|
191
|
<paper-menu class="dropdown-content">
|
e0e4a976
Renato De Donato
data-sevc-control...
|
192
193
|
<template is="dom-repeat" items={{fields}}>
<paper-item id={{index}} on-tap="_addInput">{{item}}</paper-item>
|
a31f0660
root
sevc-controllet i...
|
194
195
196
|
</template>
</paper-menu>
</paper-dropdown-menu>
|
e0e4a976
Renato De Donato
data-sevc-control...
|
197
198
199
|
<div class="info_button">
<paper-icon-button id="info_button" on-click="_showInfo" icon="info-outline" title="{{item.name}} info"></paper-icon-button>
</div>
|
a31f0660
root
sevc-controllet i...
|
200
201
202
203
204
205
206
207
|
</div>
</template>
</paper-material>
<paper-material id="datalet_selection_labels" elevation="5">
<div class="input_header">LABELS</div>
<template is="dom-repeat" items="{{labels}}" index-as="index">
<div class="inputs">
|
e0e4a976
Renato De Donato
data-sevc-control...
|
208
209
210
211
212
213
214
215
216
|
<!--<div class="input_name">-->
<!--{{item.name}}-->
<!--<div class="info_button">-->
<!--<paper-icon-button id="info_button" on-click="_showInfo" icon="info-outline" title="{{item.name}} info"></paper-icon-button>-->
<!--</div>-->
<!--</div>-->
<paper-textarea label={{item.name}}></paper-textarea>
<div class="info_button">
<paper-icon-button id="info_button" on-click="_showInfo" icon="info-outline" title="{{item.name}} info"></paper-icon-button>
|
a31f0660
root
sevc-controllet i...
|
217
|
</div>
|
a31f0660
root
sevc-controllet i...
|
218
219
220
221
222
223
|
</div>
</template>
</paper-material>
<div id="datalet_selection_column">
|
e0e4a976
Renato De Donato
data-sevc-control...
|
224
225
226
227
228
229
230
|
<template is="dom-if" if={{modify}}>
<paper-material id="datalet_selection_comment" elevation="5">
<div class="input_header">COMMENT</div>
<paper-textarea id="comment" no-label-float maxlength="100" label="comment (max 100 characters)"></paper-textarea>
</paper-material>
</template>
|
a31f0660
root
sevc-controllet i...
|
231
232
233
234
235
236
237
|
<paper-material id="datalet_selection_datalet" elevation="5">
<div class="input_header">DATALET PREVIEW</div>
<div id="datalet_selection_datalet_placeholder"></div>
</paper-material>
|
0f6424fe
root
update new data-s...
|
238
|
<paper-button id="add_button" disabled raised on-click="_addDatalet">ADD DATALET</paper-button>
|
a31f0660
root
sevc-controllet i...
|
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
|
</div>
</div>
</template>
<script>
Polymer({
is : 'datalet-selection-controllet',
properties : {
deepUrl : {
type : String,
value : undefined
},
dataletsListUrl : {
type : String,
value : undefined
},
selectedDatalet : {
type : String,
value : undefined
},
|
e0e4a976
Renato De Donato
data-sevc-control...
|
269
270
271
272
273
|
preselectedDatalet : {
type : String,
value : undefined
},
|
a31f0660
root
sevc-controllet i...
|
274
275
276
277
278
279
280
281
282
283
284
285
|
inputs : {
type : Array,
value : []
},
labels : {
type : Array,
value : []
},
fields : {
type : Array,
|
0f6424fe
root
update new data-s...
|
286
287
288
289
290
291
292
293
|
value : []
},
selectedFields : {
type : Array,
value : []
},
|
e0e4a976
Renato De Donato
data-sevc-control...
|
294
295
296
297
|
// selectableFields : {
// type : Array,
// value : []
// },
|
a31f0660
root
sevc-controllet i...
|
298
299
300
|
dataUrl : {
type : String,
|
0f6424fe
root
update new data-s...
|
301
|
value : undefined
|
e0e4a976
Renato De Donato
data-sevc-control...
|
302
303
304
305
306
|
},
modify : {
type : Boolean,
value : false
|
a31f0660
root
sevc-controllet i...
|
307
308
309
310
311
|
}
},
listeners: {
|
e0e4a976
Renato De Donato
data-sevc-control...
|
312
|
'items-vslider-controllet_selected-datalet': '_selectDatalet'
|
0f6424fe
root
update new data-s...
|
313
|
// 'tree-view-controllet_selected-fields': '_updateSelectedFields'
|
a31f0660
root
sevc-controllet i...
|
314
315
316
317
318
319
320
|
},
ready : function() {
this._resize();
$(this.$.datalet_selection_inputs).perfectScrollbar();
$(this.$.datalet_selection_labels).perfectScrollbar();
$(this.$.datalet_selection_datalet).perfectScrollbar();
|
0f6424fe
root
update new data-s...
|
321
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
322
323
324
325
326
|
if(this.preselectedDatalet){
this.modify = true;
this._preselectDatalet();
this.preselectedDatalet = undefined;
}
|
a31f0660
root
sevc-controllet i...
|
327
328
329
330
331
332
|
},
attached : function() {
this._resize();
var that = this;
window.addEventListener("resize", function() { that._resize(); });
|
e0e4a976
Renato De Donato
data-sevc-control...
|
333
334
335
336
337
338
339
|
// var inputs = document.getElementsByTagName("paper-dropdown-menu");
// console.log(inputs);
// for(var i in inputs)
// console.log(i);
// for(var i=0; i < inputs.length; i++)
// console.log($(inputs[i]).children("paper-menu"));
|
a31f0660
root
sevc-controllet i...
|
340
341
|
},
|
0f6424fe
root
update new data-s...
|
342
343
344
345
|
setFields : function(fields) {
this.fields = fields;
},
|
e0e4a976
Renato De Donato
data-sevc-control...
|
346
347
348
349
350
351
352
353
|
reset : function() {
this.selectedDatalet = undefined;
this.inputs = [];
this.labels = [];
this.$.datalet_selection_datalet_placeholder.innerHTML = "";
},
_selectDatalet : function(e){
|
0f6424fe
root
update new data-s...
|
354
355
|
this.$.add_button.setAttribute("disabled", "true");
|
a31f0660
root
sevc-controllet i...
|
356
|
this.selectedDatalet = e.detail.datalet;
|
0f6424fe
root
update new data-s...
|
357
358
359
|
this.inputs = [];
this.labels = [];
|
a31f0660
root
sevc-controllet i...
|
360
361
362
363
|
if(this.selectedDatalet){
this.$.selectedDatalet_request.url = this.deepUrl + e.detail.datalet + "-datalet";
this.$.selectedDatalet_request.generateRequest();
}
|
0f6424fe
root
update new data-s...
|
364
365
366
367
368
|
// else {
// this.inputs = [];
// this.labels = [];
// }
|
e0e4a976
Renato De Donato
data-sevc-control...
|
369
370
371
|
// this.$.datalet_selection_datalet_placeholder.innerHTML = "";
// this.selectedFields = [];
},
|
0f6424fe
root
update new data-s...
|
372
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
373
374
375
376
377
378
379
380
381
382
383
384
|
_preselectDatalet : function() {
this.$.add_button.innerText = "MODIFY DATALET";
this.selectedDatalet = this.preselectedDatalet;
this.selectedFields = this._copy(this.fields);
var inputs = document.getElementsByTagName("paper-dropdown-menu");
for(var i=0; i < inputs.length; i++)
$(inputs[i]).find("paper-menu")[0].select(i);
this._loadDatalet(this.selectedFields);
|
a31f0660
root
sevc-controllet i...
|
385
386
|
},
|
0f6424fe
root
update new data-s...
|
387
|
_handleSelectedDatalet : function(e){
|
e0e4a976
Renato De Donato
data-sevc-control...
|
388
|
this.$.datalet_selection_datalet_placeholder.innerHTML = "";
|
0f6424fe
root
update new data-s...
|
389
|
|
a31f0660
root
sevc-controllet i...
|
390
391
392
393
394
|
var inputs = e.detail.response.idm.inputs.input;
var labels = e.detail.response.idm.inputs.layouts.input;
if(inputs.constructor == Object) {//not Array && inputs.input.selection == "*"
var name = inputs.name;
|
0f6424fe
root
update new data-s...
|
395
396
|
var description = inputs.description;
var selection = inputs.selection;
|
a31f0660
root
sevc-controllet i...
|
397
398
|
inputs = [];
for(var i in this.fields)
|
0f6424fe
root
update new data-s...
|
399
|
inputs.push({name: name + " " + i, description: description, selection: selection});
|
a31f0660
root
sevc-controllet i...
|
400
401
402
403
|
}
this.inputs = inputs;
this.labels = labels;
|
a31f0660
root
sevc-controllet i...
|
404
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
405
406
407
408
|
// if(this.inputs[0].selection == "*")
// this.selectedFields = [];
// else
this.selectedFields = new Array(inputs.length);
|
0f6424fe
root
update new data-s...
|
409
410
|
},
|
e0e4a976
Renato De Donato
data-sevc-control...
|
411
|
_addInput : function(e){
|
0f6424fe
root
update new data-s...
|
412
|
var selectedFields = this._copy(this.selectedFields);
|
0f6424fe
root
update new data-s...
|
413
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
414
415
|
var index = $(e.target).parents("paper-dropdown-menu")[0].id;
selectedFields[index] = e.target.innerText;
|
0f6424fe
root
update new data-s...
|
416
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
417
|
this.selectedFields = this._copy(selectedFields);
|
0f6424fe
root
update new data-s...
|
418
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
419
|
var load = true;
|
0f6424fe
root
update new data-s...
|
420
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
if(this.inputs[0].selection == "*"){
var temp = [];
for (var i = 0; i < selectedFields.length; i++)
if(selectedFields[i])
temp.push(selectedFields[i]);
selectedFields = temp;
}
else {
for (var i = 0; i < selectedFields.length; i++)
if (!selectedFields[i]) {
load = false;
break;
}
}
|
0f6424fe
root
update new data-s...
|
435
436
|
if(load){
|
e0e4a976
Renato De Donato
data-sevc-control...
|
437
438
|
this._loadDatalet(selectedFields);
}
|
0f6424fe
root
update new data-s...
|
439
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
440
441
442
443
444
445
|
// $("#base_datalet_container").html("");
// $("#base_datalet_container").css('visibility','hidden');
// $("#base_datalet_container").css('padding','0px');
// $("#base_datalet_container").css('height','0px');
// console.log($("#base_datalet_container"));
},
|
0f6424fe
root
update new data-s...
|
446
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
447
448
|
_loadDatalet : function(selectedFields){
var params = {'data-url' : this.dataUrl};
|
0f6424fe
root
update new data-s...
|
449
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
450
451
452
453
454
455
|
var dataletParams ={
component : this.selectedDatalet+"-datalet",
params : params,
fields : selectedFields,
placeHolder : this.$.datalet_selection_datalet_placeholder
};
|
0f6424fe
root
update new data-s...
|
456
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
457
458
|
ComponentService.deep_url = this.deepUrl;
ComponentService.getComponent(dataletParams);
|
a31f0660
root
sevc-controllet i...
|
459
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
460
|
this.async(function(){this.$.add_button.removeAttribute("disabled");}, 1111);
|
0f6424fe
root
update new data-s...
|
461
462
|
},
|
e0e4a976
Renato De Donato
data-sevc-control...
|
463
|
_addDatalet : function(){
|
0f6424fe
root
update new data-s...
|
464
465
466
467
468
469
470
471
472
473
474
475
|
var data = {
dataUrl : this.dataUrl,
// params : this.paramsFields,
params : {'data-url' : this.dataUrl},
fields : this.selectedFields,
datalet : this.selectedDatalet+"-datalet",
comment : this.$.comment.value,
staticData : JSON.stringify(this.$.datalet_selection_datalet_placeholder.children[1].behavior.data)
}
this.fire('data-sevc-controllet.dataletCreated', {data : data});
|
a31f0660
root
sevc-controllet i...
|
476
477
478
|
},
|
e0e4a976
Renato De Donato
data-sevc-control...
|
479
480
481
482
483
484
485
486
487
488
|
_copy : function(o) {
var out, v, key;
out = Array.isArray(o) ? new Array(o.length) : {};
for (key in o) {
v = o[key];
out[key] = (typeof v === "object") ? this._copy(v) : v;
}
return out;
},
|
a31f0660
root
sevc-controllet i...
|
489
490
491
492
493
494
495
496
|
_resize : function(){
var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16;
h = h - 64 - 8; //height with page scroller
$("#items_vslider_container").height(h);//vslider controllet
$("#datalet_selection_inputs").height(h);
$("#datalet_selection_labels").height(h);
|
e0e4a976
Renato De Donato
data-sevc-control...
|
497
498
499
500
|
if(this.modify)
$("#datalet_selection_datalet").height(h-128);
else
$("#datalet_selection_datalet").height(h);
|
a31f0660
root
sevc-controllet i...
|
501
502
503
504
505
506
507
|
}
});
</script>
</dom-module>
|