Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #424 - display device name in screens instead of device id #463

Merged
merged 1 commit into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<MudCard>
<MudCardHeader>
<CardHeaderContent>
<MudText Align="Align.Center" Typo="Typo.h5">@Device.DeviceID</MudText>
<MudText Typo="Typo.h5">@(string.IsNullOrEmpty(Device.DeviceName) ? Device.DeviceID : Device.DeviceName)</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@

<MudDialog>
<DialogContent>
<p>Delete @deviceID ?</p>
<br />
<p><i>Warning : this cannot be undone.</i></p>
<MudGrid>
<MudItem xs=12>
<MudText>
Delete @deviceName ?
</MudText>
</MudItem>
<MudItem xs=12>
<MudText><i>Warning : this cannot be undone.</i></MudText>
</MudItem>
</MudGrid>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">Cancel</MudButton>
Expand All @@ -19,6 +26,7 @@
@code {
[CascadingParameter] MudDialogInstance MudDialog { get; set; }
[Parameter] public string deviceID { get; set; }
[Parameter] public string deviceName { get; set; }

void Submit() => MudDialog.Close(DialogResult.Ok(true));
void Cancel() => MudDialog.Cancel();
Expand All @@ -30,17 +38,17 @@
private async Task DeleteDevice()
{
// var response = await Http.PostAsJsonAsync<DeviceListItem>($"Devices/delete", device);
var response = await Http.DeleteAsync($"api/Devices/{deviceID}");
var response = await Http.DeleteAsync($"api/devices/{deviceID}");

// Prompts a snack bar to inform if the action was successful
// TODO : Deal more effectively with error/success messages
if (!response.IsSuccessStatusCode)
{
Snackbar.Add($"Oh oh, something went wrong while deleting device {deviceID}... ", Severity.Error);
Snackbar.Add($"Oh oh, something went wrong while deleting device {deviceName}... ", Severity.Error);
return;
}

Snackbar.Add($"Device {deviceID} has been successfully deleted!", Severity.Success);
Snackbar.Add($"Device {deviceName} has been successfully deleted!", Severity.Success);
MudDialog.Close(DialogResult.Ok(true));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<MudCard>
<MudCardHeader>
<CardHeaderContent>
<MudText Typo="Typo.h5">@Device.DeviceID</MudText>
<MudText Typo="Typo.h5">@(string.IsNullOrEmpty(Device.DeviceName) ? Device.DeviceID : Device.DeviceName)</MudText>
</CardHeaderContent>
<CardHeaderActions>
@if (isLoaded && (!IsLoRa || !(Device is LoRaDeviceDetails)))
Expand Down Expand Up @@ -257,7 +257,7 @@
result.EnsureSuccessStatusCode();

// Prompts a snack bar to inform the action was successful
Snackbar.Add($"Device {Device.DeviceID} has been successfully updated!", Severity.Success);
Snackbar.Add($"Device {Device.DeviceName} has been successfully updated!", Severity.Success);

// Go back to the list of devices
NavManager.NavigateTo("devices");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,14 @@
{
var parameters = new DialogParameters();
parameters.Add("deviceID", device.DeviceID);
parameters.Add("deviceName", device.DeviceName);
var result = await DialogService.Show<DeleteDevicePage>("Confirm Deletion", parameters).Result;

if (result.Cancelled)
{
return;
}

Search();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@

<MudDialog>
<DialogContent>
<p>Delete @DeviceId ?</p>
<br />
<p><i>Warning : this cannot be undone.</i></p>
<MudGrid>
<MudItem xs=12>
<MudText>
Delete @DeviceId ?
</MudText>
</MudItem>
<MudItem xs=12>
<MudText><i>Warning : this cannot be undone.</i></MudText>
</MudItem>
</MudGrid>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">Cancel</MudButton>
Expand Down