From 453f9cdbeedfc2161b8bcf8e1a93cb804d1fea16 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 1 Sep 2023 19:55:13 +0300 Subject: [PATCH] UI: Code cleanup --- ui-ngx/src/app/core/http/widget.service.ts | 58 ------------------- .../widget/widget-library-routing.module.ts | 16 ----- .../widget-types-table-config.resolver.ts | 1 - 3 files changed, 75 deletions(-) diff --git a/ui-ngx/src/app/core/http/widget.service.ts b/ui-ngx/src/app/core/http/widget.service.ts index c0fde187fc..dcaef000f2 100644 --- a/ui-ngx/src/app/core/http/widget.service.ts +++ b/ui-ngx/src/app/core/http/widget.service.ts @@ -24,7 +24,6 @@ import { WidgetsBundle } from '@shared/models/widgets-bundle.model'; import { BaseWidgetType, fullWidgetTypeFqn, - Widget, WidgetType, widgetType, WidgetTypeDetails, @@ -168,63 +167,6 @@ export class WidgetService { } } - public loadBundleLibraryWidgets(widgetsBundleId: string, - config?: RequestConfig): Observable> { - return this.getBundleWidgetTypes(widgetsBundleId, config).pipe( - map((types) => { - types = types.sort((a, b) => { - let result = (a.deprecated ? 1 : 0) - (b.deprecated ? 1 : 0); - if (result === 0) { - result = widgetType[b.descriptor.type].localeCompare(widgetType[a.descriptor.type]); - if (result === 0) { - result = b.createdTime - a.createdTime; - } - } - return result; - }); - const widgetTypes = new Array(); - let top = 0; - const lastTop = [0, 0, 0]; - let col = 0; - let column = 0; - types.forEach((type) => { - const widgetTypeInfo = toWidgetInfo(type); - const sizeX = 8; - const sizeY = Math.floor(widgetTypeInfo.sizeY); - const widget: Widget = { - typeId: type.id, - typeFullFqn: widgetTypeInfo.fullFqn, - type: widgetTypeInfo.type, - title: widgetTypeInfo.widgetName, - sizeX, - sizeY, - row: top, - col, - config: JSON.parse(widgetTypeInfo.defaultConfig) - }; - - widget.config.title = widgetTypeInfo.widgetName; - if (type.deprecated) { - widget.config.title += ` (${this.translate.instant('widget.deprecated')})`; - } - - widgetTypes.push(widget); - top += sizeY; - if (top > lastTop[column] + 10) { - lastTop[column] = top; - column++; - if (column > 2) { - column = 0; - } - top = lastTop[column]; - col = column * 8; - } - }); - return widgetTypes; - }) - ); - } - public getWidgetType(fullFqn: string, config?: RequestConfig): Observable { return this.http.get(`/api/widgetType?fqn=${fullFqn}`, defaultHttpOptionsFromConfig(config)); diff --git a/ui-ngx/src/app/modules/home/pages/widget/widget-library-routing.module.ts b/ui-ngx/src/app/modules/home/pages/widget/widget-library-routing.module.ts index 945cee8e0b..4ac54e7a68 100644 --- a/ui-ngx/src/app/modules/home/pages/widget/widget-library-routing.module.ts +++ b/ui-ngx/src/app/modules/home/pages/widget/widget-library-routing.module.ts @@ -62,21 +62,6 @@ export class WidgetsBundleWidgetsResolver implements Resolve { - - constructor(private widgetsService: WidgetService) { - } - - resolve(route: ActivatedRouteSnapshot): Observable { - const widgetsBundleId = route.params.widgetsBundleId; - return this.widgetsService.loadBundleLibraryWidgets(widgetsBundleId).pipe( - map((widgets) => ({ widgets }) - )); - } -}*/ - @Injectable() export class WidgetEditorDataResolver implements Resolve { @@ -279,7 +264,6 @@ const routes: Routes = [ WidgetsBundlesTableConfigResolver, WidgetsBundleResolver, WidgetsBundleWidgetsResolver, - // WidgetsTypesDataResolver, WidgetEditorDataResolver ] }) diff --git a/ui-ngx/src/app/modules/home/pages/widget/widget-types-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/widget/widget-types-table-config.resolver.ts index c4c1e84417..8fcf76f1fe 100644 --- a/ui-ngx/src/app/modules/home/pages/widget/widget-types-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/widget/widget-types-table-config.resolver.ts @@ -152,7 +152,6 @@ export class WidgetTypesTableConfigResolver implements Resolve this.isWidgetTypeEditable(widgetType, authUser.authority); this.config.entitySelectionEnabled = (widgetType) => this.isWidgetTypeEditable(widgetType, authUser.authority); this.config.detailsReadonly = (widgetType) => !this.isWidgetTypeEditable(widgetType, authUser.authority); - const authState = getCurrentAuthState(this.store); this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetTypes(pageLink); return this.config; }