Skip to content

Commit

Permalink
Merge branch 'master' of github.com:truenas/webui into NAS-133028
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/assets/i18n/fr.json
  • Loading branch information
undsoft committed Dec 11, 2024
2 parents 6df553a + 3f625f8 commit 5444bbf
Show file tree
Hide file tree
Showing 129 changed files with 4,158 additions and 2,483 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
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,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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<form class="ix-form-container" (submit)="onSubmit()">
<ix-fieldset [title]="'Name and Provider' | translate" [formGroup]="commonForm">
<ix-select
formControlName="provider"
formControlName="type"
[label]="'Provider' | translate"
[required]="true"
[options]="providerOptions"
Expand All @@ -18,7 +18,7 @@

@if (showProviderDescription) {
<ix-cloudsync-provider-description
[provider]="commonForm.controls.provider.value"
[provider]="commonForm.controls.type.value"
></ix-cloudsync-provider-description>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ describe('CloudCredentialsFormComponent', () => {
const fakeCloudSyncCredential = {
id: 233,
name: 'My backup server',
provider: CloudSyncProviderName.AmazonS3,
attributes: {
provider: {
type: CloudSyncProviderName.AmazonS3,
hostname: 'backup.com',
},
} as CloudSyncCredential;
Expand Down Expand Up @@ -179,10 +179,8 @@ describe('CloudCredentialsFormComponent', () => {
await verifyButton.click();

expect(spectator.inject(ApiService).call).toHaveBeenCalledWith('cloudsync.credentials.verify', [{
provider: 'S3',
attributes: {
s3attribute: 's3 value',
},
type: CloudSyncProviderName.AmazonS3,
s3attribute: 's3 value',
}]);
});

Expand Down Expand Up @@ -248,8 +246,8 @@ describe('CloudCredentialsFormComponent', () => {

expect(spectator.inject(ApiService).call).toHaveBeenCalledWith('cloudsync.credentials.create', [{
name: 'New sync',
provider: CloudSyncProviderName.AmazonS3,
attributes: {
provider: {
type: CloudSyncProviderName.AmazonS3,
s3attribute: 's3 value',
},
}]);
Expand Down Expand Up @@ -313,6 +311,7 @@ describe('CloudCredentialsFormComponent', () => {
const providerForm = spectator.query(S3ProviderFormComponent);
expect(providerForm).toBeTruthy();
expect(providerForm.getFormSetter$().next).toHaveBeenCalledWith({
type: CloudSyncProviderName.AmazonS3,
hostname: 'backup.com',
});
});
Expand All @@ -331,8 +330,8 @@ describe('CloudCredentialsFormComponent', () => {
233,
{
name: 'My updated server',
provider: CloudSyncProviderName.AmazonS3,
attributes: {
provider: {
type: CloudSyncProviderName.AmazonS3,
s3attribute: 's3 value',
},
},
Expand Down
Loading

0 comments on commit 5444bbf

Please sign in to comment.