1 import {Component, OnInit, ViewChild} from '@angular/core';
2 import {Observable} from 'rxjs';
3 import {DialogComponent} from '@eg/share/dialog/dialog.component';
4 import {OrgService} from '@eg/core/org.service';
5 import {Pager} from '@eg/share/util/pager';
6 import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
7 import {GridDataSource} from '@eg/share/grid/grid';
8 import {GridComponent} from '@eg/share/grid/grid.component';
11 selector: 'eg-admin-ou-setting-history-dialog',
12 templateUrl: './org-unit-setting-history-dialog.component.html'
15 export class OuSettingHistoryDialogComponent extends DialogComponent implements OnInit {
19 gridDataSource: GridDataSource;
20 @ViewChild('historyGrid', { static: true }) historyGrid: GridComponent;
24 private org: OrgService,
25 private modal: NgbModal
28 this.gridDataSource = new GridDataSource();
32 this.gridDataSource.getRows = (pager: Pager, sort: any[]) => {
33 return this.fetchHistory(pager);
37 fetchHistory(pager: Pager): Observable<any> {
38 return new Observable<any>(observer => {
39 this.gridDataSource.data = this.history;
46 const intTypes = ['integer', 'currency', 'link'];
47 if (intTypes.includes(this.entry.dataType)) {
48 log.original_value = Number(log.original_value);
50 log.original_value = log.original_value.replace(/^"(.*)"$/, '$1');
53 if (this.entry.dataType === 'bool') {
54 if (log.original_value.match(/^t/)) {
55 log.original_value = true;
57 log.original_value = false;
62 setting: {[this.entry.name]: log.original_value},
63 context: this.org.get(log.org),
66 this.gridDataSource.data = null;