Commit 93ba71679c91deef6cef2d6c339d5d96e48d354d

Authored by Renato De Donato
1 parent e31934c0

filters bug fix + ln

controllets/datalet-selection-controllet/datalet-selection-controllet.html
... ... @@ -219,7 +219,7 @@
219 219  
220 220 <!-- EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE -->
221 221  
222   - <div id="expert_header" on-click="_showExpertMode"><span id="expert">GROUP BY</span></div>
  222 + <div id="expert_header" on-click="_showExpertMode"><span id="groupBy"></span></div>
223 223  
224 224 <div id="expert_container">
225 225  
... ... @@ -541,6 +541,8 @@
541 541 this.$.base_title.label = ln["title_" + ln["localization"]];
542 542 this.$.base_description.label = ln["description_" + ln["localization"]];
543 543  
  544 + this.$.groupBy.innerHTML = ln["groupBy_" + ln["localization"]];
  545 +
544 546 if(this.modify)
545 547 this.$.add_button.innerHTML = ln["modifyDatalet_" + ln["localization"]];
546 548 },
... ...
controllets/filters-controllet/filters-controllet.html
... ... @@ -229,7 +229,9 @@
229 229 _addFilter : function() {
230 230 if (this.$.filter_field.selectedItem && this.$.filter_operation_menu.selectedItem && this.$.filter_value.value != "" && !this.$.filter_value.invalid) {
231 231 var field = this.$.filter_field.value;
232   - var operation = this.$.filter_operation.value;
  232 + var id = this.$.filter_operation.selectedItem.id;
  233 + var operation = this.operations[id];
  234 +// var operation = this.$.filter_operation.value;
233 235 var value = this.$.filter_value.value;
234 236  
235 237 var filters = this.filters;
... ...
controllets/select-data-controllet/demo/index.html
... ... @@ -16,7 +16,8 @@
16 16 <body>
17 17  
18 18 <!--<select-data-controllet id="tvmt" root-name="data" opened-path="records,geometry" preselected-fields='["nhits", "records,datasetid", "records,recordid"]' data-url="http://ckan.routetopa.eu/api/action/datastore_search?resource_id=73e02092-85a1-434e-85fe-0c9a43aa9a52&limit=5"></select-data-controllet>-->
19   - <select-data-controllet id="tvmt" root-name="data" data-url="https://data.issy.com/api/records/1.0/search?dataset=flux-rss-des-offres-demplois-a-issy-les-moulineaux&sort=published&facet=published&refine.published=2015%2F10"></select-data-controllet>
  19 + <!--<select-data-controllet id="tvmt" root-name="data" data-url="https://data.issy.com/api/records/1.0/search?dataset=flux-rss-des-offres-demplois-a-issy-les-moulineaux&sort=published&facet=published&refine.published=2015%2F10"></select-data-controllet>-->
  20 + <select-data-controllet id="tvmt" root-name="data" data-url="https://data.issy.com/api/records/1.0/search/?dataset=repartitiondeladetteparpreteursau3112n-feuille1&rows=56&sort=-annee"></select-data-controllet>
20 21 <!--<select-data-controllet id="tvmt" root-name="data" data-url="http://ckan.routetopa.eu/api/action/datastore_search?resource_id=73e02092-85a1-434e-85fe-0c9a43aa9a52&limit=5"></select-data-controllet>-->
21 22  
22 23 <script>
... ...
controllets/select-visualization-controllet/select-visualization-controllet.html 0 → 100755
  1 +<link rel="import" href="../../bower_components/polymer/polymer.html" />
  2 +
  3 +<link rel="import" href="../../bower_components/paper-material/paper-material.html" />
  4 +
  5 +<link rel="import" href="../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
  6 +<link rel="import" href="../../bower_components/paper-menu/paper-menu.html">
  7 +<link rel="import" href="../../bower_components/paper-item/paper-item.html">
  8 +
  9 +<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">
  10 +<link rel="import" href="../../bower_components/iron-icons/iron-icons.html">
  11 +<link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
  12 +
  13 +<link rel="import" href="../../bower_components/paper-input/paper-textarea.html">
  14 +<link rel="import" href="../../bower_components/paper-input/paper-input.html">
  15 +
  16 +<link rel="import" href="../../bower_components/paper-button/paper-button.html">
  17 +
  18 +<link rel="import" href="../../bower_components/paper-dialog/paper-dialog.html">
  19 +
  20 +<link rel="import" href="../items-vslider-controllet/items-vslider-controllet.html" />
  21 +
  22 +<script src="../../../DEEPCLIENT/js/deepClient.js"></script>
  23 +
  24 +<dom-module id="datalet-selection-controllet">
  25 +
  26 + <template>
  27 +
  28 + <style is="custom-style">
  29 + :host {
  30 + --paper-dropdown-menu-icon: {
  31 + color: #2196F3;
  32 + };
  33 + }
  34 +
  35 + #datalet_selection_container {
  36 + display: flex;
  37 + font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  38 + font-size: 16px;
  39 + margin-top: 8px;
  40 + }
  41 +
  42 + #items_vslider_controllet {
  43 + position: relative;
  44 + min-width: 172px;
  45 + }
  46 +
  47 + #datalet_selection_inputs {
  48 + position: relative;
  49 + height: 100vh;
  50 + margin-left: 32px;
  51 + min-width: 258px;
  52 + }
  53 +
  54 + #datalet_selection_labels {
  55 + position: relative;
  56 + height: 100vh;
  57 + margin-left: 32px;
  58 + min-width: 258px;
  59 + }
  60 +
  61 + #datalet_selection_column {
  62 + position: relative;
  63 + width: 100%;
  64 + margin-left: 32px;
  65 + }
  66 +
  67 + #datalet_selection_datalet {
  68 + position: relative;
  69 + height: 100vh;
  70 + width: 100%;
  71 + }
  72 +
  73 + #datalet_selection_datalet_placeholder {
  74 + padding: 16px;
  75 + }
  76 +
  77 + .inputs{
  78 + position: relative;
  79 + }
  80 +
  81 + .input_header {
  82 + height: 32px;
  83 + padding-top: 16px;
  84 + text-align: center;
  85 + font-weight: 700;
  86 + background-color: #B6B6B6;
  87 + }
  88 +
  89 + #expert_container {
  90 + display: none;
  91 + }
  92 +
  93 + #expert_header {
  94 + display: none;
  95 +
  96 + height: 32px;
  97 + padding-top: 16px;
  98 + margin-top: 8px;
  99 + text-align: center;
  100 + font-weight: 700;
  101 + color: #00BCD4;
  102 + cursor: pointer;
  103 + }
  104 +
  105 + .field_nema {
  106 + height: 40px;
  107 + padding-top: 8px;
  108 +
  109 + margin-top: 8px;
  110 + padding-left: 16px;
  111 + font-weight: 700;
  112 + color: #2196F3;
  113 + background-color: #E0E0E0;
  114 + }
  115 +
  116 + .info_button {
  117 + position: absolute;
  118 + top: 18px;
  119 + right: 0px;
  120 + }
  121 +
  122 + paper-input {
  123 + display: inline-block;
  124 + height: 48px;
  125 + width: 210px;
  126 + padding-left: 8px;
  127 + padding-bottom: 8px;
  128 + --paper-input-container-focus-color: #2196F3;
  129 + }
  130 +
  131 + paper-input.base_input {
  132 + width: 242px;
  133 + }
  134 +
  135 + paper-textarea {
  136 + width: 242px;
  137 + padding-left: 8px;
  138 + padding-bottom: 4px;
  139 + --paper-input-container-focus-color: #2196F3;
  140 + }
  141 +
  142 + paper-dropdown-menu {
  143 + height: 48px;
  144 + width: 210px;;
  145 + padding-left: 8px;
  146 + padding-bottom: 8px;
  147 + --paper-input-container-focus-color: #2196F3;
  148 + }
  149 +
  150 + paper-item.iron-selected {
  151 + background-color: #2196F3;
  152 + color: #FFFFFF;
  153 + }
  154 +
  155 + paper-icon-button {
  156 + color: #2196F3;
  157 + --paper-icon-button-ink-color: #2196F3;
  158 + margin: 0px;
  159 + }
  160 +
  161 + paper-button {
  162 + position: absolute;
  163 + bottom: 16px;
  164 + right: 11px;
  165 +
  166 + height: 48px;
  167 + width: 172px;
  168 + background-color: #00BCD4;
  169 + color: white;
  170 + font-weight: 700;
  171 + padding: 16px;
  172 + }
  173 +
  174 + paper-button:hover {
  175 + background-color: #00AABF;
  176 +
  177 + box-shadow: 0px 8px 12px #888;
  178 + -webkit-box-shadow: 0px 8px 12px #888;
  179 + -moz-box-shadow: 0px 8px 12px #888;
  180 + }
  181 +
  182 + paper-button[disabled] {
  183 + background-color: #B6B6B6;
  184 + }
  185 +
  186 + #dialog_info_input {
  187 + border: 2px solid #2196F3;
  188 + background-color: #E0E0E0;
  189 + min-width: 248px;
  190 + }
  191 + </style>
  192 +
  193 + <iron-ajax id="selectedDatalet_request" on-response="_handleSelectedDatalet"></iron-ajax>
  194 +
  195 + <div id="datalet_selection_container">
  196 +
  197 + <div id="items_vslider_controllet">
  198 + <items-vslider-controllet id="vslider" datalets-list-url={{dataletsListUrl}} preselected-datalet={{preselectedDatalet}}></items-vslider-controllet>
  199 + </div>
  200 +
  201 + <paper-material id="datalet_selection_inputs" elevation="5">
  202 + <div class="input_header"><span id="inputs"></span></div>
  203 + <template is="dom-repeat" items="{{inputs}}" index-as="ddl_index">
  204 + <div class="inputs">
  205 + <paper-dropdown-menu id={{ddl_index}} label={{_getLabelName(item.name)}}>
  206 + <paper-menu class="dropdown-content">
  207 + <template is="dom-repeat" items={{fields}}>
  208 + <paper-item id={{index}} on-tap="_addInput">{{_fieldName(item)}}</paper-item>
  209 + <!--{{_fieldName(item)}}-->
  210 + </template>
  211 + </paper-menu>
  212 + </paper-dropdown-menu>
  213 + <div class="info_button">
  214 + <paper-icon-button id={{item.name}} on-click="_showInfo" icon="info-outline" title="{{_getLabelName(item.name)}} info"></paper-icon-button>
  215 + </div>
  216 + </div>
  217 + </template>
  218 +
  219 + <!-- EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE -->
  220 +
  221 + <div id="expert_header" on-click="_showExpertMode"><span id="expert">ADVANCED: GROUP BY</span></div>
  222 +
  223 + <div id="expert_container">
  224 +
  225 + <div class="inputs">
  226 + <paper-dropdown-menu id="group_by" label="GROUP BY">
  227 + <paper-menu class="dropdown-content">
  228 + <template is="dom-repeat" items={{selectedFields}}>
  229 + <paper-item id={{index}} on-tap="_showGroupedFields">{{_fieldName(item)}}</paper-item>
  230 + </template>
  231 + </paper-menu>
  232 + </paper-dropdown-menu>
  233 + <div class="info_button">
  234 + <paper-icon-button id="gb" on-click="_addOrder" icon="unfold-more" title="unsort"></paper-icon-button>
  235 + </div>
  236 + </div>
  237 +
  238 + <template is="dom-repeat" items="{{groupedFields}}">
  239 + <div class="inputs">
  240 + <paper-dropdown-menu id="calculate_{{index}}" label="CALCULATE">
  241 + <paper-menu class="dropdown-content">
  242 + <paper-item on-tap="_addGroupByInput">COUNT of {{_fieldName(item)}}</paper-item>
  243 + <paper-item on-tap="_addGroupByInput">SUM of {{_fieldName(item)}}</paper-item>
  244 + <paper-item on-tap="_addGroupByInput">MIN of {{_fieldName(item)}}</paper-item>
  245 + <paper-item on-tap="_addGroupByInput">MAX of {{_fieldName(item)}}</paper-item>
  246 + <paper-item on-tap="_addGroupByInput">AVG of {{_fieldName(item)}}</paper-item>
  247 + <paper-item on-tap="_addGroupByInput">FIRST of {{_fieldName(item)}}</paper-item>
  248 + <paper-item on-tap="_addGroupByInput">LAST of {{_fieldName(item)}}</paper-item>
  249 + </paper-menu>
  250 + </paper-dropdown-menu>
  251 + <div class="info_button">
  252 + <paper-icon-button id={{_fieldName(item)}} on-click="_addOrder" icon="unfold-more" title="unsort"></paper-icon-button>
  253 + </div>
  254 + </div>
  255 + </template>
  256 +
  257 + </div>
  258 +
  259 + <!-- EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE EXPERT MODE -->
  260 +
  261 + </paper-material>
  262 +
  263 + <paper-material id="datalet_selection_labels" elevation="5">
  264 + <div class="input_header"><span id="baseInfo"></span></div>
  265 +
  266 + <div class="inputs">
  267 + <paper-input id="base_title" maxlength="32" class="base_input"></paper-input>
  268 + </div>
  269 +
  270 + <div class="inputs">
  271 + <paper-textarea id="base_description" maxlength="100" class="base_input"></paper-textarea>
  272 + </div>
  273 +
  274 + <div class="input_header"><span id="layouts"></span></div>
  275 +
  276 + <template is="dom-repeat" items="{{labels}}" index-as="index">
  277 + <div class="inputs">
  278 + <paper-input label={{_getLabelName(item.name)}}></paper-input>
  279 + <div class="info_button">
  280 + <paper-icon-button id={{item.name}} on-click="_showInfo" icon="info-outline" title="{{_getLabelName(item.name)}} info"></paper-icon-button>
  281 + </div>
  282 + </div>
  283 + </template>
  284 + </paper-material>
  285 +
  286 +
  287 + <div id="datalet_selection_column">
  288 +
  289 + <paper-material id="datalet_selection_datalet" elevation="5">
  290 + <div class="input_header"><span id="dataletPreview"></span></div>
  291 + <div id="datalet_selection_datalet_placeholder"></div>
  292 +
  293 + </paper-material>
  294 +
  295 + <paper-button id="add_button" disabled raised on-click="_addDatalet"></paper-button>
  296 +
  297 + </div>
  298 +
  299 + <paper-dialog id="dialog_info_input">
  300 + <h2 id="dialog_name"></h2>
  301 + <p id="dialog_description"></p>
  302 + </paper-dialog>
  303 +
  304 + </div>
  305 +
  306 + </template>
  307 +
  308 + <script>
  309 +
  310 + Polymer({
  311 +
  312 + is : 'datalet-selection-controllet',
  313 +
  314 + properties : {
  315 +
  316 + deepUrl : {
  317 + type : String,
  318 + value : undefined
  319 + },
  320 +
  321 + dataletsListUrl : {
  322 + type : String,
  323 + value : undefined
  324 + },
  325 +
  326 + selectedDatalet : {
  327 + type : String,
  328 + value : undefined
  329 + },
  330 +
  331 + preselectedDatalet : {
  332 + type : String,
  333 + value : undefined
  334 + },
  335 +
  336 + loadPreview : {
  337 + type : Boolean,
  338 + value : false
  339 + },
  340 +
  341 + type : {
  342 + type : String,
  343 + value : undefined
  344 + },
  345 +
  346 + inputs : {
  347 + type : Array,
  348 + value : []
  349 + },
  350 +
  351 + labels : {
  352 + type : Array,
  353 + value : []
  354 + },
  355 +
  356 + filters : {
  357 + type : Array,
  358 + value : []
  359 + },
  360 +
  361 + aggregators : {
  362 + type : Array,
  363 + value : []
  364 + },
  365 +
  366 + orders : {
  367 + type : Array,
  368 + value : []
  369 + },
  370 +
  371 + fields : {
  372 + type : Array,
  373 + value : []
  374 + },
  375 +
  376 + selectedFields : {
  377 + type : Array,
  378 + value : []
  379 + },
  380 +
  381 + groupedFields : {
  382 + type : Array,
  383 + value : []
  384 + },
  385 +
  386 + dataletPreset : {
  387 + type : Object,
  388 + value : []
  389 + },
  390 +
  391 +// selectableFields : {
  392 +// type : Array,
  393 +// value : []
  394 +// },
  395 +
  396 + dataUrl : {
  397 + type : String,
  398 + value : undefined
  399 + },
  400 +
  401 + params:{
  402 + type: Object,
  403 + value: undefined
  404 + },
  405 +
  406 + expert : {
  407 + type : Boolean,
  408 + value : false
  409 + },
  410 +
  411 + modify : {
  412 + type : Boolean,
  413 + value : false
  414 + }
  415 +
  416 + },
  417 +
  418 + listeners: {
  419 + 'items-vslider-controllet_selected-datalet': '_selectDatalet',
  420 +// 'tree-view-controllet_selected-fields': '_updateSelectedFields'
  421 + 'change': '_paramsChanged'
  422 + },
  423 +
  424 + _showExpertMode : function() {
  425 + if(!this.expert) {
  426 + this.$.expert_header.style.color = "#000000";
  427 + this.$.expert_header.style.background = "#B6B6B6";
  428 + this.$.expert_container.style.display = "block";
  429 + }
  430 + else {
  431 + this.$.expert_header.style.color = "#00BCD4";
  432 + this.$.expert_header.style.background = "#FFFFFF";
  433 + this.$.expert_container.style.display = "none";
  434 + }
  435 +
  436 + this.expert = !this.expert;
  437 + },
  438 +
  439 + _showGroupedFields : function(e) {
  440 + var index = e.target.id;
  441 + var isSelected = false;
  442 + var temp = [];
  443 +
  444 + for (var i = 0; i < this.selectedFields.length; i++) {
  445 + if (this.selectedFields[i]) {
  446 + if (this.selectedFields[i].indexOf(this.fields[index]) > -1) {
  447 + isSelected = true;
  448 + }
  449 + else {
  450 + temp.push(this.selectedFields[i])
  451 + }
  452 + }
  453 + }
  454 +
  455 + if (isSelected)
  456 + this.groupedFields = this._copy(temp);
  457 + else
  458 + this.groupedFields =[];
  459 +
  460 + this.async(function() {
  461 + var ddls = document.getElementsByTagName("paper-dropdown-menu");
  462 + for (var i = 0; i < ddls.length; i++){
  463 + var id = ddls[i].id;
  464 + if(id.indexOf("calculate") > -1) {
  465 + $(ddls[i]).find("paper-menu")[0].select(-1);
  466 + $(ddls[i]).find("paper-menu")[0].select(0);
  467 + }
  468 + }
  469 + }, 0);
  470 +
  471 + this._addGroupByInput();
  472 + },
  473 +
  474 + ready : function() {
  475 + this._resize();
  476 + $(this.$.datalet_selection_inputs).perfectScrollbar();
  477 + $(this.$.datalet_selection_labels).perfectScrollbar();
  478 + $(this.$.datalet_selection_datalet).perfectScrollbar();
  479 +
  480 + this.params = {'data-url' : this.dataUrl};
  481 +
  482 + //this.modify = true;//da eliminare in futuro
  483 + if(this.preselectedDatalet){
  484 + if(this.modify)
  485 + this._preselectDatalet();
  486 +
  487 + this.modify = true;
  488 + this.preselectedDatalet = undefined;
  489 + }
  490 + },
  491 +
  492 + attached : function() {
  493 + this._resize();
  494 + var that = this;
  495 + window.addEventListener("resize", function() { that._resize(); });
  496 +
  497 + this._translate();
  498 + },
  499 +
  500 + setFilters : function(filters) {
  501 + this.filters = filters;
  502 + },
  503 +
  504 + setFields : function(fields) {
  505 + this.fields = fields;
  506 + },
  507 +
  508 + reset : function() {
  509 + this.selectedDatalet = undefined;//non va!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  510 + this.preselectedDatalet = undefined;
  511 + this.type = undefined;
  512 + this.inputs = [];
  513 + this.labels = [];
  514 + this.$.expert_header.style.display = "none";
  515 + this.expert = true;
  516 + this._showExpertMode();
  517 + this.loadPreview = false;
  518 + this.$.datalet_selection_datalet_placeholder.innerHTML = "";
  519 + this._resetGroupBy();
  520 + },
  521 +
  522 + _translate : function(){
  523 +
  524 + this.$.add_button.innerHTML = ln["addDatalet_" + ln["localization"]];
  525 + this.$.inputs.innerHTML = ln["inputs_" + ln["localization"]];
  526 + this.$.baseInfo.innerHTML = ln["baseInfo_" + ln["localization"]];
  527 + this.$.layouts.innerHTML = ln["layouts_" + ln["localization"]];
  528 + this.$.dataletPreview.innerHTML = ln["dataletPreview_" + ln["localization"]];
  529 +
  530 + this.$.base_title.label = ln["title_" + ln["localization"]];
  531 + this.$.base_description.label = ln["description_" + ln["localization"]];
  532 +
  533 + if(this.modify)
  534 + this.$.add_button.innerHTML = ln["modifyDatalet_" + ln["localization"]];
  535 + },
  536 +
  537 + _selectDatalet : function(e){
  538 + this.$.add_button.setAttribute("disabled", "true");
  539 +
  540 + this.selectedDatalet = e.detail.datalet;
  541 +
  542 + this.$.datalet_selection_datalet_placeholder.innerHTML = "";
  543 +
  544 + if(!this.selectedDatalet){
  545 + this.type = undefined;
  546 + this.inputs = [];
  547 + this.labels = [];
  548 + this.$.expert_header.style.display = "none";
  549 + this.expert = true;
  550 + this._showExpertMode();
  551 + this.loadPreview = false;
  552 + }
  553 + else{
  554 + this.$.selectedDatalet_request.url = this.deepUrl + e.detail.datalet + "-datalet";
  555 + this.$.selectedDatalet_request.generateRequest();
  556 + this.$.expert_header.style.display = "block";
  557 + }
  558 + },
  559 +
  560 + _preselectDatalet : function() {
  561 + this.type = "undefined";
  562 + this.$.selectedDatalet_request.url = this.deepUrl + this.preselectedDatalet + "-datalet";
  563 + this.$.selectedDatalet_request.generateRequest();
  564 +
  565 + this.selectedDatalet = this.preselectedDatalet;
  566 + this.selectedFields = this._copy(this.fields);
  567 +
  568 + this.async(function() {
  569 + this.selectedFields = this._copy(this.fields);
  570 +
  571 + var inputs = document.getElementsByTagName("paper-dropdown-menu");
  572 + for (var i = 0; i < inputs.length; i++)
  573 + $(inputs[i]).find("paper-menu")[0].select(i);
  574 +
  575 + //set info labels options
  576 + var labels = this.$.datalet_selection_labels.querySelectorAll("paper-textarea");
  577 + for (var i = 0; i < labels.length; i++)
  578 + labels[i].value = this.dataletPreset[labels[i].label];
  579 +
  580 + var labels = this.$.datalet_selection_labels.querySelectorAll("paper-input");
  581 + for (var i = 0; i < labels.length; i++)
  582 + labels[i].value = this.dataletPreset[labels[i].label];
  583 +
  584 + this.loadPreview = true;
  585 + this._loadDatalet(this.selectedFields);
  586 + }, 300);
  587 + },
  588 +
  589 + _handleSelectedDatalet : function(e){
  590 +
  591 + if(this.type != e.detail.response.type) {
  592 +
  593 + this.inputs = [];
  594 + this.labels = [];
  595 +
  596 + var inputs = this._copy(e.detail.response.idm.inputs.input);
  597 +
  598 + if (inputs.constructor == Object) {//not Array && inputs.input.selection == "*"
  599 + var name = inputs.name;
  600 + var description = inputs.description;
  601 + var selection = inputs.selection;
  602 + inputs = [];
  603 + for (var i in this.fields)
  604 + inputs.push({name: name + " " + i, description: description, selection: selection});
  605 + }
  606 +
  607 + /**/
  608 + var computedInputs = [];
  609 + computedInputs.push(inputs[0]);
  610 +
  611 + for(var i = 0; i < inputs.length; i++) {
  612 + var input = inputs[i];
  613 + if(input.selection == "*") {
  614 + var name = input.name;
  615 + var description = input.description;
  616 + var selection = input.selection;
  617 + for(var j = 0; j < (this.fields.length - inputs.length +1); j++)
  618 + computedInputs.push({name: name + " " + j, description: description, selection: selection});
  619 + }
  620 + }
  621 +
  622 + if(computedInputs.length > inputs.length)
  623 + inputs = computedInputs;
  624 + /**/
  625 +
  626 + this.async(function(){
  627 + this.type = e.detail.response.type;
  628 + this.inputs = inputs;
  629 + this.labels = e.detail.response.idm.inputs.layouts.input;
  630 +
  631 + this.selectedFields = new Array(inputs.length);
  632 + },0);
  633 +
  634 + this._resetGroupBy();
  635 +
  636 + this.loadPreview = false;
  637 + }
  638 +
  639 + else if (this.loadPreview)
  640 + this._loadDatalet(this.selectedFields);
  641 + },
  642 +
  643 + _resetGroupBy : function(){
  644 + $(this.$.group_by).find("paper-menu")[0].select(-1);
  645 + this.groupedFields = [];
  646 + this.aggregators = [];
  647 + },
  648 +
  649 + _addGroupByInput : function(){
  650 + this.async(function() {//codice reprlicato!
  651 + var selectedFields = this.selectedFields;
  652 +
  653 + var load = true;
  654 +
  655 + if(this.inputs[0].selection == "*"){
  656 + var temp = [];
  657 + for (var i = 0; i < selectedFields.length; i++)
  658 + if(selectedFields[i])
  659 + temp.push(selectedFields[i]);
  660 + selectedFields = temp;
  661 + }
  662 + else {
  663 + for (var i = 0; i < selectedFields.length; i++)
  664 + if (!selectedFields[i]) {
  665 + load = false;
  666 + break;
  667 + }
  668 + }
  669 +
  670 + if(load){
  671 + this.loadPreview = true;
  672 + this._loadDatalet(selectedFields);
  673 + }
  674 + }, 0);
  675 + },
  676 +
  677 + _addOrder : function(e){
  678 + var t = e.target;
  679 + if(t.tagName.indexOf("IRON-ICON") > -1)
  680 + t = $(e.target).parents("paper-icon-button")[0];
  681 +
  682 + var icon = t.getAttribute("icon");
  683 + var name = t.getAttribute("id");
  684 +
  685 + if(name.indexOf("gb") > -1){
  686 + var selectedItem = $(this.$.group_by).find("paper-menu")[0].selectedItem;
  687 + if(selectedItem)
  688 + name = selectedItem.textContent.trim();
  689 +// name = "[" + selectedItem.textContent.trim() + "]";
  690 + else
  691 + return;
  692 + }// else {
  693 +// var i = name;
  694 +// var ddl = $("#calculate_"+i);
  695 +//
  696 +// var label = $(ddl).find("paper-menu")[0].selectedItem.textContent.trim();
  697 +// var index = label.split(" ", 2).join(" ").length;
  698 +// var field = label.substring(index+1, label.length);
  699 +// var operation = label.substring(0, label.indexOf(" "));
  700 +// name = operation + "([" + field + "])";
  701 +// }
  702 +
  703 + if(icon.indexOf("unfold-more") > -1){
  704 + t.setAttribute("icon", "expand-less");
  705 + t.setAttribute("title", "sort ascending");
  706 + var orders = this.orders.filter(function (el) { return el.field !== name; });
  707 + orders.push({"field": name, "operation": "ASC"});
  708 + this.orders = this._copy(orders);
  709 + }
  710 + else if(icon.indexOf("expand-less") > -1){
  711 + t.setAttribute("icon", "expand-more");
  712 + t.setAttribute("title", "sort descending");
  713 + var orders = this.orders.filter(function (el) { return el.field !== name; });
  714 + orders.push({"field": name, "operation": "DESC"});
  715 + this.orders = this._copy(orders);
  716 + }
  717 + else if(icon.indexOf("expand-more") > -1){
  718 + t.setAttribute("icon", "unfold-more");
  719 + t.setAttribute("title", "unsort");
  720 + var orders = this.orders.filter(function (el) { return el.field !== name; });
  721 + this.orders = this._copy(orders);
  722 + }
  723 +
  724 + this._addGroupByInput();//no buoono
  725 +// if(load){
  726 +// this.loadPreview = true;
  727 +// this._loadDatalet(selectedFields);
  728 +// }
  729 + },
  730 +
  731 + _addInput : function(e){
  732 + var selectedFields = this._copy(this.selectedFields);
  733 +
  734 +// var index = $(e.target).parents("paper-dropdown-menu")[0].id;
  735 +// selectedFields[index] = e.target.innerHTML.trim();
  736 +
  737 + var ddl_index = $(e.target).parents("paper-dropdown-menu")[0].id;
  738 + var index = e.target.id;
  739 + selectedFields[ddl_index] = this.fields[index];
  740 +
  741 + this.selectedFields = this._copy(selectedFields);
  742 +
  743 + var load = true;
  744 +
  745 + if(this.inputs[0].selection == "*"){
  746 + var temp = [];
  747 + for (var i = 0; i < selectedFields.length; i++)
  748 + if(selectedFields[i])
  749 + temp.push(selectedFields[i]);
  750 + selectedFields = temp;
  751 + }
  752 + else {
  753 + for (var i = 0; i < selectedFields.length; i++)
  754 + if (!selectedFields[i]) {
  755 + load = false;
  756 + break;
  757 + }
  758 + }
  759 +
  760 + this._resetGroupBy();//--> conflitto, in _updateparams valorizza this.aggregators
  761 +
  762 + if(load){
  763 + this.loadPreview = true;
  764 + this._loadDatalet(selectedFields);
  765 + }
  766 + },
  767 +
  768 + _updateParams : function(){
  769 + var textarea = this.$.datalet_selection_labels.querySelectorAll("paper-textarea");
  770 + this.params["description"] = textarea[0].value;
  771 +
  772 + if(!textarea[0].value)
  773 + this.params[textarea[0].label] = "";
  774 +
  775 + var inputs = this.$.datalet_selection_labels.querySelectorAll("paper-input");
  776 + this.params["title"] = inputs[0].value;
  777 +
  778 + for (var i = 1; i < inputs.length; i++)
  779 + this.params[this.labels[i-1].name] = inputs[i].value;
  780 +
  781 + this.aggregators = [];
  782 +
  783 + var ddls = document.getElementsByTagName("paper-dropdown-menu");
  784 + for (var i = 0; i < ddls.length; i++){
  785 + var id = ddls[i].id;
  786 + if(id.indexOf("group_by") > -1 && $(ddls[i]).find("paper-menu")[0].selectedItem) {
  787 + var label = $(ddls[i]).find("paper-menu")[0].selectedItem.textContent.trim();
  788 + this.aggregators.push({"field": label, "operation": "GROUP BY"});
  789 + }
  790 + if(id.indexOf("calculate") > -1) {
  791 + var label = $(ddls[i]).find("paper-menu")[0].selectedItem.textContent.trim();
  792 +// var field = label.substring(label.lastIndexOf(" ")+1, label.length);
  793 + var index = label.split(" ", 2).join(" ").length;
  794 + var field = label.substring(index+1, label.length);
  795 + var operation = label.substring(0, label.indexOf(" "));
  796 + this.aggregators.push({"field": field, "operation": operation});
  797 + }
  798 + }
  799 + },
  800 +
  801 + _paramsChanged : function(){
  802 +
  803 + this._updateParams();
  804 +
  805 + if(this.$.datalet_selection_datalet_placeholder.children[1])
  806 + this.$.datalet_selection_datalet_placeholder.children[1].behavior.setParameters(this.params);
  807 + },
  808 +
  809 + _loadDatalet : function(selectedFields){
  810 +
  811 + this._updateParams();
  812 +
  813 + this.params["filters"] = JSON.stringify(this.filters);
  814 + this.params["aggregators"] = JSON.stringify(this.aggregators);
  815 + this.params["orders"] = JSON.stringify(this.orders);
  816 +
  817 +// this.params["filters"] = '[{"field": "Lat", "operation": ">=", "value": "53.298164"}, {"field": "Lat", "operation": "<", "value": "54"}]';
  818 +// this.params["aggregators"] = '[{"field": "Lat", "operation": "GROUP BY"}, {"field": "Lng", "operation": "COUNT"}]';
  819 +// this.params["orders"] = '[{"field": "Lat", "operation": "DESC"}, {"field": "Lat", "operation": "ASC"}]';
  820 +
  821 + //this.params["aggregators"] = '[{"field": "Value", "operation": "GROUP BY"}, {"field": "LOCATION", "operation": "COUNT"}]';
  822 + //this.params["orders"] = '[{"field": "Value", "operation": "ASC"}, {"field": "Value", "operation": "ASC"}]';
  823 +
  824 + var dataletParams ={
  825 + component : this.selectedDatalet+"-datalet",
  826 + params : this.params,
  827 + fields : selectedFields,
  828 + placeHolder : this.$.datalet_selection_datalet_placeholder
  829 + };
  830 +
  831 + ComponentService.deep_url = this.deepUrl;
  832 + ComponentService.getComponent(dataletParams);
  833 +
  834 + this.$.add_button.removeAttribute("disabled");
  835 + },
  836 +
  837 + _addDatalet : function(){
  838 +
  839 + this._updateParams();
  840 +
  841 + var selectedFields = [];
  842 + for (var i = 0; i < this.selectedFields.length; i++)
  843 + if(this.selectedFields[i])
  844 + selectedFields.push(this.selectedFields[i]);
  845 +
  846 + var data = {
  847 + dataUrl : this.dataUrl,
  848 + params : this.params,
  849 + fields : selectedFields,
  850 + datalet : this.selectedDatalet+"-datalet",
  851 +// comment : "",//DEPRECATED!!!
  852 + staticData : JSON.stringify(this.$.datalet_selection_datalet_placeholder.children[1].behavior.data)
  853 + }
  854 +
  855 + this.fire('data-sevc-controllet.dataletCreated', {data : data});
  856 +
  857 + },
  858 +
  859 + _showInfo : function(e){
  860 +// var that = this;
  861 + var t = e.target;
  862 + if(t.tagName.indexOf("IRON-ICON") != -1)
  863 + t = $(e.target).parents("paper-icon-button")[0];
  864 +
  865 +// var name = t.getAttribute("title").replace(" info", "");
  866 + var name = t.getAttribute("id");
  867 +
  868 + var dataset = $.grep(this.inputs, function(e){ return e.name == name; })[0];
  869 + if(!dataset)
  870 + dataset = $.grep(this.labels, function(e){ return e.name == name; })[0];
  871 +
  872 + this.$.dialog_name.innerHTML = this._getLabelName(dataset.name);
  873 + this.$.dialog_description.innerHTML = ln[dataset.description + "_" + ln["localization"]];
  874 + this.$.dialog_info_input.open();
  875 +
  876 + var pos = t.getBoundingClientRect();
  877 + $("#dialog_info_input").css("top", pos.top - 4);
  878 + $("#dialog_info_input").css("left", pos.left - 4);
  879 + },
  880 +
  881 + _fieldName : function(field) {
  882 + if(!field)//when?
  883 + return "";
  884 + return field.substring(field.lastIndexOf(",")+1, field.length);
  885 + },
  886 +
  887 + _copy : function(o) {
  888 + var out, v, key;
  889 + out = Array.isArray(o) ? new Array(o.length) : {};
  890 + for (key in o) {
  891 + v = o[key];
  892 + out[key] = (typeof v === "object") ? this._copy(v) : v;
  893 + }
  894 + return out;
  895 + },
  896 +
  897 + _getLabelName: function(key) {
  898 + //* exceptions
  899 + if(key.indexOf("Cell") > -1) {
  900 + return ln["Cell" + "_" +ln["localization"]] + key.slice(-2);
  901 + }
  902 + if(key.indexOf("Level") > -1) {
  903 + return ln["Level" + "_" +ln["localization"]] + key.slice(-2);
  904 + }
  905 + if(key.indexOf("Category") > -1) {
  906 + return ln["Category" + "_" +ln["localization"]] + key.slice(-2);
  907 + }
  908 +
  909 + return ln[key + "_" +ln["localization"]];
  910 + },
  911 +
  912 + _resize : function(){
  913 + var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16;
  914 + h = h - 64 - 8; //height with page scroller
  915 +
  916 + $("#items_vslider_container").height(h);//vslider controllet
  917 +
  918 + $("#datalet_selection_inputs").height(h);
  919 + $("#datalet_selection_labels").height(h);
  920 +// if(this.modify)
  921 +// $("#datalet_selection_datalet").height(h-128);
  922 +// else
  923 + $("#datalet_selection_datalet").height(h);
  924 + }
  925 +
  926 + });
  927 +
  928 + </script>
  929 +
  930 +</dom-module>
0 931 \ No newline at end of file
... ...
datalets/base-ajax-json-alasql-datalet/static/js/AjaxJsonAlasqlBehavior.js
... ... @@ -117,7 +117,7 @@ var AjaxJsonAlasqlBehavior = {
117 117 else if(filters[i]["operation"] == "ends")
118 118 where += filters[i]["field"] + " like '%" + filters[i]["value"] + "' AND ";
119 119 else
120   - where += filters[i]["field"] + " " + filters[i]["operation"] + " " + filters[i]["value"] + " AND ";
  120 + where += filters[i]["field"] + " " + filters[i]["operation"] + " '" + filters[i]["value"] + "' AND ";
121 121 }
122 122 where = where.slice(0, -5);
123 123 }
... ...
locales/controllet_ln.js
... ... @@ -38,7 +38,8 @@ ln[&quot;ends_en&quot;] = &quot;ends with&quot;;
38 38 ln["sortAscending_en"] = "sorted ascending";
39 39 ln["sortDescending_en"] = "sorted descending";
40 40 ln["unsort_en"] = "unsorted";
41   -ln["countOf_en"] = "COUNT of";
  41 +//ln["countOf_en"] = "COUNT of";
  42 +ln["groupBy_en"] = "GROUP BY";
42 43  
43 44 ln["datatable_it"] = "tabella";
44 45 ln["barchart_it"] = "bar-chart";
... ...