Browse Source
Merge pull request #3398 from vvlladd28/improvement/ctx/add-import-router
Added widget context import Router module
pull/3407/head
Igor Kulikov
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
13 additions and
1 deletions
-
ui-ngx/src/app/modules/home/components/widget/dynamic-widget.component.ts
-
ui-ngx/src/app/modules/home/models/services.map.ts
-
ui-ngx/src/app/modules/home/models/widget-component.models.ts
-
ui-ngx/src/app/shared/models/ace/service-completion.models.ts
|
|
|
@ -41,6 +41,7 @@ import { CustomDialogService } from '@home/components/widget/dialog/custom-dialo |
|
|
|
import { DatePipe } from '@angular/common'; |
|
|
|
import { TranslateService } from '@ngx-translate/core'; |
|
|
|
import { DomSanitizer } from '@angular/platform-browser'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
|
|
|
|
@Directive() |
|
|
|
export class DynamicWidgetComponent extends PageComponent implements IDynamicWidgetComponent, OnInit, OnDestroy { |
|
|
|
@ -77,6 +78,7 @@ export class DynamicWidgetComponent extends PageComponent implements IDynamicWid |
|
|
|
this.ctx.translate = $injector.get(TranslateService); |
|
|
|
this.ctx.http = $injector.get(HttpClient); |
|
|
|
this.ctx.sanitizer = $injector.get(DomSanitizer); |
|
|
|
this.ctx.router = $injector.get(Router); |
|
|
|
|
|
|
|
this.ctx.$scope = this; |
|
|
|
if (this.ctx.defaultSubscription) { |
|
|
|
|
|
|
|
@ -31,6 +31,7 @@ import { CustomerService } from '@core/http/customer.service'; |
|
|
|
import { DashboardService } from '@core/http/dashboard.service'; |
|
|
|
import { UserService } from '@core/http/user.service'; |
|
|
|
import { AlarmService } from '@core/http/alarm.service'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
|
|
|
|
export const ServicesMap = new Map<string, Type<any>>( |
|
|
|
[ |
|
|
|
@ -49,6 +50,7 @@ export const ServicesMap = new Map<string, Type<any>>( |
|
|
|
['date', DatePipe], |
|
|
|
['utils', UtilsService], |
|
|
|
['translate', TranslateService], |
|
|
|
['http', HttpClient] |
|
|
|
['http', HttpClient], |
|
|
|
['router', Router] |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
@ -76,6 +76,7 @@ import { TranslateService } from '@ngx-translate/core'; |
|
|
|
import { PageLink } from '@shared/models/page/page-link'; |
|
|
|
import { SortOrder } from '@shared/models/page/sort-order'; |
|
|
|
import { DomSanitizer } from '@angular/platform-browser'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
|
|
|
|
export interface IWidgetAction { |
|
|
|
name: string; |
|
|
|
@ -157,6 +158,7 @@ export class WidgetContext { |
|
|
|
translate: TranslateService; |
|
|
|
http: HttpClient; |
|
|
|
sanitizer: DomSanitizer; |
|
|
|
router: Router; |
|
|
|
|
|
|
|
private changeDetectorValue: ChangeDetectorRef; |
|
|
|
|
|
|
|
|
|
|
|
@ -1379,5 +1379,11 @@ export const serviceCompletions: TbEditorCompletions = { |
|
|
|
'See <a href="https://angular.io/api/platform-browser/DomSanitizer">DomSanitizer</a> for API reference.', |
|
|
|
meta: 'service', |
|
|
|
type: '<a href="https://angular.io/api/platform-browser/DomSanitizer">DomSanitizer</a>' |
|
|
|
}, |
|
|
|
router: { |
|
|
|
description: 'Router Service<br>' + |
|
|
|
'See <a href="https://angular.io/api/router/Router">Router</a> for API reference.', |
|
|
|
meta: 'service', |
|
|
|
type: '<a href="https://angular.io/api/router/Router">Router</a>' |
|
|
|
} |
|
|
|
}; |
|
|
|
|