Skip to content

Commit

Permalink
NAS-132527: Rename instances of websocket (#11047)
Browse files Browse the repository at this point in the history
  • Loading branch information
undsoft authored Nov 18, 2024
1 parent f67d06b commit a04d02f
Show file tree
Hide file tree
Showing 221 changed files with 755 additions and 778 deletions.
2 changes: 1 addition & 1 deletion src/app/helpers/operators/to-loading-state.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface LoadingState<T> {

/**
* Usage:
* myData$ = this.ws.call('my.method').pipe(toLoadingState());
* myData$ = this.api.call('my.method').pipe(toLoadingState());
*
* <ng-container *ngIf="myData$ | async as data">
* <my-loading-spinner *ngIf="data.isLoading"></my-loading-spinner>
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/dialog/dialog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class DialogService {
* Usage:
* ```
* this.dialogService.jobDialog(
* this.ws.call('pool.create', [pool]),
* this.api.call('pool.create', [pool]),
* )
* .afterClosed()
* .pipe(
Expand Down
8 changes: 4 additions & 4 deletions src/app/modules/truecommand/truecommand-button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class TruecommandButtonComponent implements OnInit {
}

constructor(
private ws: ApiService,
private api: ApiService,
private dialogService: DialogService,
private matDialog: MatDialog,
private loader: AppLoaderService,
Expand All @@ -84,12 +84,12 @@ export class TruecommandButtonComponent implements OnInit {
) {}

ngOnInit(): void {
this.ws.call('truecommand.config').pipe(untilDestroyed(this)).subscribe((config) => {
this.api.call('truecommand.config').pipe(untilDestroyed(this)).subscribe((config) => {
this.tcStatus = config;
this.tcConnected = !!config.api_key;
this.cdr.markForCheck();
});
this.ws.subscribe('truecommand.config').pipe(untilDestroyed(this)).subscribe((event) => {
this.api.subscribe('truecommand.config').pipe(untilDestroyed(this)).subscribe((event) => {
this.tcStatus = event.fields;
this.tcConnected = !!event.fields.api_key;
if (this.isTcStatusOpened && this.tcStatusDialogRef) {
Expand Down Expand Up @@ -135,7 +135,7 @@ export class TruecommandButtonComponent implements OnInit {
}).pipe(untilDestroyed(this)).subscribe((confirmed) => {
if (confirmed) {
this.loader.open();
this.ws.call('truecommand.update', [{ enabled: false }]).pipe(untilDestroyed(this)).subscribe({
this.api.call('truecommand.update', [{ enabled: false }]).pipe(untilDestroyed(this)).subscribe({
next: () => {
this.loader.close();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ export class ServiceSshComponent implements OnInit {
readonly sftpLogLevels$ = of(helptextServiceSsh.ssh_sftp_log_level_options);
readonly sftpLogFacilities$ = of(helptextServiceSsh.ssh_sftp_log_facility_options);
readonly sshWeakCiphers$ = of(helptextServiceSsh.ssh_weak_ciphers_options);
readonly bindInterfaces$ = this.ws.call('ssh.bindiface_choices').pipe(choicesToOptions());
readonly bindInterfaces$ = this.api.call('ssh.bindiface_choices').pipe(choicesToOptions());

constructor(
private ws: ApiService,
private api: ApiService,
private errorHandler: ErrorHandlerService,
private cdr: ChangeDetectorRef,
private formErrorHandler: FormErrorHandlerService,
Expand All @@ -116,7 +116,7 @@ export class ServiceSshComponent implements OnInit {

ngOnInit(): void {
this.isFormLoading = true;
this.ws.call('ssh.config').pipe(untilDestroyed(this)).subscribe({
this.api.call('ssh.config').pipe(untilDestroyed(this)).subscribe({
next: (config) => {
this.form.patchValue(config);
this.isFormLoading = false;
Expand All @@ -138,7 +138,7 @@ export class ServiceSshComponent implements OnInit {
const values = this.form.value;

this.isFormLoading = true;
this.ws.call('ssh.update', [values as SshConfigUpdate])
this.api.call('ssh.update', [values as SshConfigUpdate])
.pipe(untilDestroyed(this))
.subscribe({
next: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class ServiceStateColumnComponent extends ColumnComponent<ServiceRow> {
}

private servicesService = inject(ServicesService);
private ws = inject(ApiService);
private api = inject(ApiService);
private dialogService = inject(DialogService);
private translate = inject(TranslateService);
private loader = inject(AppLoaderService);
Expand Down Expand Up @@ -97,7 +97,7 @@ export class ServiceStateColumnComponent extends ColumnComponent<ServiceRow> {
}

private stopService(toggle: MatSlideToggle): void {
this.ws.call('service.stop', [this.service().service, { silent: false }]).pipe(
this.api.call('service.stop', [this.service().service, { silent: false }]).pipe(
this.loader.withLoader(),
untilDestroyed(this),
).subscribe({
Expand All @@ -110,7 +110,7 @@ export class ServiceStateColumnComponent extends ColumnComponent<ServiceRow> {
}

private startService(toggle: MatSlideToggle): void {
this.ws.call('service.start', [this.service().service, { silent: false }]).pipe(
this.api.call('service.start', [this.service().service, { silent: false }]).pipe(
this.loader.withLoader(),
untilDestroyed(this),
).subscribe({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ApiService } from 'app/services/websocket/api.service';
describe('ServiceUpsComponent', () => {
let spectator: Spectator<ServiceUpsComponent>;
let loader: HarnessLoader;
let ws: ApiService;
let api: ApiService;
const createComponent = createRoutingFactory({
component: ServiceUpsComponent,
imports: [
Expand Down Expand Up @@ -72,14 +72,14 @@ describe('ServiceUpsComponent', () => {
beforeEach(() => {
spectator = createComponent();
loader = TestbedHarnessEnvironment.loader(spectator.fixture);
ws = spectator.inject(ApiService);
api = spectator.inject(ApiService);
});

it('shows current settings for UPS service when form is opened', async () => {
const form = await loader.getHarness(IxFormHarness);
const values = await form.getValues();

expect(ws.call).toHaveBeenCalledWith('ups.config');
expect(api.call).toHaveBeenCalledWith('ups.config');
expect(values).toEqual({
Identifier: 'ups',
'UPS Mode': 'Master',
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('ServiceUpsComponent', () => {
const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' }));
await saveButton.click();

expect(ws.call).toHaveBeenCalledWith('ups.update', [{
expect(api.call).toHaveBeenCalledWith('ups.update', [{
description: 'This is a test',
driver: 'bcmxcp$R1500 G2',
extrausers: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export class ServiceUpsComponent implements OnInit {
};

readonly providers: Record<string, IxComboboxProvider> = {
driver: new SimpleAsyncComboboxProvider(this.ws.call('ups.driver_choices').pipe(choicesToOptions())),
port: new SimpleAsyncComboboxProvider(this.ws.call('ups.port_choices').pipe(singleArrayToOptions())),
driver: new SimpleAsyncComboboxProvider(this.api.call('ups.driver_choices').pipe(choicesToOptions())),
port: new SimpleAsyncComboboxProvider(this.api.call('ups.port_choices').pipe(singleArrayToOptions())),
};

readonly tooltips = {
Expand Down Expand Up @@ -146,7 +146,7 @@ export class ServiceUpsComponent implements OnInit {
readonly shutdownOptions$ = of(helptextServiceUps.ups_shutdown_options);

constructor(
private ws: ApiService,
private api: ApiService,
private formErrorHandler: FormErrorHandlerService,
private cdr: ChangeDetectorRef,
private errorHandler: ErrorHandlerService,
Expand Down Expand Up @@ -181,7 +181,7 @@ export class ServiceUpsComponent implements OnInit {
}

private loadConfig(): void {
this.ws.call('ups.config')
this.api.call('ups.config')
.pipe(untilDestroyed(this))
.subscribe({
next: (config) => {
Expand All @@ -208,7 +208,7 @@ export class ServiceUpsComponent implements OnInit {
}

this.isFormLoading = true;
this.ws.call('ups.update', [params as UpsConfigUpdate])
this.api.call('ups.update', [params as UpsConfigUpdate])
.pipe(untilDestroyed(this))
.subscribe({
next: () => {
Expand Down
8 changes: 4 additions & 4 deletions src/app/pages/services/services.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const fakeDataSource: Service[] = [...serviceNames.entries()]
describe('ServicesComponent', () => {
let spectator: Spectator<ServicesComponent>;
let loader: HarnessLoader;
let ws: ApiService;
let api: ApiService;
let table: IxTableHarness;

const createComponent = createComponentFactory({
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('ServicesComponent', () => {
beforeEach(async () => {
spectator = createComponent();
loader = TestbedHarnessEnvironment.loader(spectator.fixture);
ws = spectator.inject(ApiService);
api = spectator.inject(ApiService);
table = await loader.getHarness(IxTableHarness);
});

Expand Down Expand Up @@ -205,7 +205,7 @@ describe('ServicesComponent', () => {

await toggle.check();

expect(ws.call).toHaveBeenCalledWith('service.start', [ServiceName.Ftp, { silent: false }]);
expect(api.call).toHaveBeenCalledWith('service.start', [ServiceName.Ftp, { silent: false }]);
});

it('should change service autostart state when checkbox is ticked', async () => {
Expand All @@ -215,7 +215,7 @@ describe('ServicesComponent', () => {

await toggle.check();

expect(ws.call).toHaveBeenCalledWith('service.update', [0, { enable: true }]);
expect(api.call).toHaveBeenCalledWith('service.update', [0, { enable: true }]);
});

it('should show audit log icon for SMB service', async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/services/services.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class ServicesComponent implements OnInit {
constructor(
protected emptyService: EmptyService,
private servicesService: ServicesService,
private ws: ApiService,
private api: ApiService,
private router: Router,
private translate: TranslateService,
private cdr: ChangeDetectorRef,
Expand Down Expand Up @@ -195,7 +195,7 @@ export class ServicesComponent implements OnInit {
private enableToggle(service: ServiceRow): void {
this.store$.dispatch(serviceChanged({ service: { ...service, enable: !service.enable } }));

this.ws.call('service.update', [service.id, { enable: !service.enable }])
this.api.call('service.update', [service.id, { enable: !service.enable }])
.pipe(
this.loader.withLoader(),
take(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ export class IscsiCardComponent implements OnInit {
private slideInService: SlideInService,
private translate: TranslateService,
private errorHandler: ErrorHandlerService,
private ws: ApiService,
private api: ApiService,
private dialogService: DialogService,
protected emptyService: EmptyService,
private store$: Store<ServicesState>,
) {}

ngOnInit(): void {
const iscsiShares$ = this.ws.call('iscsi.target.query').pipe(untilDestroyed(this));
const iscsiShares$ = this.api.call('iscsi.target.query').pipe(untilDestroyed(this));
this.dataProvider = new AsyncDataProvider<IscsiTarget>(iscsiShares$);
this.setDefaultSort();
this.dataProvider.load();
Expand All @@ -146,7 +146,7 @@ export class IscsiCardComponent implements OnInit {
message: this.translate.instant('Are you sure you want to delete iSCSI Share <b>"{name}"</b>?', { name: iscsi.name }),
}).pipe(
filter(Boolean),
switchMap(() => this.ws.call('iscsi.target.delete', [iscsi.id])),
switchMap(() => this.api.call('iscsi.target.delete', [iscsi.id])),
untilDestroyed(this),
).subscribe({
next: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ export class NfsCardComponent implements OnInit {
private slideInService: SlideInService,
private translate: TranslateService,
private errorHandler: ErrorHandlerService,
private ws: ApiService,
private api: ApiService,
private dialogService: DialogService,
private store$: Store<ServicesState>,
protected emptyService: EmptyService,
) {}

ngOnInit(): void {
const nfsShares$ = this.ws.call('sharing.nfs.query').pipe(untilDestroyed(this));
const nfsShares$ = this.api.call('sharing.nfs.query').pipe(untilDestroyed(this));
this.dataProvider = new AsyncDataProvider<NfsShare>(nfsShares$);
this.setDefaultSort();
this.dataProvider.load();
Expand All @@ -137,7 +137,7 @@ export class NfsCardComponent implements OnInit {
message: this.translate.instant('Are you sure you want to delete NFS Share <b>"{path}"</b>?', { path: nfs.path }),
}).pipe(
filter(Boolean),
switchMap(() => this.ws.call('sharing.nfs.delete', [nfs.id])),
switchMap(() => this.api.call('sharing.nfs.delete', [nfs.id])),
untilDestroyed(this),
).subscribe({
next: () => {
Expand All @@ -152,7 +152,7 @@ export class NfsCardComponent implements OnInit {
private onChangeEnabledState(row: NfsShare): void {
const param = 'enabled';

this.ws.call('sharing.nfs.update', [row.id, { [param]: !row[param] }]).pipe(
this.api.call('sharing.nfs.update', [row.id, { [param]: !row[param] }]).pipe(
accumulateLoadingState(row.id, this.loadingMap$),
untilDestroyed(this),
).subscribe({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class ServiceExtraActionsComponent {

constructor(
private translate: TranslateService,
private ws: ApiService,
private api: ApiService,
private dialogService: DialogService,
private router: Router,
private slideInService: SlideInService,
Expand All @@ -67,7 +67,7 @@ export class ServiceExtraActionsComponent {

changeServiceState(service: Service): void {
const rpc = service.state === ServiceStatus.Running ? 'service.stop' : 'service.start';
this.ws.call(rpc, [service.service, { silent: false }])
this.api.call(rpc, [service.service, { silent: false }])
.pipe(untilDestroyed(this))
.subscribe({
next: (hasChanged: boolean) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ export class SmbCardComponent implements OnInit {
private slideInService: SlideInService,
private translate: TranslateService,
private errorHandler: ErrorHandlerService,
private ws: ApiService,
private api: ApiService,
private dialogService: DialogService,
protected emptyService: EmptyService,
private router: Router,
private store$: Store<ServicesState>,
) {}

ngOnInit(): void {
const smbShares$ = this.ws.call('sharing.smb.query').pipe(untilDestroyed(this));
const smbShares$ = this.api.call('sharing.smb.query').pipe(untilDestroyed(this));
this.dataProvider = new AsyncDataProvider<SmbShare>(smbShares$);
this.setDefaultSort();
this.dataProvider.load();
Expand All @@ -170,7 +170,7 @@ export class SmbCardComponent implements OnInit {
message: this.translate.instant('Are you sure you want to delete SMB Share <b>"{name}"</b>?', { name: smb.name }),
}).pipe(
filter(Boolean),
switchMap(() => this.ws.call('sharing.smb.delete', [smb.id])),
switchMap(() => this.api.call('sharing.smb.delete', [smb.id])),
untilDestroyed(this),
).subscribe({
next: () => {
Expand All @@ -188,7 +188,7 @@ export class SmbCardComponent implements OnInit {
} else {
// A home share has a name (homes) set; row.name works for other shares
const searchName = row.home ? 'homes' : row.name;
this.ws.call('sharing.smb.getacl', [{ share_name: searchName }])
this.api.call('sharing.smb.getacl', [{ share_name: searchName }])
.pipe(untilDestroyed(this))
.subscribe({
next: (shareAcl: SmbSharesec) => {
Expand Down Expand Up @@ -227,7 +227,7 @@ export class SmbCardComponent implements OnInit {
private onChangeEnabledState(row: SmbShare): void {
const param = 'enabled';

this.ws.call('sharing.smb.update', [row.id, { [param]: !row[param] }]).pipe(
this.api.call('sharing.smb.update', [row.id, { [param]: !row[param] }]).pipe(
accumulateLoadingState(row.id, this.loadingMap$),
untilDestroyed(this),
).subscribe({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class AssociatedTargetFormComponent implements OnInit {
constructor(
private translate: TranslateService,
private formBuilder: FormBuilder,
private ws: ApiService,
private api: ApiService,
private iscsiService: IscsiService,
private errorHandler: FormErrorHandlerService,
private cdr: ChangeDetectorRef,
Expand All @@ -109,9 +109,9 @@ export class AssociatedTargetFormComponent implements OnInit {
this.isLoading = true;
let request$: Observable<unknown>;
if (this.isNew) {
request$ = this.ws.call('iscsi.targetextent.create', [values]);
request$ = this.api.call('iscsi.targetextent.create', [values]);
} else {
request$ = this.ws.call('iscsi.targetextent.update', [
request$ = this.api.call('iscsi.targetextent.update', [
this.editingTarget.id,
values,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class AssociatedTargetListComponent implements OnInit {
buttonText: this.translate.instant('Delete'),
}).pipe(
filter(Boolean),
switchMap(() => this.ws.call('iscsi.targetextent.delete', [row.id, true]).pipe(this.loader.withLoader())),
switchMap(() => this.api.call('iscsi.targetextent.delete', [row.id, true]).pipe(this.loader.withLoader())),
untilDestroyed(this),
).subscribe({
next: () => this.dataProvider.load(),
Expand All @@ -157,7 +157,7 @@ export class AssociatedTargetListComponent implements OnInit {
private iscsiService: IscsiService,
private loader: AppLoaderService,
private dialogService: DialogService,
private ws: ApiService,
private api: ApiService,
private translate: TranslateService,
private slideInService: SlideInService,
private cdr: ChangeDetectorRef,
Expand Down
Loading

0 comments on commit a04d02f

Please sign in to comment.