Users and servers creation.
This commit is contained in:
@@ -62,21 +62,11 @@ angular.module('xoWebApp', [
|
||||
controller: 'AboutCtrl'
|
||||
templateUrl: 'views/about.html'
|
||||
|
||||
.state 'servers_new',
|
||||
url: '/servers/new'
|
||||
controller: 'NewServerCtrl'
|
||||
templateUrl: 'views/new_server.html'
|
||||
|
||||
.state 'settings',
|
||||
url: '/settings'
|
||||
controller: 'SettingsCtrl'
|
||||
templateUrl: 'views/settings.html'
|
||||
|
||||
.state 'users_new',
|
||||
url: '/users/new'
|
||||
controller: 'NewUserCtrl'
|
||||
templateUrl: 'views/new_user.html'
|
||||
|
||||
# Changes the default settings for the tooltips.
|
||||
$tooltipProvider.options
|
||||
appendToBody: true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
# TODO: User/server creation.
|
||||
# FIXME: Mutualize the code between users and servers.
|
||||
|
||||
angular.module('xoWebApp')
|
||||
.controller 'SettingsCtrl', ($scope, xoApi) ->
|
||||
@@ -32,9 +32,22 @@ angular.module('xoWebApp')
|
||||
# Which ones are selected?
|
||||
selected = $scope.selectedUsers = {}
|
||||
|
||||
# New users to create.
|
||||
$scope.newUsers = []
|
||||
|
||||
# Add a new user to be created.
|
||||
$scope.addUser = ->
|
||||
$scope.newUsers.push {
|
||||
# Fake (unique) identifier needed by Angular.JS
|
||||
id: Math.random()
|
||||
|
||||
# Default permission.
|
||||
permission: 'none'
|
||||
}
|
||||
|
||||
# Saves any modifications.
|
||||
$scope.saveUsers = ->
|
||||
users = $scope.users
|
||||
{users, newUsers} = $scope
|
||||
|
||||
# This will be the new list of users with those marked to
|
||||
# delete removed.
|
||||
@@ -57,7 +70,23 @@ angular.module('xoWebApp')
|
||||
|
||||
updateUsers.push user
|
||||
|
||||
for user in newUsers
|
||||
{email, permission, password} = user
|
||||
|
||||
# Required field.
|
||||
continue unless email
|
||||
|
||||
# Sends the order to XO-Server.
|
||||
xoApi.call 'user.create', {email, permission, password}
|
||||
|
||||
# The password should not be displayed.
|
||||
delete user.password
|
||||
|
||||
# Adds the user to out local list.
|
||||
updateUsers.push user
|
||||
|
||||
$scope.users = updateUsers
|
||||
$scope.newUsers = []
|
||||
|
||||
# TODO: Retrieves an up to date users list from the server.
|
||||
|
||||
@@ -70,9 +99,19 @@ angular.module('xoWebApp')
|
||||
# Which ones are selected?
|
||||
selected = $scope.selectedServers = {}
|
||||
|
||||
# New servers to create.
|
||||
$scope.newServers = []
|
||||
|
||||
# Add a new server to be created.
|
||||
$scope.addServer = ->
|
||||
$scope.newServers.push {
|
||||
# Fake (unique) identifier needed by Angular.JS
|
||||
id: Math.random()
|
||||
}
|
||||
|
||||
# Saves any modifications.
|
||||
$scope.saveServers = ->
|
||||
servers = $scope.servers
|
||||
{servers, newServers} = $scope
|
||||
|
||||
# This will be the new list of servers with those marked to
|
||||
# delete removed.
|
||||
@@ -95,6 +134,22 @@ angular.module('xoWebApp')
|
||||
|
||||
updateServers.push server
|
||||
|
||||
for server in newServers
|
||||
{host, username, password} = server
|
||||
|
||||
# Required field.
|
||||
continue unless host
|
||||
|
||||
# Sends the order to XO-Server.
|
||||
xoApi.call 'server.add', {host, username, password}
|
||||
|
||||
# The password should not be displayed.
|
||||
delete server.password
|
||||
|
||||
# Adds the server to out local list.
|
||||
updateServers.push server
|
||||
|
||||
$scope.servers = updateServers
|
||||
$scope.newServers = []
|
||||
|
||||
# TODO: Retrieves an up to date servers list from the server.
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<!-- TODO: lots of stuff. -->
|
||||
<div class="grid">
|
||||
<div class="grid-cell flat-panel">
|
||||
<p class="page-title"><i class="fa fa-plus-circle"></i> Add server</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add server panel -->
|
||||
<div class="grid">
|
||||
<div class="grid-cell flat-panel">
|
||||
<p class="flat-panel-title"><i class="fa fa-link" style="color: #e25440;"></i> Server info</p>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fa fa-cloud fa-fw"></i></span>
|
||||
<input class="form-control" name="host" placeholder="Enter hostname or IP address" type="text">
|
||||
</div>
|
||||
<br/><br/>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fa fa-user fa-fw"></i></span>
|
||||
<input class="form-control" name="username" placeholder="Enter user" type="text">
|
||||
</div>
|
||||
<br/>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
|
||||
<input class="form-control" name="password" placeholder="Enter password" type="password">
|
||||
</div>
|
||||
<br/>
|
||||
<p class="text-center"><a class="btn btn-primary big"><i class="fa fa-times"></i> Clear</a> <a class="btn btn-success big"><i class="fa fa-save"></i> Save</a></p>
|
||||
</div>
|
||||
<div class="grid-cell flat-panel">
|
||||
<p class="flat-panel-title"><i class="fa fa-lightbulb-o" style="color: #e25440;"></i> Notice</p>
|
||||
<ul>
|
||||
<li>You can connect to any XAPI host (XenServer or XAPI enabled host).</li>
|
||||
<li>If you don't know which credentials uses, provide root credentials (e.g for XenServer, it's user "root" and your root password given during installation).</li>
|
||||
<li>XO manage to find automatically the pool master, so you can connect to any host in a existing pool</li>
|
||||
<li>Xen Orchestra is <strong>not</strong> compatible with XL toolstack</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,39 +0,0 @@
|
||||
<!-- TODO: lots of stuff. -->
|
||||
<div class="grid">
|
||||
<div class="grid-cell flat-panel">
|
||||
<p class="page-title"><i class="fa fa-plus-circle"></i> Add user</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add server panel -->
|
||||
<div class="grid">
|
||||
<div class="grid-cell flat-panel">
|
||||
<p class="flat-panel-title"><i class="fa fa-user" style="color: #e25440;"></i> User info</p>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fa fa-user fa-fw"></i></span>
|
||||
<input class="form-control" name="username" placeholder="Enter user" type="text">
|
||||
</div>
|
||||
<br/>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
|
||||
<input class="form-control" name="password" placeholder="Enter password" type="password">
|
||||
</div>
|
||||
<br/>
|
||||
<select class="form-control input-sm">
|
||||
<option>Admin</option>
|
||||
<option>Write</option>
|
||||
<option>Read</option>
|
||||
</select>
|
||||
<br/>
|
||||
<p class="text-center"><a class="btn btn-primary big"><i class="fa fa-times"></i> Clear</a> <a class="btn btn-success big"><i class="fa fa-save"></i> Save</a></p>
|
||||
</div>
|
||||
<div class="grid-cell flat-panel">
|
||||
<p class="flat-panel-title"><i class="fa fa-lightbulb-o" style="color: #e25440;"></i> Notice</p>
|
||||
<ul>
|
||||
<li>Users are only created in Xen Orchestra, not in XAPI</li>
|
||||
<li>"Admin" user can do everything (add/remove/edit other users, add or remove servers etc.)</li>
|
||||
<li>"Write" permissions are the same as "Admin" without the possibily to modify other users</li>
|
||||
<li>"Read" allows to see everything without any rights to modify</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -23,14 +23,20 @@
|
||||
<td><input type="password" ng-model="server.password" class="form-control"/></td>
|
||||
<td><input type="checkbox" ng-model="selectedServers[server.id]"/></td>
|
||||
</tr>
|
||||
<tr ng-repeat="server in newServers">
|
||||
<td><input type="text" ng-model="server.host" class="form-control"/></td>
|
||||
<td><input type="text" ng-model="server.username" class="form-control"/></td>
|
||||
<td><input type="password" ng-model="server.password" class="form-control"/></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="text-center">
|
||||
<button type="submit" class="btn btn-primary big">
|
||||
<i class="fa fa-save"></i> Save
|
||||
</button>
|
||||
<a class="btn btn-success big" ui-sref="servers_new">
|
||||
<button type="button" class="btn btn-success big" ng-click="addServer()">
|
||||
<i class="fa fa-plus-circle"></i> Add new server
|
||||
</a>
|
||||
</button>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
@@ -57,14 +63,27 @@
|
||||
<td><input type="password" ng-model="user.password" class="form-control"/></td>
|
||||
<td><input type="checkbox" ng-model="selectedUsers[user.id]" /></td>
|
||||
</tr>
|
||||
<tr ng-repeat="user in newUsers">
|
||||
<td><input type="text" ng-model="user.email" class="form-control"/></td>
|
||||
<td>
|
||||
<select
|
||||
ng-options="p.value as p.label for p in permissions"
|
||||
ng-model="user.permission"
|
||||
class="form-control"
|
||||
>
|
||||
</select>
|
||||
</td>
|
||||
<td><input type="password" ng-model="user.password" class="form-control"/></td>
|
||||
<td><input type="checkbox" ng-model="selectedUsers[user.id]" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="text-center">
|
||||
<button type="submit" class="btn btn-primary big">
|
||||
<i class="fa fa-save"></i> Save
|
||||
</button>
|
||||
<a class="btn btn-success big" ui-sref="users_new">
|
||||
<button type="button" class="btn btn-success big" ng-click="addUser()">
|
||||
<i class="fa fa-plus-circle"></i> Add new user
|
||||
</a>
|
||||
</button>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user