Skip to content

Commit

Permalink
Feature: Update devices pagination to distinguish devices that have t…
Browse files Browse the repository at this point in the history
…elemetry #1641 (#1658)

* Update devices listing to distinguish devices that have telemetry #1641

* Fix unit test ShowDeviceTelemetry_Clicked_LoRaDeviceTelemetryDialogIsShown
  • Loading branch information
hocinehacherouf authored Dec 9, 2022
1 parent 343de2d commit a7b271f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
@if (Portal.IsLoRaSupported)
{
<MudTd DataLabel="Telemetry" Style="text-align: center">
@if (context.SupportLoRaFeatures)
@if (context.HasLoRaTelemetry)
{
<MudTooltip Text="See device telemetries">
<MudIconButton id="@($"show-device-telemetry-{@context.DeviceID}")" Icon="@Icons.Filled.ShowChart" Color="Color.Default" OnClick="@(() => ShowDeviceTelemetry(context))" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public async Task<PaginatedResult<DeviceListItem>> GetDevices(string searchText
StatusUpdatedTime = device.StatusUpdatedTime,
DeviceModelId = device.DeviceModelId,
SupportLoRaFeatures = device is LorawanDevice,
HasLoRaTelemetry = device is LorawanDevice && ((LorawanDevice) device).Telemetry.Any(),
Labels = device.Labels
.Union(device.DeviceModel.Labels)
.Select(x => new LabelDto
Expand Down
5 changes: 5 additions & 0 deletions src/AzureIoTHub.Portal.Shared/Models/v1.0/DeviceListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public class DeviceListItem
/// </summary>
public bool SupportLoRaFeatures { get; set; }

/// <summary>
/// A value indicating whether the device has telemetry.
/// </summary>
public bool HasLoRaTelemetry { get; set; }

/// <summary>
/// The device last status updated time.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public void ShowDeviceTelemetry_Clicked_LoRaDeviceTelemetryDialogIsShown()
service.GetDevices($"{this.apiBaseUrl}?pageNumber=0&pageSize=10&searchText=&searchStatus=&searchState=&orderBy=&modelId="))
.ReturnsAsync(new PaginationResult<DeviceListItem>
{
Items = new[] { new DeviceListItem { DeviceID = deviceId, SupportLoRaFeatures = true } }
Items = new[] { new DeviceListItem { DeviceID = deviceId, SupportLoRaFeatures = true, HasLoRaTelemetry = true } }
});

_ = this.mockDeviceClientService.Setup(service => service.GetAvailableLabels())
Expand Down

0 comments on commit a7b271f

Please sign in to comment.