From cd6bcd196f8062332a0fb3f9c401b34531bc886c Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Fri, 19 Sep 2025 18:29:34 +0100 Subject: [PATCH] Don't show buttons for ongoing scans. --- .../things/smart_scan.py | 18 ++- .../scanListComponents/scanCard.vue | 129 +++++++++++------- .../tabContentComponents/scanListContent.vue | 9 +- 3 files changed, 100 insertions(+), 56 deletions(-) diff --git a/src/openflexure_microscope_server/things/smart_scan.py b/src/openflexure_microscope_server/things/smart_scan.py index 1b760e13..44fddb61 100644 --- a/src/openflexure_microscope_server/things/smart_scan.py +++ b/src/openflexure_microscope_server/things/smart_scan.py @@ -17,6 +17,7 @@ from subprocess import SubprocessError from fastapi import HTTPException from fastapi.responses import FileResponse import numpy as np +from pydantic import BaseModel import labthings_fastapi as lt @@ -39,6 +40,16 @@ CSMDep = lt.deps.direct_thing_client_dependency( AutofocusDep = lt.deps.direct_thing_client_dependency(AutofocusThing, "/autofocus/") +class ScanListData(BaseModel): + """The data to be sent to the Scan List tab.""" + + scans: list[scan_directories.ScanInfo] + """The list of scans as ScanInfo objects""" + + ongoing: Optional[str] + """The name of the ongoing scan or None""" + + class JPEGBlob(lt.blob.Blob): """A class representing a JPEG image as a LabThings FastAPI Blob.""" @@ -557,7 +568,7 @@ class SmartScanThing(lt.Thing): """Whether to run a final stitch at the end of a successful scan.""" @lt.thing_property - def scans(self) -> list[scan_directories.ScanInfo]: + def scans(self) -> ScanListData: """All the available scans. Each scan has a name (which can be used to access it), along with @@ -566,7 +577,10 @@ class SmartScanThing(lt.Thing): uses a regular expression, and changes to the naming scheme will break it. """ - return self._scan_dir_manager.all_scans_info() + return ScanListData( + scans=self._scan_dir_manager.all_scans_info(), + ongoing=None if self._ongoing_scan is None else self._ongoing_scan.name, + ) @lt.fastapi_endpoint( "get", diff --git a/webapp/src/components/tabContentComponents/scanListComponents/scanCard.vue b/webapp/src/components/tabContentComponents/scanListComponents/scanCard.vue index cef8e35b..a44d5406 100644 --- a/webapp/src/components/tabContentComponents/scanListComponents/scanCard.vue +++ b/webapp/src/components/tabContentComponents/scanListComponents/scanCard.vue @@ -14,61 +14,64 @@ /> -

{{ scanData.name }}

-
-
- - {{ scanData.name }} +

Scan in progress

+
+
+ -
- - - + +
+ + +
-
    -
  • {{ scanData.number_of_images }} images
  • -
  • created: {{ formatDate(scanData.created) }}
  • -
  • modified: {{ formatDate(scanData.modified) }}
  • -
-
  • Not enough images to stitch
  • -
  • Interactive preview not available
  • -
  • High quality stitch not available
  • +
      +
    • {{ scanData.number_of_images }} images
    • +
    • created: {{ formatDate(scanData.created) }}
    • +
    • modified: {{ formatDate(scanData.modified) }}
    • +
    +
      +
    • Not enough images to stitch
    • +
    • Interactive preview not available
    • +
    • High quality stitch not available
    • +
    @@ -92,6 +95,10 @@ export default { scansUri: { type: String, required: true + }, + ongoing: { + type: Boolean, + required: true } }, @@ -124,7 +131,9 @@ export default { }, requestViewer() { // Notify parent that thumbnail was clicked - this.$emit('viewer-requested', this.scanData); + if (!this.ongoing) { + this.$emit('viewer-requested', this.scanData); + } }, async deleteScan() { try { @@ -165,9 +174,23 @@ ul { font-weight: bold; } -.alert-msg{ +.alert-msg { color: orange; text-align: center; font-weight: bold; } + +.scan-card-buttons { + width: 100%; +} + +.scan-card-title { + text-align: center; +} + +.ongoing-msg { + text-align: center; + padding: 2rem 0; +} + \ No newline at end of file diff --git a/webapp/src/components/tabContentComponents/scanListContent.vue b/webapp/src/components/tabContentComponents/scanListContent.vue index d4434415..7cf1d4dc 100644 --- a/webapp/src/components/tabContentComponents/scanListContent.vue +++ b/webapp/src/components/tabContentComponents/scanListContent.vue @@ -88,6 +88,7 @@ @@ -112,6 +113,7 @@ export default { data: function() { return { scans: [], + ongoing: null, selectedScan: null, osdViewer: null }; @@ -191,7 +193,9 @@ export default { }, async updateScans() { try { - let scans = await this.readThingProperty("smart_scan", "scans"); + let scans_information = await this.readThingProperty("smart_scan", "scans"); + let scans = scans_information.scans + this.ongoing = scans_information.ongoing if (!scans | (scans.length == 0)) { this.scans = scans; } @@ -208,6 +212,9 @@ export default { this.scans = []; } }, + isOngoing(name) { + return name === this.ongoing + }, async deleteAllScans() { try { await this.modalConfirm(