]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-items.component.ts
7340e3d7197bb24308314d7b347d0d504a03311c
[Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / cat / vandelay / queue-items.component.ts
1 import {Component, OnInit, ViewChild} from '@angular/core';
2 import {Observable} from 'rxjs';
3 import {map} from 'rxjs/operators';
4 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
5 import {Pager} from '@eg/share/util/pager';
6 import {IdlObject} from '@eg/core/idl.service';
7 import {NetService} from '@eg/core/net.service';
8 import {AuthService} from '@eg/core/auth.service';
9 import {GridComponent} from '@eg/share/grid/grid.component';
10 import {GridDataSource} from '@eg/share/grid/grid';
11 import {VandelayService} from './vandelay.service';
12
13 @Component({
14   templateUrl: 'queue-items.component.html'
15 })
16 export class QueueItemsComponent {
17
18     queueType: string;
19     queueId: number;
20     filterImportErrors: boolean;
21     limitToImportErrors: (checked: boolean) => void;
22
23     gridSource: GridDataSource;
24     @ViewChild('itemsGrid') itemsGrid: GridComponent;
25
26     constructor(
27         private router: Router,
28         private route: ActivatedRoute,
29         private net: NetService,
30         private auth: AuthService,
31         private vandelay: VandelayService) {
32
33         this.route.paramMap.subscribe((params: ParamMap) => {
34             this.queueId = +params.get('id');
35             this.queueType = params.get('qtype');
36         });
37
38         this.gridSource = new GridDataSource();
39
40         // queue API does not support sorting
41         this.gridSource.getRows = (pager: Pager) => {
42             return this.net.request(
43                 'open-ils.vandelay',
44                 'open-ils.vandelay.import_item.queue.retrieve',
45                 this.auth.token(), this.queueId, {
46                     with_import_error: this.filterImportErrors,
47                     offset: pager.offset,
48                     limit: pager.limit
49                 }
50             );
51         };
52
53         this.limitToImportErrors = (checked: boolean) => {
54             this.filterImportErrors = checked;
55             this.itemsGrid.reload();
56         };
57     }
58 }
59