Skip to content

Commit

Permalink
Fix loading a destination on refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
sp90 committed Nov 4, 2024
1 parent 6f80797 commit c13eb06
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/app/backup/backup.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</div>
</spk-stepper>

@if (loadingBackup() && !sysinfoLoaded()) {
@if (loadingBackup() && !sysinfoLoaded() && !finishedLoading()) {
<spk-progress-bar class="indeterminate primary"></spk-progress-bar>
} @else {
<section>
Expand Down
1 change: 1 addition & 0 deletions src/app/backup/backup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default class BackupComponent {
backupId = this.#backupState.backupId;
loadingBackup = this.#backupState.loadingBackup;
sysinfoLoaded = this.#sysinfo.isLoaded;
finishedLoading = this.#backupState.finishedLoading;

ngOnInit() {
const snapshot = this.#route.snapshot;
Expand Down
22 changes: 11 additions & 11 deletions src/app/backup/backup.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ export class BackupState {
#timespanLiteralService = inject(TimespanLiteralsService);
#backupsState = inject(BackupsState);

destinationOptions = this.#sysinfo.backendModules;
generalForm = createGeneralForm();
sourceDataForm = createSourceDataForm();
scheduleForm = createScheduleForm();
destinationForm = createDestinationForm();
optionsForm = createOptionsForm();

isDraft = signal(false);
backupId = signal<'new' | 'string' | null>(null);
isSubmitting = signal(false);
loadingBackup = signal(false);
loadingDefaults = signal(true);
finishedLoading = signal(false);
isNew = computed(() => this.backupId() === 'new');
backupDefaults = signal<any>(null);
generalForm = createGeneralForm();
sourceDataForm = createSourceDataForm();
scheduleForm = createScheduleForm();
destinationForm = createDestinationForm();
optionsForm = createOptionsForm();
isNew = computed(() => this.backupId() === 'new');

selectedAdvancedOptions = signal<FormView[]>([]);
selectedAdvancedFormPair = signal<FormView[]>([]);
notSelectedAdvancedFormPair = signal<FormView[]>([]);
destinationFormPair = signal<DestinationFormPair>({
Expand All @@ -79,17 +79,20 @@ export class BackupState {
dynamic: [],
advanced: [],
});

sourceDataFormSignal = toSignal(this.sourceDataForm.valueChanges);
destinationFormSignal = toSignal(this.destinationForm.valueChanges);
generalFormSignal = toSignal(this.generalForm.valueChanges);
encryptionFieldSignal = toSignal(this.generalForm.controls.encryption.valueChanges);
scheduleFormSignal = toSignal(this.scheduleForm.valueChanges);

destinationOptions = computed(() => this.#sysinfo.sysInfoSignal()?.BackendModules ?? []);
advancedOptions = computed(() => this.#sysinfo.sysInfoSignal()?.Options ?? []);
encryptionOptions = computed(() => {
const encryptionOptions = this.#sysinfo.sysInfoSignal()?.EncryptionModules ?? [];
return [NONE_OPTION, ...encryptionOptions];
});
selectedAdvancedOptions = signal<FormView[]>([]);

nonSelectedAdvancedOptions = computed(() => {
return this.advancedOptions()
.sort((a, b) => (a?.Name && b?.Name ? a?.Name.localeCompare(b?.Name) : 0))
Expand Down Expand Up @@ -178,7 +181,6 @@ export class BackupState {
this.loadingBackup.set(true);

const onBackup = (res: GetBackupResultDto) => {
console.log('hi 1');
this.#mapScheduleToForm(res.Schedule ?? null);

if (res.Backup) {
Expand Down Expand Up @@ -207,8 +209,6 @@ export class BackupState {

onBackup(backup.data);
} else {
console.log('hi');

this.#dupServer
.getApiV1BackupById({
id,
Expand Down

0 comments on commit c13eb06

Please sign in to comment.