Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.30 KB | None | 0 0
  1. 'use strict';
  2.  
  3. const ij = angular.element(document).injector();
  4. const Customization = ij.get('Customization');
  5. const customDashboards = ij.get('customDashboards');
  6.  
  7. const visualisationContainerSrc = 'https://rawgit.com/jean-moldovan/08844b90524ec5bd9db78b76bf02f245/raw/39df263535aae431fd320f1d76e65898a5352eb7/vs.js';
  8.  
  9. const dashboard = {
  10. "sections" : [
  11. {
  12. "type" : "grid",
  13. "widgets" : [
  14. {
  15. "name" : "vs-container",
  16. "src" : visualisationContainerSrc,
  17. "config" : {
  18. "position" : {
  19. "value" : {
  20. "sizeX" : 1,
  21. "col" : 2,
  22. "row" : 3
  23. }
  24. },
  25. "type" : {
  26. "values" : [
  27. {
  28. "display" : "Line Chart",
  29. "value" : "line"
  30. },
  31. {
  32. "display" : "Bar Chart",
  33. "value" : "bar"
  34. },
  35. {
  36. "display" : "Pie Chart",
  37. "value" : "pie"
  38. },
  39. {
  40. "display" : "Trend Line Chart",
  41. "value" : "trend-line"
  42. },
  43. {
  44. "display" : "Trend Bar Chart",
  45. "value" : "trend-bar"
  46. },
  47. {
  48. "display" : "Treemap",
  49. "value" : "treemap"
  50. }
  51. ],
  52. "value" : "treemap",
  53. "editor" : "vs-visualisation-select"
  54. },
  55. "description" : {
  56. "value" : ""
  57. },
  58. "title" : {
  59. "value" : "Treemap"
  60. }
  61. },
  62. "hidden" : false
  63. },
  64. {
  65. "name" : "vs-container",
  66. "src" : visualisationContainerSrc,
  67. "config" : {
  68. "position" : {
  69. "value" : {
  70. "sizeX" : 1,
  71. "col" : 1,
  72. "row" : 3
  73. }
  74. },
  75. "type" : {
  76. "values" : [
  77. {
  78. "display" : "Line Chart",
  79. "value" : "line"
  80. },
  81. {
  82. "display" : "Bar Chart",
  83. "value" : "bar"
  84. },
  85. {
  86. "display" : "Pie Chart",
  87. "value" : "pie"
  88. },
  89. {
  90. "display" : "Trend Line Chart",
  91. "value" : "trend-line"
  92. },
  93. {
  94. "display" : "Trend Bar Chart",
  95. "value" : "trend-bar"
  96. },
  97. {
  98. "display" : "Treemap",
  99. "value" : "evtx-treemap"
  100. }
  101. ],
  102. "value" : "trend-bar",
  103. "editor" : "vs-visualisation-select"
  104. },
  105. "description" : {
  106. "value" : ""
  107. },
  108. "title" : {
  109. "value" : "Trend Bar"
  110. }
  111. }
  112. },
  113. {
  114. "name" : "vs-container",
  115. "src" : visualisationContainerSrc,
  116. "config" : {
  117. "position" : {
  118. "value" : {
  119. "sizeX" : 1,
  120. "col" : 0,
  121. "row" : 3
  122. }
  123. },
  124. "type" : {
  125. "values" : [
  126. {
  127. "display" : "Line Chart",
  128. "value" : "line"
  129. },
  130. {
  131. "display" : "Bar Chart",
  132. "value" : "bar"
  133. },
  134. {
  135. "display" : "Pie Chart",
  136. "value" : "pie"
  137. },
  138. {
  139. "display" : "Trend Line Chart",
  140. "value" : "trend-line"
  141. },
  142. {
  143. "display" : "Trend Bar Chart",
  144. "value" : "trend-bar"
  145. },
  146. {
  147. "display" : "Treemap",
  148. "value" : "evtx-treemap"
  149. }
  150. ],
  151. "value" : "trend-line",
  152. "editor" : "vs-visualisation-select"
  153. },
  154. "description" : {
  155. "value" : ""
  156. },
  157. "title" : {
  158. "value" : "Trend Line"
  159. }
  160. }
  161. },
  162. {
  163. "name" : "vs-container",
  164. "src" : visualisationContainerSrc,
  165. "config" : {
  166. "position" : {
  167. "value" : {
  168. "sizeX" : 3,
  169. "col": 0,
  170. "row" : 2
  171. }
  172. },
  173. "type" : {
  174. "values" : [
  175. {
  176. "display" : "Line Chart",
  177. "value" : "line"
  178. },
  179. {
  180. "display" : "Bar Chart",
  181. "value" : "bar"
  182. },
  183. {
  184. "display" : "Pie Chart",
  185. "value" : "pie"
  186. },
  187. {
  188. "display" : "Trend Line Chart",
  189. "value" : "trend-line"
  190. },
  191. {
  192. "display" : "Trend Bar Chart",
  193. "value" : "trend-bar"
  194. },
  195. {
  196. "display" : "Treemap",
  197. "value" : "evtx-treemap"
  198. }
  199. ],
  200. "value" : "pie",
  201. "editor" : "vs-visualisation-select"
  202. },
  203. "description" : {
  204. "value" : ""
  205. },
  206. "title" : {
  207. "value" : "Pie Chart"
  208. }
  209. }
  210. },
  211. {
  212. "name" : "vs-container",
  213. "src" : visualisationContainerSrc,
  214. "config" : {
  215. "position" : {
  216. "value" : {
  217. "sizeX" : 3,
  218. "col": 0,
  219. "row" : 1
  220. }
  221. },
  222. "type" : {
  223. "values" : [
  224. {
  225. "display" : "Line Chart",
  226. "value" : "line"
  227. },
  228. {
  229. "display" : "Bar Chart",
  230. "value" : "bar"
  231. },
  232. {
  233. "display" : "Pie Chart",
  234. "value" : "pie"
  235. },
  236. {
  237. "display" : "Trend Line Chart",
  238. "value" : "trend-line"
  239. },
  240. {
  241. "display" : "Trend Bar Chart",
  242. "value" : "trend-bar"
  243. },
  244. {
  245. "display" : "Treemap",
  246. "value" : "evtx-treemap"
  247. }
  248. ],
  249. "value" : "bar",
  250. "editor" : "vs-visualisation-select"
  251. },
  252. "description" : {
  253. "value" : ""
  254. },
  255. "title" : {
  256. "value" : "Bar Chart"
  257. }
  258. }
  259. },
  260. {
  261. "name" : "vs-container",
  262. "src" : visualisationContainerSrc,
  263. "config" : {
  264. "position" : {
  265. "value" : {
  266. "sizeX" : 3,
  267. "col": 0,
  268. "row" : 0
  269. }
  270. },
  271. "type" : {
  272. "values" : [
  273. {
  274. "display" : "Line Chart",
  275. "value" : "line"
  276. },
  277. {
  278. "display" : "Bar Chart",
  279. "value" : "bar"
  280. },
  281. {
  282. "display" : "Pie Chart",
  283. "value" : "pie"
  284. },
  285. {
  286. "display" : "Trend Line Chart",
  287. "value" : "trend-line"
  288. },
  289. {
  290. "display" : "Trend Bar Chart",
  291. "value" : "trend-bar"
  292. },
  293. {
  294. "display" : "Treemap",
  295. "value" : "evtx-treemap"
  296. }
  297. ],
  298. "value" : "line",
  299. "editor" : "vs-visualisation-select"
  300. },
  301. "description" : {
  302. "value" : ""
  303. },
  304. "title" : {
  305. "value" : "Line Chart"
  306. }
  307. }
  308. }
  309. ]
  310. }
  311. ],
  312. "icon" : "tooltip-image",
  313. "title" : "Visualisations",
  314. "slug" : "visualisations"
  315. };
  316.  
  317. /////////////////////////////////////////////////
  318.  
  319. run()
  320. .then(() => {
  321. window.location.href = '/';
  322. })
  323. .catch(err => {
  324. console.error(err);
  325. });
  326.  
  327.  
  328. /////////////////////////////////////////////////
  329.  
  330. function run() {
  331. if (exist()) {
  332. return remove().then(create);
  333. } else {
  334. return create();
  335. }
  336. }
  337.  
  338. function exist() {
  339. return !!getDashboard();
  340. }
  341.  
  342. function getDashboard() {
  343. return customDashboards.filter(d => d.title === dashboard.title)[0];
  344. }
  345.  
  346. function remove() {
  347. let id = getDashboard().id;
  348.  
  349. return Customization.removeDashboard(id);
  350. }
  351.  
  352. function create() {
  353. return Customization.addDashboard(dashboard);
  354. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement