|
|
@ -1,4 +1,4 @@
|
|
|
|
import { Component, AfterViewInit, ViewChild, EventEmitter, Output, ChangeDetectorRef } from "@angular/core";
|
|
|
|
import { Component, AfterViewInit, ViewChild, EventEmitter, Output, ChangeDetectorRef, OnInit } from "@angular/core";
|
|
|
|
import { IMovieRequests, IRequestsViewModel } from "../../../interfaces";
|
|
|
|
import { IMovieRequests, IRequestsViewModel } from "../../../interfaces";
|
|
|
|
import { MatPaginator, MatSort } from "@angular/material";
|
|
|
|
import { MatPaginator, MatSort } from "@angular/material";
|
|
|
|
import { merge, Observable, of as observableOf } from 'rxjs';
|
|
|
|
import { merge, Observable, of as observableOf } from 'rxjs';
|
|
|
@ -6,13 +6,14 @@ import { catchError, map, startWith, switchMap } from 'rxjs/operators';
|
|
|
|
|
|
|
|
|
|
|
|
import { RequestServiceV2 } from "../../../services/requestV2.service";
|
|
|
|
import { RequestServiceV2 } from "../../../services/requestV2.service";
|
|
|
|
import { AuthService } from "../../../auth/auth.service";
|
|
|
|
import { AuthService } from "../../../auth/auth.service";
|
|
|
|
|
|
|
|
import { StorageService } from "../../../shared/storage/storage-service";
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
templateUrl: "./movies-grid.component.html",
|
|
|
|
templateUrl: "./movies-grid.component.html",
|
|
|
|
selector: "movies-grid",
|
|
|
|
selector: "movies-grid",
|
|
|
|
styleUrls: ["../requests-list.component.scss"]
|
|
|
|
styleUrls: ["../requests-list.component.scss"]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
export class MoviesGridComponent implements AfterViewInit {
|
|
|
|
export class MoviesGridComponent implements OnInit, AfterViewInit {
|
|
|
|
public dataSource: IMovieRequests[] = [];
|
|
|
|
public dataSource: IMovieRequests[] = [];
|
|
|
|
public resultsLength: number;
|
|
|
|
public resultsLength: number;
|
|
|
|
public isLoadingResults = true;
|
|
|
|
public isLoadingResults = true;
|
|
|
@ -20,6 +21,11 @@ export class MoviesGridComponent implements AfterViewInit {
|
|
|
|
public gridCount: string = "15";
|
|
|
|
public gridCount: string = "15";
|
|
|
|
public showUnavailableRequests: boolean;
|
|
|
|
public showUnavailableRequests: boolean;
|
|
|
|
public isAdmin: boolean;
|
|
|
|
public isAdmin: boolean;
|
|
|
|
|
|
|
|
public defaultSort: string = "requestedDate";
|
|
|
|
|
|
|
|
public defaultOrder: string = "desc";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private storageKey = "Movie_DefaultRequestListSort";
|
|
|
|
|
|
|
|
private storageKeyOrder = "Movie_DefaultRequestListSortOrder";
|
|
|
|
|
|
|
|
|
|
|
|
@Output() public onOpenOptions = new EventEmitter<{ request: any, filter: any, onChange: any }>();
|
|
|
|
@Output() public onOpenOptions = new EventEmitter<{ request: any, filter: any, onChange: any }>();
|
|
|
|
|
|
|
|
|
|
|
@ -27,9 +33,20 @@ export class MoviesGridComponent implements AfterViewInit {
|
|
|
|
@ViewChild(MatSort, { static: false }) sort: MatSort;
|
|
|
|
@ViewChild(MatSort, { static: false }) sort: MatSort;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private requestService: RequestServiceV2, private ref: ChangeDetectorRef,
|
|
|
|
constructor(private requestService: RequestServiceV2, private ref: ChangeDetectorRef,
|
|
|
|
private auth: AuthService) {
|
|
|
|
private auth: AuthService, private storageService: StorageService) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ngOnInit() {
|
|
|
|
|
|
|
|
const defaultSort = this.storageService.get(this.storageKey);
|
|
|
|
|
|
|
|
const defaultOrder = this.storageService.get(this.storageKeyOrder);
|
|
|
|
|
|
|
|
if (defaultSort) {
|
|
|
|
|
|
|
|
this.defaultSort = defaultSort;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defaultOrder) {
|
|
|
|
|
|
|
|
this.defaultOrder = defaultOrder;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async ngAfterViewInit() {
|
|
|
|
public async ngAfterViewInit() {
|
|
|
|
// const results = await this.requestService.getMovieRequests(this.gridCount, 0, OrderType.RequestedDateDesc,
|
|
|
|
// const results = await this.requestService.getMovieRequests(this.gridCount, 0, OrderType.RequestedDateDesc,
|
|
|
@ -45,10 +62,12 @@ export class MoviesGridComponent implements AfterViewInit {
|
|
|
|
merge(this.sort.sortChange, this.paginator.page)
|
|
|
|
merge(this.sort.sortChange, this.paginator.page)
|
|
|
|
.pipe(
|
|
|
|
.pipe(
|
|
|
|
startWith({}),
|
|
|
|
startWith({}),
|
|
|
|
switchMap(() => {
|
|
|
|
switchMap((value: any) => {
|
|
|
|
this.isLoadingResults = true;
|
|
|
|
this.isLoadingResults = true;
|
|
|
|
// eturn this.exampleDatabase!.getRepoIssues(
|
|
|
|
if (value.active || value.direction) {
|
|
|
|
// this.sort.active, this.sort.direction, this.paginator.pageIndex);
|
|
|
|
this.storageService.save(this.storageKey, value.active);
|
|
|
|
|
|
|
|
this.storageService.save(this.storageKeyOrder, value.direction);
|
|
|
|
|
|
|
|
}
|
|
|
|
return this.loadData();
|
|
|
|
return this.loadData();
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
map((data: IRequestsViewModel<IMovieRequests>) => {
|
|
|
|
map((data: IRequestsViewModel<IMovieRequests>) => {
|
|
|
|