]> source.dussan.org Git - archiva.git/blob
cd1e9b0b90084266c0c5ec07b66f88b8d48dc2ae
[archiva.git] /
1 <!--
2   ~ Licensed to the Apache Software Foundation (ASF) under one
3   ~ or more contributor license agreements.  See the NOTICE file
4   ~ distributed with this work for additional information
5   ~ regarding copyright ownership.  The ASF licenses this file
6   ~ to you under the Apache License, Version 2.0 (the
7   ~ "License"); you may not use this file except in compliance
8   ~ with the License.  You may obtain a copy of the License at
9   ~
10   ~ http://www.apache.org/licenses/LICENSE-2.0
11   ~ Unless required by applicable law or agreed to in writing,
12   ~ software distributed under the License is distributed on an
13   ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14   ~ KIND, either express or implied.  See the License for the
15   ~ specific language governing permissions and limitations
16   ~ under the License.
17   -->
18
19 <form class="mt-3 mb-3" [formGroup]="userForm" (ngSubmit)="onSubmit()">
20     <div class="form-group row col-md-8">
21         <div class="col-md-2 col-form-label">{{'form.edit' |translate}}&nbsp;<span
22                 class="fas fa-edit"></span></div>
23         <div class="col-md-6">
24             <input class="form-check-input" type="checkbox" [value]="editMode" [checked]="editMode"
25                    (change)="editMode=!editMode"
26             >
27         </div>
28     </div>
29     <div class="form-group row col-md-8">
30         <label class="col-md-2 col-form-label" for="id">{{'roles.attributes.id' |translate}}</label>
31         <div class="col-md-6">
32             <input type="text" formControlName="id" id="id" class="form-control-plaintext"
33                    [attr.readonly]="true">
34         </div>
35     </div>
36     <div class="form-group row col-md-8">
37         <label class="col-md-2 col-form-label" for="id">{{'roles.attributes.name' |translate}}</label>
38         <div class="col-md-6">
39             <input type="text" formControlName="name" id="name"
40                    class="form-control-plaintext"
41                    [attr.readonly]="true">
42         </div>
43     </div>
44     <div class="form-group row col-md-8">
45         <label class="col-md-2 col-form-label" for="id">{{'roles.attributes.description' |translate}}</label>
46         <div class="col-md-6">
47             <input type="text" formControlName="description" id="description"
48                    [ngClass]="valid('description')"
49                    [attr.readonly]="editMode?null:'true'">
50         </div>
51     </div>
52     <div class="form-group row col-md-8">
53         <label class="col-md-2 col-form-label" for="id">{{'roles.attributes.resource' |translate}}</label>
54         <div class="col-md-6">
55             <input type="text" formControlName="resource" id="resource" class="form-control-plaintext"
56                    [attr.readonly]="true">
57         </div>
58     </div>
59     <div class="form-group row col-md-8">
60         <div class="col-md-2"></div>
61         <div class="col-md-4">
62             <div class="form-check">
63                 <input class="form-check-input" type="checkbox" formControlName="assignable"
64                        id="assignable" [attr.disabled]="true">
65                 <label class="form-check-label " for="assignable">
66                     {{'roles.attributes.assignable'|translate}}
67                 </label>
68             </div>
69             <div class="form-check">
70                 <input class="form-check-input" type="checkbox" formControlName="template_instance"
71                        id="template_instance" [attr.disabled]="true">
72                 <label class="form-check-label " for="template_instance">
73                     {{'roles.attributes.template_instance'|translate}}
74                 </label>
75             </div>
76         </div>
77         <div class="col-md-3" *ngIf="editMode">
78             <button class="btn btn-primary" type="submit"
79                     [disabled]="userForm.invalid || !userForm.dirty">{{'form.button.save'|translate}}</button>
80         </div>
81     </div>
82 </form>
83 <hr/>
84 <ngb-accordion activeIds="">
85     <ngb-panel id="parents">
86         <ng-template ngbPanelHeader let-opened="opened">
87             <div class="d-flex align-items-center justify-content-between">
88                 <button ngbPanelToggle class="btn btn-link text-left shadow-none">
89                     <h3>{{'roles.edit.parents'|translate}}</h3></button>
90                 <ng-container *ngIf="!opened"><i class="fa fa-eye-slash"></i></ng-container>
91                 <ng-container *ngIf="opened"><i class="fa fa-eye"></i></ng-container>
92             </div>
93         </ng-template>
94         <ng-template ngbPanelContent>
95             <ng-container *ngIf="editRole?.parents.length>0">
96                 <ul class="list-group" *ngFor="let parentRole of editRole?.parents">
97                     <li class="list-group-item"><a routerLink="../{{parentRole?.id}}">{{parentRole?.name}}</a></li>
98                 </ul>
99             </ng-container>
100         </ng-template>
101     </ngb-panel>
102     <ngb-panel id="children">
103         <ng-template ngbPanelHeader let-opened="opened">
104             <div class="d-flex align-items-center justify-content-between">
105                 <button ngbPanelToggle class="btn btn-link text-left shadow-none">
106                     <h3>{{'roles.edit.children'|translate}}</h3></button>
107                 <ng-container *ngIf="!opened"><i class="fa fa-eye-slash"></i></ng-container>
108                 <ng-container *ngIf="opened"><i class="fa fa-eye"></i></ng-container>
109             </div>
110         </ng-template>
111         <ng-template ngbPanelContent>
112             <ng-container *ngIf="editRole?.children.length>0">
113                 <ul class="list-group" *ngFor="let childRole of editRole?.children">
114                     <li class="list-group-item"><a routerLink="../{{childRole?.id}}">{{childRole?.name}}</a></li>
115                 </ul>
116             </ng-container>
117         </ng-template>
118     </ngb-panel>
119
120     <ngb-panel id="permissions">
121         <ng-template ngbPanelHeader let-opened="opened">
122             <div class="d-flex align-items-center justify-content-between">
123
124                 <button ngbPanelToggle class="btn btn-link text-left shadow-none">
125                     <h3>{{'roles.edit.permissions'|translate}}</h3></button>
126                 <ng-container *ngIf="!opened"><i class="fa fa-eye-slash"></i></ng-container>
127                 <ng-container *ngIf="opened"><i class="fa fa-eye"></i></ng-container>
128             </div>
129         </ng-template>
130         <ng-template ngbPanelContent>
131             <ng-container *ngIf="editRole">
132                 <table class="table">
133                     <thead>
134                     <tr>
135                         <th>{{'permissions.attributes.permission'|translate}}</th>
136                         <th>{{'permissions.attributes.operation'|translate}}</th>
137                         <th>{{'permissions.attributes.resource'|translate}}</th>
138                     </tr>
139                     </thead>
140                     <tbody *ngFor="let perm of editRole.permissions">
141                     <tr>
142                         <td>{{perm.name}}</td>
143                         <td>{{perm.operation.name}}</td>
144                         <td>{{perm.resource.identifier}}</td>
145                     </tr>
146                     </tbody>
147
148                 </table>
149             </ng-container>
150         </ng-template>
151     </ngb-panel>
152
153     <ngb-panel>
154         <ng-template ngbPanelHeader let-opened="opened">
155             <div class="d-flex align-items-center justify-content-between">
156                 <button ngbPanelToggle class="btn btn-link text-left shadow-none">
157                     <h3>{{'roles.edit.users'|translate}}</h3></button>
158                 <ng-container *ngIf="!opened"><i class="fa fa-eye-slash"></i></ng-container>
159                 <ng-container *ngIf="opened"><i class="fa fa-eye"></i></ng-container>
160             </div>
161         </ng-template>
162         <ng-template ngbPanelContent>
163             <h4>{{'roles.edit.usersParents'|translate}}</h4>
164             <app-paginated-entities [service]="roleUserParentService" pageSize="5" [(sortField)]="userParentSortField"
165                                     [(sortOrder)]="userParentSortOrder" [displayControlsIfSinglePage]="false"
166                                     [id]="'userParentSection'"
167                                     #userParentSection>
168
169                 <ng-container *ngIf="userParentSection.items$ |async as itemLoader">
170                     <ng-template [ngIf]="itemLoader.loading">
171                         <div class="spinner-border text-primary" role="status">
172                             <span class="sr-only">Loading...</span>
173                         </div>
174                     </ng-template>
175                 </ng-container>
176                 <ng-container *ngIf="userParentSection.items$ |stripLoading|async as userItem">
177                     <table class="table table-striped table-bordered">
178                         <thead class="thead-light">
179                         <tr sorted [sortFieldEmitter]="userParentSection.sortFieldChange"
180                             [sortOrderEmitter]="userParentSection.sortOrderChange"
181                             [toggleObserver]="userParentSection">
182                             <app-th-sorted [fieldArray]="['user_id']"
183                                            contentText="users.attributes.user_id"></app-th-sorted>
184                             <app-th-sorted [fieldArray]="['full_name']"
185                                            contentText="users.attributes.full_name"></app-th-sorted>
186                         </tr>
187                         </thead>
188                         <tbody>
189                         <tr *ngFor="let user  of userItem.data">
190                             <td><span data-toggle="tooltip" placement="left"
191                                       ngbTooltip="{{user.id}}">{{user.user_id}}</span>
192                             </td>
193                             <td>{{user.full_name}}</td>
194                         </tr>
195                         </tbody>
196                     </table>
197                 </ng-container>
198             </app-paginated-entities>
199             <hr/>
200             <h4>{{'roles.edit.usersInstance'|translate}}</h4>
201             <app-paginated-entities [service]="roleUserService" pageSize="5" [(sortField)]="userSortField"
202                                     [id]="'userSection'"
203                                     [(sortOrder)]="userSortOrder"
204                                     [displayIfEmpty]="false" [displayKeyIfEmpty]="'roles.edit.noUsersAssigned'"
205                                     [displayControlsIfSinglePage]="false"
206                                     #userSection>
207
208                 <ng-container *ngIf="userSection.items$ |async as itemLoader">
209                     <ng-template [ngIf]="itemLoader.loading">
210                         <div class="spinner-border text-primary" role="status">
211                             <span class="sr-only">Loading...</span>
212                         </div>
213                     </ng-template>
214                 </ng-container>
215                 <ng-container *ngIf="userSection.items$ |stripLoading|async as userItem">
216                     <table class="table table-striped table-bordered">
217                         <thead class="thead-light">
218                         <tr sorted [sortFieldEmitter]="userSection.sortFieldChange"
219                             [sortOrderEmitter]="userSection.sortOrderChange"
220                             [toggleObserver]="userSection">
221                             <app-th-sorted [fieldArray]="['user_id']"
222                                            contentText="users.attributes.user_id"></app-th-sorted>
223                             <app-th-sorted [fieldArray]="['full_name']"
224                                            contentText="users.attributes.full_name"></app-th-sorted>
225                             <th>{{'headers.action'|translate}}</th>
226                         </tr>
227                         </thead>
228                         <tbody>
229                         <tr *ngFor="let user  of userItem.data">
230                             <td><span data-toggle="tooltip" placement="left"
231                                       ngbTooltip="{{user.id}}">{{user.user_id}}</span>
232                             </td>
233                             <td>{{user.full_name}}</td>
234                             <td><a href="javascript: void(0)" (click)="unassignUser(user.user_id)"><span
235                                     class="fas fa-user-minus"></span></a></td>
236                         </tr>
237                         </tbody>
238                     </table>
239                 </ng-container>
240             </app-paginated-entities>
241             <hr/>
242             <form class="mt-2">
243                 <ng-template #userResultTemplate let-r="result" let-t="term">
244                     <ngb-highlight [result]="r.user_id + ' - ' + r.full_name" [term]="t"></ngb-highlight>
245                 </ng-template>
246                 <div class="form-group">
247                     <label for="typeahead-http">{{'roles.edit.assignUserSearch'|translate}}</label>
248                     <input id="typeahead-http" type="text" class="form-control col-md-2"
249                            name="userSearchField"
250                            [class.is-invalid]="userSearchFailed" [resultTemplate]="userResultTemplate"
251                            [inputFormatter]="getUserId"
252                            [placement]="'top'"
253                            [(ngModel)]="userSearchModel" [ngbTypeahead]="searchUser" placeholder="User Search"/>
254                     <small *ngIf="userSearching"
255                            class="form-text text-muted">{{'form.searching'  |translate}}</small>
256                     <div class="invalid-feedback"
257                          *ngIf="userSearchFailed">{{'roles.edit.userSearchFailed'|translate}}</div>
258                 </div>
259                 <button class="btn btn-primary" (click)="assignUserRole()">{{'roles.edit.assignButton'|translate}}</button>
260             </form>
261
262         </ng-template>
263         <div *ngIf="success">
264             Success
265         </div>
266         <div *ngIf="error">
267             <div>Error {{errorResult.error_messages}}</div>
268         </div>
269     </ngb-panel>
270
271 </ngb-accordion>