Skip to content

Commit

Permalink
NAS-131691: Refactor sharing and data-protection to standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
undsoft committed Oct 11, 2024
2 parents 9110f16 + 17fb4d7 commit 3a30464
Show file tree
Hide file tree
Showing 136 changed files with 971 additions and 381 deletions.
3 changes: 3 additions & 0 deletions src/app/constants/invalid-date.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { marker as T } from '@biesbjerg/ngx-translate-extract-marker';

export const invalidDate = T('Invalid Date');
6 changes: 0 additions & 6 deletions src/app/enums/dataset.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,3 @@ export const datasetPresetLabels = new Map<DatasetPreset, string>([
[DatasetPreset.Apps, T('Apps')],
[DatasetPreset.Multiprotocol, T('Multiprotocol')],
]);

export enum DatasetXattr {
Inherit = 'INHERIT',
On = 'ON',
Sa = 'SA',
}
4 changes: 3 additions & 1 deletion src/app/helpers/operators/options.operators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { MapOption, Option } from 'app/interfaces/option.interface';
*/
export function choicesToOptions(): OperatorFunction<Choices, Option[]> {
return map((choices) => {
return Object.entries(choices).map(([value, label]) => ({ label, value }));
return Object.entries(choices).map(
([value, label]) => ({ label, value }),
);
});
}

Expand Down
1 change: 1 addition & 0 deletions src/app/interfaces/api/api-call-directory.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ export interface ApiCallDirectory {
'vm.device.delete': { params: [number, VmDeviceDelete?]; response: boolean };
'vm.device.disk_choices': { params: void; response: Choices };
'vm.device.get_pci_ids_for_gpu_isolation': { params: [string]; response: string[] };
'system.advanced.get_gpu_pci_choices': { params: void; response: Choices };
'vm.device.nic_attach_choices': { params: void; response: Choices };
'vm.device.passthrough_device_choices': { params: void; response: Record<string, VmPassthroughDeviceChoice> };
'vm.device.query': { params: QueryParams<VmDevice>; response: VmDevice[] };
Expand Down
4 changes: 0 additions & 4 deletions src/app/interfaces/dataset.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
DatasetSync,
DatasetType,
DatasetVolumeBlockSize,
DatasetXattr,
} from 'app/enums/dataset.enum';
import { DeduplicationSetting } from 'app/enums/deduplication-setting.enum';
import { EncryptionKeyFormat } from 'app/enums/encryption-key-format.enum';
Expand Down Expand Up @@ -60,7 +59,6 @@ export interface Dataset {
share_type: ZfsProperty<DatasetPreset, string>;
special_small_block_size: ZfsProperty<string>;
sync: ZfsProperty<DatasetSync, string>;
xattr: ZfsProperty<DatasetXattr, boolean>;
checksum: ZfsProperty<DatasetChecksum>;

// Absent if extra.retrieve_children is false
Expand Down Expand Up @@ -118,7 +116,6 @@ export interface DatasetCreate {
aclmode?: AclMode;
acltype?: DatasetAclType;
share_type?: DatasetPreset;
xattr?: DatasetXattr;
encryption_options?: {
generate_key?: boolean;
pbkdf2iters?: number;
Expand Down Expand Up @@ -159,7 +156,6 @@ export interface DatasetUpdate {
recordsize?: WithInherit<DatasetRecordSize>;
aclmode?: AclMode;
acltype?: DatasetAclType;
xattr?: DatasetXattr;
user_properties?: Record<string, string>;
create_ancestors?: boolean;
user_properties_update?: { key: string; value: string; remove?: boolean }[];
Expand Down
12 changes: 12 additions & 0 deletions src/app/interfaces/smart-test-progress-ui.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { SmartTestType } from 'app/enums/smart-test-type.enum';
import { ApiTimestamp } from 'app/interfaces/api-date.interface';

export interface SmartTestProgressUi {
diskName: string;
diskIdentifier: string;
wsError: unknown;
progressPercentage: number;
finished: boolean;
esimatedEnd: ApiTimestamp;
type: SmartTestType;
}
4 changes: 1 addition & 3 deletions src/app/interfaces/smart-test-progress.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export interface SmartTestProgressUpdate {
progress: {
percent: number;
};
progress: number;
}
1 change: 0 additions & 1 deletion src/app/interfaces/storage.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export interface ZfsProperties {
version: ZfsProperty<string>;
volsize: ZfsProperty<string>;
written: ZfsProperty<string>;
xattr: ZfsProperty<string>;
}

export interface TemperatureAgg {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<span
[matTooltip]="dateTooltip"
[ixTest]="[title, uniqueRowTag(row()), 'row-relative-date']"
[class.error]="isInvalidDate"
>{{ date }}</span>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MatTooltip } from '@angular/material/tooltip';
import { TranslateService } from '@ngx-translate/core';
import { isValid } from 'date-fns';
import { utcToZonedTime, zonedTimeToUtc } from 'date-fns-tz';
import { invalidDate } from 'app/constants/invalid-date';
import { formatDistanceToNowShortened } from 'app/helpers/format-distance-to-now-shortened';
import { ColumnComponent, Column } from 'app/modules/ix-table/interfaces/column-component.class';
import { FormatDateTimePipe } from 'app/modules/pipes/format-date-time/format-datetime.pipe';
Expand Down Expand Up @@ -41,6 +42,10 @@ export class IxCellRelativeDateComponent<T> extends ColumnComponent<T> {
return this.machineTime < this.value || this.machineTime > this.value;
}

get isInvalidDate(): boolean {
return this.translate.instant(this.date) === this.translate.instant(invalidDate);
}

get date(): string {
if (!this.value) {
return this.translate.instant('N/A');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import {
} from '@angular/core';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { Actions, ofType } from '@ngrx/effects';
import { TranslateService } from '@ngx-translate/core';
import { format } from 'date-fns-tz';
import { distinctUntilChanged } from 'rxjs';
import { invalidDate } from 'app/constants/invalid-date';
import { WINDOW } from 'app/helpers/window.helper';
import { localizationFormSubmitted } from 'app/store/preferences/preferences.actions';

Expand All @@ -21,6 +23,7 @@ export class FormatDateTimePipe implements PipeTransform {
constructor(
private actions$: Actions,
private cdr: ChangeDetectorRef,
private translate: TranslateService,
@Inject(WINDOW) private window: Window,
) {
this.checkFormatsFromLocalStorage();
Expand Down Expand Up @@ -89,7 +92,7 @@ export class FormatDateTimePipe implements PipeTransform {
}
return format(localDate, `${this.dateFormat} ${this.timeFormat}`);
} catch {
return 'Invalid date';
return this.translate.instant(invalidDate);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
} from 'app/pages/data-protection/cloud-backup/cloud-backup-form/cloud-backup-form.component';
import { IxChainedSlideInService } from 'app/services/ix-chained-slide-in.service';
import { WebSocketService } from 'app/services/ws.service';
import { selectPreferences } from 'app/store/preferences/preferences.selectors';
import { selectSystemConfigState } from 'app/store/system-config/system-config.selectors';

describe('CloudBackupCardComponent', () => {
let spectator: Spectator<CloudBackupCardComponent>;
Expand Down Expand Up @@ -68,6 +70,14 @@ describe('CloudBackupCardComponent', () => {
}),
provideMockStore({
selectors: [
{
selector: selectSystemConfigState,
value: {},
},
{
selector: selectPreferences,
value: {},
},
{
selector: selectJobs,
value: [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-roles.directive';
import { JobState } from 'app/enums/job-state.enum';
import { Role } from 'app/enums/role.enum';
import { formatDistanceToNowShortened } from 'app/helpers/format-distance-to-now-shortened';
import { tapOnce } from 'app/helpers/operators/tap-once.operator';
import { WINDOW } from 'app/helpers/window.helper';
import { CloudBackup, CloudBackupUpdate } from 'app/interfaces/cloud-backup.interface';
Expand All @@ -26,6 +25,7 @@ import { IxIconComponent } from 'app/modules/ix-icon/ix-icon.component';
import { AsyncDataProvider } from 'app/modules/ix-table/classes/async-data-provider/async-data-provider';
import { IxTableComponent } from 'app/modules/ix-table/components/ix-table/ix-table.component';
import { actionsColumn } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-actions/ix-cell-actions.component';
import { relativeDateColumn } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-relative-date/ix-cell-relative-date.component';
import { stateButtonColumn } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-state-button/ix-cell-state-button.component';
import { textColumn } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-text/ix-cell-text.component';
import {
Expand Down Expand Up @@ -96,14 +96,9 @@ export class CloudBackupCardComponent implements OnInit {
getJob: (row) => row.job,
cssClass: 'state-button',
}),
textColumn({
relativeDateColumn({
title: this.translate.instant('Last Run'),
getValue: (row) => {
if (row.job?.time_finished) {
return formatDistanceToNowShortened(row.job?.time_finished.$date);
}
return this.translate.instant('N/A');
},
getValue: (row) => row.job?.time_finished?.$date,
}),
actionsColumn({
cssClass: 'wide-actions',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import {
import { CloudBackupListComponent } from 'app/pages/data-protection/cloud-backup/cloud-backup-list/cloud-backup-list.component';
import { IxChainedSlideInService } from 'app/services/ix-chained-slide-in.service';
import { WebSocketService } from 'app/services/ws.service';
import { selectAdvancedConfig, selectSystemConfigState } from 'app/store/system-config/system-config.selectors';
import { selectPreferences } from 'app/store/preferences/preferences.selectors';
import { selectSystemConfigState } from 'app/store/system-config/system-config.selectors';

describe('CloudBackupListComponent', () => {
let spectator: Spectator<CloudBackupListComponent>;
Expand Down Expand Up @@ -84,7 +85,7 @@ describe('CloudBackupListComponent', () => {
value: {},
},
{
selector: selectAdvancedConfig,
selector: selectPreferences,
value: {},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-r
import { UiSearchDirective } from 'app/directives/ui-search.directive';
import { JobState } from 'app/enums/job-state.enum';
import { Role } from 'app/enums/role.enum';
import { formatDistanceToNowShortened } from 'app/helpers/format-distance-to-now-shortened';
import { tapOnce } from 'app/helpers/operators/tap-once.operator';
import { WINDOW } from 'app/helpers/window.helper';
import { CloudBackup, CloudBackupUpdate } from 'app/interfaces/cloud-backup.interface';
Expand All @@ -27,6 +26,7 @@ import { iconMarker } from 'app/modules/ix-icon/icon-marker.util';
import { AsyncDataProvider } from 'app/modules/ix-table/classes/async-data-provider/async-data-provider';
import { IxTableComponent } from 'app/modules/ix-table/components/ix-table/ix-table.component';
import { actionsColumn } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-actions/ix-cell-actions.component';
import { relativeDateColumn } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-relative-date/ix-cell-relative-date.component';
import { stateButtonColumn } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-state-button/ix-cell-state-button.component';
import { textColumn } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-text/ix-cell-text.component';
import {
Expand Down Expand Up @@ -106,14 +106,9 @@ export class CloudBackupListComponent implements OnInit {
getJob: (row) => row.job,
cssClass: 'state-button',
}),
textColumn({
relativeDateColumn({
title: this.translate.instant('Last Run'),
getValue: (row) => {
if (row.job?.time_finished) {
return formatDistanceToNowShortened(row.job?.time_finished.$date);
}
return this.translate.instant('N/A');
},
getValue: (row) => row.job?.time_finished?.$date,
}),
actionsColumn({
cssClass: 'wide-actions',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-r
import { UiSearchDirective } from 'app/directives/ui-search.directive';
import { JobState } from 'app/enums/job-state.enum';
import { Role } from 'app/enums/role.enum';
import { formatDistanceToNowShortened } from 'app/helpers/format-distance-to-now-shortened';
import { tapOnce } from 'app/helpers/operators/tap-once.operator';
import { helptextCloudSync } from 'app/helptext/data-protection/cloudsync/cloudsync';
import { CloudSyncTask, CloudSyncTaskUi } from 'app/interfaces/cloud-sync-task.interface';
Expand All @@ -25,6 +24,7 @@ import { SearchInput1Component } from 'app/modules/forms/search-input1/search-in
import { IxIconComponent } from 'app/modules/ix-icon/ix-icon.component';
import { AsyncDataProvider } from 'app/modules/ix-table/classes/async-data-provider/async-data-provider';
import { IxTableComponent } from 'app/modules/ix-table/components/ix-table/ix-table.component';
import { relativeDateColumn } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-relative-date/ix-cell-relative-date.component';
import { stateButtonColumn } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-state-button/ix-cell-state-button.component';
import { textColumn } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-text/ix-cell-text.component';
import { yesNoColumn } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-yes-no/ix-cell-yes-no.component';
Expand Down Expand Up @@ -124,27 +124,20 @@ export class CloudSyncListComponent implements OnInit {
propertyName: 'frequency',
getValue: (task) => this.taskService.getTaskCronDescription(scheduleToCrontab(task.schedule)),
}),
textColumn({
relativeDateColumn({
title: this.translate.instant('Next Run'),
hidden: true,
getValue: (task) => {
if (task.enabled) {
return task.schedule
? formatDistanceToNowShortened(this.taskService.getTaskNextTime(scheduleToCrontab(task.schedule)))
: this.translate.instant('N/A');
return this.taskService.getTaskNextTime(scheduleToCrontab(task.schedule));
}
return this.translate.instant('Disabled');
},
}),
textColumn({
relativeDateColumn({
title: this.translate.instant('Last Run'),
hidden: true,
getValue: (task) => {
if (task.job?.time_finished?.$date) {
return formatDistanceToNowShortened(task.job?.time_finished?.$date);
}
return this.translate.instant('N/A');
},
getValue: (task) => task.job?.time_finished?.$date,
}),
stateButtonColumn({
title: this.translate.instant('State'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { ReplicationRestoreDialogComponent } from 'app/pages/data-protection/rep
import { DownloadService } from 'app/services/download.service';
import { IxChainedSlideInService } from 'app/services/ix-chained-slide-in.service';
import { WebSocketService } from 'app/services/ws.service';
import { selectPreferences } from 'app/store/preferences/preferences.selectors';
import { selectSystemConfigState } from 'app/store/system-config/system-config.selectors';

const tasks = [{
Expand Down Expand Up @@ -135,6 +136,10 @@ describe('ReplicationListComponent', () => {
selector: selectSystemConfigState,
value: {},
},
{
selector: selectPreferences,
value: {},
},
],
}),
mockWebSocket([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-r
import { UiSearchDirective } from 'app/directives/ui-search.directive';
import { JobState } from 'app/enums/job-state.enum';
import { Role } from 'app/enums/role.enum';
import { formatDistanceToNowShortened } from 'app/helpers/format-distance-to-now-shortened';
import { Job } from 'app/interfaces/job.interface';
import { ReplicationTask } from 'app/interfaces/replication-task.interface';
import { DialogService } from 'app/modules/dialog/dialog.service';
Expand All @@ -21,6 +20,7 @@ import { SearchInput1Component } from 'app/modules/forms/search-input1/search-in
import { IxIconComponent } from 'app/modules/ix-icon/ix-icon.component';
import { AsyncDataProvider } from 'app/modules/ix-table/classes/async-data-provider/async-data-provider';
import { IxTableComponent } from 'app/modules/ix-table/components/ix-table/ix-table.component';
import { relativeDateColumn } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-relative-date/ix-cell-relative-date.component';
import {
stateButtonColumn,
} from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-state-button/ix-cell-state-button.component';
Expand Down Expand Up @@ -137,14 +137,9 @@ export class ReplicationListComponent implements OnInit {
propertyName: 'auto',
hidden: true,
}),
textColumn({
relativeDateColumn({
title: this.translate.instant('Last Run'),
getValue: (row) => {
if (row.state?.datetime?.$date) {
return formatDistanceToNowShortened(row.state?.datetime?.$date);
}
return this.translate.instant('N/A');
},
getValue: (row) => row.state?.datetime?.$date,
}),
stateButtonColumn({
title: this.translate.instant('State'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class SmartTaskCardComponent implements OnInit {
}),
relativeDateColumn({
title: this.translate.instant(helptextSmart.smartlist_column_next_run),
getValue: (row) => this.taskService.getTaskNextTime(row.cron_schedule) as unknown,
getValue: (row) => this.taskService.getTaskNextTime(row.cron_schedule),
}),
actionsColumn({
actions: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class SmartTaskListComponent implements OnInit {
relativeDateColumn({
title: this.translate.instant(helptextSmart.smartlist_column_next_run),
propertyName: 'next_run',
getValue: (row) => this.taskService.getTaskNextTime(row.cron_schedule) as unknown,
getValue: (row) => this.taskService.getTaskNextTime(row.cron_schedule),
}),
actionsColumn({
actions: [
Expand Down
Loading

0 comments on commit 3a30464

Please sign in to comment.