-
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 DPS connection on device detail page if not lora (#357)
- Loading branch information
1 parent
de96cc6
commit 1102df8
Showing
4 changed files
with
110 additions
and
7 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
src/AzureIoTHub.Portal/Client/Pages/Devices/ConnectionStringDialog.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,80 @@ | ||
@using Microsoft.AspNetCore.Authorization | ||
@using AzureIoTHub.Portal.Shared.Models.V10 | ||
|
||
@inject HttpClient Http | ||
@inject ISnackbar Snackbar | ||
|
||
<div class="ConnectionString-dialog"> | ||
<MudDialog> | ||
<DialogContent> | ||
@if (loading) | ||
{ | ||
<MudItem Class="custom-centered-container"> | ||
<MudProgressCircular Class="custom-centered-item" Color="Color.Default" Indeterminate="true" /> | ||
</MudItem> | ||
} | ||
else | ||
{ | ||
<MudCard Outlined="true"> | ||
<MudCardContent> | ||
<MudGrid> | ||
<MudItem xs="12"> | ||
<MudText Style="text-decoration:underline"><b>Service Endpoint</b></MudText> | ||
<MudTextField @bind-Value="@Credentials.ProvisioningEndpoint" Class="mt-0" Variant="Variant.Text" Margin="Margin.Dense" ReadOnly="true" /> | ||
</MudItem> | ||
<MudItem xs="12"> | ||
<MudText Style="text-decoration:underline"><b>Registation Scope ID</b></MudText> | ||
<MudTextField @bind-Value="@Credentials.ScopeID" Class="mt-0" Variant="Variant.Text" Margin="Margin.Dense" ReadOnly="true" /> | ||
</MudItem> | ||
<MudItem Class="mt-0" xs="12"> | ||
<MudText Style="text-decoration:underline"><b>Device Id</b></MudText> | ||
<MudTextField @bind-Value="@Credentials.RegistrationID" Class="mt-0" Variant="Variant.Text" Margin="Margin.Dense" ReadOnly="true" /> | ||
</MudItem> | ||
<MudItem Class="mt-0" xs="12"> | ||
<MudText Style="text-decoration:underline"><b>Symmetric Key</b></MudText> | ||
<MudTextField @bind-Value="@Credentials.SymmetricKey" Class="mt-0" Variant="Variant.Text" Margin="Margin.Dense" ReadOnly="true" /> | ||
</MudItem> | ||
</MudGrid> | ||
</MudCardContent> | ||
</MudCard> | ||
} | ||
</DialogContent> | ||
<DialogActions> | ||
<MudButton OnClick="Cancel">Cancel</MudButton> | ||
</DialogActions> | ||
</MudDialog> | ||
</div> | ||
|
||
@code { | ||
[CascadingParameter] MudDialogInstance MudDialog { get; set; } | ||
[Parameter] public string deviceId { get; set; } | ||
private EnrollmentCredentials Credentials; | ||
private bool loading = true; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
try | ||
{ | ||
await base.OnInitializedAsync(); | ||
|
||
Credentials = await this.Http.GetFromJsonAsync<EnrollmentCredentials>($"api/devices/{deviceId}/credentials"); | ||
loading = false; | ||
|
||
} | ||
catch (HttpRequestException e) | ||
{ | ||
if (e.StatusCode == System.Net.HttpStatusCode.NotFound) | ||
{ | ||
Snackbar.Add("Cannot obtain the connection string <br> because the enrollment group does not exist.", Severity.Error); | ||
} | ||
else | ||
{ | ||
Snackbar.Add($"Something went wrong.", Severity.Error); | ||
} | ||
|
||
MudDialog.Close(); | ||
} | ||
} | ||
|
||
void Cancel() => MudDialog.Cancel(); | ||
} |
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