Skip to content

Commit

Permalink
Merge create and edit device screen (#1992)
Browse files Browse the repository at this point in the history
* merge create and edit device screen

* fix unit tests

* update unit tests

* fix solution project

* update unit tests

* update unit tests

* update unit tests

* update unit tests

* update unit tests

* update unit tests

---------

Co-authored-by: GuillaumeM <mourlonguillaume@gmail.com>
  • Loading branch information
kbeaugrand and GuillaumeM-2ISA committed Jun 22, 2023
1 parent 44aa2f8 commit 24df33c
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 1,432 deletions.
102 changes: 51 additions & 51 deletions src/IoTHub.Portal.Client/Components/Devices/EditDevice.razor
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,18 @@
{
<MudAutocomplete T="IDeviceModel"
id="@nameof(DeviceDetails.ModelId)"
@bind-Value="DeviceModel"
SearchFunc="@Search"
Label="Model*"
Dense=true
For=@(() => this.DeviceModel)
Variant="Variant.Outlined"
ToStringFunc="@(x => x?.Name)"
ResetValueOnEmptyText=true
Immediate=true
Clearable=true
CoerceText=true
CoerceValue=false>
@bind-Value="DeviceModel"
SearchFunc="@Search"
Label="Model*"
Dense=true
For=@(() => this.DeviceModel)
Variant="Variant.Outlined"
ToStringFunc="@(x => x?.Name)"
ResetValueOnEmptyText=true
Immediate=true
Clearable=true
CoerceText=true
CoerceValue=false>
<ItemTemplate>
@context.Name
<MudText Typo="Typo.subtitle1" Class="mud-input-helper-text">
Expand All @@ -136,22 +136,22 @@
{
<MudTextField @bind-Value="@Device.DeviceID"
id=@nameof(LoRaDeviceDetails.DeviceID)
Label="Device ID / DevEUI"
Variant="Variant.Outlined"
Validation=@(loraValidator.ValidateValue)
For="@(()=> Device.DeviceID)"
Mask="@maskLoRaDeviceID"
HelperText="Device EUI must contain 16 hexadecimal characters (numbers from 0 to 9 and/or letters from A to F)" />
Label="Device ID / DevEUI"
Variant="Variant.Outlined"
Validation=@(loraValidator.ValidateValue)
For="@(()=> Device.DeviceID)"
Mask="@maskLoRaDeviceID"
HelperText="Device EUI must contain 16 hexadecimal characters (numbers from 0 to 9 and/or letters from A to F)" />
}
else
{
<MudTextField @bind-Value="@Device.DeviceID"
id=@nameof(DeviceDetails.DeviceID)
Label="Device ID"
Variant="Variant.Outlined"
Validation=@(standardValidator.ValidateValue)
For="@(()=> Device.DeviceID)"
HelperText="The device identifier should be of ASCII 7-bit alphanumeric characters plus certain special characters" />
Label="Device ID"
Variant="Variant.Outlined"
Validation=@(standardValidator.ValidateValue)
For="@(()=> Device.DeviceID)"
HelperText="The device identifier should be of ASCII 7-bit alphanumeric characters plus certain special characters" />
}
</MudItem>
}
Expand All @@ -160,12 +160,12 @@
<MudItem xs="12" md="6">
<MudTextField @bind-Value="@Device.DeviceID"
id=@nameof(DeviceDetails.DeviceID)
Label="Device ID"
Variant="Variant.Outlined"
For="@(()=> Device.DeviceID)"
Required="true"
ReadOnly="true"
HelperText="DeviceID must contain 16 hexadecimal characters (numbers from 0 to 9 and/or letters from A to F)" />
Label="Device ID"
Variant="Variant.Outlined"
For="@(()=> Device.DeviceID)"
Required="true"
ReadOnly="true"
HelperText="DeviceID must contain 16 hexadecimal characters (numbers from 0 to 9 and/or letters from A to F)" />
</MudItem>
}

Expand Down Expand Up @@ -217,8 +217,8 @@
{
<MudItem xs="12" md="6">
<MudTextField @bind-Value="Device.Tags[tag.Name]" Label="@tag.Label"
Required="@tag.Required"
Variant="Variant.Outlined" />
Required="@tag.Required"
Variant="Variant.Outlined" />
</MudItem>
}
else if (context.Equals(CreateEditMode.Edit))
Expand All @@ -229,8 +229,8 @@
Device.Tags.Add(tag.Name, "");
}
<MudTextField @bind-Value="Device.Tags[tag.Name]" Label="@tag.Label"
Required="@tag.Required"
Variant="Variant.Outlined" />
Required="@tag.Required"
Variant="Variant.Outlined" />
</MudItem>
}
}
Expand Down Expand Up @@ -280,37 +280,37 @@
case DevicePropertyType.Double:
<MudItem xs="12" md="4">
<MudTextField @bind-Value="item.Value"
Label="@item.DisplayName"
Variant="Variant.Outlined"
Validation=@((string c) => string.IsNullOrEmpty(c) || double.TryParse(c, out var result))
Clearable="true" />
Label="@item.DisplayName"
Variant="Variant.Outlined"
Validation=@((string c) => string.IsNullOrEmpty(c) || double.TryParse(c, out var result))
Clearable="true" />
</MudItem>
break;
case DevicePropertyType.Float:
<MudItem xs="12" md="4">
<MudTextField @bind-Value="item.Value"
Label="@item.DisplayName"
Variant="Variant.Outlined"
Validation=@((string c) => string.IsNullOrEmpty(c) || float.TryParse(c, out var result))
Clearable="true" />
Label="@item.DisplayName"
Variant="Variant.Outlined"
Validation=@((string c) => string.IsNullOrEmpty(c) || float.TryParse(c, out var result))
Clearable="true" />
</MudItem>
break;
case DevicePropertyType.Integer:
<MudItem xs="12" md="4">
<MudTextField @bind-Value="item.Value"
Label="@item.DisplayName"
Variant="Variant.Outlined"
Validation=@((string c) => string.IsNullOrEmpty(c) || int.TryParse(c, out var result))
Clearable="true" />
Label="@item.DisplayName"
Variant="Variant.Outlined"
Validation=@((string c) => string.IsNullOrEmpty(c) || int.TryParse(c, out var result))
Clearable="true" />
</MudItem>
break;
case DevicePropertyType.Long:
<MudItem xs="12" md="4">
<MudTextField @bind-Value="item.Value"
Label="@item.DisplayName"
Variant="Variant.Outlined"
Validation=@((string c) => string.IsNullOrEmpty(c) || long.TryParse(c, out var result))
Clearable="true" />
Label="@item.DisplayName"
Variant="Variant.Outlined"
Validation=@((string c) => string.IsNullOrEmpty(c) || long.TryParse(c, out var result))
Clearable="true" />
</MudItem>
break;
case DevicePropertyType.String:
Expand Down Expand Up @@ -715,9 +715,9 @@
PageNumber = 0,
PageSize = 100,
OrderBy = new string[]
{
{
string.Empty
}
}
};
return (await DeviceModelsClientService.GetDeviceModels(filter)).Items.ToList<IDeviceModel>();
}
Expand Down
Loading

0 comments on commit 24df33c

Please sign in to comment.