Browse Source
Merge pull request #6635 from devaskim/resource-service
[3.4] Add resource service to widget context.
pull/6682/head
Igor Kulikov
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
25 additions and
0 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
@ -38,6 +38,7 @@ import { EntityRelationService } from '@core/http/entity-relation.service';
import { EntityService } from '@core/http/entity.service' ;
import { DialogService } from '@core/services/dialog.service' ;
import { CustomDialogService } from '@home/components/widget/dialog/custom-dialog.service' ;
import { ResourceService } from '@core/http/resource.service' ;
import { DatePipe } from '@angular/common' ;
import { TranslateService } from '@ngx-translate/core' ;
import { DomSanitizer } from '@angular/platform-browser' ;
@ -76,6 +77,7 @@ export class DynamicWidgetComponent extends PageComponent implements IDynamicWid
this . ctx . entityService = $injector . get ( EntityService ) ;
this . ctx . dialogs = $injector . get ( DialogService ) ;
this . ctx . customDialog = $injector . get ( CustomDialogService ) ;
this . ctx . resourceService = $injector . get ( ResourceService ) ;
this . ctx . date = $injector . get ( DatePipe ) ;
this . ctx . translate = $injector . get ( TranslateService ) ;
this . ctx . http = $injector . get ( HttpClient ) ;
@ -36,6 +36,7 @@ import { BroadcastService } from '@core/services/broadcast.service';
import { ImportExportService } from '@home/components/import-export/import-export.service' ;
import { DeviceProfileService } from '@core/http/device-profile.service' ;
import { OtaPackageService } from '@core/http/ota-package.service' ;
import { ResourceService } from '@core/http/resource.service' ;
import { TwoFactorAuthenticationService } from '@core/http/two-factor-authentication.service' ;
export const ServicesMap = new Map < string , Type < any > > (
@ -61,6 +62,7 @@ export const ServicesMap = new Map<string, Type<any>>(
[ 'importExport' , ImportExportService ] ,
[ 'deviceProfileService' , DeviceProfileService ] ,
[ 'otaPackageService' , OtaPackageService ] ,
[ 'resourceService' , ResourceService ] ,
[ 'twoFactorAuthenticationService' , TwoFactorAuthenticationService ]
]
) ;
@ -72,6 +72,7 @@ import { EntityRelationService } from '@core/http/entity-relation.service';
import { EntityService } from '@core/http/entity.service' ;
import { DialogService } from '@core/services/dialog.service' ;
import { CustomDialogService } from '@home/components/widget/dialog/custom-dialog.service' ;
import { ResourceService } from '@core/http/resource.service' ;
import { DatePipe } from '@angular/common' ;
import { TranslateService } from '@ngx-translate/core' ;
import { PageLink } from '@shared/models/page/page-link' ;
@ -167,6 +168,7 @@ export class WidgetContext {
entityService : EntityService ;
dialogs : DialogService ;
customDialog : CustomDialogService ;
resourceService : ResourceService ;
date : DatePipe ;
translate : TranslateService ;
http : HttpClient ;
@ -100,6 +100,8 @@ export const importEntitiesResultInfoHref = '<a href="https://github.com/thingsb
export const customDialogComponentHref = '<a href="https://github.com/thingsboard/thingsboard/blob/master/ui-ngx/src/app/modules/home/components/widget/dialog/custom-dialog.component.ts#L48">CustomDialogComponent</a>' ;
export const resourceInfoHref = '<a https://github.com/thingsboard/thingsboard/blob/b033b51712244d08e0f5e0beb8be60c9f8fa4cd2/ui-ngx/src/app/shared/models/resource.models.ts#L51">Resource info</a>' ;
export const pageLinkArg : FunctionArg = {
name : 'pageLink' ,
type : '<a href="https://github.com/thingsboard/thingsboard/blob/13e6b10b7ab830e64d31b99614a9d95a1a25928a/ui-ngx/src/app/shared/models/page/page-link.ts#L68">PageLink</a>' ,
@ -1300,6 +1302,23 @@ export const serviceCompletions: TbEditorCompletions = {
} ,
}
} ,
resourceService : {
description : 'Resource Service API<br>' +
'See <a href="https://github.com/thingsboard/thingsboard/blob/b033b51712244d08e0f5e0beb8be60c9f8fa4cd2/ui-ngx/src/app/core/http/resource.service.ts#L29">ResourceService</a> for API reference.' ,
meta : 'service' ,
type : '<a href="https://github.com/thingsboard/thingsboard/blob/b033b51712244d08e0f5e0beb8be60c9f8fa4cd2/ui-ngx/src/app/core/http/resource.service.ts#L29">ResourceService</a>' ,
children : {
getResources : {
description : 'Find resources by search text' ,
meta : 'function' ,
args : [
pageLinkArg ,
requestConfigArg
] ,
return : observablePageDataReturnType ( resourceInfoHref )
} ,
}
} ,
dialogs : {
description : 'Dialogs Service API<br>' +
'See <a href="https://github.com/thingsboard/thingsboard/blob/13e6b10b7ab830e64d31b99614a9d95a1a25928a/ui-ngx/src/app/core/services/dialog.service.ts#L39">DialogService</a> for API reference.' ,