From 0b36ee33c3895326cc382f25dad24f9fcd8d7f89 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 30 Nov 2020 07:33:54 -0800 Subject: [PATCH] LP1901930 SIP mediator continued Signed-off-by: Bill Erickson --- .../admin/server/sip/account-list.component.html | 8 ++++++- .../admin/server/sip/account-list.component.ts | 16 +++++++++++--- .../staff/admin/server/sip/account.component.html | 19 +++++++++------- .../staff/admin/server/sip/account.component.ts | 8 ++++--- .../lib/OpenILS/Application/SIP2/Session.pm | 25 +++++++++++++--------- 5 files changed, 51 insertions(+), 25 deletions(-) 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 e794f01ba7..32ecad1572 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,10 +1,16 @@ + + + + (onClick)="newAccount()"> diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account-list.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account-list.component.ts index 44e2940471..819960e53e 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account-list.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/sip/account-list.component.ts @@ -12,6 +12,7 @@ import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component'; import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; import {GridDataSource} from '@eg/share/grid/grid'; +import {GridComponent} from '@eg/share/grid/grid.component'; import {Pager} from '@eg/share/util/pager'; @Component({ @@ -20,6 +21,8 @@ import {Pager} from '@eg/share/util/pager'; export class SipAccountListComponent implements OnInit { gridSource: GridDataSource = new GridDataSource(); + @ViewChild('grid') grid: GridComponent; + @ViewChild('confirmDelete') confirmDelete: ConfirmDialogComponent; constructor( private router: Router, @@ -57,9 +60,16 @@ export class SipAccountListComponent implements OnInit { } deleteSelected(rows: any[]) { - rows.forEach(row => row.isdeleted(true)); - this.pcrud.autoApply(rows).subscribe(_ => { - this.gridSource.reset(); + if (rows.length === 0) { return; } + + this.confirmDelete.open().subscribe(confirmed => { + if (confirmed) { + rows.forEach(row => row.isdeleted(true)); + this.pcrud.autoApply(rows).toPromise().then(_ => { + this.gridSource.reset(); + this.grid.reload(); + }); + } }); } } 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 2ee2f7c8e0..a05c0b70ea 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 @@ -60,23 +60,26 @@ - - + +
+ + +
- TODO password setting - 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 d83d92bed7..78554bf85b 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 @@ -105,10 +105,12 @@ export class SipAccountComponent implements OnInit { }; this.accountPreSave = (mode: string, account: IdlObject) => { - // Migrate the setting group selected in our local group - // combobox to the object to be saved. + // Migrate data collected from custom templates into + // the object to be saved. account.setting_group(this.account.setting_group().id()); account.usr(this.account.usr().id()); + account.sip_username(this.account.sip_username()); + account.sip_password(this.account.sip_password()); }; } @@ -223,7 +225,7 @@ export class SipAccountComponent implements OnInit { if (this.createMode) { this.router.navigate( - [`/staff/admin/server/sip/account/${account.id()}`]); + [`/staff/admin/server/sip/account/${acc.id()}`]); } else { this.refreshAccount(); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Session.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Session.pm index 88c975139b..b767ce801a 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Session.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Session.pm @@ -114,28 +114,33 @@ sub sip_account { return $self->{sip_account}; } -# Logs in to Evergreen and caches the auth token/login with the SIP +# Logs in to Evergreen and stores the auth token/login with the SIP # account data. # Returns true on success, false on failure to authenticate. sub set_ils_account { my $self = shift; my $ses = shift; my $e = $self->editor; + my $account = $self->sip_account; return 1 if $e->authtoken && $e->checkauth; + my $args = { + user_id => $account->usr, + login_type => 'staff' + }; + + $args->{workstation} = $account->workstation->name + if $account->workstation; + my $auth = $U->simplereq( 'open-ils.auth_internal', - 'open-ils.auth_internal.session.create', { - user_id => $self->sip_account->usr, - workstation => $self->sip_account->workstation->name, - login_type => 'staff' - }); + 'open-ils.auth_internal.session.create', $args); if ($auth->{textcode} ne 'SUCCESS') { $logger->warn( "SIP2 failed to create an internal login session for ILS user: ". - $self->sip_account->usr); + $account->usr); return 0; } @@ -144,14 +149,14 @@ sub set_ils_account { $e->authtoken($ils_token); my $cache_ses = { - sip_account => $self->sip_account, + sip_account => $account, ils_token => $ils_token }; $SC->cache->put_cache("sip2_$seskey", $cache_ses); # transient account sessions are not tracked in the database - return 1 if $U->is_true($self->sip_account->transient); + return 1 if $U->is_true($account->transient); $e->xact_begin; @@ -171,7 +176,7 @@ sub set_ils_account { my $ses = Fieldmapper::sip::session->new; $ses->key($seskey); $ses->ils_token($ils_token); - $ses->account($self->sip_account->id); + $ses->account($account->id); unless ($e->create_sip_session($ses)) { $e->rollback; -- 2.11.0