Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. <script>
  2. // Get data like panel table (get your data from the query editor)
  3. var requestData = {
  4. "url": "api/datasources/proxy/1/query",
  5. "data": {
  6. "timezone": "browser",
  7. "panelId": 10,
  8. "dashboardId": 5,
  9. "range": {
  10. "from": 1538697600000,
  11. "to": 1553507193501,
  12. "raw": {
  13. "from": "2018-10-05T00:00:00.000Z",
  14. "to": "now"
  15. }
  16. },
  17. "rangeRaw": {
  18. "from": "2018-10-05T00:00:00.000Z",
  19. "to": "now"
  20. },
  21. "interval": "1d",
  22. "intervalMs": 86400000,
  23. "targets": [
  24. {
  25. "refId": "A",
  26. "type": "timeserie",
  27. "measurement": "data",
  28. "field": {
  29. "name": "PYCycComp_NDOO_Cycle02",
  30. "tag": null
  31. }
  32. },
  33. {
  34. "refId": "B",
  35. "type": "timeserie",
  36. "measurement": "data",
  37. "field": {
  38. "name": "Sup1_Par1_WAIT_Norm_OV",
  39. "tag": null
  40. }
  41. }
  42. ],
  43. "maxDataPoints": 80,
  44. "scopedVars": {
  45. "__interval": {
  46. "text": "1d",
  47. "value": "1d"
  48. },
  49. "__interval_ms": {
  50. "text": 86400000,
  51. "value": 86400000
  52. }
  53. },
  54. "adhocFilters": [],
  55. "source": "processdb_5",
  56. "orgId": 1,
  57. "conversionOptions": {}
  58. }
  59. }
  60. requestData.url = window.location.origin + '/' + requestData.url;
  61. var url_string = window.location.href;
  62. var url = new URL(url_string);
  63. requestData.data.orgId = url.searchParams.get("orgId");
  64. // requestData.data.source = processdb_X; // In case you need to change it
  65. refreshGeoMap();
  66.  
  67. angular.element('grafana-app').injector().get('timeSrv').$rootScope.$on('refresh', function(event, data) { refreshGeoMap(); });
  68. function refreshGeoMap( )
  69. {
  70. var timeRange = angular.element('grafana-app').injector().get('timeSrv').timeRange();
  71. requestData.data.range = {from: timeRange.from.valueOf(), to: timeRange.to.valueOf()};
  72. console.log(requestData.data.range);
  73. requestData.data.rangeRaw = requestData.data.range.raw;
  74. }
  75. console.log(requestData);
  76. $.ajax({
  77. method: "POST",
  78. url: requestData.url,
  79. data: JSON.stringify(requestData.data),
  80. dataType: "json",
  81. contentType: "application/json",
  82. success: function(res){
  83. console.log(res);
  84. }
  85. });
  86. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement