Commit 6c024360ff5c8f48535c7db5cfd8a8f5d0f2f074

Authored by Igor Kulikov
2 parents aa7752e9 9a9379d1

Fix conflicts

@@ -35,7 +35,7 @@ import { DataKey, WidgetActionDescriptor, WidgetConfig } from '@shared/models/wi @@ -35,7 +35,7 @@ import { DataKey, WidgetActionDescriptor, WidgetConfig } from '@shared/models/wi
35 import { IWidgetSubscription } from '@core/api/widget-api.models'; 35 import { IWidgetSubscription } from '@core/api/widget-api.models';
36 import { UtilsService } from '@core/services/utils.service'; 36 import { UtilsService } from '@core/services/utils.service';
37 import { TranslateService } from '@ngx-translate/core'; 37 import { TranslateService } from '@ngx-translate/core';
38 -import { createLabelFromDatasource, deepClone, hashCode, isDefined, isNumber } from '@core/utils'; 38 +import { createLabelFromDatasource, deepClone, hashCode, isDefined, isNumber, isObject } from '@core/utils';
39 import cssjs from '@core/css/css'; 39 import cssjs from '@core/css/css';
40 import { sortItems } from '@shared/models/page/page-link'; 40 import { sortItems } from '@shared/models/page/page-link';
41 import { Direction } from '@shared/models/page/sort-order'; 41 import { Direction } from '@shared/models/page/sort-order';
@@ -598,8 +598,16 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, @@ -598,8 +598,16 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
598 if (styleInfo.useCellStyleFunction && styleInfo.cellStyleFunction) { 598 if (styleInfo.useCellStyleFunction && styleInfo.cellStyleFunction) {
599 try { 599 try {
600 style = styleInfo.cellStyleFunction(value); 600 style = styleInfo.cellStyleFunction(value);
  601 + if (!isObject(style)) {
  602 + throw new TypeError(`${style === null ? 'null' : typeof style} instead of style object`);
  603 + }
  604 + if (Array.isArray(style)) {
  605 + throw new TypeError(`Array instead of style object`);
  606 + }
601 } catch (e) { 607 } catch (e) {
602 style = {}; 608 style = {};
  609 + console.warn(`Cell style function for data key '${key.label}' in widget '${this.ctx.widgetTitle}' ` +
  610 + `returns '${e}'. Please check your cell style function.`);
603 } 611 }
604 } else { 612 } else {
605 style = this.defaultStyle(key, value); 613 style = this.defaultStyle(key, value);
@@ -40,7 +40,7 @@ import { @@ -40,7 +40,7 @@ import {
40 import { IWidgetSubscription } from '@core/api/widget-api.models'; 40 import { IWidgetSubscription } from '@core/api/widget-api.models';
41 import { UtilsService } from '@core/services/utils.service'; 41 import { UtilsService } from '@core/services/utils.service';
42 import { TranslateService } from '@ngx-translate/core'; 42 import { TranslateService } from '@ngx-translate/core';
43 -import { createLabelFromDatasource, deepClone, hashCode, isDefined, isNumber } from '@core/utils'; 43 +import { createLabelFromDatasource, deepClone, hashCode, isDefined, isNumber, isObject } from '@core/utils';
44 import cssjs from '@core/css/css'; 44 import cssjs from '@core/css/css';
45 import { CollectionViewer, DataSource } from '@angular/cdk/collections'; 45 import { CollectionViewer, DataSource } from '@angular/cdk/collections';
46 import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; 46 import { DataKeyType } from '@shared/models/telemetry/telemetry.models';
@@ -515,8 +515,16 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni @@ -515,8 +515,16 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
515 if (styleInfo.useCellStyleFunction && styleInfo.cellStyleFunction) { 515 if (styleInfo.useCellStyleFunction && styleInfo.cellStyleFunction) {
516 try { 516 try {
517 style = styleInfo.cellStyleFunction(value); 517 style = styleInfo.cellStyleFunction(value);
  518 + if (!isObject(style)) {
  519 + throw new TypeError(`${style === null ? 'null' : typeof style} instead of style object`);
  520 + }
  521 + if (Array.isArray(style)) {
  522 + throw new TypeError(`Array instead of style object`);
  523 + }
518 } catch (e) { 524 } catch (e) {
519 style = {}; 525 style = {};
  526 + console.warn(`Cell style function for data key '${key.label}' in widget '${this.ctx.widgetTitle}' ` +
  527 + `returns '${e}'. Please check your cell style function.`);
520 } 528 }
521 } else { 529 } else {
522 style = {}; 530 style = {};
@@ -538,7 +546,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni @@ -538,7 +546,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
538 try { 546 try {
539 content = contentInfo.cellContentFunction(value, entity, this.ctx); 547 content = contentInfo.cellContentFunction(value, entity, this.ctx);
540 } catch (e) { 548 } catch (e) {
541 - content = '' + value; 549 + content = '' + value;
542 } 550 }
543 } else { 551 } else {
544 content = this.defaultContent(key, contentInfo, value); 552 content = this.defaultContent(key, contentInfo, value);
@@ -40,7 +40,7 @@ import { @@ -40,7 +40,7 @@ import {
40 } from '@shared/models/widget.models'; 40 } from '@shared/models/widget.models';
41 import { UtilsService } from '@core/services/utils.service'; 41 import { UtilsService } from '@core/services/utils.service';
42 import { TranslateService } from '@ngx-translate/core'; 42 import { TranslateService } from '@ngx-translate/core';
43 -import { hashCode, isDefined, isNumber } from '@core/utils'; 43 +import { hashCode, isDefined, isNumber, isObject } from '@core/utils';
44 import cssjs from '@core/css/css'; 44 import cssjs from '@core/css/css';
45 import { PageLink } from '@shared/models/page/page-link'; 45 import { PageLink } from '@shared/models/page/page-link';
46 import { Direction, SortOrder, sortOrderFromString } from '@shared/models/page/sort-order'; 46 import { Direction, SortOrder, sortOrderFromString } from '@shared/models/page/sort-order';
@@ -383,8 +383,16 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI @@ -383,8 +383,16 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
383 if (styleInfo.useCellStyleFunction && styleInfo.cellStyleFunction) { 383 if (styleInfo.useCellStyleFunction && styleInfo.cellStyleFunction) {
384 try { 384 try {
385 style = styleInfo.cellStyleFunction(value); 385 style = styleInfo.cellStyleFunction(value);
  386 + if (!isObject(style)) {
  387 + throw new TypeError(`${style === null ? 'null' : typeof style} instead of style object`);
  388 + }
  389 + if (Array.isArray(style)) {
  390 + throw new TypeError(`Array instead of style object`);
  391 + }
386 } catch (e) { 392 } catch (e) {
387 style = {}; 393 style = {};
  394 + console.warn(`Cell style function for data key '${source.header[index - 1].dataKey.label}' in widget ` +
  395 + `'${this.ctx.widgetConfig.title}' returns '${e}'. Please check your cell style function.`);
388 } 396 }
389 } 397 }
390 } 398 }