Only delete selected data types from gallery button.
This commit is contained in:
parent
a5828fbf41
commit
c4ae7f7c90
3 changed files with 26 additions and 9 deletions
|
|
@ -45,7 +45,8 @@ class GalleryThing(lt.Thing):
|
||||||
all_ofm_things: Mapping[str, OFMThing] = lt.thing_slot()
|
all_ofm_things: Mapping[str, OFMThing] = lt.thing_slot()
|
||||||
|
|
||||||
_gallery_providing_things: Optional[Mapping[str, GalleryCompatibleThing]] = None
|
_gallery_providing_things: Optional[Mapping[str, GalleryCompatibleThing]] = None
|
||||||
_card_types: Optional[Mapping[str, GalleryCompatibleThing]] = None
|
_card_types: Optional[list[str]] = None
|
||||||
|
_card_type_map: dict[str, str] = {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def gallery_providing_things(self) -> Mapping[str, GalleryCompatibleThing]:
|
def gallery_providing_things(self) -> Mapping[str, GalleryCompatibleThing]:
|
||||||
|
|
@ -101,6 +102,7 @@ class GalleryThing(lt.Thing):
|
||||||
card_type = props["card_type"]["const"]
|
card_type = props["card_type"]["const"]
|
||||||
if card_type not in card_types:
|
if card_type not in card_types:
|
||||||
card_types.append(card_type)
|
card_types.append(card_type)
|
||||||
|
self._card_type_map[thing.name] = card_type
|
||||||
|
|
||||||
self._card_types = card_types
|
self._card_types = card_types
|
||||||
|
|
||||||
|
|
@ -133,10 +135,12 @@ class GalleryThing(lt.Thing):
|
||||||
return data_list
|
return data_list
|
||||||
|
|
||||||
@lt.action
|
@lt.action
|
||||||
def delete_all_data(self) -> None:
|
def delete_all_data(self, card_types: list[str]) -> None:
|
||||||
"""Delete all the gallery data on this microscope."""
|
"""Delete all the gallery data on this microscope with the given card types."""
|
||||||
for thing in self.gallery_providing_things.values():
|
for thing in self.gallery_providing_things.values():
|
||||||
try:
|
thing_card_type = self._card_type_map.get(thing.name)
|
||||||
thing.delete_all_gallery_items()
|
if thing_card_type in card_types:
|
||||||
except Exception as e:
|
try:
|
||||||
self.logger.exception(e)
|
thing.delete_all_gallery_items()
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.exception(e)
|
||||||
|
|
|
||||||
|
|
@ -267,6 +267,7 @@ export default {
|
||||||
|
|
||||||
#container-left {
|
#container-left {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
scrollbar-gutter: stable;
|
||||||
background-color: rgba(180, 180, 180, 0.025);
|
background-color: rgba(180, 180, 180, 0.025);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div ref="galleryDisplay" class="galleryDisplay uk-padding uk-padding-remove-top">
|
<div ref="galleryDisplay" class="gallery-display uk-padding uk-padding-remove-top">
|
||||||
<!-- Gallery nav bar -->
|
<!-- Gallery nav bar -->
|
||||||
<nav class="gallery-navbar uk-navbar-container uk-navbar-transparent" uk-navbar="mode: click">
|
<nav class="gallery-navbar uk-navbar-container uk-navbar-transparent" uk-navbar="mode: click">
|
||||||
<!-- Right side buttons -->
|
<!-- Right side buttons -->
|
||||||
|
|
@ -32,11 +32,13 @@
|
||||||
thing="gallery"
|
thing="gallery"
|
||||||
action="delete_all_data"
|
action="delete_all_data"
|
||||||
submit-label="Delete All"
|
submit-label="Delete All"
|
||||||
|
:submit-data="{ card_types: selectedCardTypes }"
|
||||||
|
:is-disabled="totalPages == 0"
|
||||||
:can-terminate="true"
|
:can-terminate="true"
|
||||||
:button-primary="false"
|
:button-primary="false"
|
||||||
:modal-progress="true"
|
:modal-progress="true"
|
||||||
:requires-confirmation="true"
|
:requires-confirmation="true"
|
||||||
:confirmation-message="'<p>Are you sure you want to delete all gallery data from the microscope?</p><p>This is <b>irreversible</b>!</p>'"
|
:confirmation-message="deleteAllConfirmationMessage"
|
||||||
@error="modalError"
|
@error="modalError"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -131,6 +133,16 @@ export default {
|
||||||
const start = (this.currentPage - 1) * this.itemsPerPage;
|
const start = (this.currentPage - 1) * this.itemsPerPage;
|
||||||
return (this.filtered_items || []).slice(start, start + this.itemsPerPage);
|
return (this.filtered_items || []).slice(start, start + this.itemsPerPage);
|
||||||
},
|
},
|
||||||
|
deleteAllConfirmationMessage() {
|
||||||
|
return `
|
||||||
|
<p>Are you sure you want to delete all gallery data with the following types</p>
|
||||||
|
<ul>
|
||||||
|
${this.selectedCardTypes.map((type) => `<li>${type}</li>`).join("\n")}
|
||||||
|
</ul>
|
||||||
|
<p>from the microscope?</p>
|
||||||
|
<p>This is <b>irreversible</b>!</p>
|
||||||
|
`;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue