Browse Source

IoT Hub device packages: the duplicate step check leaves forms out, the step id comment says it is also the state key

pull/16647/head
dshvaika 3 weeks ago
parent
commit
a8bc01f224
  1. 3
      application/src/main/java/org/thingsboard/server/service/iot_hub/DeviceUpdateRequest.java
  2. 7
      ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts
  3. 3
      ui-ngx/src/app/shared/models/iot-hub/iot-hub-installed-item.models.ts

3
application/src/main/java/org/thingsboard/server/service/iot_hub/DeviceUpdateRequest.java

@ -38,7 +38,8 @@ public class DeviceUpdateRequest {
@Data @Data
public static class Step { public static class Step {
private String name; private String name;
// The package step's stable id, so that a next version can rename the step // The package step's stable id, so that a next version can rename the step. It is also the step's install state
// key when set, which the default converter update relies on to write the state back under the stored key
private String id; private String id;
// InstallStepType of the package: DEVICE_PROFILE, DEVICE, GATEWAY, GATEWAY_CONNECTOR, DASHBOARD, RULE_CHAIN, // InstallStepType of the package: DEVICE_PROFILE, DEVICE, GATEWAY, GATEWAY_CONNECTOR, DASHBOARD, RULE_CHAIN,
// UPLINK_CONVERTER, DOWNLINK_CONVERTER, INTEGRATION // UPLINK_CONVERTER, DOWNLINK_CONVERTER, INTEGRATION

7
ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts

@ -2615,11 +2615,14 @@ export class TbDeviceInstallDialogComponent extends DialogComponent<TbDeviceInst
return step.id ?? (step.type === InstallStepType.SHOW_FORM ? step.name : `${step.type}:${step.name}`); return step.id ?? (step.type === InstallStepType.SHOW_FORM ? step.name : `${step.type}:${step.name}`);
} }
/** A key two steps of the install method share, so one's install state would overwrite the other's; null when none. */ /**
* A key two entity steps of the install method share, so one's install state would overwrite the other's; null when
* none. Forms are left out: their values are merged, so a shared form key loses nothing.
*/
private duplicateStateKey(): string | null { private duplicateStateKey(): string | null {
const keys = new Set<string>(); const keys = new Set<string>();
for (const step of this.packageInfo.installSteps[this.selectedInstallMethod] ?? []) { for (const step of this.packageInfo.installSteps[this.selectedInstallMethod] ?? []) {
if (step.type !== InstallStepType.SHOW_FORM && !ENTITY_STEP_TYPES.has(step.type)) { if (!ENTITY_STEP_TYPES.has(step.type)) {
continue; continue;
} }
const key = this.stateKeyOf(step); const key = this.stateKeyOf(step);

3
ui-ngx/src/app/shared/models/iot-hub/iot-hub-installed-item.models.ts

@ -62,7 +62,8 @@ export interface DeviceUpdateStep {
serverAttributes?: any; serverAttributes?: any;
sharedAttributes?: any; sharedAttributes?: any;
resolution?: string; resolution?: string;
// The package step's stable id, so that a next version can rename the step // The package step's stable id, so that a next version can rename the step. When set it is also the step's install
// state key: the default converter update sends the stored key here to write the state back under it
id?: string; id?: string;
// INTEGRATION: the step's metadata entries, which a KEEP merges into the integration; null removes an entry // INTEGRATION: the step's metadata entries, which a KEEP merges into the integration; null removes an entry
metadata?: Record<string, string | null>; metadata?: Record<string, string | null>;

Loading…
Cancel
Save