Skip to content

Commit 223697d

Browse files
committed
Allow deploying with all WANs disabled to remove SQM from gateway
When SQM is currently deployed and users uncheck both WANs, clicking Deploy now removes scripts/cron/monitor from the gateway while keeping the WAN configurations in the database. Previously this was blocked by validation requiring at least one enabled WAN.
1 parent a66ef64 commit 223697d

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

  • src/NetworkOptimizer.Web/Components/Pages

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,6 +2371,13 @@
23712371

23722372
if (!wan1Ready && !wan2Ready)
23732373
{
2374+
// If SQM is currently deployed, allow deploying with all disabled to remove scripts (disable without deleting configs)
2375+
if (deploymentStatus?.IsDeployed == true)
2376+
{
2377+
await DisableAllSqm();
2378+
return;
2379+
}
2380+
23742381
statusMessage = "Enable at least one WAN configuration and select its interface";
23752382
statusSuccess = false;
23762383
return;
@@ -2794,6 +2801,58 @@
27942801
}
27952802
}
27962803

2804+
private async Task DisableAllSqm()
2805+
{
2806+
isDeploying = true;
2807+
deploymentSteps.Clear();
2808+
deploymentWarnings.Clear();
2809+
statusMessage = null;
2810+
adjustmentMessage = null;
2811+
StateHasChanged();
2812+
2813+
try
2814+
{
2815+
deploymentSteps.Add("Disabling Adaptive SQM (keeping configurations)...");
2816+
await ScrollDeploymentLog();
2817+
2818+
var (success, steps) = await DeploymentService.RemoveAsync(includeTcMonitor: true);
2819+
deploymentSteps.AddRange(steps);
2820+
await ScrollDeploymentLog();
2821+
2822+
if (success)
2823+
{
2824+
// Save disabled state to database WITHOUT deleting configs
2825+
await SaveWanConfigsAsync();
2826+
deploymentSteps.Add("Configurations saved (disabled)");
2827+
await ScrollDeploymentLog();
2828+
2829+
// Update snapshots so change detection doesn't show stale "deployed" state
2830+
CaptureDeployedSnapshots();
2831+
2832+
statusMessage = "Adaptive SQM disabled. Configurations preserved - re-enable and deploy to resume.";
2833+
statusSuccess = true;
2834+
InvalidateCache();
2835+
await RefreshStatus();
2836+
}
2837+
else
2838+
{
2839+
statusMessage = "Failed to disable SQM scripts";
2840+
statusSuccess = false;
2841+
}
2842+
}
2843+
catch (Exception ex)
2844+
{
2845+
statusMessage = $"Error: {ex.Message}";
2846+
statusSuccess = false;
2847+
deploymentSteps.Add($"Error: {ex.Message}");
2848+
}
2849+
finally
2850+
{
2851+
isDeploying = false;
2852+
StateHasChanged();
2853+
}
2854+
}
2855+
27972856
private async Task TriggerSqmAdjustment(string wanName)
27982857
{
27992858
Logger.LogInformation("[SQM Adjust] Button clicked for {Wan}", wanName);

0 commit comments

Comments
 (0)