device.label
+
+
{{ 'device.is-gateway' | translate }}
diff --git a/ui-ngx/src/app/modules/home/pages/device/device.component.ts b/ui-ngx/src/app/modules/home/pages/device/device.component.ts
index 53a3eaa3db..cce82dca0f 100644
--- a/ui-ngx/src/app/modules/home/pages/device/device.component.ts
+++ b/ui-ngx/src/app/modules/home/pages/device/device.component.ts
@@ -19,7 +19,16 @@ import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { EntityComponent } from '../../components/entity/entity.component';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
-import { DeviceInfo } from '@shared/models/device.models';
+import {
+ createDeviceConfiguration,
+ createDeviceProfileConfiguration, createDeviceTransportConfiguration,
+ DeviceData,
+ DeviceInfo,
+ DeviceProfileData,
+ DeviceProfileInfo,
+ DeviceProfileType,
+ DeviceTransportType
+} from '@shared/models/device.models';
import { EntityType } from '@shared/models/entity-type.models';
import { NULL_UUID } from '@shared/models/id/has-uuid';
import { ActionNotificationShow } from '@core/notification/notification.actions';
@@ -126,4 +135,36 @@ export class DeviceComponent extends EntityComponent {
);
}
}
+
+ onDeviceProfileUpdated() {
+ this.entitiesTableConfig.table.updateData(false);
+ }
+
+ onDeviceProfileChanged(deviceProfile: DeviceProfileInfo) {
+ if (deviceProfile) {
+ const deviceProfileType: DeviceProfileType = deviceProfile.type;
+ const deviceTransportType: DeviceTransportType = deviceProfile.transportType;
+ let deviceData: DeviceData = this.entityForm.getRawValue().deviceData;
+ if (!deviceData) {
+ deviceData = {
+ configuration: createDeviceConfiguration(deviceProfileType),
+ transportConfiguration: createDeviceTransportConfiguration(deviceTransportType)
+ };
+ this.entityForm.patchValue({deviceData});
+ } else {
+ let changed = false;
+ if (deviceData.configuration.type !== deviceProfileType) {
+ deviceData.configuration = createDeviceConfiguration(deviceProfileType);
+ changed = true;
+ }
+ if (deviceData.transportConfiguration.type !== deviceTransportType) {
+ deviceData.transportConfiguration = createDeviceTransportConfiguration(deviceTransportType);
+ changed = true;
+ }
+ if (changed) {
+ this.entityForm.patchValue({deviceData});
+ }
+ }
+ }
+ }
}
diff --git a/ui-ngx/src/app/modules/home/pages/device/device.module.ts b/ui-ngx/src/app/modules/home/pages/device/device.module.ts
index c6e7c3bcc4..782b92322f 100644
--- a/ui-ngx/src/app/modules/home/pages/device/device.module.ts
+++ b/ui-ngx/src/app/modules/home/pages/device/device.module.ts
@@ -24,9 +24,19 @@ import { DeviceCredentialsDialogComponent } from '@modules/home/pages/device/dev
import { HomeDialogsModule } from '../../dialogs/home-dialogs.module';
import { HomeComponentsModule } from '@modules/home/components/home-components.module';
import { DeviceTabsComponent } from '@home/pages/device/device-tabs.component';
+import { DefaultDeviceConfigurationComponent } from './data/default-device-configuration.component';
+import { DeviceConfigurationComponent } from './data/device-configuration.component';
+import { DeviceDataComponent } from './data/device-data.component';
+import { DefaultDeviceTransportConfigurationComponent } from './data/default-device-transport-configuration.component';
+import { DeviceTransportConfigurationComponent } from './data/device-transport-configuration.component';
@NgModule({
declarations: [
+ DefaultDeviceConfigurationComponent,
+ DeviceConfigurationComponent,
+ DefaultDeviceTransportConfigurationComponent,
+ DeviceTransportConfigurationComponent,
+ DeviceDataComponent,
DeviceComponent,
DeviceTabsComponent,
DeviceTableHeaderComponent,
diff --git a/ui-ngx/src/app/modules/home/pages/device/devices-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/device/devices-table-config.resolver.ts
index d2bef0da4f..158230c659 100644
--- a/ui-ngx/src/app/modules/home/pages/device/devices-table-config.resolver.ts
+++ b/ui-ngx/src/app/modules/home/pages/device/devices-table-config.resolver.ts
@@ -86,6 +86,8 @@ export class DevicesTableConfigResolver implements Resolve this.translate.instant('device.delete-device-title', { deviceName: device.name });
this.config.deleteEntityContent = () => this.translate.instant('device.delete-device-text');
this.config.deleteEntitiesTitle = count => this.translate.instant('device.delete-devices-title', {count});
diff --git a/ui-ngx/src/app/shared/models/device.models.ts b/ui-ngx/src/app/shared/models/device.models.ts
index f393042dd0..3b80fd03ec 100644
--- a/ui-ngx/src/app/shared/models/device.models.ts
+++ b/ui-ngx/src/app/shared/models/device.models.ts
@@ -91,6 +91,19 @@ export function createDeviceProfileConfiguration(type: DeviceProfileType): Devic
return configuration;
}
+export function createDeviceConfiguration(type: DeviceProfileType): DeviceConfiguration {
+ let configuration: DeviceConfiguration = null;
+ if (type) {
+ switch (type) {
+ case DeviceProfileType.DEFAULT:
+ const defaultConfiguration: DefaultDeviceConfiguration = {};
+ configuration = {...defaultConfiguration, type: DeviceProfileType.DEFAULT};
+ break;
+ }
+ }
+ return configuration;
+}
+
export function createDeviceProfileTransportConfiguration(type: DeviceTransportType): DeviceProfileTransportConfiguration {
let transportConfiguration: DeviceProfileTransportConfiguration = null;
if (type) {
@@ -112,6 +125,27 @@ export function createDeviceProfileTransportConfiguration(type: DeviceTransportT
return transportConfiguration;
}
+export function createDeviceTransportConfiguration(type: DeviceTransportType): DeviceTransportConfiguration {
+ let transportConfiguration: DeviceTransportConfiguration = null;
+ if (type) {
+ switch (type) {
+ case DeviceTransportType.DEFAULT:
+ const defaultTransportConfiguration: DefaultDeviceTransportConfiguration = {};
+ transportConfiguration = {...defaultTransportConfiguration, type: DeviceTransportType.DEFAULT};
+ break;
+ case DeviceTransportType.MQTT:
+ const mqttTransportConfiguration: MqttDeviceTransportConfiguration = {};
+ transportConfiguration = {...mqttTransportConfiguration, type: DeviceTransportType.MQTT};
+ break;
+ case DeviceTransportType.LWM2M:
+ const lwm2mTransportConfiguration: Lwm2mDeviceTransportConfiguration = {};
+ transportConfiguration = {...lwm2mTransportConfiguration, type: DeviceTransportType.LWM2M};
+ break;
+ }
+ }
+ return transportConfiguration;
+}
+
export interface DeviceProfileData {
configuration: DeviceProfileConfiguration;
transportConfiguration: DeviceProfileTransportConfiguration;
@@ -121,7 +155,7 @@ export interface DeviceProfile extends BaseData {
tenantId?: TenantId;
name: string;
description?: string;
- default: boolean;
+ default?: boolean;
type: DeviceProfileType;
transportType: DeviceTransportType;
defaultRuleChainId?: RuleChainId;
diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json
index e6895befc0..8dbfb985b3 100644
--- a/ui-ngx/src/assets/locale/locale.constant-en_US.json
+++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json
@@ -748,7 +748,9 @@
"import": "Import device",
"device-file": "Device file",
"search": "Search devices",
- "selected-devices": "{ count, plural, 1 {1 device} other {# devices} } selected"
+ "selected-devices": "{ count, plural, 1 {1 device} other {# devices} } selected",
+ "device-configuration": "Device configuration",
+ "transport-configuration": "Transport configuration"
},
"device-profile": {
"device-profile": "Device profile",