Skip to content

Commit 67172a9

Browse files
committed
crosscheck
1 parent 6bdd2c6 commit 67172a9

20 files changed

Lines changed: 5104 additions & 369 deletions

File tree

‎.vscode/launch.json‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Launch and Debug Blazor WebAssembly",
6+
"type": "blazorwasm",
7+
"request": "launch",
8+
"cwd": "${workspaceFolder}/MakerPrompt.Blazor",
9+
"url": "https://localhost:7257",
10+
"browser": "chrome",
11+
"preLaunchTask": "build-blazor"
12+
},
13+
{
14+
"name": "Attach to Blazor WebAssembly (Chrome)",
15+
"type": "blazorwasm",
16+
"request": "attach",
17+
"url": "https://localhost:7257",
18+
"webRoot": "${workspaceFolder}/MakerPrompt.Blazor/wwwroot"
19+
}
20+
]
21+
}

‎.vscode/tasks.json‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build-blazor",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/MakerPrompt.Blazor/MakerPrompt.Blazor.csproj",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary;ForceNoAlign"
13+
],
14+
"problemMatcher": "$msCompile",
15+
"group": {
16+
"kind": "build",
17+
"isDefault": true
18+
}
19+
},
20+
{
21+
"label": "watch-blazor",
22+
"command": "dotnet",
23+
"type": "process",
24+
"args": [
25+
"watch",
26+
"--project",
27+
"${workspaceFolder}/MakerPrompt.Blazor/MakerPrompt.Blazor.csproj"
28+
],
29+
"problemMatcher": "$msCompile"
30+
}
31+
]
32+
}

‎MakerPrompt.Blazor/MakerPrompt.Blazor.csproj‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
88
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
9+
<!-- Enables source-map based debugging in both VS and VS Code for .NET 10 WASM.
10+
Prevents the "failed to load metadata for System.Private.CoreLib.dll" error. -->
11+
<WasmDebugLevel>2</WasmDebugLevel>
912
<Version>0.3.10</Version>
1013
<AssemblyVersion>$(Version)</AssemblyVersion>
1114
<FileVersion>$(Version)</FileVersion>

‎MakerPrompt.Blazor/wwwroot/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<a class="dismiss">🗙</a>
7171
</div>
7272
<script src="_content/MakerPrompt.Shared/lib/bootstrap/js/bootstrap.bundle.min.js"></script>
73-
<script src="_content/MakerPrompt.Shared/lib/gcode-viewer/_bundles/gcode-viewer.min.js"></script>
73+
<script src="_content/MakerPrompt.Shared/lib/gcode-preview/gcode-preview.bundle.js"></script>
7474
<script src="_framework/blazor.webassembly.js"></script>
7575
<script src="_content/Blazor.Bootstrap/blazor.bootstrap.js"></script>
7676
<script>navigator.serviceWorker.register('service-worker.js');</script>

‎MakerPrompt.E2E.Maui/Tests/FarmModeTests.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ public async Task FarmMode_D_Disabled_ShowsControlPanel()
8787
await AppiumSetup.NavigateAsync("/dashboard");
8888
await Page.Locator(".sidebar").WaitForAsync(new LocatorWaitForOptions { Timeout = 15_000 });
8989

90-
// Dashboard should render ControlPanel directly; header-add-printer exists in farm mode only
90+
// Add Printer button appears in the navbar in single-printer (non-farm) mode
9191
var addPrinterLink = Page.Locator("[data-testid='header-add-printer']");
92-
Assert.True(await addPrinterLink.CountAsync() == 0, "Add Printer button should NOT appear in navbar when farm mode is off");
92+
await addPrinterLink.WaitForAsync(new LocatorWaitForOptions { Timeout = 5_000 });
93+
Assert.True(await addPrinterLink.IsVisibleAsync(), "Add Printer button should appear in navbar when farm mode is off");
9394
}
9495

9596
// ── Farm Name ──

‎MakerPrompt.E2E.Wasm/Tests/FarmModeTests.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ public async Task FarmMode_Disabled_ShowsAddPrinterInNavbar()
7777
await Page.GotoAsync($"{_fixture.BaseUrl}/dashboard");
7878
await Page.Locator(".sidebar").WaitForAsync(new LocatorWaitForOptions { Timeout = 15_000 });
7979

80-
// Add Printer button no longer appears in navbar for single-printer mode
80+
// Add Printer button appears in the navbar in single-printer (non-farm) mode
8181
var addPrinterLink = Page.Locator("[data-testid='header-add-printer']");
82-
Assert.True(await addPrinterLink.CountAsync() == 0, "Add Printer button should NOT appear in navbar when farm mode is off");
82+
await addPrinterLink.WaitForAsync(new LocatorWaitForOptions { Timeout = 5_000 });
83+
Assert.True(await addPrinterLink.IsVisibleAsync(), "Add Printer button should appear in navbar when farm mode is off");
8384
}
8485

8586
// ── Farm Name ──

‎MakerPrompt.MAUI/wwwroot/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</div>
2727

2828
<script src="_content/MakerPrompt.Shared/lib/bootstrap/js/bootstrap.bundle.min.js"></script>
29-
<script src="_content/MakerPrompt.Shared/lib/gcode-viewer/_bundles/gcode-viewer.min.js"></script>
29+
<script src="_content/MakerPrompt.Shared/lib/gcode-preview/gcode-preview.bundle.js"></script>
3030
<script src="_framework/blazor.webview.js" autostart="false"></script>
3131
<script src="_content/Blazor.Bootstrap/blazor.bootstrap.js"></script>
3232
<script>

‎MakerPrompt.Shared/Components/CommandPrompt.razor‎

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@
22
@inherits ConnectionComponentBase
33

44
<div class="bg-body-tertiary rounded p-3 d-flex flex-column h-100">
5-
<div class="d-flex align-items-center justify-content-between mb-2">
6-
<div class="d-flex align-items-center gap-2">
7-
@if (!string.IsNullOrEmpty(_activePrinterName))
8-
{
9-
<span class="badge bg-secondary">
10-
<i class="bi bi-terminal me-1"></i>@_activePrinterName
11-
</span>
12-
}
13-
</div>
5+
<div class="d-flex align-items-center justify-content-end mb-2">
146
<div class="form-check form-switch mb-0">
157
<input class="form-check-input" type="checkbox" id="toggle-telemetry-echo" @bind="_showTelemetry" />
168
<label class="form-check-label ms-2" for="toggle-telemetry-echo">
@@ -72,10 +64,6 @@
7264
private bool _expectTelemetryEcho;
7365
private bool _showTelemetry;
7466

75-
// Multi-printer: track which printer the terminal is attached to
76-
private string _activePrinterName = string.Empty;
77-
private string _lastPrinterConnectionName = string.Empty;
78-
7967
private async Task SendCommand()
8068
{
8169
if (string.IsNullOrWhiteSpace(inputCommand) || PrinterServiceFactory.Current == null) return;
@@ -138,20 +126,6 @@
138126
base.HandleConnectionChanged(sender, connected);
139127

140128
var currentName = PrinterServiceFactory.Current?.ConnectionName ?? string.Empty;
141-
142-
// Detect printer switch — clear history and notify
143-
if (connected && !string.IsNullOrEmpty(currentName) && currentName != _lastPrinterConnectionName && !string.IsNullOrEmpty(_lastPrinterConnectionName))
144-
{
145-
lock (_historyLock)
146-
{
147-
history.Clear();
148-
}
149-
AddSystemMessage($"Switched to {currentName}");
150-
}
151-
152-
_lastPrinterConnectionName = currentName;
153-
_activePrinterName = connected ? currentName : string.Empty;
154-
155129
var message = connected ? string.Format(Localizer[Resources.CommandPrompt_ConnectedMessage], currentName)
156130
: string.Format(Localizer[Resources.CommandPrompt_DisconnectedMessage], currentName);
157131
AddSystemMessage(message);

‎MakerPrompt.Shared/Components/ControlPanel.razor‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
</div>
111111
</div>
112112

113-
<div class="card">
113+
<div class="card mt-3">
114114
<h4 class="card-header">@Localizer[Resources.ControlPanel_Status]</h4>
115115
<div class="card-body">
116116
<div class="input-group mb-2">
@@ -120,16 +120,41 @@
120120
<span class="input-group-text">%</span>
121121
<button class="btn btn-outline-secondary" type="button" disabled>@Localizer[Resources.ControlPanel_Set]</button>
122122
</div>
123-
<div class="input-group">
123+
<div class="input-group mb-2">
124124
<span class="input-group-text" title="@Localizer[Resources.ControlPanel_Current]">C: @Telemetry.FlowRate.ToString()</span>
125125
<span class="input-group-text">@Localizer[Resources.ControlPanel_PrintFlow]:</span>
126126
<input type="text" class="form-control" @bind="printFlow" @bind:after="UpdatePrintFlowAsync" disabled="@(!IsConnected)">
127127
<span class="input-group-text">%</span>
128128
<button class="btn btn-outline-secondary" type="button" disabled>@Localizer[Resources.ControlPanel_Set]</button>
129129
</div>
130+
@if (Telemetry.SDCard.Printing || Telemetry.Status == PrinterStatus.Printing)
131+
{
132+
<div class="mt-2">
133+
@if (!string.IsNullOrWhiteSpace(Telemetry.PrintJobName))
134+
{
135+
<div class="d-flex align-items-center gap-2 mb-1">
136+
<i class="bi bi-file-earmark-text text-muted"></i>
137+
<small class="text-truncate" title="@Telemetry.PrintJobName">@Telemetry.PrintJobName</small>
138+
</div>
139+
}
140+
<div class="d-flex justify-content-between mb-1">
141+
<small class="text-muted">@Localizer[Resources.Fleet_Progress]</small>
142+
<small>@($"{Telemetry.SDCard.Progress:F0}%")</small>
143+
</div>
144+
<div class="progress" style="height: 8px;">
145+
<div class="progress-bar bg-success progress-bar-striped progress-bar-animated"
146+
role="progressbar"
147+
style="width: @($"{Telemetry.SDCard.Progress:F0}%")"
148+
aria-valuenow="@Telemetry.SDCard.Progress"
149+
aria-valuemin="0"
150+
aria-valuemax="100">
151+
</div>
152+
</div>
153+
</div>
154+
}
130155
</div>
131156
</div>
132-
<div class="card">
157+
<div class="card mt-3">
133158
<h4 class="card-header">@Localizer[Resources.GCodeCategory_Calibration]</h4>
134159
<div class="card-body">
135160
<Calibration />

‎MakerPrompt.Shared/Components/FileExplorer.razor‎

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@
1111
<button class="btn btn-sm btn-secondary" disabled="@(!IsConnected)" @onclick="RefreshFiles">
1212
<i class="bi bi-arrow-clockwise"></i> @Localizer[Resources.Files_Refresh]
1313
</button>
14-
<button class="btn btn-sm btn-outline-info" @onclick="OpenSelectedPrinter" disabled="@(selectedFile == null)">
15-
<i class="bi bi-eye"></i> Open
14+
<button class="btn btn-sm btn-outline-info" @onclick="OpenSelectedPrinter" disabled="@(selectedFile == null || _isOpening)">
15+
@if (_isOpening)
16+
{
17+
<span class="spinner-border spinner-border-sm me-1" role="status" aria-hidden="true"></span>
18+
<span>Loading...</span>
19+
}
20+
else
21+
{
22+
<i class="bi bi-eye"></i><span> Open</span>
23+
}
1624
</button>
1725
<button class="btn btn-sm btn-outline-success" @onclick="CopySelectedToApp" disabled="@(selectedFile == null)">
1826
<i class="bi bi-arrow-left-square"></i> Copy to App
@@ -69,6 +77,7 @@
6977
@code {
7078
private List<FileEntry> _files = new();
7179
private bool _isLoading;
80+
private bool _isOpening;
7281
private FileEntry? selectedFile;
7382

7483
protected override async Task OnInitializedAsync()
@@ -161,17 +170,27 @@
161170
}, "Failed to copy file");
162171
}
163172

164-
private Task OpenSelectedPrinter()
173+
private async Task OpenSelectedPrinter()
165174
{
166-
if (selectedFile == null) return Task.CompletedTask;
175+
if (selectedFile == null) return;
167176
var file = selectedFile;
168-
return RunAsync(async () =>
177+
_isOpening = true;
178+
StateHasChanged();
179+
try
169180
{
170-
await using var stream = await PrinterStorage.OpenReadAsync(file.FullPath) ?? Stream.Null;
171-
if (stream == Stream.Null) return;
172-
using var reader = new StreamReader(stream);
173-
var content = await reader.ReadToEndAsync();
174-
GCodeDoc.SetGCode(content);
175-
}, "Failed to open file");
181+
await RunAsync(async () =>
182+
{
183+
await using var stream = await PrinterStorage.OpenReadAsync(file.FullPath) ?? Stream.Null;
184+
if (stream == Stream.Null) return;
185+
using var reader = new StreamReader(stream);
186+
var content = await reader.ReadToEndAsync();
187+
GCodeDoc.SetGCode(content);
188+
}, "Failed to open file");
189+
}
190+
finally
191+
{
192+
_isOpening = false;
193+
StateHasChanged();
194+
}
176195
}
177196
}

0 commit comments

Comments
 (0)