Commit 474d4e8f61ffc701ed7ceda24835f1477578a5b5

Authored by Andrea Petta
1 parent 68ee970d

cache dataset explorer

datalets/base-ajax-json-jsonpath-datalet/static/js/AjaxJsonJsonPathBehavior.js
... ... @@ -56,9 +56,72 @@ var AjaxJsonJsonPathBehavior = {
56 56  
57 57 var comp = this;
58 58  
  59 + /*if(typeof(Worker) !== "undefined") {
  60 +
  61 + var myWorker = function() {
  62 +
  63 + self.onmessage = function(event)
  64 + {
  65 + console.log(event.data);
  66 +
  67 + var xmlhttp;
  68 +
  69 + if ( XMLHttpRequest) {
  70 + // code for IE7+, Firefox, Chrome, Opera, Safari
  71 + xmlhttp = new XMLHttpRequest();
  72 + } else {
  73 + // code for IE6, IE5
  74 + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  75 + }
  76 +
  77 + xmlhttp.onreadystatechange = function() {
  78 + if (xmlhttp.readyState == XMLHttpRequest.DONE ) {
  79 + if(xmlhttp.status == 200){
  80 + //console.log(xmlhttp.responseText);
  81 + self.postMessage(xmlhttp.responseText);
  82 + }
  83 + else if(xmlhttp.status == 400) {
  84 + console.log('There was an error 400')
  85 + }
  86 + else {
  87 + console.log('something else other than 200 was returned')
  88 + }
  89 + }
  90 + }
  91 +
  92 + //xmlhttp.open("GET", event.data, true);
  93 + xmlhttp.open("GET", "http://172.16.15.77/openwall/api/datasetTree", true);
  94 + xmlhttp.send();
  95 + }
  96 + };
  97 +
  98 + var workerData = new Blob(['(' + myWorker.toString() + ')()'], {
  99 + type: "text/javascript"
  100 + });
  101 +
  102 + myWorker = new Worker(window.URL.createObjectURL(workerData));
  103 + myWorker.postMessage(this._component.dataUrl);
  104 + myWorker.onmessage = function (e) {
  105 + console.log(e);
  106 + comp.handleResponse(JSON.parse(e.data));
  107 + };
  108 +
  109 + } else {
  110 + $.ajax({
  111 + url: this._component.dataUrl,
  112 + dataType: "json",
  113 + async : true,
  114 + success: function(e){
  115 + comp.handleResponse(e);
  116 + }
  117 + });
  118 + }*/
  119 +
59 120 $.ajax({
60 121 url: this._component.dataUrl,
61 122 dataType: "json",
  123 + async : true,
  124 + cache : false,
62 125 success: function(e){
63 126 comp.handleResponse(e);
64 127 }
... ...
datalets/base-datalet/static/js/WorkcycleBehavior.js
... ... @@ -103,6 +103,7 @@ var WorkcycleBehavior = {
103 103 }else{
104 104 this._deleteWaitImage();
105 105 this.data = JSON.parse(this._component.data);
  106 + this.filterData();
106 107 this.transformData();
107 108 this.presentData();
108 109 }
... ...
datalets/datasetexplorer-datalet/datasetexplorer-datalet.html
... ... @@ -203,8 +203,13 @@ Example:
203 203 this._component.fire("datasetexplorer-datalet_data-url", { url: url });
204 204 },
205 205  
206   - selectData : function() {
207   - this.data = [];
  206 + filterData : function() {
  207 +
  208 + var tmpData = [];
  209 +
  210 + if(!this.properties.json_results.value.result)
  211 + this.properties.json_results.value = this.data;
  212 +
208 213 this.meta = this.properties.json_results.value.result.providers;
209 214  
210 215 //Deal the fields with "'" char
... ... @@ -221,11 +226,13 @@ Example:
221 226 query += "[*]";
222 227 }
223 228 }
224   - this.data.push({
  229 +
  230 + tmpData.push({
225 231 name: query_elements[query_elements.length - 1],
226 232 data: jsonPath(this.properties.json_results.value, query)
227 233 });
228 234 }
  235 + this.data = tmpData;
229 236 this._deleteWaitImage();
230 237 }
231 238  
... ...