Very basic start for accounts admin view

This commit is contained in:
Torkel Ödegaard 2015-01-15 15:53:55 +01:00
parent cf344abff2
commit 5b93e09714
7 changed files with 110 additions and 6 deletions

View File

@ -0,0 +1,40 @@
define([
'angular',
'config',
],
function (angular, config) {
'use strict';
var module = angular.module('grafana.controllers');
module.controller('SideMenuCtrl', function($scope) {
$scope.menu = [
{
href: config.appSubUrl,
text: 'Dashboards',
icon: 'fa fa-th-large'
},
{
href: 'panels',
text: 'Panels',
icon: 'fa fa-signal',
},
{
href: 'alerts',
text: 'Alerts',
icon: 'fa fa-bolt',
},
{
href: 'account',
text: 'Account',
icon: 'fa fa-user',
},
];
$scope.init = function() {
};
});
});

View File

@ -0,0 +1,26 @@
define([
'angular',
],
function (angular) {
'use strict';
var module = angular.module('grafana.controllers');
module.controller('AccountsCtrl', function($scope, backendSrv) {
$scope.init = function() {
$scope.accounts = [];
$scope.getAccounts();
};
$scope.getAccounts = function() {
backendSrv.get('/api/admin/accounts').then(function(accounts) {
console.log(accounts);
$scope.accounts = accounts;
});
};
$scope.init();
});
});

View File

@ -0,0 +1,37 @@
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Accounts'"></div>
<div class="dashboard-edit-view" style="min-height: 500px">
<div class="row-fluid">
<div class="span8">
<table class="grafana-options-table">
<tr>
<th style="text-align:left">Id</th>
<th>Login</th>
<th>Email</th>
<th>Name</th>
<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>
<td style="width: 1%">
<a ng-click="edit(variable)" class="btn btn-success">
<i class="fa fa-edit"></i>
Edit
</a>
&nbsp;&nbsp;
<a ng-click="edit(variable)" class="btn btn-danger">
<i class="fa fa-remove"></i>
</a>
</td>
</tr>
</table>
</div>
</div>
</div>

View File

@ -9,6 +9,6 @@ define([
'./dashboard/all', './dashboard/all',
'./account/accountCtrl', './account/accountCtrl',
'./account/datasourcesCtrl', './account/datasourcesCtrl',
'./admin/adminCtrl', './admin/accountsCtrl',
'./grafanaDatasource/datasource', './grafanaDatasource/datasource',
], function () {}); ], function () {});

View File

@ -28,7 +28,7 @@
<i class="fa fa-user"></i> <i class="fa fa-user"></i>
Account Account
</a> </a>
<a class="pro-sidemenu-link" href="admin" 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>
<a class="pro-sidemenu-link" href="login?logout"> <a class="pro-sidemenu-link" href="login?logout">

View File

@ -38,9 +38,9 @@ define([
templateUrl: 'app/features/account/partials/account.html', templateUrl: 'app/features/account/partials/account.html',
controller : 'AccountCtrl', controller : 'AccountCtrl',
}) })
.when('/admin/', { .when('/admin/accounts', {
templateUrl: 'app/features/admin/partials/admin.html', templateUrl: 'app/features/admin/partials/accounts.html',
controller : 'AdminCtrl', controller : 'AccountsCtrl',
}) })
.when('/login', { .when('/login', {
templateUrl: 'app/partials/login.html', templateUrl: 'app/partials/login.html',

View File

@ -5,7 +5,8 @@
background-color: @grafanaListAccent; background-color: @grafanaListAccent;
} }
td { td, th {
text-align: left;
padding: 5px 10px; padding: 5px 10px;
white-space: nowrap; white-space: nowrap;
border-bottom: 1px solid @grafanaListBorderBottom; border-bottom: 1px solid @grafanaListBorderBottom;