row_ctrl.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 './options';
  6. import './add_panel';
  7. export class DashRowCtrl {
  8. dashboard: any;
  9. row: any;
  10. dropView: number;
  11. /** @ngInject */
  12. constructor(private $scope, private $rootScope, private $timeout) {
  13. this.row.title = this.row.title || 'Row title';
  14. }
  15. toggleCollapse() {
  16. this.row.collapse = !this.row.collapse;
  17. }
  18. onMenuDeleteRow() {
  19. this.dashboard.removeRow(this.row);
  20. }
  21. }
  22. coreModule.directive('dashRow', function($rootScope) {
  23. return {
  24. restrict: 'E',
  25. templateUrl: 'public/app/features/dashboard/row/row.html',
  26. controller: DashRowCtrl,
  27. bindToController: true,
  28. controllerAs: 'ctrl',
  29. scope: {
  30. dashboard: "=",
  31. row: "=",
  32. },
  33. link: function(scope, element) {
  34. scope.$watchGroup(['ctrl.row.collapse', 'ctrl.row.height'], function() {
  35. element.toggleClass('dash-row--collapse', scope.ctrl.row.collapse);
  36. });
  37. }
  38. };
  39. });