Verified Commit 66da1a22 authored by Alex ORLUC's avatar Alex ORLUC

FEAT #11296 TIME 1:20 add current user info in guard + end folder filters

parent 606b72c8
......@@ -25,7 +25,7 @@
<div class="bg-head-content" [class.fullContainer]="appService.getViewMode()">
<app-filters-tool style="flex:1;overflow-x: auto;overflow-y: hidden;" #filtersTool
[listProperties]="this.listProperties" [snavR]="snav2" [totalRes]="allResInBasket.length"
[selectedRes]="selectedRes" [routeDatas]="'/rest/folders/' + folderInfo.id + '/resources/filters'" (toggleAllRes)="toggleAllRes($event)"
[selectedRes]="selectedRes" [routeDatas]="'/rest/folders/' + folderInfo.id + '/filters'" (toggleAllRes)="toggleAllRes($event)"
(refreshEventAfterAction)="refreshDaoAfterAction()" (refreshEvent)="refreshDao()" [title]="lang.searchMailInFolder">
</app-filters-tool>
</div>
......
......@@ -145,7 +145,7 @@ export class FolderDocumentListComponent implements OnInit {
window['MainHeaderComponent'].setSnav(this.sidenavLeft);
window['MainHeaderComponent'].setSnavRight(null);
this.listProperties = this.filtersListService.initListsProperties(this.headerService.user.id, 0, this.folderInfo.id, 'folder');
this.listProperties = this.filtersListService.initListsProperties(this.headerService.user.id, 0, params['folderId'], 'folder');
setTimeout(() => {
this.dragInit = false;
......@@ -163,7 +163,7 @@ export class FolderDocumentListComponent implements OnInit {
}
initResultList() {
this.resultListDatabase = new ResultListHttpDao(this.http);
this.resultListDatabase = new ResultListHttpDao(this.http, this.filtersListService);
// If the user changes the sort order, reset back to the first page.
this.paginator.pageIndex = this.listProperties.page;
this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0);
......@@ -176,7 +176,7 @@ export class FolderDocumentListComponent implements OnInit {
switchMap(() => {
this.isLoadingResults = true;
return this.resultListDatabase!.getRepoIssues(
this.sort.active, this.sort.direction, this.paginator.pageIndex, this.basketUrl);
this.sort.active, this.sort.direction, this.paginator.pageIndex, this.basketUrl, this.filtersListService.getUrlFilters());
}),
map(data => {
// Flip flag to show that loading has finished.
......@@ -197,6 +197,7 @@ export class FolderDocumentListComponent implements OnInit {
}
goTo(row: any) {
this.filtersListService.filterMode = false;
if (this.docUrl == '../../rest/res/' + row.res_id + '/content' && this.sidenavRight.opened) {
this.sidenavRight.close();
} else {
......@@ -337,11 +338,12 @@ export interface BasketList {
export class ResultListHttpDao {
constructor(private http: HttpClient) { }
constructor(private http: HttpClient, private filtersListService: FiltersListService) { }
getRepoIssues(sort: string, order: string, page: number, href: string): Observable<BasketList> {
getRepoIssues(sort: string, order: string, page: number, href: string, filters: string): Observable<BasketList> {
this.filtersListService.updateListsPropertiesPage(page);
let offset = page * 10;
const requestUrl = `${href}?limit=10&offset=${offset}`;
const requestUrl = `${href}?limit=10&offset=${offset}${filters}`;
return this.http.get<BasketList>(requestUrl);
}
......
......@@ -4,5 +4,6 @@
<i class="fa fa-folder"></i>&nbsp;{{lang.folders}}
</mat-panel-title>
</mat-expansion-panel-header>
<plugin-autocomplete [labelPlaceholder]="lang.search" [labelList]="lang.search" [routeDatas]="['/rest/folders']" [targetSearchKey]="'label'" (triggerEvent)="linkUser($event)"></plugin-autocomplete>
<folder-tree #folderTree [selectedId]="id" (refreshDocList)="refreshDocList()"></folder-tree>
</mat-expansion-panel>
......@@ -2,19 +2,40 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { HeaderService } from './header.service';
@Injectable({
providedIn: 'root'
})
export class AppGuard implements CanActivate {
constructor(public http: HttpClient, private router: Router) { }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
constructor(public http: HttpClient,
private router: Router,
public headerService: HeaderService) { }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
// TO DO : CAN BE REMOVE AFTER FULL V2
localStorage.setItem('PreviousV2Route', state.url);
return true;
if (this.headerService.user.id === undefined) {
return this.http.get('../../rest/currentUser/profile')
.pipe(
map((data: any) => {
this.headerService.user = {
id : data.id,
userId : data.user_id,
firstname : data.firstname,
lastname: data.lastname,
entities: data.entities,
groups: data.groups
}
return true;
})
);
} else {
return true;
}
}
}
......@@ -7,6 +7,8 @@ export class AppService {
private _mobileQueryListener : () => void;
mobileQuery : MediaQueryList;
currentUser: any;
constructor(changeDetectorRef: ChangeDetectorRef, media: MediaMatcher) {
this.mobileQuery = media.matchMedia('(max-width: 768px)');
this._mobileQueryListener = () => changeDetectorRef.detectChanges();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment