options.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import _ from 'lodash';
  3. import config from 'app/core/config';
  4. import {coreModule, appEvents} from 'app/core/core';
  5. // import VirtualScroll from 'virtual-scroll';
  6. // console.log(VirtualScroll);
  7. export class RowOptionsCtrl {
  8. row: any;
  9. dashboard: any;
  10. rowCtrl: any;
  11. fontSizes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
  12. /** @ngInject */
  13. constructor(private $scope, private $timeout, private $rootScope) {
  14. this.row = this.rowCtrl.row;
  15. this.dashboard = this.rowCtrl.dashboard;
  16. this.row.titleSize = this.row.titleSize || 'h6';
  17. }
  18. deleteRow() {
  19. if (!this.row.panels.length) {
  20. this.dashboard.rows = _.without(this.dashboard.rows, this.row);
  21. return;
  22. }
  23. appEvents.emit('confirm-modal', {
  24. title: 'Delete',
  25. text: 'Are you sure you want to delete this row?',
  26. icon: 'fa-trash',
  27. yesText: 'Delete',
  28. onConfirm: () => {
  29. this.dashboard.rows = _.without(this.dashboard.rows, this.row);
  30. }
  31. });
  32. }
  33. }
  34. export function rowOptionsDirective() {
  35. return {
  36. restrict: 'E',
  37. templateUrl: 'public/app/features/dashboard/row/options.html',
  38. controller: RowOptionsCtrl,
  39. bindToController: true,
  40. controllerAs: 'ctrl',
  41. scope: {
  42. rowCtrl: "=",
  43. },
  44. };
  45. }
  46. coreModule.directive('dashRowOptions', rowOptionsDirective);