Commit 6a6f2dd440334822d77e8caf516f2dc635f39465
Merge branch 'master' of http://service.routetopa.eu:7480/WebCompDev/COMPONENTS
Showing
1 changed file
with
59 additions
and
45 deletions
datalets/base-datalet/base-datalet.html
... | ... | @@ -348,16 +348,75 @@ Example : |
348 | 348 | }, |
349 | 349 | |
350 | 350 | exportRTF: function () { |
351 | + | |
352 | + var t = this; | |
351 | 353 | var parent = this.parentElement; |
352 | 354 | while(!parent.hasAttribute("data-url")) |
353 | 355 | parent = parent.parentElement; |
354 | 356 | |
357 | + var post_id = parent.parentElement.id.match(/\d+/); post_id = post_id ? post_id[0] : ""; | |
358 | + var datalet_id = $(parent).parents().eq(3).attr("datalet-id") ? $(parent).parents().eq(3).attr("datalet-id") : ""; | |
359 | + var isPublicRoom = (typeof SPODPUBLICROOM != 'undefined') ? true : false; | |
355 | 360 | |
356 | 361 | var svg = $(parent).find(".highcharts-container"); |
357 | 362 | svg = $(svg[0]).html(); |
358 | 363 | |
359 | 364 | var xhr = new XMLHttpRequest(); |
360 | 365 | |
366 | + $.ajax({ | |
367 | + url: ODE.get_datalet_info, | |
368 | + data: {"post_id" : post_id, "datalet_id" : datalet_id, "is_public_room" : isPublicRoom}, | |
369 | + dataType: "json", | |
370 | + success: function(e){ | |
371 | + xhr.open('POST', 'http://172.16.15.77/DEEalerProvider/DEEP/export/export-datalet-as-rtf', true); | |
372 | + //xhr.open('POST', 'http://stage.routetopa.eu/deep/DEEP/export/export-datalet-as-rtf', true); | |
373 | + //xhr.open('POST', 'http://deep.routetopa.eu/deep_1_5/DEEP/export/export-datalet-as-rtf', true); | |
374 | + xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | |
375 | + | |
376 | + var post = 'svg_data=' + window.encodeURIComponent(svg) + '&datalet=' + parent.is + '&dataset=' + t.$.base_datalet_link.getAttribute("href"); | |
377 | + post += '&user=' + e.user + '×tamp=' + e.timestamp + '&comment=' + (e.comment ? e.comment : ""); | |
378 | + | |
379 | + xhr.responseType = 'blob'; | |
380 | + | |
381 | + //OpenDataSoft check | |
382 | + if(t.dataUrl.indexOf("/records/") > -1) | |
383 | + { | |
384 | + var urlSource = t.dataUrl.split("/")[0] + "//" + t.dataUrl.split("/")[2]; | |
385 | + | |
386 | + var i; | |
387 | + if(t.dataUrl.indexOf("&") > -1) | |
388 | + i = t.dataUrl.indexOf("&"); | |
389 | + else | |
390 | + i = t.dataUrl.length; | |
391 | + | |
392 | + $.ajax({ | |
393 | + url: urlSource + "/api/dataset/1.0/" + t.dataUrl.substring(t.dataUrl.indexOf("=")+1, i), | |
394 | + dataType: "json", | |
395 | + success: function(e){ | |
396 | + post += '&name=' + e.metas.title + '&description=' + e.metas.description + '&created=' + e.metas.data_processed + '&lastModified=' + e.metas.modified; | |
397 | + xhr.send(post); | |
398 | + } | |
399 | + }); | |
400 | + } | |
401 | + else if(t.dataUrl.indexOf("datastore_search?resource_id") > -1 ) | |
402 | + { | |
403 | + $.ajax({ | |
404 | + url: t.dataUrl.replace("datastore_search?resource_id", "resource_show?id"), | |
405 | + dataType: "json", | |
406 | + success: function(e){ | |
407 | + post += '&name=' + e.result.name + '&description=' + e.result.description + '&created=' + e.result.created + '&format=' + e.result.format + '&lastModified=' + e.result.last_modified; | |
408 | + xhr.send(post); | |
409 | + } | |
410 | + }); | |
411 | + } | |
412 | + else | |
413 | + { | |
414 | + xhr.send(post); | |
415 | + } | |
416 | + | |
417 | + } | |
418 | + }); | |
419 | + | |
361 | 420 | xhr.onreadystatechange = function(){ |
362 | 421 | if (this.readyState == 4 && this.status == 200){ |
363 | 422 | var blob = new Blob([this.response], {type:'octet/stream'}); |
... | ... | @@ -370,51 +429,6 @@ Example : |
370 | 429 | //window.URL.revokeObjectURL(downloadUrl); |
371 | 430 | } |
372 | 431 | }; |
373 | - | |
374 | - //xhr.open('POST', 'http://172.16.15.77/DEEalerProvider/DEEP/export/export-datalet-as-rtf', true); | |
375 | - //xhr.open('POST', 'http://stage.routetopa.eu/deep/DEEP/export/export-datalet-as-rtf', true); | |
376 | - xhr.open('POST', 'http://deep.routetopa.eu/deep_1_5/DEEP/export/export-datalet-as-rtf', true); | |
377 | - xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | |
378 | - | |
379 | - var post = 'svg_data=' + window.encodeURIComponent(svg) + '&datalet=' + parent.is + '&dataset=' + this.$.base_datalet_link.getAttribute("href"); | |
380 | - xhr.responseType = 'blob'; | |
381 | - | |
382 | - //OpenDataSoft check | |
383 | - if(this.dataUrl.indexOf("/records/") > -1 ) | |
384 | - { | |
385 | - var urlSource = this.dataUrl.split("/")[0] + "//" + this.dataUrl.split("/")[2]; | |
386 | - | |
387 | - var i; | |
388 | - if(this.dataUrl.indexOf("&") > -1) | |
389 | - i = this.dataUrl.indexOf("&"); | |
390 | - else | |
391 | - i = this.dataUrl.length; | |
392 | - | |
393 | - $.ajax({ | |
394 | - url: urlSource + "/api/dataset/1.0/" + this.dataUrl.substring(this.dataUrl.indexOf("=")+1, i), | |
395 | - dataType: "json", | |
396 | - success: function(e){ | |
397 | - post += '&name=' + e.metas.title + '&description=' + e.metas.description + '&created=' + e.metas.data_processed + '&lastModified=' + e.metas.modified; | |
398 | - xhr.send(post); | |
399 | - } | |
400 | - }); | |
401 | - } | |
402 | - else if(this.dataUrl.indexOf("datastore_search?resource_id") > -1 ) | |
403 | - { | |
404 | - $.ajax({ | |
405 | - url: this.dataUrl.replace("datastore_search?resource_id", "resource_show?id"), | |
406 | - dataType: "json", | |
407 | - success: function(e){ | |
408 | - post += '&name=' + e.result.name + '&description=' + e.result.description + '&created=' + e.result.created + '&format=' + e.result.format + '&lastModified=' + e.result.last_modified; | |
409 | - xhr.send(post); | |
410 | - } | |
411 | - }); | |
412 | - } | |
413 | - else | |
414 | - { | |
415 | - xhr.send(post); | |
416 | - } | |
417 | - | |
418 | 432 | }, |
419 | 433 | |
420 | 434 | importToMySpace: function() { | ... | ... |