Browse Source

UI for resources version control

pull/9542/head
ViacheslavKlimov 3 years ago
parent
commit
3d52cc9724
  1. 8
      ui-ngx/src/app/core/http/entity.service.ts
  2. 4
      ui-ngx/src/app/core/http/resource.service.ts
  3. 2
      ui-ngx/src/app/shared/models/entity-type.models.ts
  4. 4
      ui-ngx/src/app/shared/models/resource.models.ts
  5. 4
      ui-ngx/src/app/shared/models/vc.models.ts
  6. 2
      ui-ngx/src/assets/locale/locale.constant-en_US.json

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

@ -95,6 +95,7 @@ import { TenantProfileService } from '@core/http/tenant-profile.service';
import { NotificationType } from '@shared/models/notification.models'; import { NotificationType } from '@shared/models/notification.models';
import { UserId } from '@shared/models/id/user-id'; import { UserId } from '@shared/models/id/user-id';
import { AlarmService } from '@core/http/alarm.service'; import { AlarmService } from '@core/http/alarm.service';
import { ResourceService } from '@core/http/resource.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -123,7 +124,8 @@ export class EntityService {
private utils: UtilsService, private utils: UtilsService,
private queueService: QueueService, private queueService: QueueService,
private notificationService: NotificationService, private notificationService: NotificationService,
private alarmService: AlarmService private alarmService: AlarmService,
private resourceService: ResourceService
) { } ) { }
private getEntityObservable(entityType: EntityType, entityId: string, private getEntityObservable(entityType: EntityType, entityId: string,
@ -438,6 +440,10 @@ export class EntityService {
pageLink.sortOrder.property = 'name'; pageLink.sortOrder.property = 'name';
entitiesObservable = this.notificationService.getNotificationRules(pageLink, config); entitiesObservable = this.notificationService.getNotificationRules(pageLink, config);
break; break;
case EntityType.TB_RESOURCE:
pageLink.sortOrder.property = 'title';
entitiesObservable = this.resourceService.getTenantResources(pageLink, config);
break;
} }
return entitiesObservable; return entitiesObservable;
} }

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

@ -42,6 +42,10 @@ export class ResourceService {
return this.http.get<PageData<ResourceInfo>>(url, defaultHttpOptionsFromConfig(config)); return this.http.get<PageData<ResourceInfo>>(url, defaultHttpOptionsFromConfig(config));
} }
public getTenantResources(pageLink: PageLink, config?: RequestConfig): Observable<PageData<ResourceInfo>> {
return this.http.get<PageData<ResourceInfo>>(`/api/resource/tenant${pageLink.toQuery()}`, defaultHttpOptionsFromConfig(config));
}
public getResource(resourceId: string, config?: RequestConfig): Observable<Resource> { public getResource(resourceId: string, config?: RequestConfig): Observable<Resource> {
return this.http.get<Resource>(`/api/resource/${resourceId}`, defaultHttpOptionsFromConfig(config)); return this.http.get<Resource>(`/api/resource/${resourceId}`, defaultHttpOptionsFromConfig(config));
} }

2
ui-ngx/src/app/shared/models/entity-type.models.ts

@ -326,6 +326,8 @@ export const entityTypeTranslations = new Map<EntityType | AliasEntityType, Enti
EntityType.TB_RESOURCE, EntityType.TB_RESOURCE,
{ {
type: 'entity.type-tb-resource', type: 'entity.type-tb-resource',
typePlural: 'entity.type-tb-resources',
list: 'entity.list-of-tb-resources',
details: 'resource.resource-library-details', details: 'resource.resource-library-details',
add: 'resource.add', add: 'resource.add',
noEntities: 'resource.no-resource-text', noEntities: 'resource.no-resource-text',

4
ui-ngx/src/app/shared/models/resource.models.ts

@ -14,7 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { BaseData } from '@shared/models/base-data'; import { BaseData, ExportableEntity } from '@shared/models/base-data';
import { TenantId } from '@shared/models/id/tenant-id'; import { TenantId } from '@shared/models/id/tenant-id';
import { TbResourceId } from '@shared/models/id/tb-resource-id'; import { TbResourceId } from '@shared/models/id/tb-resource-id';
@ -55,7 +55,7 @@ export const ResourceTypeTranslationMap = new Map<ResourceType, string>(
] ]
); );
export interface ResourceInfo extends Omit<BaseData<TbResourceId>, 'name' | 'label'> { export interface ResourceInfo extends Omit<BaseData<TbResourceId>, 'name' | 'label'>, ExportableEntity<TbResourceId> {
tenantId?: TenantId; tenantId?: TenantId;
resourceKey?: string; resourceKey?: string;
title?: string; title?: string;

4
ui-ngx/src/app/shared/models/vc.models.ts

@ -32,6 +32,7 @@ export const exportableEntityTypes: Array<EntityType> = [
EntityType.RULE_CHAIN, EntityType.RULE_CHAIN,
EntityType.WIDGET_TYPE, EntityType.WIDGET_TYPE,
EntityType.WIDGETS_BUNDLE, EntityType.WIDGETS_BUNDLE,
EntityType.TB_RESOURCE,
EntityType.NOTIFICATION_TEMPLATE, EntityType.NOTIFICATION_TEMPLATE,
EntityType.NOTIFICATION_TARGET, EntityType.NOTIFICATION_TARGET,
EntityType.NOTIFICATION_RULE EntityType.NOTIFICATION_RULE
@ -40,7 +41,8 @@ export const exportableEntityTypes: Array<EntityType> = [
export const entityTypesWithoutRelatedData: Set<EntityType> = new Set([ export const entityTypesWithoutRelatedData: Set<EntityType> = new Set([
EntityType.NOTIFICATION_TEMPLATE, EntityType.NOTIFICATION_TEMPLATE,
EntityType.NOTIFICATION_TARGET, EntityType.NOTIFICATION_TARGET,
EntityType.NOTIFICATION_RULE EntityType.NOTIFICATION_RULE,
EntityType.TB_RESOURCE
]); ]);
export interface VersionCreateConfig { export interface VersionCreateConfig {

2
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -2198,6 +2198,8 @@
"list-of-edges": "{ count, plural, =1 {One edge} other {List of # edges} }", "list-of-edges": "{ count, plural, =1 {One edge} other {List of # edges} }",
"edge-name-starts-with": "Edges whose names start with '{{prefix}}'", "edge-name-starts-with": "Edges whose names start with '{{prefix}}'",
"type-tb-resource": "Resource", "type-tb-resource": "Resource",
"type-tb-resources": "Resources",
"list-of-tb-resources": "{ count, plural, =1 {One resource} other {List of # resources} }",
"type-ota-package": "OTA package", "type-ota-package": "OTA package",
"type-rpc": "RPC", "type-rpc": "RPC",
"type-queue": "Queue", "type-queue": "Queue",

Loading…
Cancel
Save