Commit efe7279e by Torkel Ödegaard

Quick fix for frontend for account to user split

parent 1c5f9027
......@@ -6,9 +6,9 @@ function (angular) {
var module = angular.module('grafana.controllers');
module.controller('CollaboratorsCtrl', function($scope, $http, backendSrv) {
module.controller('AccountUsersCtrl', function($scope, $http, backendSrv) {
$scope.collaborator = {
$scope.user = {
loginOrEmail: '',
role: 'Viewer',
};
......@@ -18,29 +18,27 @@ function (angular) {
};
$scope.get = function() {
backendSrv.get('/api/account/collaborators').then(function(collaborators) {
$scope.collaborators = collaborators;
backendSrv.get('/api/account/users').then(function(users) {
$scope.users = users;
});
};
$scope.removeCollaborator = function(collaborator) {
$scope.removeUser = function(user) {
backendSrv.request({
method: 'DELETE',
url: '/api/account/collaborators/' + collaborator.id,
desc: 'Remove collaborator',
url: '/api/account/users/' + user.id,
}).then($scope.get);
};
$scope.addCollaborator = function() {
$scope.addUser = function() {
if (!$scope.form.$valid) {
return;
}
backendSrv.request({
method: 'PUT',
url: '/api/account/collaborators',
data: $scope.collaborator,
desc: 'Add collaborator'
url: '/api/account/users',
data: $scope.user,
}).then($scope.get);
};
......
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Account > Collaborators'"></div>
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Account > Users'"></div>
<div class="dashboard-edit-view" style="min-height: 500px">
<div class="dashboard-editor-header">
<div class="dashboard-editor-title">
<i class="fa fa-users"></i>
Collaborators
Account users
</div>
</div>
......@@ -17,20 +17,20 @@
<div class="tight-form">
<ul class="tight-form-list">
<li class="tight-form-item" style="width: 160px">
<strong>username or email</strong>
<strong>Username or Email</strong>
</li>
<li>
<input type="text" ng-model="collaborator.loginoremail" required class="input-xlarge tight-form-input" placeholder="collaborator@email.com">
<input type="text" ng-model="user.loginOrEmail" required class="input-xlarge tight-form-input" placeholder="user@email.com or username">
</li>
<li class="tight-form-item">
role
</li>
<li>
<select type="text" ng-model="collaborator.role" class="input-small tight-form-input" ng-options="f for f in ['viewer', 'editor', 'admin']">
<select type="text" ng-model="user.role" class="input-small tight-form-input" ng-options="f for f in ['viewer', 'editor', 'admin']">
</select>
</li>
<li>
<button class="btn btn-success tight-form-btn" ng-click="addcollaborator()">add</button>
<button class="btn btn-success tight-form-btn" ng-click="addUser()">Add</button>
</li>
</ul>
<div class="clearfix"></div>
......@@ -42,13 +42,13 @@
<div class="editor-row row">
<table class="grafana-options-table span5">
<tr ng-repeat="collaborator in collaborators">
<td>{{collaborator.email}}</td>
<tr ng-repeat="user in users">
<td>{{user.email}}</td>
<td>
{{collaborator.role}}
{{user.role}}
</td>
<td style="width: 1%">
<a ng-click="removeCollaborator(collaborator)" class="btn btn-danger btn-mini">
<a ng-click="removeUser(user)" class="btn btn-danger btn-mini">
<i class="fa fa-remove"></i>
</a>
</td>
......
......@@ -6,17 +6,16 @@ function (angular) {
var module = angular.module('grafana.controllers');
module.controller('AccountsCtrl', function($scope, backendSrv) {
module.controller('AdminUsersCtrl', function($scope, backendSrv) {
$scope.init = function() {
$scope.accounts = [];
$scope.getAccounts();
$scope.getUsers();
};
$scope.getAccounts = function() {
backendSrv.get('/api/admin/accounts').then(function(accounts) {
console.log(accounts);
$scope.accounts = accounts;
$scope.getUsers = function() {
backendSrv.get('/api/admin/users').then(function(users) {
$scope.users = users;
});
};
......
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Admin > Accounts'"></div>
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Admin > Users'"></div>
<div class="dashboard-edit-view" style="min-height: 500px">
......@@ -15,12 +15,12 @@
<th>Admin</th>
<th></th>
</tr>
<tr ng-repeat="account in accounts">
<td>{{account.id}}</td>
<td>{{account.login}}</td>
<td>{{account.email}}</td>
<td>{{account.name}}</td>
<td>{{account.isAdmin}}</td>
<tr ng-repeat="user in users">
<td>{{user.id}}</td>
<td>{{user.login}}</td>
<td>{{user.email}}</td>
<td>{{user.name}}</td>
<td>{{user.isAdmin}}</td>
<td style="width: 1%">
<a ng-click="edit(variable)" class="btn btn-success btn-small">
<i class="fa fa-edit"></i>
......
......@@ -7,11 +7,11 @@ define([
'./opentsdb/datasource',
'./elasticsearch/datasource',
'./dashboard/all',
'./account/accountCtrl',
'./account/collaboratorsCtrl',
'./profile/profileCtrl',
'./account/accountUsersCtrl',
'./account/datasourcesCtrl',
'./account/apiKeysCtrl',
'./account/importCtrl',
'./admin/accountsCtrl',
'./admin/adminUsersCtrl',
'./grafanaDatasource/datasource',
], function () {});
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Account Settings'"></div>
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Profile'"></div>
<div class="dashboard-edit-view">
<div class="editor-row">
......@@ -7,13 +7,13 @@
<div class="dashboard-editor-header">
<div class="dashboard-editor-title">
<i class="fa fa-user"></i>
Account details
Your info
</div>
</div>
<div class="dashboard-editor-body">
<form name="accountForm">
<form name="userForm">
<div class="tight-form">
<ul class="tight-form-list">
......@@ -21,7 +21,7 @@
<strong>Name</strong>
</li>
<li>
<input type="text" required ng-model="account.name" class="input-xxlarge tight-form-input last" >
<input type="text" required ng-model="user.name" class="input-xxlarge tight-form-input last" >
</li>
</ul>
<div class="clearfix"></div>
......@@ -32,7 +32,7 @@
<strong>Email</strong>
</li>
<li>
<input type="text" required ng-model="account.email" class="input-xxlarge tight-form-input last" >
<input type="text" required ng-model="user.email" class="input-xxlarge tight-form-input last" >
</li>
</ul>
<div class="clearfix"></div>
......@@ -43,7 +43,7 @@
<strong>Username</strong>
</li>
<li>
<input type="text" required ng-model="account.login" class="input-xxlarge tight-form-input last" >
<input type="text" required ng-model="user.login" class="input-xxlarge tight-form-input last" >
</li>
</ul>
<div class="clearfix"></div>
......@@ -65,14 +65,14 @@
<br>
<table class="grafana-options-table">
<tr ng-repeat="other in otherAccounts">
<td>email: {{other.email}}</td>
<td>role: {{other.role}}</td>
<td ng-show="other.isUsing">
<tr ng-repeat="ac in accounts">
<td>email: {{ac.email}}</td>
<td>role: {{ac.role}}</td>
<td ng-show="ac.isUsing">
currently using this account
</td>
<td ng-show="!other.isUsing">
<a ng-click="setUsingAccount(other)" class="btn btn-success btn-mini">
<td ng-show="!ac.isUsing">
<a ng-click="setUsingAccount(ac)" class="btn btn-success btn-mini">
Select
</a>
</td>
......
......@@ -6,40 +6,37 @@ function (angular) {
var module = angular.module('grafana.controllers');
module.controller('AccountCtrl', function($scope, $http, backendSrv) {
$scope.collaborator = {};
module.controller('ProfileCtrl', function($scope, $http, backendSrv) {
$scope.init = function() {
$scope.getAccount();
$scope.getOtherAccounts();
$scope.getUser();
$scope.getUserAccounts();
};
$scope.getAccount = function() {
backendSrv.get('/api/account/').then(function(account) {
$scope.account = account;
$scope.getUser = function() {
backendSrv.get('/api/user').then(function(user) {
$scope.user = user;
});
};
$scope.getOtherAccounts = function() {
backendSrv.get('/api/account/others').then(function(otherAccounts) {
$scope.otherAccounts = otherAccounts;
$scope.getUserAccounts = function() {
backendSrv.get('/api/user/accounts').then(function(accounts) {
$scope.accounts = accounts;
});
};
$scope.setUsingAccount = function(otherAccount) {
$scope.setUsingAccount = function(account) {
backendSrv.request({
method: 'POST',
url: '/api/account/using/' + otherAccount.accountId,
url: '/api/user/using/' + account.accountId,
desc: 'Change active account',
}).then($scope.getOtherAccounts);
}).then($scope.getUserAccounts);
};
$scope.update = function() {
if (!$scope.accountForm.$valid) { return; }
if (!$scope.userForm.$valid) { return; }
backendSrv.post('/api/account/', $scope.account);
backendSrv.post('/api/user/', $scope.user);
};
$scope.init();
......
......@@ -16,12 +16,8 @@
<i class="fa fa-sitemap"></i>
Data
</a>
<a class="pro-sidemenu-link" href="account">
<i class="fa fa-user"></i>
Account
</a>
<a class="pro-sidemenu-link" href="account/collaborators">
<i class="fa fa-users"></i>Collaborators
<a class="pro-sidemenu-link" href="account/users">
<i class="fa fa-users"></i>Users
</a>
<a class="pro-sidemenu-link" href="account/apikeys">
<i class="fa fa-key"></i>API Keys
......@@ -30,9 +26,16 @@
<i class="fa fa-download"></i>
Import
</a>
<a class="pro-sidemenu-link" href="admin/accounts" ng-if="grafana.user.isGrafanaAdmin">
<a class="pro-sidemenu-link" href="profile">
<i class="fa fa-user"></i>
Profile
</a>
<a class="pro-sidemenu-link" href="admin/users" ng-if="grafana.user.isGrafanaAdmin">
<i class="fa fa-institution"></i>Admin
</a>
<a class="pro-sidemenu-link" href="login?logout">
<i class="fa fa-sign-out"></i>Sign out
</a>
......
......@@ -34,9 +34,9 @@ define([
templateUrl: 'app/features/account/partials/datasources.html',
controller : 'DataSourcesCtrl',
})
.when('/account/collaborators', {
templateUrl: 'app/features/account/partials/collaborators.html',
controller : 'CollaboratorsCtrl',
.when('/account/users', {
templateUrl: 'app/features/account/partials/users.html',
controller : 'AccountUsersCtrl',
})
.when('/account/apikeys', {
templateUrl: 'app/features/account/partials/apikeys.html',
......@@ -46,13 +46,13 @@ define([
templateUrl: 'app/features/account/partials/import.html',
controller : 'ImportCtrl',
})
.when('/account', {
templateUrl: 'app/features/account/partials/account.html',
controller : 'AccountCtrl',
.when('/profile', {
templateUrl: 'app/features/profile/partials/profile.html',
controller : 'ProfileCtrl',
})
.when('/admin/accounts', {
templateUrl: 'app/features/admin/partials/accounts.html',
controller : 'AccountsCtrl',
.when('/admin/users', {
templateUrl: 'app/features/admin/partials/users.html',
controller : 'AdminUsersCtrl',
})
.when('/login', {
templateUrl: 'app/partials/login.html',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment