Hi,
Is there a way to remove the out of the box widgets from widget selection?
Here i want to just keep the custom widgets and remove all cumulocity widgets. Any pointer on how this can be achieved would be helpful.
Hi,
Is there a way to remove the out of the box widgets from widget selection?
Hi,
Any one aware of this?
You can remove widgets by removing their corresponding entry/module in the ng1.ts
and/or app.module.ts
files.
As an alternative you could try to override the getWidgetDefinitions
method of the WidgetService
.
Regards,
Tristan
I couldn’t do it by removing entries from ng.ts file as not all entries of widgets are there.
But I was able to solve by overriding the WidgetService. This is how I did it.
--- custom-widget.service.ts ---
import { Inject, Injectable } from '@angular/core';
import { DynamicComponentDefinition, DynamicComponentService } from '@c8y/ngx-components';
import { CONTEXT_DASHBOARD_CONFIG, ContextDashboardConfig, WidgetService } from '@c8y/ngx-components/context-dashboard';
import { TranslateService } from '@ngx-translate/core';
@Injectable()
export class CustomWidgetService extends WidgetService {
widgetsToBeShown = [
// Add widget id that needs to be shown
]
constructor(dynamicComponentService: DynamicComponentService, translateService: TranslateService,
@Inject(CONTEXT_DASHBOARD_CONFIG) moduleConfig: ContextDashboardConfig) {
super(dynamicComponentService, translateService, moduleConfig);
}
getWidgetDefinitions() {
this.widgets = this.widgets.filter((widget: DynamicComponentDefinition) => this.widgetsToBeShown.includes(widget.id))
return this.widgets
}
}
--- app.module.ts ---
providers: [
CustomWidgetService,
{ provide: WidgetService, useClass: CustomWidgetService }
]
Thanks for the hint @Tristan_Bastian