Browse Source

UI: overide alarm severity colors from widget and dashboard css settings

pull/14672/head
ArtemDzhereleiko 10 months ago
parent
commit
0ea0dcadc0
  1. 4
      ui-ngx/src/app/core/services/utils.service.ts
  2. 1
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts
  3. 1
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts
  4. 2
      ui-ngx/src/app/modules/home/components/widget/lib/alarm/alarms-table-widget.component.ts
  5. 4
      ui-ngx/src/app/modules/home/components/widget/widget-container.component.ts
  6. 2
      ui-ngx/src/app/modules/home/models/widget-component.models.ts

4
ui-ngx/src/app/core/services/utils.service.ts

@ -454,11 +454,11 @@ export class UtilsService {
return base64toObj(b64Encoded);
}
public applyCssToElement(renderer: Renderer2, element: any, cssClassPrefix: string, css: string): string {
public applyCssToElement(renderer: Renderer2, element: any, cssClassPrefix: string, css: string, addTbDefaultClass: boolean = false): string {
const cssParser = new cssjs();
cssParser.testMode = false;
const cssClass = `${cssClassPrefix}-${guid()}`;
cssParser.cssPreviewNamespace = cssClass;
cssParser.cssPreviewNamespace = addTbDefaultClass ? 'tb-default .' + cssClass : cssClass;
cssParser.createStyleElement(cssClass, css);
renderer.addClass(element, cssClass);
return cssClass;

1
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts

@ -548,6 +548,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
const cssParser = new cssjs();
cssParser.testMode = false;
this.dashboardPageClass = 'tb-dashboard-page-css-' + guid();
this.dashboardCtx.dashboardCssClass = this.dashboardPageClass;
cssParser.cssPreviewNamespace = 'tb-default .' + this.dashboardPageClass;
cssParser.createStyleElement(this.dashboardPageClass, cssString);
}

1
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts

@ -51,6 +51,7 @@ export interface DashboardContext {
stateChanged: Observable<string>;
stateId: Observable<string>;
runChangeDetection: () => void;
dashboardCssClass?: string;
}
export interface IDashboardController {

2
ui-ngx/src/app/modules/home/components/widget/lib/alarm/alarms-table-widget.component.ts

@ -968,7 +968,7 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
(AlarmDetailsDialogComponent,
{
disableClose: true,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', this.ctx.stateController.dashboardCtrl.dashboardCtx.dashboardCssClass, this.ctx.widgetCssClass],
data: {
alarmId: alarm.id.id,
allowAcknowledgment: this.allowAcknowledgment,

4
ui-ngx/src/app/modules/home/components/widget/widget-container.component.ts

@ -151,8 +151,8 @@ export class WidgetContainerComponent extends PageComponent implements OnInit, O
this.widget.widgetContext.containerChangeDetector = this.cd;
const cssString = this.widget.widget.config.widgetCss;
if (isNotEmptyStr(cssString)) {
this.cssClass =
this.utils.applyCssToElement(this.renderer, this.gridsterItem.el, 'tb-widget-css', cssString);
this.cssClass = this.utils.applyCssToElement(this.renderer, this.gridsterItem.el, 'tb-widget-css', cssString, true);
this.widget.widgetContext.widgetCssClass = this.cssClass;
}
$(this.gridsterItem.el).on('mousedown', (e) => this.onMouseDown(e.originalEvent));
$(this.gridsterItem.el).on('click', (e) => this.onClicked(e.originalEvent));

2
ui-ngx/src/app/modules/home/models/widget-component.models.ts

@ -308,6 +308,8 @@ export class WidgetContext {
widgetNamespace?: string;
subscriptionApi?: WidgetSubscriptionApi;
widgetCssClass?: string;
actionsApi?: WidgetActionsApi;
activeEntityInfo?: SubscriptionEntityInfo;

Loading…
Cancel
Save