Blame view

controllets/data-sevc-controllet/data-sevc-controllet.html 38.1 KB
938d1928   Luigi Serra   Update documentat...
1
2
  <!--

  @license

584d6ecd   Luigi Serra   Update components...
3
      The MIT License (MIT)

73bcce88   luigser   COMPONENTS
4
  

584d6ecd   Luigi Serra   Update components...
5
      Copyright (c) 2015 Dipartimento di Informatica - Università di Salerno - Italy

73bcce88   luigser   COMPONENTS
6
  

938d1928   Luigi Serra   Update documentat...
7
8
9
10
11
12
      Permission is hereby granted, free of charge, to any person obtaining a copy

      of this software and associated documentation files (the "Software"), to deal

      in the Software without restriction, including without limitation the rights

      to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

      copies of the Software, and to permit persons to whom the Software is

      furnished to do so, subject to the following conditions:

e619a3b0   Luigi Serra   Controllet cross ...
13
  

938d1928   Luigi Serra   Update documentat...
14
15
      The above copyright notice and this permission notice shall be included in

      all copies or substantial portions of the Software.

73bcce88   luigser   COMPONENTS
16
  

938d1928   Luigi Serra   Update documentat...
17
18
19
20
21
22
23
24
      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

      FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

      AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

      LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

      OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN

      THE SOFTWARE.

  -->

73bcce88   luigser   COMPONENTS
25
  

938d1928   Luigi Serra   Update documentat...
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  <link rel="import" href="../../bower_components/polymer/polymer.html">

  <link rel="import" href="../../bower_components/paper-styles/color.html">

  

  <link rel="import" href="../../bower_components/neon-animation/neon-animated-pages.html">

  <link rel="import" href="../../bower_components/neon-animation/neon-animatable.html">

  <link rel="import" href="../../bower_components/neon-animation/neon-animations.html">

  

  <link rel="import" href="../../bower_components/iron-ajax/iron-ajax.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-button/paper-button.html">

  <link rel="import" href="../../bower_components/paper-tabs/paper-tabs.html">

  <link rel="import" href="../../bower_components/paper-tabs/paper-tab.html">

  <link rel="import" href="../../bower_components/iron-pages/iron-pages.html">

  <link rel="import" href="../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">

  <link rel="import" href="../../bower_components/paper-menu/paper-menu.html">

  <link rel="import" href="../../bower_components/paper-item/paper-item.html">

  <link rel="import" href="../../bower_components/paper-toast/paper-toast.html">

  

  

  <link rel="import" href="../items-slider-controllet/items-slider-controllet.html">

  <link rel="import" href="../draggable-element-controllet/draggable-element-controllet.html">

  <link rel="import" href="../treeview-controllet/treeview-controllet.html">

  

  <!--

   `data-sevc-controllet` is a controllet to generate visualization from a dataset accessible through api. A json response is required.

    It's composed by three pass. First, user have to select a datasource to access to a dataset. He can copy and paste/drag and drop an url(an api url with json response) or select

    from select contextual menu an available one. Second, the user selects the fields he want to visualize from a treeview by checking on it. A table preview of selected fields will show

    the currently selected values. Third, the users selects a visualization(datalet) from a slider and drags the previous selected fields in to the input data model fields area. A preview

    is available every time a fields is dragged in the input data model fields area.

  

  Example:

  

      <data-sevc-controllet deep-url="http://192.168.214.128/DEEalerProvider/DEEP/"

                            datalets-list-url="http://192.168.214.128/DEEalerProvider/DEEP/datalets-list"

                            organization="2" >

      </data-sevc-controllet>

  

  

  @element data-sevc-controllet

  @status beta

584d6ecd   Luigi Serra   Update components...
67
  @homepage index.html

938d1928   Luigi Serra   Update documentat...
68
69
70
71
72
73
74
  @group controllets

  -->

  

  

  <dom-module id="data-sevc-controllet">

          <template>

              <link rel="stylesheet" href="../shared_js/perfect-scrollbar/css/perfect-scrollbar.min.css">

325c348a   Luigi Serra   Cross browser bug...
75
              <link rel="stylesheet" href="static/css/reset.css">

74249687   Luigi Serra   Cross browser con...
76
  

325c348a   Luigi Serra   Cross browser bug...
77
              <style is="custom-style">

73bcce88   luigser   COMPONENTS
78
  

938d1928   Luigi Serra   Update documentat...
79
80
81
                  ::content body {

                      font-family: 'Roboto', sans-serif;

                  }

dbc787cf   Luigi Serra   Controllet cross ...
82
  

938d1928   Luigi Serra   Update documentat...
83
84
85
86
                  .flexchild

                  {

                  @apply(--layout-flex);

                  }

73bcce88   luigser   COMPONENTS
87
  

938d1928   Luigi Serra   Update documentat...
88
89
90
91
                  .flex2child

                  {

                  @apply(--layout-flex-2);

                  }

73bcce88   luigser   COMPONENTS
92
  

938d1928   Luigi Serra   Update documentat...
93
94
95
96
97
98
99
100
101
102
103
104
                  .avatar

                  {

                      display: inline-block;

                      height: 2em;

                      width: 2em;

                      border-radius: 50%;

                      background: var(--paper-blue-500);

                      color: white;

                      line-height: 2em;

                      font-size: 1.87em;

                      text-align: center;

                  }

73bcce88   luigser   COMPONENTS
105
  

938d1928   Luigi Serra   Update documentat...
106
107
108
109
110
111
                  .title

                  {

                      position: relative;

                      top: 0.60vh;

                      margin-left: 20px;

                  }

73bcce88   luigser   COMPONENTS
112
  

938d1928   Luigi Serra   Update documentat...
113
114
115
116
117
                  .big

                  {

                      font-size: 1.37em;

                      color: var(--google-grey-500);

                  }

73bcce88   luigser   COMPONENTS
118
  

938d1928   Luigi Serra   Update documentat...
119
120
121
122
123
124
125
                  .medium

                  {

                      font-size: 1em;

                      padding-bottom: 0.5em;

                      color : #000000;

                      font-weight: bold;

                  }

73bcce88   luigser   COMPONENTS
126
  

938d1928   Luigi Serra   Update documentat...
127
128
129
130
131
132
133
                  .small

                  {

                      font-size: 0.8em;

                      padding-top: 10px;

                      color: var(--paper-blue-500);

                      font-weight: bold;

                  }

74249687   Luigi Serra   Cross browser con...
134
  

938d1928   Luigi Serra   Update documentat...
135
136
137
138
                  paper-input

                  {

                      width: 80%;

                  }

73bcce88   luigser   COMPONENTS
139
  

938d1928   Luigi Serra   Update documentat...
140
141
142
143
144
145
                  paper-dropdown-menu

                  {

                      text-align: left;

                      margin: auto;

                      width: 100%;

                  }

cb1aab91   Luigi Serra   Controllets update
146
  

938d1928   Luigi Serra   Update documentat...
147
148
149
150
151
                  ::content paper-menu-button

                  {

                      display: block;

                      width: 100%;

                  }

cb1aab91   Luigi Serra   Controllets update
152
  

938d1928   Luigi Serra   Update documentat...
153
154
155
156
157
                  #visualization_slider_area

                  {

                      min-width: 670px;

                      min-height: 180px;

                  }

73bcce88   luigser   COMPONENTS
158
  

938d1928   Luigi Serra   Update documentat...
159
160
161
162
163
                  #fields_mapping_area

                  {

                      min-width: 670px;

                      min-height: 180px;

                  }

73bcce88   luigser   COMPONENTS
164
  

938d1928   Luigi Serra   Update documentat...
165
166
167
168
                  #datalet_placeholder

                  {

                      height: 360px;

                      min-height: 360px;

73bcce88   luigser   COMPONENTS
169
  

938d1928   Luigi Serra   Update documentat...
170
                  }

73bcce88   luigser   COMPONENTS
171
  

938d1928   Luigi Serra   Update documentat...
172
173
174
175
                  .datalet_right_container

                  {

                      width: 100vh;

                  }

73bcce88   luigser   COMPONENTS
176
  

938d1928   Luigi Serra   Update documentat...
177
178
179
180
181
                  .field-mapping-card

                  {

                      width: 50%;

                      float: left;

                  }

73bcce88   luigser   COMPONENTS
182
  

938d1928   Luigi Serra   Update documentat...
183
184
185
186
187
                  .toolbar_button

                  {

                      --iron-icon-height: 32px;

                      --iron-icon-width: 32px;

                  }

73bcce88   luigser   COMPONENTS
188
  

938d1928   Luigi Serra   Update documentat...
189
190
191
192
193
194
                  #finish_button

                  {

                      --iron-icon-height: 32px;

                      --iron-icon-width: 32px;

                      color: var(--paper-blue-500);

                  }

73bcce88   luigser   COMPONENTS
195
  

938d1928   Luigi Serra   Update documentat...
196
197
198
199
200
201
202
203
204
                  .area_container

                  {

                      overflow: hidden;

                      margin : 0.8em;

                      padding : 0.8em;

                      border-width: 1em;

                      border-radius: 0.125rem;

                      box-shadow: 0.125em 0.125em 0.1125em 0.125em rgba(0, 0, 0, 0.25);

                  }

73bcce88   luigser   COMPONENTS
205
  

938d1928   Luigi Serra   Update documentat...
206
207
208
209
210
211
212
                  #fields_placeholder{

                      width: 40%;

                      height: 75vh;

                      position: relative;

                      float: left;

                      overflow: auto;

                  }

73bcce88   luigser   COMPONENTS
213
  

938d1928   Luigi Serra   Update documentat...
214
215
216
217
218
219
220
                  #table_fields_container{

                      height: 75vh;

                      width: 55%;

                      position: relative;

                      float: left;

                      overflow: auto;

                  }

73bcce88   luigser   COMPONENTS
221
  

938d1928   Luigi Serra   Update documentat...
222
223
224
225
226
227
                  paper-tabs, paper-toolbar

                  {

                      background-color:  var(--paper-blue-500);

                      color: #ffffff;

                      box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.2);

                  }

cb1aab91   Luigi Serra   Controllets update
228
  

938d1928   Luigi Serra   Update documentat...
229
230
231
232
233
                  paper-toolbar paper-tabs

                  {

                      box-shadow: none;

                      --paper-tabs-selection-bar-color : var(--google-gray-500);

                  }

cb1aab91   Luigi Serra   Controllets update
234
  

938d1928   Luigi Serra   Update documentat...
235
236
237
238
                  paper-tabs[noink][no-bar] paper-tab.iron-selected

                  {

                      background-color: var(--google-gray-500);

                  }

cb1aab91   Luigi Serra   Controllets update
239
  

938d1928   Luigi Serra   Update documentat...
240
241
242
243
                  paper-tabs[align-bottom]

                  {

                      box-shadow: 0px -2px 6px rgba(0, 0, 0, 0.15);

                  }

cb1aab91   Luigi Serra   Controllets update
244
  

938d1928   Luigi Serra   Update documentat...
245
246
247
248
                  #idm_fields_main_container{

                      position: relative;

                      height: 50vh;

                  }

74249687   Luigi Serra   Cross browser con...
249
  

938d1928   Luigi Serra   Update documentat...
250
251
252
253
                  #selected_fields_main_container{

                      position: relative;

                      height: 50vh;

                  }

74249687   Luigi Serra   Cross browser con...
254
  

938d1928   Luigi Serra   Update documentat...
255
256
257
                  paper-menu{

                      width: 100%;

                  }

74249687   Luigi Serra   Cross browser con...
258
  

938d1928   Luigi Serra   Update documentat...
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
              </style>

  

              <iron-ajax

                      auto

                      id="data_request"

                      url={{dataUrl}}

                      verbose="true"

                      on-response="handleResponseData"

                      debounce-duration="300">

              </iron-ajax>

  

              <iron-ajax

                      id="datales_list_request"

                      auto

                      url={{dataletsListUrl}}

                      handle-as="json"

                      on-response="handleResponseDatalets"

                      debounce-duration="300">

              </iron-ajax>

  

              <iron-ajax

                      id="selected_datalet_request"

                      url={{deepUrl}}

                      verbose="true"

                      on-response="handleSelectedDatalet"

                      debounce-duration="300">

              </iron-ajax>

  

              <content>

  

                  <neon-animated-pages id="pages" selected="[[selected]]" entry-animation="[[entryAnimation]]" exit-animation="[[exitAnimation]]">

  

                      <neon-animatable>

  

                          <div class="vertical justified layout">

  

                              <div class="horizontal layout">

                                  <div class="avatar" style="margin-left:15px">1</div>

                                  <div class="title flex">

                                      <div id="toolbar_title" class="big">Dataset source</div>

                                      <div id="toolbar_description" class="small">Copy and paste/drag and drop in the textarea the url of datasource</div>

                                  </div>

                                  <paper-icon-button id="NextButton" class="toolbar_button" on-click="_onNextClick" icon="chevron-right" alt="arrow-forward" title="arrow-forward"></paper-icon-button>

74249687   Luigi Serra   Cross browser con...
302
                              </div>

74249687   Luigi Serra   Cross browser con...
303
  

938d1928   Luigi Serra   Update documentat...
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
                              <div class="area_container">

                                  <paper-tabs selected="{{DatasourceTabSelected}}">

                                      <paper-tab>Select data source</paper-tab>

                                      <paper-tab>Most popular</paper-tab>

                                      <paper-tab>Search</paper-tab>

                                  </paper-tabs>

                                  <iron-pages selected="{{DatasourceTabSelected}}">

                                      <div>

                                          <div class="card-content">

                                              <paper-dropdown-menu id="datasets-sources" label="Available datasets">

                                                  <paper-menu class="dropdown-content">

                                                      <template is="dom-repeat" items="{{datasets}}" as="dataset" index-as="index">

                                                          <paper-item id="{{index}}" on-tap="_datasourceSelected">{{dataset}}</paper-item>

                                                      </template>

                                                  </paper-menu>

                                              </paper-dropdown-menu>

                                          </div>

cb1aab91   Luigi Serra   Controllets update
321
  

938d1928   Luigi Serra   Update documentat...
322
                                          <div><img src="static/images/or.png" style="position: relative;left: 50%;padding-top:20px"></div>

835a711f   Luigi Serra   Controllet cross ...
323
  

938d1928   Luigi Serra   Update documentat...
324
325
326
                                          <div class="card-content">

                                              <paper-textarea id="data_url" label="Dataset api data url" floatingLabel value="{{dataUrl}}" on-dragover="_handleDatasourceDragOver"></paper-textarea>

                                          </div>

835a711f   Luigi Serra   Controllet cross ...
327
328
  

  

938d1928   Luigi Serra   Update documentat...
329
330
331
332
333
                                      </div>

                                      <div><img src="static/images/UnderConstruction.png" style="position: relative;top: 60%;left: 25%;"></div>

                                      <div><img src="static/images/UnderConstruction.png" style="position: relative;top: 60%;left: 25%;"></div>

                                  </iron-pages>

                              </div>

cb1aab91   Luigi Serra   Controllets update
334
  

938d1928   Luigi Serra   Update documentat...
335
                          </div>

73bcce88   luigser   COMPONENTS
336
  

938d1928   Luigi Serra   Update documentat...
337
                      </neon-animatable>

73bcce88   luigser   COMPONENTS
338
  

938d1928   Luigi Serra   Update documentat...
339
                      <neon-animatable>

73bcce88   luigser   COMPONENTS
340
  

938d1928   Luigi Serra   Update documentat...
341
                          <div class="vertical justified layout">

74249687   Luigi Serra   Cross browser con...
342
  

938d1928   Luigi Serra   Update documentat...
343
344
345
346
347
348
349
350
                              <div class="horizontal layout">

                                  <paper-icon-button id="PrevButton" class="toolbar_button x-scope" on-click="_onPrevClick" icon="chevron-left" alt="arrow-back" title="arrow-back"></paper-icon-button>

                                  <div class="avatar">2</div>

                                  <div class="title flex">

                                      <div id="toolbar_title" class="big">Dataset source</div>

                                      <div id="toolbar_description" class="small">Copy and paste/drag and drop in the textarea the url of datasource</div>

                                  </div>

                                  <paper-icon-button id="NextButton" class="toolbar_button" on-click="_onNextClick" icon="chevron-right" alt="arrow-forward" title="arrow-forward"></paper-icon-button>

74249687   Luigi Serra   Cross browser con...
351
                              </div>

74249687   Luigi Serra   Cross browser con...
352
  

938d1928   Luigi Serra   Update documentat...
353
                              <div class="horizontal layout">

73bcce88   luigser   COMPONENTS
354
  

938d1928   Luigi Serra   Update documentat...
355
356
357
358
359
360
361
                                  <div id="fields_placeholder" class="area_container flexchild" style="min-width:300px">

                                      <treeview-controllet id="fields_treeview"></treeview-controllet>

                                  </div>

  

                                  <div id="table_fields_container" class="area_container flex2child">

                                      <div id="table_component_place_holder"></div>

                                  </div>

74249687   Luigi Serra   Cross browser con...
362
  

73bcce88   luigser   COMPONENTS
363
                              </div>

74249687   Luigi Serra   Cross browser con...
364
  

73bcce88   luigser   COMPONENTS
365
                          </div>

74249687   Luigi Serra   Cross browser con...
366
  

938d1928   Luigi Serra   Update documentat...
367
                      </neon-animatable>

73bcce88   luigser   COMPONENTS
368
  

938d1928   Luigi Serra   Update documentat...
369
                      <neon-animatable style="height:100vh">

73bcce88   luigser   COMPONENTS
370
  

938d1928   Luigi Serra   Update documentat...
371
                          <div class="vertical justified layout">

73bcce88   luigser   COMPONENTS
372
  

938d1928   Luigi Serra   Update documentat...
373
374
375
376
377
378
379
380
                              <div class="horizontal layout">

                                  <paper-icon-button id="PrevButton" class="toolbar_button x-scope" on-click="_onPrevClick" icon="chevron-left" alt="arrow-back" title="arrow-back"></paper-icon-button>

                                  <div class="avatar">3</div>

                                  <div class="title flex">

                                      <div id="toolbar_title" class="big">Data mapping</div>

                                      <div id="toolbar_description" class="small">Select the visualization from the slider, drag and drop the selected fields in visualization parameter area, customize the visualization if you need</div>

                                  </div>

                                  <paper-icon-button id="finish_button" on-click="_onFinish" icon="add-circle" alt="Conforms the creation" title="finish"></paper-icon-button>

73bcce88   luigser   COMPONENTS
381
                              </div>

74249687   Luigi Serra   Cross browser con...
382
  

73bcce88   luigser   COMPONENTS
383
  

938d1928   Luigi Serra   Update documentat...
384
                              <div class="horizontal layout">

74249687   Luigi Serra   Cross browser con...
385
  

938d1928   Luigi Serra   Update documentat...
386
387
388
                                  <div class="">

                                      <div id="visualization_slider_area" class="area_container"></div>

                                      <div id="fields_mapping_area" class="area_container">

73bcce88   luigser   COMPONENTS
389
  

938d1928   Luigi Serra   Update documentat...
390
391
392
393
394
                                          <div id="selected_fields_main_container" class="field-mapping-card">

                                              <div class="title">

                                                  <div class="medium">Selected fields</div>

                                              </div>

                                              <div id="selected_fields_container" class="area_container"></div>

73bcce88   luigser   COMPONENTS
395
                                          </div>

73bcce88   luigser   COMPONENTS
396
  

938d1928   Luigi Serra   Update documentat...
397
398
399
400
401
                                          <div id="idm_fields_main_container" class="field-mapping-card">

                                              <div class="title">

                                                  <div class="medium">Datalet fields</div>

                                              </div>

                                              <div id="datalet_idm_fields_container" class="area_container"></div>

73bcce88   luigser   COMPONENTS
402
                                          </div>

73bcce88   luigser   COMPONENTS
403
                                      </div>

74249687   Luigi Serra   Cross browser con...
404
                                  </div>

73bcce88   luigser   COMPONENTS
405
  

938d1928   Luigi Serra   Update documentat...
406
                                  <div id="datalet_placeholder" style="min-width: 43%;"></div>

8f65d1be   Luigi Serra   selection control...
407
  

73bcce88   luigser   COMPONENTS
408
  

938d1928   Luigi Serra   Update documentat...
409
                              </div>

74249687   Luigi Serra   Cross browser con...
410
  

938d1928   Luigi Serra   Update documentat...
411
                          </div>

73bcce88   luigser   COMPONENTS
412
  

938d1928   Luigi Serra   Update documentat...
413
                      </neon-animatable>

73bcce88   luigser   COMPONENTS
414
  

938d1928   Luigi Serra   Update documentat...
415
                  </neon-animated-pages>

73bcce88   luigser   COMPONENTS
416
  

938d1928   Luigi Serra   Update documentat...
417
                  <paper-toast id="message" text=""></paper-toast>

73bcce88   luigser   COMPONENTS
418
  

938d1928   Luigi Serra   Update documentat...
419
              </content>

73bcce88   luigser   COMPONENTS
420
      </template>

74249687   Luigi Serra   Cross browser con...
421
  

0b818d7e   Luigi Serra   Selection control...
422
      <script src="../shared_js/perfect-scrollbar/js/min/perfect-scrollbar.jquery.min.js"></script>

73bcce88   luigser   COMPONENTS
423
424
425
426
      <script src="../../../DEEPCLIENT/js/deepClient.js"></script>

  

      <script>

  

cb1aab91   Luigi Serra   Controllets update
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
          var datasetsPrato = {

              names:[

                  'Consuntivo entrate 2009',

                  'Consuntivo entrate 2010',

                  'Consuntivo entrate 2011',

                  'Consuntivo entrate 2012',

                  'Consuntivo entrate 2014'

              ],

              urls: [

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=07843fc3-07e1-4c66-9be4-fed43ca4a26f&limit=10000',

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=48a4db73-d3d4-4639-bbc2-9c797d0e6cda&limit=10000',

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=a14cc2fb-0c24-48d7-9370-834045797d89&limit=10000',

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=fb32fcb6-5e44-4e52-b132-01c6540ddbee&limit=10000',

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=0cb600fc-19ad-4aaf-9794-1e6ea851840a&limit=10000'

              ]

          }

  

          var datasetsGroeningen = {

              names:[

                  'Vestigingen register gemeente Groningen',

                  'Woonruimte gemeente Groningen'

              ],

              urls: [

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=ba554c1f-02a7-4d76-b449-fb9daa1f8bfd&limit=10000',

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=af7b3916-4347-469a-8354-3c2d559bd92f&limit=10000'

              ]

          }

  

          var datasetsDublin = {

              names:[

                  'SDCC Traffic Cameras',

                  'Derelict Site Register',

                  'Dublin City Council Commencement Notices',

                  'Dublin City Council Planning Applications',

                  'Dun Laoghaire-Rathdown County Council Planning Application 2008-2014',

                  'Fingal Council Planning Applications for last 7 years',

                  'Planning Register',

                  'Fingal Development Plan 2011-2017 Record of Protected Structures'

              ],

              urls: [

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=73e02092-85a1-434e-85fe-0c9a43aa9a52&limit=10000',

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=fcbee83e-3d3d-4303-a568-24dd33d02adc&limit=10000',

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=ee00de68-f2e4-482f-a003-3c0561351075&limit=10000',

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=2f4a9d44-b52f-4c8b-a5db-d8f4a676d81e&limit=10000',

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=c479f061-9638-489d-ac55-0c68765548ff&limit=10000',

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=d29a477a-4734-43ef-8002-048c8640d441&limit=10000',

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=2b23f32d-e27e-4eef-af1e-27e05103df7d&limit=10000',

                  'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=5ea813bc-fdf9-4edb-b3b1-0142b593d5c6&limit=10000',

              ]

          }

  

          var AvailableDatasets = [datasetsPrato, datasetsGroeningen, datasetsDublin]

  

  

73bcce88   luigser   COMPONENTS
481
482
483
484
          Polymer({

  

              is : 'data-sevc-controllet',

  

938d1928   Luigi Serra   Update documentat...
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
              /**

               * Received when the user selects a datalet from slider.

               *

               * @event items-slider-controllet_item-selected

               */

  

              /**

               * Received when the user drags a selected fields in to one of the source input data model field

               *

               * @event draggable-element-controllet_content-dragged

               */

  

              /**

               * Received when the user selects one field from treeview controllet

               *

               * @event treeview-controllet-fileds-selected

               */

  

              /**

               * Received when the user drags a selected fields in to one of the source input data model field

               *

               * @event draggable-element-controllet_content-dragged

               */

  

              /**

               * Fired when the user press to finish button. At this event are attached all information about the visualization currently created

               *

               * @event data-sevc-controllet.dataletCreated

               */

  

73bcce88   luigser   COMPONENTS
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
              listeners : {

                  'items-slider-controllet_item-selected' : '_dataletSelected',

                  'draggable-element-controllet_content-dragged' : '_fieldsMapped',

                  'treeview-controllet-fileds-selected' : '_fieldsSelected'

              },

  

              properties : {

  

                  entryAnimation : {

                      type  : String,

                      value : ""

                  },

  

                  exitAnimation  : {

                      type  : String,

                      value : ""

                  },

  

                  selected       : {

                      type  : Number,

                      value : 0

                  },

  

                  /**

938d1928   Luigi Serra   Update documentat...
539
                   * It represents the data url from CKAN api

73bcce88   luigser   COMPONENTS
540
541
542
543
544
545
546
                   *

                   * @attribute dataUrl

                   * @type string

                   * @default 'null'

                   */

                  dataUrl : {

                      type : String,

cb1aab91   Luigi Serra   Controllets update
547
                      value : "",/*"http://demo.ckan.org/api/action/datastore_search?resource_id=8324a4c9-66d6-47bf-a898-94237cc39b9f&limit=50",*/

73bcce88   luigser   COMPONENTS
548
549
550
                      observer : '_dataUrlChanged'

                  },

                  /**

938d1928   Luigi Serra   Update documentat...
551
                   * It represents the DEEP url to get information about the datalets

73bcce88   luigser   COMPONENTS
552
553
554
555
556
557
558
                   *

                   * @attribute deepUrl

                   * @type string

                   * @default 'null'

                   */

                  deepUrl : {

                      type : String,

cb1aab91   Luigi Serra   Controllets update
559
                      value : ""

73bcce88   luigser   COMPONENTS
560
                  },

938d1928   Luigi Serra   Update documentat...
561
562
563
564
565
566
567
                  /**

                   * It represents the organization related to datesets available for the user. It will be set at runtime based on the country of the user

                   *

                   * @attribute organization

                   * @type Number

                   * @default 2

                   */

8bada91f   Luigi Serra   Controllets and D...
568
569
                  organization : {

                      type : Number,

2b9aa997   Luigi Serra   Bugs fix
570
                      value : 2

8bada91f   Luigi Serra   Controllets and D...
571
                  },

938d1928   Luigi Serra   Update documentat...
572
573
574
575
576
577
578
                  /**

                   * It's used to store the list of datalets returned from DEEP

                   *

                   * @attribute datalets_list

                   * @type Array

                   * @default empty

                   */

73bcce88   luigser   COMPONENTS
579
580
581
582
                  datalets_list : {

                      type : Array ,

                      value : []

                  },

938d1928   Luigi Serra   Update documentat...
583
584
585
586
587
588
589
                  /**

                   * It's used to store the selected datalet. It will be set when the controllet get the event of selection by item slider (items-slider-controllet_item-selected)

                   *

                   * @attribute selected_datalet

                   * @type String

                   * @default ''

                   */

73bcce88   luigser   COMPONENTS
590
591
592
593
                  selected_datalet : {

                      type : String,

                      value : ""

                  },

938d1928   Luigi Serra   Update documentat...
594
595
596
597
598
599
600
                  /**

                   * It's used to store the list of selected fields by user

                   *

                   * @attribute selected_fields

                   * @type Array

                   * @default empty

                   */

73bcce88   luigser   COMPONENTS
601
602
603
                  selected_fields : {

                      type : Array,

                      value : []

cb1aab91   Luigi Serra   Controllets update
604
                  },

938d1928   Luigi Serra   Update documentat...
605
606
607
608
609
610
611
                  /**

                   * It's used to store the tab index in the first pass

                   *

                   * @attribute DatasourceTabSelected

                   * @type Number

                   * @default 0

                   */

cb1aab91   Luigi Serra   Controllets update
612
613
614
615
                  DatasourceTabSelected : {

                      type : Number,

                      value : 0

                  },

938d1928   Luigi Serra   Update documentat...
616
617
618
619
620
621
622
                  /**

                   * It's used to store the datasets to show in the contexual menu

                   *

                   * @attribute datasets

                   * @type Array

                   * @default empty

                   */

cb1aab91   Luigi Serra   Controllets update
623
624
625
                  datasets :

                  {

                      type : Array,

8bada91f   Luigi Serra   Controllets and D...
626
                      value : AvailableDatasets[0].names

cb1aab91   Luigi Serra   Controllets update
627
                  },

938d1928   Luigi Serra   Update documentat...
628
629
630
631
632
633
634
                  /**

                   * It's used to store the datasets urls

                   *

                   * @attribute datasets

                   * @type Array

                   * @default empty

                   */

cb1aab91   Luigi Serra   Controllets update
635
636
637
                  datasets_urls :

                  {

                      type : Array,

8bada91f   Luigi Serra   Controllets and D...
638
                      value :AvailableDatasets[0].urls

73bcce88   luigser   COMPONENTS
639
640
641
                  }

  

              },

938d1928   Luigi Serra   Update documentat...
642
643
644
645
646
647
648
649
              /**

               * It is called after the element’s template has been stamped and all elements inside the element’s local DOM have been configured (with values bound from parents, deserialized attributes, or else default values) and had their ready method called.

               * In this phase the scrollbar will be initialized

               *

               * @method handleResponseData

               *

               * @param {Event} e

               */

73bcce88   luigser   COMPONENTS
650
651
652
  

              ready : function(){

  

8bada91f   Luigi Serra   Controllets and D...
653
654
655
                  this.datasets = AvailableDatasets[this.organization].names;

                  this.datasets_urls = AvailableDatasets[this.organization].urls;

  

0b818d7e   Luigi Serra   Selection control...
656
657
658
659
                  $(this.$.fields_placeholder).perfectScrollbar();

                  $(this.$.selected_fields_main_container).perfectScrollbar();

                  $(this.$.idm_fields_main_container).perfectScrollbar();

                  $(this.$.table_fields_container).perfectScrollbar();

73bcce88   luigser   COMPONENTS
660
  

7b2d40bf   Luigi Serra   Selection control...
661
662
              },

  

73bcce88   luigser   COMPONENTS
663
664
665
666
              /**

               * Callback to parse the data requested when dataUrl change its value

               *

               * @method handleResponseData

938d1928   Luigi Serra   Update documentat...
667
668
               *

               * @param {Event} e

73bcce88   luigser   COMPONENTS
669
670
671
672
               */

              handleResponseData : function(e){

  

                  this.$.fields_treeview.init(e.detail.response);

74249687   Luigi Serra   Cross browser con...
673
  

73bcce88   luigser   COMPONENTS
674
675
676
677
678
679
              },

  

              /**

               * Callback to parse the components response object

               *

               * @method handleResponseDatalets

938d1928   Luigi Serra   Update documentat...
680
681
               *

               * @param {Event} e

73bcce88   luigser   COMPONENTS
682
683
684
685
686
687
688
689
690
691
692
               */

              handleResponseDatalets : function(e){

                  this.datalets_list = new Array();

                  for(var i=0;i < e.detail.response.length;i++){

                      var datalet_info = { name : e.detail.response[i].name ,

                                           image : e.detail.response[i].url + e.detail.response[i].name + ".png"

                      };

  

                      this.datalets_list.push(datalet_info);

                  }

  

73bcce88   luigser   COMPONENTS
693
                  this.$.visualization_slider_area.innerHTML = '<items-slider-controllet items=\'' + JSON.stringify(this.datalets_list) + '\'' +

0b818d7e   Luigi Serra   Selection control...
694
                                                               '\'></items-slider-controllet>';

73bcce88   luigser   COMPONENTS
695
              },

938d1928   Luigi Serra   Update documentat...
696
697
698
699
700
701
702
703
              /**

               * Callback to dataset selection from list in the phase three. When a datalet is selected this function will build a bundle of box items, based on the datalet input data model,

               * to allow user to drag the fields, from the selected fields box, and create a new visualization.

               *

               * @method handleSelectedDatalet

               *

               * @param {Event} e

               */

73bcce88   luigser   COMPONENTS
704
705
706
              handleSelectedDatalet : function(e){

  

                 var response = e.detail.response;

73bcce88   luigser   COMPONENTS
707
                 this.$.datalet_idm_fields_container.innerHTML = "";

73bcce88   luigser   COMPONENTS
708
  

a619e8e4   Luigi Serra   Selection control...
709
710
711
712
713
                 if(response.idm.inputs.input.constructor == Object) {

                     var input = response.idm.inputs.input;

                     if(input.selection == "*") {

                         var input_selected_fields = Polymer.dom(this.$.selected_fields_container).querySelectorAll('draggable-element-controllet');

                         for (var j = 0; j < input_selected_fields.length; j++) {

74249687   Luigi Serra   Cross browser con...
714
                             this.$.datalet_idm_fields_container.innerHTML += '<draggable-element-controllet is-target="true" heading="Field ' + (j + 1) + '"  description="' + input.description + '" number="' + (j + 1) + '"></draggable-element-controllet><br>';

a619e8e4   Luigi Serra   Selection control...
715
716
                         }

                     }

74249687   Luigi Serra   Cross browser con...
717
718
719
720
721
                 }else{

                     for(var i =0; i < response.idm.inputs.input.length; i++){

                         var input = response.idm.inputs.input[i];

                         this.$.datalet_idm_fields_container.innerHTML += '<draggable-element-controllet is-target="true" id="' + input.name + '" heading="' + input.name + '"  description="' + input.description + '" number="' + (i + 1) + '"></draggable-element-controllet><br>';

                     }

a619e8e4   Luigi Serra   Selection control...
722
723
                 }

  

73bcce88   luigser   COMPONENTS
724
              },

938d1928   Luigi Serra   Update documentat...
725
726
727
728
729
730
731
              /**

               * Validate the current pass in order to access to next one.

               *

               * @method validateCurrentPass

               *

               * @param {Number} next_selected_pass

               */

74249687   Luigi Serra   Cross browser con...
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
              validateCurrentPass : function(next_selected_pass){

  

                  switch(next_selected_pass){

                      case 0:

                          return true;

                      case 1:

                          if(this.$.data_url.value == ""){

                              this.$.message.text = "You have to select a dataset to access to pass 2.";

                              this.$.message.show();

                              return false;

                          }else{

                              return true;

                          }

  

                      case 2:

                          if(Polymer.dom(this.$.selected_fields_container).querySelectorAll('draggable-element-controllet') == 0){

                              this.$.message.text = "You have to select a set of fields to access to pass 3.";

                              this.$.message.show();

                              return false;

                          }else{

                              return true;

                          }

                  }

  

              },

938d1928   Luigi Serra   Update documentat...
757
758
759
760
761
762
              /**

               * Callback for manage the previous pass button

               *

               * @method _onPrevClick

               *

               */

73bcce88   luigser   COMPONENTS
763
              _onPrevClick : function() {

74249687   Luigi Serra   Cross browser con...
764
765
                  if(!this.validateCurrentPass(this.selected === 0 ? 0 : (this.selected - 1))) return;

  

73bcce88   luigser   COMPONENTS
766
                  this.entryAnimation = 'slide-from-left-animation';

2b9aa997   Luigi Serra   Bugs fix
767
768
                  this.exitAnimation  = 'slide-right-animation';

                  this.selected = this.selected === 0 ? 0 : (this.selected - 1);

73bcce88   luigser   COMPONENTS
769
              },

938d1928   Luigi Serra   Update documentat...
770
771
772
773
774
775
              /**

               * Callback for manage the next pass button

               *

               * @method _onNextClick

               *

               */

73bcce88   luigser   COMPONENTS
776
              _onNextClick : function() {

74249687   Luigi Serra   Cross browser con...
777
778
779
  

                  if(!this.validateCurrentPass(this.selected === 2 ? 2 : (this.selected + 1))) return;

  

73bcce88   luigser   COMPONENTS
780
                  this.entryAnimation = 'slide-from-right-animation';

2b9aa997   Luigi Serra   Bugs fix
781
782
                  this.exitAnimation  = 'slide-left-animation';

                  this.selected = this.selected === 2 ? 2 : (this.selected + 1);

73bcce88   luigser   COMPONENTS
783
              },

938d1928   Luigi Serra   Update documentat...
784
785
786
787
788
789
790
              /**

               * Callback related to datasource selection from select menu

               *

               * @method _datasourceSelected

               *

               * @param {Event} e

               */

cb1aab91   Luigi Serra   Controllets update
791
              _datasourceSelected : function(e){

2b235978   Luigi Serra   Controllet cross ...
792
  

74249687   Luigi Serra   Cross browser con...
793
                 this.$.data_url.value = this.datasets_urls[parseInt(e.target.id)];

cb1aab91   Luigi Serra   Controllets update
794
              },

938d1928   Luigi Serra   Update documentat...
795
796
797
798
799
800
801
              /**

               * Callback related to data url change

               *

               * @method _dataUrlChanged

               *

               * @param {Event} e

               */

73bcce88   luigser   COMPONENTS
802
803
804
              _dataUrlChanged : function(newValue, oldValue){

                  this.$.data_request.generateRequest();

              },

938d1928   Luigi Serra   Update documentat...
805
806
807
808
809
810
811
              /**

               * Callback related to event 'items-slider-controllet_item-selected' fired by items-slider-controllet when the user selects a datalet

               *

               * @method _dataletSelected

               *

               * @param {Event} e

               */

73bcce88   luigser   COMPONENTS
812
813
814
815
816
817
              _dataletSelected : function(e){

                  this.selected_datalet = e.detail.datalet;

                  this.$.selected_datalet_request.url = this.deepUrl + e.detail.datalet;

                  this.$.selected_datalet_request.generateRequest();

  

              },

938d1928   Luigi Serra   Update documentat...
818
819
820
821
822
823
824
              /**

               * Callback related to event 'treeview-controllet-fileds-selected' fired by treeview-controllet when the user selects a field

               *

               * @method _fieldsSelected

               *

               * @param {Event} e

               */

73bcce88   luigser   COMPONENTS
825
826
827
828
829
830
831
832
833
              _fieldsSelected : function(e){

  

                   this.$.selected_fields_container.innerHTML = "";

                   for(var i=0;i<e.detail.fields.length;i++) {

                      this.$.selected_fields_container.innerHTML += '<draggable-element-controllet identifier="' + e.detail.fields[i] +

                                                                                                   '" label="' + e.detail.fields[i].split(",")[e.detail.fields[i].split(",").length -1] +

                                                                    '"></draggable-element-controllet><br>';

                   }

  

74249687   Luigi Serra   Cross browser con...
834
835
                   var place_holder = (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) ? this.$.table_component_place_holder : this.$.table_component_place_holder[Object.keys(this.$.table_component_place_holder)[0]];

  

73bcce88   luigser   COMPONENTS
836
837
838
839
840
841
                   var table_params ={

                       component   : "datatable-datalet",

                       params      :{

                          'data-url' : this.dataUrl

                       },

                       fields      : e.detail.fields,

74249687   Luigi Serra   Cross browser con...
842
                       placeHolder :  this.$.table_component_place_holder

73bcce88   luigser   COMPONENTS
843
844
845
846
847
848
                   };

  

                   ComponentService.deep_url = this.deepUrl;

                   ComponentService.getComponent(table_params);

  

              },

938d1928   Luigi Serra   Update documentat...
849
850
851
852
853
854
855
              /**

               * Callback related to event 'draggable-element-controllet_content-dragged' fired by draggable-element-controllet when the user drags a selected field in to input data model field

               *

               * @method _fieldsMapped

               *

               * @param {Event} e

               */

73bcce88   luigser   COMPONENTS
856
857
858
859
860
              _fieldsMapped : function(e){

  

                  var input_mapped_fields = Polymer.dom(this.$.datalet_idm_fields_container).querySelectorAll('draggable-element-controllet[is-target=true]');

                  this.selected_fields = Array();

  

a619e8e4   Luigi Serra   Selection control...
861
862
                  for (var i = 0; i < input_mapped_fields.length; i++) {

                      if (input_mapped_fields[i].value != "") {

73bcce88   luigser   COMPONENTS
863
864
865
866
867
868
869
870
871
872
873
874
875
                          this.selected_fields.push(input_mapped_fields[i].value);

                      }

                  }

  

                  var datalet_params ={

                      component   : this.selected_datalet,

                      params      :{

                          'data-url' : this.dataUrl

                      },

                      fields      : this.selected_fields,

                      placeHolder : this.$.datalet_placeholder

                  };

  

73bcce88   luigser   COMPONENTS
876
877
  

                  ComponentService.deep_url = this.deepUrl;

73bcce88   luigser   COMPONENTS
878
                  ComponentService.getComponent(datalet_params);

73bcce88   luigser   COMPONENTS
879
880
  

              },

938d1928   Luigi Serra   Update documentat...
881
882
883
884
885
886
887
              /**

               * Callback related to the drag operation in the dataUrl input area. It's used to delete previous value.

               *

               * @method _handleDatasourceDragOver

               *

               * @param {Event} e

               */

73bcce88   luigser   COMPONENTS
888
889
890
              _handleDatasourceDragOver : function(e){

                  this.$.data_url.value = "";

              },

938d1928   Luigi Serra   Update documentat...
891
892
893
894
895
896
897
              /**

               * Callback related to the finish button.

               *

               * @method _onFinish

               *

               * @param {Event} e

               */

73bcce88   luigser   COMPONENTS
898
899
              _onFinish : function(e){

  

dbc787cf   Luigi Serra   Controllet cross ...
900
901
902
903
904
905
                  if(this.selected_fields.length == 0 || this.selected_datalet == ""){

                      this.$.message.text = "You have to map the selected fields with datalets fields(by dragging) and select a datalet to export a new visualization.";

                      this.$.message.show();

                      return;

                  }

  

73bcce88   luigser   COMPONENTS
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
                  var data = {

                      dataUrl : this.dataUrl,

                      fields : this.selected_fields,

                      datalet : this.selected_datalet

                  }

  

                  this.fire('data-sevc-controllet.dataletCreated', {data : data});

  

              }

  

          });

  

      </script>

  

  </dom-module>