Blame view

controllets/select-dataset-controllet/select-dataset-controllet.html 34.3 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
  <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">
  
89558a41   Renato De Donato   datatype, provide...
36
  <link rel="import" href="../providers-utility-controllet/providers-utility-controllet.html">
382b55e7   Renato De Donato   ortelio
37
  <link rel="import" href="ortelio-controllet.html">
a53fbbed   Renato De Donato   select-dataset ne...
38
  <link rel="import" href="../../datalets/datasetexplorer-datalet/datasetexplorer-datalet.html">
a748d9bc   Renato De Donato   ala NUMBER bug
39
  
fb05b400   Renato De Donato   controllet 2.0, n...
40
  <dom-module id="select-dataset-controllet">
a748d9bc   Renato De Donato   ala NUMBER bug
41
      <template>
fb05b400   Renato De Donato   controllet 2.0, n...
42
          <style>
a53fbbed   Renato De Donato   select-dataset ne...
43
44
45
46
47
48
49
50
51
              :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...
52
               /*};*/
a53fbbed   Renato De Donato   select-dataset ne...
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
127
128
              }
  
              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...
129
              .item {
a53fbbed   Renato De Donato   select-dataset ne...
130
131
132
133
                  /*@apply(--layout-horizontal);*/
                  display: flex;
                  padding: 11px;
                  border: 1px solid #B6B6B6;
190145a5   Renato De Donato   style
134
                  border-radius: 4px;
fb05b400   Renato De Donato   controllet 2.0, n...
135
136
                  cursor: pointer;
                  margin-bottom: 8px;
a53fbbed   Renato De Donato   select-dataset ne...
137
                  background-color: #E0E0E0;
fb05b400   Renato De Donato   controllet 2.0, n...
138
139
              }
  
cd9f822e   Renato De Donato   split 1st step
140
141
142
143
144
              .item.expanded {
                  /*border: 2px solid #2196F3;*/
                  border-color: #2196F3;
              }
  
fb05b400   Renato De Donato   controllet 2.0, n...
145
              .pad {
a53fbbed   Renato De Donato   select-dataset ne...
146
147
                  @apply(--layout-flex);
                  /*@apply(--layout-vertical);*/
fb05b400   Renato De Donato   controllet 2.0, n...
148
              }
a53fbbed   Renato De Donato   select-dataset ne...
149
  
fb05b400   Renato De Donato   controllet 2.0, n...
150
              .primary {
fb05b400   Renato De Donato   controllet 2.0, n...
151
                  font-weight: bold;
fb05b400   Renato De Donato   controllet 2.0, n...
152
              }
a53fbbed   Renato De Donato   select-dataset ne...
153
154
155
  
              .item.expanded .primary {
                  color: #2196F3;
a748d9bc   Renato De Donato   ala NUMBER bug
156
              }
a53fbbed   Renato De Donato   select-dataset ne...
157
  
fb05b400   Renato De Donato   controllet 2.0, n...
158
              .longText {
fb05b400   Renato De Donato   controllet 2.0, n...
159
                  display: none;
a748d9bc   Renato De Donato   ala NUMBER bug
160
              }
a53fbbed   Renato De Donato   select-dataset ne...
161
  
fb05b400   Renato De Donato   controllet 2.0, n...
162
163
164
              .item.expanded .longText {
                  display: block;
              }
fb05b400   Renato De Donato   controllet 2.0, n...
165
  
a53fbbed   Renato De Donato   select-dataset ne...
166
167
168
              #select_dataset_container {
                  margin-top: 8px;
              }
a748d9bc   Renato De Donato   ala NUMBER bug
169
  
a53fbbed   Renato De Donato   select-dataset ne...
170
              #select_dataset_container * {
fb05b400   Renato De Donato   controllet 2.0, n...
171
172
                  font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
                  font-size: 16px;
a53fbbed   Renato De Donato   select-dataset ne...
173
174
                  line-height: 24px;
              }
a748d9bc   Renato De Donato   ala NUMBER bug
175
  
a53fbbed   Renato De Donato   select-dataset ne...
176
177
178
179
              #select_dataset_container #neon_container {
                  height: calc(100% - 172px);
                  width: calc(100% - 8px);
              }
a748d9bc   Renato De Donato   ala NUMBER bug
180
  
cd9f822e   Renato De Donato   split 1st step
181
182
              #select_dataset_container #list_info {
                  display: flex;
a53fbbed   Renato De Donato   select-dataset ne...
183
                  height: calc(100% - 48px);
cd9f822e   Renato De Donato   split 1st step
184
185
186
187
                  width: calc(100% + 8px);/*bad*/
              }
  
              #select_dataset_container #list_container {
a53fbbed   Renato De Donato   select-dataset ne...
188
                  position: relative;
cd9f822e   Renato De Donato   split 1st step
189
190
                  height: 100%;
                  width: 50%;
382b55e7   Renato De Donato   ortelio
191
                  border-left: 4px solid #B6B6B6;
cd9f822e   Renato De Donato   split 1st step
192
193
194
195
196
197
198
              }
  
              #select_dataset_container #info_container {
                  position: relative;
                  height: 100%;
                  width: 50%;
                  border-right: 4px solid #B6B6B6;
cd9f822e   Renato De Donato   split 1st step
199
200
201
202
203
204
205
206
207
208
209
              }
  
              #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;*/
              /*}*/
382b55e7   Renato De Donato   ortelio
300
301
302
303
304
305
306
307
  
              /*#ortelio {*/
                  /*/!*height: calc(100% - 172px);*!/*/
                  /*/!*width: calc(100% - 8px);*!/*/
                  /*height: 100%;*/
                  /*width: 100%;*/
                  /*background-color: red;*/
              /*}*/
a748d9bc   Renato De Donato   ala NUMBER bug
308
309
          </style>
  
a53fbbed   Renato De Donato   select-dataset ne...
310
          <paper-material id="select_dataset_container" elevation="5">
a748d9bc   Renato De Donato   ala NUMBER bug
311
  
a53fbbed   Renato De Donato   select-dataset ne...
312
              <paper-tabs selected="{{selected}}" no-bar>
382b55e7   Renato De Donato   ortelio
313
                  <paper-tab on-tap="_refreshList" noink><span id="listView"></span></paper-tab>
3388b02b   Renato De Donato   shadow x Andrea
314
                  <paper-tab on-tap="_noShadow" noink><span id="treeMapView"></span></paper-tab>
382b55e7   Renato De Donato   ortelio
315
                  <paper-tab on-tap="_hideSearch" noink><span id="extendedSearch"></span></paper-tab>
a53fbbed   Renato De Donato   select-dataset ne...
316
              </paper-tabs>
a748d9bc   Renato De Donato   ala NUMBER bug
317
  
a53fbbed   Renato De Donato   select-dataset ne...
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
              <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
342
343
              </div>
  
a53fbbed   Renato De Donato   select-dataset ne...
344
345
346
              <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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
                      <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...
362
                                              </div>
cd9f822e   Renato De Donato   split 1st step
363
                                              <iron-icon icon$="{{_getIconForItem(item)}}" style$="color: {{_getColorForIcon(item)}};"></iron-icon>
a53fbbed   Renato De Donato   select-dataset ne...
364
                                          </div>
a53fbbed   Renato De Donato   select-dataset ne...
365
                                      </div>
cd9f822e   Renato De Donato   split 1st step
366
367
368
369
370
371
372
                                  </template>
                              </iron-list>
                          </div>
                          <div id="info_container">
                              <div id="info">
                              </div>
                          </div>
a53fbbed   Renato De Donato   select-dataset ne...
373
374
375
376
377
378
379
380
381
382
383
384
                      </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
385
                          </div>
a53fbbed   Renato De Donato   select-dataset ne...
386
387
388
389
390
391
392
393
394
395
396
397
                      </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
398
  
382b55e7   Renato De Donato   ortelio
399
400
401
402
403
404
                  <neon-animatable>
                      <!--<div id="ortelio">-->
                          <ortelio-controllet datasets={{datasets}}></ortelio-controllet>
                      <!--</div>-->
                  </neon-animatable>
  
a53fbbed   Renato De Donato   select-dataset ne...
405
406
407
408
              </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
409
410
              </div>
  
a53fbbed   Renato De Donato   select-dataset ne...
411
          </paper-material>
a748d9bc   Renato De Donato   ala NUMBER bug
412
413
414
415
  
      </template>
  
      <script>
fb05b400   Renato De Donato   controllet 2.0, n...
416
417
418
419
          HTMLImports.whenReady(function() {
              Polymer({
                  is: 'select-dataset-controllet',
                  properties: {
a53fbbed   Renato De Donato   select-dataset ne...
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
451
452
453
454
455
456
457
458
459
460
461
462
463
464
                      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...
465
                      }
a748d9bc   Renato De Donato   ala NUMBER bug
466
                  },
a53fbbed   Renato De Donato   select-dataset ne...
467
468
469
470
471
  
                  listeners: {
                      'datasetexplorer-datalet_data-url': '_selectDataUrl_treeMap'
                  },
  
fb05b400   Renato De Donato   controllet 2.0, n...
472
473
                  ready : function() {
                      $(this.$.list_container).perfectScrollbar();
cd9f822e   Renato De Donato   split 1st step
474
                      $(this.$.info).perfectScrollbar();
a53fbbed   Renato De Donato   select-dataset ne...
475
476
  
  //                    this.$.selected_url.invalid = true;
a748d9bc   Renato De Donato   ala NUMBER bug
477
478
                  },
  
fb05b400   Renato De Donato   controllet 2.0, n...
479
                  attached: function() {
a53fbbed   Renato De Donato   select-dataset ne...
480
481
                      this._resize();
                      var that = this;
20799010   Renato De Donato   treemap resize
482
                      window.addEventListener("resize", function() { that._resize(); that._loadTreeMap();});
a53fbbed   Renato De Donato   select-dataset ne...
483
  
00210b7a   Renato De Donato   controllet SPOD p...
484
485
  //                    this.providers = that.datasets["result"]["providers"];
  //                    this.datasets = that.datasets["result"]["datasets"];
a53fbbed   Renato De Donato   select-dataset ne...
486
  
00210b7a   Renato De Donato   controllet SPOD p...
487
488
489
490
491
492
493
494
495
496
497
498
499
                      $.ajax({
                          url: "/cocreation/ajax/get-all-dataset",
                          dataType: "json",
                          success: function(spodDatasets){
  
                              that.providers = $.extend(that.datasets["result"]["providers"], {99: {api_url: "/cocreation/ajax/get-all-dataset", id: "99", image_hash: "SPOD", title: "SPOD"}});
                              that.datasets = $.merge(spodDatasets, that.datasets["result"]["datasets"]);
  
                              if(that.suggestedDatasets) {
                                  that.tempDatasets = that.datasets;
                                  that.datasets = that.suggestedDatasets.concat(that.datasets);
                                  that.$.suggested_div.style.visibility = "visible";
                              }
a53fbbed   Renato De Donato   select-dataset ne...
500
  
00210b7a   Renato De Donato   controllet SPOD p...
501
                              that.filteredDatasets = that.datasets;
a53fbbed   Renato De Donato   select-dataset ne...
502
  
00210b7a   Renato De Donato   controllet SPOD p...
503
504
505
                              that.prev = 1;
                              that.next = that.step;
                              that.length = that.filteredDatasets.length;
a53fbbed   Renato De Donato   select-dataset ne...
506
  
00210b7a   Renato De Donato   controllet SPOD p...
507
508
509
                              that.shownPrev = Math.min(that.prev, that.length);
                              that.shownNext = Math.min(that.next, that.length);
                              that.shownDatasets = that.filteredDatasets.slice(that.prev-1, that.next);
a53fbbed   Renato De Donato   select-dataset ne...
510
  
00210b7a   Renato De Donato   controllet SPOD p...
511
                              that.$.list.scrollTarget = that.ownerDocument.documentElement;
a53fbbed   Renato De Donato   select-dataset ne...
512
  
00210b7a   Renato De Donato   controllet SPOD p...
513
                              that._translate();
a53fbbed   Renato De Donato   select-dataset ne...
514
  
00210b7a   Renato De Donato   controllet SPOD p...
515
516
517
                              that._loadTreeMap();
                          }
                      });
a53fbbed   Renato De Donato   select-dataset ne...
518
519
520
521
522
                  },
  
                  _translate : function(){
                      this.$.listView.innerHTML    = ln["listView_" + ln["localization"]];
                      this.$.treeMapView.innerHTML = ln["treeMapView_" + ln["localization"]];
382b55e7   Renato De Donato   ortelio
523
                      this.$.extendedSearch.innerHTML = ln["extendedSearch_" + ln["localization"]];
a53fbbed   Renato De Donato   select-dataset ne...
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
  
                      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
539
                  },
a53fbbed   Renato De Donato   select-dataset ne...
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
  
                  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)
413bc541   Renato De Donato   data cache
556
                          this.$.treemap_container.innerHTML = "<datasetexplorer-datalet data='"+data+"' width=\""+w+"\" height=\""+h+"\" fields='[\"provider_name\",\"organization_name\",\"package_name\",\"resource_name\",\"url\",\"w\",\"metas\"]'></datasetexplorer-datalet>";
a53fbbed   Renato De Donato   select-dataset ne...
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
                      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);
382b55e7   Renato De Donato   ortelio
600
601
602
603
604
  
                      this.$.header.style.display = "flex";
                      this.$.header.style.visibility = "visible";
  //                    this.$.url.style.marginTop = "-4px";
  
3388b02b   Renato De Donato   shadow x Andrea
605
606
607
608
                      this.$.header.className = this.$.header.className.replace(" noshadow", "");
                  },
  
                  _noShadow : function() {
382b55e7   Renato De Donato   ortelio
609
610
611
612
                      this.$.header.style.display = "flex";
                      this.$.header.style.visibility = "visible";
  //                    this.$.url.style.marginTop = "-4px";
  
3388b02b   Renato De Donato   shadow x Andrea
613
                      this.$.header.className += " noshadow";
a53fbbed   Renato De Donato   select-dataset ne...
614
615
                  },
  
382b55e7   Renato De Donato   ortelio
616
617
618
619
620
621
                  _hideSearch : function() {
  //                    this.$.header.style.display = "none";
                      this.$.header.style.visibility = "hidden";
  //                    this.$.url.style.marginTop = "44px";
                  },
  
a53fbbed   Renato De Donato   select-dataset ne...
622
623
                  _clearInput : function() {
                      this.$.datasets_filter.value = "";
a748d9bc   Renato De Donato   ala NUMBER bug
624
                  },
a53fbbed   Renato De Donato   select-dataset ne...
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
  
                  _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...
687
                      return selected ? 'item expanded' : 'item';
a53fbbed   Renato De Donato   select-dataset ne...
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
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
                  },
  
                  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
745
746
  
                              var metas = JSON.parse(this.$.list.selectedItem.metas);
c5fa9cdb   Renato De Donato   info style
747
748
749
                              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
750
751
752
753
                              for(var i in metas)
                                  html += "<b>" + i + ":</b> " + metas[i] + "<br>";
                              this.$.info.innerHTML = html;
  
89558a41   Renato De Donato   datatype, provide...
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
                              this.dataUrl = this.$.list.selectedItem.url;
  //                            var url = this.$.list.selectedItem.url;
  
  //                            url = utility_getResourceUrl(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);
  //                            this.dataUrl = url;
a53fbbed   Renato De Donato   select-dataset ne...
780
781
782
                          }
                          else {
                              this.dataUrl = "";
cd9f822e   Renato De Donato   split 1st step
783
                              this.$.info.innerHTML = "";
a53fbbed   Renato De Donato   select-dataset ne...
784
785
786
787
788
                          }
                      }, 0);
                  },
  
                  _selectDataUrl_treeMap : function(e) {
89558a41   Renato De Donato   datatype, provide...
789
790
  //                    this.dataUrl = this._addlimitUrl(e.detail.url);
                      this.dataUrl = e.detail.url;
a53fbbed   Renato De Donato   select-dataset ne...
791
792
793
794
795
796
                  },
  
                  _fireDataUrl : function(){
                      this.fire('dataset-selection-controllet_data-url', {url: this.dataUrl});
                  },
  
89558a41   Renato De Donato   datatype, provide...
797
798
799
800
801
802
803
804
805
806
807
808
  //                _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;
  //                },
a53fbbed   Renato De Donato   select-dataset ne...
809
810
811
812
813
  
                  _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
814
                  }
fb05b400   Renato De Donato   controllet 2.0, n...
815
              });
a748d9bc   Renato De Donato   ala NUMBER bug
816
          });
a748d9bc   Renato De Donato   ala NUMBER bug
817
      </script>
a748d9bc   Renato De Donato   ala NUMBER bug
818
  </dom-module>