a31f0660
root
sevc-controllet i...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/paper-tabs/paper-tabs.html">
<link rel="import" href="../../bower_components/paper-tabs/paper-tab.html">
<link rel="import" href="../../bower_components/neon-animation/neon-animation.html">
<link rel="import" href="../../bower_components/neon-animation/neon-animatable.html">
<link rel="import" href="../../bower_components/neon-animation/neon-animations.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-input/paper-textarea.html">
<link rel="import" href="../../bower_components/paper-material/paper-material.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-dialog/paper-dialog.html">
|
a31f0660
root
sevc-controllet i...
|
23
24
25
|
<link rel="import" href="../../datalets/datasetexplorer-datalet/datasetexplorer-datalet.html">
|
4bf5f658
root
update tree map, ...
|
26
27
|
<link rel="import" href="paper-input-search.html">
|
a31f0660
root
sevc-controllet i...
|
28
29
30
31
32
|
<dom-module id="dataset-selection-controllet">
<template>
<style is="custom-style">
|
e0e4a976
Renato De Donato
data-sevc-control...
|
33
34
35
36
37
38
|
:host {
--paper-dropdown-menu-icon: {
color: #2196F3;
};
}
|
a31f0660
root
sevc-controllet i...
|
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
paper-tabs {
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
font-weight: bold;
--paper-tabs-selection-bar-color: #2196F3;
}
paper-tab {
transition: all 1.0s;
}
paper-tab.iron-selected {
background-color: #B6B6B6;
}
paper-tab:hover {
color: #2196F3;
}
paper-tab[disabled] {
color: #B6B6B6;
}
|
e0e4a976
Renato De Donato
data-sevc-control...
|
62
|
paper-dropdown-menu {
|
e0e4a976
Renato De Donato
data-sevc-control...
|
63
64
65
66
67
68
69
70
|
width: 45%;
margin-bottom: 32px;
--paper-input-container-focus-color: #2196F3;
}
paper-dropdown-menu paper-item {
white-space: nowrap;
}
|
0f6424fe
root
update new data-s...
|
71
72
|
paper-input-search {
|
a31f0660
root
sevc-controllet i...
|
73
74
75
76
77
|
width: 45%;
margin-bottom: 32px;
--paper-input-container-focus-color: #2196F3;
}
|
0f6424fe
root
update new data-s...
|
78
79
80
81
|
paper-input-search paper-item {
white-space: nowrap;
}
|
a31f0660
root
sevc-controllet i...
|
82
83
84
85
86
|
paper-item.iron-selected {
background-color: #2196F3;
color: #FFFFFF;
}
|
e0e4a976
Renato De Donato
data-sevc-control...
|
87
88
|
.ddl_container {
position: relative;
|
4bf5f658
root
update tree map, ...
|
89
90
|
}
|
e0e4a976
Renato De Donato
data-sevc-control...
|
91
|
.info_button {
|
e0e4a976
Renato De Donato
data-sevc-control...
|
92
93
94
95
96
|
position: absolute;
top: 18px;
left: 45%;
}
|
a31f0660
root
sevc-controllet i...
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
paper-textarea {
width: 90%;
margin-bottom: 32px;
--paper-input-container-focus-color: #2196F3;
}
paper-icon-button {
color: #2196F3;
--paper-icon-button-ink-color: #2196F3;
}
paper-icon-button[disabled] {
color: #B6B6B6;
}
#material_container {
margin-top: 8px;
|
a31f0660
root
sevc-controllet i...
|
114
115
116
117
118
|
}
#div_selection {
padding-left: 10%;
padding-top: 64px;
|
a31f0660
root
sevc-controllet i...
|
119
120
121
122
123
|
}
#dialog_info {
border: 2px solid #2196F3;
background-color: #E0E0E0;
|
a31f0660
root
sevc-controllet i...
|
124
125
126
127
128
|
}
</style>
<paper-material id="material_container" elevation="5">
|
4a58f4fc
Renato De Donato
treemap placeholder
|
129
|
<paper-tabs selected="{{selected}}">
|
6d2a2a1e
Andrea Petta
language handling
|
130
131
132
|
<paper-tab noink><span id="listView"></span></paper-tab>
<paper-tab noink><span id="treeMapView"></span></paper-tab>
<!--<paper-tab noink disabled><span data-l10n-id="mostPopular"></span></paper-tab>-->
|
a31f0660
root
sevc-controllet i...
|
133
134
135
136
137
138
139
|
</paper-tabs>
<neon-animated-pages selected="{{selected}}" entry-animation="fade-in-animation" exit-animation="fade-out-animation">
<neon-animatable>
<div id="div_selection">
|
e0e4a976
Renato De Donato
data-sevc-control...
|
140
|
<div class="ddl_container">
|
57ef9bf4
Renato De Donato
labels + info
|
141
|
<paper-input-search id="_datasets" label="Available datasets">
|
e0e4a976
Renato De Donato
data-sevc-control...
|
142
143
144
|
<paper-menu class="dropdown-content">
<template is="dom-repeat" items={{filteredDatasets}} as="dataset">
<paper-item id={{index}} on-tap="_selectDataUrl">{{dataset.name}}</paper-item>
|
e0e4a976
Renato De Donato
data-sevc-control...
|
145
146
147
148
149
150
151
152
153
|
</template>
</paper-menu>
</paper-input-search>
<div class="info_button">
<paper-icon-button id="info_dataset" disabled on-click="_showInfo" icon="info-outline" title="dataset info"></paper-icon-button>
</div>
</div>
|
fb432ae9
Renato De Donato
suggested
|
154
|
<template is="dom-if" if={{isSuggested}}>
|
57ef9bf4
Renato De Donato
labels + info
|
155
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
156
|
<div class="ddl_container">
|
57ef9bf4
Renato De Donato
labels + info
|
157
|
<paper-dropdown-menu id="s_datasets" label="Suggested datasets">
|
e0e4a976
Renato De Donato
data-sevc-control...
|
158
159
|
<paper-menu class="dropdown-content">
<template is="dom-repeat" items={{suggestedDatasets}} as="dataset">
|
0ff13705
root
suggested dataset...
|
160
|
<paper-item id={{index}} on-tap="_selectSuggestedDataUrl">{{dataset.name}}</paper-item>
|
e0e4a976
Renato De Donato
data-sevc-control...
|
161
162
163
164
165
166
167
168
169
170
|
</template>
</paper-menu>
</paper-dropdown-menu>
<div class="info_button">
<paper-icon-button id="info_s_dataset" disabled on-click="_showInfo" icon="info-outline" title="dataset info"></paper-icon-button>
</div>
</div>
</template>
|
0f6424fe
root
update new data-s...
|
171
|
|
5c96a7bc
Renato De Donato
controllet invali...
|
172
|
<paper-textarea id="selected_url" label="Selected url" value={{dataUrl}} error-message={{errorMessage}}></paper-textarea>
|
a31f0660
root
sevc-controllet i...
|
173
|
|
a31f0660
root
sevc-controllet i...
|
174
175
176
177
178
179
180
181
182
|
<paper-dialog id="dialog_info">
<h2 id="dialog_name"></h2>
<p id="dialog_description"></p>
</paper-dialog>
</div>
</neon-animatable>
<neon-animatable>
|
f6aff0c5
Renato De Donato
loader
|
183
|
<div id="div_datasetexplorer"></div>
|
a31f0660
root
sevc-controllet i...
|
184
185
186
|
</neon-animatable>
<neon-animatable>
|
e0e4a976
Renato De Donato
data-sevc-control...
|
187
|
<!--popular-->
|
a31f0660
root
sevc-controllet i...
|
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
|
</neon-animatable>
</neon-animated-pages>
</paper-material>
</template>
<script>
Polymer({
is : 'dataset-selection-controllet',
properties : {
selected : {
type : Number,
value : 0
},
datasets : {
type : Array,
value : undefined
},
|
0f6424fe
root
update new data-s...
|
214
215
216
217
218
|
filteredDatasets : {
type : Array,
value : []
},
|
e0e4a976
Renato De Donato
data-sevc-control...
|
219
220
221
222
223
|
suggestedDatasets : {
type : Array,
value : undefined
},
|
fb432ae9
Renato De Donato
suggested
|
224
225
226
227
228
|
isSuggested : {
type : Boolean,
value : false
},
|
a31f0660
root
sevc-controllet i...
|
229
230
231
232
|
dataUrl : {
type : String,
value : undefined,
observer : '_fireDataUrl'
|
5c96a7bc
Renato De Donato
controllet invali...
|
233
234
235
236
237
|
},
errorMessage : {
type : String,
value : "",
|
a31f0660
root
sevc-controllet i...
|
238
239
240
241
242
|
}
},
listeners: {
|
0f6424fe
root
update new data-s...
|
243
244
|
'datasetexplorer-datalet_data-url': '_selectDataUrl_treeMap',
'paper-input-search_input-value' : '_filterDatasets'
|
a31f0660
root
sevc-controllet i...
|
245
246
247
|
},
ready : function(){
|
f6aff0c5
Renato De Donato
loader
|
248
|
$(this.$.material_container).perfectScrollbar();
|
a31f0660
root
sevc-controllet i...
|
249
|
$(this.$.dialog_info).perfectScrollbar();
|
5c96a7bc
Renato De Donato
controllet invali...
|
250
251
|
this.errorMessage = ln["wrongUrl_" + ln["localization"]];
|
a31f0660
root
sevc-controllet i...
|
252
253
254
255
256
257
|
},
attached : function(){
this._resize();
var that = this;
window.addEventListener("resize", function() { that._resize(); });
|
0f6424fe
root
update new data-s...
|
258
259
|
this.filteredDatasets = this.datasets;
|
0f6424fe
root
update new data-s...
|
260
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
261
|
if(this.suggestedDatasets)
|
fb432ae9
Renato De Donato
suggested
|
262
|
this.isSuggested = true;
|
4a58f4fc
Renato De Donato
treemap placeholder
|
263
264
|
this._loadTreeMap();
|
0e9aeacd
root
localization l20n
|
265
|
|
6d2a2a1e
Andrea Petta
language handling
|
266
|
this.async(function(){this._translate();},100);
|
0e9aeacd
root
localization l20n
|
267
268
269
|
},
_translate : function(){
|
6d2a2a1e
Andrea Petta
language handling
|
270
271
272
273
|
this.$._datasets.setAttribute("label", ln["availableDatasets_" + ln["localization"]]);
this.$.listView.innerHTML = ln["listView_" + ln["localization"]];
this.$.treeMapView.innerHTML = ln["treeMapView_" + ln["localization"]];
|
d2da5141
Renato De Donato
async 0
|
274
|
if(this.isSuggested)
|
6d2a2a1e
Andrea Petta
language handling
|
275
276
|
this.$$("#s_datasets").setAttribute("label", ln["suggestedDatasets_" + ln["localization"]]);
this.$.selected_url.setAttribute("label", ln["selectedUrl_" + ln["localization"]]);
|
e0e4a976
Renato De Donato
data-sevc-control...
|
277
278
|
},
|
0f6424fe
root
update new data-s...
|
279
|
_filterDatasets : function(e){
|
47c1dcd5
root
selectio-controll...
|
280
|
var filter = e.detail.inputValue;
|
0f6424fe
root
update new data-s...
|
281
282
283
284
285
286
287
|
var filteredDatasets = [];
for (var i in this.datasets){
if(this.datasets[i].name.toLowerCase().indexOf(filter.toLowerCase()) != -1)
filteredDatasets.push(this.datasets[i]);
}
this.filteredDatasets = filteredDatasets;
|
a31f0660
root
sevc-controllet i...
|
288
289
290
|
},
_loadTreeMap : function(){
|
4a58f4fc
Renato De Donato
treemap placeholder
|
291
292
|
var h = $("#material_container").height() - 48;
var w = $("#material_container").width();
|
57ef9bf4
Renato De Donato
labels + info
|
293
|
// /oxwall_x.y.z
|
57372c47
root
Updated treemap
|
294
|
this.$.div_datasetexplorer.innerHTML = "<datasetexplorer-datalet width=\""+w+"\" height=\""+h+"\" data-url=\"/openwall/api/datasetTree\" fields='[\"result,datasets,provider_name\",\"result,datasets,organization_name\",\"result,datasets,package_name\",\"result,datasets,resource_name\",\"result,datasets,url\",\"result,datasets,w\"]'></datasetexplorer-datalet>";
|
a31f0660
root
sevc-controllet i...
|
295
296
|
},
|
57ef9bf4
Renato De Donato
labels + info
|
297
298
299
300
|
_selectDataUrl_treeMap : function(e) {
$("#_datasets")[0]._setSelectedItem(null);
$("#_datasets")[0].inputValue = "";
$("#info_dataset")[0].setAttribute("disabled", "true");
|
a31f0660
root
sevc-controllet i...
|
301
|
|
57ef9bf4
Renato De Donato
labels + info
|
302
303
304
305
306
|
if (this.isSuggested) {
$("#s_datasets")[0]._setSelectedItem(null);
$("#s_datasets")[0].contentElement.select(-1);
$("#info_s_dataset")[0].setAttribute("disabled", "true");
}
|
a31f0660
root
sevc-controllet i...
|
307
|
|
57ef9bf4
Renato De Donato
labels + info
|
308
|
this.dataUrl = e.detail.url;
|
a31f0660
root
sevc-controllet i...
|
309
310
311
|
this.selected=0;
},
|
0e9aeacd
root
localization l20n
|
312
|
_selectDataUrl : function(e){this._translate();
|
57ef9bf4
Renato De Donato
labels + info
|
313
314
315
316
317
318
|
if (this.isSuggested) {
$("#s_datasets")[0]._setSelectedItem(null);
$("#s_datasets")[0].contentElement.select(-1);
$("#info_s_dataset")[0].setAttribute("disabled", "true");
}
|
47c1dcd5
root
selectio-controll...
|
319
|
var dataset = this.filteredDatasets[parseInt(e.target.id)]
|
a31f0660
root
sevc-controllet i...
|
320
|
|
0ff13705
root
suggested dataset...
|
321
322
|
this.dataUrl = dataset.url;
|
57ef9bf4
Renato De Donato
labels + info
|
323
324
325
326
327
328
329
|
if(dataset.description != ""){
$("#info_dataset")[0].removeAttribute("disabled");
this.$.dialog_name.innerHTML = dataset.name;
this.$.dialog_description.innerHTML = dataset.description;
}
else
$("#info_dataset")[0].setAttribute("disabled", "true");
|
0ff13705
root
suggested dataset...
|
330
331
332
|
},
_selectSuggestedDataUrl : function(e){
|
57ef9bf4
Renato De Donato
labels + info
|
333
334
335
336
|
$("#_datasets")[0]._setSelectedItem(null);
$("#_datasets")[0].inputValue = "";
$("#info_dataset")[0].setAttribute("disabled", "true");
|
0ff13705
root
suggested dataset...
|
337
338
|
var dataset = this.suggestedDatasets[parseInt(e.target.id)]
|
a31f0660
root
sevc-controllet i...
|
339
340
|
this.dataUrl = dataset.url;
|
57ef9bf4
Renato De Donato
labels + info
|
341
342
343
344
345
346
347
|
if(dataset.description != ""){
$("#info_s_dataset")[0].removeAttribute("disabled");
this.$.dialog_name.innerHTML = dataset.name;
this.$.dialog_description.innerHTML = dataset.description;
}
else
$("#info_s_dataset")[0].setAttribute("disabled", "true");
|
a31f0660
root
sevc-controllet i...
|
348
349
|
},
|
57ef9bf4
Renato De Donato
labels + info
|
350
351
352
353
354
|
_showInfo : function(e){
var t = e.target;
if(t.tagName.indexOf("IRON-ICON") != -1)
t = $(e.target).parents("paper-icon-button")[0];
|
a31f0660
root
sevc-controllet i...
|
355
|
this.$.dialog_info.open();
|
57ef9bf4
Renato De Donato
labels + info
|
356
357
358
359
|
var pos = t.getBoundingClientRect();
$("#dialog_info").css("top", pos.top - 4);
$("#dialog_info").css("left", pos.left - 4);
|
a31f0660
root
sevc-controllet i...
|
360
361
362
363
364
365
|
},
_fireDataUrl : function(){
this.fire('dataset-selection-controllet_data-url', {url: this.dataUrl});
},
|
a31f0660
root
sevc-controllet i...
|
366
367
368
369
370
371
372
373
374
375
|
_resize : function(){
var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16;
h = h - 64 - 8; //height with page scroller
$("#material_container").height(h);
}
});
</script>
|
57372c47
root
Updated treemap
|
376
|
</dom-module>
|