Browse Source

Merge pull request #14557 from mtsymbarov-del/fix/entities-endpoints

Added fetch by ids entities endpoints
pull/14573/head
Vladyslav Prykhodko 10 months ago
committed by GitHub
parent
commit
ae836800a6
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      ui-ngx/src/app/core/http/asset-profile.service.ts
  2. 4
      ui-ngx/src/app/core/http/customer.service.ts
  3. 5
      ui-ngx/src/app/core/http/dashboard.service.ts
  4. 5
      ui-ngx/src/app/core/http/device-profile.service.ts
  5. 5
      ui-ngx/src/app/core/http/entity-view.service.ts
  6. 36
      ui-ngx/src/app/core/http/entity.service.ts
  7. 5
      ui-ngx/src/app/core/http/rule-chain.service.ts
  8. 4
      ui-ngx/src/app/core/http/tenant.service.ts
  9. 4
      ui-ngx/src/app/core/http/user.service.ts
  10. 5
      ui-ngx/src/app/core/http/widget.service.ts

5
ui-ngx/src/app/core/http/asset-profile.service.ts

@ -38,6 +38,11 @@ export class AssetProfileService {
return this.http.get<PageData<AssetProfile>>(`/api/assetProfiles${pageLink.toQuery()}`, defaultHttpOptionsFromConfig(config));
}
public getAssetProfilesByIds(assetProfileIds: Array<string>, config?: RequestConfig): Observable<Array<AssetProfileInfo>> {
return this.http.get<Array<AssetProfileInfo>>(`/api/assetProfileInfos?assetProfileIds=${assetProfileIds.join(',')}`,
defaultHttpOptionsFromConfig(config));
}
public getAssetProfile(assetProfileId: string, config?: RequestConfig): Observable<AssetProfile> {
return this.http.get<AssetProfile>(`/api/assetProfile/${assetProfileId}`, defaultHttpOptionsFromConfig(config));
}

4
ui-ngx/src/app/core/http/customer.service.ts

@ -41,6 +41,10 @@ export class CustomerService {
return this.http.get<Customer>(`/api/customer/${customerId}`, defaultHttpOptionsFromConfig(config));
}
public getCustomersByIds(customerIds: Array<string>, config?: RequestConfig): Observable<Array<Customer>> {
return this.http.get<Array<Customer>>(`/api/customers?customerIds=${customerIds.join(',')}`, defaultHttpOptionsFromConfig(config));
}
public saveCustomer(customer: Customer, config?: RequestConfig): Observable<Customer>;
public saveCustomer(customer: Customer, saveParams: SaveEntityParams, config?: RequestConfig): Observable<Customer>;
public saveCustomer(customer: Customer, saveParamsOrConfig?: SaveEntityParams | RequestConfig, config?: RequestConfig): Observable<Customer> {

5
ui-ngx/src/app/core/http/dashboard.service.ts

@ -83,6 +83,11 @@ export class DashboardService {
return this.http.get<DashboardInfo>(`/api/dashboard/info/${dashboardId}`, defaultHttpOptionsFromConfig(config));
}
public getDashboards(dashboardIds: string[], config?: RequestConfig): Observable<Array<DashboardInfo>> {
return this.http.get<Array<DashboardInfo>>(`/api/dashboards?dashboardIds=${dashboardIds.join(',')}`,
defaultHttpOptionsFromConfig(config));
}
public saveDashboard(dashboard: Dashboard, config?: RequestConfig): Observable<Dashboard> {
return this.http.post<Dashboard>('/api/dashboard', dashboard, defaultHttpOptionsFromConfig(config));
}

5
ui-ngx/src/app/core/http/device-profile.service.ts

@ -50,6 +50,11 @@ export class DeviceProfileService {
return this.http.get<PageData<DeviceProfile>>(`/api/deviceProfiles${pageLink.toQuery()}`, defaultHttpOptionsFromConfig(config));
}
public getDeviceProfilesByIds(deviceProfileIds: Array<string>, config?: RequestConfig): Observable<Array<DeviceProfileInfo>> {
return this.http.get<Array<DeviceProfileInfo>>(`/api/deviceProfileInfos?deviceProfileIds=${deviceProfileIds.join(',')}`,
defaultHttpOptionsFromConfig(config));
}
public getDeviceProfile(deviceProfileId: string, config?: RequestConfig): Observable<DeviceProfile> {
return this.http.get<DeviceProfile>(`/api/deviceProfile/${deviceProfileId}`, defaultHttpOptionsFromConfig(config));
}

5
ui-ngx/src/app/core/http/entity-view.service.ts

@ -48,6 +48,11 @@ export class EntityViewService {
return this.http.get<EntityView>(`/api/entityView/${entityViewId}`, defaultHttpOptionsFromConfig(config));
}
public getEntityViews(entityViewIds: Array<string>, config?: RequestConfig): Observable<Array<EntityView>> {
return this.http.get<Array<EntityView>>(`/api/entityViews?entityViewIds=${entityViewIds.join(',')}`,
defaultHttpOptionsFromConfig(config));
}
public getEntityViewInfo(entityViewId: string, config?: RequestConfig): Observable<EntityViewInfo> {
return this.http.get<EntityViewInfo>(`/api/entityView/info/${entityViewId}`, defaultHttpOptionsFromConfig(config));
}

36
ui-ngx/src/app/core/http/entity.service.ts

@ -245,50 +245,34 @@ export class EntityService {
observable = this.edgeService.getEdges(entityIds, config);
break;
case EntityType.ENTITY_VIEW:
observable = this.getEntitiesByIdsObservable(
(id) => this.entityViewService.getEntityView(id, config),
entityIds);
observable = this.entityViewService.getEntityViews(entityIds, config);
break;
case EntityType.TENANT:
observable = this.getEntitiesByIdsObservable(
(id) => this.tenantService.getTenant(id, config),
entityIds);
observable = this.tenantService.getTenantsByIds(entityIds, config);
break;
case EntityType.CUSTOMER:
observable = this.getEntitiesByIdsObservable(
(id) => this.customerService.getCustomer(id, config),
entityIds);
observable = this.customerService.getCustomersByIds(entityIds, config);
break;
case EntityType.DASHBOARD:
observable = this.getEntitiesByIdsObservable(
(id) => this.dashboardService.getDashboardInfo(id, config),
entityIds);
observable = this.dashboardService.getDashboards(entityIds, config);
break;
case EntityType.USER:
observable = this.getEntitiesByIdsObservable(
(id) => this.userService.getUser(id, config),
entityIds);
observable = this.userService.getUsersByIds(entityIds, config);
break;
case EntityType.ALARM:
console.error('Get Alarm Entity is not implemented!');
break;
case EntityType.DEVICE_PROFILE:
observable = this.getEntitiesByIdsObservable(
(id) => this.deviceProfileService.getDeviceProfileInfo(id, config),
entityIds);
observable = this.deviceProfileService.getDeviceProfilesByIds(entityIds, config);
break;
case EntityType.TENANT_PROFILE:
observable = this.tenantProfileService.getTenantProfilesByIds(entityIds, config);
break;
case EntityType.ASSET_PROFILE:
observable = this.getEntitiesByIdsObservable(
(id) => this.assetProfileService.getAssetProfileInfo(id, config),
entityIds);
observable = this.assetProfileService.getAssetProfilesByIds(entityIds, config);
break;
case EntityType.WIDGETS_BUNDLE:
observable = this.getEntitiesByIdsObservable(
(id) => this.widgetService.getWidgetsBundle(id, config),
entityIds);
observable = this.widgetService.getWidgetsBundlesByIds(entityIds, config);
break;
case EntityType.NOTIFICATION_TARGET:
observable = this.notificationService.getNotificationTargetsByIds(entityIds, config);
@ -300,9 +284,7 @@ export class EntityService {
observable = this.oauth2Service.findTenantOAuth2ClientInfosByIds(entityIds, config);
break;
case EntityType.RULE_CHAIN:
observable = this.getEntitiesByIdsObservable(
(id) => this.ruleChainService.getRuleChain(id, config),
entityIds);
observable = this.ruleChainService.getRuleChainsByIds(entityIds, config);
break;
case EntityType.TB_RESOURCE:
observable = this.resourceService.getResourcesByIds(entityIds, config);

5
ui-ngx/src/app/core/http/rule-chain.service.ts

@ -68,6 +68,11 @@ export class RuleChainService {
defaultHttpOptionsFromConfig(config));
}
public getRuleChainsByIds(ruleChainIds: Array<string>, config?: RequestConfig): Observable<Array<RuleChain>> {
return this.http.get<Array<RuleChain>>(`/api/ruleChains?&ruleChainIds=${ruleChainIds.join(',')}`,
defaultHttpOptionsFromConfig(config));
}
public getRuleChain(ruleChainId: string, config?: RequestConfig): Observable<RuleChain> {
return this.http.get<RuleChain>(`/api/ruleChain/${ruleChainId}`, defaultHttpOptionsFromConfig(config));
}

4
ui-ngx/src/app/core/http/tenant.service.ts

@ -35,6 +35,10 @@ export class TenantService {
return this.http.get<PageData<Tenant>>(`/api/tenants${pageLink.toQuery()}`, defaultHttpOptionsFromConfig(config));
}
public getTenantsByIds(tenantIds: Array<string>, config?: RequestConfig): Observable<Array<Tenant>> {
return this.http.get<Array<Tenant>>(`/api/tenants?tenantIds=${tenantIds.join(',')}`, defaultHttpOptionsFromConfig(config));
}
public getTenantInfos(pageLink: PageLink, config?: RequestConfig): Observable<PageData<TenantInfo>> {
return this.http.get<PageData<TenantInfo>>(`/api/tenantInfos${pageLink.toQuery()}`, defaultHttpOptionsFromConfig(config));
}

4
ui-ngx/src/app/core/http/user.service.ts

@ -61,6 +61,10 @@ export class UserService {
return this.http.get<User>(`/api/user/${userId}`, defaultHttpOptionsFromConfig(config));
}
public getUsersByIds(userIds: Array<string>, config?: RequestConfig): Observable<Array<User>> {
return this.http.get<Array<User>>(`/api/users?userIds=${userIds.join(',')}`, defaultHttpOptionsFromConfig(config));
}
public saveUser(user: User, sendActivationMail: boolean = false,
config?: RequestConfig): Observable<User> {
let url = '/api/user';

5
ui-ngx/src/app/core/http/widget.service.ts

@ -331,6 +331,11 @@ export class WidgetService {
this.widgetsInfoInMemoryCache.delete(fullFqn);
}
public getWidgetsBundlesByIds(widgetsBundleIds: Array<string>, config?: RequestConfig): Observable<Array<WidgetsBundle>> {
return this.http.get<Array<WidgetsBundle>>(`/api/widgetsBundles?widgetsBundleIds=${widgetsBundleIds.join(',')}`,
defaultHttpOptionsFromConfig(config));
}
private loadWidgetsBundleCache(config?: RequestConfig): Observable<any> {
if (!this.allWidgetsBundles) {
if (!this.loadWidgetsBundleCacheSubject) {

Loading…
Cancel
Save