Add printer controls to the fleet cards: pause, resume, stop, fan
The console could only watch. A printer card now offers what
POST /printers/:id/commands accepts and a person should press: pause
while printing, resume while paused, and a fan percentage.
Stop is the one command with no undo (the printer reports FAILED), so it
sits apart from Pause and needs a second, named confirmation
("Cancel <job>? ... cannot be resumed"). Offline and never-reported
printers get no controls, since every command would be refused as
unreachable. A successful reply only means the printer accepted the
command, so the notice says to watch the status line rather than claiming
the state changed. The backend's own error message is shown for a 403, 409
or 502.
PrinterControls takes a `send` function like the card takes `signal`, so
@continuum/ui still knows nothing of the API; no function, no controls.
send_gcode_line and start_print are deliberately not offered here.
Verified in real Chrome against the live stack with the command requests
intercepted in the browser (the H2C was mid-print): controls render per
state, Stop shows its confirmation and Keep printing sends nothing, the
body is {action:"set_fan_speed",percent:100}, a 409 surfaces its message,
no page errors. pnpm -r typecheck is clean.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import type { AppPrinterState } from "../types";
|
||||
import type { AppPrinterState, PrinterCommand } from "../types";
|
||||
import PrinterControls from "./PrinterControls.vue";
|
||||
import TemperatureGraph from "./TemperatureGraph.vue";
|
||||
import WebRTCStreamView from "./WebRTCStreamView.vue";
|
||||
|
||||
@@ -43,6 +44,11 @@ const props = defineProps<{
|
||||
* No function means no player, rather than a player that cannot signal.
|
||||
*/
|
||||
signal?: (offerSdp: string) => Promise<string>;
|
||||
/**
|
||||
* Delivers a command to this printer. No function means no controls, so a
|
||||
* read-only embedding of the card cannot offer buttons that do nothing.
|
||||
*/
|
||||
send?: (command: PrinterCommand) => Promise<void>;
|
||||
}>();
|
||||
|
||||
// `status` is open-ended and null for a printer that has never reported.
|
||||
@@ -98,6 +104,8 @@ const lastSeen = computed(() => {
|
||||
|
||||
<!-- Omitted when null: an empty bar reads as 0% complete. -->
|
||||
<progress v-if="printer.progressPercent != null" :value="printer.progressPercent" max="100" />
|
||||
|
||||
<PrinterControls v-if="send" :printer="printer" :send="send" />
|
||||
</article>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user