Commit a748d9bc93e53753a17026b105be34dd77071664

Authored by Renato De Donato
1 parent 0dafdf4f

ala NUMBER bug

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