<field name="enabled" reporter:datatype="bool" reporter:label="Enabled"/>
<field name="setting_group" reporter:datatype="link" reporter:label="Settings Group" oils_obj:required="true"/>
<field name="sip_username" reporter:datatype="text" reporter:label="SIP Username" oils_obj:required="true"/>
- <field name="sip_password" reporter:datatype="id" reporter:label="SIP Password" oils_obj:required="true"/>
<field name="usr" reporter:datatype="link" reporter:label="ILS User" oils_obj:required="true"/>
<field name="workstation" reporter:datatype="link" reporter:label="Workstation"/>
<field name="transient" reporter:datatype="bool" reporter:label="Transient"/>
<field name="activity_who" reporter:datatype="text" reporter:label="Activity Who"/>
+ <field name="sip_password" reporter:datatype="id" reporter:label="SIP Password" oils_persist:virtual="true"/>
</fields>
<links>
<link field="usr" reltype="has_a" key="id" map="" class="au"/>
<ng-template #usrTemplate>
<eg-combobox #usrCbox [entries]="usrCboxEntries" required="true"
+ (onChange)="usrChanged($event)"
[selectedId]="usrId" [asyncDataSource]="usrCboxSource">
</eg-combobox>
</ng-template>
(click)="setPassword()">Set Password</button>
</ng-template>
+ <b>TODO password setting</b>
+
<eg-fm-record-editor #editor
idlClass="sipacc" [mode]="createMode ? 'create' : 'update'"
hiddenFields="id" displayMode="inline" [inPlaceMode]="true"
import {OrgService} from '@eg/core/org.service';
import {NetService} from '@eg/core/net.service';
import {AuthService} from '@eg/core/auth.service';
+import {EventService} from '@eg/core/event.service';
import {PcrudService} from '@eg/core/pcrud.service';
import {ToastService} from '@eg/share/toast/toast.service';
import {StringComponent} from '@eg/share/string/string.component';
private router: Router,
private idl: IdlService,
private net: NetService,
+ private auth: AuthService,
+ private evt: EventService,
private pcrud: PcrudService
) {}
};
this.accountPreSave = (mode: string, account: IdlObject) => {
- if (this.account.setting_group()) {
- // Migrate the setting group selected in our local group
- // combobox to the object to be saved.
- account.setting_group(this.account.setting_group().id());
- }
+ // Migrate the setting group selected in our local group
+ // combobox to the object to be saved.
+ account.setting_group(this.account.setting_group().id());
+ account.usr(this.account.usr().id());
};
}
});
}
+ usrChanged(entry: ComboboxEntry) {
+ if (!entry) {
+ this.account.usr(null);
+ return;
+ }
+
+ this.pcrud.retrieve('au', entry.id)
+ .subscribe(usr => this.account.usr(usr));
+ }
+
+
// Create a new setting group
// Clone the settings for the currently selected group into the new group
// Point our account at the new group.
}
accountSaved(account) {
- // Create/modify the account via API
- /*
if (this.createMode) {
- this.router.navigate(
- [`/staff/admin/server/sip/account/${result.id()}`]);
+ account.isnew(true);
} else {
- this.refreshAccount();
+ account.ischanged(true);
}
- */
+
+ this.net.request('open-ils.sip2',
+ 'open-ils.sip2.account.cud', this.auth.token(), account)
+ .subscribe(acc => {
+
+ const evt = this.evt.parse(acc);
+
+ if (evt) {
+ console.error(evt);
+ return;
+ }
+
+ if (this.createMode) {
+ this.router.navigate(
+ [`/staff/admin/server/sip/account/${account.id()}`]);
+ } else {
+ this.refreshAccount();
+ }
+ });
}
editFirstSetting(rows: any) {
setPassword() {
this.passwordDialog.open().subscribe(value => {
- // API will translate this into an actor.passwd entry.
+ // API will translate this into an actor.passwd
this.account.sip_password(value);
});
}
return 1;
}
+__PACKAGE__->register_method(
+ method => 'account_cud',
+ api_name => 'open-ils.sip2.account.cud',
+ api_level => 1,
+ argc => 2,
+ signature => {
+ desc => q/Create, Update, Delete SIP accounts. If a value is
+ stored in the virtual sip_password field on the account, the
+ value will be used as the new password for the account/,
+ params => [{
+ name => 'auth',
+ desc => 'Authtoken',
+ type => 'string'
+ }, {
+ name => 'account',
+ desc => 'SIP account object',
+ type => 'object'
+ }],
+ return => {
+ desc => q/Account object on success, Event on error/,
+ type => 'object'
+ }
+ }
+);
+
+sub account_cud {
+ my ($self, $client, $auth, $account) = @_;
+
+ my $e = new_editor(authtoken => $auth, xact => 1);
+ return $e->die_event unless $e->checkauth;
+ return $e->die_event unless $e->allowed('SIP_ADMIN');
+
+ if ($account->sip_password) {
+ my $pw = $e->json_query({from => ['actor.change_password',
+ $account->usr, $account->sip_password, 'sip2']});
+
+ return $e->die_event unless $pw;
+ }
+
+ if ($account->isnew) {
+ return undef unless $e->create_sip_account($account);
+
+ } elsif ($account->ischanged) {
+ return undef unless $e->update_sip_account($account);
+
+ } elsif ($account->isdeleted) {
+ return undef unless $e->delete_sip_account($account);
+ }
+
+ $account = $e->retrieve_sip_account($account->id);
+
+ return $e->die_event unless $e->commit;
+
+ return $account;
+}
+
+
1;
setting_group INTEGER NOT NULL REFERENCES sip.setting_group (id)
DEFERRABLE INITIALLY DEFERRED,
sip_username TEXT NOT NULL,
- sip_password BIGINT NOT NULL REFERENCES actor.passwd
- DEFERRABLE INITIALLY DEFERRED,
usr BIGINT NOT NULL REFERENCES actor.usr(id)
DEFERRABLE INITIALLY DEFERRED,
workstation INTEGER REFERENCES actor.workstation(id),