Skip to content

Commit

Permalink
NAS-131862 / 25.04 / Fix reboot call (#10933)
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanY147 authored Oct 28, 2024
1 parent 768c57f commit 26de9c0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/core/testing/classes/mock-websocket.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { WebSocketService } from 'app/services/ws.service';
/**
* Better than just expect.anything() because it allows null and undefined.
*/
const anyArgument = when((_: unknown) => true);
const anyArgument = when((_: ApiJobParams<ApiJobMethod>) => true);

/**
* MockWebSocketService can be used to update websocket mocks on the fly.
Expand Down
6 changes: 4 additions & 2 deletions src/app/interfaces/api/api-job-directory.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import {
PoolReplaceParams,
UpdatePool,
} from 'app/interfaces/pool.interface';
import { RebootParams } from 'app/interfaces/reboot.interface';
import { ShutdownParams } from 'app/interfaces/shutdown.interface';
import { SystemDatasetConfig, SystemDatasetUpdate } from 'app/interfaces/system-dataset-config.interface';
import { SystemSecurityConfig } from 'app/interfaces/system-security-config.interface';
import { UpdateParams } from 'app/interfaces/system-update.interface';
Expand Down Expand Up @@ -173,8 +175,8 @@ export interface ApiJobDirectory {
'support.new_ticket': { params: [CreateNewTicket]; response: NewTicketResponse };

// System
'system.reboot': { params: { delay?: number; reason?: string }; response: void };
'system.shutdown': { params: { delay?: number; reason?: string }; response: void };
'system.reboot': { params: RebootParams; response: void };
'system.shutdown': { params: ShutdownParams; response: void };
'system.security.update': { params: [SystemSecurityConfig]; response: void };

// SystemDataset
Expand Down
6 changes: 6 additions & 0 deletions src/app/interfaces/reboot.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type RebootParams = [
reason: string,
config?: {
delay?: number;
},
];
6 changes: 6 additions & 0 deletions src/app/interfaces/shutdown.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type ShutdownParams = [
reason: string,
config?: {
delay?: number;
},
];
2 changes: 1 addition & 1 deletion src/app/pages/system-tasks/restart/restart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class RestartComponent implements OnInit {
this.location.replaceState('/signin');

this.matDialog.closeAll();
this.ws.job('system.reboot', { reason }).pipe(untilDestroyed(this)).subscribe({
this.ws.job('system.reboot', [reason]).pipe(untilDestroyed(this)).subscribe({
error: (error: unknown) => { // error on restart
this.dialogService.error(this.errorHandler.parseError(error))
.pipe(untilDestroyed(this))
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/system-tasks/shutdown/shutdown.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ShutdownComponent implements OnInit {
// Replace URL so that we don't shutdown again if page is refreshed.
this.location.replaceState('/signin');

this.ws.job('system.shutdown', { reason }).pipe(untilDestroyed(this)).subscribe({
this.ws.job('system.shutdown', [reason]).pipe(untilDestroyed(this)).subscribe({
error: (error: unknown) => { // error on shutdown
this.dialogService.error(this.errorHandler.parseError(error))
.pipe(untilDestroyed(this))
Expand Down

0 comments on commit 26de9c0

Please sign in to comment.