Skip to content
Snippets Groups Projects
Commit 717c3e61 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #12073 TIME 1:30 add priv history + switch mode full / actions

parent cbd3af4b
No related branches found
No related tags found
No related merge requests found
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
</mat-autocomplete> </mat-autocomplete>
</mat-form-field> </mat-form-field>
</div> </div>
<button color="primary" mat-icon-button title="Afficher tout l'historique"> <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 fa-history"></mat-icon> <mat-icon class="fas" [class.fa-exchange-alt]="fullHistoryMode" [class.fa-history]="!fullHistoryMode"></mat-icon>
</button> </button>
<div class="table-head-tool"> <div class="table-head-tool">
<mat-paginator #paginatorHistoryList [length]="resultsLength" [hidePageSize]="true" [pageSize]="10" <mat-paginator #paginatorHistoryList [length]="resultsLength" [hidePageSize]="true" [pageSize]="10"
......
...@@ -9,6 +9,7 @@ import { takeUntil, startWith, switchMap, map, catchError, filter, exhaustMap, t ...@@ -9,6 +9,7 @@ import { takeUntil, startWith, switchMap, map, catchError, filter, exhaustMap, t
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { FunctionsService } from '../../service/functions.service'; import { FunctionsService } from '../../service/functions.service';
import { LatinisePipe } from 'ngx-pipes'; import { LatinisePipe } from 'ngx-pipes';
import { PrivilegeService } from '../../service/privileges.service';
@Component({ @Component({
selector: 'app-history-list', selector: 'app-history-list',
...@@ -20,6 +21,8 @@ export class HistoryComponent implements OnInit { ...@@ -20,6 +21,8 @@ export class HistoryComponent implements OnInit {
lang: any = LANG; lang: any = LANG;
loading: boolean = false; loading: boolean = false;
fullHistoryMode : boolean = true;
filtersChange = new EventEmitter(); filtersChange = new EventEmitter();
data: any; data: any;
...@@ -28,6 +31,8 @@ export class HistoryComponent implements OnInit { ...@@ -28,6 +31,8 @@ export class HistoryComponent implements OnInit {
isLoadingResults = true; isLoadingResults = true;
routeUrl: string = '../../rest/history'; routeUrl: string = '../../rest/history';
filterListUrl: string = '../../rest/history/availableFilters';
extraParamUrl: string = '';
resultListDatabase: HistoryListHttpDao | null; resultListDatabase: HistoryListHttpDao | null;
resultsLength = 0; resultsLength = 0;
...@@ -63,20 +68,46 @@ export class HistoryComponent implements OnInit { ...@@ -63,20 +68,46 @@ export class HistoryComponent implements OnInit {
private headerService: HeaderService, private headerService: HeaderService,
public dialog: MatDialog, public dialog: MatDialog,
public functions: FunctionsService, public functions: FunctionsService,
private latinisePipe: LatinisePipe) { } private latinisePipe: LatinisePipe,
public privilegeService: PrivilegeService) { }
ngOnInit(): void { ngOnInit(): void {
if (this.resId !== null) { if (this.resId !== null) {
this.routeUrl = '../../rest/history';
this.displayedColumnsHistory = ['event_date', 'info']; this.displayedColumnsHistory = ['event_date', 'info'];
this.fullHistoryMode = !this.privilegeService.hasCurrentUserPrivilege('view_doc_history')
} else { } else {
this.routeUrl = '../../rest/history';
this.displayedColumnsHistory = ['event_date', 'userLabel', 'info', 'remote_ip']; this.displayedColumnsHistory = ['event_date', 'userLabel', 'info', 'remote_ip'];
} }
this.loading = true; this.loading = true;
this.initHistoryMode();
this.initHistoryList(); 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() { initHistoryList() {
this.resultListDatabase = new HistoryListHttpDao(this.http); this.resultListDatabase = new HistoryListHttpDao(this.http);
this.paginator.pageIndex = 0; this.paginator.pageIndex = 0;
...@@ -92,7 +123,7 @@ export class HistoryComponent implements OnInit { ...@@ -92,7 +123,7 @@ export class HistoryComponent implements OnInit {
switchMap(() => { switchMap(() => {
this.isLoadingResults = true; this.isLoadingResults = true;
return this.resultListDatabase!.getRepoIssues( 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 => { map(data => {
this.isLoadingResults = false; this.isLoadingResults = false;
...@@ -129,8 +160,10 @@ export class HistoryComponent implements OnInit { ...@@ -129,8 +160,10 @@ export class HistoryComponent implements OnInit {
if (this.filterList === null) { if (this.filterList === null) {
this.filterList = {}; this.filterList = {};
this.filterUsed = {};
this.filterUrl = '';
this.loadingFilters = true; this.loadingFilters = true;
this.http.get("../../rest/history/availableFilters").pipe( this.http.get(this.filterListUrl).pipe(
map((data: any) => { map((data: any) => {
let deletedActions = data.actions.filter((action: any) => action.label === null).map((action: any) => action.id); 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); let deletedUser = data.users.filter((user: any) => user.label === null).map((user: any) => user.login);
...@@ -269,10 +302,10 @@ export class HistoryListHttpDao { ...@@ -269,10 +302,10 @@ export class HistoryListHttpDao {
constructor(private http: HttpClient) { } 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; 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); return this.http.get<HistoryList>(requestUrl);
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<div class="processTool"> <div class="processTool">
<div class="processTool-module jiggle" *ngFor="let module of processTool" <div class="processTool-module jiggle" *ngFor="let module of processTool"
[class.processTool-module-active]="module.id === currentTool" matRipple [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 *ngIf="module.count > 0" class="fas fa-circle haveContent"></i>
<i [class]="module.icon"></i> <i [class]="module.icon"></i>
<span>{{module.label}}</span> <span>{{module.label}}</span>
......
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
color: $primary; color: $primary;
} }
&:hover { &:hover:not(.tool-disabled) {
transition: all 0.3s; transition: all 0.3s;
color: $primary; color: $primary;
} }
...@@ -313,7 +313,7 @@ ...@@ -313,7 +313,7 @@
} }
} }
.jiggle:active { .jiggle:active:not(.tool-disabled) {
i { i {
-webkit-animation: jiggle 0.2s; -webkit-animation: jiggle 0.2s;
-moz-animation-duration: 0.2s; -moz-animation-duration: 0.2s;
...@@ -414,3 +414,8 @@ ...@@ -414,3 +414,8 @@
.followIcon { .followIcon {
color: $secondary; color: $secondary;
} }
.tool-disabled {
cursor: not-allowed;
opacity: 0.3;
}
\ No newline at end of file
...@@ -583,4 +583,16 @@ export class ProcessComponent implements OnInit { ...@@ -583,4 +583,16 @@ export class ProcessComponent implements OnInit {
).subscribe(); ).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;
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment