-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAS-131138 / 25.04 / Add dialog for Shutdown/Restart Reason (#10821)
* NAS-131138: Add dialog for Shutdown/Restart Reason * NAS-131138: Add custom reason option --------- Co-authored-by: Boris Vasilenko <[email protected]>
- Loading branch information
1 parent
d9ab633
commit 6e2d054
Showing
96 changed files
with
2,174 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
.../modules/layout/topbar/reboot-or-shutdown-dialog/reboot-or-shutdown-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<h3 mat-dialog-title>{{ title }}</h3> | ||
|
||
<div mat-dialog-content> | ||
<ix-select | ||
[formControl]="form.controls.reason" | ||
[label]="'Reason' | translate" | ||
[options]="reasonOptions$" | ||
[required]="true" | ||
></ix-select> | ||
@if(form.controls.customReason.enabled) { | ||
<ix-input | ||
[formControl]="form.controls.customReason" | ||
[label]="'Custom Reason' | translate" | ||
[required]="true" | ||
></ix-input> | ||
} | ||
</div> | ||
|
||
<ix-form-actions mat-dialog-actions class="form-actions"> | ||
<ix-checkbox | ||
class="confirm" | ||
[formControl]="form.controls.confirm" | ||
[label]="'Confirm' | translate" | ||
[required]="true" | ||
></ix-checkbox> | ||
|
||
<button mat-button type="button" matDialogClose ixTest="cancel"> | ||
{{ 'Cancel' | translate }} | ||
</button> | ||
|
||
<button | ||
mat-button | ||
type="submit" | ||
color="primary" | ||
ixTest="submit" | ||
[disabled]="form.invalid" | ||
(click)="onSubmit()" | ||
> | ||
{{ buttonText }} | ||
</button> | ||
</ix-form-actions> |
4 changes: 4 additions & 0 deletions
4
.../modules/layout/topbar/reboot-or-shutdown-dialog/reboot-or-shutdown-dialog.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.confirm { | ||
margin-right: auto; | ||
padding-right: 10px; | ||
} |
138 changes: 138 additions & 0 deletions
138
...pp/modules/layout/topbar/reboot-or-shutdown-dialog/reboot-or-shutdown-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import { ChangeDetectionStrategy, Component, Inject } from '@angular/core'; | ||
import { ReactiveFormsModule, Validators } from '@angular/forms'; | ||
import { MatButton } from '@angular/material/button'; | ||
import { | ||
MatDialogRef, MatDialogContent, MatDialogActions, MatDialogTitle, | ||
MAT_DIALOG_DATA, | ||
MatDialogModule, | ||
} from '@angular/material/dialog'; | ||
import { FormBuilder } from '@ngneat/reactive-forms'; | ||
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; | ||
import { TranslateModule, TranslateService } from '@ngx-translate/core'; | ||
import { Observable, of } from 'rxjs'; | ||
import { SelectOption } from 'app/interfaces/option.interface'; | ||
import { IxCheckboxComponent } from 'app/modules/forms/ix-forms/components/ix-checkbox/ix-checkbox.component'; | ||
import { IxInputComponent } from 'app/modules/forms/ix-forms/components/ix-input/ix-input.component'; | ||
import { IxSelectComponent } from 'app/modules/forms/ix-forms/components/ix-select/ix-select.component'; | ||
import { TestDirective } from 'app/modules/test-id/test.directive'; | ||
|
||
const customReasonValue = 'CUSTOM_REASON_VALUE'; | ||
|
||
@UntilDestroy() | ||
@Component({ | ||
selector: 'ix-reboot-or-shutdown-dialog', | ||
templateUrl: './reboot-or-shutdown-dialog.component.html', | ||
styleUrls: ['./reboot-or-shutdown-dialog.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [ | ||
MatDialogTitle, | ||
MatDialogContent, | ||
MatDialogActions, | ||
MatDialogModule, | ||
MatButton, | ||
TranslateModule, | ||
TestDirective, | ||
ReactiveFormsModule, | ||
IxCheckboxComponent, | ||
IxSelectComponent, | ||
IxInputComponent, | ||
], | ||
}) | ||
export class RebootOrShutdownDialogComponent { | ||
form = this.fb.group({ | ||
confirm: [false, Validators.requiredTrue], | ||
reason: ['', Validators.required], | ||
customReason: ['', Validators.required], | ||
}); | ||
|
||
readonly reasonOptions$: Observable<SelectOption[]> = of([ | ||
{ | ||
label: this.translate.instant('Custom Reason'), | ||
value: customReasonValue, | ||
}, | ||
{ | ||
label: this.translate.instant('System Update'), | ||
tooltip: this.translate.instant('Applying important system or security updates.'), | ||
value: 'Applying important system or security updates.', | ||
}, | ||
{ | ||
label: this.translate.instant('Hardware Change'), | ||
tooltip: this.translate.instant('Adding, removing, or changing hardware components.'), | ||
value: 'Adding, removing, or changing hardware components.', | ||
}, | ||
{ | ||
label: this.translate.instant('Troubleshooting Issues'), | ||
tooltip: this.translate.instant('Required reset to fix system operation issues.'), | ||
value: 'Required reset to fix system operation issues.', | ||
}, | ||
{ | ||
label: this.translate.instant('Power Outage'), | ||
tooltip: this.translate.instant('Unexpected power loss necessitating a reboot.'), | ||
value: 'Unexpected power loss necessitating a reboot.', | ||
}, | ||
{ | ||
label: this.translate.instant('Maintenance Window'), | ||
tooltip: this.translate.instant('Regularly scheduled system checks and updates.'), | ||
value: 'Regularly scheduled system checks and updates.', | ||
}, | ||
{ | ||
label: this.translate.instant('System Overload'), | ||
tooltip: this.translate.instant('High usage necessitating a system reset.'), | ||
value: 'High usage necessitating a system reset.', | ||
}, | ||
{ | ||
label: this.translate.instant('Software Installation'), | ||
tooltip: this.translate.instant('Required reboot after new software installation.'), | ||
value: 'Required reboot after new software installation.', | ||
}, | ||
{ | ||
label: this.translate.instant('Performance Optimization'), | ||
tooltip: this.translate.instant('Restart to improve system performance speed.'), | ||
value: 'Restart to improve system performance speed.', | ||
}, | ||
{ | ||
label: this.translate.instant('Network Reset'), | ||
tooltip: this.translate.instant('Restart to re-establish network connections.'), | ||
value: 'Restart to re-establish network connections.', | ||
}, | ||
{ | ||
label: this.translate.instant('System Freeze'), | ||
tooltip: this.translate.instant('Unresponsive system necessitating a forced reboot.'), | ||
value: 'Unresponsive system necessitating a forced reboot.', | ||
}, | ||
]); | ||
|
||
get title(): string { | ||
return this.isShutdown | ||
? this.translate.instant('Shut down') | ||
: this.translate.instant('Restart'); | ||
} | ||
|
||
get buttonText(): string { | ||
return this.isShutdown | ||
? this.translate.instant('Shut Down') | ||
: this.translate.instant('Restart'); | ||
} | ||
|
||
constructor( | ||
public dialogRef: MatDialogRef<RebootOrShutdownDialogComponent>, | ||
private fb: FormBuilder, | ||
private translate: TranslateService, | ||
@Inject(MAT_DIALOG_DATA) public isShutdown = false, | ||
) { | ||
this.form.controls.reason.valueChanges.pipe(untilDestroyed(this)).subscribe((reason) => { | ||
if (reason === customReasonValue) { | ||
this.form.controls.customReason.enable(); | ||
} else { | ||
this.form.controls.customReason.disable(); | ||
} | ||
}); | ||
} | ||
|
||
onSubmit(): void { | ||
const formValue = this.form.value; | ||
const reason = formValue.reason === customReasonValue ? formValue.customReason : formValue.reason; | ||
this.dialogRef.close(reason); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.