Browse Source

Tenant, device profiles UI

pull/3477/head
Igor Kulikov 6 years ago
parent
commit
868234f13d
  1. 10
      ui-ngx/src/app/core/http/tenant.service.ts
  2. 4
      ui-ngx/src/app/modules/home/pages/device/device.component.ts
  3. 9
      ui-ngx/src/app/modules/home/pages/device/devices-table-config.resolver.ts
  4. 4
      ui-ngx/src/app/modules/home/pages/tenant/tenant-tabs.component.ts
  5. 24
      ui-ngx/src/app/modules/home/pages/tenant/tenant.component.ts
  6. 32
      ui-ngx/src/app/modules/home/pages/tenant/tenants-table-config.resolver.ts
  7. 2
      ui-ngx/src/app/shared/models/constants.ts
  8. 63
      ui-ngx/src/app/shared/models/device.models.ts
  9. 42
      ui-ngx/src/app/shared/models/entity-type.models.ts
  10. 6
      ui-ngx/src/app/shared/models/entity.models.ts
  11. 26
      ui-ngx/src/app/shared/models/id/device-profile-id.ts
  12. 2
      ui-ngx/src/app/shared/models/id/public-api.ts
  13. 26
      ui-ngx/src/app/shared/models/id/tenant-profile-id.ts
  14. 17
      ui-ngx/src/app/shared/models/query/query.models.ts
  15. 22
      ui-ngx/src/app/shared/models/tenant.model.ts
  16. 28
      ui-ngx/src/assets/locale/locale.constant-en_US.json

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

@ -20,7 +20,7 @@ import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { PageLink } from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
import { PageData } from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';
import { Tenant } from '@shared/models/tenant.model'; import { Tenant, TenantInfo } from '@shared/models/tenant.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -35,10 +35,18 @@ export class TenantService {
return this.http.get<PageData<Tenant>>(`/api/tenants${pageLink.toQuery()}`, defaultHttpOptionsFromConfig(config)); return this.http.get<PageData<Tenant>>(`/api/tenants${pageLink.toQuery()}`, defaultHttpOptionsFromConfig(config));
} }
public getTenantInfos(pageLink: PageLink, config?: RequestConfig): Observable<PageData<TenantInfo>> {
return this.http.get<PageData<TenantInfo>>(`/api/tenantInfos${pageLink.toQuery()}`, defaultHttpOptionsFromConfig(config));
}
public getTenant(tenantId: string, config?: RequestConfig): Observable<Tenant> { public getTenant(tenantId: string, config?: RequestConfig): Observable<Tenant> {
return this.http.get<Tenant>(`/api/tenant/${tenantId}`, defaultHttpOptionsFromConfig(config)); return this.http.get<Tenant>(`/api/tenant/${tenantId}`, defaultHttpOptionsFromConfig(config));
} }
public getTenantInfo(tenantId: string, config?: RequestConfig): Observable<TenantInfo> {
return this.http.get<TenantInfo>(`/api/tenant/info/${tenantId}`, defaultHttpOptionsFromConfig(config));
}
public saveTenant(tenant: Tenant, config?: RequestConfig): Observable<Tenant> { public saveTenant(tenant: Tenant, config?: RequestConfig): Observable<Tenant> {
return this.http.post<Tenant>('/api/tenant', tenant, defaultHttpOptionsFromConfig(config)); return this.http.post<Tenant>('/api/tenant', tenant, defaultHttpOptionsFromConfig(config));
} }

4
ui-ngx/src/app/modules/home/pages/device/device.component.ts

@ -70,8 +70,10 @@ export class DeviceComponent extends EntityComponent<DeviceInfo> {
return this.fb.group( return this.fb.group(
{ {
name: [entity ? entity.name : '', [Validators.required]], name: [entity ? entity.name : '', [Validators.required]],
deviceProfileId: [entity ? entity.deviceProfileId : null, [Validators.required]],
type: [entity ? entity.type : null, [Validators.required]], type: [entity ? entity.type : null, [Validators.required]],
label: [entity ? entity.label : ''], label: [entity ? entity.label : ''],
deviceData: [entity ? entity.deviceData : null, [Validators.required]],
additionalInfo: this.fb.group( additionalInfo: this.fb.group(
{ {
gateway: [entity && entity.additionalInfo ? entity.additionalInfo.gateway : false], gateway: [entity && entity.additionalInfo ? entity.additionalInfo.gateway : false],
@ -84,8 +86,10 @@ export class DeviceComponent extends EntityComponent<DeviceInfo> {
updateForm(entity: DeviceInfo) { updateForm(entity: DeviceInfo) {
this.entityForm.patchValue({name: entity.name}); this.entityForm.patchValue({name: entity.name});
this.entityForm.patchValue({deviceProfileId: entity.deviceProfileId});
this.entityForm.patchValue({type: entity.type}); this.entityForm.patchValue({type: entity.type});
this.entityForm.patchValue({label: entity.label}); this.entityForm.patchValue({label: entity.label});
this.entityForm.patchValue({deviceData: entity.deviceData});
this.entityForm.patchValue({additionalInfo: this.entityForm.patchValue({additionalInfo:
{gateway: entity.additionalInfo ? entity.additionalInfo.gateway : false}}); {gateway: entity.additionalInfo ? entity.additionalInfo.gateway : false}});
this.entityForm.patchValue({additionalInfo: {description: entity.additionalInfo ? entity.additionalInfo.description : ''}}); this.entityForm.patchValue({additionalInfo: {description: entity.additionalInfo ? entity.additionalInfo.description : ''}});

9
ui-ngx/src/app/modules/home/pages/device/devices-table-config.resolver.ts

@ -150,13 +150,14 @@ export class DevicesTableConfigResolver implements Resolve<EntityTableConfig<Dev
configureColumns(deviceScope: string): Array<EntityTableColumn<DeviceInfo>> { configureColumns(deviceScope: string): Array<EntityTableColumn<DeviceInfo>> {
const columns: Array<EntityTableColumn<DeviceInfo>> = [ const columns: Array<EntityTableColumn<DeviceInfo>> = [
new DateEntityTableColumn<DeviceInfo>('createdTime', 'common.created-time', this.datePipe, '150px'), new DateEntityTableColumn<DeviceInfo>('createdTime', 'common.created-time', this.datePipe, '150px'),
new EntityTableColumn<DeviceInfo>('name', 'device.name', '25%'), new EntityTableColumn<DeviceInfo>('name', 'device.name', '20%'),
new EntityTableColumn<DeviceInfo>('type', 'device.device-type', '25%'), new EntityTableColumn<DeviceInfo>('deviceProfileName', 'device-profile.device-profile', '20%'),
new EntityTableColumn<DeviceInfo>('label', 'device.label', '25%') new EntityTableColumn<DeviceInfo>('type', 'device.device-type', '20%'),
new EntityTableColumn<DeviceInfo>('label', 'device.label', '20%')
]; ];
if (deviceScope === 'tenant') { if (deviceScope === 'tenant') {
columns.push( columns.push(
new EntityTableColumn<DeviceInfo>('customerTitle', 'customer.customer', '25%'), new EntityTableColumn<DeviceInfo>('customerTitle', 'customer.customer', '20%'),
new EntityTableColumn<DeviceInfo>('customerIsPublic', 'device.public', '60px', new EntityTableColumn<DeviceInfo>('customerIsPublic', 'device.public', '60px',
entity => { entity => {
return checkBoxCell(entity.customerIsPublic); return checkBoxCell(entity.customerIsPublic);

4
ui-ngx/src/app/modules/home/pages/tenant/tenant-tabs.component.ts

@ -18,14 +18,14 @@ import { Component } from '@angular/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state'; import { AppState } from '@core/core.state';
import { EntityTabsComponent } from '../../components/entity/entity-tabs.component'; import { EntityTabsComponent } from '../../components/entity/entity-tabs.component';
import { Tenant } from '@shared/models/tenant.model'; import { TenantInfo } from '@shared/models/tenant.model';
@Component({ @Component({
selector: 'tb-tenant-tabs', selector: 'tb-tenant-tabs',
templateUrl: './tenant-tabs.component.html', templateUrl: './tenant-tabs.component.html',
styleUrls: [] styleUrls: []
}) })
export class TenantTabsComponent extends EntityTabsComponent<Tenant> { export class TenantTabsComponent extends EntityTabsComponent<TenantInfo> {
constructor(protected store: Store<AppState>) { constructor(protected store: Store<AppState>) {
super(store); super(store);

24
ui-ngx/src/app/modules/home/pages/tenant/tenant.component.ts

@ -18,7 +18,7 @@ import { Component, Inject } from '@angular/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state'; import { AppState } from '@core/core.state';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Tenant } from '@app/shared/models/tenant.model'; import { Tenant, TenantInfo } from '@app/shared/models/tenant.model';
import { ActionNotificationShow } from '@app/core/notification/notification.actions'; import { ActionNotificationShow } from '@app/core/notification/notification.actions';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { ContactBasedComponent } from '../../components/entity/contact-based.component'; import { ContactBasedComponent } from '../../components/entity/contact-based.component';
@ -29,12 +29,12 @@ import { EntityTableConfig } from '@home/models/entity/entities-table-config.mod
templateUrl: './tenant.component.html', templateUrl: './tenant.component.html',
styleUrls: ['./tenant.component.scss'] styleUrls: ['./tenant.component.scss']
}) })
export class TenantComponent extends ContactBasedComponent<Tenant> { export class TenantComponent extends ContactBasedComponent<TenantInfo> {
constructor(protected store: Store<AppState>, constructor(protected store: Store<AppState>,
protected translate: TranslateService, protected translate: TranslateService,
@Inject('entity') protected entityValue: Tenant, @Inject('entity') protected entityValue: TenantInfo,
@Inject('entitiesTableConfig') protected entitiesTableConfigValue: EntityTableConfig<Tenant>, @Inject('entitiesTableConfig') protected entitiesTableConfigValue: EntityTableConfig<TenantInfo>,
protected fb: FormBuilder) { protected fb: FormBuilder) {
super(store, fb, entityValue, entitiesTableConfigValue); super(store, fb, entityValue, entitiesTableConfigValue);
} }
@ -47,12 +47,13 @@ export class TenantComponent extends ContactBasedComponent<Tenant> {
} }
} }
buildEntityForm(entity: Tenant): FormGroup { buildEntityForm(entity: TenantInfo): FormGroup {
return this.fb.group( return this.fb.group(
{ {
title: [entity ? entity.title : '', [Validators.required]], title: [entity ? entity.title : '', [Validators.required]],
isolatedTbCore: [entity ? entity.isolatedTbCore : false, []], tenantProfileId: [entity ? entity.tenantProfileId : null, [Validators.required]],
isolatedTbRuleEngine: [entity ? entity.isolatedTbRuleEngine : false, []], // isolatedTbCore: [entity ? entity.isolatedTbCore : false, []],
// isolatedTbRuleEngine: [entity ? entity.isolatedTbRuleEngine : false, []],
additionalInfo: this.fb.group( additionalInfo: this.fb.group(
{ {
description: [entity && entity.additionalInfo ? entity.additionalInfo.description : ''] description: [entity && entity.additionalInfo ? entity.additionalInfo.description : '']
@ -64,8 +65,9 @@ export class TenantComponent extends ContactBasedComponent<Tenant> {
updateEntityForm(entity: Tenant) { updateEntityForm(entity: Tenant) {
this.entityForm.patchValue({title: entity.title}); this.entityForm.patchValue({title: entity.title});
this.entityForm.patchValue({isolatedTbCore: entity.isolatedTbCore}); this.entityForm.patchValue({tenantProfileId: entity.tenantProfileId});
this.entityForm.patchValue({isolatedTbRuleEngine: entity.isolatedTbRuleEngine}); // this.entityForm.patchValue({isolatedTbCore: entity.isolatedTbCore});
// this.entityForm.patchValue({isolatedTbRuleEngine: entity.isolatedTbRuleEngine});
this.entityForm.patchValue({additionalInfo: {description: entity.additionalInfo ? entity.additionalInfo.description : ''}}); this.entityForm.patchValue({additionalInfo: {description: entity.additionalInfo ? entity.additionalInfo.description : ''}});
} }
@ -73,10 +75,10 @@ export class TenantComponent extends ContactBasedComponent<Tenant> {
if (this.entityForm) { if (this.entityForm) {
if (this.isEditValue) { if (this.isEditValue) {
this.entityForm.enable({emitEvent: false}); this.entityForm.enable({emitEvent: false});
if (!this.isAdd) { /* if (!this.isAdd) {
this.entityForm.get('isolatedTbCore').disable({emitEvent: false}); this.entityForm.get('isolatedTbCore').disable({emitEvent: false});
this.entityForm.get('isolatedTbRuleEngine').disable({emitEvent: false}); this.entityForm.get('isolatedTbRuleEngine').disable({emitEvent: false});
} } */
} else { } else {
this.entityForm.disable({emitEvent: false}); this.entityForm.disable({emitEvent: false});
} }

32
ui-ngx/src/app/modules/home/pages/tenant/tenants-table-config.resolver.ts

@ -18,7 +18,7 @@ import { Injectable } from '@angular/core';
import { Resolve, Router } from '@angular/router'; import { Resolve, Router } from '@angular/router';
import { Tenant } from '@shared/models/tenant.model'; import { TenantInfo } from '@shared/models/tenant.model';
import { import {
DateEntityTableColumn, DateEntityTableColumn,
EntityTableColumn, EntityTableColumn,
@ -31,11 +31,12 @@ import { EntityType, entityTypeResources, entityTypeTranslations } from '@shared
import { TenantComponent } from '@modules/home/pages/tenant/tenant.component'; import { TenantComponent } from '@modules/home/pages/tenant/tenant.component';
import { EntityAction } from '@home/models/entity/entity-component.models'; import { EntityAction } from '@home/models/entity/entity-component.models';
import { TenantTabsComponent } from '@home/pages/tenant/tenant-tabs.component'; import { TenantTabsComponent } from '@home/pages/tenant/tenant-tabs.component';
import { mergeMap } from 'rxjs/operators';
@Injectable() @Injectable()
export class TenantsTableConfigResolver implements Resolve<EntityTableConfig<Tenant>> { export class TenantsTableConfigResolver implements Resolve<EntityTableConfig<TenantInfo>> {
private readonly config: EntityTableConfig<Tenant> = new EntityTableConfig<Tenant>(); private readonly config: EntityTableConfig<TenantInfo> = new EntityTableConfig<TenantInfo>();
constructor(private tenantService: TenantService, constructor(private tenantService: TenantService,
private translate: TranslateService, private translate: TranslateService,
@ -49,11 +50,12 @@ export class TenantsTableConfigResolver implements Resolve<EntityTableConfig<Ten
this.config.entityResources = entityTypeResources.get(EntityType.TENANT); this.config.entityResources = entityTypeResources.get(EntityType.TENANT);
this.config.columns.push( this.config.columns.push(
new DateEntityTableColumn<Tenant>('createdTime', 'common.created-time', this.datePipe, '150px'), new DateEntityTableColumn<TenantInfo>('createdTime', 'common.created-time', this.datePipe, '150px'),
new EntityTableColumn<Tenant>('title', 'tenant.title', '25%'), new EntityTableColumn<TenantInfo>('title', 'tenant-profile.tenant-profile', '20%'),
new EntityTableColumn<Tenant>('email', 'contact.email', '25%'), new EntityTableColumn<TenantInfo>('tenantProfileName', 'tenant.title', '20%'),
new EntityTableColumn<Tenant>('country', 'contact.country', '25%'), new EntityTableColumn<TenantInfo>('email', 'contact.email', '20%'),
new EntityTableColumn<Tenant>('city', 'contact.city', '25%') new EntityTableColumn<TenantInfo>('country', 'contact.country', '20%'),
new EntityTableColumn<TenantInfo>('city', 'contact.city', '20%')
); );
this.config.cellActionDescriptors.push( this.config.cellActionDescriptors.push(
@ -70,27 +72,29 @@ export class TenantsTableConfigResolver implements Resolve<EntityTableConfig<Ten
this.config.deleteEntitiesTitle = count => this.translate.instant('tenant.delete-tenants-title', {count}); this.config.deleteEntitiesTitle = count => this.translate.instant('tenant.delete-tenants-title', {count});
this.config.deleteEntitiesContent = () => this.translate.instant('tenant.delete-tenants-text'); this.config.deleteEntitiesContent = () => this.translate.instant('tenant.delete-tenants-text');
this.config.entitiesFetchFunction = pageLink => this.tenantService.getTenants(pageLink); this.config.entitiesFetchFunction = pageLink => this.tenantService.getTenantInfos(pageLink);
this.config.loadEntity = id => this.tenantService.getTenant(id.id); this.config.loadEntity = id => this.tenantService.getTenantInfo(id.id);
this.config.saveEntity = tenant => this.tenantService.saveTenant(tenant); this.config.saveEntity = tenant => this.tenantService.saveTenant(tenant).pipe(
mergeMap((savedTenant) => this.tenantService.getTenantInfo(savedTenant.id.id))
);
this.config.deleteEntity = id => this.tenantService.deleteTenant(id.id); this.config.deleteEntity = id => this.tenantService.deleteTenant(id.id);
this.config.onEntityAction = action => this.onTenantAction(action); this.config.onEntityAction = action => this.onTenantAction(action);
} }
resolve(): EntityTableConfig<Tenant> { resolve(): EntityTableConfig<TenantInfo> {
this.config.tableTitle = this.translate.instant('tenant.tenants'); this.config.tableTitle = this.translate.instant('tenant.tenants');
return this.config; return this.config;
} }
manageTenantAdmins($event: Event, tenant: Tenant) { manageTenantAdmins($event: Event, tenant: TenantInfo) {
if ($event) { if ($event) {
$event.stopPropagation(); $event.stopPropagation();
} }
this.router.navigateByUrl(`tenants/${tenant.id.id}/users`); this.router.navigateByUrl(`tenants/${tenant.id.id}/users`);
} }
onTenantAction(action: EntityAction<Tenant>): boolean { onTenantAction(action: EntityAction<TenantInfo>): boolean {
switch (action.action) { switch (action.action) {
case 'manageTenantAdmins': case 'manageTenantAdmins':
this.manageTenantAdmins(action.event, action.entity); this.manageTenantAdmins(action.event, action.entity);

2
ui-ngx/src/app/shared/models/constants.ts

@ -107,9 +107,11 @@ export const HelpLinks = {
ruleNodeRestApiCall: helpBaseUrl + '/docs/user-guide/rule-engine-2-0/external-nodes/#rest-api-call-node', ruleNodeRestApiCall: helpBaseUrl + '/docs/user-guide/rule-engine-2-0/external-nodes/#rest-api-call-node',
ruleNodeSendEmail: helpBaseUrl + '/docs/user-guide/rule-engine-2-0/external-nodes/#send-email-node', ruleNodeSendEmail: helpBaseUrl + '/docs/user-guide/rule-engine-2-0/external-nodes/#send-email-node',
tenants: helpBaseUrl + '/docs/user-guide/ui/tenants', tenants: helpBaseUrl + '/docs/user-guide/ui/tenants',
tenantProfiles: helpBaseUrl + '/docs/user-guide/ui/tenant-profiles',
customers: helpBaseUrl + '/docs/user-guide/ui/customers', customers: helpBaseUrl + '/docs/user-guide/ui/customers',
users: helpBaseUrl + '/docs/user-guide/ui/users', users: helpBaseUrl + '/docs/user-guide/ui/users',
devices: helpBaseUrl + '/docs/user-guide/ui/devices', devices: helpBaseUrl + '/docs/user-guide/ui/devices',
deviceProfiles: helpBaseUrl + '/docs/user-guide/ui/device-profiles',
assets: helpBaseUrl + '/docs/user-guide/ui/assets', assets: helpBaseUrl + '/docs/user-guide/ui/assets',
entityViews: helpBaseUrl + '/docs/user-guide/ui/entity-views', entityViews: helpBaseUrl + '/docs/user-guide/ui/entity-views',
entitiesImport: helpBaseUrl + '/docs/user-guide/bulk-provisioning', entitiesImport: helpBaseUrl + '/docs/user-guide/bulk-provisioning',

63
ui-ngx/src/app/shared/models/device.models.ts

@ -20,6 +20,62 @@ import { TenantId } from '@shared/models/id/tenant-id';
import { CustomerId } from '@shared/models/id/customer-id'; import { CustomerId } from '@shared/models/id/customer-id';
import { DeviceCredentialsId } from '@shared/models/id/device-credentials-id'; import { DeviceCredentialsId } from '@shared/models/id/device-credentials-id';
import { EntitySearchQuery } from '@shared/models/relation.models'; import { EntitySearchQuery } from '@shared/models/relation.models';
import { DeviceProfileId } from '@shared/models/id/device-profile-id';
import { RuleChainId } from '@shared/models/id/rule-chain-id';
import { EntityInfoData } from '@shared/models/entity.models';
export enum DeviceProfileType {
DEFAULT = 'DEFAULT',
LWM2M = 'LWM2M'
}
export interface DefaultDeviceProfileConfiguration {
[key: string]: any;
}
export interface Lwm2mDeviceProfileConfiguration {
[key: string]: any;
}
export type DeviceProfileConfigurations = DefaultDeviceProfileConfiguration & Lwm2mDeviceProfileConfiguration;
export interface DeviceProfileConfiguration extends DeviceProfileConfigurations {
type: DeviceProfileType;
}
export interface DeviceProfileData {
configuration: DeviceProfileConfiguration;
}
export interface DeviceProfile extends BaseData<DeviceProfileId> {
tenantId?: TenantId;
name: string;
description?: string;
isDefault: boolean;
type: DeviceProfileType;
defaultRuleChainId?: RuleChainId;
profileData: DeviceProfileData;
}
export interface DeviceProfileInfo extends EntityInfoData {
type: DeviceProfileType;
}
export interface DefaultDeviceConfiguration {
[key: string]: any;
}
export interface Lwm2mDeviceConfiguration {
[key: string]: any;
}
export type DeviceConfigurations = DefaultDeviceConfiguration & Lwm2mDeviceConfiguration;
export interface DeviceConfiguration extends DeviceConfigurations {
type: DeviceProfileType;
}
export interface DeviceData {
configuration: DeviceConfiguration;
}
export interface Device extends BaseData<DeviceId> { export interface Device extends BaseData<DeviceId> {
tenantId?: TenantId; tenantId?: TenantId;
@ -27,12 +83,15 @@ export interface Device extends BaseData<DeviceId> {
name: string; name: string;
type: string; type: string;
label: string; label: string;
deviceProfileId: DeviceProfileId;
deviceData: DeviceData;
additionalInfo?: any; additionalInfo?: any;
} }
export interface DeviceInfo extends Device { export interface DeviceInfo extends Device {
customerTitle: string; customerTitle: string;
customerIsPublic: boolean; customerIsPublic: boolean;
deviceProfileName: string;
} }
export enum DeviceCredentialsType { export enum DeviceCredentialsType {
@ -69,6 +128,6 @@ export enum ClaimResponse {
} }
export interface ClaimResult { export interface ClaimResult {
device: Device, device: Device;
response: ClaimResponse response: ClaimResponse;
} }

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

@ -35,11 +35,13 @@ import { BaseData, HasId } from '@shared/models/base-data';
export enum EntityType { export enum EntityType {
TENANT = 'TENANT', TENANT = 'TENANT',
TENANT_PROFILE = 'TENANT_PROFILE',
CUSTOMER = 'CUSTOMER', CUSTOMER = 'CUSTOMER',
USER = 'USER', USER = 'USER',
DASHBOARD = 'DASHBOARD', DASHBOARD = 'DASHBOARD',
ASSET = 'ASSET', ASSET = 'ASSET',
DEVICE = 'DEVICE', DEVICE = 'DEVICE',
DEVICE_PROFILE = 'DEVICE_PROFILE',
ALARM = 'ALARM', ALARM = 'ALARM',
RULE_CHAIN = 'RULE_CHAIN', RULE_CHAIN = 'RULE_CHAIN',
RULE_NODE = 'RULE_NODE', RULE_NODE = 'RULE_NODE',
@ -88,6 +90,20 @@ export const entityTypeTranslations = new Map<EntityType | AliasEntityType, Enti
selectedEntities: 'tenant.selected-tenants' selectedEntities: 'tenant.selected-tenants'
} }
], ],
[
EntityType.TENANT_PROFILE,
{
type: 'entity.type-tenant-profile',
typePlural: 'entity.type-tenant-profiles',
list: 'entity.list-of-tenant-profiles',
nameStartsWith: 'entity.tenant-profile-name-starts-with',
details: 'tenant-profile.tenant-profile-details',
add: 'tenant-profile.add',
noEntities: 'tenant-profile.no-tenant-profiles-text',
search: 'tenant-profile.search',
selectedEntities: 'tenant-profile.selected-tenant-profiles'
}
],
[ [
EntityType.CUSTOMER, EntityType.CUSTOMER,
{ {
@ -130,6 +146,20 @@ export const entityTypeTranslations = new Map<EntityType | AliasEntityType, Enti
selectedEntities: 'device.selected-devices' selectedEntities: 'device.selected-devices'
} }
], ],
[
EntityType.DEVICE_PROFILE,
{
type: 'entity.type-device-profile',
typePlural: 'entity.type-device-profiles',
list: 'entity.list-of-device-profiles',
nameStartsWith: 'entity.device-profile-name-starts-with',
details: 'device-profile.device-profile-details',
add: 'device-profile.add',
noEntities: 'device-profile.no-device-profiles-text',
search: 'device-profile.search',
selectedEntities: 'device-profile.selected-device-profiles'
}
],
[ [
EntityType.ASSET, EntityType.ASSET,
{ {
@ -257,6 +287,12 @@ export const entityTypeResources = new Map<EntityType, EntityTypeResource<BaseDa
helpLinkId: 'tenants' helpLinkId: 'tenants'
} }
], ],
[
EntityType.TENANT_PROFILE,
{
helpLinkId: 'tenantProfiles'
}
],
[ [
EntityType.CUSTOMER, EntityType.CUSTOMER,
{ {
@ -275,6 +311,12 @@ export const entityTypeResources = new Map<EntityType, EntityTypeResource<BaseDa
helpLinkId: 'devices' helpLinkId: 'devices'
} }
], ],
[
EntityType.DEVICE_PROFILE,
{
helpLinkId: 'deviceProfiles'
}
],
[ [
EntityType.ASSET, EntityType.ASSET,
{ {

6
ui-ngx/src/app/shared/models/entity.models.ts

@ -16,6 +16,7 @@
import { EntityType } from '@shared/models/entity-type.models'; import { EntityType } from '@shared/models/entity-type.models';
import { AttributeData } from './telemetry/telemetry.models'; import { AttributeData } from './telemetry/telemetry.models';
import { EntityId } from '@shared/models/id/entity-id';
export interface EntityInfo { export interface EntityInfo {
name?: string; name?: string;
@ -25,6 +26,11 @@ export interface EntityInfo {
entityDescription?: string; entityDescription?: string;
} }
export interface EntityInfoData {
id: EntityId;
name: string;
}
export interface ImportEntityData { export interface ImportEntityData {
name: string; name: string;
type: string; type: string;

26
ui-ngx/src/app/shared/models/id/device-profile-id.ts

@ -0,0 +1,26 @@
///
/// Copyright © 2016-2020 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { EntityId } from './entity-id';
import { EntityType } from '@shared/models/entity-type.models';
export class DeviceProfileId implements EntityId {
entityType = EntityType.DEVICE_PROFILE;
id: string;
constructor(id: string) {
this.id = id;
}
}

2
ui-ngx/src/app/shared/models/id/public-api.ts

@ -21,6 +21,7 @@ export * from './customer-id';
export * from './dashboard-id'; export * from './dashboard-id';
export * from './device-credentials-id'; export * from './device-credentials-id';
export * from './device-id'; export * from './device-id';
export * from './device-profile-id';
export * from './entity-id'; export * from './entity-id';
export * from './entity-view-id'; export * from './entity-view-id';
export * from './event-id'; export * from './event-id';
@ -28,6 +29,7 @@ export * from './has-uuid';
export * from './rule-chain-id'; export * from './rule-chain-id';
export * from './rule-node-id'; export * from './rule-node-id';
export * from './tenant-id'; export * from './tenant-id';
export * from './tenant-profile-id';
export * from './user-id'; export * from './user-id';
export * from './widget-type-id'; export * from './widget-type-id';
export * from './widgets-bundle-id'; export * from './widgets-bundle-id';

26
ui-ngx/src/app/shared/models/id/tenant-profile-id.ts

@ -0,0 +1,26 @@
///
/// Copyright © 2016-2020 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { EntityId } from './entity-id';
import { EntityType } from '@shared/models/entity-type.models';
export class TenantProfileId implements EntityId {
entityType = EntityType.TENANT_PROFILE;
id: string;
constructor(id: string) {
this.id = id;
}
}

17
ui-ngx/src/app/shared/models/query/query.models.ts

@ -50,7 +50,7 @@ export function entityKeyTypeToDataKeyType(entityKeyType: EntityKeyType): DataKe
case EntityKeyType.CLIENT_ATTRIBUTE: case EntityKeyType.CLIENT_ATTRIBUTE:
case EntityKeyType.SHARED_ATTRIBUTE: case EntityKeyType.SHARED_ATTRIBUTE:
case EntityKeyType.SERVER_ATTRIBUTE: case EntityKeyType.SERVER_ATTRIBUTE:
return DataKeyType.attribute return DataKeyType.attribute;
case EntityKeyType.TIME_SERIES: case EntityKeyType.TIME_SERIES:
return DataKeyType.timeseries; return DataKeyType.timeseries;
case EntityKeyType.ENTITY_FIELD: case EntityKeyType.ENTITY_FIELD:
@ -81,11 +81,10 @@ export interface EntityKey {
} }
export function dataKeyToEntityKey(dataKey: DataKey): EntityKey { export function dataKeyToEntityKey(dataKey: DataKey): EntityKey {
const entityKey: EntityKey = { return {
key: dataKey.name, key: dataKey.name,
type: dataKeyTypeToEntityKeyType(dataKey.type) type: dataKeyTypeToEntityKeyType(dataKey.type)
}; };
return entityKey;
} }
export enum EntityKeyValueType { export enum EntityKeyValueType {
@ -287,26 +286,26 @@ export interface FilterPredicateValue<T> {
} }
export interface StringFilterPredicate { export interface StringFilterPredicate {
type: FilterPredicateType.STRING, type: FilterPredicateType.STRING;
operation: StringOperation; operation: StringOperation;
value: FilterPredicateValue<string>; value: FilterPredicateValue<string>;
ignoreCase: boolean; ignoreCase: boolean;
} }
export interface NumericFilterPredicate { export interface NumericFilterPredicate {
type: FilterPredicateType.NUMERIC, type: FilterPredicateType.NUMERIC;
operation: NumericOperation; operation: NumericOperation;
value: FilterPredicateValue<number>; value: FilterPredicateValue<number>;
} }
export interface BooleanFilterPredicate { export interface BooleanFilterPredicate {
type: FilterPredicateType.BOOLEAN, type: FilterPredicateType.BOOLEAN;
operation: BooleanOperation; operation: BooleanOperation;
value: FilterPredicateValue<boolean>; value: FilterPredicateValue<boolean>;
} }
export interface BaseComplexFilterPredicate<T extends KeyFilterPredicate | KeyFilterPredicateInfo> { export interface BaseComplexFilterPredicate<T extends KeyFilterPredicate | KeyFilterPredicateInfo> {
type: FilterPredicateType.COMPLEX, type: FilterPredicateType.COMPLEX;
operation: ComplexOperation; operation: ComplexOperation;
predicates: Array<T>; predicates: Array<T>;
} }
@ -481,7 +480,7 @@ export interface Filter extends FilterInfo {
} }
export interface Filters { export interface Filters {
[id: string]: Filter [id: string]: Filter;
} }
export interface EntityFilter extends EntityFilters { export interface EntityFilter extends EntityFilters {
@ -535,7 +534,7 @@ export function createDefaultEntityDataPageLink(pageSize: number): EntityDataPag
}, },
direction: Direction.DESC direction: Direction.DESC
} }
} };
} }
export const singleEntityDataPageLink: EntityDataPageLink = createDefaultEntityDataPageLink(1); export const singleEntityDataPageLink: EntityDataPageLink = createDefaultEntityDataPageLink(1);

22
ui-ngx/src/app/shared/models/tenant.model.ts

@ -16,11 +16,29 @@
import { ContactBased } from '@shared/models/contact-based.model'; import { ContactBased } from '@shared/models/contact-based.model';
import { TenantId } from './id/tenant-id'; import { TenantId } from './id/tenant-id';
import { TenantProfileId } from '@shared/models/id/tenant-profile-id';
import { BaseData } from '@shared/models/base-data';
export interface TenantProfileData {
[key: string]: string;
}
export interface TenantProfile extends BaseData<TenantProfileId> {
name: string;
description: string;
isDefault: boolean;
isolatedTbCore: boolean;
isolatedTbRuleEngine: boolean;
profileData: TenantProfileData;
}
export interface Tenant extends ContactBased<TenantId> { export interface Tenant extends ContactBased<TenantId> {
title: string; title: string;
region: string; region: string;
isolatedTbCore: boolean; tenantProfileId: TenantProfileId;
isolatedTbRuleEngine: boolean;
additionalInfo?: any; additionalInfo?: any;
} }
export interface TenantInfo extends Tenant {
tenantProfileName: string;
}

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

@ -750,6 +750,15 @@
"search": "Search devices", "search": "Search devices",
"selected-devices": "{ count, plural, 1 {1 device} other {# devices} } selected" "selected-devices": "{ count, plural, 1 {1 device} other {# devices} } selected"
}, },
"device-profile": {
"device-profile": "Device profile",
"device-profiles": "Device profiles",
"add": "Add device profile",
"device-profile-details": "Device profile details",
"no-device-profiles-text": "No device profiles found",
"search": "Search device profiles",
"selected-device-profiles": "{ count, plural, 1 {1 device profile} other {# device profiles} } selected"
},
"dialog": { "dialog": {
"close": "Close dialog" "close": "Close dialog"
}, },
@ -806,6 +815,10 @@
"type-devices": "Devices", "type-devices": "Devices",
"list-of-devices": "{ count, plural, 1 {One device} other {List of # devices} }", "list-of-devices": "{ count, plural, 1 {One device} other {List of # devices} }",
"device-name-starts-with": "Devices whose names start with '{{prefix}}'", "device-name-starts-with": "Devices whose names start with '{{prefix}}'",
"type-device-profile": "Device profile",
"type-device-profiles": "Device profiles",
"list-of-device-profiles": "{ count, plural, 1 {One device profile} other {List of # device profiles} }",
"device-profile-name-starts-with": "Device profiles whose names start with '{{prefix}}'",
"type-asset": "Asset", "type-asset": "Asset",
"type-assets": "Assets", "type-assets": "Assets",
"list-of-assets": "{ count, plural, 1 {One asset} other {List of # assets} }", "list-of-assets": "{ count, plural, 1 {One asset} other {List of # assets} }",
@ -826,6 +839,10 @@
"type-tenants": "Tenants", "type-tenants": "Tenants",
"list-of-tenants": "{ count, plural, 1 {One tenant} other {List of # tenants} }", "list-of-tenants": "{ count, plural, 1 {One tenant} other {List of # tenants} }",
"tenant-name-starts-with": "Tenants whose names start with '{{prefix}}'", "tenant-name-starts-with": "Tenants whose names start with '{{prefix}}'",
"type-tenant-profile": "Tenant profile",
"type-tenant-profiles": "Tenant profiles",
"list-of-tenant-profiles": "{ count, plural, 1 {One tenant profile} other {List of # tenant profiles} }",
"tenant-profile-name-starts-with": "Tenant profiles whose names start with '{{prefix}}'",
"type-customer": "Customer", "type-customer": "Customer",
"type-customers": "Customers", "type-customers": "Customers",
"list-of-customers": "{ count, plural, 1 {One customer} other {List of # customers} }", "list-of-customers": "{ count, plural, 1 {One customer} other {List of # customers} }",
@ -1659,6 +1676,15 @@
"isolated-tb-core-details": "Requires separate microservice(s) per isolated Tenant", "isolated-tb-core-details": "Requires separate microservice(s) per isolated Tenant",
"isolated-tb-rule-engine-details": "Requires separate microservice(s) per isolated Tenant" "isolated-tb-rule-engine-details": "Requires separate microservice(s) per isolated Tenant"
}, },
"tenant-profile": {
"tenant-profile": "Tenant profile",
"tenant-profiles": "Tenant profiles",
"add": "Add tenant profile",
"tenant-profile-details": "Tenant profile details",
"no-tenant-profiles-text": "No tenant profiles found",
"search": "Search tenant profiles",
"selected-tenant-profiles": "{ count, plural, 1 {1 tenant profile} other {# tenant profiles} } selected"
},
"timeinterval": { "timeinterval": {
"seconds-interval": "{ seconds, plural, 1 {1 second} other {# seconds} }", "seconds-interval": "{ seconds, plural, 1 {1 second} other {# seconds} }",
"minutes-interval": "{ minutes, plural, 1 {1 minute} other {# minutes} }", "minutes-interval": "{ minutes, plural, 1 {1 minute} other {# minutes} }",
@ -2059,4 +2085,4 @@
"ka_GE": "ქართული" "ka_GE": "ქართული"
} }
} }
} },

Loading…
Cancel
Save