diff --git a/npm/ng-packs/packages/core/src/lib/directives/autofocus.directive.ts b/npm/ng-packs/packages/core/src/lib/directives/autofocus.directive.ts index 40b0fe0b0b..84703badcf 100644 --- a/npm/ng-packs/packages/core/src/lib/directives/autofocus.directive.ts +++ b/npm/ng-packs/packages/core/src/lib/directives/autofocus.directive.ts @@ -5,12 +5,20 @@ import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core'; selector: '[autofocus]', }) export class AutofocusDirective implements AfterViewInit { + private _delay = 0; + @Input('autofocus') - delay = 0; + set delay(val: number | string | undefined) { + this._delay = Number(val) || 0; + } + + get delay() { + return this._delay; + } constructor(private elRef: ElementRef) {} ngAfterViewInit(): void { - setTimeout(() => this.elRef.nativeElement.focus(), this.delay); + setTimeout(() => this.elRef.nativeElement.focus(), this.delay as number); } } diff --git a/npm/ng-packs/packages/core/src/lib/directives/permission.directive.ts b/npm/ng-packs/packages/core/src/lib/directives/permission.directive.ts index 891c4c6e8c..2054a0d529 100644 --- a/npm/ng-packs/packages/core/src/lib/directives/permission.directive.ts +++ b/npm/ng-packs/packages/core/src/lib/directives/permission.directive.ts @@ -1,12 +1,10 @@ import { ChangeDetectorRef, Directive, - ElementRef, Input, OnChanges, OnDestroy, Optional, - Renderer2, TemplateRef, ViewContainerRef, } from '@angular/core'; @@ -18,13 +16,11 @@ import { PermissionService } from '../services/permission.service'; selector: '[abpPermission]', }) export class PermissionDirective implements OnDestroy, OnChanges { - @Input('abpPermission') condition: string; + @Input('abpPermission') condition: string | undefined; - subscription: Subscription; + subscription!: Subscription; constructor( - private elRef: ElementRef, - private renderer: Renderer2, @Optional() private templateRef: TemplateRef, private vcRef: ViewContainerRef, private permissionService: PermissionService, @@ -37,7 +33,7 @@ export class PermissionDirective implements OnDestroy, OnChanges { } this.subscription = this.permissionService - .getGrantedPolicy$(this.condition) + .getGrantedPolicy$(this.condition || '') .pipe(distinctUntilChanged()) .subscribe(isGranted => { this.vcRef.clear(); diff --git a/npm/ng-packs/packages/core/src/lib/directives/replaceable-template.directive.ts b/npm/ng-packs/packages/core/src/lib/directives/replaceable-template.directive.ts index f83af059f6..5a96ada9a9 100644 --- a/npm/ng-packs/packages/core/src/lib/directives/replaceable-template.directive.ts +++ b/npm/ng-packs/packages/core/src/lib/directives/replaceable-template.directive.ts @@ -33,7 +33,7 @@ export class ReplaceableTemplateDirective implements OnInit, OnChanges { context = {} as any; - externalComponent: Type; + externalComponent!: Type; defaultComponentRef: any; @@ -50,7 +50,7 @@ export class ReplaceableTemplateDirective implements OnInit, OnChanges { private subscription: SubscriptionService, ) { this.context = { - initTemplate: ref => { + initTemplate: (ref: any) => { this.resetDefaultComponent(); this.defaultComponentRef = ref; this.setDefaultComponentInputs(); @@ -121,8 +121,8 @@ export class ReplaceableTemplateDirective implements OnInit, OnChanges { if (Object.prototype.hasOwnProperty.call(this.data.outputs, key)) { if (!this.defaultComponentSubscriptions[key]) { this.defaultComponentSubscriptions[key] = this.defaultComponentRef[key].subscribe( - value => { - this.data.outputs[key](value); + (value: any) => { + this.data.outputs?.[key](value); }, ); } @@ -132,7 +132,7 @@ export class ReplaceableTemplateDirective implements OnInit, OnChanges { } setProvidedData() { - this.providedData = { ...this.data, inputs: {} }; + this.providedData = { ...this.data, inputs: {}, outputs: {} }; if (!this.data.inputs) return; Object.defineProperties(this.providedData.inputs, { @@ -142,9 +142,9 @@ export class ReplaceableTemplateDirective implements OnInit, OnChanges { [key]: { enumerable: true, configurable: true, - get: () => this.data.inputs[key].value, - ...(this.data.inputs[key].twoWay && { - set: newValue => { + get: () => this.data.inputs[key]?.value, + ...(this.data.inputs[key]?.twoWay && { + set: (newValue: any) => { this.data.inputs[key].value = newValue; this.data.outputs[`${key}Change`](newValue); }, diff --git a/npm/ng-packs/packages/core/src/lib/models/common.ts b/npm/ng-packs/packages/core/src/lib/models/common.ts index d99d591ad4..0196ce385a 100644 --- a/npm/ng-packs/packages/core/src/lib/models/common.ts +++ b/npm/ng-packs/packages/core/src/lib/models/common.ts @@ -52,7 +52,7 @@ export namespace ABP { } export interface Route extends Nav { - path: string; + path?: string; layout?: eLayoutType; iconClass?: string; } diff --git a/npm/ng-packs/packages/core/src/lib/models/replaceable-components.ts b/npm/ng-packs/packages/core/src/lib/models/replaceable-components.ts index d20768e7ff..ebdc7d1b8b 100644 --- a/npm/ng-packs/packages/core/src/lib/models/replaceable-components.ts +++ b/npm/ng-packs/packages/core/src/lib/models/replaceable-components.ts @@ -16,8 +16,8 @@ export namespace ReplaceableComponents { I, O extends { [K in keyof O]: EventEmitter | Subject }, > { - inputs: { -readonly [K in keyof I]: { value: I[K]; twoWay?: boolean } }; - outputs: { -readonly [K in keyof O]: (value: ABP.ExtractFromOutput) => void }; + inputs?: { -readonly [K in keyof I]: { value: I[K]; twoWay?: boolean } }; + outputs?: { -readonly [K in keyof O]: (value: ABP.ExtractFromOutput) => void }; componentKey: string; } diff --git a/npm/ng-packs/packages/core/src/lib/pipes/localization.pipe.ts b/npm/ng-packs/packages/core/src/lib/pipes/localization.pipe.ts index 50427ec5ed..2dbac68eb7 100644 --- a/npm/ng-packs/packages/core/src/lib/pipes/localization.pipe.ts +++ b/npm/ng-packs/packages/core/src/lib/pipes/localization.pipe.ts @@ -9,13 +9,20 @@ import { LocalizationService } from '../services/localization.service'; export class LocalizationPipe implements PipeTransform { constructor(private localization: LocalizationService) {} - transform(value: string | LocalizationWithDefault = '', ...interpolateParams: string[]): string { - return this.localization.instant( - value, - ...interpolateParams.reduce( - (acc, val) => (Array.isArray(val) ? [...acc, ...val] : [...acc, val]), - [], - ), - ); + transform( + value: string | LocalizationWithDefault = '', + ...interpolateParams: (string | string[] | undefined)[] + ): string { + const params = + interpolateParams.reduce((acc, val) => { + if (!acc) { + return val; + } + if (!val) { + return acc; + } + return Array.isArray(val) ? [...acc, ...val] : [...acc, val]; + }, []) || []; + return this.localization.instant(value, ...params); } } diff --git a/npm/ng-packs/packages/core/src/lib/services/config-state.service.ts b/npm/ng-packs/packages/core/src/lib/services/config-state.service.ts index 3aadfa898b..4223ea97de 100644 --- a/npm/ng-packs/packages/core/src/lib/services/config-state.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/config-state.service.ts @@ -48,14 +48,14 @@ export class ConfigStateService { return this.store.state; } - getDeep$(keys: string[] | string) { + getDeep$(keys: string[] | string): Observable { keys = splitKeys(keys); return this.store .sliceState(state => state) .pipe( map(state => { - return (keys as string[]).reduce((acc, val) => { + return (keys as string[]).reduce((acc: any, val) => { if (acc) { return acc[val]; } @@ -66,10 +66,10 @@ export class ConfigStateService { ); } - getDeep(keys: string[] | string) { + getDeep(keys: string[] | string): any { keys = splitKeys(keys); - return (keys as string[]).reduce((acc, val) => { + return (keys as string[]).reduce((acc: any, val) => { if (acc) { return acc[val]; } diff --git a/npm/ng-packs/packages/core/src/lib/services/environment.service.ts b/npm/ng-packs/packages/core/src/lib/services/environment.service.ts index 10d7664acb..9fd1e280a3 100644 --- a/npm/ng-packs/packages/core/src/lib/services/environment.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/environment.service.ts @@ -23,11 +23,11 @@ export class EnvironmentService { return this.store.state; } - getApiUrl(key?: string) { + getApiUrl(key: string) { return mapToApiUrl(key)(this.store.state.apis); } - getApiUrl$(key?: string) { + getApiUrl$(key: string) { return this.store.sliceState(state => state.apis).pipe(map(mapToApiUrl(key))); } diff --git a/npm/ng-packs/packages/core/src/lib/services/http-error-reporter.service.ts b/npm/ng-packs/packages/core/src/lib/services/http-error-reporter.service.ts index b34402c8cd..65d063f82d 100644 --- a/npm/ng-packs/packages/core/src/lib/services/http-error-reporter.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/http-error-reporter.service.ts @@ -4,7 +4,7 @@ import { BehaviorSubject, Subject } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class HttpErrorReporterService { - private _reporter$ = new Subject(); + private _reporter$ = new Subject(); private _errors$ = new BehaviorSubject([]); get reporter$() { diff --git a/npm/ng-packs/packages/core/src/lib/services/lazy-load.service.ts b/npm/ng-packs/packages/core/src/lib/services/lazy-load.service.ts index 0aca94c94a..3254396b82 100644 --- a/npm/ng-packs/packages/core/src/lib/services/lazy-load.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/lazy-load.service.ts @@ -8,7 +8,7 @@ import { ResourceWaitService } from './resource-wait.service'; providedIn: 'root', }) export class LazyLoadService { - readonly loaded = new Map(); + readonly loaded = new Map(); constructor(private resourceWaitService: ResourceWaitService) {} diff --git a/npm/ng-packs/packages/core/src/lib/services/list.service.ts b/npm/ng-packs/packages/core/src/lib/services/list.service.ts index dc79e67f66..e130e3d64f 100644 --- a/npm/ng-packs/packages/core/src/lib/services/list.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/list.service.ts @@ -21,7 +21,7 @@ import { PagedResultDto } from '../models/dtos'; import { LIST_QUERY_DEBOUNCE_TIME } from '../tokens/list.token'; @Injectable() -export class ListService implements OnDestroy { +export class ListService implements OnDestroy { private _filter = ''; set filter(value: string) { this._filter = value; @@ -112,7 +112,7 @@ export class ListService implements OnDes switchMap(query => streamCreatorCallback(query).pipe(catchError(() => of(null)))), filter(Boolean), tap(() => this._isLoading$.next(false)), - shareReplay({ bufferSize: 1, refCount: true }), + shareReplay({ bufferSize: 1, refCount: true }), takeUntil(this.destroy$), ); } diff --git a/npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts b/npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts index 02bbc3f338..59a0e99051 100644 --- a/npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts +++ b/npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts @@ -35,7 +35,7 @@ export function createLocalizationPipeKeyGenerator( ) { const findLocalization = createLocalizationFinder(localization); - return (resourceNames: string[], keys: string[], defaultKey: string) => { + return (resourceNames: string[], keys: string[], defaultKey: string | undefined) => { const { resourceName, key } = findLocalization(resourceNames, keys); return !resourceName ? defaultKey : resourceName === '_' ? key : `${resourceName}::${key}`; }; @@ -45,7 +45,7 @@ function createLocalizationFinder(localization: ApplicationLocalizationConfigura const localize = createLocalizer(localization); return (resourceNames: string[], keys: string[]) => { - resourceNames = resourceNames.concat(localization.defaultResourceName).filter(Boolean); + resourceNames = resourceNames.concat(localization.defaultResourceName || '').filter(Boolean); const resourceCount = resourceNames.length; const keyCount = keys.length; diff --git a/npm/ng-packs/packages/setting-management/config/src/components/email-setting-group/email-setting-group.component.html b/npm/ng-packs/packages/setting-management/config/src/components/email-setting-group/email-setting-group.component.html index 6017609d1e..ff6d51f692 100644 --- a/npm/ng-packs/packages/setting-management/config/src/components/email-setting-group/email-setting-group.component.html +++ b/npm/ng-packs/packages/setting-management/config/src/components/email-setting-group/email-setting-group.component.html @@ -2,7 +2,7 @@
-
+
@@ -41,7 +41,7 @@ - +
@@ -63,7 +63,7 @@ providerKey: { value: providerKey }, visible: { value: visibleFeatures, twoWay: true } }, - outputs: { visibleChange: onVisibleFeaturesChange }, + outputs: { visibleChange: $any(onVisibleFeaturesChange) }, componentKey: featureManagementKey }" [(visible)]="visibleFeatures" diff --git a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts index b3ebca01b1..dfee9ada2e 100644 --- a/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts +++ b/npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts @@ -26,17 +26,15 @@ import { eTenantManagementComponents } from '../../enums/components'; export class TenantsComponent implements OnInit { data: PagedResultDto = { items: [], totalCount: 0 }; - selected: TenantDto; + selected!: TenantDto; - tenantForm: FormGroup; + tenantForm!: FormGroup; - isModalVisible: boolean; + isModalVisible!: boolean; visibleFeatures = false; - providerKey: string; - - _useSharedDatabase: boolean; + providerKey!: string; modalBusy = false; @@ -142,7 +140,7 @@ export class TenantsComponent implements OnInit { }, 0); } - sort(data) { + sort(data: any) { const { prop, dir } = data.sorts[0]; this.list.sortKey = prop; this.list.sortOrder = dir; diff --git a/npm/ng-packs/packages/tenant-management/src/lib/defaults/default-tenants-toolbar-actions.ts b/npm/ng-packs/packages/tenant-management/src/lib/defaults/default-tenants-toolbar-actions.ts index e305186276..8bd590d2f6 100644 --- a/npm/ng-packs/packages/tenant-management/src/lib/defaults/default-tenants-toolbar-actions.ts +++ b/npm/ng-packs/packages/tenant-management/src/lib/defaults/default-tenants-toolbar-actions.ts @@ -7,7 +7,7 @@ export const DEFAULT_TENANTS_TOOLBAR_ACTIONS = ToolbarAction.createMany { const component = data.getInjected(TenantsComponent); - component.openFeaturesModal(null); + component.openFeaturesModal(''); }, permission: 'FeatureManagement.ManageHostFeatures', icon: 'fa fa-cog', diff --git a/npm/ng-packs/packages/theme-basic/src/lib/components/account-layout/tenant-box/tenant-box.component.html b/npm/ng-packs/packages/theme-basic/src/lib/components/account-layout/tenant-box/tenant-box.component.html index f0f80b599e..1804050cf8 100644 --- a/npm/ng-packs/packages/theme-basic/src/lib/components/account-layout/tenant-box/tenant-box.component.html +++ b/npm/ng-packs/packages/theme-basic/src/lib/components/account-layout/tenant-box/tenant-box.component.html @@ -1,4 +1,4 @@ - +
diff --git a/npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/current-user.component.ts b/npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/current-user.component.ts index aa2a144be6..fbfa01882a 100644 --- a/npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/current-user.component.ts +++ b/npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/current-user.component.ts @@ -21,7 +21,7 @@ export class CurrentUserComponent { } constructor( - @Inject(NAVIGATE_TO_MANAGE_PROFILE) public navigateToManageProfile, + @Inject(NAVIGATE_TO_MANAGE_PROFILE) public navigateToManageProfile: () => void, private authService: AuthService, private configState: ConfigStateService, private sessionState: SessionStateService, diff --git a/npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/languages.component.ts b/npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/languages.component.ts index 04b6cfa3bd..9dd27b28e1 100644 --- a/npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/languages.component.ts +++ b/npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/languages.component.ts @@ -7,7 +7,7 @@ import { map } from 'rxjs/operators'; selector: 'abp-languages', template: ` @@ -52,7 +52,7 @@ export class LanguagesComponent { return this.languages$.pipe( map( languages => - languages?.find(lang => lang.cultureName === this.selectedLangCulture).displayName || '', + languages?.find(lang => lang.cultureName === this.selectedLangCulture)?.displayName || '', ), ); } diff --git a/npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/nav-items.component.html b/npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/nav-items.component.html index d781ad90b2..ac571d7680 100644 --- a/npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/nav-items.component.html +++ b/npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/nav-items.component.html @@ -1,6 +1,6 @@