Skip to content

Commit

Permalink
Change Edge device
Browse files Browse the repository at this point in the history
  • Loading branch information
crib authored and kbeaugrand committed Oct 28, 2022
1 parent 093ba2d commit 6a0ed35
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/AzureIoTHub.Portal.Domain/Entities/EdgeDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class EdgeDevice : EntityBase
public string DeviceModelId { get; set; }

public int Version { get; set; }
public string ConnectionState { get; set; }


/// <summary>
/// <c>true</c> if this instance is enabled; otherwise, <c>false</c>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
Version = table.Column<int>(type: "integer", nullable: false),
IsEnabled = table.Column<bool>(type: "boolean", nullable: false),
Scope = table.Column<string>(type: "text", nullable: true),
ConnectionState = table.Column<string>(type: "text", nullable: true),
NbDevices = table.Column<int>(type: "integer", nullable: false),
NbModules = table.Column<int>(type: "integer", nullable: false)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<int>("Version")
.HasColumnType("integer");

b.Property<string>("ConnectionState")
.HasColumnType("text");

b.HasKey("Id");

b.ToTable("EdgeDevices");
Expand Down
3 changes: 3 additions & 0 deletions src/AzureIoTHub.Portal.Server/Mappers/EdgeDeviceProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public EdgeDeviceProfile()
_ = CreateMap<Twin, EdgeDevice>()
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.DeviceId))
.ForMember(dest => dest.Name, opts => opts.MapFrom(src => src.Tags["deviceName"]))
.ForMember(dest => dest.ConnectionState, opts => opts.MapFrom(src => src.ConnectionState.ToString()))
.ForMember(dest => dest.DeviceModelId, opts => opts.MapFrom(src => src.Tags["modelId"]))
.ForMember(dest => dest.Version, opts => opts.MapFrom(src => src.Version))
.ForMember(dest => dest.IsEnabled, opts => opts.MapFrom(src => src.Status == Microsoft.Azure.Devices.DeviceStatus.Enabled))
Expand All @@ -34,6 +35,7 @@ public EdgeDeviceProfile()
_ = CreateMap<EdgeDevice, IoTEdgeDevice>()
.ForMember(dest => dest.DeviceId, opts => opts.MapFrom(src => src.Id))
.ForMember(dest => dest.DeviceName, opts => opts.MapFrom(src => src.Name))
.ForMember(dest => dest.ConnectionState, opts => opts.MapFrom(src => src.ConnectionState))
.ForMember(dest => dest.ModelId, opts => opts.MapFrom(src => src.DeviceModelId))
.ForMember(dest => dest.Scope, opts => opts.MapFrom(src => src.Scope))
.ForMember(dest => dest.IsEnabled, opts => opts.MapFrom(src => src.IsEnabled))
Expand All @@ -46,6 +48,7 @@ public EdgeDeviceProfile()
.ForMember(dest => dest.Name, opts => opts.MapFrom(src => src.DeviceName))
.ForMember(dest => dest.DeviceModelId, opts => opts.MapFrom(src => src.ModelId))
.ForMember(dest => dest.Scope, opts => opts.MapFrom(src => src.Scope))
.ForMember(dest => dest.ConnectionState, opts => opts.MapFrom(src => src.ConnectionState))
.ForMember(dest => dest.IsEnabled, opts => opts.MapFrom(src => src.IsEnabled))
.ForMember(dest => dest.NbDevices, opts => opts.MapFrom(src => src.NbDevices))
.ForMember(dest => dest.NbModules, opts => opts.MapFrom(src => src.NbModules))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public async Task<IoTEdgeDevice> GetEdgeDevice(string edgeDeviceId)
deviceDto.ImageUrl = this.deviceModelImageManager.ComputeImageUri(deviceDto.ModelId);
deviceDto.Modules = DeviceHelper.RetrieveModuleList(deviceTwinWithModules);
deviceDto.RuntimeResponse = DeviceHelper.RetrieveRuntimeResponse(deviceTwinWithModules);
deviceDto.ConnectionState = deviceTwinWithModules.ConnectionState?.ToString();

deviceDto.Status = deviceTwinWithModules.Status?.ToString();
deviceDto.Tags = FilterDeviceTags(deviceDto);

Expand Down

0 comments on commit 6a0ed35

Please sign in to comment.