Added button to delete an entire scan

This commit is contained in:
Joel Collins 2020-05-19 10:43:30 +01:00
parent bc1df9542d
commit 1ffd2b16a8
2 changed files with 44 additions and 1 deletions

View file

@ -24,6 +24,11 @@
<div class="uk-margin-remove-top uk-padding-remove uk-width-expand">
<b>{{ metadata.type || "Dataset" }}: </b> {{ metadata.image.name }}
</div>
<div class="uk-margin-remove-top uk-padding-remove uk-width-auto">
<a href="#" class="uk-icon" @click="delAllConfirm()">
<i class="material-icons">delete</i>
</a>
</div>
</div>
<div
@ -68,9 +73,11 @@
</template>
<script>
import axios from "axios";
// Export main app
export default {
name: "CaptureCard",
name: "ScanCard",
props: {
metadata: {
@ -80,6 +87,10 @@ export default {
thumbnail: {
type: String,
required: true
},
captures: {
type: Array,
required: true
}
},
@ -95,12 +106,43 @@ export default {
},
metadataModalTarget: function() {
return "#" + this.metadataModalID;
},
allURLs: function() {
var urls = [];
for (var capture of this.captures) {
urls.push(capture.links.self.href);
}
return urls;
}
},
methods: {
makeModalName: function(prefix) {
return prefix + this.metadata.image.id;
},
delAllConfirm: function() {
var context = this;
this.modalConfirm(
"Permanantly delete all captures in this dataset?"
).then(function() {
context.deleteAll();
});
},
deleteAll: function() {
axios
.all(this.allURLs.map(l => axios.delete(l)))
.then(
axios.spread(function(...res) {
// all requests are now complete
console.log(res);
})
)
.then(() => {
// Emit signal to update capture list
this.$root.$emit("globalUpdateCaptures");
});
}
}
};

View file

@ -107,6 +107,7 @@
v-if="'isScan' in item"
:metadata="item.metadata"
:thumbnail="item.thumbnail"
:captures="item.captures"
/>
<captureCard v-else :capture-state="item" />
</div>