-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add label feature #777 * Enable filtering devices by labels * Enable filtering edge devices by labels * Fix unit tests on DeviceListPage * Add missing override on lorawan controller * Add unit tests on LabelsEditor * Add unit tests on LabelRepository * Add unit test on GetAvailableLabels * Update unit test on GetDevices with custom filter * Remove labels init when null * Add unit tests on GetAvailableLabels methods on client services * Add unit tests on GetAvailableLabels on device controllers * Add unit test on GetAvailableLabels on edge device service * Update unit test on update edge device to cover delete labels * Update unit test on get edge devices to cover filter by labels * Update unit tests on edge model service * Add unit test on GetAvailableLabels on edge device controller * Add unit test on search device models on device list page * Add unit test on search device models on edge device list page * Render labels on unit test on edge device list page * Add unit test on search edge model on create edge device page
- Loading branch information
1 parent
0692b89
commit cf525a8
Showing
72 changed files
with
2,254 additions
and
134 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
src/AzureIoTHub.Portal.Client/Components/Commons/LabelsEditor.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
@using AzureIoTHub.Portal.Shared.Models.v10 | ||
|
||
<MudGrid> | ||
|
||
@if (ReadOnlyLabels != null && ReadOnlyLabels.Any()) | ||
{ | ||
<MudItem xs="12"> | ||
<MudText Typo="Typo.h6">Mandatory labels</MudText> | ||
</MudItem> | ||
<MudItem xs="12"> | ||
<MudChipSet ReadOnly="true"> | ||
@foreach (var label in ReadOnlyLabels) | ||
{ | ||
<MudChip Text="@label.Name" Color="Color.Primary" Style="@($"background-color: {label.Color};")" /> | ||
} | ||
</MudChipSet> | ||
</MudItem> | ||
} | ||
|
||
<MudItem xs="12"> | ||
<MudItem xs="12"> | ||
<MudText Typo="Typo.h6">Edit labels</MudText> | ||
</MudItem> | ||
<MudGrid> | ||
<MudItem xs="6"> | ||
<MudTextField T="string" @bind-Value="labelNameValue" Label="Name" Required="true" Variant="Variant.Text" /> | ||
</MudItem> | ||
<MudItem xs="5"> | ||
<MudColorPicker @bind-Text="labelColorValue" Label="Label color" DisableToolbar="false" PickerVariant="PickerVariant.Inline" Required="true" /> | ||
</MudItem> | ||
<MudItem xs="1"> | ||
<MudIconButton id="add-label" Icon="@Icons.Material.Filled.Add" aria-label="add-label" OnClick="@AddLabel" /> | ||
</MudItem> | ||
</MudGrid> | ||
</MudItem> | ||
<MudItem xs="12"> | ||
<MudChipSet AllClosable="true" OnClose="RemoveLabel"> | ||
@foreach (var label in Labels) | ||
{ | ||
<MudChip Text="@label.Name" Color="Color.Primary" Style="@($"background-color: {label.Color};")" /> | ||
} | ||
</MudChipSet> | ||
</MudItem> | ||
|
||
</MudGrid> | ||
|
||
@code { | ||
|
||
[Parameter] | ||
public List<LabelDto> ReadOnlyLabels { get; set; } = new(); | ||
|
||
[Parameter] | ||
public List<LabelDto> Labels { get; set; } = new(); | ||
|
||
private string labelNameValue; | ||
private string labelColorValue; | ||
|
||
public void AddLabel() | ||
{ | ||
if (string.IsNullOrWhiteSpace(labelNameValue) || | ||
string.IsNullOrEmpty(labelColorValue) || | ||
Labels.Any(dto => dto.Name.Equals(labelNameValue)) || | ||
(ReadOnlyLabels?.Any(label => label.Name.Equals(labelNameValue)) ?? false)) return; | ||
|
||
var labelToAdd = new LabelDto | ||
{ | ||
Name = labelNameValue, | ||
Color = labelColorValue | ||
}; | ||
|
||
Labels.Add(labelToAdd); | ||
|
||
labelNameValue = string.Empty; | ||
} | ||
|
||
public void RemoveLabel(MudChip chip) | ||
{ | ||
var labelToDelete = Labels.FirstOrDefault(dto => dto.Name.Equals(chip.Text)); | ||
|
||
if (labelToDelete == null) return; | ||
|
||
Labels.Remove(labelToDelete); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.