From 49db51c6fe69a865bf4e10952c30944a967743fb Mon Sep 17 00:00:00 2001 From: Audrey Serra Date: Wed, 8 Dec 2021 16:13:42 +0100 Subject: [PATCH 1/4] Gestion des exceptions dans la fonction filtre du search panel. --- .../Client/Pages/Devices/DeviceListPage.razor | 49 ++++++++++++++----- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceListPage.razor b/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceListPage.razor index 18b7c432f..cd668cb8b 100644 --- a/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceListPage.razor +++ b/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceListPage.razor @@ -19,7 +19,7 @@ - + Status : @@ -79,6 +79,7 @@ + Search Reset @@ -168,7 +169,7 @@ @code { private DeviceListItem[] result; - private string searchString = ""; + private string searchID = ""; private string searchStatus = ""; private string searchState = ""; private string searchLocation = ""; @@ -205,7 +206,7 @@ /// private void Reset() { - searchString = ""; + searchID = ""; searchStatus = ""; searchState = ""; searchLocation = ""; @@ -234,23 +235,45 @@ } /// - /// Filter the list of devices, based on fields set in the search panel + /// Filters the list of devices, based on fields set in the search panel /// - /// - /// + /// Device represented in the current row + /// Boolean private bool FilterFunc(DeviceListItem item) { - bool flagName = string.IsNullOrWhiteSpace(searchString) || item.DeviceID.Contains(searchString, StringComparison.OrdinalIgnoreCase); - bool flagStatus = string.IsNullOrWhiteSpace(searchStatus) || item.IsEnabled.ToString().Contains(searchStatus, StringComparison.OrdinalIgnoreCase); - bool flagState = string.IsNullOrWhiteSpace(searchState) || item.IsConnected.ToString().Contains(searchState, StringComparison.OrdinalIgnoreCase); - bool flagLocation = string.IsNullOrWhiteSpace(searchLocation) || item.LocationCode.Contains(searchLocation, StringComparison.OrdinalIgnoreCase); - bool flagAppEUI = string.IsNullOrWhiteSpace(searchAppEUI) || item.AppEUI.Contains(searchAppEUI, StringComparison.OrdinalIgnoreCase); - bool flagAppKey = string.IsNullOrWhiteSpace(searchAppKey) || item.AppKey.Contains(searchAppKey, StringComparison.OrdinalIgnoreCase); + bool flagID = checkFlag(item.DeviceID, searchID); + bool flagStatus = checkFlag(item.IsEnabled.ToString(), searchStatus); + bool flagState = checkFlag(item.IsConnected.ToString(), searchState); + bool flagLocation = checkFlag(item.LocationCode, searchLocation); + bool flagAppEUI = checkFlag(item.AppEUI, searchAppEUI); + bool flagAppKey = checkFlag(item.AppKey, searchAppKey); // Current row is shown only if all the flags are true - if (flagName && flagStatus && flagState && flagLocation && flagAppEUI && flagAppKey) + if (flagID && flagStatus && flagState && flagLocation && flagAppEUI && flagAppKey) return true; return false; } + + /// + /// Checks if the specific device value matches the search criteria + /// + /// Device attribute being compared + /// Field value in the search panel + /// True if it matches of field is empty + private bool checkFlag(string deviceValue, string searchString) + { + bool flag; + try + { + flag = string.IsNullOrWhiteSpace(searchString) || deviceValue.Contains(searchString, StringComparison.OrdinalIgnoreCase); + } + + //May happen if the device attribute is set to null + catch (NullReferenceException) + { + flag = false; + } + return flag; + } } From fa47a8722afcf68b7dfad7be8336d4b742cec6a1 Mon Sep 17 00:00:00 2001 From: Audrey Serra Date: Wed, 8 Dec 2021 16:14:08 +0100 Subject: [PATCH 2/4] Rajout de LocationCode dans l'objet DeviceListItem --- src/AzureIoTHub.Portal/Server/Mappers/DeviceTwinMapper.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AzureIoTHub.Portal/Server/Mappers/DeviceTwinMapper.cs b/src/AzureIoTHub.Portal/Server/Mappers/DeviceTwinMapper.cs index 008966e5d..76b01f2b5 100644 --- a/src/AzureIoTHub.Portal/Server/Mappers/DeviceTwinMapper.cs +++ b/src/AzureIoTHub.Portal/Server/Mappers/DeviceTwinMapper.cs @@ -54,6 +54,7 @@ public DeviceListItem CreateDeviceListItem(Twin twin) ImageUrl = this.deviceModelImageManager.ComputeImageUri(Helpers.DeviceHelper.RetrieveTagValue(twin, nameof(DeviceDetails.ModelId))), IsConnected = twin.ConnectionState == DeviceConnectionState.Connected, IsEnabled = twin.Status == DeviceStatus.Enabled, + LocationCode = Helpers.DeviceHelper.RetrieveTagValue(twin, nameof(DeviceDetails.LocationCode)), LastActivityDate = twin.LastActivityTime.GetValueOrDefault(DateTime.MinValue) }; } From e92fba32ae5e0000f8a070fd9be836e4e8fd4458 Mon Sep 17 00:00:00 2001 From: Audrey Serra Date: Wed, 8 Dec 2021 17:23:17 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Suppression=20AppEUI=20et=20AppKey=20dans?= =?UTF-8?q?=20search=20panel=20Fonctionnel=20mais=20CSS=20=C3=A0=20revoir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Client/Pages/Devices/DeviceListPage.razor | 150 ++++++++++++------ 1 file changed, 100 insertions(+), 50 deletions(-) diff --git a/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceListPage.razor b/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceListPage.razor index cd668cb8b..4774efd16 100644 --- a/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceListPage.razor +++ b/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceListPage.razor @@ -16,12 +16,88 @@ Search panel + @* + + + + + + Status : + + + Enabled + + + Disabled + + + All + + + + Connection state : + + + Connected + + + Disconnected + + + All + + + + + + + + Location : + + + + + + + + AppEUI : + + + + + + + + AppKey : + + + + + + + + *@ - - + + + + DeviceID : + + + + + + + + Location : + + + + + - + Status : @@ -34,7 +110,7 @@ All - + Connection state : @@ -48,34 +124,8 @@ - - - - - Location : - - - - - - - - AppEUI : - - - - - - - - AppKey : - - - - - - + @@ -119,7 +169,7 @@ Delete - + @@ -135,9 +185,9 @@ { } - - - + + + @if (context.IsConnected) { @@ -146,20 +196,20 @@ { } - - @context.LastActivityDate - - - - - - - - - - - - + + @context.LastActivityDate + + + + + + + + + + + + } @@ -268,7 +318,7 @@ { flag = string.IsNullOrWhiteSpace(searchString) || deviceValue.Contains(searchString, StringComparison.OrdinalIgnoreCase); } - + //May happen if the device attribute is set to null catch (NullReferenceException) { From ea878ab61b946badff1e2f5de458e628d19548fc Mon Sep 17 00:00:00 2001 From: Audrey Serra Date: Wed, 8 Dec 2021 17:25:15 +0100 Subject: [PATCH 4/4] Suppression commentaires --- .../Client/Pages/Devices/DeviceListPage.razor | 61 ------------------- 1 file changed, 61 deletions(-) diff --git a/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceListPage.razor b/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceListPage.razor index 4774efd16..3cc4abdad 100644 --- a/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceListPage.razor +++ b/src/AzureIoTHub.Portal/Client/Pages/Devices/DeviceListPage.razor @@ -16,67 +16,6 @@ Search panel - @* - - - - - - Status : - - - Enabled - - - Disabled - - - All - - - - Connection state : - - - Connected - - - Disconnected - - - All - - - - - - - - Location : - - - - - - - - AppEUI : - - - - - - - - AppKey : - - - - - - - - *@