Revert "Solved issue of a re-init Widget-Component service and widgets-info Cache."
This reverts commit 2b0fa4c4
This commit is contained in:
parent
4c3154da4b
commit
2aec503830
@ -31,7 +31,6 @@ import {
|
||||
Optional,
|
||||
Renderer2,
|
||||
StaticProvider,
|
||||
Type,
|
||||
ViewChild,
|
||||
ViewContainerRef,
|
||||
ViewEncapsulation
|
||||
@ -152,7 +151,6 @@ import { tap } from 'rxjs/operators';
|
||||
import { LayoutFixedSize, LayoutWidthType } from '@home/components/dashboard-page/layout/layout.models';
|
||||
import { TbPopoverComponent } from '@shared/components/popover.component';
|
||||
import { ResizeObserver } from '@juggle/resize-observer';
|
||||
import { HOME_COMPONENTS_MODULE_TOKEN } from '@home/components/tokens';
|
||||
|
||||
// @dynamic
|
||||
@Component({
|
||||
@ -341,7 +339,6 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
|
||||
constructor(protected store: Store<AppState>,
|
||||
@Inject(WINDOW) private window: Window,
|
||||
@Inject(DOCUMENT) private document: Document,
|
||||
@Inject(HOME_COMPONENTS_MODULE_TOKEN) private homeComponentsModule: Type<any>,
|
||||
private breakpointObserver: BreakpointObserver,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
@ -1147,8 +1144,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
|
||||
addWidgetFromType(widget: WidgetInfo) {
|
||||
this.onAddWidgetClosed();
|
||||
this.searchBundle = '';
|
||||
this.widgetComponentService.getWidgetInfo(widget.bundleAlias, widget.typeAlias, widget.isSystemType,
|
||||
[this.homeComponentsModule]).subscribe(
|
||||
this.widgetComponentService.getWidgetInfo(widget.bundleAlias, widget.typeAlias, widget.isSystemType).subscribe(
|
||||
(widgetTypeInfo) => {
|
||||
const config: WidgetConfig = JSON.parse(widgetTypeInfo.defaultConfig);
|
||||
config.title = 'New ' + widgetTypeInfo.widgetName;
|
||||
|
||||
@ -35,6 +35,7 @@ import { AddAttributeDialogComponent } from '@home/components/attribute/add-attr
|
||||
import { EditAttributeValuePanelComponent } from '@home/components/attribute/edit-attribute-value-panel.component';
|
||||
import { DashboardComponent } from '@home/components/dashboard/dashboard.component';
|
||||
import { WidgetComponent } from '@home/components/widget/widget.component';
|
||||
import { WidgetComponentService } from '@home/components/widget/widget-component.service';
|
||||
import { LegendComponent } from '@home/components/widget/legend.component';
|
||||
import { AliasesEntitySelectPanelComponent } from '@home/components/alias/aliases-entity-select-panel.component';
|
||||
import { AliasesEntitySelectComponent } from '@home/components/alias/aliases-entity-select.component';
|
||||
@ -455,6 +456,7 @@ import { AssetProfileAutocompleteComponent } from '@home/components/profile/asse
|
||||
RateLimitsDetailsDialogComponent
|
||||
],
|
||||
providers: [
|
||||
WidgetComponentService,
|
||||
CustomDialogService,
|
||||
ImportExportService,
|
||||
{provide: EMBED_DASHBOARD_DIALOG_TOKEN, useValue: EmbedDashboardDialogComponent},
|
||||
|
||||
@ -45,13 +45,13 @@ import { MODULES_MAP } from '@shared/public-api';
|
||||
import * as tinycolor_ from 'tinycolor2';
|
||||
import moment from 'moment';
|
||||
import { IModulesMap } from '@modules/common/modules-map.models';
|
||||
import { HOME_COMPONENTS_MODULE_TOKEN } from '@home/components/tokens';
|
||||
import { widgetSettingsComponentsMap } from '@home/components/widget/lib/settings/widget-settings.module';
|
||||
|
||||
const tinycolor = tinycolor_;
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
// @dynamic
|
||||
@Injectable()
|
||||
export class WidgetComponentService {
|
||||
|
||||
private cssParser = new cssjs();
|
||||
@ -68,6 +68,7 @@ export class WidgetComponentService {
|
||||
|
||||
constructor(@Inject(WINDOW) private window: Window,
|
||||
@Optional() @Inject(MODULES_MAP) private modulesMap: IModulesMap,
|
||||
@Inject(HOME_COMPONENTS_MODULE_TOKEN) private homeComponentsModule: Type<any>,
|
||||
private dynamicComponentFactoryService: DynamicComponentFactoryService,
|
||||
private widgetService: WidgetService,
|
||||
private utils: UtilsService,
|
||||
@ -184,9 +185,9 @@ export class WidgetComponentService {
|
||||
() => {
|
||||
const loadDefaultWidgetInfoTasks = [
|
||||
this.loadWidgetResources(this.missingWidgetType, 'global-widget-missing-type',
|
||||
[SharedModule, WidgetComponentsModule]),
|
||||
[SharedModule, WidgetComponentsModule, this.homeComponentsModule]),
|
||||
this.loadWidgetResources(this.errorWidgetType, 'global-widget-error-type',
|
||||
[SharedModule, WidgetComponentsModule]),
|
||||
[SharedModule, WidgetComponentsModule, this.homeComponentsModule]),
|
||||
];
|
||||
forkJoin(loadDefaultWidgetInfoTasks).subscribe(
|
||||
() => {
|
||||
@ -230,14 +231,13 @@ export class WidgetComponentService {
|
||||
}
|
||||
}
|
||||
|
||||
public getWidgetInfo(bundleAlias: string, widgetTypeAlias: string, isSystem: boolean, modules?: Type<any>[]): Observable<WidgetInfo> {
|
||||
public getWidgetInfo(bundleAlias: string, widgetTypeAlias: string, isSystem: boolean): Observable<WidgetInfo> {
|
||||
return this.init().pipe(
|
||||
mergeMap(() => this.getWidgetInfoInternal(bundleAlias, widgetTypeAlias, isSystem, modules))
|
||||
mergeMap(() => this.getWidgetInfoInternal(bundleAlias, widgetTypeAlias, isSystem))
|
||||
);
|
||||
}
|
||||
|
||||
private getWidgetInfoInternal(bundleAlias: string, widgetTypeAlias: string, isSystem: boolean,
|
||||
modules?: Type<any>[]): Observable<WidgetInfo> {
|
||||
private getWidgetInfoInternal(bundleAlias: string, widgetTypeAlias: string, isSystem: boolean): Observable<WidgetInfo> {
|
||||
const widgetInfoSubject = new ReplaySubject<WidgetInfo>();
|
||||
const widgetInfo = this.getWidgetInfoFromCache(bundleAlias, widgetTypeAlias, isSystem);
|
||||
if (widgetInfo) {
|
||||
@ -245,7 +245,7 @@ export class WidgetComponentService {
|
||||
widgetInfoSubject.complete();
|
||||
} else {
|
||||
if (this.utils.widgetEditMode) {
|
||||
this.loadWidget(this.editingWidgetType, bundleAlias, isSystem, widgetInfoSubject, modules);
|
||||
this.loadWidget(this.editingWidgetType, bundleAlias, isSystem, widgetInfoSubject);
|
||||
} else {
|
||||
const key = this.createWidgetInfoCacheKey(bundleAlias, widgetTypeAlias, isSystem);
|
||||
let fetchQueue = this.widgetsInfoFetchQueue.get(key);
|
||||
@ -256,7 +256,7 @@ export class WidgetComponentService {
|
||||
this.widgetsInfoFetchQueue.set(key, fetchQueue);
|
||||
this.widgetService.getWidgetType(bundleAlias, widgetTypeAlias, isSystem, {ignoreErrors: true}).subscribe(
|
||||
(widgetType) => {
|
||||
this.loadWidget(widgetType, bundleAlias, isSystem, widgetInfoSubject, modules);
|
||||
this.loadWidget(widgetType, bundleAlias, isSystem, widgetInfoSubject);
|
||||
},
|
||||
() => {
|
||||
widgetInfoSubject.next(this.missingWidgetType);
|
||||
@ -270,8 +270,7 @@ export class WidgetComponentService {
|
||||
return widgetInfoSubject.asObservable();
|
||||
}
|
||||
|
||||
private loadWidget(widgetType: WidgetType, bundleAlias: string, isSystem: boolean, widgetInfoSubject: Subject<WidgetInfo>,
|
||||
modules?: Type<any>[]) {
|
||||
private loadWidget(widgetType: WidgetType, bundleAlias: string, isSystem: boolean, widgetInfoSubject: Subject<WidgetInfo>) {
|
||||
const widgetInfo = toWidgetInfo(widgetType);
|
||||
const key = this.createWidgetInfoCacheKey(bundleAlias, widgetInfo.alias, isSystem);
|
||||
let widgetControllerDescriptor: WidgetControllerDescriptor = null;
|
||||
@ -284,11 +283,7 @@ export class WidgetComponentService {
|
||||
}
|
||||
if (widgetControllerDescriptor) {
|
||||
const widgetNamespace = `widget-type-${(isSystem ? 'sys-' : '')}${bundleAlias}-${widgetInfo.alias}`;
|
||||
const widgetModules = [SharedModule, WidgetComponentsModule];
|
||||
if (modules) {
|
||||
widgetModules.push(...modules);
|
||||
}
|
||||
this.loadWidgetResources(widgetInfo, widgetNamespace, widgetModules).subscribe(
|
||||
this.loadWidgetResources(widgetInfo, widgetNamespace, [SharedModule, WidgetComponentsModule, this.homeComponentsModule]).subscribe(
|
||||
() => {
|
||||
if (widgetControllerDescriptor.settingsSchema) {
|
||||
widgetInfo.typeSettingsSchema = widgetControllerDescriptor.settingsSchema;
|
||||
|
||||
@ -31,7 +31,6 @@ import {
|
||||
OnInit,
|
||||
Renderer2,
|
||||
SimpleChanges,
|
||||
Type,
|
||||
ViewChild,
|
||||
ViewContainerRef,
|
||||
ViewEncapsulation
|
||||
@ -115,7 +114,7 @@ import { MobileService } from '@core/services/mobile.service';
|
||||
import { DialogService } from '@core/services/dialog.service';
|
||||
import { PopoverPlacement } from '@shared/components/popover.models';
|
||||
import { TbPopoverService } from '@shared/components/popover.service';
|
||||
import { DASHBOARD_PAGE_COMPONENT_TOKEN, HOME_COMPONENTS_MODULE_TOKEN } from '@home/components/tokens';
|
||||
import { DASHBOARD_PAGE_COMPONENT_TOKEN } from '@home/components/tokens';
|
||||
|
||||
@Component({
|
||||
selector: 'tb-widget',
|
||||
@ -191,7 +190,6 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
|
||||
private popoverService: TbPopoverService,
|
||||
@Inject(EMBED_DASHBOARD_DIALOG_TOKEN) private embedDashboardDialogComponent: ComponentType<any>,
|
||||
@Inject(DASHBOARD_PAGE_COMPONENT_TOKEN) private dashboardPageComponent: ComponentType<any>,
|
||||
@Inject(HOME_COMPONENTS_MODULE_TOKEN) private homeComponentsModule: Type<any>,
|
||||
private widgetService: WidgetService,
|
||||
private resources: ResourcesService,
|
||||
private timeService: TimeService,
|
||||
@ -356,8 +354,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
|
||||
this.subscriptionContext.widgetUtils = this.widgetContext.utils;
|
||||
this.subscriptionContext.getServerTimeDiff = this.dashboardService.getServerTimeDiff.bind(this.dashboardService);
|
||||
|
||||
this.widgetComponentService.getWidgetInfo(this.widget.bundleAlias, this.widget.typeAlias, this.widget.isSystemType,
|
||||
[this.homeComponentsModule]).subscribe(
|
||||
this.widgetComponentService.getWidgetInfo(this.widget.bundleAlias, this.widget.typeAlias, this.widget.isSystemType).subscribe(
|
||||
(widgetInfo) => {
|
||||
this.widgetInfo = widgetInfo;
|
||||
this.loadFromWidgetInfo();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user