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