Commit 9667f324 by Torkel Ödegaard

added ability to create accounts from profile page

parent d9a33680
......@@ -58,8 +58,8 @@
<div class="section">
<div class="dashboard-editor-header">
<div class="dashboard-editor-title">
<i class="fa fa-eye"></i>
Active account
<i class="fa fa-cubes"></i>
Your accounts
</div>
</div>
<br>
......@@ -69,7 +69,9 @@
<td>Name: {{ac.name}}</td>
<td>Role: {{ac.role}}</td>
<td ng-show="ac.isUsing">
currently using this account
<span class="label label-info">
active now
</span>
</td>
<td ng-show="!ac.isUsing">
<a ng-click="setUsingAccount(ac)" class="btn btn-success btn-mini">
......@@ -78,7 +80,34 @@
</td>
</tr>
</table>
</div>
<div class="section">
<div class="dashboard-editor-header">
<div class="dashboard-editor-title">
<i class="fa fa-plus-square"></i>
Add account
</div>
</div>
<br>
<form name="form">
<div class="tight-form">
<ul class="tight-form-list">
<li class="tight-form-item">
<strong>Account name</strong>
</li>
<li>
<input type="text" ng-model="newAccount.name" required class="input-xlarge tight-form-input" placeholder="account name">
</li>
<li>
<button class="btn btn-success tight-form-btn" ng-click="createAccount()">Create</button>
</li>
</ul>
<div class="clearfix"></div>
</div>
</form>
</div>
</div>
</div>
......
......@@ -8,6 +8,8 @@ function (angular) {
module.controller('ProfileCtrl', function($scope, $http, backendSrv) {
$scope.newAccount = {name: ''};
$scope.init = function() {
$scope.getUser();
$scope.getUserAccounts();
......@@ -26,11 +28,7 @@ function (angular) {
};
$scope.setUsingAccount = function(account) {
backendSrv.request({
method: 'POST',
url: '/api/user/using/' + account.accountId,
desc: 'Change active account',
}).then($scope.getUserAccounts);
backendSrv.post('/api/user/using/' + account.accountId).then($scope.getUserAccounts);
};
$scope.update = function() {
......@@ -39,6 +37,10 @@ function (angular) {
backendSrv.post('/api/user/', $scope.user);
};
$scope.createAccount = function() {
backendSrv.put('/api/account/', $scope.newAccount).then($scope.getUserAccounts);
};
$scope.init();
});
......
......@@ -486,7 +486,7 @@ legend, label {
}
.label {
color: @grayLighter;
color: @white;
}
.badge {
......
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