From b23781515b71749e02883a7065861c4bde5ef872 Mon Sep 17 00:00:00 2001 From: RehanY147 Date: Mon, 23 Sep 2024 22:57:52 +0500 Subject: [PATCH] NAS-131036 / 25.04 / Remove use of `chain` method from `'lodash-es'` (#10716) --- .eslintrc.cjs | 10 ++++++ .../core/testing/utils/mock-window.utils.ts | 4 +-- .../helpers/operators/options.operators.ts | 4 +-- .../entity/entity-job/entity-job.component.ts | 6 ++-- .../similar-issues.component.ts | 4 +-- .../ix-forms/validators/ip-validation.ts | 4 +-- .../password-validation.ts | 6 ++-- .../global-search/global-search.component.ts | 4 +-- .../ix-table/classes/base-data-provider.ts | 9 +++-- .../ix-table-columns-selector.component.ts | 4 +-- .../breadcrumb/breadcrumb.component.ts | 34 +++++++++---------- .../truecommand-button.component.ts | 4 +-- .../groups/group-form/group-form.component.ts | 4 +-- .../users/user-form/user-form.component.ts | 4 +-- .../app-wizard/app-wizard.component.ts | 8 ++--- .../filter-select-list.harness.ts | 4 +-- .../apps/store/apps-filter-store.service.ts | 6 ++-- .../audit/utils/audit-api-data-provider.ts | 4 +-- .../provider-forms/base-provider-form.ts | 4 +-- .../certificate-authority-add.component.ts | 4 +-- .../ca-identifier-and-type.component.ts | 4 +-- .../steps/ca-import/ca-import.component.ts | 4 +-- .../certificate-details.component.ts | 4 +-- .../csr-add/csr-add.component.ts | 4 +-- .../csr-identifier-and-type.component.ts | 4 +-- .../steps/csr-import/csr-import.component.ts | 4 +-- .../certificate-add.component.ts | 4 +-- ...rtificate-identifier-and-type.component.ts | 4 +-- .../certificate-import.component.ts | 4 +-- .../certificate-constraints.component.ts | 8 ++--- .../certificate-subject.component.ts | 4 +-- .../cloudsync-form.component.ts | 20 +++++------ .../cloudsync-what-and-when.component.ts | 20 +++++------ .../transport-section.component.ts | 10 +++--- .../replication-wizard.component.ts | 4 +-- .../quotas-section.component.ts | 4 +-- .../dataset-roles-cell.component.ts | 6 ++-- .../roles-card/roles-card.component.ts | 6 ++-- .../edit-nfs-ace/edit-nfs-ace.component.ts | 6 ++-- .../save-as-preset-modal.component.ts | 10 +++--- .../stores/dataset-acl-editor.store.ts | 11 +++--- .../snapshot-details-row.component.ts | 4 +-- .../ip-addresses-cell.component.ts | 4 +-- .../components/report/report.component.ts | 4 +-- .../extent-form/extent-form.component.ts | 8 ++--- .../initiator-form.component.ts | 4 +-- .../target-form/target-form.component.ts | 4 +-- .../sharing/smb/smb-acl/smb-acl.component.ts | 4 +-- .../smb/smb-form/smb-form.component.ts | 6 ++-- .../signin-form/signin-form.component.ts | 4 +-- .../export-disconnect-modal.component.ts | 6 ++-- .../manage-unused-disk-dialog.component.ts | 6 ++-- .../smart-info-card.component.ts | 4 +-- .../devices/stores/devices-store.service.ts | 4 +-- .../store/add-vdevs-store.service.ts | 4 +-- ...xisting-configuration-preview.component.ts | 24 ++++++------- ...manual-selection-disk-filters.component.ts | 4 +-- .../store/manual-disk-selection.store.ts | 32 ++++++++--------- .../vdevs-to-manual-selection-vdevs.utils.ts | 4 +-- .../draid-selection.component.ts | 4 +-- .../pool-warnings/pool-warnings.component.ts | 4 +-- .../store/pool-manager-validation.service.ts | 4 +-- .../pool-manager/store/pool-manager.store.ts | 12 +++---- .../modules/pool-manager/utils/form.utils.ts | 4 +-- .../utils/generate-vdevs/test-utils.ts | 4 +-- .../stores/pools-dashboard-store.service.ts | 6 ++-- .../global-two-factor-form.component.ts | 4 +-- .../self-encrypting-drive-card.component.ts | 4 +-- .../statuses-legend.component.ts | 10 +++--- .../mini-disks-overview.component.ts | 12 +++---- .../pools-legend/pools-legend.component.ts | 22 ++++++------ .../enclosure/services/enclosure.store.ts | 32 ++++++++++------- .../localization-form.component.ts | 4 +-- .../support-card/support-card.component.ts | 4 +-- src/app/pages/vm/utils/vm-gpu.service.ts | 4 +-- .../pages/vm/vm-wizard/vm-wizard.component.ts | 8 ++--- .../dataset-service/dataset.service.ts | 8 ++--- src/app/services/language.service.ts | 4 +-- src/app/services/schema/app-schema.service.ts | 16 ++++----- src/app/services/system-general.service.ts | 4 +-- src/app/services/validators.ts | 8 ++--- 81 files changed, 298 insertions(+), 290 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 19d9e5c0775..7e72b57de10 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -303,6 +303,16 @@ module.exports = { "importNames": ["CommonModule"], "message": "Import individual constituents instead." }, + { + "name": "lodash-es", + "importNames": ["chain"], + "message": "Use standalone methods to get results instead of using 'chain' for chaining." + }, + { + "name": "lodash", + "importNames": ["chain"], + "message": "Use standalone methods to get results instead of using 'chain' for chaining." + } ], "patterns": [{ "group": [ "../**"], diff --git a/src/app/core/testing/utils/mock-window.utils.ts b/src/app/core/testing/utils/mock-window.utils.ts index 2e95164794a..2447d8f0aef 100644 --- a/src/app/core/testing/utils/mock-window.utils.ts +++ b/src/app/core/testing/utils/mock-window.utils.ts @@ -1,5 +1,5 @@ import { ValueProvider } from '@angular/core'; -import * as _ from 'lodash-es'; +import { merge } from 'lodash-es'; import { DeepPartial } from 'utility-types'; import { WINDOW } from 'app/helpers/window.helper'; @@ -14,6 +14,6 @@ export function mockWindow(overrides: DeepPartial = {}): ValueProvider { return { provide: WINDOW, - useValue: _.merge(baseWindow, overrides), + useValue: merge(baseWindow, overrides), }; } diff --git a/src/app/helpers/operators/options.operators.ts b/src/app/helpers/operators/options.operators.ts index 9d18b7d7512..0414e6c7639 100644 --- a/src/app/helpers/operators/options.operators.ts +++ b/src/app/helpers/operators/options.operators.ts @@ -1,4 +1,4 @@ -import * as _ from 'lodash-es'; +import { uniq } from 'lodash-es'; import { OperatorFunction } from 'rxjs'; import { map } from 'rxjs/operators'; import { Choices } from 'app/interfaces/choices.interface'; @@ -28,7 +28,7 @@ export function singleArrayToOptions(): OperatorFunction<(string | number)[], Op export function redundantListToUniqueOptions(): OperatorFunction { return map((redundantArray) => { - return _.uniq(redundantArray).map((item: string) => ({ label: item, value: item })); + return uniq(redundantArray).map((item: string) => ({ label: item, value: item })); }); } diff --git a/src/app/modules/entity/entity-job/entity-job.component.ts b/src/app/modules/entity/entity-job/entity-job.component.ts index ebc2aa06adf..2bca3291e4f 100644 --- a/src/app/modules/entity/entity-job/entity-job.component.ts +++ b/src/app/modules/entity/entity-job/entity-job.component.ts @@ -8,7 +8,7 @@ import { } from '@angular/core'; import { MatDialogConfig, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import * as _ from 'lodash-es'; +import { replace } from 'lodash-es'; import { Subscription } from 'rxjs'; import { filter, map } from 'rxjs/operators'; import { JobState } from 'app/enums/job-state.enum'; @@ -91,8 +91,8 @@ export class EntityJobComponent implements OnInit, AfterViewChecked { }); this.failure.pipe(untilDestroyed(this)).subscribe((job) => { - let error = _.replace(job.error, '<', '< '); - error = _.replace(error, '>', ' >'); + let error = replace(job.error, '<', '< '); + error = replace(error, '>', ' >'); this.description = 'Error: ' + error; }); diff --git a/src/app/modules/feedback/components/similar-issues/similar-issues.component.ts b/src/app/modules/feedback/components/similar-issues/similar-issues.component.ts index 7ab14cd1655..3d1e067aee0 100644 --- a/src/app/modules/feedback/components/similar-issues/similar-issues.component.ts +++ b/src/app/modules/feedback/components/similar-issues/similar-issues.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, Input, } from '@angular/core'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import * as _ from 'lodash-es'; +import { sortBy, uniqBy } from 'lodash-es'; import { BehaviorSubject, Observable, debounceTime, distinctUntilChanged, filter, pairwise, switchMap, } from 'rxjs'; @@ -64,7 +64,7 @@ export class SimilarIssuesComponent { this.isLoading$.next(true); return this.feedbackService.getSimilarIssues(query).pipe( switchMap((newIssues) => { - const combinedUniqueIssues = _.sortBy(_.uniqBy([ + const combinedUniqueIssues = sortBy(uniqBy([ ...this.similarIssues$.value, ...newIssues, ], 'id'), { summaryText: query }); diff --git a/src/app/modules/forms/ix-forms/validators/ip-validation.ts b/src/app/modules/forms/ix-forms/validators/ip-validation.ts index 5bdc05dc3d7..0dbb93a96be 100644 --- a/src/app/modules/forms/ix-forms/validators/ip-validation.ts +++ b/src/app/modules/forms/ix-forms/validators/ip-validation.ts @@ -1,7 +1,7 @@ import { FormControl, ValidatorFn } from '@angular/forms'; import ipRegex from 'ip-regex'; import isCidr from 'is-cidr'; -import * as _ from 'lodash-es'; +import { indexOf } from 'lodash-es'; // Accepts ipv4 or ipv6 addresses with no CIDR (ie, /24) export function ipv4or6Validator(): ValidatorFn { @@ -154,7 +154,7 @@ export function ipValidator(type: string = 'ipv4' || 'ipv6' || 'all'): Validator function checkIp(ipType = 'ipv4' || 'ipv6'): boolean { const regex = ipType === 'ipv4' ? ipv4Regex : ipv6Regex; const wildcard = ipType === 'ipv4' ? '0.0.0.0' : '::'; - if (_.indexOf(thisControl.value, wildcard) !== -1) { + if (indexOf(thisControl.value, wildcard) !== -1) { for (const ip of thisControl.value) { if (ip !== wildcard && regex.test(ip)) { error = [ipType === 'ipv4' ? 'IPv4' : 'IPv6', wildcard, ip]; diff --git a/src/app/modules/forms/ix-forms/validators/password-validation/password-validation.ts b/src/app/modules/forms/ix-forms/validators/password-validation/password-validation.ts index 36051e1fe80..193a561f8f4 100644 --- a/src/app/modules/forms/ix-forms/validators/password-validation/password-validation.ts +++ b/src/app/modules/forms/ix-forms/validators/password-validation/password-validation.ts @@ -1,5 +1,5 @@ import { FormGroup, UntypedFormControl, ValidatorFn } from '@angular/forms'; -import * as _ from 'lodash-es'; +import { isEmpty } from 'lodash-es'; export function matchOthersFgValidator( controlName: string, @@ -34,7 +34,7 @@ export function matchOthersFgValidator( } let prevErrors = { ...fg.get(controlName).errors }; delete prevErrors.matchOther; - if (_.isEmpty(prevErrors)) { + if (isEmpty(prevErrors)) { prevErrors = null; } fg.get(controlName).setErrors(prevErrors); @@ -75,7 +75,7 @@ export function doesNotEqualFgValidator( } let prevErrors = { ...fg.get(controlName).errors }; delete prevErrors.matchesOther; - if (_.isEmpty(prevErrors)) { + if (isEmpty(prevErrors)) { prevErrors = null; } fg.get(controlName).setErrors(prevErrors); diff --git a/src/app/modules/global-search/components/global-search/global-search.component.ts b/src/app/modules/global-search/components/global-search/global-search.component.ts index 8257082fdb6..05eb4b2e5d3 100644 --- a/src/app/modules/global-search/components/global-search/global-search.component.ts +++ b/src/app/modules/global-search/components/global-search/global-search.component.ts @@ -8,7 +8,7 @@ import { import { FormControl } from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { Store } from '@ngrx/store'; -import * as _ from 'lodash-es'; +import { isEqual } from 'lodash-es'; import { tap, debounceTime, filter, switchMap, combineLatestWith, @@ -183,7 +183,7 @@ export class GlobalSearchComponent implements OnInit, AfterViewInit, OnDestroy { }), combineLatestWith(this.searchDirectives.directiveAdded$.pipe(filter(Boolean))), filter(([config]) => !!this.searchDirectives.get(config)), - distinctUntilChanged(([prevConfig], [nextConfig]) => _.isEqual(prevConfig, nextConfig)), + distinctUntilChanged(([prevConfig], [nextConfig]) => isEqual(prevConfig, nextConfig)), untilDestroyed(this), ).subscribe(([config]) => { this.resetInput(); diff --git a/src/app/modules/ix-table/classes/base-data-provider.ts b/src/app/modules/ix-table/classes/base-data-provider.ts index b89c73bf559..e4c7a89a829 100644 --- a/src/app/modules/ix-table/classes/base-data-provider.ts +++ b/src/app/modules/ix-table/classes/base-data-provider.ts @@ -1,5 +1,5 @@ import { EventEmitter } from '@angular/core'; -import * as _ from 'lodash-es'; +import { orderBy, sortBy } from 'lodash-es'; import { BehaviorSubject, Observable, Subscription, map, } from 'rxjs'; @@ -85,16 +85,15 @@ export function sort(rows: T[], sorting: TableSort): T[] { const sorted = rows; const direction = sorting.direction; const propertyName = sorting.propertyName; - const sortBy = sorting.sortBy; if (direction === null || propertyName === null) { return sorted; } - if (sortBy) { - return direction === SortDirection.Desc ? _.sortBy(sorted, sortBy).reverse() : _.sortBy(sorted, sortBy); + if (sorting.sortBy) { + return direction === SortDirection.Desc ? sortBy(sorted, sorting.sortBy).reverse() : sortBy(sorted, sorting.sortBy); } - return _.orderBy(sorted, propertyName, direction); + return orderBy(sorted, propertyName, direction); } export function paginate(rows: T[], pagination: TablePagination): T[] { diff --git a/src/app/modules/ix-table/components/ix-table-columns-selector/ix-table-columns-selector.component.ts b/src/app/modules/ix-table/components/ix-table-columns-selector/ix-table-columns-selector.component.ts index c4271b892d1..4637c4865cb 100644 --- a/src/app/modules/ix-table/components/ix-table-columns-selector/ix-table-columns-selector.component.ts +++ b/src/app/modules/ix-table/components/ix-table-columns-selector/ix-table-columns-selector.component.ts @@ -6,7 +6,7 @@ import { MatButton } from '@angular/material/button'; import { MatMenuTrigger, MatMenu, MatMenuItem } from '@angular/material/menu'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateModule } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { cloneDeep } from 'lodash-es'; import { IxSimpleChanges } from 'app/interfaces/simple-changes.interface'; import { IxIconModule } from 'app/modules/ix-icon/ix-icon.module'; import { Column, ColumnComponent } from 'app/modules/ix-table/interfaces/column-component.class'; @@ -87,7 +87,7 @@ export class IxTableColumnsSelectorComponent implements OnChanges { } private setInitialState(): void { - this.columns = _.cloneDeep(this.defaultColumns); + this.columns = cloneDeep(this.defaultColumns); this.hiddenColumns.select(...this.columns); this.defaultColumns.forEach((column, index) => { diff --git a/src/app/modules/page-header/breadcrumb/breadcrumb.component.ts b/src/app/modules/page-header/breadcrumb/breadcrumb.component.ts index c753a52cd78..59ecaab9b3b 100644 --- a/src/app/modules/page-header/breadcrumb/breadcrumb.component.ts +++ b/src/app/modules/page-header/breadcrumb/breadcrumb.component.ts @@ -3,7 +3,7 @@ import { } from '@angular/core'; import { Router, NavigationEnd } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import { chain } from 'lodash-es'; +import { uniqBy } from 'lodash-es'; import { filter } from 'rxjs/operators'; import { RoutePartsService, RoutePart } from 'app/services/route-parts/route-parts.service'; @@ -39,22 +39,20 @@ export class BreadcrumbComponent implements OnInit { } private getBreadcrumbs(): RoutePart[] { - return chain(this.routePartsService.routeParts) - .sort((a, b) => a.ngUrl.length - b.ngUrl.length) - .uniqBy('url') - .filter((routePart) => { - routePart.ngUrl = routePart.ngUrl.filter((item) => item !== ''); - if (routePart.url === this.router.url) { - return false; - } - return Boolean(routePart.breadcrumb); - }) - .map((routePart) => { - if (noLinksRoutes.some((url) => routePart.url === url)) { - return { ...routePart, url: null }; - } - return routePart; - }) - .value(); + const sortedRoutes = this.routePartsService.routeParts.sort((a, b) => a.ngUrl.length - b.ngUrl.length); + const uniqRoutesList = uniqBy(sortedRoutes, 'url'); + const validRoutesBeforeCurrent = uniqRoutesList.filter((routePart) => { + routePart.ngUrl = routePart.ngUrl.filter((item) => item !== ''); + if (routePart.url === this.router.url) { + return false; + } + return Boolean(routePart.breadcrumb); + }); + return validRoutesBeforeCurrent.map((routePart) => { + if (noLinksRoutes.some((url) => routePart.url === url)) { + return { ...routePart, url: null }; + } + return routePart; + }); } } diff --git a/src/app/modules/truecommand/truecommand-button.component.ts b/src/app/modules/truecommand/truecommand-button.component.ts index 8e0d7c90973..35b0e4a6c97 100644 --- a/src/app/modules/truecommand/truecommand-button.component.ts +++ b/src/app/modules/truecommand/truecommand-button.component.ts @@ -4,7 +4,7 @@ import { } from '@angular/core'; import { MatDialog, MatDialogRef } from '@angular/material/dialog'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import * as _ from 'lodash-es'; +import { isObject } from 'lodash-es'; import { TrueCommandStatus } from 'app/enums/true-command-status.enum'; import { WINDOW } from 'app/helpers/window.helper'; import { helptextTopbar } from 'app/helptext/topbar'; @@ -93,7 +93,7 @@ export class TruecommandButtonComponent implements OnInit { .afterClosed() .pipe(untilDestroyed(this)) .subscribe((dialogResult: TruecommandSignupModalResult) => { - if (_.isObject(dialogResult) && dialogResult?.deregistered) { + if (isObject(dialogResult) && dialogResult?.deregistered) { this.tcStatusDialogRef.close(true); } }); diff --git a/src/app/pages/account/groups/group-form/group-form.component.ts b/src/app/pages/account/groups/group-form/group-form.component.ts index ab811c42ce6..6faf4790ad5 100644 --- a/src/app/pages/account/groups/group-form/group-form.component.ts +++ b/src/app/pages/account/groups/group-form/group-form.component.ts @@ -5,7 +5,7 @@ import { FormBuilder, Validators } from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { Store } from '@ngrx/store'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { remove } from 'lodash-es'; import { Observable, combineLatest, of, } from 'rxjs'; @@ -240,7 +240,7 @@ export class GroupFormComponent implements OnInit { this.ws.call('group.query').pipe(untilDestroyed(this)).subscribe((groups) => { let forbiddenNames = groups.map((group) => group.group); if (currentName) { - forbiddenNames = _.remove(forbiddenNames, currentName); + forbiddenNames = remove(forbiddenNames, currentName); } this.form.controls.name.addValidators(forbiddenValues(forbiddenNames)); }); diff --git a/src/app/pages/account/users/user-form/user-form.component.ts b/src/app/pages/account/users/user-form/user-form.component.ts index 5ceb1f2013e..0653f001e22 100644 --- a/src/app/pages/account/users/user-form/user-form.component.ts +++ b/src/app/pages/account/users/user-form/user-form.component.ts @@ -6,7 +6,7 @@ import { FormBuilder } from '@ngneat/reactive-forms'; import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy'; import { Store } from '@ngrx/store'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { remove } from 'lodash-es'; import { from, Observable, of, Subscription, } from 'rxjs'; @@ -457,7 +457,7 @@ export class UserFormComponent implements OnInit { this.store$.select(selectUsers).pipe(untilDestroyed(this)).subscribe((users) => { let forbiddenNames = users.map((user) => user.username); if (currentName) { - forbiddenNames = _.remove(forbiddenNames, currentName); + forbiddenNames = remove(forbiddenNames, currentName); } this.form.controls.username.addValidators(forbiddenValues(forbiddenNames)); }); diff --git a/src/app/pages/apps/components/app-wizard/app-wizard.component.ts b/src/app/pages/apps/components/app-wizard/app-wizard.component.ts index ca5af339e2b..6f48e39eef8 100644 --- a/src/app/pages/apps/components/app-wizard/app-wizard.component.ts +++ b/src/app/pages/apps/components/app-wizard/app-wizard.component.ts @@ -10,7 +10,7 @@ import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Router } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { isArray, isPlainObject, unset } from 'lodash-es'; import { BehaviorSubject, Observable, of, Subject, Subscription, timer, } from 'rxjs'; @@ -202,12 +202,12 @@ export class AppWizardComponent implements OnInit, OnDestroy { } }); } - if (_.isPlainObject(data)) { + if (isPlainObject(data)) { Object.keys(data).forEach((key) => { this.getFieldsHiddenOnForm((data as Record)[key], deleteField$, path ? path + '.' + key : key); }); } - if (_.isArray(data)) { + if (isArray(data)) { for (let i = 0; i < data.length; i++) { this.getFieldsHiddenOnForm(data[i], deleteField$, `${path}.${i}`); } @@ -220,7 +220,7 @@ export class AppWizardComponent implements OnInit, OnDestroy { deleteField$.pipe(untilDestroyed(this)).subscribe({ next: (fieldToBeDeleted) => { const keys = fieldToBeDeleted.split('.'); - _.unset(data, keys); + unset(data, keys); }, complete: () => this.saveData(data), }); diff --git a/src/app/pages/apps/modules/custom-forms/components/filter-select-list/filter-select-list.harness.ts b/src/app/pages/apps/modules/custom-forms/components/filter-select-list/filter-select-list.harness.ts index 324d31bf22b..eae17a91d1d 100644 --- a/src/app/pages/apps/modules/custom-forms/components/filter-select-list/filter-select-list.harness.ts +++ b/src/app/pages/apps/modules/custom-forms/components/filter-select-list/filter-select-list.harness.ts @@ -1,6 +1,6 @@ import { coerceBooleanProperty } from '@angular/cdk/coercion'; import { ComponentHarness } from '@angular/cdk/testing'; -import * as _ from 'lodash-es'; +import { isString } from 'lodash-es'; import { IxFormControlHarness } from 'app/modules/forms/ix-forms/interfaces/ix-form-control-harness.interface'; import { getErrorText } from 'app/modules/forms/ix-forms/utils/harness.utils'; import { IxIconHarness } from 'app/modules/ix-icon/ix-icon.harness'; @@ -35,7 +35,7 @@ export class IxFilterSelectListHarness extends ComponentHarness implements IxFor } async setValue(value: string[] | string): Promise { - if (_.isString(value)) { + if (isString(value)) { value = [value]; } const items = await this.getItems(); diff --git a/src/app/pages/apps/store/apps-filter-store.service.ts b/src/app/pages/apps/store/apps-filter-store.service.ts index 211bd07efa8..9c8befd124e 100644 --- a/src/app/pages/apps/store/apps-filter-store.service.ts +++ b/src/app/pages/apps/store/apps-filter-store.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { ComponentStore } from '@ngrx/component-store'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { deburr, some, toLower } from 'lodash-es'; import { EMPTY, Observable, combineLatest, map, } from 'rxjs'; @@ -191,10 +191,10 @@ export class AppsFilterStore extends ComponentStore { } private doesAppContainString = (searchQuery: string, app: AvailableApp): boolean => { - const normalize = (str: string): string => _.toLower(_.deburr(str)); + const normalize = (str: string): string => toLower(deburr(str)); const isStringsArray = (arr: unknown[]): boolean => arr.every((i) => typeof i === 'string'); const search = normalize(searchQuery); - return _.some(app, (value) => { + return some(app, (value) => { if (typeof value === 'string') { return normalize(value).includes(search); } diff --git a/src/app/pages/audit/utils/audit-api-data-provider.ts b/src/app/pages/audit/utils/audit-api-data-provider.ts index 7f1aa5a92b3..ba4d03656e1 100644 --- a/src/app/pages/audit/utils/audit-api-data-provider.ts +++ b/src/app/pages/audit/utils/audit-api-data-provider.ts @@ -1,4 +1,4 @@ -import * as _ from 'lodash-es'; +import { isEqual } from 'lodash-es'; import { Observable, of } from 'rxjs'; import { ApiCallParams } from 'app/interfaces/api/api-call-directory.interface'; import { AuditEntry, AuditQueryParams } from 'app/interfaces/audit/audit.interface'; @@ -14,7 +14,7 @@ export class AuditApiDataProvider extends ApiDataProvider<'audit.query'> { } get avoidCountRowsRequest(): boolean { - return this.totalRows && !this.isLastOffset && _.isEqual(this.lastParams, this.params[0]); + return this.totalRows && !this.isLastOffset && isEqual(this.lastParams, this.params[0]); } constructor(ws: WebSocketService) { diff --git a/src/app/pages/credentials/backup-credentials/cloud-credentials-form/provider-forms/base-provider-form.ts b/src/app/pages/credentials/backup-credentials/cloud-credentials-form/provider-forms/base-provider-form.ts index 1ea76404f9b..519de9839ff 100644 --- a/src/app/pages/credentials/backup-credentials/cloud-credentials-form/provider-forms/base-provider-form.ts +++ b/src/app/pages/credentials/backup-credentials/cloud-credentials-form/provider-forms/base-provider-form.ts @@ -1,5 +1,5 @@ import { FormGroup } from '@angular/forms'; -import * as _ from 'lodash-es'; +import { isNull, omitBy } from 'lodash-es'; import { BehaviorSubject, Observable, of } from 'rxjs'; import { helptextSystemCloudcredentials as helptext } from 'app/helptext/system/cloud-credentials'; import { CloudCredential } from 'app/interfaces/cloud-sync-task.interface'; @@ -23,7 +23,7 @@ export abstract class BaseProviderFormComponent step.getPayload()); - return _.merge({}, ...values); + return merge({}, ...values); } private setDefaultConstraints(): void { diff --git a/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.ts b/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.ts index 6c07cb39c58..445184a698f 100644 --- a/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.ts +++ b/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.ts @@ -4,7 +4,7 @@ import { import { FormBuilder, Validators } from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { pick } from 'lodash-es'; import { Observable, of } from 'rxjs'; import { CaCreateType } from 'app/enums/ca-create-type.enum'; import { mapToOptions } from 'app/helpers/options.helper'; @@ -106,7 +106,7 @@ export class CaIdentifierAndTypeComponent implements OnInit, SummaryProvider { } getPayload(): Pick { - return _.pick(this.form.value, ['name', 'create_type', 'add_to_trusted_store']); + return pick(this.form.value, ['name', 'create_type', 'add_to_trusted_store']); } private emitEventOnProfileChange(): void { diff --git a/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-import/ca-import.component.ts b/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-import/ca-import.component.ts index cbee05badbf..7a6af007ca2 100644 --- a/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-import/ca-import.component.ts +++ b/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-import/ca-import.component.ts @@ -4,7 +4,7 @@ import { import { FormBuilder, Validators } from '@angular/forms'; import { UntilDestroy } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { pick } from 'lodash-es'; import { helptextSystemCertificates } from 'app/helptext/system/certificates'; import { matchOthersFgValidator } from 'app/modules/forms/ix-forms/validators/password-validation/password-validation'; import { SummaryProvider, SummarySection } from 'app/modules/summary/summary.interface'; @@ -60,6 +60,6 @@ export class CaImportComponent implements SummaryProvider { getPayload(): Omit { const values = this.form.value; - return _.pick(values, ['certificate', 'privatekey', 'passphrase']); + return pick(values, ['certificate', 'privatekey', 'passphrase']); } } diff --git a/src/app/pages/credentials/certificates-dash/certificate-details/certificate-details.component.ts b/src/app/pages/credentials/certificates-dash/certificate-details/certificate-details.component.ts index 196beff3e64..0089d762be2 100644 --- a/src/app/pages/credentials/certificates-dash/certificate-details/certificate-details.component.ts +++ b/src/app/pages/credentials/certificates-dash/certificate-details/certificate-details.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component, computed, input, } from '@angular/core'; -import * as _ from 'lodash-es'; +import { isObject } from 'lodash-es'; import { CertificateAuthority } from 'app/interfaces/certificate-authority.interface'; import { Certificate } from 'app/interfaces/certificate.interface'; @@ -21,7 +21,7 @@ export class CertificateDetailsComponent { issuer = computed(() => { const certificate = this.certificate(); - return _.isObject(certificate.issuer) ? certificate.issuer.name : certificate.issuer; + return isObject(certificate.issuer) ? certificate.issuer.name : certificate.issuer; }); signedCertificates = computed(() => { diff --git a/src/app/pages/credentials/certificates-dash/csr-add/csr-add.component.ts b/src/app/pages/credentials/certificates-dash/csr-add/csr-add.component.ts index 6bc13fba3cd..f41b5dc4c2a 100644 --- a/src/app/pages/credentials/certificates-dash/csr-add/csr-add.component.ts +++ b/src/app/pages/credentials/certificates-dash/csr-add/csr-add.component.ts @@ -3,7 +3,7 @@ import { } from '@angular/core'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { merge } from 'lodash-es'; import { CertificateCreateType } from 'app/enums/certificate-create-type.enum'; import { Role } from 'app/enums/role.enum'; import { CertificateCreate, CertificateProfile } from 'app/interfaces/certificate.interface'; @@ -128,6 +128,6 @@ export class CsrAddComponent { const steps = this.isImport ? this.getImportCsrSteps() : this.getNewCsrSteps(); const values = steps.map((step) => step.getPayload()); - return _.merge({}, ...values); + return merge({}, ...values); } } diff --git a/src/app/pages/credentials/certificates-dash/csr-add/steps/csr-identifier-and-type/csr-identifier-and-type.component.ts b/src/app/pages/credentials/certificates-dash/csr-add/steps/csr-identifier-and-type/csr-identifier-and-type.component.ts index b1eb33db279..a7ba41e9646 100644 --- a/src/app/pages/credentials/certificates-dash/csr-add/steps/csr-identifier-and-type/csr-identifier-and-type.component.ts +++ b/src/app/pages/credentials/certificates-dash/csr-add/steps/csr-identifier-and-type/csr-identifier-and-type.component.ts @@ -4,7 +4,7 @@ import { import { FormBuilder, Validators } from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { pick } from 'lodash-es'; import { Observable, of } from 'rxjs'; import { CertificateCreateType } from 'app/enums/certificate-create-type.enum'; import { mapToOptions } from 'app/helpers/options.helper'; @@ -85,7 +85,7 @@ export class CsrIdentifierAndTypeComponent implements OnInit, SummaryProvider { } getPayload(): Pick { - return _.pick(this.form.value, ['name', 'create_type']); + return pick(this.form.value, ['name', 'create_type']); } private loadProfiles(): void { diff --git a/src/app/pages/credentials/certificates-dash/csr-add/steps/csr-import/csr-import.component.ts b/src/app/pages/credentials/certificates-dash/csr-add/steps/csr-import/csr-import.component.ts index d5095756593..6129b4fe70e 100644 --- a/src/app/pages/credentials/certificates-dash/csr-add/steps/csr-import/csr-import.component.ts +++ b/src/app/pages/credentials/certificates-dash/csr-add/steps/csr-import/csr-import.component.ts @@ -4,7 +4,7 @@ import { import { FormBuilder, Validators } from '@angular/forms'; import { UntilDestroy } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { pick } from 'lodash-es'; import { helptextSystemCertificates } from 'app/helptext/system/certificates'; import { matchOthersFgValidator } from 'app/modules/forms/ix-forms/validators/password-validation/password-validation'; import { SummaryProvider, SummarySection } from 'app/modules/summary/summary.interface'; @@ -60,6 +60,6 @@ export class CsrImportComponent implements SummaryProvider { getPayload(): Omit { const values = this.form.value; - return _.pick(values, ['CSR', 'privatekey', 'passphrase']); + return pick(values, ['CSR', 'privatekey', 'passphrase']); } } diff --git a/src/app/pages/credentials/certificates-dash/forms/certificate-add/certificate-add.component.ts b/src/app/pages/credentials/certificates-dash/forms/certificate-add/certificate-add.component.ts index 31f7a1288cc..5df1a6c9f24 100644 --- a/src/app/pages/credentials/certificates-dash/forms/certificate-add/certificate-add.component.ts +++ b/src/app/pages/credentials/certificates-dash/forms/certificate-add/certificate-add.component.ts @@ -3,7 +3,7 @@ import { } from '@angular/core'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { merge } from 'lodash-es'; import { CertificateCreateType } from 'app/enums/certificate-create-type.enum'; import { Role } from 'app/enums/role.enum'; import { CertificateCreate, CertificateProfile } from 'app/interfaces/certificate.interface'; @@ -125,6 +125,6 @@ export class CertificateAddComponent { const steps = this.isImport ? this.getImportCertificateSteps() : this.getNewCertificateSteps(); const values = steps.map((step) => step.getPayload()); - return _.merge({}, ...values); + return merge({}, ...values); } } diff --git a/src/app/pages/credentials/certificates-dash/forms/certificate-add/steps/certificate-identifier-and-type/certificate-identifier-and-type.component.ts b/src/app/pages/credentials/certificates-dash/forms/certificate-add/steps/certificate-identifier-and-type/certificate-identifier-and-type.component.ts index 450ecf7c78d..76580a1985b 100644 --- a/src/app/pages/credentials/certificates-dash/forms/certificate-add/steps/certificate-identifier-and-type/certificate-identifier-and-type.component.ts +++ b/src/app/pages/credentials/certificates-dash/forms/certificate-add/steps/certificate-identifier-and-type/certificate-identifier-and-type.component.ts @@ -4,7 +4,7 @@ import { import { FormBuilder, Validators } from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { pick } from 'lodash-es'; import { Observable, of } from 'rxjs'; import { CertificateCreateType } from 'app/enums/certificate-create-type.enum'; import { mapToOptions } from 'app/helpers/options.helper'; @@ -100,7 +100,7 @@ export class CertificateIdentifierAndTypeComponent implements OnInit, SummaryPro } getPayload(): Pick { - return _.pick(this.form.value, ['name', 'create_type', 'add_to_trusted_store']); + return pick(this.form.value, ['name', 'create_type', 'add_to_trusted_store']); } private emitEventOnProfileChange(): void { diff --git a/src/app/pages/credentials/certificates-dash/forms/certificate-add/steps/certificate-import/certificate-import.component.ts b/src/app/pages/credentials/certificates-dash/forms/certificate-add/steps/certificate-import/certificate-import.component.ts index d44094ad1f8..dca38e34109 100644 --- a/src/app/pages/credentials/certificates-dash/forms/certificate-add/steps/certificate-import/certificate-import.component.ts +++ b/src/app/pages/credentials/certificates-dash/forms/certificate-add/steps/certificate-import/certificate-import.component.ts @@ -4,7 +4,7 @@ import { import { FormBuilder, Validators } from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { pick } from 'lodash-es'; import { of } from 'rxjs'; import { helptextSystemCertificates } from 'app/helptext/system/certificates'; import { Certificate } from 'app/interfaces/certificate.interface'; @@ -103,7 +103,7 @@ export class CertificateImportComponent implements OnInit, SummaryProvider { }; } - return _.pick(values, ['certificate', 'privatekey', 'passphrase']); + return pick(values, ['certificate', 'privatekey', 'passphrase']); } private loadCsrs(): void { diff --git a/src/app/pages/credentials/certificates-dash/forms/common-steps/certificate-constraints/certificate-constraints.component.ts b/src/app/pages/credentials/certificates-dash/forms/common-steps/certificate-constraints/certificate-constraints.component.ts index a2bc1f1dc5c..0c8d3e0b46e 100644 --- a/src/app/pages/credentials/certificates-dash/forms/common-steps/certificate-constraints/certificate-constraints.component.ts +++ b/src/app/pages/credentials/certificates-dash/forms/common-steps/certificate-constraints/certificate-constraints.component.ts @@ -4,7 +4,7 @@ import { import { FormBuilder, Validators } from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { omit } from 'lodash-es'; import { of } from 'rxjs'; import { ExtendedKeyUsageFlag } from 'app/enums/extended-key-usage-flag.enum'; import { choicesToOptions } from 'app/helpers/operators/options.operators'; @@ -151,7 +151,7 @@ export class CertificateConstraintsComponent implements OnInit, SummaryProvider enabled: basicConstraints.enabled, path_length: basicConstraints.path_length || null, BasicConstraints: extensionsToSelectValues( - _.omit(basicConstraints, ['enabled', 'path_length']), + omit(basicConstraints, ['enabled', 'path_length']), ) as BasicConstraint[], }, }); @@ -161,7 +161,7 @@ export class CertificateConstraintsComponent implements OnInit, SummaryProvider AuthorityKeyIdentifier: { enabled: authorityKeyIdentifier.enabled, AuthorityKeyIdentifier: extensionsToSelectValues( - _.omit(authorityKeyIdentifier, ['enabled']), + omit(authorityKeyIdentifier, ['enabled']), ) as AuthorityKeyIdentifier[], }, }); @@ -179,7 +179,7 @@ export class CertificateConstraintsComponent implements OnInit, SummaryProvider this.form.patchValue({ KeyUsage: { enabled: keyUsage.enabled, - KeyUsage: extensionsToSelectValues(_.omit(keyUsage, ['enabled'])), + KeyUsage: extensionsToSelectValues(omit(keyUsage, ['enabled'])), }, }); } diff --git a/src/app/pages/credentials/certificates-dash/forms/common-steps/certificate-subject/certificate-subject.component.ts b/src/app/pages/credentials/certificates-dash/forms/common-steps/certificate-subject/certificate-subject.component.ts index b39c02803d3..6b25c3f400e 100644 --- a/src/app/pages/credentials/certificates-dash/forms/common-steps/certificate-subject/certificate-subject.component.ts +++ b/src/app/pages/credentials/certificates-dash/forms/common-steps/certificate-subject/certificate-subject.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { FormBuilder, Validators } from '@angular/forms'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { pickBy } from 'lodash-es'; import { choicesToOptions } from 'app/helpers/operators/options.operators'; import { helptextSystemCertificates } from 'app/helptext/system/certificates'; import { emailValidator } from 'app/modules/forms/ix-forms/validators/email-validation/email-validation'; @@ -67,6 +67,6 @@ export class CertificateSubjectComponent implements SummaryProvider { getPayload(): CertificateSubjectComponent['form']['value'] { // Filter out empty values - return _.pickBy(this.form.value, Boolean); + return pickBy(this.form.value, Boolean); } } diff --git a/src/app/pages/data-protection/cloudsync/cloudsync-form/cloudsync-form.component.ts b/src/app/pages/data-protection/cloudsync/cloudsync-form/cloudsync-form.component.ts index f80ba4c118a..50d72e1610c 100644 --- a/src/app/pages/data-protection/cloudsync/cloudsync-form/cloudsync-form.component.ts +++ b/src/app/pages/data-protection/cloudsync/cloudsync-form/cloudsync-form.component.ts @@ -7,7 +7,7 @@ import { NavigationExtras, Router } from '@angular/router'; import { FormBuilder } from '@ngneat/reactive-forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { find, findIndex, isArray } from 'lodash-es'; import { Observable, forkJoin, of } from 'rxjs'; import { filter, map, pairwise, startWith, tap, @@ -356,7 +356,7 @@ export class CloudSyncFormComponent implements OnInit { } loadBucketOptions(): void { - const targetCredentials = _.find(this.credentialsList, { id: this.form.controls.credentials.value }); + const targetCredentials = find(this.credentialsList, { id: this.form.controls.credentials.value }); this.cloudCredentialService.getBuckets(targetCredentials.id) .pipe(untilDestroyed(this)) @@ -451,8 +451,8 @@ export class CloudSyncFormComponent implements OnInit { if (credentials) { this.enableRemoteExplorer(); - const targetCredentials = _.find(this.credentialsList, { id: credentials }); - const targetProvider = _.find(this.providersList, { name: targetCredentials?.provider }); + const targetCredentials = find(this.credentialsList, { id: credentials }); + const targetProvider = find(this.providersList, { name: targetCredentials?.provider }); if (targetProvider?.buckets) { this.isLoading = true; if (targetCredentials.provider === CloudSyncProviderName.MicrosoftAzure @@ -483,12 +483,12 @@ export class CloudSyncFormComponent implements OnInit { this.form.controls.bucket_policy_only.disable(); } - const schemaFound = _.find(this.providersList, { name: targetCredentials?.provider }); + const schemaFound = find(this.providersList, { name: targetCredentials?.provider }); const taskSchema = schemaFound ? schemaFound.task_schema : []; const taskSchemas = ['task_encryption', 'fast_list', 'chunk_size', 'storage_class']; for (const i of taskSchemas) { - const toBeDisable = !(_.findIndex(taskSchema, { property: i }) > -1); + const toBeDisable = !(findIndex(taskSchema, { property: i }) > -1); if (i === 'task_encryption' || i === 'fast_list' || i === 'chunk_size' || i === 'storage_class') { if (toBeDisable) { this.form.controls[i].disable(); @@ -606,9 +606,9 @@ export class CloudSyncFormComponent implements OnInit { }); if (formValue.direction === Direction.Pull) { - value.path = _.isArray(formValue.path_destination) ? formValue.path_destination[0] : formValue.path_destination; + value.path = isArray(formValue.path_destination) ? formValue.path_destination[0] : formValue.path_destination; - if (!formValue.folder_source.length || !_.isArray(formValue.folder_source)) { + if (!formValue.folder_source.length || !isArray(formValue.folder_source)) { attributes.folder = '/'; } else if (formValue.folder_source.length === 1) { attributes.folder = formValue.folder_source[0]; @@ -622,10 +622,10 @@ export class CloudSyncFormComponent implements OnInit { attributes.folder = directory.slice(0, directory.length - 1).join('/'); } } else { - attributes.folder = _.isArray(formValue.folder_destination) + attributes.folder = isArray(formValue.folder_destination) ? formValue.folder_destination[0] : formValue.folder_destination; - if (!formValue.path_source.length || !_.isArray(formValue.path_source)) { + if (!formValue.path_source.length || !isArray(formValue.path_source)) { value.path = '/'; } else if (formValue.path_source.length === 1) { value.path = formValue.path_source[0]; diff --git a/src/app/pages/data-protection/cloudsync/cloudsync-wizard/steps/cloudsync-what-and-when/cloudsync-what-and-when.component.ts b/src/app/pages/data-protection/cloudsync/cloudsync-wizard/steps/cloudsync-what-and-when/cloudsync-what-and-when.component.ts index 4b5f1aa88ec..48469ac1aab 100644 --- a/src/app/pages/data-protection/cloudsync/cloudsync-wizard/steps/cloudsync-what-and-when/cloudsync-what-and-when.component.ts +++ b/src/app/pages/data-protection/cloudsync/cloudsync-wizard/steps/cloudsync-what-and-when/cloudsync-what-and-when.component.ts @@ -6,7 +6,7 @@ import { MatDialog } from '@angular/material/dialog'; import { NavigationExtras, Router } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { find, findIndex, isArray } from 'lodash-es'; import { Observable, combineLatest, filter, map, merge, of, tap, } from 'rxjs'; @@ -190,9 +190,9 @@ export class CloudSyncWhatAndWhenComponent implements OnInit, OnChanges { }); if (formValue.direction === Direction.Pull) { - value.path = _.isArray(formValue.path_destination) ? formValue.path_destination[0] : formValue.path_destination; + value.path = isArray(formValue.path_destination) ? formValue.path_destination[0] : formValue.path_destination; - if (!formValue.folder_source?.length || !_.isArray(formValue.folder_source)) { + if (!formValue.folder_source?.length || !isArray(formValue.folder_source)) { attributes.folder = '/'; } else if (formValue.folder_source.length === 1) { attributes.folder = formValue.folder_source[0]; @@ -206,10 +206,10 @@ export class CloudSyncWhatAndWhenComponent implements OnInit, OnChanges { attributes.folder = directory.slice(0, directory.length - 1).join('/'); } } else { - attributes.folder = _.isArray(formValue.folder_destination) + attributes.folder = isArray(formValue.folder_destination) ? formValue.folder_destination[0] : formValue.folder_destination; - if (!formValue.path_source.length || !_.isArray(formValue.path_source)) { + if (!formValue.path_source.length || !isArray(formValue.path_source)) { value.path = '/'; } else if (formValue.path_source.length === 1) { value.path = formValue.path_source[0]; @@ -349,8 +349,8 @@ export class CloudSyncWhatAndWhenComponent implements OnInit, OnChanges { if (credential) { this.enableRemoteExplorer(); - const targetCredentials = _.find(this.credentials, { id: credential }); - const targetProvider = _.find(this.providers, { name: targetCredentials?.provider }); + const targetCredentials = find(this.credentials, { id: credential }); + const targetProvider = find(this.providers, { name: targetCredentials?.provider }); if (targetProvider?.buckets) { if ( [ @@ -383,12 +383,12 @@ export class CloudSyncWhatAndWhenComponent implements OnInit, OnChanges { this.form.controls.bucket_policy_only.disable(); } - const schemaFound = _.find(this.providers, { name: targetCredentials?.provider }); + const schemaFound = find(this.providers, { name: targetCredentials?.provider }); const taskSchema = schemaFound ? schemaFound.task_schema : []; const taskSchemas = ['task_encryption', 'fast_list', 'chunk_size', 'storage_class']; for (const i of taskSchemas) { - const toBeDisable = !(_.findIndex(taskSchema, { property: i }) > -1); + const toBeDisable = !(findIndex(taskSchema, { property: i }) > -1); if (i === 'task_encryption' || i === 'fast_list' || i === 'chunk_size' || i === 'storage_class') { if (toBeDisable) { this.form.controls[i].disable(); @@ -422,7 +422,7 @@ export class CloudSyncWhatAndWhenComponent implements OnInit, OnChanges { } private loadBucketOptions(): void { - const credential = _.find(this.credentials, { id: this.form.controls.credentials.value }); + const credential = find(this.credentials, { id: this.form.controls.credentials.value }); this.cloudCredentialService.getBuckets(credential.id) .pipe(untilDestroyed(this)) diff --git a/src/app/pages/data-protection/replication/replication-form/sections/transport-section/transport-section.component.ts b/src/app/pages/data-protection/replication/replication-form/sections/transport-section/transport-section.component.ts index 0cc4f58e9c3..29ecbe9aec8 100644 --- a/src/app/pages/data-protection/replication/replication-form/sections/transport-section/transport-section.component.ts +++ b/src/app/pages/data-protection/replication/replication-form/sections/transport-section/transport-section.component.ts @@ -4,7 +4,7 @@ import { import { FormBuilder } from '@angular/forms'; import { UntilDestroy } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { isNull, omitBy } from 'lodash-es'; import { of } from 'rxjs'; import { CompressionType, compressionTypeNames } from 'app/enums/compression-type.enum'; import { NetcatMode, netcatModeNames } from 'app/enums/netcat-mode.enum'; @@ -108,13 +108,13 @@ export class TransportSectionComponent implements OnChanges { if (this.isSsh) { return { - ..._.omitBy({ + ...omitBy({ ssh_credentials: values.ssh_credentials, compression: values.compression === CompressionType.Disabled ? null : values.compression, speed_limit: values.speed_limit, large_block: values.large_block, compressed: values.compressed, - }, _.isNull), + }, isNull), netcat_active_side: null, netcat_active_side_listen_address: null, netcat_active_side_port_min: null, @@ -124,7 +124,7 @@ export class TransportSectionComponent implements OnChanges { } return { - ..._.omitBy({ + ...omitBy({ ssh_credentials: values.ssh_credentials, large_block: values.large_block, compressed: values.compressed, @@ -133,7 +133,7 @@ export class TransportSectionComponent implements OnChanges { netcat_active_side_port_min: values.netcat_active_side_port_min, netcat_active_side_port_max: values.netcat_active_side_port_max, netcat_passive_side_connect_address: values.netcat_passive_side_connect_address, - }, _.isNull), + }, isNull), speed_limit: null, }; } diff --git a/src/app/pages/data-protection/replication/replication-wizard/replication-wizard.component.ts b/src/app/pages/data-protection/replication/replication-wizard/replication-wizard.component.ts index fc440eae6fa..e7b7882c4e8 100644 --- a/src/app/pages/data-protection/replication/replication-wizard/replication-wizard.component.ts +++ b/src/app/pages/data-protection/replication/replication-wizard/replication-wizard.component.ts @@ -6,7 +6,7 @@ import { } from '@angular/core'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { merge } from 'lodash-es'; import { catchError, EMPTY, forkJoin, map, Observable, of, switchMap, tap, } from 'rxjs'; @@ -165,7 +165,7 @@ export class ReplicationWizardComponent { const steps = this.getSteps(); const values = steps.map((step) => step.getPayload()); - const payload = _.merge({}, ...values) as ReplicationWizardData; + const payload = merge({}, ...values) as ReplicationWizardData; payload.source_datasets = payload.source_datasets.map((item) => item.replace(`${mntPath}/`, '')); payload.target_dataset = payload.target_dataset.replace(`${mntPath}/`, ''); return payload; diff --git a/src/app/pages/datasets/components/dataset-form/sections/quotas-section/quotas-section.component.ts b/src/app/pages/datasets/components/dataset-form/sections/quotas-section/quotas-section.component.ts index 1dcf24597eb..1b785e16024 100644 --- a/src/app/pages/datasets/components/dataset-form/sections/quotas-section/quotas-section.component.ts +++ b/src/app/pages/datasets/components/dataset-form/sections/quotas-section/quotas-section.component.ts @@ -4,7 +4,7 @@ import { import { AbstractControl, FormBuilder, Validators } from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { pickBy } from 'lodash-es'; import { GiB } from 'app/constants/bytes.constant'; import { helptextDatasetForm } from 'app/helptext/storage/volumes/datasets/dataset-form'; import { Dataset, DatasetCreate } from 'app/interfaces/dataset.interface'; @@ -66,7 +66,7 @@ export class QuotasSectionComponent implements OnInit { getPayload(): Partial { const values = this.form.value; - const payload: Partial = _.pickBy(values, (value, key) => { + const payload: Partial = pickBy(values, (value, key) => { return [ 'refquota', 'refreservation', diff --git a/src/app/pages/datasets/components/dataset-node/dataset-roles-cell/dataset-roles-cell.component.ts b/src/app/pages/datasets/components/dataset-node/dataset-roles-cell/dataset-roles-cell.component.ts index dfc2b719608..63497f47234 100644 --- a/src/app/pages/datasets/components/dataset-node/dataset-roles-cell/dataset-roles-cell.component.ts +++ b/src/app/pages/datasets/components/dataset-node/dataset-roles-cell/dataset-roles-cell.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component, computed, input, } from '@angular/core'; -import * as _ from 'lodash-es'; +import { uniq } from 'lodash-es'; import { DatasetDetails } from 'app/interfaces/dataset.interface'; import { doesDatasetHaveShares, ixAppsDataset } from 'app/pages/datasets/utils/dataset.utils'; @@ -16,8 +16,8 @@ export class DatasetRolesCellComponent { readonly isSystemDataset = input.required(); readonly isApps = computed(() => this.dataset().name.endsWith(ixAppsDataset)); - readonly appNames = computed(() => _.uniq(this.dataset().apps.map((app) => app.name)).join(', ')); - readonly vmNames = computed(() => _.uniq(this.dataset().vms.map((vm) => vm.name)).join(', ')); + readonly appNames = computed(() => uniq(this.dataset().apps.map((app) => app.name)).join(', ')); + readonly vmNames = computed(() => uniq(this.dataset().vms.map((vm) => vm.name)).join(', ')); readonly hasShares = computed(() => doesDatasetHaveShares(this.dataset())); } diff --git a/src/app/pages/datasets/components/roles-card/roles-card.component.ts b/src/app/pages/datasets/components/roles-card/roles-card.component.ts index 6a4ebeb425d..a51306406d4 100644 --- a/src/app/pages/datasets/components/roles-card/roles-card.component.ts +++ b/src/app/pages/datasets/components/roles-card/roles-card.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, computed, input, } from '@angular/core'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import * as _ from 'lodash-es'; +import { uniq } from 'lodash-es'; import { filter } from 'rxjs'; import { Role } from 'app/enums/role.enum'; import { DatasetDetails } from 'app/interfaces/dataset.interface'; @@ -32,11 +32,11 @@ export class RolesCardComponent { }); readonly appNames = computed(() => { - return _.uniq(this.dataset().apps.map((app) => app.name)).join(', '); + return uniq(this.dataset().apps.map((app) => app.name)).join(', '); }); readonly vmNames = computed(() => { - return _.uniq(this.dataset().vms.map((app) => app.name)).join(', '); + return uniq(this.dataset().vms.map((app) => app.name)).join(', '); }); readonly isSystemDataset = computed(() => { diff --git a/src/app/pages/datasets/modules/permissions/components/edit-nfs-ace/edit-nfs-ace.component.ts b/src/app/pages/datasets/modules/permissions/components/edit-nfs-ace/edit-nfs-ace.component.ts index 9be5d348da5..41ae4228bc9 100644 --- a/src/app/pages/datasets/modules/permissions/components/edit-nfs-ace/edit-nfs-ace.component.ts +++ b/src/app/pages/datasets/modules/permissions/components/edit-nfs-ace/edit-nfs-ace.component.ts @@ -4,7 +4,7 @@ import { import { FormBuilder, Validators } from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { fromPairs } from 'lodash-es'; import { of } from 'rxjs'; import { NfsAclTag, nfsAclTagLabels, NfsAclType, @@ -152,7 +152,7 @@ export class EditNfsAceComponent implements OnChanges, OnInit { ace.perms = { BASIC: formValues.basicPermission } as BasicNfsPermissions; } } else if (Array.isArray(formValues.advancedPermissions)) { - ace.perms = _.fromPairs(formValues.advancedPermissions.map((key) => [key, true])) as AdvancedNfsPermissions; + ace.perms = fromPairs(formValues.advancedPermissions.map((key) => [key, true])) as AdvancedNfsPermissions; } if (formValues.flagsType === NfsFormFlagsType.Basic) { @@ -162,7 +162,7 @@ export class EditNfsAceComponent implements OnChanges, OnInit { ace.flags = { BASIC: formValues.basicFlag } as BasicNfsFlags; } } else if (Array.isArray(formValues.advancedFlags)) { - ace.flags = _.fromPairs(formValues.advancedFlags.map((key) => [key, true])) as AdvancedNfsFlags; + ace.flags = fromPairs(formValues.advancedFlags.map((key) => [key, true])) as AdvancedNfsFlags; } return ace; diff --git a/src/app/pages/datasets/modules/permissions/components/save-as-preset-modal/save-as-preset-modal.component.ts b/src/app/pages/datasets/modules/permissions/components/save-as-preset-modal/save-as-preset-modal.component.ts index 97e3a682e46..95391a18688 100644 --- a/src/app/pages/datasets/modules/permissions/components/save-as-preset-modal/save-as-preset-modal.component.ts +++ b/src/app/pages/datasets/modules/permissions/components/save-as-preset-modal/save-as-preset-modal.component.ts @@ -4,7 +4,7 @@ import { import { FormBuilder, Validators } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import * as _ from 'lodash-es'; +import { cloneDeep, concat } from 'lodash-es'; import { EMPTY, Observable, catchError, combineLatest, map, of, switchMap, tap, } from 'rxjs'; @@ -86,21 +86,21 @@ export class SaveAsPresetModalComponent implements OnInit { } private sortPresets(presets: AclTemplateByPath[]): AclTemplateByPath[] { - return _.concat( + return concat( presets.filter((preset) => this.isCurrentAclType(preset.acltype)).sort((a, b) => (a.name < b.name ? -1 : 1)), presets.filter((preset) => !this.isCurrentAclType(preset.acltype)).sort((a, b) => (a.name < b.name ? -1 : 1)), ); } onSubmit(): void { - this.loadIds(_.cloneDeep(this.acl)).pipe( + this.loadIds(cloneDeep(this.acl)).pipe( switchMap((newAcl) => { const payload: AclTemplateCreateParams = { name: this.form.value.presetName, acltype: this.acl.acltype, acl: newAcl.acl.map((acl) => { delete acl.who; - return _.cloneDeep(acl); + return cloneDeep(acl); }) as NfsAclItem[] | PosixAclItem[], }; @@ -157,7 +157,7 @@ export class SaveAsPresetModalComponent implements OnInit { const result$ = combineLatest(requests$).pipe( map(() => { - const newAcl = _.cloneDeep(acl); + const newAcl = cloneDeep(acl); const newAces = []; for (const ace of newAcl.acl) { if ([NfsAclTag.User, PosixAclTag.User].includes(ace.tag)) { diff --git a/src/app/pages/datasets/modules/permissions/stores/dataset-acl-editor.store.ts b/src/app/pages/datasets/modules/permissions/stores/dataset-acl-editor.store.ts index 7f11e868bc5..b5ffacfb29b 100644 --- a/src/app/pages/datasets/modules/permissions/stores/dataset-acl-editor.store.ts +++ b/src/app/pages/datasets/modules/permissions/stores/dataset-acl-editor.store.ts @@ -2,8 +2,7 @@ import { Injectable } from '@angular/core'; import { Router } from '@angular/router'; import { ComponentStore } from '@ngrx/component-store'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; -import { omit } from 'lodash-es'; +import { union, without, omit } from 'lodash-es'; import { EMPTY, forkJoin, Observable, of, } from 'rxjs'; @@ -96,7 +95,7 @@ export class DatasetAclEditorStore extends ComponentStore selectedAceIndex = Math.max(0, selectedAceIndex - 1); } - const newAcesWithError = _.without(state.acesWithError, indexToRemove).map((aceWithErrorIndex) => { + const newAcesWithError = without(state.acesWithError, indexToRemove).map((aceWithErrorIndex) => { if (aceWithErrorIndex <= indexToRemove) { return aceWithErrorIndex; } @@ -165,8 +164,8 @@ export class DatasetAclEditorStore extends ComponentStore return { ...state, acesWithError: isValid - ? _.without(state.acesWithError, state.selectedAceIndex) - : _.union(state.acesWithError, [state.selectedAceIndex]), + ? without(state.acesWithError, state.selectedAceIndex) + : union(state.acesWithError, [state.selectedAceIndex]), }; }); @@ -270,7 +269,7 @@ export class DatasetAclEditorStore extends ComponentStore const markAceAsHavingErrors = (aceIndex: number): void => { this.patchState((state) => ({ ...state, - acesWithError: _.union(state.acesWithError, [aceIndex]), + acesWithError: union(state.acesWithError, [aceIndex]), })); }; diff --git a/src/app/pages/datasets/modules/snapshots/snapshot-details-row/snapshot-details-row.component.ts b/src/app/pages/datasets/modules/snapshots/snapshot-details-row/snapshot-details-row.component.ts index 0f9f4745fb1..a8d461d1040 100644 --- a/src/app/pages/datasets/modules/snapshots/snapshot-details-row/snapshot-details-row.component.ts +++ b/src/app/pages/datasets/modules/snapshots/snapshot-details-row/snapshot-details-row.component.ts @@ -5,7 +5,7 @@ import { FormControl } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { isEmpty } from 'lodash-es'; import { filter, switchMap, tap, map, } from 'rxjs/operators'; @@ -81,7 +81,7 @@ export class SnapshotDetailsRowComponent implements OnInit, OnDestroy { .subscribe({ next: (snapshot) => { this.snapshotInfo = snapshot; - this.holdControl.setValue(!_.isEmpty(snapshot.holds), { emitEvent: false }); + this.holdControl.setValue(!isEmpty(snapshot.holds), { emitEvent: false }); this.isLoading = false; this.cdr.markForCheck(); }, diff --git a/src/app/pages/network/components/interfaces-card/ip-addresses-cell/ip-addresses-cell.component.ts b/src/app/pages/network/components/interfaces-card/ip-addresses-cell/ip-addresses-cell.component.ts index c47ab1ebfaf..6da6753f70c 100644 --- a/src/app/pages/network/components/interfaces-card/ip-addresses-cell/ip-addresses-cell.component.ts +++ b/src/app/pages/network/components/interfaces-card/ip-addresses-cell/ip-addresses-cell.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, inject, } from '@angular/core'; -import * as _ from 'lodash-es'; +import { uniq } from 'lodash-es'; import { NetworkInterfaceAliasType } from 'app/enums/network-interface.enum'; import { NetworkInterface, NetworkInterfaceAlias } from 'app/interfaces/network-interface.interface'; import { Column, ColumnComponent } from 'app/modules/ix-table/interfaces/column-component.class'; @@ -39,7 +39,7 @@ export class IpAddressesCellComponent extends ColumnComponent { addresses.push(...virtualAddresses); } - return _.uniq(addresses); + return uniq(addresses); } private aliasesToAddress(aliases: NetworkInterfaceAlias[]): string[] { diff --git a/src/app/pages/reports-dashboard/components/report/report.component.ts b/src/app/pages/reports-dashboard/components/report/report.component.ts index d791d1a95a2..ce6c8c880f8 100644 --- a/src/app/pages/reports-dashboard/components/report/report.component.ts +++ b/src/app/pages/reports-dashboard/components/report/report.component.ts @@ -13,7 +13,7 @@ import { UUID } from 'angular2-uuid'; import { add, isToday, sub, } from 'date-fns'; -import * as _ from 'lodash-es'; +import { cloneDeep } from 'lodash-es'; import { BehaviorSubject, Subscription, timer, } from 'rxjs'; @@ -461,7 +461,7 @@ export class ReportComponent implements OnInit, OnChanges { untilDestroyed(this), ).subscribe({ next: (event) => { - this.data = formatData(_.cloneDeep(event)); + this.data = formatData(cloneDeep(event)); this.cdr.markForCheck(); }, error: (err: WebSocketError) => { diff --git a/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.ts b/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.ts index e187c7f0370..731e35eb323 100644 --- a/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.ts +++ b/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.ts @@ -5,7 +5,7 @@ import { Validators } from '@angular/forms'; import { FormBuilder } from '@ngneat/reactive-forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { sortBy, startsWith } from 'lodash-es'; import { BehaviorSubject, combineLatest, Observable, of, } from 'rxjs'; @@ -42,7 +42,7 @@ export class ExtentFormComponent implements OnInit { } get isAvailableThreshold(): boolean { - return _.startsWith(this.form.controls.disk.value, 'zvol'); + return startsWith(this.form.controls.disk.value, 'zvol'); } get title(): string { @@ -94,7 +94,7 @@ export class ExtentFormComponent implements OnInit { options.push(extentDiskBeingEdited); } - return _.sortBy(options, ['label']); + return sortBy(options, ['label']); }), ); readonly treeNodeProvider = this.filesystemService.getFilesystemNodeProvider(); @@ -177,7 +177,7 @@ export class ExtentFormComponent implements OnInit { } private setExtentDisk(): void { - if (!_.startsWith(this.editingExtent.path, 'zvol')) { + if (!startsWith(this.editingExtent.path, 'zvol')) { return; } diff --git a/src/app/pages/sharing/iscsi/initiator/initiator-form/initiator-form.component.ts b/src/app/pages/sharing/iscsi/initiator/initiator-form/initiator-form.component.ts index 6db64982c91..9a8b04da7f9 100644 --- a/src/app/pages/sharing/iscsi/initiator/initiator-form/initiator-form.component.ts +++ b/src/app/pages/sharing/iscsi/initiator/initiator-form/initiator-form.component.ts @@ -4,7 +4,7 @@ import { import { ActivatedRoute, Router } from '@angular/router'; import { FormBuilder } from '@ngneat/reactive-forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import * as _ from 'lodash-es'; +import { unionBy } from 'lodash-es'; import { Role } from 'app/enums/role.enum'; import { helptextSharingIscsi } from 'app/helptext/sharing'; import { IscsiGlobalSession } from 'app/interfaces/iscsi-global-config.interface'; @@ -118,7 +118,7 @@ export class InitiatorFormComponent implements OnInit { getConnectedInitiators(): void { this.ws.call('iscsi.global.sessions').pipe(untilDestroyed(this)).subscribe({ next: (sessions) => { - this.connectedInitiators = _.unionBy(sessions, (item) => item.initiator && item.initiator_addr); + this.connectedInitiators = unionBy(sessions, (item) => item.initiator && item.initiator_addr); this.cdr.markForCheck(); }, error: (error: unknown) => { diff --git a/src/app/pages/sharing/iscsi/target/target-form/target-form.component.ts b/src/app/pages/sharing/iscsi/target/target-form/target-form.component.ts index abf4b728144..a77024fff2b 100644 --- a/src/app/pages/sharing/iscsi/target/target-form/target-form.component.ts +++ b/src/app/pages/sharing/iscsi/target/target-form/target-form.component.ts @@ -5,7 +5,7 @@ import { Validators } from '@angular/forms'; import { FormBuilder } from '@ngneat/reactive-forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { uniq } from 'lodash-es'; import { Observable, of } from 'rxjs'; import { map } from 'rxjs/operators'; import { IscsiAuthMethod, IscsiTargetMode } from 'app/enums/iscsi.enum'; @@ -70,7 +70,7 @@ export class TargetFormComponent implements OnInit { readonly auths$ = this.iscsiService.getAuth().pipe( map((auths) => { const opts: Option[] = []; - const tags = _.uniq(auths.map((item) => item.tag)); + const tags = uniq(auths.map((item) => item.tag)); tags.forEach((tag) => { opts.push({ label: String(tag), value: tag }); }); diff --git a/src/app/pages/sharing/smb/smb-acl/smb-acl.component.ts b/src/app/pages/sharing/smb/smb-acl/smb-acl.component.ts index b2ec88b2856..c90b78e6479 100644 --- a/src/app/pages/sharing/smb/smb-acl/smb-acl.component.ts +++ b/src/app/pages/sharing/smb/smb-acl/smb-acl.component.ts @@ -4,7 +4,7 @@ import { import { FormBuilder } from '@ngneat/reactive-forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { isNumber } from 'lodash-es'; import { concatMap, firstValueFrom, forkJoin, mergeMap, Observable, of, from, } from 'rxjs'; @@ -191,7 +191,7 @@ export class SmbAclComponent implements OnInit { result.ae_who_sid = 'S-1-1-0'; } else { let id: number; - if (_.isNumber(whoIdOrName)) { + if (isNumber(whoIdOrName)) { id = Number(whoIdOrName); } else if (ace.ae_who === NfsAclTag.UserGroup) { id = (await firstValueFrom(this.userService.getGroupByName(whoIdOrName.toString()))) diff --git a/src/app/pages/sharing/smb/smb-form/smb-form.component.ts b/src/app/pages/sharing/smb/smb-form/smb-form.component.ts index d6e543b6d3e..1a149c4db94 100644 --- a/src/app/pages/sharing/smb/smb-form/smb-form.component.ts +++ b/src/app/pages/sharing/smb/smb-form/smb-form.component.ts @@ -12,7 +12,7 @@ import { Router } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { Store } from '@ngrx/store'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { isEqual } from 'lodash-es'; import { noop, Observable, of } from 'rxjs'; import { debounceTime, @@ -112,8 +112,8 @@ export class SmbFormComponent implements OnInit, AfterViewInit { hasHostAllowDenyChanged(hostsallow: string[], hostsdeny: string[]): boolean { return ( - !_.isEqual(this.existingSmbShare?.hostsallow, hostsallow) - || !_.isEqual(this.existingSmbShare?.hostsdeny, hostsdeny) + !isEqual(this.existingSmbShare?.hostsallow, hostsallow) + || !isEqual(this.existingSmbShare?.hostsdeny, hostsdeny) ); } diff --git a/src/app/pages/signin/signin-form/signin-form.component.ts b/src/app/pages/signin/signin-form/signin-form.component.ts index 3828870affa..bfdc0cfa047 100644 --- a/src/app/pages/signin/signin-form/signin-form.component.ts +++ b/src/app/pages/signin/signin-form/signin-form.component.ts @@ -9,7 +9,7 @@ import { import { MatButton } from '@angular/material/button'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService, TranslateModule } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { isEqual } from 'lodash-es'; import { distinctUntilChanged, EMPTY, firstValueFrom, switchMap, } from 'rxjs'; @@ -99,7 +99,7 @@ export class SigninFormComponent implements OnInit { ngOnInit(): void { this.form.valueChanges.pipe( - distinctUntilChanged(_.isEqual), + distinctUntilChanged(isEqual), untilDestroyed(this), ).subscribe({ next: () => { diff --git a/src/app/pages/storage/components/dashboard-pool/export-disconnect-modal/export-disconnect-modal.component.ts b/src/app/pages/storage/components/dashboard-pool/export-disconnect-modal/export-disconnect-modal.component.ts index 0021adcfd7d..ffcb8fb4f7e 100644 --- a/src/app/pages/storage/components/dashboard-pool/export-disconnect-modal/export-disconnect-modal.component.ts +++ b/src/app/pages/storage/components/dashboard-pool/export-disconnect-modal/export-disconnect-modal.component.ts @@ -5,7 +5,7 @@ import { AbstractControl, FormBuilder, Validators } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { isObject } from 'lodash-es'; import { forkJoin } from 'rxjs'; import { filter } from 'rxjs/operators'; import { PoolStatus } from 'app/enums/pool-status.enum'; @@ -158,7 +158,7 @@ export class ExportDisconnectModalComponent implements OnInit { handleDisconnectJobFailure(failureData: Job): void { if (failureData.error) { if ( - _.isObject(failureData.exc_info.extra) + isObject(failureData.exc_info.extra) && !Array.isArray(failureData.exc_info.extra) && failureData.exc_info.extra.code === 'control_services' ) { @@ -185,7 +185,7 @@ export class ExportDisconnectModalComponent implements OnInit { const stopMsg = this.translate.instant(helptextVolumes.exportMessages.onfail.stopServices); const restartMsg = this.translate.instant(helptextVolumes.exportMessages.onfail.restartServices); let conditionalErrMessage = ''; - if (_.isObject(failureData.exc_info.extra) && !Array.isArray(failureData.exc_info.extra)) { + if (isObject(failureData.exc_info.extra) && !Array.isArray(failureData.exc_info.extra)) { if ((failureData.exc_info.extra.stop_services as string[]).length > 0) { conditionalErrMessage += '
' + stopMsg; (failureData.exc_info.extra.stop_services as string[]).forEach((item) => { diff --git a/src/app/pages/storage/components/unused-resources/unused-disk-card/manage-unused-disk-dialog/manage-unused-disk-dialog.component.ts b/src/app/pages/storage/components/unused-resources/unused-disk-card/manage-unused-disk-dialog/manage-unused-disk-dialog.component.ts index 1d643f81a2c..44ff3384c1c 100644 --- a/src/app/pages/storage/components/unused-resources/unused-disk-card/manage-unused-disk-dialog/manage-unused-disk-dialog.component.ts +++ b/src/app/pages/storage/components/unused-resources/unused-disk-card/manage-unused-disk-dialog/manage-unused-disk-dialog.component.ts @@ -6,7 +6,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { Router } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { groupBy } from 'lodash-es'; import { Observable, of } from 'rxjs'; import { PoolStatus } from 'app/enums/pool-status.enum'; import { Role } from 'app/enums/role.enum'; @@ -74,7 +74,7 @@ export class ManageUnusedDiskDialogComponent implements OnInit { exportedPool: disk.exported_zpool, }; }); - const groupDisks = _.groupBy(diskInfoFormats, (diskDetailsWithPoolName) => { + const groupDisks = groupBy(diskInfoFormats, (diskDetailsWithPoolName) => { return diskDetailsWithPoolName.detailedDisk + diskDetailsWithPoolName.exportedPool; }); return Object.keys(groupDisks).map((format: string) => { @@ -94,7 +94,7 @@ export class ManageUnusedDiskDialogComponent implements OnInit { exportedPool: disk.exported_zpool, }; }); - const groupDisks = _.groupBy(diskInfoFormats, (diskDetailsWithPoolName) => { + const groupDisks = groupBy(diskInfoFormats, (diskDetailsWithPoolName) => { return diskDetailsWithPoolName.detailedDisk + diskDetailsWithPoolName.exportedPool; }); return Object.keys(groupDisks).map((format: string) => { diff --git a/src/app/pages/storage/modules/devices/components/smart-info-card/smart-info-card.component.ts b/src/app/pages/storage/modules/devices/components/smart-info-card/smart-info-card.component.ts index 7dd58f54c3a..8c5b313be19 100644 --- a/src/app/pages/storage/modules/devices/components/smart-info-card/smart-info-card.component.ts +++ b/src/app/pages/storage/modules/devices/components/smart-info-card/smart-info-card.component.ts @@ -5,7 +5,7 @@ import { MatDialog } from '@angular/material/dialog'; import { marker as T } from '@biesbjerg/ngx-translate-extract-marker'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { uniqBy } from 'lodash-es'; import { Observable, } from 'rxjs'; @@ -93,7 +93,7 @@ export class SmartInfoCardComponent implements OnChanges { ...result, description: this.normalizeDescription(result.description), })); - const lastResultsInCategories = _.uniqBy(normalizedResults, (result) => result.description); + const lastResultsInCategories = uniqBy(normalizedResults, (result) => result.description); return lastResultsInCategories.slice(0, this.maxResultCategories); }), ); diff --git a/src/app/pages/storage/modules/devices/stores/devices-store.service.ts b/src/app/pages/storage/modules/devices/stores/devices-store.service.ts index 56328e24b6f..7b816eed032 100644 --- a/src/app/pages/storage/modules/devices/stores/devices-store.service.ts +++ b/src/app/pages/storage/modules/devices/stores/devices-store.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { ComponentStore } from '@ngrx/component-store'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { keyBy } from 'lodash-es'; import { EMPTY, Observable, of } from 'rxjs'; import { catchError, switchMap, tap } from 'rxjs/operators'; import { VdevType } from 'app/enums/v-dev-type.enum'; @@ -88,7 +88,7 @@ export class DevicesStore extends ComponentStore { this.patchState({ isLoading: false, error: null, - diskDictionary: _.keyBy(disks, (disk) => disk.devname), + diskDictionary: keyBy(disks, (disk) => disk.devname), nodes: this.createDataNodes(pools[0].topology), }); }), diff --git a/src/app/pages/storage/modules/pool-manager/components/add-vdevs/store/add-vdevs-store.service.ts b/src/app/pages/storage/modules/pool-manager/components/add-vdevs/store/add-vdevs-store.service.ts index e76ba19098c..17056939398 100644 --- a/src/app/pages/storage/modules/pool-manager/components/add-vdevs/store/add-vdevs-store.service.ts +++ b/src/app/pages/storage/modules/pool-manager/components/add-vdevs/store/add-vdevs-store.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { ComponentStore } from '@ngrx/component-store'; import { tapResponse } from '@ngrx/operators'; -import * as _ from 'lodash-es'; +import { cloneDeep } from 'lodash-es'; import { combineLatest, filter, switchMap, tap, } from 'rxjs'; @@ -65,7 +65,7 @@ export class AddVdevsStore extends ComponentStore { tapResponse( (pools) => { this.patchState({ - pool: _.cloneDeep(pools[0]), + pool: cloneDeep(pools[0]), isLoading: false, }); }, diff --git a/src/app/pages/storage/modules/pool-manager/components/existing-configuration-preview/existing-configuration-preview.component.ts b/src/app/pages/storage/modules/pool-manager/components/existing-configuration-preview/existing-configuration-preview.component.ts index 7563dcc5275..4feeec3b063 100644 --- a/src/app/pages/storage/modules/pool-manager/components/existing-configuration-preview/existing-configuration-preview.component.ts +++ b/src/app/pages/storage/modules/pool-manager/components/existing-configuration-preview/existing-configuration-preview.component.ts @@ -3,7 +3,7 @@ import { } from '@angular/core'; import { UntilDestroy } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { cloneDeep } from 'lodash-es'; import { CreateVdevLayout, TopologyItemType, VdevType, vdevTypeLabels, } from 'app/enums/v-dev-type.enum'; @@ -62,12 +62,12 @@ export class ExistingConfigurationPreviewComponent implements OnChanges { parseTopology(topology: PoolTopology): PoolManagerTopology { const poolManagerTopology: PoolManagerTopology = { - data: _.cloneDeep(defaultCategory), - log: _.cloneDeep(defaultCategory), - spare: _.cloneDeep(defaultCategory), - cache: _.cloneDeep(defaultCategory), - dedup: _.cloneDeep(defaultCategory), - special: _.cloneDeep(defaultCategory), + data: cloneDeep(defaultCategory), + log: cloneDeep(defaultCategory), + spare: cloneDeep(defaultCategory), + cache: cloneDeep(defaultCategory), + dedup: cloneDeep(defaultCategory), + special: cloneDeep(defaultCategory), }; let vdevTypes = Object.entries(VdevType); @@ -97,19 +97,19 @@ export class ExistingConfigurationPreviewComponent implements OnChanges { if (firstVdevType === TopologyItemType.Stripe) { const vdevDisk = this.disks.find((disk) => disk.devname === vdev.disk); - allCategoryVdevsDisks.push(_.cloneDeep(vdevDisk)); - poolManagerTopology[value].vdevs.push([_.cloneDeep(vdevDisk)]); + allCategoryVdevsDisks.push(cloneDeep(vdevDisk)); + poolManagerTopology[value].vdevs.push([cloneDeep(vdevDisk)]); } else { const vdevDisks = []; for (const vdevDisk of vdev.children) { const fullDisk = this.disks.find((disk) => disk.devname === vdevDisk.disk); - allCategoryVdevsDisks.push(_.cloneDeep(fullDisk)); - vdevDisks.push(_.cloneDeep(fullDisk)); + allCategoryVdevsDisks.push(cloneDeep(fullDisk)); + vdevDisks.push(cloneDeep(fullDisk)); } poolManagerTopology[value].vdevs.push(vdevDisks); } } - const firstDisk = _.cloneDeep(allCategoryVdevsDisks[0]); + const firstDisk = cloneDeep(allCategoryVdevsDisks[0]); poolManagerTopology[value].hasCustomDiskSelection = poolManagerTopology[value].hasCustomDiskSelection || allCategoryVdevsDisks.some((disk) => disk.size !== firstDisk.size || disk.type !== firstDisk.type); if (!poolManagerTopology[value].hasCustomDiskSelection) { diff --git a/src/app/pages/storage/modules/pool-manager/components/manual-disk-selection/components/manual-selection-disks/manual-selection-disk-filters/manual-selection-disk-filters.component.ts b/src/app/pages/storage/modules/pool-manager/components/manual-disk-selection/components/manual-selection-disks/manual-selection-disk-filters/manual-selection-disk-filters.component.ts index 95c646edcff..1035162545c 100644 --- a/src/app/pages/storage/modules/pool-manager/components/manual-disk-selection/components/manual-selection-disks/manual-selection-disk-filters/manual-selection-disk-filters.component.ts +++ b/src/app/pages/storage/modules/pool-manager/components/manual-disk-selection/components/manual-selection-disks/manual-selection-disk-filters/manual-selection-disk-filters.component.ts @@ -3,7 +3,7 @@ import { } from '@angular/core'; import { FormBuilder } from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import * as _ from 'lodash-es'; +import { uniq } from 'lodash-es'; import { map } from 'rxjs/operators'; import { DiskType } from 'app/enums/disk-type.enum'; import { buildNormalizedFileSize } from 'app/helpers/file-size.utils'; @@ -39,7 +39,7 @@ export class ManualSelectionDiskFiltersComponent implements OnInit { map((disks) => { const diskSizes = disks.sort((a, b) => a.size - b.size).map((disk) => disk.size); const sizeLabels = diskSizes.map((size) => buildNormalizedFileSize(size)); - const uniqueLabels = _.uniq(sizeLabels); + const uniqueLabels = uniq(sizeLabels); return uniqueLabels.map((size: string) => ({ label: size, value: size })); }), ); diff --git a/src/app/pages/storage/modules/pool-manager/components/manual-disk-selection/store/manual-disk-selection.store.ts b/src/app/pages/storage/modules/pool-manager/components/manual-disk-selection/store/manual-disk-selection.store.ts index b26104dae2a..34b3f7cace0 100644 --- a/src/app/pages/storage/modules/pool-manager/components/manual-disk-selection/store/manual-disk-selection.store.ts +++ b/src/app/pages/storage/modules/pool-manager/components/manual-disk-selection/store/manual-disk-selection.store.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { ComponentStore } from '@ngrx/component-store'; import { UUID } from 'angular2-uuid'; -import * as _ from 'lodash-es'; +import { cloneDeep } from 'lodash-es'; import { CreateVdevLayout } from 'app/enums/v-dev-type.enum'; import { DetailsDisk } from 'app/interfaces/disk.interface'; import { @@ -42,25 +42,25 @@ export class ManualDiskSelectionStore extends ComponentStore { - let vdevs = _.cloneDeep(state.vdevs); + let vdevs = cloneDeep(state.vdevs); if (!vdevs.length) { - vdevs = [_.cloneDeep(vdevUpdate.vdev)]; + vdevs = [cloneDeep(vdevUpdate.vdev)]; } for (const vdev of vdevs) { const diskAlreadyExists = vdev.disks.some( (vdevDisk) => vdevDisk.identifier === vdevUpdate.disk.identifier, ); if (vdev.uuid === vdevUpdate.vdev.uuid && !diskAlreadyExists) { - const newDisk = _.cloneDeep(vdevUpdate.disk) as ManualSelectionDisk; + const newDisk = cloneDeep(vdevUpdate.disk) as ManualSelectionDisk; newDisk.vdevUuid = vdev.uuid; vdev.disks.push(newDisk); } } - const inventory = _.cloneDeep(state.inventory).filter( + const inventory = cloneDeep(state.inventory).filter( (unusedDisk) => unusedDisk.identifier !== vdevUpdate.disk.identifier, ); return { - ...(_.cloneDeep(state)), + ...(cloneDeep(state)), vdevs, inventory, }; @@ -70,12 +70,12 @@ export class ManualDiskSelectionStore extends ComponentStore { - const vdevs = _.cloneDeep(state.vdevs).map((vdev) => { + const vdevs = cloneDeep(state.vdevs).map((vdev) => { if (vdev.uuid !== disk.vdevUuid) { return vdev; } - const newVdev = _.cloneDeep(vdev); + const newVdev = cloneDeep(vdev); newVdev.disks = newVdev.disks.filter((vdevDisk) => { return vdevDisk.identifier !== disk.identifier; }); @@ -83,22 +83,22 @@ export class ManualDiskSelectionStore extends ComponentStore unusedDisk.identifier === disk.identifier); if (!isDiskAlreadyInInventory) { - const newDisk = _.cloneDeep(disk); + const newDisk = cloneDeep(disk); newDisk.vdevUuid = null; inventory.push(newDisk); } return { - ...(_.cloneDeep(state)), + ...(cloneDeep(state)), vdevs, inventory, }; }); addVdev = this.updater((state: ManualDiskSelectionState) => { - const newState = _.cloneDeep(state); + const newState = cloneDeep(state); return { ...newState, vdevs: [ @@ -113,18 +113,18 @@ export class ManualDiskSelectionStore extends ComponentStore { - const vdevs = _.cloneDeep(state.vdevs).filter((vdev) => vdev.uuid !== vdevToRemove.uuid); - const inventory = _.cloneDeep(state.inventory); + const vdevs = cloneDeep(state.vdevs).filter((vdev) => vdev.uuid !== vdevToRemove.uuid); + const inventory = cloneDeep(state.inventory); for (const disk of vdevToRemove.disks) { const isDiskAlreadyInInventory = inventory.some((unusedDisk) => unusedDisk.identifier === disk.identifier); if (!isDiskAlreadyInInventory) { - const newDisk = _.cloneDeep(disk); + const newDisk = cloneDeep(disk); newDisk.vdevUuid = null; inventory.push(newDisk); } } return { - ...(_.cloneDeep(state)), + ...(cloneDeep(state)), vdevs, inventory, }; diff --git a/src/app/pages/storage/modules/pool-manager/components/manual-disk-selection/utils/vdevs-to-manual-selection-vdevs.utils.ts b/src/app/pages/storage/modules/pool-manager/components/manual-disk-selection/utils/vdevs-to-manual-selection-vdevs.utils.ts index b2490d72469..042b358f3dc 100644 --- a/src/app/pages/storage/modules/pool-manager/components/manual-disk-selection/utils/vdevs-to-manual-selection-vdevs.utils.ts +++ b/src/app/pages/storage/modules/pool-manager/components/manual-disk-selection/utils/vdevs-to-manual-selection-vdevs.utils.ts @@ -1,5 +1,5 @@ import { UUID } from 'angular2-uuid'; -import * as _ from 'lodash-es'; +import { omit } from 'lodash-es'; import { DetailsDisk } from 'app/interfaces/disk.interface'; import { ManualSelectionVdev, @@ -24,7 +24,7 @@ export function vdevsToManualSelectionVdevs(vdevs: DetailsDisk[][]): ManualSelec export function manualSelectionVdevsToVdevs(vdevs: ManualSelectionVdev[]): DetailsDisk[][] { return vdevs.map((vdev) => { return vdev.disks.map((disk) => { - return _.omit(disk, ['vdevUuid', 'real_capacity']) as DetailsDisk; + return omit(disk, ['vdevUuid', 'real_capacity']) as DetailsDisk; }); }); } diff --git a/src/app/pages/storage/modules/pool-manager/components/pool-manager-wizard/components/layout-step/automated-disk-selection/draid-selection/draid-selection.component.ts b/src/app/pages/storage/modules/pool-manager/components/pool-manager-wizard/components/layout-step/automated-disk-selection/draid-selection/draid-selection.component.ts index 6f9b46bc386..e16e99d3c68 100644 --- a/src/app/pages/storage/modules/pool-manager/components/pool-manager-wizard/components/layout-step/automated-disk-selection/draid-selection/draid-selection.component.ts +++ b/src/app/pages/storage/modules/pool-manager/components/pool-manager-wizard/components/layout-step/automated-disk-selection/draid-selection/draid-selection.component.ts @@ -3,7 +3,7 @@ import { } from '@angular/core'; import { FormBuilder } from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import * as _ from 'lodash-es'; +import { range } from 'lodash-es'; import { merge, of } from 'rxjs'; import { filter } from 'rxjs/operators'; import { CreateVdevLayout, VdevType } from 'app/enums/v-dev-type.enum'; @@ -193,7 +193,7 @@ export class DraidSelectionComponent implements OnInit, OnChanges { let nextOptions: Option[] = []; if ((groupSize + hotSpares) <= maxPossibleWidth && dataDevices) { - nextOptions = _.range(groupSize + hotSpares, maxPossibleWidth).map((item) => { + nextOptions = range(groupSize + hotSpares, maxPossibleWidth).map((item) => { const disks = item + 1; return { label: String(disks), diff --git a/src/app/pages/storage/modules/pool-manager/components/pool-manager-wizard/components/pool-warnings/pool-warnings.component.ts b/src/app/pages/storage/modules/pool-manager/components/pool-manager-wizard/components/pool-warnings/pool-warnings.component.ts index 617c24a482d..b6f16a79d90 100644 --- a/src/app/pages/storage/modules/pool-manager/components/pool-manager-wizard/components/pool-warnings/pool-warnings.component.ts +++ b/src/app/pages/storage/modules/pool-manager/components/pool-manager-wizard/components/pool-warnings/pool-warnings.component.ts @@ -5,7 +5,7 @@ import { FormBuilder } from '@angular/forms'; import { MatCheckboxChange } from '@angular/material/checkbox'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { uniq } from 'lodash-es'; import { of, Observable, combineLatest, startWith, } from 'rxjs'; @@ -85,7 +85,7 @@ export class PoolWarningsComponent implements OnInit { private setExportedPoolOptions(): void { const exportedPools = this.disksWithExportedPools.map((disk) => disk.exported_zpool); - const options = _.uniq(exportedPools).map((pool) => { + const options = uniq(exportedPools).map((pool) => { this.poolAndDisks.set(pool, this.getDiskNamesByPool(pool)); return { label: pool, value: pool }; }); diff --git a/src/app/pages/storage/modules/pool-manager/store/pool-manager-validation.service.ts b/src/app/pages/storage/modules/pool-manager/store/pool-manager-validation.service.ts index 0bd634f337d..f9e3cb15a99 100644 --- a/src/app/pages/storage/modules/pool-manager/store/pool-manager-validation.service.ts +++ b/src/app/pages/storage/modules/pool-manager/store/pool-manager-validation.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { ValidationErrors } from '@angular/forms'; import { Store } from '@ngrx/store'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { uniqBy } from 'lodash-es'; import { combineLatest, map, Observable } from 'rxjs'; import { CreateVdevLayout, VdevType } from 'app/enums/v-dev-type.enum'; import { helptextManager } from 'app/helptext/storage/volumes/manager/manager'; @@ -62,7 +62,7 @@ export class PoolManagerValidationService { errors.push(...this.validateNewPoolVdevs(topology)); } - return _.uniqBy(errors, 'text') + return uniqBy(errors, 'text') .sort((a, b) => { const warningSeverity = PoolCreationSeverity.Warning; // eslint-disable-next-line no-nested-ternary diff --git a/src/app/pages/storage/modules/pool-manager/store/pool-manager.store.ts b/src/app/pages/storage/modules/pool-manager/store/pool-manager.store.ts index 4bf64f81217..73ad373e5a3 100644 --- a/src/app/pages/storage/modules/pool-manager/store/pool-manager.store.ts +++ b/src/app/pages/storage/modules/pool-manager/store/pool-manager.store.ts @@ -5,7 +5,7 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { ComponentStore } from '@ngrx/component-store'; import { tapResponse } from '@ngrx/operators'; import { Store } from '@ngrx/store'; -import * as _ from 'lodash-es'; +import { differenceBy, isEqual, without } from 'lodash-es'; import { combineLatest, forkJoin, Observable, of, Subject, @@ -205,7 +205,7 @@ export class PoolManagerStore extends ComponentStore { this.topology$, (allowedDisks, topology) => { const usedDisks = topologyToDisks(topology); - return _.differenceBy(allowedDisks, usedDisks, (disk) => disk.devname); + return differenceBy(allowedDisks, usedDisks, (disk) => disk.devname); }, ); @@ -221,7 +221,7 @@ export class PoolManagerStore extends ComponentStore { } return topologyCategoryToDisks(category); }); - return _.differenceBy(allowedDisks, disksUsedInOtherCategories, (disk) => disk.devname); + return differenceBy(allowedDisks, disksUsedInOtherCategories, (disk) => disk.devname); }, ); } @@ -368,9 +368,9 @@ export class PoolManagerStore extends ComponentStore { this.patchState((state) => { const topology = state.topology[type]; const wasCategoryChanged = !Object.entries(update) - .every(([key, value]) => _.isEqual(topology[key as keyof typeof topology], value)); + .every(([key, value]) => isEqual(topology[key as keyof typeof topology], value)); const categorySequence = wasCategoryChanged - ? _.without(state.categorySequence, type).concat([type]) + ? without(state.categorySequence, type).concat([type]) : state.categorySequence; return { @@ -429,7 +429,7 @@ export class PoolManagerStore extends ComponentStore { ])), switchMap(([state, inventoryForStep]: [PoolManagerState, DetailsDisk[]]) => { const usedDisks = topologyCategoryToDisks(state.topology[type]); - const inventory = _.differenceBy(inventoryForStep, usedDisks, (disk: DetailsDisk) => disk.devname); + const inventory = differenceBy(inventoryForStep, usedDisks, (disk: DetailsDisk) => disk.devname); const isVdevsLimitedToOne = type === VdevType.Spare || type === VdevType.Cache || type === VdevType.Log; return this.matDialog.open(ManualDiskSelectionComponent, { data: { diff --git a/src/app/pages/storage/modules/pool-manager/utils/form.utils.ts b/src/app/pages/storage/modules/pool-manager/utils/form.utils.ts index e30d3a03dac..8c8d3c53e46 100644 --- a/src/app/pages/storage/modules/pool-manager/utils/form.utils.ts +++ b/src/app/pages/storage/modules/pool-manager/utils/form.utils.ts @@ -1,5 +1,5 @@ import { FormControl } from '@angular/forms'; -import * as _ from 'lodash-es'; +import { isEqual } from 'lodash-es'; import { Option } from 'app/interfaces/option.interface'; import { IxSimpleChanges } from 'app/interfaces/simple-changes.interface'; @@ -30,5 +30,5 @@ export function hasDeepChanges( key: keyof T, ): boolean { return changes[key]?.currentValue - && !_.isEqual(changes[key].currentValue, changes[key].previousValue); + && !isEqual(changes[key].currentValue, changes[key].previousValue); } diff --git a/src/app/pages/storage/modules/pool-manager/utils/generate-vdevs/test-utils.ts b/src/app/pages/storage/modules/pool-manager/utils/generate-vdevs/test-utils.ts index ff7702276b8..70699bfc2d6 100644 --- a/src/app/pages/storage/modules/pool-manager/utils/generate-vdevs/test-utils.ts +++ b/src/app/pages/storage/modules/pool-manager/utils/generate-vdevs/test-utils.ts @@ -1,4 +1,4 @@ -import * as _ from 'lodash-es'; +import { shuffle } from 'lodash-es'; import { GiB } from 'app/constants/bytes.constant'; import { DiskType } from 'app/enums/disk-type.enum'; import { VdevType } from 'app/enums/v-dev-type.enum'; @@ -16,7 +16,7 @@ function makeDisk(enclosure: string, slot: number): DetailsDisk { } as DetailsDisk; } -export const generateVdevDisks = _.shuffle([ +export const generateVdevDisks = shuffle([ makeDisk('1', 1), makeDisk('1', 2), makeDisk('1', 3), diff --git a/src/app/pages/storage/stores/pools-dashboard-store.service.ts b/src/app/pages/storage/stores/pools-dashboard-store.service.ts index b018dca1559..65543c6299f 100644 --- a/src/app/pages/storage/stores/pools-dashboard-store.service.ts +++ b/src/app/pages/storage/stores/pools-dashboard-store.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { ComponentStore } from '@ngrx/component-store'; import { tapResponse } from '@ngrx/operators'; -import * as _ from 'lodash-es'; +import { keyBy, sortBy } from 'lodash-es'; import { combineLatest, forkJoin, Observable, of, tap, } from 'rxjs'; @@ -93,8 +93,8 @@ export class PoolsDashboardStore extends ComponentStore { ({ pools, rootDatasets }) => { this.patchState({ arePoolsLoading: false, - pools: _.sortBy(pools, (pool) => pool.name), - rootDatasets: _.keyBy(rootDatasets, (dataset) => dataset.id), + pools: sortBy(pools, (pool) => pool.name), + rootDatasets: keyBy(rootDatasets, (dataset) => dataset.id), }); }, (error: unknown) => { diff --git a/src/app/pages/system/advanced/global-two-factor-auth/global-two-factor-form/global-two-factor-form.component.ts b/src/app/pages/system/advanced/global-two-factor-auth/global-two-factor-form/global-two-factor-form.component.ts index dc40035d234..fb4229fe959 100644 --- a/src/app/pages/system/advanced/global-two-factor-auth/global-two-factor-form/global-two-factor-form.component.ts +++ b/src/app/pages/system/advanced/global-two-factor-auth/global-two-factor-form/global-two-factor-form.component.ts @@ -5,7 +5,7 @@ import { FormBuilder, Validators } from '@angular/forms'; import { Router } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { isEqual } from 'lodash-es'; import { EMPTY, catchError, filter, of, switchMap, tap, } from 'rxjs'; @@ -95,7 +95,7 @@ export class GlobalTwoFactorAuthFormComponent implements OnInit { this.isFormLoading = false; this.snackbar.success(this.translate.instant('Settings saved')); this.authService.globalTwoFactorConfigUpdated(); - if (!_.isEqual(this.twoFactorConfig, payload) && payload.enabled) { + if (!isEqual(this.twoFactorConfig, payload) && payload.enabled) { this.router.navigate(['/two-factor-auth']); } this.cdr.markForCheck(); diff --git a/src/app/pages/system/advanced/self-encrypting-drive/self-encrypting-drive-card/self-encrypting-drive-card.component.ts b/src/app/pages/system/advanced/self-encrypting-drive/self-encrypting-drive-card/self-encrypting-drive-card.component.ts index ff5eba2ec73..d288d11adc9 100644 --- a/src/app/pages/system/advanced/self-encrypting-drive/self-encrypting-drive-card/self-encrypting-drive-card.component.ts +++ b/src/app/pages/system/advanced/self-encrypting-drive/self-encrypting-drive-card/self-encrypting-drive-card.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { Store } from '@ngrx/store'; -import * as _ from 'lodash-es'; +import { isEqual } from 'lodash-es'; import { Subject, combineLatest } from 'rxjs'; import { distinctUntilChanged, @@ -37,7 +37,7 @@ export class SelfEncryptingDriveCardComponent { switchMap(() => { const updatedSedUser$ = this.store$.pipe( waitForAdvancedConfig, - distinctUntilChanged((previous, current) => _.isEqual(previous.sed_user, current.sed_user)), + distinctUntilChanged((previous, current) => isEqual(previous.sed_user, current.sed_user)), map((config) => config.sed_user), ); const updatedSedPassword$ = this.ws.call('system.advanced.sed_global_password').pipe( diff --git a/src/app/pages/system/enclosure/components/pages/enclosure-page/status-view/statuses-legend/statuses-legend.component.ts b/src/app/pages/system/enclosure/components/pages/enclosure-page/status-view/statuses-legend/statuses-legend.component.ts index 7104f4a8308..76a178e1394 100644 --- a/src/app/pages/system/enclosure/components/pages/enclosure-page/status-view/statuses-legend/statuses-legend.component.ts +++ b/src/app/pages/system/enclosure/components/pages/enclosure-page/status-view/statuses-legend/statuses-legend.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, computed, input, } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; -import { chain } from 'lodash-es'; +import { uniq } from 'lodash-es'; import { enclosureDiskStatusLabels } from 'app/enums/enclosure-slot-status.enum'; import { DashboardEnclosureSlot } from 'app/interfaces/enclosure.interface'; import { getDiskStatusColor } from 'app/pages/system/enclosure/utils/disk-status-tint.utils'; @@ -17,11 +17,9 @@ export class StatusesLegendComponent { readonly slots = input.required(); protected readonly legend = computed(() => { - const statuses = chain(this.slots()) - .filter((slot) => Boolean(slot.pool_info)) - .map((slot) => slot.pool_info.disk_status) - .uniq() - .value(); + const slots = this.slots(); + const slotsWithPool = slots.filter((slot) => Boolean(slot.pool_info)); + const statuses = uniq(slotsWithPool.map((slot) => slot.pool_info.disk_status)); return statuses.map((status) => { const statusLabel = enclosureDiskStatusLabels.has(status) ? enclosureDiskStatusLabels.get(status) : status; diff --git a/src/app/pages/system/enclosure/components/pages/mini-page/mini-disks-overview/mini-disks-overview.component.ts b/src/app/pages/system/enclosure/components/pages/mini-page/mini-disks-overview/mini-disks-overview.component.ts index 74e0298d9ca..a8c26b645c2 100644 --- a/src/app/pages/system/enclosure/components/pages/mini-page/mini-disks-overview/mini-disks-overview.component.ts +++ b/src/app/pages/system/enclosure/components/pages/mini-page/mini-disks-overview/mini-disks-overview.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component, computed, input, } from '@angular/core'; -import { chain } from 'lodash-es'; +import { uniq } from 'lodash-es'; import { EnclosureDiskStatus } from 'app/enums/enclosure-slot-status.enum'; import { DashboardEnclosureSlot } from 'app/interfaces/enclosure.interface'; @@ -15,12 +15,10 @@ export class MiniDisksOverviewComponent { readonly slots = input.required(); protected readonly totalPools = computed(() => { - return chain(this.slots()) - .map((slot) => slot.pool_info?.pool_name) - .filter((slot) => slot !== undefined) - .uniq() - .value() - .length; + const slots = this.slots(); + const slotsWithValidPools = slots.map((slot) => slot.pool_info?.pool_name); + const validSlots = slotsWithValidPools.filter((slot) => slot !== undefined); + return uniq(validSlots).length; }); protected readonly totalDisks = computed(() => { diff --git a/src/app/pages/system/enclosure/components/pools-legend/pools-legend.component.ts b/src/app/pages/system/enclosure/components/pools-legend/pools-legend.component.ts index e9ec4390e3d..977680d9f96 100644 --- a/src/app/pages/system/enclosure/components/pools-legend/pools-legend.component.ts +++ b/src/app/pages/system/enclosure/components/pools-legend/pools-legend.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, computed, input, } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; -import { chain } from 'lodash-es'; +import { uniq } from 'lodash-es'; import { DashboardEnclosure } from 'app/interfaces/enclosure.interface'; import { getSlotsOfSide } from 'app/pages/system/enclosure/utils/get-slots-of-side.utils'; import { EnclosureSide } from 'app/pages/system/enclosure/utils/supported-enclosures'; @@ -26,17 +26,17 @@ export class PoolsLegendComponent { readonly legend = computed(() => { const poolColors = this.poolColors(); - return chain(this.slots()) - .map((slot) => slot.pool_info?.pool_name || null) - .uniq() - .map((poolName) => { - if (poolName === null) { - return [this.translate.instant('Unassigned'), unassignedColor] as [string, string]; - } + const slots = this.slots(); - return [poolName, poolColors[poolName]] as [string, string]; - }) - .value(); + const poolsFromSlots = slots.map((slot) => slot.pool_info?.pool_name || null); + const uniqPools = uniq(poolsFromSlots); + return uniqPools.map((poolName) => { + if (poolName === null) { + return [this.translate.instant('Unassigned'), unassignedColor] as [string, string]; + } + + return [poolName, poolColors[poolName]] as [string, string]; + }); }); constructor( diff --git a/src/app/pages/system/enclosure/services/enclosure.store.ts b/src/app/pages/system/enclosure/services/enclosure.store.ts index 264eeeaa3be..20a8d58512c 100644 --- a/src/app/pages/system/enclosure/services/enclosure.store.ts +++ b/src/app/pages/system/enclosure/services/enclosure.store.ts @@ -3,7 +3,9 @@ import { toSignal } from '@angular/core/rxjs-interop'; import { UntilDestroy } from '@ngneat/until-destroy'; import { ComponentStore } from '@ngrx/component-store'; import { produce } from 'immer'; -import { chain } from 'lodash-es'; +import { + filter, flatMap, fromPairs, map, uniq, +} from 'lodash-es'; import { Observable, switchMap, tap } from 'rxjs'; import { debounceTime, finalize } from 'rxjs/operators'; import { EnclosureElementType, DriveBayLightStatus } from 'app/enums/enclosure-slot-status.enum'; @@ -64,18 +66,22 @@ export class EnclosureStore extends ComponentStore { readonly enclosures = computed(() => this.stateAsSignal().enclosures); readonly poolColors = computed>(() => { - const poolNames = chain(this.enclosures()) - .flatMap((enclosure) => Object.values(enclosure.elements[EnclosureElementType.ArrayDeviceSlot])) - .filter((slot) => Boolean(slot.pool_info?.pool_name)) - .map((slot) => slot.pool_info.pool_name) - .uniq(); - - return poolNames - .map((poolName, index) => { - return [poolName, this.theme.getRgbBackgroundColorByIndex(index)]; - }) - .fromPairs() - .value(); + const enclosures = this.enclosures(); + const extractedEnclosuresObjects = flatMap( + enclosures, + (enclosure) => Object.values(enclosure.elements[EnclosureElementType.ArrayDeviceSlot]), + ); + const enclosuresWithPools = filter( + extractedEnclosuresObjects, + (slot) => Boolean(slot.pool_info?.pool_name), + ); + const poolNames = map(enclosuresWithPools, (slot) => slot.pool_info.pool_name); + const uniqPoolNames = uniq(poolNames); + const poolNamesWithColorsByIndex = map(uniqPoolNames, (poolName, index) => { + return [poolName, this.theme.getRgbBackgroundColorByIndex(index)]; + }); + + return fromPairs(poolNamesWithColorsByIndex); }); readonly enclosureLabel = computed(() => getEnclosureLabel(this.selectedEnclosure())); diff --git a/src/app/pages/system/general-settings/localization/localization-form/localization-form.component.ts b/src/app/pages/system/general-settings/localization/localization-form/localization-form.component.ts index 26fae7df05a..756eaf96113 100644 --- a/src/app/pages/system/general-settings/localization/localization-form/localization-form.component.ts +++ b/src/app/pages/system/general-settings/localization/localization-form/localization-form.component.ts @@ -6,7 +6,7 @@ import { } from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { Store } from '@ngrx/store'; -import * as _ from 'lodash-es'; +import { sortBy } from 'lodash-es'; import { Observable, of } from 'rxjs'; import { map } from 'rxjs/operators'; import { WINDOW } from 'app/helpers/window.helper'; @@ -86,7 +86,7 @@ export class LocalizationFormComponent implements OnInit { label: helptext.stg_timezone.placeholder, tooltip: helptext.stg_timezone.tooltip, provider: new SimpleAsyncComboboxProvider(this.sysGeneralService.timezoneChoices().pipe(map( - (tzChoices) => _.sortBy(tzChoices, [(option) => option.label.toLowerCase()]), + (tzChoices) => sortBy(tzChoices, [(option) => option.label.toLowerCase()]), ))), }; diff --git a/src/app/pages/system/general-settings/support/support-card/support-card.component.ts b/src/app/pages/system/general-settings/support/support-card/support-card.component.ts index f3c643d3cb3..87eb32d4935 100644 --- a/src/app/pages/system/general-settings/support/support-card/support-card.component.ts +++ b/src/app/pages/system/general-settings/support/support-card/support-card.component.ts @@ -7,7 +7,7 @@ import { MatDialog } from '@angular/material/dialog'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { Store } from '@ngrx/store'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { isObject } from 'lodash-es'; import { Observable, of, switchMap } from 'rxjs'; import { filter, tap } from 'rxjs/operators'; import { GiB } from 'app/constants/bytes.constant'; @@ -157,7 +157,7 @@ export class SupportCardComponent implements OnInit { request$.pipe( switchMap((result) => { - const attachDebug = (_.isObject(result) && result.sendInitialDebug) || false; + const attachDebug = (isObject(result) && result.sendInitialDebug) || false; return this.ws.job('truenas.set_production', [event.checked, attachDebug]).pipe(this.loader.withLoader()); }), diff --git a/src/app/pages/vm/utils/vm-gpu.service.ts b/src/app/pages/vm/utils/vm-gpu.service.ts index 0f0fc4e7489..c2afc13ca04 100644 --- a/src/app/pages/vm/utils/vm-gpu.service.ts +++ b/src/app/pages/vm/utils/vm-gpu.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import * as _ from 'lodash-es'; +import { differenceBy } from 'lodash-es'; import { forkJoin, Observable, of, switchMap, } from 'rxjs'; @@ -53,7 +53,7 @@ export class VmGpuService { } private subtractGpus(gpus: Device[], gpusToSubtract: Device[]): Device[] { - return _.differenceBy(gpus, gpusToSubtract, (gpu) => gpu.addr.pci_slot); + return differenceBy(gpus, gpusToSubtract, (gpu) => gpu.addr.pci_slot); } private addGpus(vm: VirtualMachine, previousSlots: string[], gpusToAdd: Device[]): Observable[] { diff --git a/src/app/pages/vm/vm-wizard/vm-wizard.component.ts b/src/app/pages/vm/vm-wizard/vm-wizard.component.ts index d8fc2322988..54bf35f9315 100644 --- a/src/app/pages/vm/vm-wizard/vm-wizard.component.ts +++ b/src/app/pages/vm/vm-wizard/vm-wizard.component.ts @@ -3,7 +3,7 @@ import { } from '@angular/core'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { pick } from 'lodash-es'; import { forkJoin, Observable, of, switchMap, } from 'rxjs'; @@ -160,17 +160,17 @@ export class VmWizardComponent implements OnInit { private createVm(): Observable { const vmPayload = { - ..._.pick(this.osForm, [ + ...pick(this.osForm, [ 'name', 'description', 'time', 'hyperv_enlightenments', 'bootloader', 'shutdown_timeout', 'autostart', ]), - ..._.pick(this.cpuAndMemoryForm, [ + ...pick(this.cpuAndMemoryForm, [ 'cpu_mode', 'vcpus', 'cores', 'threads', 'cpuset', 'nodeset', 'pin_vcpus', ]), cpu_model: this.cpuAndMemoryForm.cpu_model || null, // Middleware expects values in MiBs memory: this.cpuAndMemoryForm.memory / MiB, min_memory: this.cpuAndMemoryForm.min_memory ? this.cpuAndMemoryForm.min_memory / MiB : null, - ..._.pick(this.gpuForm, [ + ...pick(this.gpuForm, [ 'ensure_display_device', 'hide_from_msr', ]), } as VirtualMachineUpdate; diff --git a/src/app/services/dataset-service/dataset.service.ts b/src/app/services/dataset-service/dataset.service.ts index 8e8c1c47f40..3dc1dd1cf76 100644 --- a/src/app/services/dataset-service/dataset.service.ts +++ b/src/app/services/dataset-service/dataset.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { find } from 'lodash-es'; import { Observable, of } from 'rxjs'; import { map } from 'rxjs/operators'; import { ExplorerNodeType } from 'app/enums/explorer-type.enum'; @@ -36,10 +36,10 @@ export class DatasetService { return; } - let parent = _.find(nodes, { name: pathSegments[0] }); + let parent = find(nodes, { name: pathSegments[0] }); let i = 1; - while (_.find(parent.children, { name: pathSegments[i] })) { - parent = _.find(parent.children, { name: pathSegments[i++] }); + while (find(parent.children, { name: pathSegments[i] })) { + parent = find(parent.children, { name: pathSegments[i++] }); } parent.children.push({ diff --git a/src/app/services/language.service.ts b/src/app/services/language.service.ts index fa240798d03..56a33454678 100644 --- a/src/app/services/language.service.ts +++ b/src/app/services/language.service.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@angular/core'; import { UntilDestroy } from '@ngneat/until-destroy'; import { Store } from '@ngrx/store'; import { TranslateService } from '@ngx-translate/core'; -import * as _ from 'lodash-es'; +import { find } from 'lodash-es'; import { Observable, of } from 'rxjs'; import { map, switchMap } from 'rxjs/operators'; import { WINDOW } from 'app/helpers/window.helper'; @@ -404,7 +404,7 @@ export class LanguageService { * @return Observable that completes when translations have been loaded. */ setLanguage(lang: string): Observable { - if (_.find(this.availableLangs, { code: lang })) { + if (find(this.availableLangs, { code: lang })) { this.currentLanguage = lang; } else { this.currentLanguage = 'en'; diff --git a/src/app/services/schema/app-schema.service.ts b/src/app/services/schema/app-schema.service.ts index ab6ab9c43a7..746f9fcde0f 100644 --- a/src/app/services/schema/app-schema.service.ts +++ b/src/app/services/schema/app-schema.service.ts @@ -4,7 +4,7 @@ import { } from '@angular/forms'; import { UntilDestroy } from '@ngneat/until-destroy'; import { parseString } from 'cron-parser'; -import * as _ from 'lodash-es'; +import { isArray, isEqual, isPlainObject } from 'lodash-es'; import { BehaviorSubject, Subscription, timer } from 'rxjs'; import { debounceTime, take } from 'rxjs/operators'; import { ChartSchemaType } from 'app/enums/chart-schema-type.enum'; @@ -323,9 +323,9 @@ export class AppSchemaService { if (valueConfig && this.checkIsValidSchedule(valueConfig as Schedule)) { newConfig[keyConfig] = scheduleToCrontab(valueConfig as Schedule); - } else if (_.isArray(valueConfig)) { + } else if (isArray(valueConfig)) { newConfig = this.createHierarchicalObjectFromArray(restoreKeysPayload); - } else if (_.isPlainObject(valueConfig)) { + } else if (isPlainObject(valueConfig)) { newConfig = this.createHierarchicalObjectFromPlainObject(restoreKeysPayload); } else { newConfig[keyConfig] = valueConfig; @@ -387,7 +387,7 @@ export class AppSchemaService { } = payload; newConfig[keyConfig] = (valueConfig as ChartFormValue[]).map((valueItem, idxItem) => { - if (_.isPlainObject(valueItem)) { + if (isPlainObject(valueItem)) { return this.restoreKeysFromFormGroup( valueItem as HierarchicalObjectMap, formConfig.controls[idxItem] as FormGroup, @@ -572,7 +572,7 @@ export class AppSchemaService { schema, isNew, subscription, formGroup, isParentImmutable, chartSchemaNode, } = payload; - if (!_.isEqual(formGroup.controls[relation.fieldName].value, relation.operatorValue)) { + if (!isEqual(formGroup.controls[relation.fieldName].value, relation.operatorValue)) { const formField = (formGroup.controls[chartSchemaNode.variable] as CustomUntypedFormField); if (!formField.hidden$) { formField.hidden$ = new BehaviorSubject(false); @@ -594,7 +594,7 @@ export class AppSchemaService { if (!formField.hidden$) { formField.hidden$ = new BehaviorSubject(false); } - if (_.isEqual(value, relation.operatorValue) && formGroup.controls[relation.fieldName].status !== 'DISABLED') { + if (isEqual(value, relation.operatorValue) && formGroup.controls[relation.fieldName].status !== 'DISABLED') { formField.hidden$.next(false); if (!isNew && (isParentImmutable || !!schema.immutable)) { formField.disable(); @@ -615,7 +615,7 @@ export class AppSchemaService { schema, isNew, subscription, formGroup, isParentImmutable, chartSchemaNode, } = payload; - if (_.isEqual(formGroup.controls[relation.fieldName].value, relation.operatorValue)) { + if (isEqual(formGroup.controls[relation.fieldName].value, relation.operatorValue)) { const formField = (formGroup.controls[chartSchemaNode.variable] as CustomUntypedFormField); if (!formField.hidden$) { formField.hidden$ = new BehaviorSubject(false); @@ -637,7 +637,7 @@ export class AppSchemaService { if (!formField.hidden$) { formField.hidden$ = new BehaviorSubject(false); } - if (!_.isEqual(value, relation.operatorValue) && formGroup.controls[relation.fieldName].status !== 'DISABLED') { + if (!isEqual(value, relation.operatorValue) && formGroup.controls[relation.fieldName].status !== 'DISABLED') { formField.hidden$.next(false); if (!isNew && (isParentImmutable || !!schema.immutable)) { formField.disable(); diff --git a/src/app/services/system-general.service.ts b/src/app/services/system-general.service.ts index 08d0d0917d9..b779fd7239d 100644 --- a/src/app/services/system-general.service.ts +++ b/src/app/services/system-general.service.ts @@ -1,5 +1,5 @@ import { EventEmitter, Injectable } from '@angular/core'; -import * as _ from 'lodash-es'; +import { sortBy } from 'lodash-es'; import { Subject, Observable, } from 'rxjs'; @@ -117,7 +117,7 @@ export class SystemGeneralService { : `${key} (${languageList[key]})`, value: key, })); - options = _.sortBy( + options = sortBy( options, sortLanguagesByName ? 'label' : 'value', ); diff --git a/src/app/services/validators.ts b/src/app/services/validators.ts index cd2d8c011db..f1abc542f39 100644 --- a/src/app/services/validators.ts +++ b/src/app/services/validators.ts @@ -1,7 +1,7 @@ import { FormControl, FormGroup, UntypedFormControl, ValidatorFn, } from '@angular/forms'; -import * as _ from 'lodash-es'; +import { isEmpty, isNumber, toNumber } from 'lodash-es'; export function greaterThanFg( controlName: string, @@ -25,10 +25,10 @@ export function greaterThanFg( const otherValueExists = otherControl.value !== null && otherControl.value !== undefined && otherControl.value !== ''; const subjectValueExists = subjectControl.value !== null && subjectControl.value !== undefined && subjectControl.value !== ''; if (otherValueExists && subjectValueExists) { - if (!_.isNumber(otherControl.value) || !_.isNumber(subjectControl.value)) { + if (!isNumber(otherControl.value) || !isNumber(subjectControl.value)) { throw new Error('greaterThanValidator(): Comparates are not all numeric'); } - if (_.toNumber(otherControl.value) >= _.toNumber(subjectControl.value)) { + if (toNumber(otherControl.value) >= toNumber(subjectControl.value)) { errFields.push(name); } } @@ -43,7 +43,7 @@ export function greaterThanFg( } let prevErrors = { ...fg.get(controlName).errors }; delete prevErrors.greaterThan; - if (_.isEmpty(prevErrors)) { + if (isEmpty(prevErrors)) { prevErrors = null; } fg.get(controlName).setErrors(prevErrors);