--- /dev/null
+import {Component, EventEmitter, Input, Output, OnChanges, OnInit, ViewChild} from '@angular/core';
+import {Router} from '@angular/router';
+import {Observable, from, of} from 'rxjs';
+import {tap, switchMap, mergeMap} from 'rxjs/operators';
+import {AuthService} from '@eg/core/auth.service';
+import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
+import {FormatService} from '@eg/core/format.service';
+import {GridComponent} from '@eg/share/grid/grid.component';
+import {GridDataSource} from '@eg/share/grid/grid';
+import {IdlService, IdlObject} from '@eg/core/idl.service';
+import {PcrudService} from '@eg/core/pcrud.service';
+import {Pager} from '@eg/share/util/pager';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {NetService} from '@eg/core/net.service';
+import {OrgService} from '@eg/core/org.service';
+
+// A filterable grid of A/T events for circ or ahr hook core types
+
+@Component({
+ selector: 'eg-event-grid',
+ templateUrl: './event-grid.component.html'
+})
+
+export class EventGridComponent implements OnChanges, OnInit {
+
+ @Input() patron: number;
+ @Input() event_type: string;
+
+ gridSource: GridDataSource;
+ numRowsSelected: number;
+
+ @ViewChild('grid', { static: true }) grid: GridComponent;
+
+ constructor(
+ private idl: IdlService,
+ private auth: AuthService,
+ private format: FormatService,
+ private pcrud: PcrudService,
+ private router: Router,
+ private toast: ToastService,
+ private net: NetService,
+ private org: OrgService
+ ) {
+
+ }
+
+ ngOnInit() {
+ this.gridSource = new GridDataSource();
+
+ this.gridSource.getRows = (pager: Pager, sort: any[]): Observable<IdlObject> => {
+ // TODO: why is this getting called twice on page load?
+
+ const orderBy: any = {atul: 'id'};
+ if (sort.length) {
+ orderBy.atul = sort[0].name + ' ' + sort[0].dir;
+ }
+
+ // base query to grab everything
+ const base: Object = {};
+ base[this.idl.classes['atul'].pkey] = {'!=' : null};
+ base['context_user'] = (this.patron ? this.patron : {'>' : 0})
+
+ // circs or holds?
+ if (this.event_type == 'circ') {
+ base['target_circ'] = { '>' : 0 }
+ } else {
+ base['target_hold'] = { '>' : 0 }
+ }
+
+ const query: any = new Array();
+ query.push(base);
+
+ // and add any filters
+ Object.keys(this.gridSource.filters).forEach(key => {
+ Object.keys(this.gridSource.filters[key]).forEach(key2 => {
+ query.push(this.gridSource.filters[key][key2]);
+ });
+ });
+
+ return this.pcrud.search('atul',
+ query, {
+ flesh: 1,
+ flesh_fields: {atul: ['target_circ', 'target_hold']},
+ offset: pager.offset,
+ limit: pager.limit,
+ order_by: orderBy
+ });
+ };
+ }
+
+ ngOnChanges() { this.reloadGrid(); }
+
+ reloadGrid() { this.grid.reload(); }
+}
--- /dev/null
+import {Component, OnInit, ViewChild} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
+import {NetService} from '@eg/core/net.service';
+import {AuthService} from '@eg/core/auth.service';
+import {EventGridComponent} from './event-grid.component';
+
+@Component({
+ templateUrl: 'event-log.component.html'
+})
+
+export class EventLogComponent implements OnInit {
+ patronId: number;
+
+ @ViewChild('eventGrid', { static: true }) eventGrid: EventGridComponent;
+
+ constructor(
+ private route: ActivatedRoute,
+ private net: NetService,
+ private auth: AuthService
+ ) {}
+
+ ngOnInit() {
+ // Note: if this is not supplied, the grid will show recent events
+ // across all patrons, which may be a neat feature...
+ // TODO: see if we're honoring VIEW_USER permission and patron opt-in
+ this.patronId = +this.route.snapshot.paramMap.get('patron');
+ }
+}
+
+