diff --git a/src/frontend/app/history/history.component.html b/src/frontend/app/history/history.component.html index 8d1daff3c812430b88adbd24eee6d8b782553181..711fdcef1d6d7fe846432bf22549372fec328727 100644 --- a/src/frontend/app/history/history.component.html +++ b/src/frontend/app/history/history.component.html @@ -28,8 +28,8 @@ </mat-autocomplete> </mat-form-field> </div> - <button color="primary" mat-icon-button title="Afficher tout l'historique"> - <mat-icon class="fas fa-history"></mat-icon> + <button *ngIf="privilegeService.hasCurrentUserPrivilege('view_full_history') && privilegeService.hasCurrentUserPrivilege('view_doc_history')" color="primary" mat-icon-button [title]="!fullHistoryMode ? 'Afficher tout l\'historique' : 'Afficher l\'historique des actions'" (click)="switchHistoryMode()"> + <mat-icon class="fas" [class.fa-exchange-alt]="fullHistoryMode" [class.fa-history]="!fullHistoryMode"></mat-icon> </button> <div class="table-head-tool"> <mat-paginator #paginatorHistoryList [length]="resultsLength" [hidePageSize]="true" [pageSize]="10" diff --git a/src/frontend/app/history/history.component.ts b/src/frontend/app/history/history.component.ts index de89a606fcae718b5a0acf8b4b70a3da8860c861..fccf8fdee7ead4b78aee3bfb9f2c99766b2807cc 100644 --- a/src/frontend/app/history/history.component.ts +++ b/src/frontend/app/history/history.component.ts @@ -9,6 +9,7 @@ import { takeUntil, startWith, switchMap, map, catchError, filter, exhaustMap, t import { FormControl } from '@angular/forms'; import { FunctionsService } from '../../service/functions.service'; import { LatinisePipe } from 'ngx-pipes'; +import { PrivilegeService } from '../../service/privileges.service'; @Component({ selector: 'app-history-list', @@ -20,6 +21,8 @@ export class HistoryComponent implements OnInit { lang: any = LANG; loading: boolean = false; + fullHistoryMode : boolean = true; + filtersChange = new EventEmitter(); data: any; @@ -28,6 +31,8 @@ export class HistoryComponent implements OnInit { isLoadingResults = true; routeUrl: string = '../../rest/history'; + filterListUrl: string = '../../rest/history/availableFilters'; + extraParamUrl: string = ''; resultListDatabase: HistoryListHttpDao | null; resultsLength = 0; @@ -63,20 +68,46 @@ export class HistoryComponent implements OnInit { private headerService: HeaderService, public dialog: MatDialog, public functions: FunctionsService, - private latinisePipe: LatinisePipe) { } + private latinisePipe: LatinisePipe, + public privilegeService: PrivilegeService) { } ngOnInit(): void { if (this.resId !== null) { - this.routeUrl = '../../rest/history'; this.displayedColumnsHistory = ['event_date', 'info']; + this.fullHistoryMode = !this.privilegeService.hasCurrentUserPrivilege('view_doc_history') } else { - this.routeUrl = '../../rest/history'; this.displayedColumnsHistory = ['event_date', 'userLabel', 'info', 'remote_ip']; } this.loading = true; + this.initHistoryMode(); this.initHistoryList(); } + switchHistoryMode() { + this.fullHistoryMode = !this.fullHistoryMode; + this.initHistoryMode(); + this.refreshDao(); + } + + resetFilter() { + this.loadingFilters = true; + this.filterList = null; + this.filterUsed = {}; + this.filterUrl = ''; + } + + initHistoryMode() { + this.resetFilter(); + + if (this.fullHistoryMode) { + this.extraParamUrl = this.resId !== null ? `&resId=${this.resId}` : ''; + this.filterListUrl = this.resId !== null ? `../../rest/history/availableFilters?resId=${this.resId}` : '../../rest/history/availableFilters'; + } else { + this.extraParamUrl = this.resId !== null ? `&resId=${this.resId}&onlyActions=true` : '&onlyActions=true'; + this.filterListUrl = this.resId !== null ? `../../rest/history/availableFilters?resId=${this.resId}&onlyActions=true` : '../../rest/history/availableFilters?onlyActions=true'; + } + } + initHistoryList() { this.resultListDatabase = new HistoryListHttpDao(this.http); this.paginator.pageIndex = 0; @@ -92,7 +123,7 @@ export class HistoryComponent implements OnInit { switchMap(() => { this.isLoadingResults = true; return this.resultListDatabase!.getRepoIssues( - this.sort.active, this.sort.direction, this.paginator.pageIndex, this.routeUrl, this.filterUrl); + this.sort.active, this.sort.direction, this.paginator.pageIndex, this.routeUrl, this.filterUrl, this.extraParamUrl); }), map(data => { this.isLoadingResults = false; @@ -129,8 +160,10 @@ export class HistoryComponent implements OnInit { if (this.filterList === null) { this.filterList = {}; + this.filterUsed = {}; + this.filterUrl = ''; this.loadingFilters = true; - this.http.get("../../rest/history/availableFilters").pipe( + this.http.get(this.filterListUrl).pipe( map((data: any) => { let deletedActions = data.actions.filter((action: any) => action.label === null).map((action: any) => action.id); let deletedUser = data.users.filter((user: any) => user.label === null).map((user: any) => user.login); @@ -269,10 +302,10 @@ export class HistoryListHttpDao { constructor(private http: HttpClient) { } - getRepoIssues(sort: string, order: string, page: number, href: string, search: string): Observable<HistoryList> { + getRepoIssues(sort: string, order: string, page: number, href: string, search: string, extraParamUrl: string): Observable<HistoryList> { let offset = page * 10; - const requestUrl = `${href}?limit=10&offset=${offset}&order=${order}&orderBy=${sort}${search}`; + const requestUrl = `${href}?limit=10&offset=${offset}&order=${order}&orderBy=${sort}${search}${extraParamUrl}`; return this.http.get<HistoryList>(requestUrl); } diff --git a/src/frontend/app/process/process.component.html b/src/frontend/app/process/process.component.html index 5f699b615449ce47d5b43e52b92ce69a5ca4f287..a0ea7c176e80ba050351b07c92552312b92026a4 100644 --- a/src/frontend/app/process/process.component.html +++ b/src/frontend/app/process/process.component.html @@ -9,7 +9,7 @@ <div class="processTool"> <div class="processTool-module jiggle" *ngFor="let module of processTool" [class.processTool-module-active]="module.id === currentTool" matRipple - (click)="changeTab(module.id)"> + (click)="isToolEnabled(module.id) ? changeTab(module.id) : false" [class.tool-disabled]="!isToolEnabled(module.id)"> <i *ngIf="module.count > 0" class="fas fa-circle haveContent"></i> <i [class]="module.icon"></i> <span>{{module.label}}</span> diff --git a/src/frontend/app/process/process.component.scss b/src/frontend/app/process/process.component.scss index e30a811f4559ffe95c99a9746b4beb7cfacdd2c1..f4b76d41836fb20d6df06c537c9fad66a01de7cf 100644 --- a/src/frontend/app/process/process.component.scss +++ b/src/frontend/app/process/process.component.scss @@ -287,7 +287,7 @@ color: $primary; } - &:hover { + &:hover:not(.tool-disabled) { transition: all 0.3s; color: $primary; } @@ -313,7 +313,7 @@ } } -.jiggle:active { +.jiggle:active:not(.tool-disabled) { i { -webkit-animation: jiggle 0.2s; -moz-animation-duration: 0.2s; @@ -414,3 +414,8 @@ .followIcon { color: $secondary; } + +.tool-disabled { + cursor: not-allowed; + opacity: 0.3; +} \ No newline at end of file diff --git a/src/frontend/app/process/process.component.ts b/src/frontend/app/process/process.component.ts index 5ef4c40a4693685f074092a1ad88d34e017129ff..ae92d4baa6dd3198c339da9ad62e747c6c8f15d1 100755 --- a/src/frontend/app/process/process.component.ts +++ b/src/frontend/app/process/process.component.ts @@ -583,4 +583,16 @@ export class ProcessComponent implements OnInit { ).subscribe(); } } + + isToolEnabled(id: string) { + if (id === 'history') { + if (!this.privilegeService.hasCurrentUserPrivilege('view_full_history') && !this.privilegeService.hasCurrentUserPrivilege('view_doc_history')) { + return false + } else { + return true; + } + } else { + return true; + } + } }