<eg-staff-banner bannerText="SIP Accounts" i18n-bannerText></eg-staff-banner>
+<eg-confirm-dialog #confirmDelete
+ i18n-dialogTitle i18n-dialogBody
+ dialogTitle="Delete Accounts"
+ dialogBody="Delete selected SIP accounts?">
+</eg-confirm-dialog>
+
<eg-grid #grid idlClass="sipacc" [dataSource]="gridSource"
persistKey="admin.server.sip.account-list"
[stickyHeader]="true" [sortable]="true" (onRowActivate)="openAccount($event)">
<eg-grid-toolbar-button label="New Account" i18n-label
- (onClick)="newAccount"></eg-grid-toolbar-button>
+ (onClick)="newAccount()"></eg-grid-toolbar-button>
<eg-grid-toolbar-action label="Delete Selected" i18n-label
(onClick)="deleteSelected($event)">
</eg-grid-toolbar-action>
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({
export class SipAccountListComponent implements OnInit {
gridSource: GridDataSource = new GridDataSource();
+ @ViewChild('grid') grid: GridComponent;
+ @ViewChild('confirmDelete') confirmDelete: ConfirmDialogComponent;
constructor(
private router: Router,
}
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();
+ });
+ }
});
}
}
</div>
</ng-template>
- <ng-template #sipPassTemplate>
- <button class="btn btn-outline-dark"
- [ngClass]="{'border-danger' : !account.sip_password()}"
- (click)="setPassword()">Set Password</button>
+ <ng-template #sipUsernameTemplate>
+ <div class="form-inline">
+ <input type="text" class="form-control"
+ [ngModel]="account.sip_username()"
+ (ngModelChange)="account.sip_username($event)">
+ <button class="btn btn-outline-dark ml-2"
+ [ngClass]="{'border-danger' : createMode && !account.sip_password()}"
+ (click)="setPassword()">Set Password</button>
+ </div>
</ng-template>
- <b>TODO password setting</b>
-
<eg-fm-record-editor #editor
idlClass="sipacc" [mode]="createMode ? 'create' : 'update'"
hiddenFields="id" displayMode="inline" [inPlaceMode]="true"
fieldOrder="sip_username,sip_password,setting_group,usr,workstation,transient,activity_who,enabled"
[fieldOptions]="{
setting_group:{customTemplate:{template:grpTemplate}},
- sip_password:{customTemplate:{template:sipPassTemplate}},
+ sip_username:{customTemplate:{template:sipUsernameTemplate}},
usr:{customTemplate:{template:usrTemplate}}}"
- [preSave]="accountPreSave" [recordId]="createMode ? accountId : null"
+ [preSave]="accountPreSave" [recordId]="!createMode ? accountId : null"
(recordSaved)="accountSaved($event)">
</eg-fm-record-editor>
</div>
};
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());
};
}
if (this.createMode) {
this.router.navigate(
- [`/staff/admin/server/sip/account/${account.id()}`]);
+ [`/staff/admin/server/sip/account/${acc.id()}`]);
} else {
this.refreshAccount();
}
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;
}
$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;
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;