Skip to content

Commit

Permalink
NAS-133358: Add more warnings about unsaved changes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKarpov98 committed Jan 3, 2025
1 parent 3d1d3a1 commit 0df65be
Show file tree
Hide file tree
Showing 67 changed files with 300 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
combineLatest,
filter,
forkJoin,
of,
take,
} from 'rxjs';
import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-roles.directive';
Expand Down Expand Up @@ -97,6 +98,9 @@ export class AppsSettingsComponent implements OnInit {
private errorHandler: FormErrorHandlerService,
private fb: FormBuilder,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
this.dockerStore.initialize();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MatButton } from '@angular/material/button';
import { MatCard, MatCardContent } from '@angular/material/card';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { of } from 'rxjs';
import { latestVersion } from 'app/constants/catalog.constants';
import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-roles.directive';
import { Role } from 'app/enums/role.enum';
Expand Down Expand Up @@ -67,7 +68,11 @@ export class PullImageFormComponent {
private fb: FormBuilder,
private translate: TranslateService,
private dialogService: DialogService,
) {}
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
}

onSubmit(): void {
const values = this.form.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { MatCard, MatCardContent } from '@angular/material/card';
import { MatDialog } from '@angular/material/dialog';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateModule } from '@ngx-translate/core';
import { map } from 'rxjs';
import { map, of } from 'rxjs';
import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-roles.directive';
import { Role } from 'app/enums/role.enum';
import { ParamsBuilder } from 'app/helpers/params-builder/params-builder.class';
Expand Down Expand Up @@ -113,6 +113,9 @@ export class ApiKeyFormComponent implements OnInit {
private authService: AuthService,
public slideInRef: SlideInRef<ApiKey | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
this.editingRow.set(slideInRef.getData());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class WidgetGroupFormComponent {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.layoutControl.dirty || this.widgetGroupSlotForm()?.form?.dirty);
});

this.setupLayoutUpdates();
this.setInitialFormValues();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ export class CloudBackupRestoreFromSnapshotFormComponent implements OnInit {

public slideInRef: SlideInRef<{ backup: CloudBackup; snapshot: CloudBackupSnapshot } | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});

this.data = this.slideInRef.getData();
this.form.patchValue({
subFolder: this.data.backup.path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ export class ReplicationWhatAndWhereComponent implements OnInit, SummaryProvider
}

constructor(
public slideInRef: SlideInRef<unknown, unknown>,
private formBuilder: FormBuilder,
private replicationService: ReplicationService,
private keychainCredentials: KeychainCredentialService,
Expand All @@ -174,7 +173,12 @@ export class ReplicationWhatAndWhereComponent implements OnInit, SummaryProvider
private api: ApiService,
private cdr: ChangeDetectorRef,
private errorHandler: ErrorHandlerService,
) {}
public slideInRef: SlideInRef<unknown, unknown>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
}

ngOnInit(): void {
this.disableSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ export class SnapshotTaskFormComponent implements OnInit {
protected storageService: StorageService,
public slideInRef: SlideInRef<PeriodicSnapshotTask | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
this.editingTask = slideInRef.getData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ export class VmwareSnapshotFormComponent implements OnInit {
protected dialogService: DialogService,
public slideInRef: SlideInRef<VmwareSnapshot | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
this.editingSnapshot = slideInRef.getData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { MatButton } from '@angular/material/button';
import { MatCard, MatCardContent } from '@angular/material/card';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { of } from 'rxjs';
import { GiB } from 'app/constants/bytes.constant';
import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-roles.directive';
import { Role } from 'app/enums/role.enum';
Expand Down Expand Up @@ -113,6 +114,9 @@ export class DatasetCapacitySettingsComponent implements OnInit {
private validators: IxValidatorsService,
public slideInRef: SlideInRef<DatasetDetails | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
this.dataset = slideInRef.getData();
this.setFormRelations();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ export class DatasetFormComponent implements OnInit, AfterViewInit {
private store$: Store<AppState>,
public slideInRef: SlideInRef<{ datasetId: string; isNew?: boolean } | undefined, Dataset>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(
this.form.dirty
|| this.nameAndOptionsSection().form.dirty
|| this.encryptionSection().form.dirty
|| this.otherOptionsSection().form.dirty
|| this.quotasSection()?.form.dirty,
);
});
this.slideInData = slideInRef.getData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MatCard, MatCardContent } from '@angular/material/card';
import { FormBuilder } from '@ngneat/reactive-forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { combineLatest, map } from 'rxjs';
import { combineLatest, map, of } from 'rxjs';
import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-roles.directive';
import { DatasetQuotaType } from 'app/enums/dataset.enum';
import { Role } from 'app/enums/role.enum';
Expand Down Expand Up @@ -138,6 +138,10 @@ export class DatasetQuotaAddFormComponent implements OnInit {
private userService: UserService,
public slideInRef: SlideInRef<{ quotaType: DatasetQuotaType; datasetId: string } | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});

this.quotaType = slideInRef.getData().quotaType;
this.datasetId = slideInRef.getData().datasetId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ export class DatasetQuotaEditFormComponent implements OnInit {
protected dialogService: DialogService,
public slideInRef: SlideInRef<{ quotaType: DatasetQuotaType; datasetId: string; id: number } | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});

this.datasetId = slideInRef.getData().datasetId;
this.quotaType = slideInRef.getData().quotaType;
this.id = slideInRef.getData().id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ export class ZvolFormComponent implements OnInit {
protected snackbar: SnackbarService,
public slideInRef: SlideInRef<{ isNew: boolean; parentId: string } | undefined, Dataset>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});

this.slideInData = slideInRef.getData();
this.form.controls.key.disable();
this.form.controls.passphrase.disable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ export class SnapshotAddFormComponent implements OnInit {
private datasetStore: DatasetTreeStore,
public slideInRef: SlideInRef<string | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
this.datasetId = slideInRef.getData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { MatDialog } from '@angular/material/dialog';
import { FormBuilder } from '@ngneat/reactive-forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateService, TranslateModule } from '@ngx-translate/core';
import { forkJoin, Observable } from 'rxjs';
import { forkJoin, Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-roles.directive';
import { DirectoryServiceState } from 'app/enums/directory-service-state.enum';
Expand Down Expand Up @@ -115,7 +115,11 @@ export class ActiveDirectoryComponent implements OnInit {
private translate: TranslateService,
private snackbarService: SnackbarService,
public slideInRef: SlideInRef<ActiveDirectoryComponent | undefined, boolean>,
) {}
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
}

ngOnInit(): void {
this.loadFormValues();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ export class IdmapFormComponent implements OnInit {
private snackbar: SnackbarService,
public slideInRef: SlideInRef<Idmap | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
this.existingIdmap = slideInRef.getData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MatButton } from '@angular/material/button';
import { MatCard, MatCardContent } from '@angular/material/card';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateService, TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { Observable, of } from 'rxjs';
import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-roles.directive';
import { Role } from 'app/enums/role.enum';
import { helptextKerberosKeytabs } from 'app/helptext/directory-service/kerberos-keytabs-form-list';
Expand Down Expand Up @@ -73,6 +73,9 @@ export class KerberosKeytabsFormComponent implements OnInit {
private api: ApiService,
public slideInRef: SlideInRef<KerberosKeytab | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
this.editingKerberosKeytab = slideInRef.getData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MatButton } from '@angular/material/button';
import { MatCard, MatCardContent } from '@angular/material/card';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateService, TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { Observable, of } from 'rxjs';
import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-roles.directive';
import { Role } from 'app/enums/role.enum';
import { helptextKerberosRealms } from 'app/helptext/directory-service/kerberos-realms-form-list';
Expand Down Expand Up @@ -80,6 +80,9 @@ export class KerberosRealmsFormComponent implements OnInit {
private translate: TranslateService,
public slideInRef: SlideInRef<KerberosRealm | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
this.editingRealm = slideInRef.getData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { MatButton } from '@angular/material/button';
import { MatCard, MatCardContent } from '@angular/material/card';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateModule } from '@ngx-translate/core';
import { of } from 'rxjs';
import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-roles.directive';
import { Role } from 'app/enums/role.enum';
import { helptextKerberosSettings } from 'app/helptext/directory-service/kerberos-settings';
Expand Down Expand Up @@ -64,7 +65,11 @@ export class KerberosSettingsComponent implements OnInit {
private fb: FormBuilder,
private dialogService: DialogService,
public slideInRef: SlideInRef<KerberosSettingsComponent | undefined, boolean>,
) {}
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
}

ngOnInit(): void {
this.isFormLoading = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MatCard, MatCardContent } from '@angular/material/card';
import { FormBuilder } from '@ngneat/reactive-forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateService, TranslateModule } from '@ngx-translate/core';
import { of } from 'rxjs';
import { map } from 'rxjs/operators';
import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-roles.directive';
import { Role } from 'app/enums/role.enum';
Expand Down Expand Up @@ -113,7 +114,11 @@ export class LdapComponent implements OnInit {
private translate: TranslateService,
private snackbar: SnackbarService,
public slideInRef: SlideInRef<LdapComponent | undefined, boolean>,
) {}
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
}

ngOnInit(): void {
this.loadFormValues();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ export class NetworkConfigurationComponent implements OnInit {
private systemGeneralService: SystemGeneralService,
private store$: Store<AppState>,
public slideInRef: SlideInRef<undefined, boolean>,
) {}
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
}

ngOnInit(): void {
this.isFormLoading = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ export class InterfaceFormComponent implements OnInit {
private store$: Store<AppState>,
public slideInRef: SlideInRef<NetworkInterface | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
this.existingInterface = slideInRef.getData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ export class IpmiFormComponent implements OnInit {
private dialogService: DialogService,
public slideInRef: SlideInRef<number | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
this.ipmiId = this.slideInRef.getData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ export class ReportingExportersFormComponent implements OnInit {
private dialogService: DialogService,
public slideInRef: SlideInRef<ReportingExporter | undefined, boolean>,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
this.editingExporter = this.slideInRef.getData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ export class ServiceFtpComponent implements OnInit {
private snackbar: SnackbarService,
public iecFormatter: IxFormatterService,
public slideInRef: SlideInRef<undefined, boolean>,
) {}
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
}

ngOnInit(): void {
this.loadConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ export class ServiceNfsComponent implements OnInit {
private matDialog: MatDialog,
private validatorsService: IxValidatorsService,
public slideInRef: SlideInRef<undefined, boolean>,
) {}
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
}

ngOnInit(): void {
this.isFormLoading.set(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ export class ServiceSmartComponent implements OnInit {
private dialogService: DialogService,
private snackbar: SnackbarService,
public slideInRef: SlideInRef<undefined, boolean>,
) {}
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});
}

ngOnInit(): void {
this.isFormLoading = true;
Expand Down
Loading

0 comments on commit 0df65be

Please sign in to comment.