2015-01-19 11:57:25 -06:00
|
|
|
define([
|
|
|
|
'angular',
|
2015-02-18 06:18:29 -06:00
|
|
|
'config',
|
2015-01-19 11:57:25 -06:00
|
|
|
],
|
2015-02-18 06:18:29 -06:00
|
|
|
function (angular, config) {
|
2015-01-19 11:57:25 -06:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var module = angular.module('grafana.controllers');
|
|
|
|
|
2015-02-19 09:09:49 -06:00
|
|
|
module.controller('ProfileCtrl', function($scope, backendSrv) {
|
2015-01-19 11:57:25 -06:00
|
|
|
|
|
|
|
$scope.init = function() {
|
|
|
|
$scope.getUser();
|
2015-02-25 01:07:52 -06:00
|
|
|
$scope.getUserOrgs();
|
2015-01-19 11:57:25 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.getUser = function() {
|
|
|
|
backendSrv.get('/api/user').then(function(user) {
|
|
|
|
$scope.user = user;
|
2015-02-28 07:30:08 -06:00
|
|
|
$scope.user.theme = user.theme || 'dark';
|
2015-01-19 11:57:25 -06:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2015-02-25 01:07:52 -06:00
|
|
|
$scope.getUserOrgs = function() {
|
|
|
|
backendSrv.get('/api/user/orgs').then(function(orgs) {
|
|
|
|
$scope.orgs = orgs;
|
2015-01-19 11:57:25 -06:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2015-02-25 01:07:52 -06:00
|
|
|
$scope.setUsingOrg = function(org) {
|
|
|
|
backendSrv.post('/api/user/using/' + org.orgId).then(function() {
|
2015-02-18 06:18:29 -06:00
|
|
|
window.location.href = config.appSubUrl + '/profile';
|
|
|
|
});
|
2015-01-19 11:57:25 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.update = function() {
|
|
|
|
if (!$scope.userForm.$valid) { return; }
|
2015-01-26 05:57:44 -06:00
|
|
|
backendSrv.put('/api/user/', $scope.user);
|
2015-01-19 11:57:25 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.init();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|