Merge branch 'iotchina_dm' of https://zhang-hua:44a01cfb8c121ccee197d7464875a44e0907808c@github.com/Azure/azure-iot-remote-monitoring.git
This commit is contained in:
Коммит
eaa1df678f
|
@ -40,7 +40,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
|
||||
public async Task<IEnumerable<Filter>> GetRecentFiltersAsync(int max)
|
||||
{
|
||||
var filters = await _filterRepository.GetRecentFiltersAsync(max);
|
||||
var filters = await _filterRepository.GetRecentFiltersAsync(max, true);
|
||||
return filters.Select(filter => new Filter(filter));
|
||||
}
|
||||
|
||||
|
|
|
@ -120,12 +120,12 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
return (result.Status == TableStorageResponseStatus.Successful);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<DeviceListFilter>> GetRecentFiltersAsync(int Max = 20)
|
||||
public async Task<IEnumerable<DeviceListFilter>> GetRecentFiltersAsync(int Max = 20, bool excludeTemporary = true)
|
||||
{
|
||||
TableQuery<DeviceListFilterTableEntity> query = new TableQuery<DeviceListFilterTableEntity>();
|
||||
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))
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
/// Return recenty queries executed recently, sorted by timestamp.
|
||||
/// </summary>
|
||||
/// <returns>a set of queries</returns>
|
||||
Task<IEnumerable<DeviceListFilter>> GetRecentFiltersAsync(int Max=20);
|
||||
Task<IEnumerable<DeviceListFilter>> GetRecentFiltersAsync(int Max, bool excludeTemporary);
|
||||
|
||||
/// <summary>
|
||||
/// Delete the saved filter by name.
|
||||
|
|
|
@ -65,7 +65,6 @@
|
|||
<img src="/Content/img/column_delete.svg" data-bind="click: $parent.unCheckClause" />
|
||||
</div>
|
||||
</div>
|
||||
<a href="#" class="device_list_clause_clear" data-bind="visible: checkedClauses().length > 0, click: unCheckAllClauses">@Strings.ClearAll</a>
|
||||
<!-- /ko -->
|
||||
<!--ko if: isAdvanced() && advancedClause() -->
|
||||
<div class="device_list_clause" data-bind="attr: { title: advancedClause }">
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.UnitTests.Infras
|
|||
{
|
||||
filter.Clauses = null;
|
||||
}
|
||||
_deviceListFilterRepositoryMock.Setup(x => x.GetRecentFiltersAsync(It.IsAny<int>())).ReturnsAsync(filters.Take(3));
|
||||
_deviceListFilterRepositoryMock.Setup(x => x.GetRecentFiltersAsync(It.IsAny<int>(), It.IsAny<bool>())).ReturnsAsync(filters.Take(3));
|
||||
var ret = await _filterLogic.GetRecentFiltersAsync(3);
|
||||
Assert.Equal(3, ret.Count());
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче