Blame view

controllets/data-sevc-controllet/data-sevc-controllet.html 24.3 KB
73bcce88   luigser   COMPONENTS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
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
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
  <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="../../controllets/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">

  

  

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

      <template>

          <link rel="stylesheet" href="../shared_js/malihu-custom-scrollbar-plugin-3.0.9/jquery.mCustomScrollbar.css">

          <style is="custom-style">

              body {

                  font-family: RobotoDraft, 'Helvetica Neue', Helvetica, Arial;

                  font-size: 1em;

                  margin: 0;

                  padding: 1.5em;

                  -webkit-tap-highlight-color: rgba(0,0,0,0);

                  -webkit-touch-callout: none;

              }

  

              #pages{

                  min-width: 1336px;

                  max-width: 1634px;

              }

  

              .fields-card-content {

                  padding-left: 1.5em;

              }

  

              .fancy .fields-title {

                  /*position: absolute;

                  top: 30px;

                  left: 100px;

                  display: inline-block;*/

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

              }

  

               .fancy-content {

                  /*padding: 25px;*/

              }

  

               .avatar {

                  display: inline-block;

                  height: 2em;

                  width: 2em;

                  border-radius: 50%;

                  /*background: var(--paper-pink-500);*/

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

                  color: white;

                  line-height: 2em;

                  font-size: 1.87em;

                  text-align: center;

              }

  

               .fancy .title {

                  /*position: absolute;

                  top: 30px;

                  left: 100px;*/

                  display: inline-block;

                  position: relative;

                  top: .75em;

                  left: .625em;

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

              }

  

               .fancy .big {

                  font-size: 1.37em;

                  padding: 0.5em 0 1em;

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

              }

  

               .fancy .medium {

                  font-size: 1em;

                  padding-bottom: 0.5em;

                  color : #000000;

                  font-weight: bold;

              }

  

              paper-input {

                  width: 80%;

              }

  

              #visualization_slider_area{

                  position:relative;

                  float:left;

                  height: 22vh;

                  /*width: 50%;*/

                  min-width: 670px;

                  min-height: 180px;

              }

  

              #datalet_area{

                  position:relative;

                  /*height: 30em;*/

                  width: 46%;

                  min-height: 500px;

                  min-width: 600px;

                  float: right;

              }

  

              #fields_mapping_area{

                  position:relative;

                  height: auto;/*70%;*/

                  /*width: 50%;*/

                  float:left;

                  min-width: 670px;

              }

  

               #visualization_customization_area{

                  position:relative;

                  /*height:auto;*/

                  width: 46%;

                  float:right;

                  background-color: white;

              }

  

              .field-mapping-card{

                  width: 50%;

                  height: 50vh;

                  overflow: auto;

                  position: relative;

                  float: left;

                  overflow: auto;

              }

  

              .horizontal-section-container .vertical-section {

                  /*max-width: 130px;*/

                  diplay:block;

                  float: left;

              }

  

  

              .colorful {

                  background: #4285f4;

                  color: #fff;

              }

  

              .toolbar_button{

                  /*height: 100%;

                  display: inline-block;*/

                  float: left;

                  margin-top: 2em;

                  --iron-icon-height: 32px;

                  --iron-icon-width: 32px;

              }

  

              /*paper-iron-button.toolbar_button{

                  height: 34px;

                  width: 34px;

              }*/

  

              .toolbar-center{

                  display: inline-block;

                  position: relative;

                  float: left;

                  width: 90%;

              }

  

              .toolbar{

                  width: 100%;

                  height : 8em;

                  vertical-align: middle;

                  min-width: 975px;

              }

  

  

  

              #datalet_created_idm_fields_container{

                  position: relative;

                  float: left;

                  width: 100%;

                  height: 50vh;

                  overflow: auto;

              }

  

              #finish{

                  position: relative;

                  float: left;

                  width: 100%;

                  height : 20%;

                  align-content: center;

              }

  

              #datalet_created_placehorder {

                  width: 100%;

              }

  

              #finish_button{

                  float: left;

                  margin-top: 2em;

                  --iron-icon-height: 64px;

                  --iron-icon-width: 64px;

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

              }

  

              #finish_button:hover{

                  --iron-icon : "add-circle-outline"

              }

  

             /* #finish_button iron-icon:hover{

                  icon : "add-circle";

              }

  

              #finish_button iron-icon{

                  height: 4vh;

                  width: 4vw;

              }*/

  

              .area_container{

                  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);

              }

  

              #fields_placeholder{

                  width: 40%;

                  height: 50vh;

                  float: left;

                  overflow: auto;

              }

  

              #table_fields_container{

                  height: 50vh;

                  width: 55%;

                  /*max-width: 100vw;

                  max-height: 50vh;*/

                  float: left;

                  overflow: auto;

              }

  

          </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>

              <div class="toolbar">

                  <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="fancy toolbar-center">

                      <div class="fancy-content">

                          <div id="toolbar_number" class="avatar">1</div>

                          <div class="title">

                              <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>

                      </div>

                  </div>

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

              </div>

  

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

  

                  <neon-animatable>

  

                      <div class="fancy">

                          <div class="card-content">

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

                          </div>

                      </div>

  

                  </neon-animatable>

  

                  <neon-animatable>

  

                      <div class="fancy">

                          <div class="fancy-content">

  

                              <div id="fields_placeholder" class="area_container mCustomScrollBox" data-mcs-theme="minimal-dark">

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

                              </div>

                              <div id="table_fields_container" class="area_container mCustomScrollBox" data-mcs-theme="minimal-dark">

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

                              </div>

                          </div>

                      </div>

  

                  </neon-animatable>

  

                  <neon-animatable>

  

                      <div class='fancy'>

                          <div class="fancy-content">

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

  

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

                                 <div id="datalet_placeholder"></div>

                              </div>

  

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

  

                                      <div class="field-mapping-card mCustomScrollBox" data-mcs-theme="minimal-dark">

                                          <div class="title">

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

                                          </div>

                                          <div id="selected_fields_container" class="area_container mCustomScrollBox" data-mcs-theme="minimal-dark"></div>

                                      </div>

  

                                      <div class="field-mapping-card mCustomScrollBox" data-mcs-theme="minimal-dark">

                                          <div class="title">

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

                                          </div>

                                          <div id="datalet_idm_fields_container" class="area_container mCustomScrollBox" data-mcs-theme="minimal-dark"></div>

                                      </div>

                              </div>

  

                              <div id="visualization_customization_area">

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

                              </div>

  

                          </div>

                      </div>

  

                  </neon-animatable>

  

                  <!--<neon-animatable>

  

                      <div class="fancy">

                          <div class="card-content area_container">

                              <div id="datalet_created_placehorder"></div>

                          </div>

                          <div class="card-content area_container">

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

                          </div>

                      </div>

  

                  </neon-animatable>-->

  

              </neon-animated-pages>

          </content>

      </template>

      <script src="../shared_js/bootstrap-3.3.4-dist/js/bootstrap.min.js"></script>

      <script src="../shared_js/malihu-custom-scrollbar-plugin-3.0.9/jquery.mCustomScrollbar.js"></script>

      <script src="../../../DEEPCLIENT/js/deepClient.js"></script>

  

      <script>

  

          Polymer({

  

              is : 'data-sevc-controllet',

  

              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

                  },

  

                  /**

                   * It represent the data url from CKAN api

                   *

                   * @attribute dataUrl

                   * @type string

                   * @default 'null'

                   */

                  dataUrl : {

                      type : String,

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

                      observer : '_dataUrlChanged'

                  },

                  /**

                   * It represent the DEEP url to get information about the datalets

                   *

                   * @attribute deepUrl

                   * @type string

                   * @default 'null'

                   */

                  deepUrl : {

                      type : String,

                      value : "http://demo.ckan.org/api/action/datastore_search?resource_id=8324a4c9-66d6-47bf-a898-94237cc39b9f&limit=50"

                  },

  

                  datalet_query : {

                      type : String,

                      value : ""

                  },

  

                  datalets_list : {

                      type : Array ,

                      value : []

                  },

  

                  selected_datalet : {

                      type : String,

                      value : ""

                  },

  

                  selected_fields : {

                      type : Array,

                      value : []

                  }

  

              },

  

              ready : function(){

  

                  var scrollbar_options = {

                      autoHideScrollbar:true,

                      theme:"rounded"

                  };

  

                  $(this.$.fields_placeholder).mCustomScrollbar(scrollbar_options);

                  $(".field-mapping-card").mCustomScrollbar(scrollbar_options);

  

                  /*$(this.$.table_fields_container).mCustomScrollbar({

                      autoHideScrollbar:true,

                      theme:"rounded",

                      advanced:{autoExpandHorizontalScroll:true},

                      axis:"yx"

                  });*/

              },

  

              /**

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

               *

               * @method handleResponseData

               */

              handleResponseData : function(e){

  

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

                  var table_params ={

                      component   : "datatable-datalet",

                      params      :{

                          'data-url' : this.dataUrl

                      },

                      fields      : [],

                      placeHolder : this.$.table_component_place_holder

                  };

  

                  ComponentService.deep_url = this.deepUrl;

                  ComponentService.getComponent(table_params);

  

              },

  

              /**

               * Callback to parse the components response object

               *

               * @method handleResponseDatalets

               */

              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);

                  }

  

                  var w = $(this.$.visualization_slider_area).width();

                  var pages = 2;

                  var numItemsPerPage = 3;

  

                  this.$.visualization_slider_area.innerHTML = '<items-slider-controllet items=\'' + JSON.stringify(this.datalets_list) + '\'' +

                                                               '\'></items-slider-controllet>'

              },

  

              handleSelectedDatalet : function(e){

  

                 var response = e.detail.response;

                 //<draggable-element-controllet is-target="true" heading="Field 1"  description="This fields is used for ..." number="1"></draggable-element-controllet>

                 this.$.datalet_idm_fields_container.innerHTML = "";

                 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...
518
519
520
521
522
523
524
525
526
527
                 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++) {

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

                         }

                     }

                 }

  

73bcce88   luigser   COMPONENTS
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
              },

  

              assignToolbar : function(){

                  this.$.toolbar_number.innerHTML = (this.selected + 1);

                  switch(this.selected){

                     case 0:

                         this.$.toolbar_title.innerHTML  = "Dataset source";

                         this.$.toolbar_description.innerHTML = "Copy and paste/drag and drop in the textarea the url of datasource";

                         break;

                     case 1:

                         this.$.toolbar_title.innerHTML  = "Data fields selection";

                         this.$.toolbar_description.innerHTML = "Select the fields you want to visualize";

                         break;

                     case 2:

                         this.$.toolbar_title.innerHTML  = "Data mapping";

                         this.$.toolbar_description.innerHTML = "Select the visualization from the slider, drag and drop the selected fields in visualization parameter area, customize the visualization if you need";

                         break;

                      case 3:

                          this.$.toolbar_title.innerHTML  = "Finish";

                          this.$.toolbar_description.innerHTML = "Confirms the creation of the datalet";

  

                          break;

                 }

              },

  

              _onPrevClick : function() {

                  this.entryAnimation = 'slide-from-left-animation';

                  this.exitAnimation = 'slide-right-animation';

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

                  this.assignToolbar();

              },

  

              _onNextClick : function() {

                  this.entryAnimation = 'slide-from-right-animation';

                  this.exitAnimation = 'slide-left-animation';

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

                  this.assignToolbar();

              },

  

              _dataUrlChanged : function(newValue, oldValue){

                  this.$.data_request.generateRequest();

              },

  

              _dataletSelected : function(e){

                  this.selected_datalet = e.detail.datalet;

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

                  this.$.selected_datalet_request.generateRequest();

  

              },

  

              _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>';

                   }

  

                   var table_params ={

                       component   : "datatable-datalet",

                       params      :{

                          'data-url' : this.dataUrl

                       },

                       fields      : e.detail.fields,

                       placeHolder : this.$.table_component_place_holder

                   };

  

                   ComponentService.deep_url = this.deepUrl;

                   ComponentService.getComponent(table_params);

  

              },

  

              _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...
606
607
                  for (var i = 0; i < input_mapped_fields.length; i++) {

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

73bcce88   luigser   COMPONENTS
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
                          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

                  };

  

                  var datalet_finish_params ={

                      component   : this.selected_datalet,

                      params      :{

                          'data-url' : this.dataUrl

                      },

                      fields      : this.selected_fields,

                      placeHolder : this.$.datalet_created_placehorder

                  };

  

                  ComponentService.deep_url = this.deepUrl;

  

                  ComponentService.getComponent(datalet_params);

                  ComponentService.getComponent(datalet_finish_params);

  

              },

  

              _handleDatasourceDragOver : function(e){

                  this.$.data_url.value = "";

              },

  

              _onFinish : function(e){

  

                  var data = {

                      dataUrl : this.dataUrl,

                      fields : this.selected_fields,

                      datalet : this.selected_datalet

                  }

  

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

  

              }

  

          });

  

      </script>

  

  </dom-module>