Commit fb1e71b5984cc5dc2038d9b89744feb636c1a5d1

Authored by Andrea Petta
1 parent 209594a3

plugin update

datalets/base-datalet/base-datalet.html
... ... @@ -165,9 +165,9 @@ Example :
165 165 <div class="export" on-click="showHideExportMenu"></div>
166 166 <div class="highcharts-contextmenu" id="highcharts-contextmenu">
167 167 <div class="highcharts-contextmenu-container">
168   - <div id="export_html" on-click="exportToHTML">Export to HTML</div>
169   - <div id="export_png" on-click="exportToIMG">Export to PNG</div>
170   - <div id="export_rtf">Export to RTF</div>
  168 + <div id="export_html" on-click="exportToHTML">Export to HTML</div>
  169 + <div id="export_png" on-click="exportToIMG">Export to PNG</div>
  170 + <div id="export_rtf" on-click="exportRTF">Export to RTF</div>
171 171 <div id="export_my_space" on-click="importToMySpace">Import in My Space</div>
172 172 </div>
173 173 </div>
... ... @@ -337,6 +337,39 @@ Example :
337 337 xhr.send(post);
338 338 },
339 339  
  340 + exportRTF: function () {
  341 + var parent = this.parentElement;
  342 + while(!parent.hasAttribute("data-url"))
  343 + parent = parent.parentElement;
  344 +
  345 +
  346 + var svg = $(parent.is + " .highcharts-container");
  347 + svg = $(svg[0]).html();
  348 +
  349 + var xhr = new XMLHttpRequest();
  350 +
  351 + xhr.onreadystatechange = function(){
  352 + if (this.readyState == 4 && this.status == 200){
  353 + var blob = new Blob([this.response], {type:'octet/stream'});
  354 + var downloadUrl = window.URL.createObjectURL(blob);
  355 + var a = document.createElement("a");
  356 + a.href = downloadUrl;
  357 + a.download = "datalet.rtf";
  358 + document.body.appendChild(a);
  359 + a.click();
  360 + //window.URL.revokeObjectURL(downloadUrl);
  361 + }
  362 + };
  363 +
  364 + //xhr.open('POST', 'http://172.16.15.77/DEEalerProvider/DEEP/export/export-datalet-as-rtf', true);
  365 + xhr.open('POST', 'http://stage.routetopa.eu/deep/DEEP/export/export-datalet-as-rtf', true);
  366 + xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  367 +
  368 + var post = 'svg_data=' + window.encodeURIComponent(svg) + '&datalet=' + parent.is + '&dataset=' + this.$.base_datalet_link.getAttribute("href");
  369 + xhr.responseType = 'blob';
  370 + xhr.send(post);
  371 + },
  372 +
340 373 importToMySpace: function() {
341 374 var parent = this.parentElement;
342 375 var html = '';
... ...