Merge branch 'scan_tab' into 'v3'

Scan tab updates

See merge request openflexure/openflexure-microscope-server!260
This commit is contained in:
Joe Knapper 2025-05-14 11:53:19 +00:00
commit 1468a90c60
5 changed files with 29 additions and 24 deletions

View file

@ -76,6 +76,7 @@ class ScanInfo(BaseModel):
created: datetime
modified: datetime
number_of_images: int
stitch_available: bool
DOWNLOADABLE_SCAN_FILES = (
@ -809,22 +810,24 @@ class SmartScanThing(Thing):
images_folder = os.path.join(path, IMG_DIR_NAME)
if os.path.isdir(images_folder):
folder_contents = os.listdir(images_folder)
scan_images = [x for x in folder_contents if IMAGE_REGEX.search(x)]
scan_images = [i for i in folder_contents if IMAGE_REGEX.search(i)]
stitches = [
i for i in folder_contents if i.endswith("_stitched.jpg")
]
number_of_images = len(scan_images)
stitch_available = len(stitches) > 0
else:
number_of_images = 0
stitch_available = False
modified = max(os.stat(root).st_mtime for root, _, _ in os.walk(path))
# If number of images is 0, should the scan be appended or ignored?
# When deleting images, empty scans should be deleted. When displaying
# scans in the GUI or choosing a new scan name, should be ignored
# A function to delete empty scan folders from the disk achieves all of this
scans.append(
ScanInfo(
name=f,
created=os.path.getctime(path),
modified=modified,
number_of_images=number_of_images,
stitch_available=stitch_available,
)
)
return scans
@ -998,12 +1001,9 @@ class SmartScanThing(Thing):
def log_buffer(buffer):
"""A short internal function to read everything in the buffer to
a multiline string and log"""
lines = []
the log"""
while line := buffer.readline():
lines.append(line)
if lines:
logger.info("".join(lines))
logger.info(line)
# Run the command piping stdout into the process for reading and
# forwarding the stdrerr to stdout

View file

@ -3,7 +3,7 @@
<svg width="100%" height="100%" viewBox="0 0 90 56" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;">
<g transform="matrix(1,0,0,1,-30.245,-47.0254)">
<g id="path3773" transform="matrix(0.12596,0,0,0.12596,28.1368,19.1335)">
<path d="M212.85,344.652C234.052,276.913 297.347,227.702 372.047,227.702C446.747,227.702 510.042,276.913 531.245,344.652L531.245,344.652L531.246,344.656C531.789,346.391 532.304,348.138 532.791,349.896C556.452,421.618 655.593,393.868 655.593,393.868L721.09,563.056L472.356,659.347L430.306,550.728L430.129,550.794L406.853,490.142C408.621,489.464 410.361,488.736 412.072,487.962C419.736,484.232 426.404,480.109 432.198,475.703C447.995,463.209 459.586,446.041 465.257,426.69C473.38,395.32 463.384,366.691 463.101,365.891C449.309,328.959 413.54,302.366 372.047,302.366C330.554,302.366 294.785,328.959 280.994,365.891C280.711,366.689 270.714,395.319 278.838,426.69C284.509,446.041 296.099,463.209 311.897,475.703C317.69,480.109 324.359,484.232 332.023,487.962C333.734,488.736 335.474,489.464 337.242,490.142L337.166,490.34C337.166,490.34 313.965,550.794 313.965,550.794L313.788,550.728L271.739,659.347L23.004,563.056L88.501,393.868C88.501,393.868 187.642,421.618 211.303,349.896C211.79,348.138 212.306,346.391 212.849,344.656L212.85,344.652L212.85,344.652Z" style="fill:#C5247F;fill-rule:nonzero;stroke:white;stroke-width:12.54px;"/>
<path d="M212.85,344.652C234.052,276.913 297.347,227.702 372.047,227.702C446.747,227.702 510.042,276.913 531.245,344.652L531.245,344.652L531.246,344.656C531.789,346.391 532.304,348.138 532.791,349.896C556.452,421.618 655.593,393.868 655.593,393.868L721.09,563.056L472.356,659.347L430.306,550.728L430.129,550.794L406.853,490.142C408.621,489.464 410.361,488.736 412.072,487.962C419.736,484.232 426.404,480.109 432.198,475.703C447.995,463.209 459.586,446.041 465.257,426.69C473.38,395.32 463.384,366.691 463.101,365.891C449.309,328.959 413.54,302.366 372.047,302.366C330.554,302.366 294.785,328.959 280.994,365.891C280.711,366.689 270.714,395.319 278.838,426.69C284.509,446.041 296.099,463.209 311.897,475.703C317.69,480.109 324.359,484.232 332.023,487.962C333.734,488.736 335.474,489.464 337.242,490.142L337.166,490.34C337.166,490.34 313.965,550.794 313.965,550.794L313.788,550.728L271.739,659.347L23.004,563.056L88.501,393.868C88.501,393.868 187.642,421.618 211.303,349.896C211.79,348.138 212.306,346.391 212.849,344.656L212.85,344.652L212.85,344.652Z" style="fill:#C5247F;fill-rule:nonzero;"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before After
Before After

View file

@ -438,6 +438,7 @@ html {
.thumbnail-fit {
max-height: 120px;
max-width: 240px;
object-fit: contain;
overflow-y: hidden;
}

View file

@ -207,7 +207,8 @@ h4, .uk-h4 {
}
.uk-card-body {
padding: 20px 16px 8px 16px;;
padding: 20px 16px 8px 16px;
width: 240px;
}
.uk-card-media-top img {

View file

@ -41,8 +41,7 @@
class="uk-padding-remove-top"
uk-lightbox="toggle: .lightbox-link"
>
<!-- Gallery capture cards -->
<!-- Gallery capture cards -->
<div class="gallery-grid uk-grid-match" uk-grid>
<div v-if="scansEmpty">
<h2>No scans available</h2>
@ -65,7 +64,7 @@
/>
</div>
</div>
<h3 class="uk-card-title">{{ item.name }}</h3>
<h3 class="uk-card-title" style="text-align: center;">{{ item.name }}</h3>
<action-button
thing="smart_scan"
action="download_zip"
@ -86,6 +85,7 @@
submit-label="Stitch Images"
thing="smart_scan"
action="stitch_scan"
v-if="item.can_stitch"
:can-terminate="false"
:submit-data="{ scan_name: item.name }"
:button-primary="false"
@ -94,15 +94,11 @@
/>
<ul>
<li>{{ item.number_of_images }} images</li>
<li>created {{ formatDate(item.created) }}</li>
<li>modified {{ formatDate(item.modified) }}</li>
<li>created: {{ formatDate(item.created) }}</li>
<li>modified: {{ formatDate(item.modified) }}</li>
<li v-if="item.number_of_images<3" style="color:red; font-weight: bold;">Not enough images to stitch</li>
<li v-else-if=!item.stitch_available style="color:red; font-weight: bold;">Scan not stitched</li>
</ul>
<div
class="uk-text-meta uk-margin-remove-top uk-padding-remove uk-width-expand"
>
<time>{{ item.created }}</time>
</div>
</div>
</div>
</div>
@ -198,6 +194,7 @@ export default {
scans.forEach(scan => {
scan.modified = Date.parse(scan.modified);
scan.created = Date.parse(scan.created);
scan.can_stitch = !scan.stitch_available && scan.number_of_images > 3;
});
scans.sort((a, b) => {
return b.modified - a.modified;
@ -280,7 +277,7 @@ export default {
display: grid;
grid-template-columns: repeat(auto-fill, 320px);
justify-content: center;
overflow-y: auto;
overflow-y: hidden;
}
.gallery-grid > div {
@ -294,4 +291,10 @@ export default {
margin-left: auto;
margin-right: auto;
}*/
ul {
display: inline-block;
text-align: center;
list-style-type:none;
}
</style>