2016-04-26 21:10:05 +08:00
|
|
|
<app-frame>
|
2016-05-01 16:28:05 +08:00
|
|
|
<div class="container">
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<h3 class="panel-title">User management</h3>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body">
|
2016-05-03 20:29:24 +08:00
|
|
|
|
|
|
|
<table class="table table-hover">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Role</th>
|
|
|
|
<th></th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tr *ngFor="let user of users">
|
|
|
|
<td>{{user.name}}</td>
|
|
|
|
<td *ngIf="canModifyUser(user)">
|
|
|
|
<select class="form-control" [(ngModel)]="user.role" (ngModelChange)="updateRole(user)" required>
|
|
|
|
<option *ngFor="let repository of userRoles" [value]="repository.key">
|
|
|
|
{{repository.value}}
|
|
|
|
</option>
|
|
|
|
</select>
|
|
|
|
</td>
|
|
|
|
<td *ngIf="!canModifyUser(user)">
|
|
|
|
{{user.role | stringifyRole}}
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<button *ngIf="canModifyUser(user)" (click)="deleteUser(user)"
|
|
|
|
class="btn btn-danger pull-right">
|
|
|
|
<span class="glyphicon glyphicon-trash" aria-hidden="true" aria-label="Delete"></span>
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<button class="btn btn-default pull-right" data-toggle="modal" data-target="#myModal"
|
|
|
|
(click)="initNewUser()">+ Add
|
2016-05-02 03:30:43 +08:00
|
|
|
user
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Modal -->
|
|
|
|
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
|
|
|
<div class="modal-dialog" role="document">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
|
|
|
|
aria-hidden="true">×</span></button>
|
|
|
|
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
|
|
|
|
</div>
|
|
|
|
<form (ngSubmit)="onSubmit()" #NewUserForm="ngForm">
|
|
|
|
<div class="modal-body">
|
|
|
|
<input type="text" class="form-control" placeholder="Username" autofocus
|
|
|
|
[(ngModel)]="newUser.name" ngControl="name" #name="ngForm" required>
|
|
|
|
<input type="password" class="form-control" placeholder="Password"
|
|
|
|
[(ngModel)]="newUser.password" ngControl="password" #name="ngForm" required>
|
|
|
|
<select class="form-control" [(ngModel)]="newUser.role" required>
|
|
|
|
<option *ngFor="let repository of userRoles" [value]="repository.key">{{repository.value}}
|
|
|
|
</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
|
|
|
<button type="button" class="btn btn-primary" data-dismiss="modal"
|
|
|
|
(click)="addNewUser()"
|
|
|
|
[disabled]="!NewUserForm.form.valid">Add User
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
2016-05-01 16:28:05 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-04-26 21:10:05 +08:00
|
|
|
</app-frame>
|