Commit fa380bc3002ec526a2ba727ade2d3400427b72ed

Authored by Igor Kulikov
1 parent 7a8683ef

Add enumerable to widget x,y,cols,rows. Fix js_beautify.

... ... @@ -98,6 +98,7 @@
98 98 "react-ace",
99 99 "schema-inspector",
100 100 "@flowjs/flow.js",
  101 + "js-beautify",
101 102 "mousetrap",
102 103 "prop-types",
103 104 "react-is",
... ...
... ... @@ -34,6 +34,7 @@ import { AppState } from '@core/core.state';
34 34 import { CustomActionDescriptor } from '@shared/models/widget.models';
35 35 import * as ace from 'ace-builds';
36 36 import { CancelAnimationFrame, RafService } from '@core/services/raf.service';
  37 +import { css_beautify, html_beautify } from 'js-beautify';
37 38 import { ResizeObserver } from '@juggle/resize-observer';
38 39 import { CustomPrettyActionEditorCompleter } from '@home/components/widget/action/custom-action.models';
39 40
... ... @@ -134,7 +135,7 @@ export class CustomActionPrettyResourcesTabsComponent extends PageComponent impl
134 135 }
135 136
136 137 public beautifyCss(): void {
137   - const res = js_beautify.css_beautify(this.action.customCss, {indent_size: 4});
  138 + const res = css_beautify(this.action.customCss, {indent_size: 4});
138 139 if (this.action.customCss !== res) {
139 140 this.action.customCss = res;
140 141 this.cssEditor.setValue(this.action.customCss ? this.action.customCss : '', -1);
... ... @@ -143,7 +144,7 @@ export class CustomActionPrettyResourcesTabsComponent extends PageComponent impl
143 144 }
144 145
145 146 public beautifyHtml(): void {
146   - const res = js_beautify.html_beautify(this.action.customHtml, {indent_size: 4, wrap_line_length: 60});
  147 + const res = html_beautify(this.action.customHtml, {indent_size: 4, wrap_line_length: 60});
147 148 if (this.action.customHtml !== res) {
148 149 this.action.customHtml = res;
149 150 this.htmlEditor.setValue(this.action.customHtml ? this.action.customHtml : '', -1);
... ...
... ... @@ -23,6 +23,7 @@ import { Observable, of, Subject } from 'rxjs';
23 23 import { guid, isDefined, isEqual, isUndefined } from '@app/core/utils';
24 24 import { IterableDiffer, KeyValueDiffer } from '@angular/core';
25 25 import { IAliasController, IStateController } from '@app/core/api/widget-api.models';
  26 +import { enumerable } from '@shared/decorators/enumerable';
26 27
27 28 export interface WidgetsData {
28 29 widgets: Array<Widget>;
... ... @@ -401,6 +402,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget {
401 402 this.widgetActions = this.widgetContext.widgetActions ? this.widgetContext.widgetActions : [];
402 403 }
403 404
  405 + @enumerable(true)
404 406 get x(): number {
405 407 let res;
406 408 if (this.widgetLayout) {
... ... @@ -421,6 +423,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget {
421 423 }
422 424 }
423 425
  426 + @enumerable(true)
424 427 get y(): number {
425 428 let res;
426 429 if (this.widgetLayout) {
... ... @@ -441,6 +444,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget {
441 444 }
442 445 }
443 446
  447 + @enumerable(true)
444 448 get cols(): number {
445 449 let res;
446 450 if (this.widgetLayout) {
... ... @@ -461,6 +465,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget {
461 465 }
462 466 }
463 467
  468 + @enumerable(true)
464 469 get rows(): number {
465 470 let res;
466 471 if (this.dashboard.isMobileSize && !this.dashboard.mobileAutofillHeight) {
... ... @@ -497,6 +502,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget {
497 502 }
498 503 }
499 504
  505 + @enumerable(true)
500 506 get widgetOrder(): number {
501 507 let order;
502 508 if (this.widgetLayout && isDefined(this.widgetLayout.mobileOrder) && this.widgetLayout.mobileOrder >= 0) {
... ...
... ... @@ -33,6 +33,7 @@ import { Hotkey } from 'angular2-hotkeys';
33 33 import { TranslateService } from '@ngx-translate/core';
34 34 import { getCurrentIsLoading } from '@app/core/interceptors/load.selectors';
35 35 import * as ace from 'ace-builds';
  36 +import { css_beautify, html_beautify } from 'js-beautify';
36 37 import { CancelAnimationFrame, RafService } from '@core/services/raf.service';
37 38 import { WINDOW } from '@core/services/window.service';
38 39 import { WindowMessage } from '@shared/models/window-message.model';
... ... @@ -576,7 +577,7 @@ export class WidgetEditorComponent extends PageComponent implements OnInit, OnDe
576 577 }
577 578
578 579 beautifyCss(): void {
579   - const res = js_beautify.css_beautify(this.widget.templateCss, {indent_size: 4});
  580 + const res = css_beautify(this.widget.templateCss, {indent_size: 4});
580 581 if (this.widget.templateCss !== res) {
581 582 this.isDirty = true;
582 583 this.widget.templateCss = res;
... ... @@ -585,7 +586,7 @@ export class WidgetEditorComponent extends PageComponent implements OnInit, OnDe
585 586 }
586 587
587 588 beautifyHtml(): void {
588   - const res = js_beautify.html_beautify(this.widget.templateHtml, {indent_size: 4, wrap_line_length: 60});
  589 + const res = html_beautify(this.widget.templateHtml, {indent_size: 4, wrap_line_length: 60});
589 590 if (this.widget.templateHtml !== res) {
590 591 this.isDirty = true;
591 592 this.widget.templateHtml = res;
... ...
... ... @@ -16,6 +16,7 @@
16 16 import * as React from 'react';
17 17 import ThingsboardAceEditor from './json-form-ace-editor';
18 18 import { JsonFormFieldProps, JsonFormFieldState } from '@shared/components/json-form/react/json-form.models';
  19 +import { css_beautify } from 'js-beautify';
19 20
20 21 class ThingsboardCss extends React.Component<JsonFormFieldProps, JsonFormFieldState> {
21 22
... ... @@ -25,7 +26,7 @@ class ThingsboardCss extends React.Component<JsonFormFieldProps, JsonFormFieldSt
25 26 }
26 27
27 28 onTidyCss(css: string): string {
28   - return js_beautify.css_beautify(css, {indent_size: 4});
  29 + return css_beautify(css, {indent_size: 4});
29 30 }
30 31
31 32 render() {
... ...
... ... @@ -15,6 +15,7 @@
15 15 */
16 16 import * as React from 'react';
17 17 import ThingsboardAceEditor from './json-form-ace-editor';
  18 +import { html_beautify } from 'js-beautify';
18 19 import { JsonFormFieldProps, JsonFormFieldState } from '@shared/components/json-form/react/json-form.models';
19 20
20 21 class ThingsboardHtml extends React.Component<JsonFormFieldProps, JsonFormFieldState> {
... ... @@ -25,7 +26,7 @@ class ThingsboardHtml extends React.Component<JsonFormFieldProps, JsonFormFieldS
25 26 }
26 27
27 28 onTidyHtml(html: string): string {
28   - return js_beautify.html_beautify(html, {indent_size: 4});
  29 + return html_beautify(html, {indent_size: 4});
29 30 }
30 31
31 32 render() {
... ...
  1 +export function enumerable(value: boolean) {
  2 + return (
  3 + target: any,
  4 + propertyKey: string,
  5 + descriptor: PropertyDescriptor
  6 + ) => {
  7 + descriptor.enumerable = value;
  8 + };
  9 +}
... ...