Commit 9d1dacb8 by Torkel Ödegaard

Worked on account update, moved collaborators to its own view

parent f3bb2d41
...@@ -18,7 +18,6 @@ function (angular) { ...@@ -18,7 +18,6 @@ function (angular) {
$scope.getAccount = function() { $scope.getAccount = function() {
backendSrv.get('/api/account/').then(function(account) { backendSrv.get('/api/account/').then(function(account) {
$scope.account = account; $scope.account = account;
$scope.collaborators = account.collaborators;
}); });
}; };
...@@ -36,25 +35,10 @@ function (angular) { ...@@ -36,25 +35,10 @@ function (angular) {
}).then($scope.getOtherAccounts); }).then($scope.getOtherAccounts);
}; };
$scope.removeCollaborator = function(collaborator) { $scope.update = function() {
backendSrv.request({ if (!$scope.accountForm.$valid) { return; }
method: 'DELETE',
url: '/api/account/collaborators/' + collaborator.id,
desc: 'Remove collaborator',
}).then($scope.getAccount);
};
$scope.addCollaborator = function() { backendSrv.post('/api/account/', $scope.account);
if (!$scope.addCollaboratorForm.$valid) {
return;
}
backendSrv.request({
method: 'PUT',
url: '/api/account/collaborators',
data: $scope.collaborator,
desc: 'Add collaborator'
}).then($scope.getAccount);
}; };
$scope.init(); $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 @@ ...@@ -8,38 +8,54 @@
<div class="dashboard-editor-header"> <div class="dashboard-editor-header">
<div class="dashboard-editor-title"> <div class="dashboard-editor-title">
<i class="fa fa-user"></i> <i class="fa fa-user"></i>
Personal information Account details
</div> </div>
</div> </div>
<div class="dashboard-editor-body"> <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"> <form name="accountForm">
<div class="editor-option">
<label class="small">Email</label> <div class="grafana-target">
<input type="text" class="input-xxlarge" ng-model='account.email' placeholder="name"></input> <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>
</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>
</div>
</div>
<div class="dashboard-editor-footer"> <br>
<button class="btn btn-success">Update</button> <button type="submit" class="btn btn-success" ng-click="update()">Update</button>
</form>
</div> </div>
</div> </div>
<div class="section"> <div class="section">
...@@ -70,43 +86,4 @@ ...@@ -70,43 +86,4 @@
</div> </div>
</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([ ...@@ -8,6 +8,7 @@ define([
'./elasticsearch/datasource', './elasticsearch/datasource',
'./dashboard/all', './dashboard/all',
'./account/accountCtrl', './account/accountCtrl',
'./account/collaboratorsCtrl',
'./account/datasourcesCtrl', './account/datasourcesCtrl',
'./admin/accountsCtrl', './admin/accountsCtrl',
'./grafanaDatasource/datasource', './grafanaDatasource/datasource',
......
...@@ -22,12 +22,15 @@ ...@@ -22,12 +22,15 @@
</a> </a>
<a class="pro-sidemenu-link" href="account/datasources"> <a class="pro-sidemenu-link" href="account/datasources">
<i class="fa fa-sitemap"></i> <i class="fa fa-sitemap"></i>
Data sources Data
</a> </a>
<a class="pro-sidemenu-link" href="account"> <a class="pro-sidemenu-link" href="account">
<i class="fa fa-user"></i> <i class="fa fa-user"></i>
Account Account
</a> </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"> <a class="pro-sidemenu-link" href="admin/accounts" ng-if="grafana.user.isAdmin">
<i class="fa fa-institution"></i>Admin <i class="fa fa-institution"></i>Admin
</a> </a>
......
...@@ -34,6 +34,10 @@ define([ ...@@ -34,6 +34,10 @@ define([
templateUrl: 'app/features/account/partials/datasources.html', templateUrl: 'app/features/account/partials/datasources.html',
controller : 'DataSourcesCtrl', controller : 'DataSourcesCtrl',
}) })
.when('/account/collaborators', {
templateUrl: 'app/features/account/partials/collaborators.html',
controller : 'CollaboratorsCtrl',
})
.when('/account', { .when('/account', {
templateUrl: 'app/features/account/partials/account.html', templateUrl: 'app/features/account/partials/account.html',
controller : 'AccountCtrl', 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