Skip to content

Commit 57ff02f

Browse files
committed
Add removal confirmation to Performance Tweaks (#580)
* Add removal confirmation modal to Performance Tweaks Remove buttons now show a confirmation modal before proceeding, matching the deploy confirmation pattern. MongoDB SSD removal includes an extra warning about the UniFi Network restart. * Fix CS8604 null reference warnings in WAN speed attribution * Fix dark spinner inside buttons to use light color
1 parent 7916d65 commit 57ff02f

3 files changed

Lines changed: 69 additions & 6 deletions

File tree

src/NetworkOptimizer.Web/Components/Pages/PerformanceTweaks.razor

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
</button>
353353
@if (tweakStatus?.IsManuallyDeployed != true)
354354
{
355-
<button class="btn btn-sm btn-danger" @onclick="() => RemoveTweak(def.Id)" disabled="@(_removingTweakId == def.Id || _deployingTweakId == def.Id)">
355+
<button class="btn btn-sm btn-danger" @onclick="() => ShowRemoveConfirmation(def.Id)" disabled="@(_removingTweakId == def.Id || _deployingTweakId == def.Id)">
356356
@if (_removingTweakId == def.Id)
357357
{
358358
<span class="spinner spinner-sm"></span>
@@ -399,8 +399,16 @@
399399
<button class="btn btn-sm btn-secondary" @onclick="RefreshStatus" disabled="@_isLoading">
400400
Check Status
401401
</button>
402-
<button class="btn btn-sm btn-danger" @onclick="() => RemoveTweak(def.Id)" disabled="@(_deployingTweakId == def.Id)">
403-
Remove
402+
<button class="btn btn-sm btn-danger" @onclick="() => ShowRemoveConfirmation(def.Id)" disabled="@(_removingTweakId == def.Id || _deployingTweakId == def.Id)">
403+
@if (_removingTweakId == def.Id)
404+
{
405+
<span class="spinner spinner-sm"></span>
406+
<span>Removing...</span>
407+
}
408+
else
409+
{
410+
<span>Remove</span>
411+
}
404412
</button>
405413
}
406414
</div>
@@ -462,6 +470,34 @@
462470
</div>
463471
}
464472

473+
<!-- Remove Confirmation Modal -->
474+
@if (_showRemoveConfirm && _pendingRemoveTweakId != null)
475+
{
476+
var removeDef = _tweakDefs.FirstOrDefault(d => d.Id == _pendingRemoveTweakId);
477+
<div class="pt-modal-overlay" @onclick="CancelRemove">
478+
<div class="pt-modal" @onclick:stopPropagation="true">
479+
<div class="pt-modal-header">
480+
<h3>Confirm Removal</h3>
481+
</div>
482+
<div class="pt-modal-body">
483+
<p>Are you sure you want to remove <strong>@(removeDef?.Title ?? _pendingRemoveTweakId)</strong>? This will delete the boot script and reverse the tweak's changes on your gateway.</p>
484+
@if (_pendingRemoveTweakId == "mongodb-ssd")
485+
{
486+
<div class="alert alert-warning" style="margin-top: 0.75rem;">
487+
<strong>Note:</strong> Removal will briefly stop UniFi Network while migrating MongoDB data back from SSD to eMMC, then restart it.
488+
</div>
489+
}
490+
</div>
491+
<div class="pt-modal-footer">
492+
<button class="btn btn-secondary btn-sm" @onclick="CancelRemove">Cancel</button>
493+
<button class="btn btn-danger btn-sm" @onclick="ConfirmRemove">
494+
Confirm Remove
495+
</button>
496+
</div>
497+
</div>
498+
</div>
499+
}
500+
465501
<style>
466502
.pt-container {
467503
display: flex;
@@ -755,6 +791,8 @@
755791
private bool _confirmBackupDownloaded;
756792
private bool _confirmWarranty;
757793
private bool _confirmRisk;
794+
private bool _showRemoveConfirm;
795+
private string? _pendingRemoveTweakId;
758796
private bool _allConfirmed => _confirmBackup && _confirmBackupDownloaded && _confirmWarranty && _confirmRisk;
759797
private bool _canDeploy => _status?.UdmBootInstalled == true && _status?.FirmwareSupported == true;
760798
private List<string> _deploySteps = new();
@@ -873,6 +911,26 @@
873911
_pendingDeployTweakId = null;
874912
}
875913

914+
private void ShowRemoveConfirmation(string tweakId)
915+
{
916+
_pendingRemoveTweakId = tweakId;
917+
_showRemoveConfirm = true;
918+
}
919+
920+
private async Task ConfirmRemove()
921+
{
922+
_showRemoveConfirm = false;
923+
if (_pendingRemoveTweakId != null)
924+
await RemoveTweak(_pendingRemoveTweakId);
925+
_pendingRemoveTweakId = null;
926+
}
927+
928+
private void CancelRemove()
929+
{
930+
_showRemoveConfirm = false;
931+
_pendingRemoveTweakId = null;
932+
}
933+
876934
private async Task DeployTweak(string tweakId)
877935
{
878936
_deployingTweakId = tweakId;

src/NetworkOptimizer.Web/Services/UwnSpeedTestService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,16 @@ public UwnSpeedTestService(
276276
// configured speed, assume multiple WANs are bonded. The 25% margin
277277
// accounts for ISP overprovisioning and burst headroom.
278278
var maxSingleDown = wanNetworks!.Max(n => n.WanDownloadMbps ?? 0);
279-
var maxSingleUp = wanNetworks.Max(n => n.WanUploadMbps ?? 0);
279+
var maxSingleUp = wanNetworks!.Max(n => n.WanUploadMbps ?? 0);
280280
const double fudgeFactor = 1.25;
281281

282282
if (downloadMbps > maxSingleDown * fudgeFactor || uploadMbps > maxSingleUp * fudgeFactor)
283283
{
284-
var groups = wanNetworks
284+
var groups = wanNetworks!
285285
.Select(n => n.WanNetworkgroup ?? "WAN")
286286
.Distinct().OrderBy(g => g);
287287
result.WanNetworkGroup = string.Join("+", groups);
288-
var names = wanNetworks
288+
var names = wanNetworks!
289289
.Select(n => !string.IsNullOrEmpty(n.Name) ? n.Name : n.WanNetworkgroup ?? "WAN")
290290
.Distinct().OrderBy(n => n);
291291
result.WanName = string.Join(" + ", names);

src/NetworkOptimizer.Web/wwwroot/css/app.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4009,6 +4009,11 @@ select.form-control {
40094009
animation: spin 0.8s linear infinite;
40104010
}
40114011

4012+
.btn .spinner-sm {
4013+
border-color: rgba(255, 255, 255, 0.4);
4014+
border-top-color: white;
4015+
}
4016+
40124017
.status-offline {
40134018
color: var(--danger-color);
40144019
}

0 commit comments

Comments
 (0)