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}}">
|
0e9aeacd
root
localization l20n
|
130
131
132
|
<paper-tab noink><span data-l10n-id="listView"></span></paper-tab>
<paper-tab noink><span data-l10n-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
|
|
a31f0660
root
sevc-controllet i...
|
172
173
|
<paper-textarea id="selected_url" label="Selected url" value={{dataUrl}}></paper-textarea>
|
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
233
234
235
236
237
|
dataUrl : {
type : String,
value : undefined,
observer : '_fireDataUrl'
}
},
listeners: {
|
0f6424fe
root
update new data-s...
|
238
239
|
'datasetexplorer-datalet_data-url': '_selectDataUrl_treeMap',
'paper-input-search_input-value' : '_filterDatasets'
|
a31f0660
root
sevc-controllet i...
|
240
241
242
|
},
ready : function(){
|
f6aff0c5
Renato De Donato
loader
|
243
|
$(this.$.material_container).perfectScrollbar();
|
a31f0660
root
sevc-controllet i...
|
244
245
246
247
248
249
250
|
$(this.$.dialog_info).perfectScrollbar();
},
attached : function(){
this._resize();
var that = this;
window.addEventListener("resize", function() { that._resize(); });
|
0f6424fe
root
update new data-s...
|
251
252
|
this.filteredDatasets = this.datasets;
|
0f6424fe
root
update new data-s...
|
253
|
|
e0e4a976
Renato De Donato
data-sevc-control...
|
254
|
if(this.suggestedDatasets)
|
fb432ae9
Renato De Donato
suggested
|
255
|
this.isSuggested = true;
|
4a58f4fc
Renato De Donato
treemap placeholder
|
256
257
|
this._loadTreeMap();
|
0e9aeacd
root
localization l20n
|
258
259
260
261
262
|
this._translate();
},
_translate : function(){
|
90890e86
Andrea Petta
l20n bug fix
|
263
264
|
var that = this;
document.l10n.formatValue('availableDatasets').then(function(s){$("#_datasets")[0].setAttribute("label", s)});
|
d2da5141
Renato De Donato
async 0
|
265
|
if(this.isSuggested)
|
90890e86
Andrea Petta
l20n bug fix
|
266
267
|
document.l10n.formatValue('suggestedDatasets').then(function(s){$("#s_datasets")[0].setAttribute("label", s)});
document.l10n.formatValue('selectedUrl').then(function(s){that.$.selected_url.setAttribute("label", s)});
|
e0e4a976
Renato De Donato
data-sevc-control...
|
268
269
|
},
|
0f6424fe
root
update new data-s...
|
270
|
_filterDatasets : function(e){
|
47c1dcd5
root
selectio-controll...
|
271
|
var filter = e.detail.inputValue;
|
0f6424fe
root
update new data-s...
|
272
273
274
275
276
277
278
|
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...
|
279
280
281
|
},
_loadTreeMap : function(){
|
4a58f4fc
Renato De Donato
treemap placeholder
|
282
283
|
var h = $("#material_container").height() - 48;
var w = $("#material_container").width();
|
57ef9bf4
Renato De Donato
labels + info
|
284
|
// /oxwall_x.y.z
|
3501c407
Renato De Donato
treemap placeholder
|
285
|
this.$.div_datasetexplorer.innerHTML = "<datasetexplorer-datalet width=\""+w+"\" height=\""+h+"\" data-url=\"/openwall/api/datasetTree\" fields='[\"result,provider_name\",\"result,organization_name\",\"result,package_name\",\"result,resource_name\",\"result,url\",\"result,w\"]'></datasetexplorer-datalet>";
|
a31f0660
root
sevc-controllet i...
|
286
287
|
},
|
57ef9bf4
Renato De Donato
labels + info
|
288
289
290
291
|
_selectDataUrl_treeMap : function(e) {
$("#_datasets")[0]._setSelectedItem(null);
$("#_datasets")[0].inputValue = "";
$("#info_dataset")[0].setAttribute("disabled", "true");
|
a31f0660
root
sevc-controllet i...
|
292
|
|
57ef9bf4
Renato De Donato
labels + info
|
293
294
295
296
297
|
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...
|
298
|
|
57ef9bf4
Renato De Donato
labels + info
|
299
|
this.dataUrl = e.detail.url;
|
a31f0660
root
sevc-controllet i...
|
300
301
302
|
this.selected=0;
},
|
0e9aeacd
root
localization l20n
|
303
|
_selectDataUrl : function(e){this._translate();
|
57ef9bf4
Renato De Donato
labels + info
|
304
305
306
307
308
309
|
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...
|
310
|
var dataset = this.filteredDatasets[parseInt(e.target.id)]
|
a31f0660
root
sevc-controllet i...
|
311
|
|
0ff13705
root
suggested dataset...
|
312
313
|
this.dataUrl = dataset.url;
|
57ef9bf4
Renato De Donato
labels + info
|
314
315
316
317
318
319
320
|
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...
|
321
322
323
|
},
_selectSuggestedDataUrl : function(e){
|
57ef9bf4
Renato De Donato
labels + info
|
324
325
326
327
|
$("#_datasets")[0]._setSelectedItem(null);
$("#_datasets")[0].inputValue = "";
$("#info_dataset")[0].setAttribute("disabled", "true");
|
0ff13705
root
suggested dataset...
|
328
329
|
var dataset = this.suggestedDatasets[parseInt(e.target.id)]
|
a31f0660
root
sevc-controllet i...
|
330
331
|
this.dataUrl = dataset.url;
|
57ef9bf4
Renato De Donato
labels + info
|
332
333
334
335
336
337
338
|
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...
|
339
340
|
},
|
57ef9bf4
Renato De Donato
labels + info
|
341
342
343
344
345
|
_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...
|
346
|
this.$.dialog_info.open();
|
57ef9bf4
Renato De Donato
labels + info
|
347
348
349
350
|
var pos = t.getBoundingClientRect();
$("#dialog_info").css("top", pos.top - 4);
$("#dialog_info").css("left", pos.left - 4);
|
a31f0660
root
sevc-controllet i...
|
351
352
353
354
355
356
|
},
_fireDataUrl : function(){
this.fire('dataset-selection-controllet_data-url', {url: this.dataUrl});
},
|
a31f0660
root
sevc-controllet i...
|
357
358
359
360
361
362
363
364
365
366
367
|
_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>
</dom-module>
|