From: Bill Erickson Date: Thu, 12 Nov 2020 23:20:08 +0000 (-0500) Subject: LP1901930 SIP account admin UI WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=197c0dfc2e654f69a6141803ac145b884c083449;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-list.component.html b/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account-list.component.html index 917d4e81dd..1dcf5152c6 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account-list.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account-list.component.html @@ -1,6 +1,7 @@ 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 87d6ef6732..a13caa8b61 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 @@ -1,10 +1,17 @@ + + + + -
+
@@ -38,3 +45,16 @@
+
+ +
+

Settings For Group + {{account.setting_group().label()}} +

+ + + +
+
+ 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 c80693584c..b43dce742f 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} from 'rxjs/operators'; +import {map, switchMap} 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,8 @@ 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 {GridDataSource} from '@eg/share/grid/grid'; +import {Pager} from '@eg/share/util/pager'; @Component({ templateUrl: './account.component.html' @@ -23,11 +25,13 @@ export class SipAccountComponent implements OnInit { usrCboxSource: (term: string) => Observable; usrCboxEntries: ComboboxEntry[]; usrId: number; + settingsSource: GridDataSource = new GridDataSource(); @ViewChild('cloneDialog') cloneDialog: FmRecordEditorComponent; constructor( private route: ActivatedRoute, + private idl: IdlService, private pcrud: PcrudService ) {} @@ -52,6 +56,22 @@ export class SipAccountComponent implements OnInit { return {id: user.id(), label: user.usrname()}; })); }; + + this.settingsSource.getRows = (pager: Pager, sort: any[]) => { + if (!this.account && this.account.setting_group()) { + return of(); + } + + const orderBy: any = {sipset: 'name'}; + if (sort.length) { + orderBy.sipset = sort[0].name + ' ' + sort[0].dir; + } + + return this.pcrud.search('sipset', + {setting_group: this.account.setting_group().id()}, + {order_by: orderBy}, + ); + } } loadAccount() { @@ -60,8 +80,8 @@ export class SipAccountComponent implements OnInit { flesh_fields: { sipacc: ['usr', 'setting_group', 'workstation'], sipsetg: ['settings'] - } - }).subscribe(acc => { + }}, {authoritative: true} + ).subscribe(acc => { this.account = acc; this.usrId = acc.usr().id(); this.usrCboxEntries = @@ -77,11 +97,29 @@ export class SipAccountComponent implements OnInit { .subscribe(grp => this.account.setting_group(grp)); } + // Create a new setting group + // Clone the settings for the currently selected group into the new group + // Point our account at the new group. openCloneDialog() { this.cloneDialog.open().subscribe(resp => { if (!resp) { return; } - // create settings that match the currently selected group. + const settings = this.account.setting_group().settings() + .map(setting => { + const clone = this.idl.clone(setting); + clone.setting_group(resp.id()); + clone.isnew(true); + clone.id(null); + return clone; + }); + + // avoid de-fleshing the group on the active account + const modified = this.idl.clone(this.account); + modified.setting_group(resp.id()); + modified.ischanged(true); + + this.pcrud.autoApply(settings.concat(modified)).toPromise() + .then(_ => this.loadAccount()); }); }