Commit cc27993b0055e9473e6da3d048fe54510835fa55
Committed by
GitHub
Merge pull request #3255 from vvlladd28/feature/sanitier
[3.0] Add angular Sanitizer for widgetContext
Showing
4 changed files
with
27 additions
and
0 deletions
@@ -40,6 +40,7 @@ import { DialogService } from '@core/services/dialog.service'; | @@ -40,6 +40,7 @@ import { DialogService } from '@core/services/dialog.service'; | ||
40 | import { CustomDialogService } from '@home/components/widget/dialog/custom-dialog.service'; | 40 | import { CustomDialogService } from '@home/components/widget/dialog/custom-dialog.service'; |
41 | import { DatePipe } from '@angular/common'; | 41 | import { DatePipe } from '@angular/common'; |
42 | import { TranslateService } from '@ngx-translate/core'; | 42 | import { TranslateService } from '@ngx-translate/core'; |
43 | +import { DomSanitizer } from '@angular/platform-browser'; | ||
43 | 44 | ||
44 | export class DynamicWidgetComponent extends PageComponent implements IDynamicWidgetComponent, OnInit, OnDestroy { | 45 | export class DynamicWidgetComponent extends PageComponent implements IDynamicWidgetComponent, OnInit, OnDestroy { |
45 | 46 | ||
@@ -74,6 +75,7 @@ export class DynamicWidgetComponent extends PageComponent implements IDynamicWid | @@ -74,6 +75,7 @@ export class DynamicWidgetComponent extends PageComponent implements IDynamicWid | ||
74 | this.ctx.date = $injector.get(DatePipe); | 75 | this.ctx.date = $injector.get(DatePipe); |
75 | this.ctx.translate = $injector.get(TranslateService); | 76 | this.ctx.translate = $injector.get(TranslateService); |
76 | this.ctx.http = $injector.get(HttpClient); | 77 | this.ctx.http = $injector.get(HttpClient); |
78 | + this.ctx.sanitizer = $injector.get(DomSanitizer); | ||
77 | 79 | ||
78 | this.ctx.$scope = this; | 80 | this.ctx.$scope = this; |
79 | if (this.ctx.defaultSubscription) { | 81 | if (this.ctx.defaultSubscription) { |
@@ -75,6 +75,7 @@ import { DatePipe } from '@angular/common'; | @@ -75,6 +75,7 @@ import { DatePipe } from '@angular/common'; | ||
75 | import { TranslateService } from '@ngx-translate/core'; | 75 | import { TranslateService } from '@ngx-translate/core'; |
76 | import { PageLink } from '@shared/models/page/page-link'; | 76 | import { PageLink } from '@shared/models/page/page-link'; |
77 | import { SortOrder } from '@shared/models/page/sort-order'; | 77 | import { SortOrder } from '@shared/models/page/sort-order'; |
78 | +import { DomSanitizer } from '@angular/platform-browser'; | ||
78 | 79 | ||
79 | export interface IWidgetAction { | 80 | export interface IWidgetAction { |
80 | name: string; | 81 | name: string; |
@@ -155,6 +156,7 @@ export class WidgetContext { | @@ -155,6 +156,7 @@ export class WidgetContext { | ||
155 | date: DatePipe; | 156 | date: DatePipe; |
156 | translate: TranslateService; | 157 | translate: TranslateService; |
157 | http: HttpClient; | 158 | http: HttpClient; |
159 | + sanitizer: DomSanitizer; | ||
158 | 160 | ||
159 | private changeDetectorValue: ChangeDetectorRef; | 161 | private changeDetectorValue: ChangeDetectorRef; |
160 | 162 |
@@ -1382,5 +1382,11 @@ export const serviceCompletions: TbEditorCompletions = { | @@ -1382,5 +1382,11 @@ export const serviceCompletions: TbEditorCompletions = { | ||
1382 | 'See <a href="https://angular.io/api/common/http/HttpClient">HttpClient</a> for API reference.', | 1382 | 'See <a href="https://angular.io/api/common/http/HttpClient">HttpClient</a> for API reference.', |
1383 | meta: 'service', | 1383 | meta: 'service', |
1384 | type: '<a href="https://angular.io/api/common/http/HttpClient">HttpClient</a>' | 1384 | type: '<a href="https://angular.io/api/common/http/HttpClient">HttpClient</a>' |
1385 | + }, | ||
1386 | + sanitizer: { | ||
1387 | + description: 'DomSanitizer Service<br>' + | ||
1388 | + 'See <a href="https://angular.io/api/platform-browser/DomSanitizer">DomSanitizer</a> for API reference.', | ||
1389 | + meta: 'service', | ||
1390 | + type: '<a href="https://angular.io/api/platform-browser/DomSanitizer">DomSanitizer</a>' | ||
1385 | } | 1391 | } |
1386 | } | 1392 | } |
@@ -579,6 +579,23 @@ export const widgetContextCompletions: TbEditorCompletions = { | @@ -579,6 +579,23 @@ export const widgetContextCompletions: TbEditorCompletions = { | ||
579 | } | 579 | } |
580 | ] | 580 | ] |
581 | }, | 581 | }, |
582 | + pushAndOpenState: { | ||
583 | + description: 'Navigate to new dashboard state and adding intermediate states.', | ||
584 | + meta: 'function', | ||
585 | + args: [ | ||
586 | + { | ||
587 | + name: 'id', | ||
588 | + description: 'An array state object of the target dashboard state.', | ||
589 | + type: 'Array <a href="https://github.com/thingsboard/thingsboard/blob/13e6b10b7ab830e64d31b99614a9d95a1a25928a/ui-ngx/src/app/core/api/widget-api.models.ts#L140">StateObject</a>', | ||
590 | + }, | ||
591 | + { | ||
592 | + name: 'openRightLayout', | ||
593 | + description: 'An optional boolean argument to force open right dashboard layout if present in mobile view mode.', | ||
594 | + type: 'boolean', | ||
595 | + optional: true | ||
596 | + } | ||
597 | + ] | ||
598 | + }, | ||
582 | updateState: { | 599 | updateState: { |
583 | description: 'Updates current dashboard state.', | 600 | description: 'Updates current dashboard state.', |
584 | meta: 'function', | 601 | meta: 'function', |