Add resource service to widget context.

This commit is contained in:
devaskim 2022-06-03 23:06:34 +05:00
parent 19a953428e
commit 9669da0442
4 changed files with 26 additions and 1 deletions

View File

@ -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);

View File

@ -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';
export const ServicesMap = new Map<string, Type<any>>(
[
@ -59,6 +60,7 @@ export const ServicesMap = new Map<string, Type<any>>(
['router', Router],
['importExport', ImportExportService],
['deviceProfileService', DeviceProfileService],
['otaPackageService', OtaPackageService]
['otaPackageService', OtaPackageService],
['resourceService', ResourceService]
]
);

View File

@ -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';
@ -168,6 +169,7 @@ export class WidgetContext {
entityService: EntityService;
dialogs: DialogService;
customDialog: CustomDialogService;
resourceService: ResourceService;
date: DatePipe;
translate: TranslateService;
http: HttpClient;

View File

@ -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.',