Blame view

controllets/select-dataset-controllet/select-dataset-controllet.html 32.2 KB
fb05b400   Renato De Donato   controllet 2.0, n...
1
  <link rel="import" href="../../bower_components/polymer/polymer.html">
a53fbbed   Renato De Donato   select-dataset ne...
2
3
4
5
6
7
8
9
  
  <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">
  
fb05b400   Renato De Donato   controllet 2.0, n...
10
11
  <link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout.html">
  <!--<link rel="import" href="../../bower_components/app-layout/app-toolbar/app-toolbar.html">-->
a748d9bc   Renato De Donato   ala NUMBER bug
12
  <link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">
fb05b400   Renato De Donato   controllet 2.0, n...
13
14
15
  <link rel="import" href="../../bower_components/paper-styles/color.html">
  <link rel="import" href="../../bower_components/paper-styles/typography.html">
  <link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
a748d9bc   Renato De Donato   ala NUMBER bug
16
  <link rel="import" href="../../bower_components/iron-icons/iron-icons.html">
fb05b400   Renato De Donato   controllet 2.0, n...
17
18
  <link rel="import" href="../../bower_components/iron-image/iron-image.html">
  <link rel="import" href="../../bower_components/iron-list/iron-list.html">
a748d9bc   Renato De Donato   ala NUMBER bug
19
  
a53fbbed   Renato De Donato   select-dataset ne...
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  <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-input.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/hardware-icons.html">
  <!--<link rel="import" href="../../bower_components/iron-icons/iron-icons.html">-->
  
  <link rel="import" href="../../bower_components/paper-checkbox/paper-checkbox.html">
  
  <link rel="import" href="../../datalets/datasetexplorer-datalet/datasetexplorer-datalet.html">
a748d9bc   Renato De Donato   ala NUMBER bug
37
  
fb05b400   Renato De Donato   controllet 2.0, n...
38
  <dom-module id="select-dataset-controllet">
a748d9bc   Renato De Donato   ala NUMBER bug
39
      <template>
fb05b400   Renato De Donato   controllet 2.0, n...
40
          <style>
a53fbbed   Renato De Donato   select-dataset ne...
41
42
43
44
45
46
47
48
49
              :host {
              --paper-dropdown-menu-icon: {
                   color: #000000;
               };
              --paper-dropdown-menu-ripple: {
                   color: #FFFFFF;
               };
              /*--paper-tab-ink: {*/
                   /*color: #FFFFFF;*/
fb05b400   Renato De Donato   controllet 2.0, n...
50
               /*};*/
a53fbbed   Renato De Donato   select-dataset ne...
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
              }
  
              iron-list {
              --iron-list-items-container: {
                  margin:16px 16px 8px 16px;
               };
              }
  
              paper-textarea {
                  width: 100%;
                  --paper-input-container-focus-color: #2196F3;
              }
  
              paper-input {
                  --paper-input-container-focus-color: #2196F3;
              }
              paper-dropdown-menu {
                  width: 100%;
                  --paper-input-container-focus-color: #2196F3;
              }
  
              paper-item.iron-selected {
                  background-color: #2196F3;
                  color: #FFFFFF;
              }
  
              paper-checkbox {
                  height: 24px;
                  /*margin-top: 8px*/
                  --paper-checkbox-checked-color: #2196F3;
                  --paper-checkbox-checked-ink-color: #FFFFFF;
                  --paper-checkbox-unchecked-color: #000000;
                  --paper-checkbox-unchecked-ink-color: #FFFFFF;
                  --paper-checkbox-label-color: #000000;
              }
  
              paper-icon-button{
                  height: 48px;
                  width: 48px;
                  padding: 0px;
                  --paper-icon-button-ink-color: #FFFFFF;
              }
  
              paper-icon-button:hover{
                  color: #2196F3;
              }
  
              paper-icon-button[disabled]{
                  color: #B6B6B6;
              }
  
              paper-icon-button.clear {
                  width: 24px;
                  height: 24px;
                  padding: 0px 4px;
                  color: #F44336;
                  --paper-icon-button-ink-color: #FFFFFF;
              }
  
              paper-tabs {
                  font-weight: bold;
              }
  
              paper-tab {
                  transition: all 1.0s;
              }
  
              paper-tab.iron-selected {
                  background-color: #2196F3;
                  color: #FFFFFF;
              }
  
              paper-tab:not(.iron-selected):hover {
                  color: #2196F3;
              }
  
fb05b400   Renato De Donato   controllet 2.0, n...
127
              .item {
a53fbbed   Renato De Donato   select-dataset ne...
128
129
130
131
                  /*@apply(--layout-horizontal);*/
                  display: flex;
                  padding: 11px;
                  border: 1px solid #B6B6B6;
190145a5   Renato De Donato   style
132
                  border-radius: 4px;
fb05b400   Renato De Donato   controllet 2.0, n...
133
134
                  cursor: pointer;
                  margin-bottom: 8px;
a53fbbed   Renato De Donato   select-dataset ne...
135
                  background-color: #E0E0E0;
fb05b400   Renato De Donato   controllet 2.0, n...
136
137
              }
  
cd9f822e   Renato De Donato   split 1st step
138
139
140
141
142
              .item.expanded {
                  /*border: 2px solid #2196F3;*/
                  border-color: #2196F3;
              }
  
fb05b400   Renato De Donato   controllet 2.0, n...
143
              .pad {
a53fbbed   Renato De Donato   select-dataset ne...
144
145
                  @apply(--layout-flex);
                  /*@apply(--layout-vertical);*/
fb05b400   Renato De Donato   controllet 2.0, n...
146
              }
a53fbbed   Renato De Donato   select-dataset ne...
147
  
fb05b400   Renato De Donato   controllet 2.0, n...
148
              .primary {
fb05b400   Renato De Donato   controllet 2.0, n...
149
                  font-weight: bold;
fb05b400   Renato De Donato   controllet 2.0, n...
150
              }
a53fbbed   Renato De Donato   select-dataset ne...
151
152
153
  
              .item.expanded .primary {
                  color: #2196F3;
a748d9bc   Renato De Donato   ala NUMBER bug
154
              }
a53fbbed   Renato De Donato   select-dataset ne...
155
  
fb05b400   Renato De Donato   controllet 2.0, n...
156
              .longText {
fb05b400   Renato De Donato   controllet 2.0, n...
157
                  display: none;
a748d9bc   Renato De Donato   ala NUMBER bug
158
              }
a53fbbed   Renato De Donato   select-dataset ne...
159
  
fb05b400   Renato De Donato   controllet 2.0, n...
160
161
162
              .item.expanded .longText {
                  display: block;
              }
fb05b400   Renato De Donato   controllet 2.0, n...
163
  
a53fbbed   Renato De Donato   select-dataset ne...
164
165
166
              #select_dataset_container {
                  margin-top: 8px;
              }
a748d9bc   Renato De Donato   ala NUMBER bug
167
  
a53fbbed   Renato De Donato   select-dataset ne...
168
              #select_dataset_container * {
fb05b400   Renato De Donato   controllet 2.0, n...
169
170
                  font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
                  font-size: 16px;
a53fbbed   Renato De Donato   select-dataset ne...
171
172
                  line-height: 24px;
              }
a748d9bc   Renato De Donato   ala NUMBER bug
173
  
a53fbbed   Renato De Donato   select-dataset ne...
174
175
176
177
              #select_dataset_container #neon_container {
                  height: calc(100% - 172px);
                  width: calc(100% - 8px);
              }
a748d9bc   Renato De Donato   ala NUMBER bug
178
  
cd9f822e   Renato De Donato   split 1st step
179
180
              #select_dataset_container #list_info {
                  display: flex;
a53fbbed   Renato De Donato   select-dataset ne...
181
                  height: calc(100% - 48px);
cd9f822e   Renato De Donato   split 1st step
182
183
184
185
                  width: calc(100% + 8px);/*bad*/
              }
  
              #select_dataset_container #list_container {
a53fbbed   Renato De Donato   select-dataset ne...
186
                  position: relative;
cd9f822e   Renato De Donato   split 1st step
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
                  height: 100%;
                  width: 50%;
                  border-left: 4px solid #B6B6B6;;
              }
  
              #select_dataset_container #info_container {
                  position: relative;
                  height: 100%;
                  width: 50%;
                  border-right: 4px solid #B6B6B6;
  
                  /*background-color: red;*/
              }
  
              #select_dataset_container #info {
                  position: relative;
                  height: calc(100% - 56px);
                  width: calc(100% - 56px);
                  padding: 11px;
                  border: 1px solid #B6B6B6;
                  border-radius: 4px;
                  background-color: #E0E0E0;
                  margin: 16px;
a748d9bc   Renato De Donato   ala NUMBER bug
210
211
              }
  
a53fbbed   Renato De Donato   select-dataset ne...
212
213
214
215
216
217
218
219
220
              #select_dataset_container #treemap_container {
                  /*height: calc(100% - 244px);*/
                  /*width: calc(100% - 8px);*/
                  height: calc(100% - 48px);
                  width: 100%;
                  border: 4px solid #B6B6B6;
                  border-top: 0px;
                  border-bottom: 0px;
                  position: relative;
a748d9bc   Renato De Donato   ala NUMBER bug
221
222
              }
  
a53fbbed   Renato De Donato   select-dataset ne...
223
              #select_dataset_container #header {
3388b02b   Renato De Donato   shadow x Andrea
224
225
226
227
228
229
                  position: relative;
                  z-index: 1;
                  -webkit-box-shadow: 0 30px 24px -12px rgba(0, 0, 0, 0.14), 0 20px 30px -9px rgba(0, 0, 0, 0.12), 0 20px 10px -19px rgba(0, 0, 0, 0.4);
                  -moz-box-shadow: 0 30px 24px -12px rgba(0, 0, 0, 0.14), 0 20px 30px -9px rgba(0, 0, 0, 0.12), 0 20px 10px -19px rgba(0, 0, 0, 0.4);
                  box-shadow: 0 30px 24px -12px rgba(0, 0, 0, 0.14), 0 20px 30px -9px rgba(0, 0, 0, 0.12), 0 20px 10px -19px rgba(0, 0, 0, 0.4);
  
a748d9bc   Renato De Donato   ala NUMBER bug
230
                  background-color: #B6B6B6;
a53fbbed   Renato De Donato   select-dataset ne...
231
232
233
                  display: flex;
                  padding: 0px 4px;
              }
a748d9bc   Renato De Donato   ala NUMBER bug
234
  
3388b02b   Renato De Donato   shadow x Andrea
235
236
237
238
239
240
241
242
243
244
245
246
247
248
              #select_dataset_container #footer_list {
                  position: relative;
                  z-index: 1;
                  -webkit-box-shadow: 0 -30px 24px -12px rgba(0, 0, 0, 0.14), 0 -20px 30px -9px rgba(0, 0, 0, 0.12), 0 -20px 10px -19px rgba(0, 0, 0, 0.4);
                  -moz-box-shadow: 0 -30px 24px -12px rgba(0, 0, 0, 0.14), 0 -20px 30px -9px rgba(0, 0, 0, 0.12), 0 -20px 10px -19px rgba(0, 0, 0, 0.4);
                  box-shadow: 0 -30px 24px -12px rgba(0, 0, 0, 0.14), 0 -20px 30px -9px rgba(0, 0, 0, 0.12), 0 -20px 10px -19px rgba(0, 0, 0, 0.4);
              }
  
              .noshadow {
                  -webkit-box-shadow: none !important;
                  -moz-box-shadow: none !important;
                  box-shadow: none !important;
              }
  
a53fbbed   Renato De Donato   select-dataset ne...
249
250
251
252
253
254
255
256
257
258
259
260
261
262
              #select_dataset_container #footer_list,
              #select_dataset_container #footer_treemap {
                  width: 100%;
                  background-color: #B6B6B6;
                  display: flex;
                  padding: 0px 4px;
              }
  
              #select_dataset_container #url {
                  height: 76px;/*100*/
                  border: 4px solid #B6B6B6;
                  border-top: 0px;
                  padding: 0px 16px;
                  margin-top: -4px;
a748d9bc   Renato De Donato   ala NUMBER bug
263
              }
a53fbbed   Renato De Donato   select-dataset ne...
264
265
266
267
268
269
270
271
272
273
274
275
276
  
              #header .header_block {
                  width: 20%;
                  height: 40px;
                  padding: 4px 16px 4px 16px;
              }
  
              /*.header_block:nth-child(2), .header_block:nth-child(3), .header_block:nth-child(3), .header_block:nth-child(4){*/
                  /*visibility: hidden;*/
              /*}*/
  
              #header .header_block:nth-child(4) {
                  text-align: center;
a748d9bc   Renato De Donato   ala NUMBER bug
277
278
              }
  
a53fbbed   Renato De Donato   select-dataset ne...
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
              .footer_block {
                  width: calc((100% - 0px) / 3);
                  height: 24px;
                  padding: 12px 8px 12px 8px;
                  text-align: center;
              }
  
              .footer_block:nth-child(2) {
                  height: 48px;
                  padding: 0px 8px;
              }
  
              #suggested_div {
                  visibility: hidden;
              }
c5fa9cdb   Renato De Donato   info style
294
295
296
297
298
299
  
              /*.info_resource_name {*/
                  /*color: #2196F3;*/
                  /*font-weight: bold;*/
                  /*line-height: 48px;*/
              /*}*/
a748d9bc   Renato De Donato   ala NUMBER bug
300
301
          </style>
  
a53fbbed   Renato De Donato   select-dataset ne...
302
          <paper-material id="select_dataset_container" elevation="5">
a748d9bc   Renato De Donato   ala NUMBER bug
303
  
a53fbbed   Renato De Donato   select-dataset ne...
304
305
306
              <paper-tabs selected="{{selected}}" no-bar>
                  <paper-tab noink on-tap="_refreshList"><span id="listView"></span></paper-tab>
                  <!--<paper-tab noink ><span id="listView"></span></paper-tab>-->
3388b02b   Renato De Donato   shadow x Andrea
307
                  <paper-tab on-tap="_noShadow" noink><span id="treeMapView"></span></paper-tab>
a53fbbed   Renato De Donato   select-dataset ne...
308
              </paper-tabs>
a748d9bc   Renato De Donato   ala NUMBER bug
309
  
a53fbbed   Renato De Donato   select-dataset ne...
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
              <div id="header">
                  <div class="header_block">
                      <paper-dropdown-menu id="ddl_provider" label="" no-label-float>
                          <paper-menu class="dropdown-content" selected="0">
                              <paper-item id="0" on-tap="_filter"></paper-item>
                              <template is="dom-repeat" items={{_toArray(providers)}} as="provider">
                                  <!--<paper-item id={{provider.value.id}} style$="background: {{_getProviderColor(provider.value.id)}};">{{provider.value.title}}</paper-item>-->
                                  <paper-item id={{provider.value.id}} on-tap="_filter">{{provider.value.title}}</paper-item>
                              </template>
                          </paper-menu>
                      </paper-dropdown-menu>
                  </div>
                  <div class="header_block">
                  </div>
                  <div class="header_block">
                  </div>
                  <div class="header_block">
                  </div>
                  <div class="header_block">
                      <paper-input id="datasets_filter" value={{filter}} no-label-float label="">
                          <iron-icon class="search" icon="search" prefix></iron-icon>
                          <paper-icon-button class="clear" suffix on-click="_clearInput" icon="clear" tabindex="0"></paper-icon-button>
                      </paper-input>
                  </div>
a748d9bc   Renato De Donato   ala NUMBER bug
334
335
              </div>
  
a53fbbed   Renato De Donato   select-dataset ne...
336
337
338
              <neon-animated-pages id="neon_container" selected="{{selected}}" entry-animation="fade-in-animation" exit-animation="fade-out-animation">
  
                  <neon-animatable>
cd9f822e   Renato De Donato   split 1st step
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
                      <div id="list_info">
                          <div id="list_container">
                              <iron-list id="list" items="{{shownDatasets}}" selection-enabled>
                                  <template>
                                      <div>
                                          <div class$="{{getClassForItem(selected)}}" on-tap="_selectDataUrl" style$="background: {{_getColorForItem(item)}};">
                                              <span style="display:none;">{{item.url}}</span>
                                              <div class="pad">
                                                  <div class="primary">{{item.resource_name}}</div>
                                                  <!--<div class="longText">-->
                                                      <!--<template is="dom-repeat" items="{{_stringToArray(item.metas)}}" as="mata">-->
                                                          <!--<b>{{mata.name}}:</b>-->
                                                          <!--<span inner-h-t-m-l="{{mata.value}}"></span> <br>-->
                                                      <!--</template>-->
                                                  <!--</div>-->
a53fbbed   Renato De Donato   select-dataset ne...
354
                                              </div>
cd9f822e   Renato De Donato   split 1st step
355
                                              <iron-icon icon$="{{_getIconForItem(item)}}" style$="color: {{_getColorForIcon(item)}};"></iron-icon>
a53fbbed   Renato De Donato   select-dataset ne...
356
                                          </div>
a53fbbed   Renato De Donato   select-dataset ne...
357
                                      </div>
cd9f822e   Renato De Donato   split 1st step
358
359
360
361
362
363
364
                                  </template>
                              </iron-list>
                          </div>
                          <div id="info_container">
                              <div id="info">
                              </div>
                          </div>
a53fbbed   Renato De Donato   select-dataset ne...
365
366
367
368
369
370
371
372
373
374
375
376
                      </div>
  
                      <div id="footer_list">
                          <div class="footer_block"><span id="showing"></span> {{shownPrev}} <span id="to"></span> {{shownNext}} <span id="of"></span> {{length}} <span id="datasets"></span></div>
                          <div class="footer_block">
                              <paper-icon-button id="slider_chevron_left" class="chevron-left" on-click="_onPrevClick" icon="chevron-left"></paper-icon-button>
                              <paper-icon-button id="slider_chevron_right" class="chevron-right" on-click="_onNextClick" icon="chevron-right"></paper-icon-button>
                          </div>
                          <div id="suggested_div" class="footer_block">
                              <!--<template is="dom-if" if={{suggestedDatasets}}>-->
                                  <paper-checkbox checked on-change="showSuggested"><span id="suggested_datasets"></span></paper-checkbox>
                              <!--</template>-->
a748d9bc   Renato De Donato   ala NUMBER bug
377
                          </div>
a53fbbed   Renato De Donato   select-dataset ne...
378
379
380
381
382
383
384
385
386
387
388
389
                      </div>
                  </neon-animatable>
  
                  <neon-animatable>
                      <div id="treemap_container"></div>
  
                      <div id="footer_treemap">
                          <div class="footer_block"><span id="showing2"></span> {{tLength}} <span id="datasets2"></span></div>
                          <div class="footer_block"></div>
                          <div class="footer_block"></div>
                      </div>
                  </neon-animatable>
a748d9bc   Renato De Donato   ala NUMBER bug
390
  
a53fbbed   Renato De Donato   select-dataset ne...
391
392
393
394
              </neon-animated-pages>
  
              <div id="url">
                  <paper-textarea id="selected_url" label="" value={{dataUrl}} error-message={{errorMessage}}></paper-textarea>
a748d9bc   Renato De Donato   ala NUMBER bug
395
396
              </div>
  
a53fbbed   Renato De Donato   select-dataset ne...
397
          </paper-material>
a748d9bc   Renato De Donato   ala NUMBER bug
398
399
400
401
  
      </template>
  
      <script>
fb05b400   Renato De Donato   controllet 2.0, n...
402
403
404
405
          HTMLImports.whenReady(function() {
              Polymer({
                  is: 'select-dataset-controllet',
                  properties: {
a53fbbed   Renato De Donato   select-dataset ne...
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
                      datasets: {
                          type: Object,
                          value: undefined
                      },
                      filteredDatasets : {
                          type : Array,
                          value : undefined
                      },
                      shownDatasets : {
                          type : Array,
                          value : undefined
                      },
                      suggestedDatasets : {
                          type : Array,
                          value : undefined
                      },
  
                      providers : {
                          type : Array,
                          value : undefined
                      },
                      dataUrl : {
                          type  : String,
                          value : undefined,
                          observer : '_fireDataUrl'
                      },
                      filter : {
                          type  : String,
                          value : "",
                          observer : '_filter'
                      },
                      selected : {
                          type  : Number,
                          value : 0
                      },
                      prev : {type  : Number, value : undefined},
                      next : {type  : Number, value : undefined},
                      shownPrev : {type  : Number, value : undefined},
                      shownNext : {type  : Number, value : undefined},
                      length : {type  : Number, value : undefined},
                      tLength : {type  : Number, computed : 'treemapLength(length)'},
                      step : {type  : Number, value : 20},
                      colors : {
                          type : Array,
                          value : ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"]
fb05b400   Renato De Donato   controllet 2.0, n...
451
                      }
a748d9bc   Renato De Donato   ala NUMBER bug
452
                  },
a53fbbed   Renato De Donato   select-dataset ne...
453
454
455
456
457
  
                  listeners: {
                      'datasetexplorer-datalet_data-url': '_selectDataUrl_treeMap'
                  },
  
fb05b400   Renato De Donato   controllet 2.0, n...
458
459
                  ready : function() {
                      $(this.$.list_container).perfectScrollbar();
cd9f822e   Renato De Donato   split 1st step
460
                      $(this.$.info).perfectScrollbar();
a53fbbed   Renato De Donato   select-dataset ne...
461
462
  
  //                    this.$.selected_url.invalid = true;
a748d9bc   Renato De Donato   ala NUMBER bug
463
464
                  },
  
fb05b400   Renato De Donato   controllet 2.0, n...
465
                  attached: function() {
a53fbbed   Renato De Donato   select-dataset ne...
466
467
                      this._resize();
                      var that = this;
20799010   Renato De Donato   treemap resize
468
                      window.addEventListener("resize", function() { that._resize(); that._loadTreeMap();});
a53fbbed   Renato De Donato   select-dataset ne...
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
  
                      this.providers = this.datasets["result"]["providers"];
                      this.datasets = this.datasets["result"]["datasets"];
  
                      if(this.suggestedDatasets) {
                          this.tempDatasets = this.datasets;
                          this.datasets = this.suggestedDatasets.concat(this.datasets);
                          this.$.suggested_div.style.visibility = "visible";
                      }
  
                      this.filteredDatasets = this.datasets;
  
                      this.prev = 1;
                      this.next = this.step;
                      this.length = this.filteredDatasets.length;
  
                      this.shownPrev = Math.min(this.prev, this.length);
                      this.shownNext = Math.min(this.next, this.length);
                      this.shownDatasets = this.filteredDatasets.slice(this.prev-1, this.next);
  
fb05b400   Renato De Donato   controllet 2.0, n...
489
                      this.$.list.scrollTarget = this.ownerDocument.documentElement;
a53fbbed   Renato De Donato   select-dataset ne...
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
  
                      this._translate();
  
                      this._loadTreeMap();
                  },
  
                  _translate : function(){
                      this.$.listView.innerHTML    = ln["listView_" + ln["localization"]];
                      this.$.treeMapView.innerHTML = ln["treeMapView_" + ln["localization"]];
  
                      this.$.ddl_provider.setAttribute("label", ln["provider_" + ln["localization"]]);
                      this.$.datasets_filter.setAttribute("label", ln["search_" + ln["localization"]]);
  
                      this.$.suggested_datasets.innerHTML = ln["suggestedDatasets_" + ln["localization"]];
  
                      this.$.showing.innerHTML = ln["showing_" + ln["localization"]];
                      this.$.showing2.innerHTML = ln["showing_" + ln["localization"]];
                      this.$.to.innerHTML = ln["to_" + ln["localization"]];
                      this.$.of.innerHTML = ln["of_" + ln["localization"]];
                      this.$.datasets.innerHTML = ln["datasets_" + ln["localization"]];
                      this.$.datasets2.innerHTML = ln["datasets_" + ln["localization"]];
  
                      this.$.selected_url.setAttribute("label", ln["selectedUrl_" + ln["localization"]]);
                      this.errorMessage = ln["wrongUrl_" + ln["localization"]];
a748d9bc   Renato De Donato   ala NUMBER bug
514
                  },
a53fbbed   Renato De Donato   select-dataset ne...
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
  
                  showSuggested : function(e) {
                      if(e.target.checked)
                          this.datasets = this.suggestedDatasets.concat(this.tempDatasets);
                      else
                          this.datasets = this.tempDatasets;
                      this._filter();
                  },
  
                  _loadTreeMap : function(){
                      var h = $("#neon_container").height() - 48;
                      var w = $("#neon_container").width();
  
                      var data = JSON.stringify({result : {providers: this.providers, datasets: this.filteredDatasets}}).replace(/'/g, "");
  
                      if(this.filteredDatasets.length > 0)
                          this.$.treemap_container.innerHTML = "<datasetexplorer-datalet data='"+data+"' width=\""+w+"\" height=\""+h+"\" fields='[\"result,datasets,provider_name\",\"result,datasets,organization_name\",\"result,datasets,package_name\",\"result,datasets,resource_name\",\"result,datasets,url\",\"result,datasets,w\",\"result,datasets,metas\"]'></datasetexplorer-datalet>";
                      else
                          this.$.treemap_container.innerHTML = "";
                  },
  
                  _filter : function() {
                      if(this.filteredDatasets) {
                          this.async(function () {
                              var ddl_provider = $(this.$.ddl_provider).find("paper-menu")[0].selectedItem;
                              var name = ddl_provider.innerHTML.trim();
                              var id = this._getIdByProviderName(name);
                              this.prev = 1;
                              this.next = this.step;
                              if (id) {
                                  //filtered by provider name
                                  this.filteredDatasets = this.datasets.filter(function (el) {
                                      return el.provider_name == "p:" + id;
                                  });
                              }
                              else {
                                  this.filteredDatasets = this.datasets;
                              }
  
                              //filtered by filter
                              var filter = this.filter;
                              this.filteredDatasets = this.filteredDatasets.filter(function (el) {
                                  return el.resource_name.toLowerCase().indexOf(filter.toLowerCase()) > -1;
                              });
  
                              this.length = this.filteredDatasets.length;
  
                              this.shownPrev = Math.min(this.prev, this.length);
                              this.shownNext = Math.min(this.next, this.length);
                              this.shownDatasets = this.filteredDatasets.slice(this.prev - 1, this.next);
  
                              $("#list_container").animate({scrollTop: 0}, 0);
  
                              this._loadTreeMap();
                          }, 0);
                      }
                  },
  
                  _refreshList : function() {
                      this.shownDatasets = this.filteredDatasets.slice(this.prev - 1, this.next);
3388b02b   Renato De Donato   shadow x Andrea
575
576
577
578
579
580
                      this.$.header.className = this.$.header.className.replace(" noshadow", "");
                  },
  
                  _noShadow : function() {
                      console.log(this.$.header);
                      this.$.header.className += " noshadow";
a53fbbed   Renato De Donato   select-dataset ne...
581
582
583
584
                  },
  
                  _clearInput : function() {
                      this.$.datasets_filter.value = "";
a748d9bc   Renato De Donato   ala NUMBER bug
585
                  },
a53fbbed   Renato De Donato   select-dataset ne...
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
  
                  _getIdByProviderName : function(name) {
                      for(var id in this.providers) {
                          if (this.providers[id].title == name)
                              return this.providers[id].id;
                      }
                  },
  
  //                iconForItem: function(item) {
  //                    return item ? (item.integer < 50 ? 'star-border' : 'info-outline') : '';
  //                },
  
                  treemapLength : function(length) {
                      var ddl_provider = $(this.$.ddl_provider).find("paper-menu")[0].selectedItem;
                      var name = ddl_provider.innerHTML.trim();
                      var id = this._getIdByProviderName(name);
  
                      if(this.suggestedDatasets && !id)
                          return Math.max(length - this.suggestedDatasets.length, 0);
                      return length;
                  },
  
                  _getColorForIcon : function(item) {
                      var ddl_provider = $(this.$.ddl_provider).find("paper-menu")[0].selectedItem;
                      var name = ddl_provider.innerHTML.trim();
                      var id = this._getIdByProviderName(name);
                      if (id) {
                          return this.colors[0];
                      }
                      if(!item.provider_name) {
                          return "#00BCD4";
                      }
                      var id = item.provider_name.substring(2, item.provider_name.length);
                      var i = this.getProviderById(id) % this.colors.length;
                      return this.colors[i];
                  },
  
                  _getColorForItem : function(item) {
  //                    var ddl_provider = $(this.$.ddl_provider).find("paper-menu")[0].selectedItem;
  //                    var name = ddl_provider.innerHTML.trim();
  //                    var id = this._getIdByProviderName(name);
  //                    if (id) {
  //                        return this.colors[0];
  //                    }
                      if(!item.provider_name) {
                          return "#FFEB3B";
                      }
  //                    var id = item.provider_name.substring(2, item.provider_name.length);
  //                    var i = this.getProviderById(id) % this.colors.length;
  //                    return this.colors[i];
                  },
  
                  _getIconForItem : function(item) {
                      return item.provider_name ? 'bookmark' : 'star';
                  },
  
  //                _getProviderColor: function(id) {
  //                    var i = this.getProviderById(id) % this.colors.length;
  //                    return this.colors[i];
  //                },
  
                  getClassForItem: function(selected) {
fb05b400   Renato De Donato   controllet 2.0, n...
648
                      return selected ? 'item expanded' : 'item';
a53fbbed   Renato De Donato   select-dataset ne...
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
                  },
  
                  getProviderById: function(providerId) {
                      var i = 0;
                      for(var id in this.providers){
                          if(this.providers[id].id == providerId)
                              return i;
                          i++;
                      }
                  },
  
                  _onPrevClick : function(){
                      if(this.prev != 1) {
                          this.prev -= this.step;
                          this.next -= this.step;
  
                          this.shownPrev = Math.min(this.prev, this.length);
                          this.shownNext = Math.min(this.next, this.length);
                          this.shownDatasets = this.filteredDatasets.slice(this.prev - 1, this.next);
                      }
                      $("#list_container").animate({ scrollTop: 0}, 0);
                  },
  
                  _onNextClick : function(){
                      if(this.next < this.length) {
                          this.prev += this.step;
                          this.next += this.step;
  
                          this.shownPrev = Math.min(this.prev, this.length);
                          this.shownNext = Math.min(this.next, this.length);
                          this.shownDatasets = this.filteredDatasets.slice(this.prev - 1, this.next);
                      }
                      $("#list_container").animate({ scrollTop: 0}, 0);
                  },
  
                  _stringToArray: function(obj) {
                      obj = JSON.parse(obj);
                      return Object.keys(obj).map(function(key) {
                          return {
                              name: key,
                              value: obj[key]
                          };
                      });
                  },
  
                  _toArray: function(obj) {
                      return Object.keys(obj).map(function(key) {
                          return {
                              name: key,
                              value: obj[key]
                          };
                      });
                  },
  
                  _selectDataUrl : function(){
                      this.async(function () {
                          if(this.$.list.selectedItem) {
cd9f822e   Renato De Donato   split 1st step
706
707
  
                              var metas = JSON.parse(this.$.list.selectedItem.metas);
c5fa9cdb   Renato De Donato   info style
708
709
710
                              var html = "<span style=\"color: #2196F3; font-weight: bold;\">" + this.$.list.selectedItem.resource_name + "</span><br><br>";
                              /*font-weight: bold;*/
                              /*line-height: 48px;*/
cd9f822e   Renato De Donato   split 1st step
711
712
713
714
                              for(var i in metas)
                                  html += "<b>" + i + ":</b> " + metas[i] + "<br>";
                              this.$.info.innerHTML = html;
  
a53fbbed   Renato De Donato   select-dataset ne...
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
                              var url = this.$.list.selectedItem.url;
  
                              // Check if CKAN
                              var strDatasetPos = url.indexOf('/dataset/');
                              var strResourcePos = (strDatasetPos >= 0) ? url.indexOf('/resource/') : -1;
                              if (strDatasetPos >= 0 && strResourcePos > strDatasetPos) {
                                  var urlSegment1 = url.substring(0, strDatasetPos);
                                  var urlResourceEnd = url.indexOf('/', strResourcePos + 10);
                                  var resourceId = url.substring(strResourcePos + 10, urlResourceEnd);
                                  url = urlSegment1 + "/api/action/datastore_search?resource_id=" + resourceId;
                              }
  
                              // Check if OPENDATASOFT
                              var strExploreDatasetPos = url.indexOf('/explore/dataset/');
                              if (strExploreDatasetPos >= 0) {
                                  var urlSegment1 = url.substring(0, strExploreDatasetPos);
                                  var datasetEnd = url.indexOf(strExploreDatasetPos + 17, '/');
                                  var datasetId = url.substring(strExploreDatasetPos + 17, datasetEnd >= 0 ? datasetEnd : url.length);
                                  url = urlSegment1 + '/api/records/1.0/search?dataset=' + datasetId;
                              }
  
                              this.dataUrl = this._addlimitUrl(url);
                          }
                          else {
                              this.dataUrl = "";
cd9f822e   Renato De Donato   split 1st step
740
                              this.$.info.innerHTML = "";
a53fbbed   Renato De Donato   select-dataset ne...
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
                          }
                      }, 0);
                  },
  
                  _selectDataUrl_treeMap : function(e) {
                      this.dataUrl = this._addlimitUrl(e.detail.url);
                  },
  
                  _fireDataUrl : function(){
                      this.fire('dataset-selection-controllet_data-url', {url: this.dataUrl});
                  },
  
                  _addlimitUrl : function(url){
                      //CKAN --> action no limit
                      if((url.indexOf("api/action") > -1) && !(url.indexOf("limit") > -1))
                      {
                          url += "&limit=99999";
                      }
                      //OpenDataSoft --> action no limit
                      if((url.indexOf("api/records") > -1) && !(url.indexOf("rows") > -1)){
                          url += "&rows=10000";
                      }
                      return url;
                  },
  
                  _resize : function(){
                      var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16;
                      h = h - 64 - 8; //height with page scroller
                      $("#select_dataset_container").height(h);
a748d9bc   Renato De Donato   ala NUMBER bug
770
                  }
fb05b400   Renato De Donato   controllet 2.0, n...
771
              });
a748d9bc   Renato De Donato   ala NUMBER bug
772
          });
a748d9bc   Renato De Donato   ala NUMBER bug
773
      </script>
a748d9bc   Renato De Donato   ala NUMBER bug
774
  </dom-module>