2017-12-20 05:33:33 -06:00
|
|
|
import angular from 'angular';
|
2015-02-23 11:29:01 -06:00
|
|
|
|
2017-11-23 10:04:50 -06:00
|
|
|
export class OrgDetailsCtrl {
|
|
|
|
/** @ngInject **/
|
|
|
|
constructor($scope, $http, backendSrv, contextSrv, navModelSrv) {
|
2015-02-23 11:29:01 -06:00
|
|
|
$scope.init = function() {
|
|
|
|
$scope.getOrgInfo();
|
2017-12-20 05:33:33 -06:00
|
|
|
$scope.navModel = navModelSrv.getNav('cfg', 'org-settings', 0);
|
2015-02-23 11:29:01 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.getOrgInfo = function() {
|
2017-12-20 05:33:33 -06:00
|
|
|
backendSrv.get('/api/org').then(function(org) {
|
2015-02-25 01:07:52 -06:00
|
|
|
$scope.org = org;
|
2015-09-08 07:22:44 -05:00
|
|
|
$scope.address = org.address;
|
2015-02-28 02:46:37 -06:00
|
|
|
contextSrv.user.orgName = org.name;
|
2015-02-23 11:29:01 -06:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.update = function() {
|
2017-12-19 09:06:54 -06:00
|
|
|
if (!$scope.orgForm.$valid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var data = { name: $scope.org.name };
|
2017-12-20 05:33:33 -06:00
|
|
|
backendSrv.put('/api/org', data).then($scope.getOrgInfo);
|
2015-09-08 07:22:44 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.updateAddress = function() {
|
2017-12-19 09:06:54 -06:00
|
|
|
if (!$scope.addressForm.$valid) {
|
|
|
|
return;
|
|
|
|
}
|
2017-12-21 01:39:31 -06:00
|
|
|
backendSrv.put('/api/org/address', $scope.address).then($scope.getOrgInfo);
|
2015-02-23 11:29:01 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.init();
|
2017-11-23 10:04:50 -06:00
|
|
|
}
|
|
|
|
}
|
2015-02-23 11:29:01 -06:00
|
|
|
|
2017-12-21 01:39:31 -06:00
|
|
|
angular.module('grafana.controllers').controller('OrgDetailsCtrl', OrgDetailsCtrl);
|