From d91ebeb1e946e817d2ebbf8fdebf27edd6157d21 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 1 Nov 2024 13:52:09 +0200 Subject: [PATCH] Remove TbInject decorator. --- ui-ngx/esbuild/tb-esbuild-plugins.ts | 7 +++--- ui-ngx/package.json | 4 ++-- ui-ngx/src/app/modules/common/modules-map.ts | 2 -- .../widget/dialog/custom-dialog.component.ts | 7 ++---- .../widget/dynamic-widget.component.ts | 7 ++---- .../app/shared/components/page.component.ts | 6 +++-- .../src/app/shared/decorators/public-api.ts | 1 - ui-ngx/src/app/shared/decorators/tb-inject.ts | 23 ------------------- 8 files changed, 14 insertions(+), 43 deletions(-) delete mode 100644 ui-ngx/src/app/shared/decorators/tb-inject.ts diff --git a/ui-ngx/esbuild/tb-esbuild-plugins.ts b/ui-ngx/esbuild/tb-esbuild-plugins.ts index 15323e0db0..db2ec59930 100644 --- a/ui-ngx/esbuild/tb-esbuild-plugins.ts +++ b/ui-ngx/esbuild/tb-esbuild-plugins.ts @@ -42,8 +42,9 @@ const resolveJQueryPlugin: Plugin = { name: 'tb-resolve-jquery-plugin', setup(build: PluginBuild) { if (isProduction()) { - build.onResolve({filter: /^(jquery|\$)$/}, (args) => { - return {path: require.resolve('jquery')}; + const jQueryPath = require.resolve('jquery'); + build.onResolve({filter: /^(jquery|\$)$/}, () => { + return {path: jQueryPath}; }) } } @@ -63,7 +64,7 @@ const compressorPlugin: Plugin = { if (!compressFileTypes.some((ext) => ext === path.extname(file.path))) continue; if (file.contents.byteLength <= compressThreshold) continue; const compressedContent = await gzipContent(file.contents); - const compressedFilePath = `${file.path}${outputExt}`; //path.join(outputDir, `${path.basename(file.path)}${outputExt}`); + const compressedFilePath = `${file.path}${outputExt}`; gzippedFiles.push( { path: compressedFilePath, diff --git a/ui-ngx/package.json b/ui-ngx/package.json index af7a7a0af1..36bae3bbe0 100644 --- a/ui-ngx/package.json +++ b/ui-ngx/package.json @@ -3,9 +3,9 @@ "version": "3.9.0", "scripts": { "ng": "ng", - "start": "ng serve --configuration development --host 0.0.0.0 --open", + "start": "node --max_old_space_size=8048 ./node_modules/@angular/cli/bin/ng serve --configuration development --host 0.0.0.0 --open", "build": "ng build", - "build:prod": "ng build --configuration production", + "build:prod": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --configuration production", "build:types": "node generate-types.js", "build:icon-metadata": "node generate-icon-metadata.js", "lint": "ng lint", diff --git a/ui-ngx/src/app/modules/common/modules-map.ts b/ui-ngx/src/app/modules/common/modules-map.ts index 12041a71da..52995f3f9a 100644 --- a/ui-ngx/src/app/modules/common/modules-map.ts +++ b/ui-ngx/src/app/modules/common/modules-map.ts @@ -100,7 +100,6 @@ import * as TruncateWithTooltipDirective from '@shared/directives/truncate-with- import * as coercion from '@shared/decorators/coercion'; import * as enumerable from '@shared/decorators/enumerable'; -import * as TbInject from '@shared/decorators/tb-inject'; import * as FooterComponent from '@shared/components/footer.component'; import * as LogoComponent from '@shared/components/logo.component'; @@ -432,7 +431,6 @@ class ModulesMap implements IModulesMap { '@shared/decorators/coercion': coercion, '@shared/decorators/enumerable': enumerable, - '@shared/decorators/tb-inject': TbInject, '@shared/import-export/import-export.service': ImportExportService, '@shared/import-export/import-dialog.component': ImportDialogComponent, diff --git a/ui-ngx/src/app/modules/home/components/widget/dialog/custom-dialog.component.ts b/ui-ngx/src/app/modules/home/components/widget/dialog/custom-dialog.component.ts index d918aac7eb..87c0696352 100644 --- a/ui-ngx/src/app/modules/home/components/widget/dialog/custom-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/dialog/custom-dialog.component.ts @@ -16,13 +16,10 @@ import { MatDialogRef } from '@angular/material/dialog'; import { Directive, inject, InjectionToken } from '@angular/core'; -import { Store } from '@ngrx/store'; -import { AppState } from '@core/core.state'; import { Router } from '@angular/router'; import { PageComponent } from '@shared/components/page.component'; import { CustomDialogContainerComponent } from './custom-dialog-container.component'; import { UntypedFormBuilder, Validators } from '@angular/forms'; -import { TbInject } from '@shared/decorators/tb-inject'; export const CUSTOM_DIALOG_DATA = new InjectionToken('ConfigDialogData'); @@ -42,8 +39,8 @@ export class CustomDialogComponent extends PageComponent { public data = inject(CUSTOM_DIALOG_DATA); public fb = inject(UntypedFormBuilder); - constructor(@TbInject(Store) protected store: Store) { - super(store); + constructor() { + super(); // @ts-ignore this.validators = Validators; this.data.controller(this); diff --git a/ui-ngx/src/app/modules/home/components/widget/dynamic-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/dynamic-widget.component.ts index 34eb8c83ba..44008d3e0f 100644 --- a/ui-ngx/src/app/modules/home/components/widget/dynamic-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/dynamic-widget.component.ts @@ -16,8 +16,6 @@ import { PageComponent } from '@shared/components/page.component'; import { Directive, inject, Injector, OnDestroy, OnInit } from '@angular/core'; -import { Store } from '@ngrx/store'; -import { AppState } from '@core/core.state'; import { IDynamicWidgetComponent, widgetContextToken, @@ -50,7 +48,6 @@ import { DatePipe } from '@angular/common'; import { TranslateService } from '@ngx-translate/core'; import { DomSanitizer } from '@angular/platform-browser'; import { Router } from '@angular/router'; -import { TbInject } from '@shared/decorators/tb-inject'; import { MillisecondsToTimeStringPipe } from '@shared/pipe/milliseconds-to-time-string.pipe'; import { UserSettingsService } from '@core/http/user-settings.service'; import { ImagePipe } from '@shared/pipe/image.pipe'; @@ -76,8 +73,8 @@ export class DynamicWidgetComponent extends PageComponent implements IDynamicWid public readonly errorMessages = inject(widgetErrorMessagesToken); public readonly widgetTitlePanel = inject(widgetTitlePanelToken); - constructor(@TbInject(Store) protected store: Store) { - super(store); + constructor() { + super(); this.ctx.$injector = this.$injector; this.ctx.deviceService = this.$injector.get(DeviceService); this.ctx.assetService = this.$injector.get(AssetService); diff --git a/ui-ngx/src/app/shared/components/page.component.ts b/ui-ngx/src/app/shared/components/page.component.ts index 4a5ee06cbc..ec6864e227 100644 --- a/ui-ngx/src/app/shared/components/page.component.ts +++ b/ui-ngx/src/app/shared/components/page.component.ts @@ -14,7 +14,7 @@ /// limitations under the License. /// -import { Directive, OnDestroy } from '@angular/core'; +import { Directive, inject, OnDestroy } from '@angular/core'; import { select, Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { Observable, Subscription } from 'rxjs'; @@ -25,13 +25,15 @@ import { AbstractControl } from '@angular/forms'; @Directive() export abstract class PageComponent implements OnDestroy { + protected store: Store = inject(Store); + isLoading$: Observable; loadingSubscription: Subscription; disabledOnLoadFormControls: Array = []; showMainLoadingBar = true; - protected constructor(protected store: Store) { + protected constructor(...args: unknown[]) { this.isLoading$ = this.store.pipe(delay(0), select(selectIsLoading), share()); } diff --git a/ui-ngx/src/app/shared/decorators/public-api.ts b/ui-ngx/src/app/shared/decorators/public-api.ts index e8dbfc608f..d8a8a397f4 100644 --- a/ui-ngx/src/app/shared/decorators/public-api.ts +++ b/ui-ngx/src/app/shared/decorators/public-api.ts @@ -16,4 +16,3 @@ export * from './coercion'; export * from './enumerable'; -export * from './tb-inject'; diff --git a/ui-ngx/src/app/shared/decorators/tb-inject.ts b/ui-ngx/src/app/shared/decorators/tb-inject.ts deleted file mode 100644 index 7c421c6514..0000000000 --- a/ui-ngx/src/app/shared/decorators/tb-inject.ts +++ /dev/null @@ -1,23 +0,0 @@ -/// -/// Copyright © 2016-2024 The Thingsboard Authors -/// -/// Licensed under the Apache License, Version 2.0 (the "License"); -/// you may not use this file except in compliance with the License. -/// You may obtain a copy of the License at -/// -/// http://www.apache.org/licenses/LICENSE-2.0 -/// -/// Unless required by applicable law or agreed to in writing, software -/// distributed under the License is distributed on an "AS IS" BASIS, -/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -/// See the License for the specific language governing permissions and -/// limitations under the License. -/// - -import { Inject, Type } from '@angular/core'; - -export function TbInject(token: any): (target: Type, key: any, paramIndex: number) => void { - return (target: Type, key: any, paramIndex: number) => { - Inject(token)(target, key, paramIndex); - }; -}