Skip to content

Commit

Permalink
NAS-132527: Rename some instances of websocket (#11040)
Browse files Browse the repository at this point in the history
  • Loading branch information
undsoft authored Nov 15, 2024
1 parent 1f6c5cd commit 663e7bc
Show file tree
Hide file tree
Showing 203 changed files with 802 additions and 806 deletions.
14 changes: 7 additions & 7 deletions src/app/modules/alerts/store/alert.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class AlertEffects {
loadAlerts$ = createEffect(() => this.actions$.pipe(
ofType(adminUiInitialized, alertIndicatorPressed, alertReceivedWhenPanelIsOpen),
switchMap(() => {
return this.ws.call('alert.list').pipe(
return this.api.call('alert.list').pipe(
map((alerts) => alertsLoaded({ alerts })),
catchError((error) => {
console.error(error);
Expand All @@ -51,7 +51,7 @@ export class AlertEffects {
subscribeToUpdates$ = createEffect(() => this.actions$.pipe(
ofType(adminUiInitialized),
switchMap(() => {
return this.ws.subscribe('alert.list').pipe(
return this.api.subscribe('alert.list').pipe(
switchMap((event) => {
return this.store$.select(selectIsAlertPanelOpen).pipe(
switchMap((isAlertsPanelOpen) => {
Expand Down Expand Up @@ -80,7 +80,7 @@ export class AlertEffects {
dismissAlert$ = createEffect(() => this.actions$.pipe(
ofType(dismissAlertPressed),
mergeMap(({ id }) => {
return this.ws.call('alert.dismiss', [id]).pipe(
return this.api.call('alert.dismiss', [id]).pipe(
catchError((error) => {
this.errorHandler.showErrorModal(error);
this.store$.dispatch(alertChanged({ alert: { id, dismissed: false } as Alert }));
Expand All @@ -93,7 +93,7 @@ export class AlertEffects {
reopenAlert$ = createEffect(() => this.actions$.pipe(
ofType(reopenAlertPressed),
mergeMap(({ id }) => {
return this.ws.call('alert.restore', [id]).pipe(
return this.api.call('alert.restore', [id]).pipe(
catchError((error) => {
this.errorHandler.showErrorModal(error);
this.store$.dispatch(alertChanged({ alert: { id, dismissed: true } as Alert }));
Expand All @@ -107,7 +107,7 @@ export class AlertEffects {
ofType(dismissAllAlertsPressed),
withLatestFrom(this.store$.select(selectUnreadAlerts).pipe(pairwise())),
mergeMap(([, [unreadAlerts]]) => {
const requests = unreadAlerts.map((alert) => this.ws.call('alert.dismiss', [alert.id]));
const requests = unreadAlerts.map((alert) => this.api.call('alert.dismiss', [alert.id]));
return forkJoin(requests).pipe(
catchError((error) => {
this.errorHandler.showErrorModal(error);
Expand All @@ -123,7 +123,7 @@ export class AlertEffects {
ofType(reopenAllAlertsPressed),
withLatestFrom(this.store$.select(selectDismissedAlerts).pipe(pairwise())),
mergeMap(([, [dismissedAlerts]]) => {
const requests = dismissedAlerts.map((alert) => this.ws.call('alert.restore', [alert.id]));
const requests = dismissedAlerts.map((alert) => this.api.call('alert.restore', [alert.id]));
return forkJoin(requests).pipe(
catchError((error) => {
this.errorHandler.showErrorModal(error);
Expand All @@ -136,7 +136,7 @@ export class AlertEffects {

constructor(
private actions$: Actions,
private ws: ApiService,
private api: ApiService,
private store$: Store<AlertSlice>,
private translate: TranslateService,
private errorHandler: ErrorHandlerService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class ExportButtonComponent<T, M extends ApiJobMethod> {
protected readonly isHaLicensed = toSignal(this.store$.select(selectIsHaLicensed));

constructor(
private ws: ApiService,
private api: ApiService,
private cdr: ChangeDetectorRef,
private errorHandler: ErrorHandlerService,
private dialogService: DialogService,
Expand All @@ -67,7 +67,7 @@ export class ExportButtonComponent<T, M extends ApiJobMethod> {

onExport(): void {
this.isLoading = true;
this.ws.job(this.jobMethod, this.getExportParams(
this.api.job(this.jobMethod, this.getExportParams(
this.getQueryFilters(this.searchQuery),
this.getQueryOptions(this.sorting),
)).pipe(
Expand All @@ -89,7 +89,7 @@ export class ExportButtonComponent<T, M extends ApiJobMethod> {
customArguments.report_name = url;
}

return this.ws.call('core.download', [downloadMethod, [customArguments], url]);
return this.api.call('core.download', [downloadMethod, [customArguments], url]);
}),
switchMap(([, url]) => this.download.downloadUrl(url, `${this.filename}.${this.fileType}`, this.fileMimeType)),
catchError((error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class ErrorDialogComponent {

constructor(
public dialogRef: MatDialogRef<ErrorDialogComponent>,
private ws: ApiService,
private api: ApiService,
private download: DownloadService,
private errorHandler: ErrorHandlerService,
private dialogService: DialogService,
Expand All @@ -63,7 +63,7 @@ export class ErrorDialogComponent {
}

downloadLogs(): void {
this.ws.call('core.job_download_logs', [this.logs.id, `${this.logs.id}.log`]).pipe(untilDestroyed(this)).subscribe({
this.api.call('core.job_download_logs', [this.logs.id, `${this.logs.id}.log`]).pipe(untilDestroyed(this)).subscribe({
next: (url) => {
const mimetype = 'text/plain';
this.download.streamDownloadFile(url, `${this.logs.id}.log`, mimetype).pipe(untilDestroyed(this)).subscribe({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class JobProgressDialogComponent<T> implements OnInit, AfterViewChecked {
constructor(
private dialogRef: MatDialogRef<JobProgressDialogComponent<T>, MatDialogConfig>,
@Inject(MAT_DIALOG_DATA) public data: JobProgressDialogConfig<T>,
private ws: ApiService,
private api: ApiService,
private cdr: ChangeDetectorRef,
private errorHandler: ErrorHandlerService,
) { }
Expand Down Expand Up @@ -199,7 +199,7 @@ export class JobProgressDialogComponent<T> implements OnInit, AfterViewChecked {
}

abortJob(): void {
this.ws.call('core.job_abort', [this.job.id]).pipe(
this.api.call('core.job_abort', [this.job.id]).pipe(
this.errorHandler.catchError(),
untilDestroyed(this),
)
Expand All @@ -218,7 +218,7 @@ export class JobProgressDialogComponent<T> implements OnInit, AfterViewChecked {
this.realtimeLogsSubscribed = true;
const subName = 'filesystem.file_tail_follow:' + this.job.logs_path;
this.cdr.markForCheck();
return this.ws.subscribeToLogs(subName)
return this.api.subscribeToLogs(subName)
.pipe(map((apiEvent) => apiEvent.fields), untilDestroyed(this))
.subscribe((logs) => {
if (logs?.data && typeof logs.data === 'string') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ErrorTemplateComponent {
@Input() logs: Job;

constructor(
private ws: ApiService,
private api: ApiService,
private download: DownloadService,
private errorHandler: ErrorHandlerService,
private dialogService: DialogService,
Expand All @@ -68,7 +68,7 @@ export class ErrorTemplateComponent {
}

downloadLogs(): void {
this.ws.call('core.job_download_logs', [this.logs.id, `${this.logs.id}.log`])
this.api.call('core.job_download_logs', [this.logs.id, `${this.logs.id}.log`])
.pipe(this.errorHandler.catchError(), untilDestroyed(this))
.subscribe((url) => {
const mimetype = 'text/plain';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ import { ErrorHandlerService } from 'app/services/error-handler.service';
})
export class ShowLogsDialogComponent {
constructor(
private ws: ApiService,
private api: ApiService,
private errorHandler: ErrorHandlerService,
private download: DownloadService,
private dialogService: DialogService,
@Inject(MAT_DIALOG_DATA) public job: Job,
) { }

downloadLogs(): void {
this.ws.call('core.job_download_logs', [this.job.id, `${this.job.id}.log`]).pipe(
this.api.call('core.job_download_logs', [this.job.id, `${this.job.id}.log`]).pipe(
switchMap((url) => this.download.downloadUrl(url, `${this.job.id}.log`, 'text/plain')),
catchError((error: HttpErrorResponse | Job) => {
this.dialogService.error(this.errorHandler.parseError(error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class StartServiceDialogComponent implements OnInit {
}

constructor(
private ws: ApiService,
private api: ApiService,
private cdr: ChangeDetectorRef,
private translate: TranslateService,
private snackbar: SnackbarService,
Expand Down Expand Up @@ -94,11 +94,11 @@ export class StartServiceDialogComponent implements OnInit {
};

if (result.start && result.startAutomatically && this.isDisabled) {
requests.push(this.ws.call('service.update', [this.service.id, { enable: result.startAutomatically }]));
requests.push(this.api.call('service.update', [this.service.id, { enable: result.startAutomatically }]));
}

if (result.start) {
requests.push(this.ws.call('service.start', [this.serviceName, { silent: false }]));
requests.push(this.api.call('service.start', [this.serviceName, { silent: false }]));
}

forkJoin(requests)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class FileTicketLicensedComponent {
private imageValidator: ImageValidatorService,
private formErrorHandler: FormErrorHandlerService,
@Inject(WINDOW) private window: Window,
private ws: ApiService,
private api: ApiService,
) {
this.getSystemFileSizeLimit();
}
Expand Down Expand Up @@ -154,7 +154,7 @@ export class FileTicketLicensedComponent {
}

private getSystemFileSizeLimit(): void {
this.ws.call('support.attach_ticket_max_size').pipe(untilDestroyed(this)).subscribe((size) => {
this.api.call('support.attach_ticket_max_size').pipe(untilDestroyed(this)).subscribe((size) => {
this.form.controls.images.addAsyncValidators(
this.imageValidator.getImagesValidator(size * MiB),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class FileTicketComponent {
private feedbackService: FeedbackService,
private imageValidator: ImageValidatorService,
private formErrorHandler: FormErrorHandlerService,
private ws: ApiService,
private api: ApiService,
) {
this.getSystemFileSizeLimit();
}
Expand All @@ -106,7 +106,7 @@ export class FileTicketComponent {
}

private getSystemFileSizeLimit(): void {
this.ws.call('support.attach_ticket_max_size').pipe(untilDestroyed(this)).subscribe((size) => {
this.api.call('support.attach_ticket_max_size').pipe(untilDestroyed(this)).subscribe((size) => {
this.form.controls.images.addAsyncValidators(this.imageValidator.getImagesValidator(size * MiB));
this.form.controls.images.updateValueAndValidity();
});
Expand Down
8 changes: 4 additions & 4 deletions src/app/modules/feedback/services/feedback.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class FeedbackService {

constructor(
private httpClient: HttpClient,
private ws: ApiService,
private api: ApiService,
private store$: Store<AppState>,
private systemGeneralService: SystemGeneralService,
private sentryService: SentryService,
Expand Down Expand Up @@ -157,7 +157,7 @@ export class FeedbackService {
}

getSimilarIssues(query: string): Observable<SimilarIssue[]> {
return this.ws.call('support.similar_issues', [query]);
return this.api.call('support.similar_issues', [query]);
}

addDebugInfoToMessage(message: string): Observable<string> {
Expand Down Expand Up @@ -261,12 +261,12 @@ export class FeedbackService {
filter((systemInfoState) => Boolean(systemInfoState.systemInfo)),
take(1),
),
this.ws.call('system.host_id'),
this.api.call('system.host_id'),
]);
}

private addTicket(ticket: CreateNewTicket): Observable<NewTicketResponse> {
return this.ws.job('support.new_ticket', [ticket]).pipe(
return this.api.job('support.new_ticket', [ticket]).pipe(
filter((job) => job.state === JobState.Success),
map((job) => job.result),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class UnusedDiskSelectComponent implements OnInit, AfterViewInit {
return getNonUniqueSerialDisksWarning(this.nonUniqueSerialDisks(), this.translate);
});

private unusedDisks$ = this.ws.call('disk.details').pipe(
private unusedDisks$ = this.api.call('disk.details').pipe(
map((diskDetails) => {
return [
...diskDetails.unused,
Expand Down Expand Up @@ -105,7 +105,7 @@ export class UnusedDiskSelectComponent implements OnInit, AfterViewInit {
constructor(
private dialogService: DialogService,
private translate: TranslateService,
private ws: ApiService,
private api: ApiService,
) {}

ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class CreateDatasetDialogComponent implements OnInit {
constructor(
private fb: FormBuilder,
private cdr: ChangeDetectorRef,
private ws: ApiService,
private api: ApiService,
private dialog: DialogService,
private errorHandler: ErrorHandlerService,
private dialogRef: MatDialogRef<CreateDatasetDialogComponent>,
Expand All @@ -89,7 +89,7 @@ export class CreateDatasetDialogComponent implements OnInit {

createDataset(): void {
this.isLoading$.next(true);
this.ws.call('pool.dataset.create', [{ ...this.data.dataset, name: `${this.parent.name}/${this.form.value.name}` }])
this.api.call('pool.dataset.create', [{ ...this.data.dataset, name: `${this.parent.name}/${this.form.value.name}` }])
.pipe(untilDestroyed(this)).subscribe({
next: (dataset) => {
this.isLoading$.next(false);
Expand All @@ -105,7 +105,7 @@ export class CreateDatasetDialogComponent implements OnInit {
loadParentDataset(): void {
this.isLoading$.next(true);
const normalizedParentId = this.data.parentId.replace(/\/$/, '');
this.ws.call('pool.dataset.query', [[['id', '=', normalizedParentId]]]).pipe(
this.api.call('pool.dataset.query', [[['id', '=', normalizedParentId]]]).pipe(
tap((parent) => {
if (!parent.length) {
throw new Error(`Parent dataset ${normalizedParentId} not found`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class ApiDataProvider<T extends QueryMethods> extends BaseDataProvider<Ap
private rows: ApiCallResponseType<T>[] = [];

constructor(
protected ws: ApiService,
protected api: ApiService,
protected method: T,
protected params: ApiCallParams<T> = [],
) {
Expand All @@ -38,7 +38,7 @@ export class ApiDataProvider<T extends QueryMethods> extends BaseDataProvider<Ap
this.countRows().pipe(
switchMap((count: number) => {
this.totalRows = count;
return this.ws.call(this.method, this.prepareParams(this.params)) as Observable<ApiCallResponseType<T>[]>;
return this.api.call(this.method, this.prepareParams(this.params)) as Observable<ApiCallResponseType<T>[]>;
}),
).subscribe({
next: (rows: ApiCallResponseType<T>[]) => {
Expand Down Expand Up @@ -80,7 +80,7 @@ export class ApiDataProvider<T extends QueryMethods> extends BaseDataProvider<Ap
{ count: true },
] as ApiCallParams<T>;

return this.ws.call(this.method, params) as unknown as Observable<number>;
return this.api.call(this.method, params) as unknown as Observable<number>;
}

protected prepareParams(params: ApiCallParams<T>): ApiCallParams<T> {
Expand Down
12 changes: 6 additions & 6 deletions src/app/modules/jobs/store/job.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export class JobEffects {
loadJobs$ = createEffect(() => this.actions$.pipe(
ofType(adminUiInitialized),
switchMap(() => {
const getNotCompletedJobs$ = this.ws.call('core.get_jobs', [[['state', '!=', JobState.Success]]]);
const getCompletedJobs$ = this.ws.call('core.get_jobs', [[['state', '=', JobState.Success]], { order_by: ['-id'], limit: 30 }]);
const getNotCompletedJobs$ = this.api.call('core.get_jobs', [[['state', '!=', JobState.Success]]]);
const getCompletedJobs$ = this.api.call('core.get_jobs', [[['state', '=', JobState.Success]], { order_by: ['-id'], limit: 30 }]);

return forkJoin([
getNotCompletedJobs$,
Expand All @@ -43,7 +43,7 @@ export class JobEffects {
subscribeToUpdates$ = createEffect(() => this.actions$.pipe(
ofType(jobsLoaded),
switchMap(() => {
return this.ws.subscribe('core.get_jobs').pipe(
return this.api.subscribe('core.get_jobs').pipe(
filter((event) => event.msg !== IncomingApiMessageType.Removed),
switchMap((event) => {
switch (event.msg) {
Expand All @@ -62,7 +62,7 @@ export class JobEffects {
subscribeToRemoval$ = createEffect(() => this.actions$.pipe(
ofType(jobsLoaded),
switchMap(() => {
return this.ws.subscribe('core.get_jobs').pipe(
return this.api.subscribe('core.get_jobs').pipe(
filter((event) => event.msg === IncomingApiMessageType.Removed),
map((event) => jobRemoved({ id: event.id as number })),
);
Expand All @@ -72,15 +72,15 @@ export class JobEffects {
abortJob$ = createEffect(() => this.actions$.pipe(
ofType(abortJobPressed),
switchMap(({ job }) => {
return this.ws.call('core.job_abort', [job.id]).pipe(
return this.api.call('core.job_abort', [job.id]).pipe(
map(() => jobAborted({ job })),
);
}),
));

constructor(
private actions$: Actions,
private ws: ApiService,
private api: ApiService,
private translate: TranslateService,
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export class ConsoleMessagesStore extends ComponentStore<ConsoleMessagesState> i
});

constructor(
private ws: ApiService,
private api: ApiService,
) {
super(initialConsoleMessagesState);
}

subscribeToMessageUpdates(): void {
this.ws.subscribeToLogs(this.logPath)
this.api.subscribeToLogs(this.logPath)
.pipe(
map((event) => event.fields),
filter((log) => typeof log?.data === 'string'),
Expand Down
Loading

0 comments on commit 663e7bc

Please sign in to comment.