Commit 9667f324 by Torkel Ödegaard

added ability to create accounts from profile page

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