diff --git a/src/app/interfaces/api/api-job-directory.interface.ts b/src/app/interfaces/api/api-job-directory.interface.ts index fd59144c1c8..cfa74787109 100644 --- a/src/app/interfaces/api/api-job-directory.interface.ts +++ b/src/app/interfaces/api/api-job-directory.interface.ts @@ -166,8 +166,8 @@ export interface ApiJobDirectory { 'support.new_ticket': { params: [CreateNewTicket]; response: NewTicketResponse }; // System - 'system.reboot': { params: { delay?: number }; response: void }; - 'system.shutdown': { params: { delay?: number }; response: void }; + 'system.reboot': { params: { delay?: number; reason: string }; response: void }; + 'system.shutdown': { params: { delay?: number; reason: string }; response: void }; 'system.security.update': { params: [SystemSecurityConfig]; response: void }; // SystemDataset diff --git a/src/app/pages/system-tasks/reboot/reboot.component.ts b/src/app/pages/system-tasks/reboot/reboot.component.ts index fb4f2497774..7c9178d2098 100644 --- a/src/app/pages/system-tasks/reboot/reboot.component.ts +++ b/src/app/pages/system-tasks/reboot/reboot.component.ts @@ -1,7 +1,7 @@ import { Location } from '@angular/common'; import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { DialogService } from 'app/modules/dialog/dialog.service'; import { AppLoaderService } from 'app/modules/loader/app-loader.service'; @@ -21,6 +21,7 @@ export class RebootComponent implements OnInit { protected ws: WebSocketService, private wsManager: WebSocketConnectionService, protected router: Router, + private route: ActivatedRoute, private errorHandler: ErrorHandlerService, protected loader: AppLoaderService, protected dialogService: DialogService, @@ -30,11 +31,13 @@ export class RebootComponent implements OnInit { } ngOnInit(): void { + const reason = this.route.snapshot.queryParamMap.get('reason') || 'Unknown Reason'; + // Replace URL so that we don't reboot again if page is refreshed. this.location.replaceState('/signin'); this.matDialog.closeAll(); - this.ws.job('system.reboot').pipe(untilDestroyed(this)).subscribe({ + this.ws.job('system.reboot', { reason }).pipe(untilDestroyed(this)).subscribe({ error: (error: unknown) => { // error on reboot this.dialogService.error(this.errorHandler.parseError(error)) .pipe(untilDestroyed(this)) diff --git a/src/app/pages/system-tasks/shutdown/shutdown.component.ts b/src/app/pages/system-tasks/shutdown/shutdown.component.ts index 675d783ff06..7356ef76638 100644 --- a/src/app/pages/system-tasks/shutdown/shutdown.component.ts +++ b/src/app/pages/system-tasks/shutdown/shutdown.component.ts @@ -1,6 +1,6 @@ import { Location } from '@angular/common'; import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { DialogService } from 'app/modules/dialog/dialog.service'; import { ErrorHandlerService } from 'app/services/error-handler.service'; @@ -20,15 +20,18 @@ export class ShutdownComponent implements OnInit { private wsManager: WebSocketConnectionService, private errorHandler: ErrorHandlerService, protected router: Router, + private route: ActivatedRoute, protected dialogService: DialogService, private location: Location, ) {} ngOnInit(): void { + const reason = this.route.snapshot.queryParamMap.get('reason') || 'Unknown Reason'; + // Replace URL so that we don't shutdown again if page is refreshed. this.location.replaceState('/signin'); - this.ws.job('system.shutdown', {}).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))