Blame view

controllets/dataset-selection-controllet/dataset-selection-controllet.html 8.78 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;
              }
  
025ed52b   isisadmin   fix
59
              paper-dropdown-menu {
a31f0660   root   sevc-controllet i...
60
61
62
63
64
                  width: 45%;
                  margin-bottom: 32px;
                  --paper-input-container-focus-color: #2196F3;
              }
  
a31f0660   root   sevc-controllet i...
65
66
67
68
69
              paper-item.iron-selected {
                  background-color: #2196F3;
                  color: #FFFFFF;
              }
  
4bf5f658   root   update tree map, ...
70
71
72
73
              paper-menu{
                  /*visibility: visible ! important;*/
              }
  
a31f0660   root   sevc-controllet i...
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
              /*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>
025ed52b   isisadmin   fix
123
                  <paper-tab noink>TREE MAP SEARCH</paper-tab>
a31f0660   root   sevc-controllet i...
124
125
126
127
128
129
130
131
                  <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">
4bf5f658   root   update tree map, ...
132
                          <paper-input-search label="Available datasets">
a31f0660   root   sevc-controllet i...
133
                              <paper-menu class="dropdown-content">
025ed52b   isisadmin   fix
134
                                  <template is="dom-repeat" items={{datasets}} as="dataset">
a31f0660   root   sevc-controllet i...
135
                                      <paper-item id={{index}} on-tap="_selectDataUrl">{{dataset.name}}</paper-item>
a31f0660   root   sevc-controllet i...
136
137
                                  </template>
                              </paper-menu>
4bf5f658   root   update tree map, ...
138
                          </paper-input-search>
a31f0660   root   sevc-controllet i...
139
140
  
                          <paper-icon-button id="info_button" disabled on-click="_showInfo" icon="info-outline" title="dataset info"></paper-icon-button>
025ed52b   isisadmin   fix
141
  
a31f0660   root   sevc-controllet i...
142
143
144
145
146
147
148
149
150
151
152
153
                          <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">
025ed52b   isisadmin   fix
154
                          <datasetexplorer-datalet class="datasetexplorer" data-url="/openwall/api/datasetTree" fields='["result,provider_name","result,organization_name","result,package_name","result,resource_name","result,url","result,w"]'></datasetexplorer-datalet>
a31f0660   root   sevc-controllet i...
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
                      </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
                  },
  
a31f0660   root   sevc-controllet i...
185
186
187
188
189
190
191
192
193
                  dataUrl : {
                      type  : String,
                      value : undefined,
                      observer : '_fireDataUrl'
                  }
  
              },
  
              listeners: {
025ed52b   isisadmin   fix
194
                  'datasetexplorer-datalet_data-url': '_selectDataUrl_treeMap'
a31f0660   root   sevc-controllet i...
195
196
197
198
199
200
201
202
203
204
              },
  
              ready : function(){
                  $(this.$.dialog_info).perfectScrollbar();
              },
  
              attached : function(){
                  this._resize();
                  var that = this;
                  window.addEventListener("resize", function() { that._resize(); });
a31f0660   root   sevc-controllet i...
205
206
207
208
              },
  
              _loadTreeMap : function(){
                  if(this.selected == 0 && this.$.div_datasetexplorer.innerHTML == "")
025ed52b   isisadmin   fix
209
                      this.$.div_datasetexplorer.innerHTML = "<datasetexplorer-datalet class=\"datasetexplorer\" data-url=\"/openwall/api/datasetTree\" fields='[\"result,provider_name\",\"result,organization_name\",\"result,package_name\",\"result,resource_name\",\"result,url\",\"result,w\"]'></datasetexplorer-datalet>";
a31f0660   root   sevc-controllet i...
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
              },
  
              _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){
025ed52b   isisadmin   fix
228
                  var dataset = this.datasets[parseInt(e.target.id)]
a31f0660   root   sevc-controllet i...
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
  
                  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});
              },
  
a31f0660   root   sevc-controllet i...
249
250
251
252
253
254
255
256
257
258
259
              _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>