Skip to content

Commit

Permalink
Revert "NAS-132263: Change Truecloud Backup form to have a dropdown f…
Browse files Browse the repository at this point in the history
…or transfer_setting"

This reverts commit cb11361.
  • Loading branch information
undsoft committed Nov 12, 2024
1 parent cb11361 commit 9dd7883
Show file tree
Hide file tree
Showing 97 changed files with 81 additions and 244 deletions.
13 changes: 0 additions & 13 deletions src/app/enums/cloudsync-transfer-setting.enum.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/app/interfaces/api/api-call-directory.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AlertPolicy } from 'app/enums/alert-policy.enum';
import { CloudsyncTransferSetting } from 'app/enums/cloudsync-transfer-setting.enum';
import { DatasetRecordSize, DatasetType } from 'app/enums/dataset.enum';
import { DeviceType } from 'app/enums/device-type.enum';
import { DockerConfig, DockerStatusData } from 'app/enums/docker-config.interface';
Expand Down Expand Up @@ -390,7 +389,6 @@ export interface ApiCallDirectory {
'cloud_backup.delete': { params: [id: number]; response: boolean };
'cloud_backup.list_snapshots': { params: [id: number]; response: CloudBackupSnapshot[] };
'cloud_backup.list_snapshot_directory': { params: CloudBackupSnapshotDirectoryParams; response: CloudBackupSnapshotDirectoryListing[] };
'cloud_backup.transfer_setting_choices': { params: void; response: CloudsyncTransferSetting[] };
'cloud_backup.query': { params: [id?: QueryParams<CloudBackup>]; response: CloudBackup[] };
'cloud_backup.update': { params: [id: number, update: CloudBackupUpdate]; response: CloudBackup };

Expand Down
9 changes: 5 additions & 4 deletions src/app/interfaces/cloud-backup.interface.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { marker as T } from '@biesbjerg/ngx-translate-extract-marker';
import { CloudsyncTransferSetting } from 'app/enums/cloudsync-transfer-setting.enum';
import { ApiTimestamp } from 'app/interfaces/api-date.interface';
import { Job } from 'app/interfaces/job.interface';
import { CloudCredential } from './cloud-sync-task.interface';
import { BwLimit, BwLimitUpdate, CloudCredential } from './cloud-sync-task.interface';
import { Schedule } from './schedule.interface';

export interface CloudBackup {
Expand All @@ -16,18 +15,20 @@ export interface CloudBackup {
snapshot: boolean;
include: string[];
exclude: string[];
transfers: number | null;
args: string;
enabled: boolean;
password: string;
credentials: CloudCredential;
job: Job | null;
locked: boolean;
bwlimit?: BwLimit[];
keep_last?: number;
transfer_setting: CloudsyncTransferSetting;
}

export interface CloudBackupUpdate extends Omit<CloudBackup, 'id' | 'job' | 'locked' | 'credentials'> {
export interface CloudBackupUpdate extends Omit<CloudBackup, 'id' | 'job' | 'locked' | 'bwlimit' | 'credentials'> {
credentials: number;
bwlimit: BwLimitUpdate[];
}

export interface CloudBackupSnapshot {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ <h3 mat-card-title>
<p>{{ 'Bucket' | translate }}: {{ backup.attributes.bucket || '-' }}</p>
<p>{{ 'Folder' | translate }}: {{ backup.attributes.folder || '-' }}</p>
<p>{{ 'Keep Last' | translate }}: {{ backup.keep_last || '-' }}</p>
<p>
{{ 'Transfer Setting' | translate }}:
{{ (backup.transfer_setting | mapValue: cloudsyncTransferSettingLabels) || '-' }}
</p>
<p>{{ 'Transfers' | translate }}: {{ backup.transfers || '-' }}</p>
<p>{{ 'Post Script' | translate }}: {{ backup.post_script || '-' }}</p>
<p>{{ 'Pre Script' | translate }}: {{ backup.pre_script || '-' }}</p>
</mat-card-content>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { cloudsyncTransferSettingLabels } from 'app/enums/cloudsync-transfer-setting.enum';
import { CloudBackup } from 'app/interfaces/cloud-backup.interface';

@Component({
Expand All @@ -10,5 +9,4 @@ import { CloudBackup } from 'app/interfaces/cloud-backup.interface';
})
export class CloudBackupStatsComponent {
@Input() backup: CloudBackup;
protected readonly cloudsyncTransferSettingLabels = cloudsyncTransferSettingLabels;
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,17 @@
class="fieldset"
[title]="helptext.fieldset_advanced_remote_options | translate"
>
<ix-select
formControlName="transfer_setting"
[required]="true"
[options]="transferSettings$"
[label]="'Transfer Setting' | translate"
></ix-select>
<ix-input
formControlName="transfers"
type="number"
[label]="helptext.transfers_placeholder | translate"
[tooltip]="helptext.transfers_tooltip | translate"
></ix-input>
<ix-chips
formControlName="bwlimit"
[label]="helptext.bwlimit_placeholder | translate"
[tooltip]="helptext.bwlimit_tooltip | translate"
></ix-chips>
</ix-fieldset>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,15 @@ import { of } from 'rxjs';
import { mockAuth } from 'app/core/testing/utils/mock-auth.utils';
import { mockCall, mockWebSocket } from 'app/core/testing/utils/mock-websocket.utils';
import { CloudSyncProviderName } from 'app/enums/cloudsync-provider.enum';
import { CloudsyncTransferSetting } from 'app/enums/cloudsync-transfer-setting.enum';
import { CloudBackup } from 'app/interfaces/cloud-backup.interface';
import { DialogService } from 'app/modules/dialog/dialog.service';
import {
CloudCredentialsSelectModule,
} from 'app/modules/forms/custom-selects/cloud-credentials-select/cloud-credentials-select.module';
import { CloudCredentialsSelectModule } from 'app/modules/forms/custom-selects/cloud-credentials-select/cloud-credentials-select.module';
import { ChainedRef } from 'app/modules/forms/ix-forms/components/ix-slide-in/chained-component-ref';
import { IxFormsModule } from 'app/modules/forms/ix-forms/ix-forms.module';
import { IxFormHarness } from 'app/modules/forms/ix-forms/testing/ix-form.harness';
import { SchedulerModule } from 'app/modules/scheduler/scheduler.module';
import {
CloudBackupFormComponent,
} from 'app/pages/data-protection/cloud-backup/cloud-backup-form/cloud-backup-form.component';
import {
googlePhotosCreds,
googlePhotosProvider,
storjProvider,
} from 'app/pages/data-protection/cloudsync/cloudsync-wizard/cloudsync-wizard.testing.utils';
import { CloudBackupFormComponent } from 'app/pages/data-protection/cloud-backup/cloud-backup-form/cloud-backup-form.component';
import { googlePhotosCreds, googlePhotosProvider, storjProvider } from 'app/pages/data-protection/cloudsync/cloudsync-wizard/cloudsync-wizard.testing.utils';
import {
TransferModeExplanationComponent,
} from 'app/pages/data-protection/cloudsync/transfer-mode-explanation/transfer-mode-explanation.component';
Expand Down Expand Up @@ -56,9 +47,10 @@ describe('CloudBackupFormComponent', () => {
pre_script: '',
post_script: '',
snapshot: false,
bwlimit: [],
include: [],
exclude: [],
transfer_setting: CloudsyncTransferSetting.Performance,
transfers: 5,
args: '',
enabled: true,
job: null,
Expand Down Expand Up @@ -101,11 +93,6 @@ describe('CloudBackupFormComponent', () => {
mockCall('cloud_backup.create', existingTask),
mockCall('cloud_backup.update', existingTask),
mockCall('cloudsync.create_bucket'),
mockCall('cloud_backup.transfer_setting_choices', [
CloudsyncTransferSetting.Default,
CloudsyncTransferSetting.Performance,
CloudsyncTransferSetting.FastStorage,
]),
]),
mockProvider(IxChainedSlideInService, {
open: jest.fn(() => of()),
Expand Down Expand Up @@ -143,14 +130,15 @@ describe('CloudBackupFormComponent', () => {
const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' }));
await saveButton.click();

expect(spectator.inject(WebSocketService).call).toHaveBeenNthCalledWith(2, 'cloudsync.create_bucket', [
expect(spectator.inject(WebSocketService).call).toHaveBeenNthCalledWith(1, 'cloudsync.create_bucket', [
2,
'brand-new-bucket',
]);

expect(spectator.inject(WebSocketService).call).toHaveBeenNthCalledWith(3, 'cloud_backup.create', [{
expect(spectator.inject(WebSocketService).call).toHaveBeenNthCalledWith(2, 'cloud_backup.create', [{
args: '',
attributes: { folder: '/', bucket: 'brand-new-bucket' },
bwlimit: [],
credentials: 2,
description: 'Cloud Backup Task With New Bucket',
enabled: true,
Expand All @@ -169,7 +157,7 @@ describe('CloudBackupFormComponent', () => {
month: '*',
},
snapshot: false,
transfer_setting: CloudsyncTransferSetting.Default,
transfers: null,
}]);
expect(chainedComponentRef.close).toHaveBeenCalledWith({ response: existingTask, error: null });
});
Expand All @@ -184,10 +172,10 @@ describe('CloudBackupFormComponent', () => {
'Keep Last': 3,
Folder: '/',
Enabled: false,
Transfers: 22,
Bucket: 'bucket1',
'Take Snapshot': true,
Exclude: ['/test'],
'Transfer Setting': 'Fast Storage',
});

const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' }));
Expand All @@ -196,6 +184,7 @@ describe('CloudBackupFormComponent', () => {
expect(spectator.inject(WebSocketService).call).toHaveBeenLastCalledWith('cloud_backup.create', [{
args: '',
attributes: { folder: '/', bucket: 'path_to_bucket1' },
bwlimit: [],
credentials: 2,
description: 'New Cloud Backup Task',
enabled: false,
Expand All @@ -214,7 +203,7 @@ describe('CloudBackupFormComponent', () => {
month: '*',
},
snapshot: true,
transfer_setting: CloudsyncTransferSetting.FastStorage,
transfers: 22,
}]);
expect(chainedComponentRef.close).toHaveBeenCalledWith({ response: existingTask, error: null });
});
Expand All @@ -236,6 +225,7 @@ describe('CloudBackupFormComponent', () => {
it('shows values for an existing cloud backup task when it is open for edit', async () => {
const form = await loader.getHarness(IxFormHarness);
expect(await form.getValues()).toEqual({
'Bandwidth Limit': [],
Bucket: '',
Credentials: 'Storj iX (Storj)',
Enabled: true,
Expand All @@ -249,7 +239,26 @@ describe('CloudBackupFormComponent', () => {
Schedule: 'Weekly (0 0 * * sun)  On Sundays at 00:00 (12:00 AM)',
'Source Path': '/mnt/my pool',
'Take Snapshot': false,
'Transfer Setting': 'Performance',
Transfers: '5',
});

expect(spectator.component.form.value).toEqual({
args: '',
bucket: '',
bwlimit: [],
credentials: 2,
description: 'sdf',
enabled: true,
exclude: [],
folder: '/My Folder',
keep_last: 2,
password: '1234',
path: '/mnt/my pool',
post_script: '',
pre_script: '',
schedule: '0 0 * * sun',
snapshot: false,
transfers: 5,
});
});

Expand All @@ -260,6 +269,7 @@ describe('CloudBackupFormComponent', () => {
Password: 'qwerty123',
Bucket: 'bucket1',
'Source Path': '/mnt/path1',
'Bandwidth Limit': ['00:00,10G', '12:00,20M', '18:00,10K', '20:00,off'],
});

const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' }));
Expand All @@ -271,6 +281,24 @@ describe('CloudBackupFormComponent', () => {
folder: '/My Folder',
bucket: 'path_to_bucket1',
},
bwlimit: [
{
bandwidth: '10737418240',
time: '00:00',
},
{
bandwidth: '20971520',
time: '12:00',
},
{
bandwidth: '10240',
time: '18:00',
},
{
bandwidth: null,
time: '20:00',
},
],
credentials: 2,
description: 'Edited description',
enabled: true,
Expand All @@ -289,7 +317,7 @@ describe('CloudBackupFormComponent', () => {
month: '*',
},
snapshot: false,
transfer_setting: CloudsyncTransferSetting.Performance,
transfers: 5,
}]);
expect(chainedComponentRef.close).toHaveBeenCalledWith({ response: existingTask, error: null });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
switchMap,
} from 'rxjs';
import { CloudSyncProviderName } from 'app/enums/cloudsync-provider.enum';
import { CloudsyncTransferSetting, cloudsyncTransferSettingLabels } from 'app/enums/cloudsync-transfer-setting.enum';
import { ExplorerNodeType } from 'app/enums/explorer-type.enum';
import { Role } from 'app/enums/role.enum';
import { mapToOptions } from 'app/helpers/options.helper';
import { prepareBwlimit } from 'app/helpers/bwlimit.utils';
import { buildNormalizedFileSize } from 'app/helpers/file-size.utils';
import { helptextCloudBackup } from 'app/helptext/data-protection/cloud-backup/cloud-backup';
import { CloudBackup, CloudBackupUpdate } from 'app/interfaces/cloud-backup.interface';
import { SelectOption, newOption } from 'app/interfaces/option.interface';
Expand Down Expand Up @@ -59,7 +59,7 @@ export class CloudBackupFormComponent implements OnInit {
disabled: false,
};

protected form = this.fb.group({
form = this.fb.group({
path: ['', [Validators.required]],
credentials: [null as number, [Validators.required]],
schedule: [CronPresetValue.Daily, [Validators.required]],
Expand All @@ -68,7 +68,8 @@ export class CloudBackupFormComponent implements OnInit {
post_script: [''],
description: ['', [Validators.required]],
snapshot: [false],
transfer_setting: [CloudsyncTransferSetting.Default],
bwlimit: [[] as string[]],
transfers: [null as number],
args: [''],
enabled: [true],
password: ['', [Validators.required]],
Expand All @@ -83,12 +84,6 @@ export class CloudBackupFormComponent implements OnInit {
editingTask: CloudBackup;

bucketOptions$ = of<SelectOption[]>([]);
transferSettings$ = this.ws.call('cloud_backup.transfer_setting_choices').pipe(
map((availableSettings) => {
const allOptions = mapToOptions(cloudsyncTransferSettingLabels, this.translate);
return allOptions.filter((option) => availableSettings.includes(option.value as CloudsyncTransferSetting));
}),
);

fileNodeProvider: TreeNodeProvider;
bucketNodeProvider: TreeNodeProvider;
Expand Down Expand Up @@ -240,6 +235,11 @@ export class CloudBackupFormComponent implements OnInit {
credentials: (this.editingTask.credentials).id,
folder: this.editingTask.attributes.folder as string,
bucket: this.editingTask.attributes.bucket === newOption ? '' : this.editingTask.attributes.bucket as string || '',
bwlimit: this.editingTask.bwlimit.map((bwlimit) => {
return bwlimit.bandwidth
? `${bwlimit.time}, ${buildNormalizedFileSize(bwlimit.bandwidth, 'B', 2)}/s`
: `${bwlimit.time}, off`;
}),
});
}

Expand Down Expand Up @@ -292,6 +292,7 @@ export class CloudBackupFormComponent implements OnInit {
...formValue,
attributes,
include: [],
bwlimit: prepareBwlimit(formValue.bwlimit),
schedule: crontabToSchedule(formValue.schedule),
};

Expand Down
2 changes: 0 additions & 2 deletions src/app/pages/data-protection/data-protection.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { IxIconModule } from 'app/modules/ix-icon/ix-icon.module';
import { IxTableModule } from 'app/modules/ix-table/ix-table.module';
import { LayoutModule } from 'app/modules/layout/layout.module';
import { PageHeaderModule } from 'app/modules/page-header/page-header.module';
import { MapValuePipe } from 'app/modules/pipes/map-value/map-value.pipe';
import { SchedulerModule } from 'app/modules/scheduler/scheduler.module';
import { TestIdModule } from 'app/modules/test-id/test-id.module';
import { CloudBackupRestoreFromSnapshotFormComponent } from 'app/pages/data-protection/cloud-backup/cloud-backup-details/cloud-backup-restore-form-snapshot-form/cloud-backup-restore-from-snapshot-form.component';
Expand Down Expand Up @@ -127,7 +126,6 @@ import { SmartTaskListComponent } from './smart-task/smart-task-list/smart-task-
CloudSyncProviderDescriptionComponent,
SearchInput1Component,
MatProgressSpinnerModule,
MapValuePipe,
],
declarations: [
SnapshotTaskListComponent,
Expand Down
2 changes: 0 additions & 2 deletions src/assets/i18n/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,6 @@
"Failover is administratively disabled.": "",
"Failover is in an error state.": "",
"Failover is recommended for new FIPS setting to take effect. Would you like to failover now?": "",
"Fast Storage": "",
"Fatal error! Check logs.": "",
"Faulted": "",
"Feature Request": "",
Expand Down Expand Up @@ -4495,7 +4494,6 @@
"Train": "",
"Transfer": "",
"Transfer Mode": "",
"Transfer Setting": "",
"Transfers": "",
"Translate App": "",
"Transmit Hash Policy": "",
Expand Down
Loading

0 comments on commit 9dd7883

Please sign in to comment.