Newer
Older
import { ChangeDetectorRef, Component, OnInit, ViewChild, Inject, EventEmitter, Output } from '@angular/core';
import { MediaMatcher } from '@angular/cdk/layout';
import { HttpClient } from '@angular/common/http';
import { LANG } from '../translate.component';
import { merge, Observable, of as observableOf } from 'rxjs';
import { NotificationService } from '../notification.service';
import { MatDialog, MatSidenav, MatPaginator, MatSort, MatBottomSheet, MatBottomSheetRef, MAT_BOTTOM_SHEET_DATA, MatButtonToggleGroup } from '@angular/material';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { startWith, switchMap, map, catchError } from 'rxjs/operators';
import { ActivatedRoute } from '@angular/router';
import { HeaderService } from '../../service/header.service';
import { FiltersListService } from '../../service/filtersList.service';
declare function $j(selector: any): any;
declare var angularGlobals: any;
@Component({
templateUrl: "basket-list.component.html",
styleUrls: ['basket-list.component.scss'],
providers: [NotificationService]
})
export class BasketListComponent implements OnInit {
private _mobileQueryListener: () => void;
mobileQuery: MediaQueryList;
coreUrl: string;
lang: any = LANG;
loading: boolean = false;
public innerHtml: SafeHtml;
basketUrl: string;
homeData: any;
@ViewChild('snav') sidenavLeft: MatSidenav;
@ViewChild('snav2') sidenavRight: MatSidenav;
displayedColumnsBasket: string[] = ['res_id'];
displayedMainData: any = [
{
'id': 'alt_identifier',
'class': 'softColorData centerData',
'icon': ''
'id': 'subject',
'class': 'longData',
'icon': ''
displayedSecondaryData: any = [];
// displayedSecondaryData: any = [
// {
// 'id' : 'priority_label',
// 'class' : '',
// 'icon' : ''
// },
// {
// 'id' : 'category_id',
// 'class' : '',
// 'icon' : ''
// },
// {
// 'id' : 'doctype_label',
// 'class' : '',
// 'icon' : 'fa fa-file'
// },
// {
// 'id' : 'contact_society',
// 'class' : '',
// 'icon' : ''
// },
// {
// 'id' : 'contact_society',
// 'class' : '',
// 'icon' : ''
// },
// {
// 'id' : 'date',
// 'class' : 'rightData',
// 'icon' : ''
// },
// ];
exampleDatabase: ResultListHttpDao | null;
data: any[] = [];
resultsLength = 0;
isLoadingResults = true;
listProperties: any = {};
listPropertiesIndex: number = 0;
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild('tableBasketListSort') sort: MatSort;
constructor(changeDetectorRef: ChangeDetectorRef, private route: ActivatedRoute, media: MediaMatcher, public http: HttpClient, public dialog: MatDialog, private sanitizer: DomSanitizer, private bottomSheet: MatBottomSheet, private headerService: HeaderService, public filtersListService: FiltersListService) {
this.mobileMode = angularGlobals.mobileMode;
$j("link[href='merged_css.php']").remove();
this.mobileQuery = media.matchMedia('(max-width: 768px)');
this._mobileQueryListener = () => changeDetectorRef.detectChanges();
this.mobileQuery.addListener(this._mobileQueryListener);
}
ngOnInit(): void {
this.coreUrl = angularGlobals.coreUrl;
this.loading = false;
$j('.mat-paginator-navigation-previous').hide();
$j('.mat-paginator-navigation-next').hide();
this.http.get(this.coreUrl + "rest/home")
.subscribe((data: any) => {
this.homeData = data;
});
this.route.params.subscribe(params => {
this.basketUrl = this.coreUrl + 'rest/resourcesList/users/' + params['userSerialId'] + '/groups/' + params['groupSerialId'] + '/baskets/' + params['basketId'];
this.headerService.headerMessage = data.basketLabel;
this.filtersListService.filterMode = false;
window['MainHeaderComponent'].setSnav(this.sidenavLeft);
window['MainHeaderComponent'].setSnavRight(this.sidenavRight);
this.listProperties = this.filtersListService.initListsProperties('bbain', params['groupSerialId'], params['basketId']);
}, () => {
location.href = "index.php";
});
initResultList() {
this.exampleDatabase = 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);
// When list is refresh (sort, page, filters)
merge(this.sort.sortChange, this.paginator.page, this.filtersChange)
.pipe(
startWith({}),
switchMap(() => {
this.isLoadingResults = true;
return this.exampleDatabase!.getRepoIssues(
this.sort.active, this.sort.direction, this.paginator.pageIndex, this.basketUrl, this.filtersListService.getUrlFilters());
}),
map(data => {
// Flip flag to show that loading has finished.
this.isLoadingResults = false;
this.resultsLength = data.count;
return data.resources;
}),
catchError(() => {
this.isLoadingResults = false;
return observableOf([]);
})
).subscribe(data => this.data = data);
this.filtersListService.filterMode = false;
if (this.docUrl == this.coreUrl + 'rest/res/' + row.res_id + '/content' && this.sidenavRight.opened) {
this.sidenavRight.close();
} else {
this.docUrl = this.coreUrl + 'rest/res/' + row.res_id + '/content';
this.innerHtml = this.sanitizer.bypassSecurityTrustHtml(
"<iframe style='height:100%;width:100%;' src='" + this.docUrl + "' class='embed-responsive-item'>" +
"</iframe>");
this.sidenavRight.open();
}
}
goToDetail(row: any) {
location.href = "index.php?page=details&dir=indexing_searching&id=" + row.res_id;
}
openBottomSheet(row: any): void {
this.bottomSheet.open(BottomSheetNoteList, {
data: { resId: row.res_id, chrono: row.alt_identifier },
panelClass: 'note-width-bottom-sheet'
});
}
openAttachSheet(row: any): void {
this.bottomSheet.open(BottomSheetAttachmentList, {
data: { resId: row.res_id, chrono: row.alt_identifier },
});
openDiffusionSheet(row: any): void {
this.bottomSheet.open(BottomSheetDiffusionList, {
data: { resId: row.res_id, chrono: row.alt_identifier },
});
}
}
export interface BasketList {
resources: any[];
export class ResultListHttpDao {
constructor(private http: HttpClient, private filtersListService: FiltersListService) { }
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}${filters}`;
return this.http.get<BasketList>(requestUrl);
}
templateUrl: 'note-list.component.html',
styleUrls: ['note-list.component.scss'],
})
export class BottomSheetNoteList {
coreUrl: string;
lang: any = LANG;
notes: any;
loading: boolean = true;
constructor(public http: HttpClient, private bottomSheetRef: MatBottomSheetRef<BottomSheetNoteList>, @Inject(MAT_BOTTOM_SHEET_DATA) public data: any) { }
ngOnInit(): void {
}
ngAfterViewInit() {
this.coreUrl = angularGlobals.coreUrl;
this.http.get(this.coreUrl + "rest/res/" + this.data.resId + "/notes")
.subscribe((data: any) => {
this.notes = data;
this.loading = false;
});
}
}
@Component({
templateUrl: 'attachment-list.component.html',
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
})
export class BottomSheetAttachmentList {
coreUrl: string;
lang: any = LANG;
attachments: any;
attachmentTypes: any;
loading: boolean = true;
constructor(public http: HttpClient, private bottomSheetRef: MatBottomSheetRef<BottomSheetAttachmentList>, @Inject(MAT_BOTTOM_SHEET_DATA) public data: any) { }
ngOnInit(): void {
}
ngAfterViewInit() {
this.coreUrl = angularGlobals.coreUrl;
this.http.get(this.coreUrl + "rest/res/" + this.data.resId + "/attachments")
.subscribe((data: any) => {
this.attachments = data.attachments;
this.attachmentTypes = data.attachment_types;
this.loading = false;
});
}
}
@Component({
templateUrl: 'diffusion-list.component.html',
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
})
export class BottomSheetDiffusionList {
coreUrl: string;
lang: any = LANG;
listinstance: any = [];
visaCircuit: any;
avisCircuit: any;
roles: any = [];
loading: boolean = true;
tabVisaCircuit: boolean = false;
tabAvisCircuit: boolean = false;
constructor(public http: HttpClient, private bottomSheetRef: MatBottomSheetRef<BottomSheetDiffusionList>, @Inject(MAT_BOTTOM_SHEET_DATA) public data: any) { }
ngOnInit(): void {
}
ngAfterViewInit() {
this.coreUrl = angularGlobals.coreUrl;
this.http.get(this.coreUrl + "rest/res/" + this.data.resId + "/listinstance")
.subscribe((data: any) => {
if (data != null) {
this.roles = Object.keys(data);
this.listinstance = data;
}
this.http.get(this.coreUrl + "rest/res/" + this.data.resId + "/visaCircuit")
.subscribe((data: any) => {
this.visaCircuit = data;
if (this.visaCircuit.length > 0) {
this.tabVisaCircuit = true;
}
this.http.get(this.coreUrl + "rest/res/" + this.data.resId + "/avisCircuit")
.subscribe((data: any) => {
this.avisCircuit = data;
if (this.avisCircuit.length > 0) {
this.tabAvisCircuit = true;
}
this.loading = false;
});
});
});
}
}