Blame view

controllets/dataset-selection-controllet/dataset-selection-controllet.html 10.1 KB
a31f0660   root   sevc-controllet i...
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
  <link rel="import" href="../../bower_components/polymer/polymer.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/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">
  
  <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-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/iron-icons.html">
  <link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
  
  <link rel="import" href="../../bower_components/paper-dialog/paper-dialog.html">
  <link rel="import" href="../../bower_components/paper-dialog-scrollable/paper-dialog-scrollable.html">
  
  <link rel="import" href="../../datalets/datasetexplorer-datalet/datasetexplorer-datalet.html">
  
  <!--<script src="../../datalets/shared_js/d3.js"></script>-->
  
4bf5f658   root   update tree map, ...
29
30
  <link rel="import" href="paper-input-search.html">
  
a31f0660   root   sevc-controllet i...
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
  <dom-module id="dataset-selection-controllet">
  
      <template>
  
          <style is="custom-style">
              paper-tabs {
                  font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
                  font-size: 16px;
                  font-weight: bold;
                  --paper-tabs-selection-bar-color: #2196F3;
              }
  
              paper-tab {
                  transition: all 1.0s;
              }
  
              paper-tab.iron-selected {
                  background-color: #B6B6B6;
              }
  
              paper-tab:hover {
                  color: #2196F3;
              }
  
              paper-tab[disabled] {
                  color: #B6B6B6;
              }
  
0f6424fe   root   update new data-s...
59
60
61
62
63
64
65
              /*paper-dropdown-menu {*/
                  /*width: 45%;*/
                  /*margin-bottom: 32px;*/
                  /*--paper-input-container-focus-color: #2196F3;*/
              /*}*/
  
              paper-input-search {
a31f0660   root   sevc-controllet i...
66
67
68
69
70
                  width: 45%;
                  margin-bottom: 32px;
                  --paper-input-container-focus-color: #2196F3;
              }
  
0f6424fe   root   update new data-s...
71
72
73
74
              paper-input-search paper-item {
                  white-space: nowrap;
              }
  
a31f0660   root   sevc-controllet i...
75
76
77
78
79
              paper-item.iron-selected {
                  background-color: #2196F3;
                  color: #FFFFFF;
              }
  
4bf5f658   root   update tree map, ...
80
81
82
83
              paper-menu{
                  /*visibility: visible ! important;*/
              }
  
a31f0660   root   sevc-controllet i...
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
              /*paper-item[focused] {*/
                  /*background: #FFFFFF;*/
              /*}*/
  
              paper-textarea {
                  width: 90%;
                  margin-bottom: 32px;
                  --paper-input-container-focus-color: #2196F3;
              }
  
              paper-icon-button {
                  color: #2196F3;
                  --paper-icon-button-ink-color: #2196F3;
              }
  
              paper-icon-button[disabled] {
                  color: #B6B6B6;
              }
  
              #material_container {
                  margin-top: 8px;
                  /*height: 55vh;*/
              }
  
              #div_selection {
                  padding-left: 10%;
                  padding-top: 64px;
                  /*padding-bottom: 64px;*/
              }
  
              #dialog_info {
                  border: 2px solid #2196F3;
                  background-color: #E0E0E0;
                  position: fixed;
                  top: 232px;
                  width: 60%;
                  height: auto;
                  /*overflow: auto;*/
              }
  
              #div_datasetexplorer {
                  padding-top: 48px;
              }
          </style>
  
          <paper-material id="material_container" elevation="5">
  
              <paper-tabs selected="{{selected}}" on-tap="_loadTreeMap">
                  <paper-tab noink>SELECT DATA SOURCE</paper-tab>
0f6424fe   root   update new data-s...
133
                  <paper-tab noink>TREE MAP VIEW</paper-tab>
a31f0660   root   sevc-controllet i...
134
135
136
137
138
139
140
141
                  <paper-tab noink disabled>MOST POPULAR</paper-tab>
              </paper-tabs>
  
              <neon-animated-pages selected="{{selected}}" entry-animation="fade-in-animation" exit-animation="fade-out-animation">
  
                  <neon-animatable>
  
                      <div id="div_selection">
0f6424fe   root   update new data-s...
142
  
4bf5f658   root   update tree map, ...
143
                          <paper-input-search label="Available datasets">
a31f0660   root   sevc-controllet i...
144
                              <paper-menu class="dropdown-content">
0f6424fe   root   update new data-s...
145
                                  <template is="dom-repeat" items={{filteredDatasets}} as="dataset">
a31f0660   root   sevc-controllet i...
146
                                      <paper-item id={{index}} on-tap="_selectDataUrl">{{dataset.name}}</paper-item>
0f6424fe   root   update new data-s...
147
                                      <!--<paper-item id={{index}} on-tap="_selectDataUrl">{{_addHTMLSpace(dataset.name)}}</paper-item>-->
a31f0660   root   sevc-controllet i...
148
149
                                  </template>
                              </paper-menu>
4bf5f658   root   update tree map, ...
150
                          </paper-input-search>
a31f0660   root   sevc-controllet i...
151
152
  
                          <paper-icon-button id="info_button" disabled on-click="_showInfo" icon="info-outline" title="dataset info"></paper-icon-button>
0f6424fe   root   update new data-s...
153
                              <!--aggiustami anche dialog...-->
a31f0660   root   sevc-controllet i...
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
                          <paper-textarea id="selected_url" label="Selected url" value={{dataUrl}}></paper-textarea>
  
                          <paper-dialog id="dialog_info">
                              <h2 id="dialog_name"></h2>
                              <p id="dialog_description"></p>
                          </paper-dialog>
                      </div>
  
                  </neon-animatable>
  
                  <neon-animatable>
                      <div id="div_datasetexplorer">
                          <datasetexplorer-datalet class="datasetexplorer" data-url="/oxwall_x.y.z/openwall/api/datasetTree" fields='["result,provider_name","result,organization_name","result,package_name","result,resource_name","result,url","result,w"]'></datasetexplorer-datalet>
                      </div>
                  </neon-animatable>
  
                  <neon-animatable>
                  </neon-animatable>
  
              </neon-animated-pages>
  
          </paper-material>
  
      </template>
  
      <script>
  
          Polymer({
  
              is : 'dataset-selection-controllet',
  
              properties : {
  
                  selected : {
                      type  : Number,
                      value : 0
                  },
  
                  datasets : {
                      type : Array,
                      value : undefined
                  },
  
0f6424fe   root   update new data-s...
197
198
199
200
201
                  filteredDatasets : {
                      type : Array,
                      value : []
                  },
  
a31f0660   root   sevc-controllet i...
202
203
204
205
206
207
208
209
210
                  dataUrl : {
                      type  : String,
                      value : undefined,
                      observer : '_fireDataUrl'
                  }
  
              },
  
              listeners: {
0f6424fe   root   update new data-s...
211
212
                  'datasetexplorer-datalet_data-url': '_selectDataUrl_treeMap',
                  'paper-input-search_input-value' : '_filterDatasets'
a31f0660   root   sevc-controllet i...
213
214
215
216
217
218
219
220
221
222
              },
  
              ready : function(){
                  $(this.$.dialog_info).perfectScrollbar();
              },
  
              attached : function(){
                  this._resize();
                  var that = this;
                  window.addEventListener("resize", function() { that._resize(); });
0f6424fe   root   update new data-s...
223
224
225
226
227
  
                  this.filteredDatasets = this.datasets;
              },
  
              _filterDatasets : function(e){
47c1dcd5   root   selectio-controll...
228
                  var filter = e.detail.inputValue;
0f6424fe   root   update new data-s...
229
230
231
232
233
234
235
                  var filteredDatasets = [];
                  for (var i in this.datasets){
                      if(this.datasets[i].name.toLowerCase().indexOf(filter.toLowerCase()) != -1)
                          filteredDatasets.push(this.datasets[i]);
                  }
  
                  this.filteredDatasets = filteredDatasets;
a31f0660   root   sevc-controllet i...
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
              },
  
              _loadTreeMap : function(){
                  if(this.selected == 0 && this.$.div_datasetexplorer.innerHTML == "")
                      this.$.div_datasetexplorer.innerHTML = "<datasetexplorer-datalet class=\"datasetexplorer\" data-url=\"/oxwall_x.y.z/openwall/api/datasetTree\" fields='[\"result,provider_name\",\"result,organization_name\",\"result,package_name\",\"result,resource_name\",\"result,url\",\"result,w\"]'></datasetexplorer-datalet>";
              },
  
              _selectDataUrl_treeMap : function(e){
                  var url = e.detail.url;
                  url = url.split('/');
                  var index = url.indexOf('resource')
                  if (index != -1) { // ckan
                      var resourceId = url[index + 1];
                      url = "http://ckan.routetopa.eu/api/action/datastore_search?resource_id=" + resourceId;
  
                  } else
                      url = "sorry, data provider not supported yet";
  
                  this.dataUrl = url;
                  this.selected=0;
              },
  
              _selectDataUrl : function(e){
47c1dcd5   root   selectio-controll...
259
                  var dataset = this.filteredDatasets[parseInt(e.target.id)]
a31f0660   root   sevc-controllet i...
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
  
                  this.dataUrl = dataset.url;
  
                  if(dataset.description != ""){
                      this.$.info_button.removeAttribute("disabled");
                      this.$.dialog_name.innerHTML = dataset.name;
                      this.$.dialog_description.innerHTML = dataset.description;
                  }
                  else
                      this.$.info_button.setAttribute("disabled", "true");
              },
  
              _showInfo : function(){
                  this.$.dialog_info.open();
              },
  
              _fireDataUrl : function(){
                  this.fire('dataset-selection-controllet_data-url', {url: this.dataUrl});
              },
  
0f6424fe   root   update new data-s...
280
281
282
283
  //            _addHTMLSpace : function(name){
  //                return name.replace(/ /g, '&nbsp;');
  //            },
  
a31f0660   root   sevc-controllet i...
284
285
286
287
288
289
290
291
292
293
294
              _resize : function(){
                  var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16;
                  h = h - 64 - 8; //height with page scroller
                  $("#material_container").height(h);
              }
  
          });
  
      </script>
  
  </dom-module>