Blame view

controllets/select-dataset-controllet/select-dataset-controllet.html 30.7 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;
fb05b400   Renato De Donato   controllet 2.0, n...
132
133
                  cursor: pointer;
                  margin-bottom: 8px;
a53fbbed   Renato De Donato   select-dataset ne...
134
                  background-color: #E0E0E0;
fb05b400   Renato De Donato   controllet 2.0, n...
135
136
              }
  
fb05b400   Renato De Donato   controllet 2.0, n...
137
              .pad {
a53fbbed   Renato De Donato   select-dataset ne...
138
139
                  @apply(--layout-flex);
                  /*@apply(--layout-vertical);*/
fb05b400   Renato De Donato   controllet 2.0, n...
140
              }
a53fbbed   Renato De Donato   select-dataset ne...
141
  
fb05b400   Renato De Donato   controllet 2.0, n...
142
              .primary {
fb05b400   Renato De Donato   controllet 2.0, n...
143
                  font-weight: bold;
fb05b400   Renato De Donato   controllet 2.0, n...
144
              }
a53fbbed   Renato De Donato   select-dataset ne...
145
146
147
  
              .item.expanded .primary {
                  color: #2196F3;
a748d9bc   Renato De Donato   ala NUMBER bug
148
              }
a53fbbed   Renato De Donato   select-dataset ne...
149
  
fb05b400   Renato De Donato   controllet 2.0, n...
150
              .longText {
fb05b400   Renato De Donato   controllet 2.0, n...
151
                  display: none;
a748d9bc   Renato De Donato   ala NUMBER bug
152
              }
a53fbbed   Renato De Donato   select-dataset ne...
153
  
fb05b400   Renato De Donato   controllet 2.0, n...
154
155
156
              .item.expanded .longText {
                  display: block;
              }
fb05b400   Renato De Donato   controllet 2.0, n...
157
  
a53fbbed   Renato De Donato   select-dataset ne...
158
159
160
              #select_dataset_container {
                  margin-top: 8px;
              }
a748d9bc   Renato De Donato   ala NUMBER bug
161
  
a53fbbed   Renato De Donato   select-dataset ne...
162
              #select_dataset_container * {
fb05b400   Renato De Donato   controllet 2.0, n...
163
164
                  font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
                  font-size: 16px;
a53fbbed   Renato De Donato   select-dataset ne...
165
166
                  line-height: 24px;
              }
a748d9bc   Renato De Donato   ala NUMBER bug
167
  
a53fbbed   Renato De Donato   select-dataset ne...
168
169
170
171
              #select_dataset_container #neon_container {
                  height: calc(100% - 172px);
                  width: calc(100% - 8px);
              }
a748d9bc   Renato De Donato   ala NUMBER bug
172
  
a53fbbed   Renato De Donato   select-dataset ne...
173
174
175
176
177
178
179
180
181
              #select_dataset_container #list_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
182
183
              }
  
a53fbbed   Renato De Donato   select-dataset ne...
184
185
186
187
188
189
190
191
192
              #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
193
194
              }
  
a53fbbed   Renato De Donato   select-dataset ne...
195
              #select_dataset_container #header {
3388b02b   Renato De Donato   shadow x Andrea
196
197
198
199
200
201
                  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
202
                  background-color: #B6B6B6;
a53fbbed   Renato De Donato   select-dataset ne...
203
204
205
                  display: flex;
                  padding: 0px 4px;
              }
a748d9bc   Renato De Donato   ala NUMBER bug
206
  
3388b02b   Renato De Donato   shadow x Andrea
207
208
209
210
211
212
213
214
215
216
217
218
219
220
              #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...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
              #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
235
              }
a53fbbed   Renato De Donato   select-dataset ne...
236
237
238
239
240
241
242
243
244
245
246
247
248
  
              #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
249
250
              }
  
a53fbbed   Renato De Donato   select-dataset ne...
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
              .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;
              }
a748d9bc   Renato De Donato   ala NUMBER bug
266
267
          </style>
  
a53fbbed   Renato De Donato   select-dataset ne...
268
          <paper-material id="select_dataset_container" elevation="5">
a748d9bc   Renato De Donato   ala NUMBER bug
269
  
a53fbbed   Renato De Donato   select-dataset ne...
270
271
272
              <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
273
                  <paper-tab on-tap="_noShadow" noink><span id="treeMapView"></span></paper-tab>
a53fbbed   Renato De Donato   select-dataset ne...
274
              </paper-tabs>
a748d9bc   Renato De Donato   ala NUMBER bug
275
  
a53fbbed   Renato De Donato   select-dataset ne...
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
              <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
300
301
              </div>
  
a53fbbed   Renato De Donato   select-dataset ne...
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
              <neon-animated-pages id="neon_container" selected="{{selected}}" entry-animation="fade-in-animation" exit-animation="fade-out-animation">
  
                  <neon-animatable>
                      <div id="list_container">
                          <iron-list id="list" items="{{shownDatasets}}" selection-enabled><!--multi-selection-->
                              <template>
                                  <div>
                                      <div class$="{{getClassForItem(selected)}}" on-tap="_selectDataUrl" style$="background: {{_getColorForItem(item)}};">
                                      <!--<div class$="{{getClassForItem(selected)}}" on-tap="_selectDataUrl">-->
                                          <span style="display:none;">{{item.url}}</span>
                                          <div class="pad">
                                              <div class="primary">{{item.resource_name}}</div>
                                              <!--<div class="shortText" style="display:none;">{{item.url}}</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>
                                          </div>
                                          <!--<iron-icon icon$="[[iconForItem(item)]]"></iron-icon>-->
                                          <!--<iron-icon icon="bookmark" style$="color: {{_getColorForItem(item)}};"></iron-icon>-->
                                          <iron-icon icon$="{{_getIconForItem(item)}}" style$="color: {{_getColorForIcon(item)}};"></iron-icon>
                                      </div>
fb05b400   Renato De Donato   controllet 2.0, n...
326
                                  </div>
a53fbbed   Renato De Donato   select-dataset ne...
327
328
329
330
331
332
333
334
335
336
337
338
339
340
                              </template>
                          </iron-list>
                      </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
341
                          </div>
a53fbbed   Renato De Donato   select-dataset ne...
342
343
344
345
346
347
348
349
350
351
352
353
                      </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
354
  
a53fbbed   Renato De Donato   select-dataset ne...
355
356
357
358
              </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
359
360
              </div>
  
a53fbbed   Renato De Donato   select-dataset ne...
361
          </paper-material>
a748d9bc   Renato De Donato   ala NUMBER bug
362
363
364
365
  
      </template>
  
      <script>
fb05b400   Renato De Donato   controllet 2.0, n...
366
367
368
369
          HTMLImports.whenReady(function() {
              Polymer({
                  is: 'select-dataset-controllet',
                  properties: {
a53fbbed   Renato De Donato   select-dataset ne...
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
                      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...
415
                      }
a748d9bc   Renato De Donato   ala NUMBER bug
416
                  },
a53fbbed   Renato De Donato   select-dataset ne...
417
418
419
420
421
  
                  listeners: {
                      'datasetexplorer-datalet_data-url': '_selectDataUrl_treeMap'
                  },
  
fb05b400   Renato De Donato   controllet 2.0, n...
422
423
                  ready : function() {
                      $(this.$.list_container).perfectScrollbar();
a53fbbed   Renato De Donato   select-dataset ne...
424
425
  
  //                    this.$.selected_url.invalid = true;
a748d9bc   Renato De Donato   ala NUMBER bug
426
427
                  },
  
fb05b400   Renato De Donato   controllet 2.0, n...
428
                  attached: function() {
a53fbbed   Renato De Donato   select-dataset ne...
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
                      this._resize();
                      var that = this;
                      window.addEventListener("resize", function() { that._resize(); });
  
                      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...
452
                      this.$.list.scrollTarget = this.ownerDocument.documentElement;
a53fbbed   Renato De Donato   select-dataset ne...
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
  
                      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
477
                  },
a53fbbed   Renato De Donato   select-dataset ne...
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
  
                  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
538
539
540
541
542
543
                      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...
544
545
546
547
                  },
  
                  _clearInput : function() {
                      this.$.datasets_filter.value = "";
a748d9bc   Renato De Donato   ala NUMBER bug
548
                  },
a53fbbed   Renato De Donato   select-dataset ne...
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
575
576
577
578
579
580
581
582
583
584
585
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
  
                  _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...
611
                      return selected ? 'item expanded' : 'item';
a53fbbed   Renato De Donato   select-dataset ne...
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
648
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
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
                  },
  
                  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) {
                              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 = "";
                          }
                      }, 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
723
                  }
fb05b400   Renato De Donato   controllet 2.0, n...
724
              });
a748d9bc   Renato De Donato   ala NUMBER bug
725
          });
a748d9bc   Renato De Donato   ala NUMBER bug
726
      </script>
a748d9bc   Renato De Donato   ala NUMBER bug
727
  </dom-module>