module.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import _ from 'lodash';
  3. import config from 'app/core/config';
  4. import {PanelCtrl} from 'app/plugins/sdk';
  5. import {impressions} from 'app/features/dashboard/impression_store';
  6. class PermissionListCtrl extends PanelCtrl {
  7. static templateUrl = 'module.html';
  8. userPermissions: any[];
  9. userGroupPermissions: any[];
  10. roles: any[];
  11. panelDefaults = {
  12. folderId: 0
  13. };
  14. /** @ngInject */
  15. constructor($scope, $injector, private backendSrv) {
  16. super($scope, $injector);
  17. _.defaults(this.panel, this.panelDefaults);
  18. this.events.on('refresh', this.onRefresh.bind(this));
  19. this.events.on('init-edit-mode', this.onInitEditMode.bind(this));
  20. this.getPermissions();
  21. }
  22. onInitEditMode() {
  23. this.editorTabIndex = 1;
  24. this.addEditorTab('Options', 'public/app/plugins/panel/permissionlist/editor.html');
  25. }
  26. onRefresh() {
  27. var promises = [];
  28. promises.push(this.getPermissions());
  29. return Promise.all(promises)
  30. .then(this.renderingCompleted.bind(this));
  31. }
  32. onFolderChange(folder: any) {
  33. this.panel.folderId = folder.id;
  34. this.refresh();
  35. }
  36. getPermissions() {
  37. return this.backendSrv.get(`/api/dashboards/id/${this.panel.folderId}/acl`)
  38. .then(result => {
  39. this.userPermissions = _.filter(result, p => { return p.userId > 0;});
  40. this.userGroupPermissions = _.filter(result, p => { return p.userGroupId > 0;});
  41. // this.roles = this.setRoles(result);
  42. });
  43. }
  44. }
  45. export {PermissionListCtrl, PermissionListCtrl as PanelCtrl};