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 35 import { IWidgetSubscription } from '@core/api/widget-api.models';
36 36 import { UtilsService } from '@core/services/utils.service';
37 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 39 import cssjs from '@core/css/css';
40 40 import { sortItems } from '@shared/models/page/page-link';
41 41 import { Direction } from '@shared/models/page/sort-order';
... ... @@ -598,8 +598,16 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
598 598 if (styleInfo.useCellStyleFunction && styleInfo.cellStyleFunction) {
599 599 try {
600 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 607 } catch (e) {
602 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 612 } else {
605 613 style = this.defaultStyle(key, value);
... ...
... ... @@ -40,7 +40,7 @@ import {
40 40 import { IWidgetSubscription } from '@core/api/widget-api.models';
41 41 import { UtilsService } from '@core/services/utils.service';
42 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 44 import cssjs from '@core/css/css';
45 45 import { CollectionViewer, DataSource } from '@angular/cdk/collections';
46 46 import { DataKeyType } from '@shared/models/telemetry/telemetry.models';
... ... @@ -515,8 +515,16 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
515 515 if (styleInfo.useCellStyleFunction && styleInfo.cellStyleFunction) {
516 516 try {
517 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 524 } catch (e) {
519 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 529 } else {
522 530 style = {};
... ... @@ -538,7 +546,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
538 546 try {
539 547 content = contentInfo.cellContentFunction(value, entity, this.ctx);
540 548 } catch (e) {
541   - content = '' + value;
  549 + content = '' + value;
542 550 }
543 551 } else {
544 552 content = this.defaultContent(key, contentInfo, value);
... ...
... ... @@ -40,7 +40,7 @@ import {
40 40 } from '@shared/models/widget.models';
41 41 import { UtilsService } from '@core/services/utils.service';
42 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 44 import cssjs from '@core/css/css';
45 45 import { PageLink } from '@shared/models/page/page-link';
46 46 import { Direction, SortOrder, sortOrderFromString } from '@shared/models/page/sort-order';
... ... @@ -383,8 +383,16 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
383 383 if (styleInfo.useCellStyleFunction && styleInfo.cellStyleFunction) {
384 384 try {
385 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 392 } catch (e) {
387 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 }
... ...