Blame view

controllets/datalet-preview-controllet/datalet-preview-controllet.html 9.28 KB
256ece27   Renato De Donato   new controllet
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
  <link rel="import" href="../../bower_components/polymer/polymer.html" />
  
  <link rel="import" href="../../bower_components/paper-material/paper-material.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">
  
  <dom-module id="datalet-preview-controllet">
  
      <template>
  
          <style is="custom-style">
              #preview_container {
                  height: 100%;
                  width: 100%;
              }
  
              #preview_container * {
                  font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
                  font-size: 16px;
                  line-height: 24px;
              }
  
              #preview_container #neon_container {
                  height: calc(100% - 48px);
                  width: 100%;
              }
  
              #preview_container #preview, #preview_container #info {
                  position: relative;
                  height: calc(100% - 32px);
                  width: calc(100% - 32px);
                  padding: 16px;
              }
  
              #preview_container #info_container {
                  display: flex;
                  flex-direction: row;
              }
  
              #preview_container #datalet_img{
                  min-height: 124px;
                  width: 124px;
                  position:relative;
              }
  
              #preview_container img{
                  max-width: 124px;
                  position: absolute;
                  top: 0;
                  bottom: 0;
                  margin: auto;
              }
  
              #preview_container #datalet_base_info {
                  width: calc(100% - 124px - 16px);
                  margin-left: 16px;
              }
  
              #preview_container #datalet_name{
                  font-size: 32px;
                  line-height: 48px;
                  color: #2196F3;
              }
  
              #preview_container #datalet_description{
              }
  
              #preview_container #datalet_inputs{
                  margin-top: 16px;
              }
  
              #preview_container .input_label {
                  color: #2196F3;
                  font-weight: 700;
              }
  
              #preview_container ul {
                  list-style-type: disc;
              }
  
              #preview_container li {
                  font-weight: 700;
              }
  
              paper-tabs {
                  background: #B6B6B6;
a4b9ef13   Renato De Donato   css +ln
92
                  /*--paper-tabs-selection-bar-color: #00BCD4;*/
256ece27   Renato De Donato   new controllet
93
94
95
              }
  
              paper-tab {
a4b9ef13   Renato De Donato   css +ln
96
97
98
99
100
101
102
                  font-weight: 700;
                  border-right: 2px solid #FFFFFF;
                  /*--paper-tab-ink: #2196F3;*/
              }
  
              paper-tab:nth-child(2) {
                  border-right: 0;
256ece27   Renato De Donato   new controllet
103
104
105
              }
  
              paper-tab.iron-selected {
a4b9ef13   Renato De Donato   css +ln
106
107
                  color: #FFFFFF;
                  background: #2196F3;;
256ece27   Renato De Donato   new controllet
108
109
              }
  
a4b9ef13   Renato De Donato   css +ln
110
              paper-tab:not(.iron-selected):hover {
256ece27   Renato De Donato   new controllet
111
112
113
114
115
116
117
                  color: #2196F3;
              }
  
          </style>
  
          <paper-material id="preview_container" elevation="5">
  
a4b9ef13   Renato De Donato   css +ln
118
119
120
              <paper-tabs selected="{{tabIndex}}" no-bar>
                  <paper-tab noink><span id="previewTab"></span></paper-tab>
                  <paper-tab noink><span id="infoTab"></span></paper-tab>
256ece27   Renato De Donato   new controllet
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
              </paper-tabs>
  
              <neon-animated-pages id="neon_container" selected="{{_getNeonIndex(tabIndex)}}" entry-animation="fade-in-animation" exit-animation="fade-out-animation">
  
                  <neon-animatable>
                      <div id="preview">
  
                      </div>
                  </neon-animatable>
  
                  <neon-animatable>
                      <div id="info">
                          <div id="info_container">
                              <div id="datalet_img">
                                  <img src="{{dataletImg}}">
                              </div>
                              <div id="datalet_base_info">
                                  <div id="datalet_name">
                                      {{dataletName}}
                                  </div>
                                  <div id="datalet_description">
                                      {{dataletDescription}}
                                  </div>
                              </div>
                          </div>
                          <div id="datalet_inputs">
                              <span id="inputs" class="input_label"></span>
                              <ul>
                                  <template is="dom-repeat" items="{{inputs}}">
                                      <li>{{_getInputName(item.name)}}</li>
                                      {{_getInputDescription(item.name)}}
                                  </template>
                              </ul>
                              <span id="options" class="input_label"></span>
                              <ul>
                                  <template is="dom-repeat" items="{{options}}">
                                      <li>{{_getInputName(item.name)}}</li>
                                      {{_getInputDescription(item.name)}}
                                  </template>
                              </ul>
                          </div>
                      </div>
                  </neon-animatable>
  
              </neon-animated-pages>
  
          </paper-material>
  
      </template>
  
      <script>
  
          Polymer({
  
              is : 'datalet-preview-controllet',
  
              properties : {
  
                  deepUrl : {
                      type : String,
                      value : undefined
                  },
  
                  tabIndex: {
                      type: Number,
                      value: 0
                  }
  
              },
  
              ready : function() {
                  $(this.$.preview).perfectScrollbar();
                  $(this.$.info).perfectScrollbar();
              },
  
              attached : function() {
                  this._translate();
              },
  
              _translate : function(){
                  this.$.previewTab.innerHTML = ln["previewTab_" + ln["localization"]];
                  this.$.infoTab.innerHTML = ln["infoTab_" + ln["localization"]];
              },
  
              loadDatalet : function(dataletParams){
                  this._setTabindex(0);
  
                  dataletParams.placeHolder = this.$.preview;
  
                  ComponentService.deep_url = this.deepUrl;
                  ComponentService.getComponent(dataletParams);
              },
  
              eraseDatalet : function(){
                  this.$.preview.innerHTML = "";
              },
  
              loadInfo : function(selectedDatalet){
                  this._setTabindex(1);
  
                  this.dataletImg = (selectedDatalet.bridge_link + selectedDatalet.component_link).replace("html", "png");
                  this.dataletName = this._getChartName(selectedDatalet.name.replace("-datalet", ""));
                  this.dataletDescription = this._getChartName(selectedDatalet.name.replace("-datalet", "Description"));
  
                  var inputs = selectedDatalet.idm.inputs.input;
                  var options = [];
                  if(selectedDatalet.idm.inputs.layouts)
                      options = selectedDatalet.idm.inputs.layouts.input;
  
                  if(!(inputs instanceof Array))
                      inputs = [inputs];
  
                  if(!(options instanceof Array))
                      options = [options];
  
                  this.inputs = inputs;
                  this.options = options;
  
                  this.$.inputs.innerHTML = ln["inputs_" + ln["localization"]];
                  if(this.options.length > 0)
                      this.$.options.innerHTML = ln["options_" + ln["localization"]];
                  else
                      this.$.options.innerHTML = "";
              },
  
              eraseInfo : function(){
                  this.dataletImg = "";
                  this.dataletName = "";
                  this.dataletDescription = "";
  
                  this.inputs = [];
                  this.options = [];
  
                  this.$.inputs.innerHTML = "";
                  this.$.options.innerHTML = "";
              },
  
              _getChartName: function(key) {
                  return ln[key + "_" +ln["localization"]];
              },
  
  //            _getInputRichName : function(item) {
  //                var name =  ln[item.name + "_" +ln["localization"]];
  //                if(item.type != "TEXT")
  //                    name += " [" + item.type + "]";
  //                if(item.selection == "?")
  //                    name += " [OPT]";
  //                return name;
  //            },
  
              _getInputName : function(name) {
                  return ln[name + "_" +ln["localization"]];
              },
  
              _getInputDescription : function(name) {
                  return ln[name + "Description_" +ln["localization"]];
              },
  
              _setTabindex : function(tabIndex) {
                  this.debounce('_filter', function () {
                      this.tabIndex = -1;
                      this.tabIndex = tabIndex;
                  }, 0);
              },
  
              _getNeonIndex : function(tabIndex){
                  if(tabIndex == -1)
                      return 0;
                  return tabIndex;
              }
  
          });
  
      </script>
  
  </dom-module>