module.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import {PanelCtrl} from 'app/plugins/sdk';
  3. import {contextSrv} from 'app/core/core';
  4. class GettingStartedPanelCtrl extends PanelCtrl {
  5. static templateUrl = 'public/app/plugins/panel/gettingstarted/module.html';
  6. checksDone: boolean;
  7. step: number;
  8. /** @ngInject **/
  9. constructor($scope, $injector, private backendSrv, private datasourceSrv) {
  10. super($scope, $injector);
  11. /* tslint:disable */
  12. if (contextSrv.user.helpFlags1 & 1) {
  13. this.row.removePanel(this.panel, false);
  14. return;
  15. }
  16. /* tslint:enable */
  17. var datasources = datasourceSrv.getMetricSources().filter(item => {
  18. return item.meta.builtIn === false;
  19. });
  20. this.step = 2;
  21. if (datasources.length === 0) {
  22. this.checksDone = true;
  23. return;
  24. }
  25. this.step = 3;
  26. this.backendSrv.search({limit: 1}).then(result => {
  27. if (result.length === 0) {
  28. this.checksDone = true;
  29. return;
  30. }
  31. this.step = 4;
  32. this.checksDone = true;
  33. });
  34. }
  35. getStateClass(step) {
  36. if (step === this.step) { return 'active'; }
  37. if (step < this.step) { return 'completed'; }
  38. return '';
  39. }
  40. dismiss() {
  41. this.row.removePanel(this.panel, false);
  42. this.backendSrv.request({
  43. method: 'PUT',
  44. url: '/api/user/helpflags/1',
  45. showSuccessAlert: false,
  46. }).then(res => {
  47. contextSrv.user.helpFlags1 = res.helpFlags1;
  48. });
  49. }
  50. }
  51. export {GettingStartedPanelCtrl, GettingStartedPanelCtrl as PanelCtrl}