grafana/public/app/features/admin/AdminListOrgsCtrl.ts
Hugo Häggmark d3642a3e91
Moved Server Admin and children to separate menu item on Side Menu (#15592)
* Moved Server Admin and children to separate menu item on Side Menu

* Removed style guide after PR comments
2019-03-05 13:02:41 +01:00

33 lines
844 B
TypeScript

export default class AdminListOrgsCtrl {
/** @ngInject */
constructor($scope, backendSrv, navModelSrv) {
$scope.init = () => {
$scope.navModel = navModelSrv.getNav('admin', 'global-orgs', 0);
$scope.getOrgs();
};
$scope.getOrgs = () => {
backendSrv.get('/api/orgs').then(orgs => {
$scope.orgs = orgs;
});
};
$scope.deleteOrg = org => {
$scope.appEvent('confirm-modal', {
title: 'Delete',
text: 'Do you want to delete organization ' + org.name + '?',
text2: 'All dashboards for this organization will be removed!',
icon: 'fa-trash',
yesText: 'Delete',
onConfirm: () => {
backendSrv.delete('/api/orgs/' + org.id).then(() => {
$scope.getOrgs();
});
},
});
};
$scope.init();
}
}