From: Bill Erickson Date: Fri, 13 Nov 2020 15:29:13 +0000 (-0500) Subject: LP1901930 SIP account admin UI WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e80351935f0d944c14406a2baaa9a4ec8b4cb89d;p=working%2FEvergreen.git LP1901930 SIP account admin UI WIP Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account.component.html b/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account.component.html index a13caa8b61..82e5989a49 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account.component.html @@ -11,6 +11,11 @@ hiddenFields="id" fieldOrder="label,institution"> + + +
@@ -52,8 +57,16 @@ {{account.setting_group().label()}} - + Setting values must be entered as valid JSON. + + + + +
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account.component.ts index b43dce742f..e1c204e52d 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account.component.ts @@ -1,7 +1,7 @@ import {Component, Input, ViewChild, OnInit} from '@angular/core'; import {ActivatedRoute} from '@angular/router'; import {Observable, of} from 'rxjs'; -import {map, switchMap} from 'rxjs/operators'; +import {map, tap, switchMap, catchError} from 'rxjs/operators'; import {IdlService, IdlObject} from '@eg/core/idl.service'; import {OrgService} from '@eg/core/org.service'; import {AuthService} from '@eg/core/auth.service'; @@ -12,6 +12,7 @@ import {StringService} from '@eg/share/string/string.service'; import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component'; import {ComboboxEntry, ComboboxComponent} from '@eg/share/combobox/combobox.component'; +import {GridComponent} from '@eg/share/grid/grid.component'; import {GridDataSource} from '@eg/share/grid/grid'; import {Pager} from '@eg/share/util/pager'; @@ -28,6 +29,8 @@ export class SipAccountComponent implements OnInit { settingsSource: GridDataSource = new GridDataSource(); @ViewChild('cloneDialog') cloneDialog: FmRecordEditorComponent; + @ViewChild('settingDialog') settingDialog: FmRecordEditorComponent; + @ViewChild('settingGrid') settingGrid: GridComponent; constructor( private route: ActivatedRoute, @@ -36,9 +39,10 @@ export class SipAccountComponent implements OnInit { ) {} ngOnInit() { + this.route.paramMap.subscribe(map => { this.accountId = Number(map.get('id')); - this.loadAccount(); + this.loadAccount().toPromise(); // force it to run }); this.usrCboxSource = term => { @@ -74,19 +78,19 @@ export class SipAccountComponent implements OnInit { } } - loadAccount() { - this.pcrud.retrieve('sipacc', this.accountId, { + loadAccount(): Observable { + return this.pcrud.retrieve('sipacc', this.accountId, { flesh: 2, flesh_fields: { sipacc: ['usr', 'setting_group', 'workstation'], sipsetg: ['settings'] }}, {authoritative: true} - ).subscribe(acc => { + ).pipe(tap(acc => { this.account = acc; this.usrId = acc.usr().id(); this.usrCboxEntries = [{id: acc.usr().id(), label: acc.usr().usrname()}]; - }); + })); } grpChanged(entry: ComboboxEntry) { @@ -126,5 +130,29 @@ export class SipAccountComponent implements OnInit { accountSaved() { this.loadAccount(); } + + editFirstSetting(rows: any) { + if (rows.length > 0) { + this.editSetting(rows[0]); + } + } + + editSetting(row: any) { + this.settingDialog.record = this.idl.clone(row); + this.settingDialog.open().subscribe( + ok => { + // Easier to simply refresh the whole account. + // After refresh, force a grid reload. + this.loadAccount().subscribe(ok2 => { + setTimeout(() => { + if (this.settingGrid) { + this.settingGrid.reload(); + } + }); + }); + }, + err => {} // todo toast + ); + } }