Commit 9d1dacb8 by Torkel Ödegaard

Worked on account update, moved collaborators to its own view

parent f3bb2d41
......@@ -18,7 +18,6 @@ function (angular) {
$scope.getAccount = function() {
backendSrv.get('/api/account/').then(function(account) {
$scope.account = account;
$scope.collaborators = account.collaborators;
});
};
......@@ -36,25 +35,10 @@ function (angular) {
}).then($scope.getOtherAccounts);
};
$scope.removeCollaborator = function(collaborator) {
backendSrv.request({
method: 'DELETE',
url: '/api/account/collaborators/' + collaborator.id,
desc: 'Remove collaborator',
}).then($scope.getAccount);
};
$scope.update = function() {
if (!$scope.accountForm.$valid) { return; }
$scope.addCollaborator = function() {
if (!$scope.addCollaboratorForm.$valid) {
return;
}
backendSrv.request({
method: 'PUT',
url: '/api/account/collaborators',
data: $scope.collaborator,
desc: 'Add collaborator'
}).then($scope.getAccount);
backendSrv.post('/api/account/', $scope.account);
};
$scope.init();
......
define([
'angular',
],
function (angular) {
'use strict';
var module = angular.module('grafana.controllers');
module.controller('CollaboratorsCtrl', function($scope, $http, backendSrv) {
$scope.collaborator = {};
$scope.init = function() {
$scope.get();
};
$scope.get = function() {
backendSrv.get('/api/account/collaborators').then(function(collaborators) {
$scope.collaborators = collaborators;
console.log(collaborators);
});
};
$scope.removeCollaborator = function(collaborator) {
backendSrv.request({
method: 'DELETE',
url: '/api/account/collaborators/' + collaborator.id,
desc: 'Remove collaborator',
}).then($scope.get);
};
$scope.addCollaborator = function() {
if (!$scope.addCollaboratorForm.$valid) {
return;
}
backendSrv.request({
method: 'PUT',
url: '/api/account/collaborators',
data: $scope.collaborator,
desc: 'Add collaborator'
}).then($scope.get);
};
$scope.init();
});
});
......@@ -8,38 +8,54 @@
<div class="dashboard-editor-header">
<div class="dashboard-editor-title">
<i class="fa fa-user"></i>
Personal information
Account details
</div>
</div>
<div class="dashboard-editor-body">
<div class="editor-row">
<div class="editor-option">
<label class="small">Name</label>
<input type="text" class="input-xxlarge" ng-model='account.name' placeholder="name"></input>
</div>
</div>
<div class="editor-row">
<div class="editor-option">
<label class="small">Email</label>
<input type="text" class="input-xxlarge" ng-model='account.email' placeholder="name"></input>
</div>
</div>
<div class="editor-row">
<div class="editor-option">
<label class="small">Account Name</label>
<input type="text" class="input-xxlarge" ng-model='account.accountName' placeholder="name"></input>
</div>
<form name="accountForm">
<div class="grafana-target">
<div class="grafana-target-inner">
<ul class="grafana-segment-list">
<li class="grafana-target-segment" style="width: 80px">
<strong>Name</strong>
</li>
<li>
<input type="text" ng-model="account.name" class="input-xxlarge grafana-target-segment-input last" >
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="grafana-target-inner" style="margin-top: 10px">
<ul class="grafana-segment-list">
<li class="grafana-target-segment" style="width: 80px">
<strong>Email</strong>
</li>
<li>
<input type="text" ng-model="account.email" class="input-xxlarge grafana-target-segment-input last" >
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="grafana-target-inner" style="margin-top: 10px">
<ul class="grafana-segment-list">
<li class="grafana-target-segment" style="width: 80px">
<strong>Username</strong>
</li>
<li>
<input type="text" ng-model="account.login" class="input-xxlarge grafana-target-segment-input last" >
</li>
</ul>
<div class="clearfix"></div>
</div>
</div>
<div class="dashboard-editor-footer">
<button class="btn btn-success">Update</button>
<br>
<button type="submit" class="btn btn-success" ng-click="update()">Update</button>
</form>
</div>
</div>
<div class="section">
......@@ -70,43 +86,4 @@
</div>
</div>
<div class="dashboard-edit-view" style="border-top: solid 1px black;">
<div class="dashboard-editor-header">
<div class="dashboard-editor-title">
<i class="fa fa-users"></i>
Collaborators
</div>
</div>
<div class="dashboard-editor-body">
<div class="editor-row">
<div class="editor-option">
<form name="addCollaboratorForm" class="form-inline">
<label class="small">Add a collaborator</label>
<input type="text" class="input-xxlarge" ng-model='collaborator.email' placeholder="collaborator@email.com"></input>
<button class="btn btn-success" ng-click="addCollaborator()">Add</button>
</form>
</div>
</div>
<div class="editor-row row">
<table class="grafana-options-table span5">
<tr ng-repeat="collaborator in account.collaborators">
<td>{{collaborator.email}}</td>
<td>
{{collaborator.role}}
</td>
<td style="width: 1%">
<a ng-click="removeCollaborator(collaborator)" class="btn btn-danger btn-mini">
<i class="fa fa-remove"></i>
</a>
</td>
</tr>
</table>
</div>
</div>
</div>
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Account > Collaborators'"></div>
<div class="dashboard-edit-view">
<div class="dashboard-editor-header">
<div class="dashboard-editor-title">
<i class="fa fa-users"></i>
Collaborators
</div>
</div>
<div class="dashboard-editor-body">
<div class="editor-row">
<div class="editor-option">
<form name="addCollaboratorForm" class="form-inline">
<label class="small">Add a collaborator</label>
<input type="text" class="input-xxlarge" ng-model='collaborator.email' placeholder="collaborator@email.com"></input>
<button class="btn btn-success" ng-click="addCollaborator()">Add</button>
</form>
</div>
</div>
<div class="editor-row row">
<table class="grafana-options-table span5">
<tr ng-repeat="collaborator in collaborators">
<td>{{collaborator.email}}</td>
<td>
{{collaborator.role}}
</td>
<td style="width: 1%">
<a ng-click="removeCollaborator(collaborator)" class="btn btn-danger btn-mini">
<i class="fa fa-remove"></i>
</a>
</td>
</tr>
</table>
</div>
</div>
</div>
......@@ -8,6 +8,7 @@ define([
'./elasticsearch/datasource',
'./dashboard/all',
'./account/accountCtrl',
'./account/collaboratorsCtrl',
'./account/datasourcesCtrl',
'./admin/accountsCtrl',
'./grafanaDatasource/datasource',
......
......@@ -22,12 +22,15 @@
</a>
<a class="pro-sidemenu-link" href="account/datasources">
<i class="fa fa-sitemap"></i>
Data sources
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>
<a class="pro-sidemenu-link" href="admin/accounts" ng-if="grafana.user.isAdmin">
<i class="fa fa-institution"></i>Admin
</a>
......
......@@ -34,6 +34,10 @@ define([
templateUrl: 'app/features/account/partials/datasources.html',
controller : 'DataSourcesCtrl',
})
.when('/account/collaborators', {
templateUrl: 'app/features/account/partials/collaborators.html',
controller : 'CollaboratorsCtrl',
})
.when('/account', {
templateUrl: 'app/features/account/partials/account.html',
controller : 'AccountCtrl',
......
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