You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

manage-roles-edit.component.html 14KB

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