From 8c31466ffc38f35be194b37f339cb389ed4e1e3c Mon Sep 17 00:00:00 2001 From: Darren Chuang Date: Fri, 6 Jan 2017 16:29:41 +0800 Subject: [PATCH 1/2] Remove "Clear All" button --- DeviceAdministration/Web/Views/Device/Index.cshtml | 1 - 1 file changed, 1 deletion(-) diff --git a/DeviceAdministration/Web/Views/Device/Index.cshtml b/DeviceAdministration/Web/Views/Device/Index.cshtml index 5d84320b..bf03a4ce 100644 --- a/DeviceAdministration/Web/Views/Device/Index.cshtml +++ b/DeviceAdministration/Web/Views/Device/Index.cshtml @@ -65,7 +65,6 @@ - @Strings.ClearAll
From e0dfd6d88f88b10f3ebdc5502b6c80edc1cbcb8e Mon Sep 17 00:00:00 2001 From: Hua Zhang Date: Fri, 6 Jan 2017 16:42:14 +0800 Subject: [PATCH 2/2] Filter temporary device list filters from recent list Both GetRecentFiltersAsync and GetFilterListAsync need to be changed to support excluding temporary filters. --- .../Infrastructure/BusinessLogic/FilterLogic.cs | 2 +- .../Repository/DeviceListFilterRepository.cs | 4 ++-- .../Repository/IDeviceListFilterRepository.cs | 2 +- .../Infrastructure/DeviceListFilterRepositoryTests.cs | 7 +++++++ UnitTests/Infrastructure/FilterLogicTests.cs | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/DeviceAdministration/Infrastructure/BusinessLogic/FilterLogic.cs b/DeviceAdministration/Infrastructure/BusinessLogic/FilterLogic.cs index c58760d3..55211191 100644 --- a/DeviceAdministration/Infrastructure/BusinessLogic/FilterLogic.cs +++ b/DeviceAdministration/Infrastructure/BusinessLogic/FilterLogic.cs @@ -40,7 +40,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr public async Task> GetRecentFiltersAsync(int max) { - var filters = await _filterRepository.GetRecentFiltersAsync(max); + var filters = await _filterRepository.GetRecentFiltersAsync(max, true); return filters.Select(filter => new Filter(filter)); } diff --git a/DeviceAdministration/Infrastructure/Repository/DeviceListFilterRepository.cs b/DeviceAdministration/Infrastructure/Repository/DeviceListFilterRepository.cs index b4a4c076..8075aeb7 100644 --- a/DeviceAdministration/Infrastructure/Repository/DeviceListFilterRepository.cs +++ b/DeviceAdministration/Infrastructure/Repository/DeviceListFilterRepository.cs @@ -120,12 +120,12 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr return (result.Status == TableStorageResponseStatus.Successful); } - public async Task> GetRecentFiltersAsync(int Max = 20) + public async Task> GetRecentFiltersAsync(int Max = 20, bool excludeTemporary = true) { TableQuery query = new TableQuery(); var entities = await _filterTableStorageClient.ExecuteQueryAsync(query); // replace the timestamp of default filter with current time so that it is always sorted at top of filter list. - var ordered = entities.Select(e => + var ordered = entities.Where(e => !excludeTemporary || !e.IsTemporary).Select(e => { if (e.Id.Equals(DefaultDeviceListFilter.Id)) { diff --git a/DeviceAdministration/Infrastructure/Repository/IDeviceListFilterRepository.cs b/DeviceAdministration/Infrastructure/Repository/IDeviceListFilterRepository.cs index dbb83521..6d4ffa75 100644 --- a/DeviceAdministration/Infrastructure/Repository/IDeviceListFilterRepository.cs +++ b/DeviceAdministration/Infrastructure/Repository/IDeviceListFilterRepository.cs @@ -46,7 +46,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr /// Return recenty queries executed recently, sorted by timestamp. /// /// a set of queries - Task> GetRecentFiltersAsync(int Max=20); + Task> GetRecentFiltersAsync(int Max, bool excludeTemporary); /// /// Delete the saved filter by name. diff --git a/UnitTests/Infrastructure/DeviceListFilterRepositoryTests.cs b/UnitTests/Infrastructure/DeviceListFilterRepositoryTests.cs index 6f3b4194..73cd4e16 100644 --- a/UnitTests/Infrastructure/DeviceListFilterRepositoryTests.cs +++ b/UnitTests/Infrastructure/DeviceListFilterRepositoryTests.cs @@ -241,6 +241,13 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infras var expectedNams = tableEntities.OrderByDescending(e => e.Timestamp).Take(max).Select(e => e.Name).ToArray(); Assert.Equal(max, ret.Count()); Assert.Equal(expectedNams, ret.Select(e => e.Name).ToArray()); + + filters.Take(max).All(f => f.IsTemporary = true); + tableEntities = filters.Select(f => new DeviceListFilterTableEntity(f)); + ret = await deviceListFilterRepository.GetRecentFiltersAsync(max, false); + Assert.Equal(max, ret.Count()); + ret = await deviceListFilterRepository.GetRecentFiltersAsync(max, true); + Assert.Equal(40 - max, ret.Count()); } [Fact] diff --git a/UnitTests/Infrastructure/FilterLogicTests.cs b/UnitTests/Infrastructure/FilterLogicTests.cs index 20860df7..b0b29ecb 100644 --- a/UnitTests/Infrastructure/FilterLogicTests.cs +++ b/UnitTests/Infrastructure/FilterLogicTests.cs @@ -55,7 +55,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infras { filter.Clauses = null; } - _deviceListFilterRepositoryMock.Setup(x => x.GetRecentFiltersAsync(It.IsAny())).ReturnsAsync(filters.Take(3)); + _deviceListFilterRepositoryMock.Setup(x => x.GetRecentFiltersAsync(It.IsAny(), It.IsAny())).ReturnsAsync(filters.Take(3)); var ret = await _filterLogic.GetRecentFiltersAsync(3); Assert.Equal(3, ret.Count()); }