-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathPerformanceTweaks.razor
More file actions
1256 lines (1123 loc) · 53.1 KB
/
Copy pathPerformanceTweaks.razor
File metadata and controls
1256 lines (1123 loc) · 53.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@page "/perf-tweaks"
@implements IDisposable
@inject UniFiConnectionService ConnectionService
@inject IGatewaySshService GatewaySshService
@inject PerfTweaksDeploymentService DeployService
@inject ILogger<PerformanceTweaks> Logger
@inject PullToRefreshState PtrState
@rendermode InteractiveServer
@using NetworkOptimizer.Web.Services.Ssh
<PageTitle>Performance Tweaks - Network Optimizer</PageTitle>
<div class="page-header">
<h1>Performance Tweaks</h1>
<p class="page-description">Deploy and manage performance optimizations for your UCG-Fiber, UXG-Fiber, or UCG-Max gateway. These tweaks address eMMC write pressure, thermal management, and SFP+ link speed - all persistent across reboots via udm-boot. We have more tweaks in testing that we'll be bringing over soon, and we're always looking for ideas.</p>
</div>
@if (!ConnectionService.IsConnected && ConnectionService.IsInitialized && !string.IsNullOrEmpty(ConnectionService.LastError))
{
<div class="connection-banner connection-error">
<div class="banner-content">
<span class="banner-icon">!</span>
<div class="banner-text">
<strong>UniFi Connection Error</strong>
<span>@ConnectionService.LastError</span>
</div>
<a href="/settings" class="btn btn-primary">Check Settings</a>
</div>
</div>
}
<div class="pt-container">
<!-- Deployment Status -->
<div class="card">
<div class="card-header">
<h2 class="card-title">Deployment Status</h2>
@if (!_isLoading)
{
<button class="btn btn-sm btn-secondary" @onclick="RefreshStatus">Refresh</button>
}
</div>
<div class="card-body">
<div class="deployment-status-content" style="min-height: 90px;">
@if (_isLoading)
{
<div class="loading-container">
<span class="spinner"></span>
<span>Checking deployment status...</span>
</div>
}
else
{
<div class="pt-status-metrics">
<div class="metric">
<div class="metric-label">Gateway Connection</div>
<div class="metric-value">
<span class="status-indicator @(_gatewayConnected ? "status-active" : "status-inactive")"></span>
@(_gatewayConnected ? "Connected" : "Not Connected")
</div>
</div>
<div class="metric">
<div class="metric-label">UDM Boot</div>
<div class="metric-value">
<span class="status-indicator @(_status?.UdmBootInstalled == true ? "status-active" : "status-inactive")"></span>
@if (_status?.UdmBootInstalled == true)
{
<span>@(_status.UdmBootEnabled ? "Enabled" : "Installed")</span>
}
else
{
<span>Not Installed</span>
}
</div>
</div>
<div class="metric">
<div class="metric-label">Gateway Model</div>
<div class="metric-value">
@if (_gatewayConnected && !string.IsNullOrEmpty(_status?.GatewayModel))
{
@if (_status.IsSupportedGateway)
{
<span class="status-indicator status-active"></span>
}
else
{
<span class="status-indicator status-danger"></span>
}
<span>@_status.GatewayModel</span>
}
else
{
<span>-</span>
}
</div>
</div>
<div class="metric">
<div class="metric-label">Firmware</div>
<div class="metric-value">
@if (!string.IsNullOrEmpty(_status?.FirmwareVersion))
{
<span class="status-indicator @(_status.FirmwareSupported ? "status-active" : "status-danger")"></span>
<span>@_status.FirmwareVersion</span>
}
else
{
<span>-</span>
}
</div>
</div>
<div class="metric">
<div class="metric-label">Active Tweaks</div>
<div class="metric-value">@_activeTweakCount / @_compatibleTweakSlotCount</div>
</div>
</div>
@if (_gatewayConnected && _status?.FirmwareSupported == false && !string.IsNullOrEmpty(_status?.FirmwareVersion))
{
<div class="alert alert-danger" style="margin-top: 1rem;">
<strong>Unsupported Firmware:</strong> Performance tweaks are currently tested and supported up to UniFi OS 5.1.11. Your gateway is running @_status.FirmwareVersion. Deploying new tweaks is disabled until we validate compatibility with this version. Existing tweaks will continue to run.
</div>
}
@if (!_gatewayConfigured)
{
<div class="alert alert-warning" style="margin-top: 1rem;">
<strong>Gateway SSH not configured.</strong>
Go to <a href="/settings#gateway-ssh">Settings</a> to configure Gateway SSH credentials before using Performance Tweaks.
</div>
}
else if (!string.IsNullOrEmpty(_status?.Error))
{
<div class="alert alert-danger alert-with-tooltip" style="margin-top: 1rem;">
<span class="alert-text"><strong>Connection Error:</strong> @_status.Error</span>
<SshTroubleshootingTooltip Context="gateway" />
</div>
}
else if (_gatewayConnected && _status?.IsSupportedGateway == false)
{
<div class="alert alert-warning" style="margin-top: 1rem;">
<strong>Unsupported Gateway:</strong> Performance Tweaks are designed for UCG-Fiber, UXG-Fiber, and UCG-Max gateways. Your gateway (@(_status.GatewayModel ?? "unknown")) is not supported.
</div>
}
@if (_gatewayConnected && _status?.UdmBootInstalled != true)
{
<div class="alert alert-warning" style="margin-top: 1rem;">
<strong>UDM Boot Required:</strong> Performance tweaks use boot scripts in <code>/data/on_boot.d/</code> that require udm-boot to persist across reboots.
<button class="btn btn-sm btn-primary" style="margin-left: 0.5rem;" @onclick="InstallUdmBoot" disabled="@_isInstallingUdmBoot">
@if (_isInstallingUdmBoot)
{
<span class="spinner spinner-sm"></span>
<span>Installing...</span>
}
else
{
<span>Install UDM Boot</span>
}
</button>
</div>
}
}
</div>
</div>
</div>
<!-- Firmware Notes -->
@if (!_isLoading && _gatewayConnected && _status?.IsSupportedGateway == true && _activeTweakCount > 0)
{
<div class="card">
<div class="card-header" style="cursor: pointer;" @onclick="() => _showFirmwareNotes = !_showFirmwareNotes">
<h2 class="card-title">Firmware Upgrade Notes</h2>
<span class="pt-collapse-icon">@(_showFirmwareNotes ? "−" : "+")</span>
</div>
@if (_showFirmwareNotes)
{
<div class="card-body">
<div class="pt-firmware-table table-responsive">
<table class="data-table">
<thead>
<tr>
<th>Scenario</th>
<th>Impact</th>
<th>Action Required</th>
</tr>
</thead>
<tbody>
<tr>
<td>UniFi Network Upgrade</td>
<td>No impact</td>
<td>None - everything is preserved</td>
</tr>
<tr>
<td>UniFi OS Upgrade</td>
<td>Boot scripts survive and reapply all tweaks on next boot</td>
<td>Check status indicators here to confirm everything survived</td>
</tr>
<tr>
<td>Factory Reset</td>
<td><strong>Boot scripts and custom modules will be wiped; SSD data may be wiped depending on reset options</strong></td>
<td><strong>Reinstall udm-boot and redeploy all tweaks</strong></td>
</tr>
</tbody>
</table>
</div>
</div>
}
</div>
}
@if (!string.IsNullOrEmpty(_removeMessage))
{
<div class="alert alert-warning">
@_removeMessage
</div>
}
<!-- Tweak Cards -->
@if (!_isLoading && _gatewayConnected && _status?.IsSupportedGateway == true)
{
@foreach (var def in _tweakDefs.Where(d => d.IsCompatibleWith(_status?.GatewayModel)))
{
var tweakStatus = _status?.Tweaks.GetValueOrDefault(def.Id);
var effectiveStatus = GetEffectiveStatus(tweakStatus, def.Id);
var exclusiveOtherActive = def.MutuallyExclusiveWith != null
&& _status?.Tweaks.TryGetValue(def.MutuallyExclusiveWith, out var otherTweak) == true
&& (otherTweak.IsActive || otherTweak.IsManuallyDeployed);
<div class="card pt-tweak-card">
<div class="card-header">
<div class="pt-tweak-header">
<h2 class="card-title">@def.Title</h2>
@if (effectiveStatus == TweakDisplayStatus.Active)
{
<span class="pt-status-badge pt-status-active">Active</span>
}
else if (effectiveStatus == TweakDisplayStatus.Manual)
{
<span class="pt-status-badge pt-status-manual">Manual</span>
}
else if (effectiveStatus == TweakDisplayStatus.Detected)
{
<span class="pt-status-badge pt-status-detected">Detected</span>
}
else if (effectiveStatus == TweakDisplayStatus.Issue)
{
<span class="pt-status-badge pt-status-issue">Issue</span>
}
else
{
<span class="pt-status-badge pt-status-inactive">Not Deployed</span>
}
</div>
</div>
<div class="card-body">
<p class="pt-tweak-description">@def.Description</p>
@if (!string.IsNullOrEmpty(def.ExtraNote))
{
<p class="pt-tweak-description" style="font-style: italic;">@def.ExtraNote</p>
}
<!-- SFP carrier wait note: boot script deployed but module not yet loaded -->
@if ((def.Id == "sfp-sgmiiplus" || def.Id == "sfp-sgmiiplus-port6") && tweakStatus?.BootScriptDeployed == true && tweakStatus?.RuntimeDetected != true)
{
<div class="alert alert-info" style="margin-top: 0.75rem; margin-bottom: 0.75rem;">
<strong>Waiting for link:</strong> After a reboot or deploy, the boot script waits up to 90 seconds for the SFP to establish a 1 G link before loading the SGMII+ kernel module. This allows time for the ONT's boot sequence and SerDes configuration. If the kernel module has not loaded yet, it may still be in this link check period.
</div>
}
<!-- Health Check Results -->
@if (tweakStatus != null && tweakStatus.HealthChecks.Any())
{
<div class="pt-health-section">
<div class="pt-health-grid">
@foreach (var check in tweakStatus.HealthChecks)
{
<div class="pt-health-item">
<span class="status-indicator @GetHealthClass(check.Status)"></span>
<span class="pt-health-label">@check.Label</span>
<span class="pt-health-value">@check.Value</span>
</div>
}
</div>
</div>
}
@if (effectiveStatus == TweakDisplayStatus.Issue && !string.IsNullOrEmpty(tweakStatus?.IssueDescription))
{
<div class="alert alert-danger" style="margin-top: 0.75rem;">
@tweakStatus.IssueDescription
</div>
}
<!-- MongoDB SSD gate: requires SSD volume -->
@if (def.Id == "mongodb-ssd" && effectiveStatus == TweakDisplayStatus.NotDeployed && _status?.SsdAvailable != true)
{
<div class="alert alert-warning" style="margin-top: 0.75rem;">
<strong>No SSD volume detected.</strong> This tweak requires an internal NVMe SSD mounted at <code>/volume1</code> or <code>/volume/<uuid>/</code>. Make sure your gateway has an SSD installed and mounted.
</div>
}
else if (def.Id == "mongodb-ssd" && effectiveStatus == TweakDisplayStatus.NotDeployed && _status?.SsdAvailable == true)
{
<div class="alert alert-info" style="margin-top: 0.75rem;">
<strong>Note:</strong> First-run deployment will briefly stop UniFi Network while migrating MongoDB data to SSD. It will restart automatically once the migration completes.
</div>
}
<!-- SFP qca-ssdk gate -->
@if ((def.Id == "sfp-sgmiiplus" || def.Id == "sfp-sgmiiplus-port6") && effectiveStatus == TweakDisplayStatus.NotDeployed && _status?.SfpQcaSsdkMissing == true)
{
<div class="alert alert-warning" style="margin-top: 0.75rem;">
<strong>Missing dependency:</strong> The <code>qca-ssdk</code> kernel module is not loaded on this gateway. It is required for the SFP SGMII+ patch to function.
</div>
}
<!-- SFP-specific gate (Port 6) -->
@if (def.Id == "sfp-sgmiiplus-port6" && (effectiveStatus == TweakDisplayStatus.NotDeployed || effectiveStatus == TweakDisplayStatus.Detected) && _status?.SfpPort6ModuleAlreadyLoaded == true)
{
<div class="alert alert-info" style="margin-top: 0.75rem;">
<strong>Module already loaded.</strong> The SFP SGMII+ kernel module is already active on this port. Use "Mark as Manually Deployed" to enable monitoring without redeploying.
</div>
}
<!-- SFP-specific gate (Port 7) -->
@if (def.Id == "sfp-sgmiiplus" && (effectiveStatus == TweakDisplayStatus.NotDeployed || effectiveStatus == TweakDisplayStatus.Detected) && _status?.SfpModuleAlreadyLoaded == true)
{
<div class="alert alert-info" style="margin-top: 0.75rem;">
<strong>Module already loaded.</strong> The SFP SGMII+ kernel module is already active on this port. Use "Mark as Manually Deployed" to enable monitoring without redeploying.
</div>
}
@if (def.Id == "sfp-sgmiiplus" || def.Id == "sfp-sgmiiplus-port6")
{
<div class="alert alert-warning" style="margin-top: 0.75rem;">
<strong>GPON stick compatibility:</strong> Some SFP GPON ONTs need extra configuration to negotiate 2.5 G with the UniFi host. For Zyxel PMG3000-D20B sticks, upgrading to V2.50 firmware is recommended - it supports 2.5 G out of the box. <a href="javascript:void(0)" @onclick="() => _showZyxelInstructions = true" @onclick:stopPropagation="true" class="pt-inline-link">See compatibility details</a>, and Remove the SFP tweak to restore the link if all else fails.
</div>
}
@if (exclusiveOtherActive && effectiveStatus == TweakDisplayStatus.NotDeployed)
{
var otherDef = _tweakDefs.FirstOrDefault(d => d.Id == def.MutuallyExclusiveWith);
<div class="alert alert-danger" style="margin-top: 0.75rem;">
<strong>Cannot deploy:</strong> @(otherDef?.Title ?? def.MutuallyExclusiveWith) is currently active. Only one SFP+ SGMII+ patch can be loaded at a time - each module saves and restores the MAC sync polling loop's port bitmap independently, so loading both would corrupt the restore state. Remove the other patch first.
</div>
}
<!-- Action Buttons -->
<div class="pt-actions">
@if (effectiveStatus == TweakDisplayStatus.NotDeployed)
{
<button class="btn btn-primary btn-sm"
disabled="@(!_canDeploy || _deployingTweakId == def.Id || exclusiveOtherActive || (def.Id == "sfp-sgmiiplus" && _status?.SfpModuleAlreadyLoaded == true) || (def.Id == "sfp-sgmiiplus-port6" && _status?.SfpPort6ModuleAlreadyLoaded == true) || ((def.Id == "sfp-sgmiiplus" || def.Id == "sfp-sgmiiplus-port6") && _status?.SfpQcaSsdkMissing == true) || (def.Id == "mongodb-ssd" && _status?.SsdAvailable != true))"
@onclick="() => ShowDeployConfirmation(def.Id)"
data-tooltip="@(!_canDeploy ? (_status?.FirmwareSupported != true ? "Unsupported firmware" : "Install UDM Boot first") : null)">
@if (_deployingTweakId == def.Id)
{
<span class="spinner spinner-sm"></span>
<span>Deploying...</span>
}
else
{
<span>Deploy</span>
}
</button>
<button class="btn btn-secondary btn-sm" @onclick="() => MarkAsManual(def.Id)" disabled="@(_deployingTweakId != null || _removingTweakId != null)">
Mark as Manually Deployed
</button>
}
else if (effectiveStatus == TweakDisplayStatus.Active)
{
@if (tweakStatus?.ScriptOutdated == true)
{
<button class="btn btn-sm btn-primary" @onclick="() => ShowDeployConfirmation(def.Id)" disabled="@(_deployingTweakId == def.Id)">
@if (_deployingTweakId == def.Id)
{
<span class="spinner spinner-sm"></span>
<span>Updating...</span>
}
else
{
<span>Update</span>
}
</button>
}
<button class="btn btn-sm btn-secondary" @onclick="RefreshStatus" disabled="@_isLoading">
Check Status
</button>
@if (tweakStatus?.IsManuallyDeployed != true)
{
<button class="btn btn-sm btn-danger" @onclick="() => ShowRemoveConfirmation(def.Id)" disabled="@(_removingTweakId == def.Id || _deployingTweakId == def.Id)">
@if (_removingTweakId == def.Id)
{
<span class="spinner spinner-sm"></span>
<span>Removing...</span>
}
else
{
<span>Remove</span>
}
</button>
}
}
else if (effectiveStatus == TweakDisplayStatus.Manual)
{
<button class="btn btn-sm btn-secondary" @onclick="RefreshStatus" disabled="@_isLoading">
Check Status
</button>
<button class="btn btn-sm btn-outline-primary" @onclick="() => UnmarkManual(def.Id)">
Unmark Manual
</button>
}
else if (effectiveStatus == TweakDisplayStatus.Detected)
{
<button class="btn btn-sm btn-primary" @onclick="() => MarkAsManual(def.Id)" disabled="@(_deployingTweakId != null || _removingTweakId != null)">
Mark as Manually Deployed
</button>
<button class="btn btn-sm btn-secondary" @onclick="RefreshStatus" disabled="@_isLoading">
Check Status
</button>
}
else if (effectiveStatus == TweakDisplayStatus.Issue)
{
<button class="btn btn-sm btn-primary" @onclick="() => ShowDeployConfirmation(def.Id)" disabled="@(_deployingTweakId == def.Id)">
@if (_deployingTweakId == def.Id)
{
<span class="spinner spinner-sm"></span>
<span>Redeploying...</span>
}
else
{
<span>Redeploy</span>
}
</button>
<button class="btn btn-sm btn-secondary" @onclick="RefreshStatus" disabled="@_isLoading">
Check Status
</button>
<button class="btn btn-sm btn-danger" @onclick="() => ShowRemoveConfirmation(def.Id)" disabled="@(_removingTweakId == def.Id || _deployingTweakId == def.Id)">
@if (_removingTweakId == def.Id)
{
<span class="spinner spinner-sm"></span>
<span>Removing...</span>
}
else
{
<span>Remove</span>
}
</button>
}
</div>
<!-- Deployment Progress -->
@if (_deployingTweakId == def.Id && _deploySteps.Any())
{
<div class="pt-deploy-progress">
@foreach (var step in _deploySteps)
{
<div>@step</div>
}
</div>
}
</div>
</div>
}
}
</div>
<!-- Deploy Confirmation Modal -->
@if (_showDeployConfirm)
{
<div class="pt-modal-overlay" @onclick="CancelDeploy">
<div class="pt-modal" @onclick:stopPropagation="true">
<div class="pt-modal-header">
<h3>Confirm Deployment</h3>
</div>
<div class="pt-modal-body">
<p>Before deploying, please confirm the following:</p>
<label class="pt-confirm-item">
<input type="checkbox" @bind="_confirmBackup" />
<span>I have created a <strong>full backup</strong> (OS + Network) in my UniFi Console</span>
</label>
<label class="pt-confirm-item">
<input type="checkbox" @bind="_confirmBackupDownloaded" />
<span>I have <strong>downloaded a copy</strong> of that backup to a separate device</span>
</label>
<label class="pt-confirm-item">
<input type="checkbox" @bind="_confirmWarranty" />
<span>I understand these are <strong>community-developed tweaks</strong>, not supported by Ubiquiti, and may affect my warranty or support eligibility</span>
</label>
<label class="pt-confirm-item">
<input type="checkbox" @bind="_confirmRisk" />
<span>I understand that while these tweaks have been tested across multiple gateways and sites, <strong>some risk remains</strong>, particularly with newer firmware versions</span>
</label>
</div>
<div class="pt-modal-footer">
<button class="btn btn-secondary btn-sm" @onclick="CancelDeploy">Cancel</button>
<button class="btn btn-primary btn-sm" @onclick="ConfirmDeploy" disabled="@(!_allConfirmed)">
Confirm Deploy
</button>
</div>
</div>
</div>
}
<!-- Remove Confirmation Modal -->
@if (_showRemoveConfirm && _pendingRemoveTweakId != null)
{
var removeDef = _tweakDefs.FirstOrDefault(d => d.Id == _pendingRemoveTweakId);
<div class="pt-modal-overlay" @onclick="CancelRemove">
<div class="pt-modal" @onclick:stopPropagation="true">
<div class="pt-modal-header">
<h3>Confirm Removal</h3>
</div>
<div class="pt-modal-body">
<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>
@if (_pendingRemoveTweakId == "mongodb-ssd")
{
<div class="alert alert-warning" style="margin-top: 0.75rem;">
<strong>Note:</strong> Removal will briefly stop UniFi Network while migrating MongoDB data back from SSD to eMMC, then restart it.
</div>
}
</div>
<div class="pt-modal-footer">
<button class="btn btn-secondary btn-sm" @onclick="CancelRemove">Cancel</button>
<button class="btn btn-danger btn-sm" @onclick="ConfirmRemove">
Confirm Remove
</button>
</div>
</div>
</div>
}
<!-- GPON Stick Pre-Flight Instructions Modal -->
@if (_showZyxelInstructions)
{
<div class="pt-modal-overlay" @onclick="() => _showZyxelInstructions = false">
<div class="pt-modal pt-modal-wide" @onclick:stopPropagation="true">
<div class="pt-modal-header">
<h3>GPON Stick Compatibility - Pre-Flight Steps</h3>
</div>
<div class="pt-modal-body pt-instructions">
<p>Some GPON ONT SFP modules default to a link mode that won't negotiate 2.5 G with the UniFi host. The exact steps depend on your stick and its firmware version.</p>
<h4>If it doesn't work</h4>
<p>If the link and data path don't come up after deploying, use the Remove button on the tweak card to unload the module - this should restore normal functionality. If the link still doesn't recover after removal, reboot the SFP stick.</p>
<h4>Zyxel PMG3000-D20B</h4>
<p><strong>Recommended: upgrade to V2.50 firmware.</strong> The V1.00 firmware branch has an incomplete auto-negotiation state machine that can fail to converge at 2.5 G, especially after host reboots. The V2.50 branch (V2.50(ABVJ.1)b1f or later) fixes this and defaults to 2.5 G out of the box - no manual SFP configuration needed. Just deploy the SGMII+ patch and the stick handles the rest.</p>
<p>V2.50 firmware images are available from the <a href="https://gist.github.com/maurice-w/faeb60bf8201ce70391873bcb9059bc2" target="_blank" rel="noopener noreferrer">community firmware archive</a>. Flash via the SFP's web installer or UART.</p>
<details class="pt-collapsible">
<summary>V1.00 firmware workaround (if you can't upgrade)</summary>
<div class="pt-collapsible-body">
<p>This workaround switches the V1.00 stick to 2.5/1 G auto-negotiation mode. It may work for initial link-up, but the V1.00 firmware may fail to re-converge at 2.5 G after a host reboot due to missing clock domain reset logic. If that happens, upgrading to V2.50 is the fix.</p>
<p><strong>Configure auto-negotiation.</strong> SSH to the stick and run:</p>
<pre><code>linuxshell
onu lanpcs 0 1 -1 4 15 1 3 5 0 0 4096 1 3 0 0 0</code></pre>
<p>The <code>linuxshell</code> command breaks out of the Zyxel CLI into a Linux shell. The <code>onu lanpcs</code> command switches the SFP interface to 2.5/1 G auto-negotiation mode. It resets on SFP reboot, so you always have a way out.</p>
<p><strong>Deploy the patch.</strong> Come back here and deploy the SGMII+ patch. After about a minute, the link should come up and you should have data path again.</p>
<p><strong>Persist across reboots.</strong> If it works, make the command run automatically on every SFP boot. SSH to the stick again and run:</p>
<pre><code># Enter the Linux shell first (if a new SSH session)
linuxshell
# Check if the boot script file already exists
ls -la /var/config/run-syslog.sh</code></pre>
<p>If the file <strong>does not exist</strong> (you see "No such file or directory"):</p>
<pre><code>echo 'onu lanpcs 0 1 -1 4 15 1 3 5 0 0 4096 1 3 0 0 0' > /var/config/run-syslog.sh</code></pre>
<p>If the file <strong>already exists</strong>, safely append the command:</p>
<pre><code>grep -q 'lanpcs' /var/config/run-syslog.sh 2>/dev/null || echo 'onu lanpcs 0 1 -1 4 15 1 3 5 0 0 4096 1 3 0 0 0' >> /var/config/run-syslog.sh</code></pre>
</div>
</details>
<h4>Other GPON ONT sticks</h4>
<p>If your stick isn't a Zyxel PMG3000 but still has trouble linking at 2.5 G, a firmware upgrade may help. Many carrier-grade and ISP-issued GPON sticks (including the Zyxel and Calix) use T&W boards with the Lantiq Falcon SoC, and the SGMII auto-negotiation recovery logic improved significantly in newer kernel builds. The Zyxel only started working reliably after upgrading from its older V1.00 kernel to the newer V2.50 branch. Realtek-based sticks may have similar gotchas. Check your stick's community resources for newer firmware images.</p>
</div>
<div class="pt-modal-footer">
<button class="btn btn-primary btn-sm" @onclick="() => _showZyxelInstructions = false">Got It</button>
</div>
</div>
</div>
}
<style>
.pt-container {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
/* Status metrics grid */
.pt-status-metrics {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 1rem;
}
.pt-status-metrics .metric {
text-align: center;
padding: 1.25rem;
background: var(--bg-primary);
border-radius: 0.5rem;
}
.pt-status-metrics .metric-label {
font-size: 0.8rem;
color: var(--text-secondary);
margin-bottom: 0.25rem;
}
.pt-status-metrics .metric-value {
font-size: 1rem;
font-weight: 500;
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
}
.pt-status-metrics .status-indicator {
width: 10px;
height: 10px;
border-radius: 50%;
display: inline-block;
}
.pt-status-metrics .status-active {
background: var(--success-color);
}
.pt-status-metrics .status-inactive {
background: var(--danger-color);
}
.pt-health-item .status-warning {
background: var(--warning-color);
}
/* Tweak cards */
.pt-tweak-card .card-body {
padding-top: 0.75rem;
}
.pt-tweak-header {
display: flex;
align-items: center;
gap: 0.75rem;
}
.pt-tweak-description {
color: var(--text-secondary);
font-size: 0.9rem;
line-height: 1.5;
margin: 0 0 1rem 0;
}
/* Status badges */
.pt-status-badge {
font-size: 0.7rem;
font-weight: 600;
padding: 0.2rem 0.6rem;
border-radius: 1rem;
text-transform: uppercase;
letter-spacing: 0.03em;
white-space: nowrap;
}
.pt-status-active {
background: rgba(36, 188, 112, 0.15);
color: var(--success-color);
}
.pt-status-manual {
background: rgba(71, 151, 255, 0.15);
color: var(--info-color);
}
.pt-status-detected {
background: rgba(249, 115, 22, 0.15);
color: var(--accent-color);
}
.pt-status-issue {
background: rgba(238, 99, 104, 0.15);
color: var(--danger-color);
}
.pt-status-inactive {
background: rgba(100, 116, 139, 0.15);
color: var(--text-muted);
}
/* Health checks */
.pt-health-section {
background: var(--bg-primary);
border-radius: 0.5rem;
padding: 0.75rem 1rem;
margin-bottom: 1rem;
}
.pt-health-grid {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.pt-health-item {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.85rem;
}
.pt-health-item .status-indicator {
width: 8px;
height: 8px;
border-radius: 50%;
display: inline-block;
flex-shrink: 0;
}
.pt-health-label {
color: var(--text-secondary);
min-width: 180px;
}
.pt-health-value {
color: var(--text-primary);
font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
font-size: 0.8rem;
}
/* Action buttons */
.pt-actions {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
margin-top: 1rem;
}
/* Deploy progress */
.pt-deploy-progress {
margin-top: 0.75rem;
padding: 0.75rem 1rem;
background: var(--bg-primary);
border-radius: 0.5rem;
font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
font-size: 0.8rem;
color: var(--text-secondary);
max-height: 150px;
overflow-y: auto;
}
.pt-deploy-progress div {
padding: 0.15rem 0;
}
/* Firmware notes */
.pt-collapse-icon {
font-size: 1.2rem;
color: var(--text-secondary);
font-weight: 600;
user-select: none;
}
.pt-firmware-table table {
font-size: 0.85rem;
}
.pt-firmware-table td strong {
color: var(--warning-color);
}
/* Deploy confirmation modal */
.pt-modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.6);
display: flex;
align-items: flex-start;
justify-content: center;
z-index: 1000;
padding: 2rem 1rem;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.pt-modal {
background: var(--bg-secondary);
border-radius: 0.75rem;
max-width: 540px;
width: 100%;
margin: auto 0;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.pt-modal-header {
padding: 1.25rem 1.5rem 0;
}
.pt-modal-header h3 {
margin: 0;
font-size: 1.1rem;
color: var(--text-primary);
}
.pt-modal-body {
padding: 1rem 1.5rem;
}
.pt-modal-body > p {
color: var(--text-secondary);
font-size: 0.9rem;
margin: 0 0 1rem 0;
}
.pt-confirm-item {
display: flex;
align-items: flex-start;
gap: 0.75rem;
padding: 0.6rem 0;
cursor: pointer;
font-size: 0.85rem;
color: var(--text-primary);
line-height: 1.4;
}
.pt-confirm-item input[type="checkbox"] {
margin-top: 0.15rem;
flex-shrink: 0;
width: 16px;
height: 16px;
accent-color: var(--primary-color);
}
.pt-modal-footer {
padding: 0.75rem 1.5rem 1.25rem;
display: flex;
justify-content: flex-end;
gap: 0.5rem;
}
@@media (max-width: 768px) {
.pt-status-metrics {
grid-template-columns: repeat(2, 1fr);
}
.pt-health-label {
min-width: 130px;
}
.pt-actions {
flex-direction: column;
}
.pt-actions .btn {
width: 100%;
}
}
/* Inline action link */
.pt-inline-link {
color: var(--primary-color);
text-decoration: underline;
cursor: pointer;
}
.pt-inline-link:hover {
color: var(--primary-hover);
}
/* Wide modal variant */
.pt-modal-wide {
max-width: 640px;
}
/* Instructional modal body */
.pt-instructions h4 {
color: var(--text-primary);
font-size: 0.95rem;
margin: 1.25rem 0 0.5rem 0;
}
.pt-instructions h4:first-child {
margin-top: 0;
}
.pt-instructions p {
color: var(--text-secondary);
font-size: 0.85rem;
line-height: 1.5;
margin: 0 0 0.5rem 0;
}
.pt-instructions pre {
background: var(--bg-primary);
border-radius: 0.375rem;
padding: 0.75rem 1rem;
margin: 0.5rem 0 0.75rem 0;
overflow-x: auto;
}
.pt-instructions code {
font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
font-size: 0.8rem;
color: var(--text-primary);
}
.pt-instructions ol {
color: var(--text-secondary);
font-size: 0.85rem;
line-height: 1.5;
margin: 0 0 0.75rem 0;
padding-left: 1.25rem;
}
.pt-instructions li {
margin-bottom: 0.25rem;
}
.pt-collapsible {
margin-top: 1rem;
border: 1px solid var(--bg-tertiary);
border-radius: 0.375rem;
}
.pt-collapsible summary {
padding: 0.625rem 1rem;
color: var(--text-secondary);
font-size: 0.85rem;
cursor: pointer;
background: var(--bg-primary);
border-radius: 0.375rem;
}
.pt-collapsible summary:hover {
color: var(--text-primary);
}
.pt-collapsible[open] summary {
border-radius: 0.375rem 0.375rem 0 0;
border-bottom: 1px solid var(--bg-tertiary);
}
.pt-collapsible-body {
padding: 0.75rem 1rem;
}
</style>
@code {
private bool _isLoading = true;
private bool _gatewayConfigured;
private bool _gatewayConnected;
private bool _isInstallingUdmBoot;
private bool _showFirmwareNotes;
private string? _deployingTweakId;
private string? _removingTweakId;
private string? _removeMessage;
private bool _showDeployConfirm;
private string? _pendingDeployTweakId;
private bool _confirmBackup;
private bool _confirmBackupDownloaded;
private bool _confirmWarranty;
private bool _confirmRisk;
private bool _showRemoveConfirm;
private string? _pendingRemoveTweakId;
private bool _showZyxelInstructions;
private readonly Dictionary<string, DateTime> _sfpDeployTimes = new();
private bool _allConfirmed => _confirmBackup && _confirmBackupDownloaded && _confirmWarranty && _confirmRisk;
private bool _canDeploy => _status?.UdmBootInstalled == true && _status?.FirmwareSupported == true;
private List<string> _deploySteps = new();
private PerfTweaksStatus? _status;
private List<TweakDefinition> _compatibleTweaks => _tweakDefs
.Where(d => d.IsCompatibleWith(_status?.GatewayModel)).ToList();
// TODO: Remove deduplication when simultaneous SFP port support is working -
// at that point each SFP tweak should count independently.
private int _compatibleTweakSlotCount => _compatibleTweaks
.Where(d => d.MutuallyExclusiveWith == null
|| string.Compare(d.Id, d.MutuallyExclusiveWith, StringComparison.Ordinal) < 0)
.Count();
private int _activeTweakCount
{
get
{
if (_status == null) return 0;
var activeIds = _status.Tweaks.Values