Skip to content

Commit

Permalink
NAS-132932: PR update
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKarpov98 committed Dec 12, 2024
2 parents 77f3377 + 92195eb commit 6a2a224
Show file tree
Hide file tree
Showing 151 changed files with 4,821 additions and 2,801 deletions.
3 changes: 3 additions & 0 deletions src/app/helptext/data-protection/cloud-backup/cloud-backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export const helptextCloudBackup = {
snapshot_placeholder: T('Take Snapshot'),
snapshot_tooltip: T('Set to take a snapshot of the dataset before a <i>PUSH</i>.'),

absolute_paths_placeholder: T('Use Absolute Paths'),
absolute_paths_tooltip: T('Determines whether restic backup will contain absolute or relative paths'),

transfers_placeholder: T('Transfers'),
transfers_tooltip: T('Number of simultaneous file transfers. Enter a\
number based on the available bandwidth and destination system\
Expand Down
2 changes: 2 additions & 0 deletions src/app/interfaces/api/api-call-directory.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import {
FibreChannelPort,
FibreChannelPortChoices,
FibreChannelPortUpdate,
FibreChannelStatus,
} from 'app/interfaces/fibre-channel.interface';
import { FileRecord, ListdirQueryParams } from 'app/interfaces/file-record.interface';
import { FileSystemStat, Statfs } from 'app/interfaces/filesystem-stat.interface';
Expand Down Expand Up @@ -466,6 +467,7 @@ export interface ApiCallDirectory {
'fcport.delete': { params: [id: number]; response: true };
'fcport.port_choices': { params: [include_used?: boolean]; response: FibreChannelPortChoices };
'fcport.query': { params: QueryParams<FibreChannelPort>; response: FibreChannelPort[] };
'fcport.status': { params: []; response: FibreChannelStatus[] };

// Filesystem
'filesystem.acltemplate.by_path': { params: [AclTemplateByPathParams]; response: AclTemplateByPath[] };
Expand Down
1 change: 1 addition & 0 deletions src/app/interfaces/app.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ export type AppDeleteParams = [
{
remove_images?: boolean;
remove_ix_volumes?: boolean;
force_remove_ix_volumes?: boolean;
},
];

Expand Down
4 changes: 2 additions & 2 deletions src/app/interfaces/cloud-backup.interface.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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 { CloudSyncCredential } from 'app/interfaces/cloudsync-credential.interface';
import { Job } from 'app/interfaces/job.interface';
import { CloudCredential } from './cloud-sync-task.interface';
import { Schedule } from './schedule.interface';

export interface CloudBackup {
Expand All @@ -19,7 +19,7 @@ export interface CloudBackup {
args: string;
enabled: boolean;
password: string;
credentials: CloudCredential;
credentials: CloudSyncCredential;
job: Job | null;
locked: boolean;
keep_last?: number;
Expand Down
10 changes: 2 additions & 8 deletions src/app/interfaces/cloud-sync-task.interface.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import { Direction } from 'app/enums/direction.enum';
import { TransferMode } from 'app/enums/transfer-mode.enum';
import { CloudSyncCredential } from 'app/interfaces/cloudsync-credential.interface';
import { DataProtectionTaskState } from 'app/interfaces/data-protection-task-state.interface';
import { Job } from 'app/interfaces/job.interface';
import { Schedule } from 'app/interfaces/schedule.interface';

export interface CloudCredential {
id: number;
name: string;
provider: string;
attributes: Record<string, string | number | boolean>;
}

export interface BwLimit {
time: string;
bandwidth: number;
Expand All @@ -25,7 +19,7 @@ export interface CloudSyncTask {
args: string;
attributes: Record<string, string | number | boolean>;
bwlimit: BwLimit[];
credentials: CloudCredential;
credentials: CloudSyncCredential;
description: string;
direction: Direction;
enabled: boolean;
Expand Down
9 changes: 6 additions & 3 deletions src/app/interfaces/cloudsync-credential.interface.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { CloudSyncProviderName } from 'app/enums/cloudsync-provider.enum';

export type SomeProviderAttributes = Record<string, string | number | boolean | string[] | number[] | boolean[]>;

export interface CloudSyncCredential {
attributes: Record<string, string | number | boolean>;
id: number;
name: string;
provider: CloudSyncProviderName;
provider: SomeProviderAttributes & {
type: CloudSyncProviderName;
};
}

export type CloudSyncCredentialUpdate = Omit<CloudSyncCredential, 'id'>;

export type CloudSyncCredentialVerify = Pick<CloudSyncCredential, 'provider' | 'attributes'>;
export type CloudSyncCredentialVerify = CloudSyncCredential['provider'];

export interface CloudSyncCredentialVerifyResult {
error?: string;
Expand Down
16 changes: 16 additions & 0 deletions src/app/interfaces/fibre-channel.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,19 @@ export type FibreChannelPortChoices = Record<string, {
wwpn: string;
wwpn_b: string;
}>;

export interface FibreChannelStatusNode {
port_type: string;
port_state: string;
speed: string;
physical: boolean;
wwpn?: string;
wwpn_b?: string;
sessions: unknown[];
}

export interface FibreChannelStatus {
port: string;
A: FibreChannelStatusNode;
B: FibreChannelStatusNode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ describe('CloudCredentialsSelectComponent', () => {

const mockCloudCredentialService = {
getCloudSyncCredentials: jest.fn(() => of([
{ id: '1', name: 'AWS S3', provider: CloudSyncProviderName.AmazonS3 },
{ id: '2', name: 'Dropbox', provider: CloudSyncProviderName.Dropbox },
{ id: '2', name: 'Drive', provider: CloudSyncProviderName.GoogleDrive },
{ id: '1', name: 'AWS S3', provider: { type: CloudSyncProviderName.AmazonS3 } },
{ id: '2', name: 'Dropbox', provider: { type: CloudSyncProviderName.Dropbox } },
{ id: '2', name: 'Drive', provider: { type: CloudSyncProviderName.GoogleDrive } },
])),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { Observable, map } from 'rxjs';
import { CloudSyncProviderName, cloudSyncProviderNameMap } from 'app/enums/cloudsync-provider.enum';
import { CloudCredential } from 'app/interfaces/cloud-sync-task.interface';
import { CloudSyncCredential } from 'app/interfaces/cloudsync-credential.interface';
import { Option } from 'app/interfaces/option.interface';
import { IxSelectWithNewOption } from 'app/modules/forms/ix-forms/components/ix-select/ix-select-with-new-option.directive';
import { IxSelectComponent, IxSelectValue } from 'app/modules/forms/ix-forms/components/ix-select/ix-select.component';
Expand Down Expand Up @@ -39,16 +39,16 @@ export class CloudCredentialsSelectComponent extends IxSelectWithNewOption {
return this.cloudCredentialService.getCloudSyncCredentials().pipe(
map((options) => {
if (this.filterByProviders()) {
options = options.filter((option) => this.filterByProviders().includes(option.provider));
options = options.filter((option) => this.filterByProviders().includes(option.provider.type));
}
return options.map((option) => {
return { label: `${option.name} (${cloudSyncProviderNameMap.get(option.provider)})`, value: option.id };
return { label: `${option.name} (${cloudSyncProviderNameMap.get(option.provider.type)})`, value: option.id };
});
}),
);
}

getValueFromChainedResponse(result: ChainedComponentResponse<CloudCredential>): IxSelectValue {
getValueFromChainedResponse(result: ChainedComponentResponse<CloudSyncCredential>): IxSelectValue {
return result.response.id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Direction } from 'app/enums/direction.enum';
import { JobState } from 'app/enums/job-state.enum';
import { TransferMode } from 'app/enums/transfer-mode.enum';
import { CloudSyncTaskUi } from 'app/interfaces/cloud-sync-task.interface';
import { CloudSyncCredential } from 'app/interfaces/cloudsync-credential.interface';
import { DialogService } from 'app/modules/dialog/dialog.service';
import { CloudCredentialsSelectComponent } from 'app/modules/forms/custom-selects/cloud-credentials-select/cloud-credentials-select.component';
import { ChainedRef } from 'app/modules/slide-ins/chained-component-ref';
Expand Down Expand Up @@ -52,9 +53,12 @@ describe('IxSlideIn2Component', () => {
credentials: {
id: 2,
name: 'test2',
provider: 'MEGA',
attributes: { user: 'login', pass: 'password' } as Record<string, string>,
},
provider: {
type: CloudSyncProviderName.Mega,
user: 'login',
pass: 'password',
},
} as CloudSyncCredential,
schedule: {
minute: '0',
hour: '0',
Expand Down Expand Up @@ -97,16 +101,16 @@ describe('IxSlideIn2Component', () => {
{
id: 1,
name: 'test1',
provider: CloudSyncProviderName.Http,
attributes: {
provider: {
type: CloudSyncProviderName.Http,
url: 'http',
},
},
{
id: 2,
name: 'test2',
provider: CloudSyncProviderName.Mega,
attributes: {
provider: {
type: CloudSyncProviderName.Mega,
user: 'login',
pass: 'password',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ <h1 matDialogTitle>
{{ 'Delete {name}?' | translate: { name: data.name } }}
</p>

@if(data.showRemoveVolumes) {
@if (data.showRemoveVolumes) {
<ix-checkbox
formControlName="remove_volumes"
formControlName="removeVolumes"
[label]="'Remove iXVolumes' | translate"
></ix-checkbox>

@if (data.showRemoveVolumes && form.value.removeVolumes) {
<ix-checkbox
formControlName="forceRemoveVolumes"
[label]="'Force-remove iXVolumes' | translate"
></ix-checkbox>
}
}

<ix-checkbox
formControlName="remove_images"
formControlName="removeImages"
[label]="'Remove Images' | translate"
></ix-checkbox>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@ describe('AppDeleteDialogComponent', () => {
expect(spectator.inject(MatDialogRef).close).toHaveBeenCalledWith({
removeImages: true,
removeVolumes: true,
forceRemoveVolumes: false,
});
});

it('shows force remove volumes checkbox when Remove iXVolumes is selected', async () => {
expect(await form.getLabels()).not.toContain('Force-remove iXVolumes');

await form.fillForm({
'Remove iXVolumes': true,
'Force-remove iXVolumes': true,
});

const deleteButton = await loader.getHarness(MatButtonHarness.with({ text: 'Delete' }));
await deleteButton.click();

expect(spectator.inject(MatDialogRef).close).toHaveBeenCalledWith({
removeImages: true,
removeVolumes: true,
forceRemoveVolumes: true,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ import { AppDeleteDialogInputData, AppDeleteDialogOutputData } from 'app/pages/a
})
export class AppDeleteDialogComponent {
form = this.formBuilder.group({
remove_volumes: [false],
remove_images: [true],
removeVolumes: [false],
removeImages: [true],
forceRemoveVolumes: [false],
});

constructor(
Expand All @@ -44,9 +45,6 @@ export class AppDeleteDialogComponent {
) { }

onSubmit(): void {
this.dialogRef.close({
removeVolumes: this.form.value.remove_volumes,
removeImages: this.form.value.remove_images,
});
this.dialogRef.close(this.form.getRawValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export interface AppDeleteDialogInputData {
export interface AppDeleteDialogOutputData {
removeVolumes: boolean;
removeImages: boolean;
forceRemoveVolumes: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,16 @@ export class AppInfoCardComponent {
filter(Boolean),
untilDestroyed(this),
)
.subscribe(({ removeVolumes, removeImages }) => this.executeDelete(name, removeVolumes, removeImages));
.subscribe((options) => this.executeDelete(name, options));
}

executeDelete(name: string, removeVolumes = false, removeImages = true): void {
executeDelete(name: string, options: AppDeleteDialogOutputData): void {
this.dialogService.jobDialog(
this.api.job('app.delete', [name, { remove_images: removeImages, remove_ix_volumes: removeVolumes }]),
this.api.job('app.delete', [name, {
remove_images: options.removeImages,
remove_ix_volumes: options.removeVolumes,
force_remove_ix_volumes: options.forceRemoveVolumes,
}]),
{ title: helptextApps.apps.delete_dialog.job },
)
.afterClosed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export class InstalledAppsListComponent implements OnInit {
}).afterClosed();
}),
filter(Boolean),
switchMap(({ removeVolumes, removeImages }) => this.executeBulkDeletion(removeVolumes, removeImages)),
switchMap((options) => this.executeBulkDeletion(options)),
this.errorHandler.catchError(),
untilDestroyed(this),
)
Expand Down Expand Up @@ -420,13 +420,14 @@ export class InstalledAppsListComponent implements OnInit {
});
}

private executeBulkDeletion(
removeVolumes = false,
removeImages = true,
): Observable<Job<CoreBulkResponse[]>> {
private executeBulkDeletion(options: AppDeleteDialogOutputData): Observable<Job<CoreBulkResponse[]>> {
const bulkDeletePayload = this.checkedAppsNames.map((name) => [
name,
{ remove_images: removeImages, remove_ix_volumes: removeVolumes },
{
remove_images: options.removeImages,
remove_ix_volumes: options.removeVolumes,
force_remove_ix_volumes: options.forceRemoveVolumes,
},
]);

return this.dialogService.jobDialog(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { createComponentFactory, mockProvider, Spectator } from '@ngneat/spectat
import { of } from 'rxjs';
import { mockCall, mockApi } from 'app/core/testing/utils/mock-api.utils';
import { mockAuth } from 'app/core/testing/utils/mock-auth.utils';
import { CloudSyncProviderName } from 'app/enums/cloudsync-provider.enum';
import { CloudSyncCredential } from 'app/interfaces/cloudsync-credential.interface';
import { CloudSyncProvider } from 'app/interfaces/cloudsync-provider.interface';
import { DialogService } from 'app/modules/dialog/dialog.service';
Expand All @@ -30,8 +31,8 @@ describe('CloudCredentialsCardComponent', () => {
{
id: 1,
name: 'GDrive',
provider: 'GOOGLE_DRIVE',
attributes: {
provider: {
type: CloudSyncProviderName.GoogleDrive,
client_id: 'client_id',
client_secret: 'client_secret',
token: '{"access_token":"<token>","expiry":"2023-08-10T01:59:50.96113807-07:00"}',
Expand All @@ -41,19 +42,19 @@ describe('CloudCredentialsCardComponent', () => {
{
id: 2,
name: 'BB2',
provider: 'B2',
attributes: {
provider: {
type: CloudSyncProviderName.BackblazeB2,
account: '<account>',
key: '<key>',
},
},
] as CloudSyncCredential[];

const providers = [{
name: 'GOOGLE_DRIVE',
name: CloudSyncProviderName.GoogleDrive,
title: 'Google Drive',
}, {
name: 'B2',
name: CloudSyncProviderName.BackblazeB2,
title: 'Backblaze B2',
}] as CloudSyncProvider[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export class CloudCredentialsCardComponent implements OnInit {
textColumn({
title: this.translate.instant('Provider'),
propertyName: 'provider',
getValue: (row) => this.providers.get(row.provider) || row.provider,
getValue: (row) => {
const provider = row.provider.type;
return this.providers.get(provider) || provider;
},
}),
actionsColumn({
actions: [
Expand Down
Loading

0 comments on commit 6a2a224

Please sign in to comment.