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"> <div class="uk-margin-remove-top uk-padding-remove uk-width-expand">
<b>{{ metadata.type || "Dataset" }}: </b> {{ metadata.image.name }} <b>{{ metadata.type || "Dataset" }}: </b> {{ metadata.image.name }}
</div> </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>
<div <div
@ -68,9 +73,11 @@
</template> </template>
<script> <script>
import axios from "axios";
// Export main app // Export main app
export default { export default {
name: "CaptureCard", name: "ScanCard",
props: { props: {
metadata: { metadata: {
@ -80,6 +87,10 @@ export default {
thumbnail: { thumbnail: {
type: String, type: String,
required: true required: true
},
captures: {
type: Array,
required: true
} }
}, },
@ -95,12 +106,43 @@ export default {
}, },
metadataModalTarget: function() { metadataModalTarget: function() {
return "#" + this.metadataModalID; return "#" + this.metadataModalID;
},
allURLs: function() {
var urls = [];
for (var capture of this.captures) {
urls.push(capture.links.self.href);
}
return urls;
} }
}, },
methods: { methods: {
makeModalName: function(prefix) { makeModalName: function(prefix) {
return prefix + this.metadata.image.id; 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" v-if="'isScan' in item"
:metadata="item.metadata" :metadata="item.metadata"
:thumbnail="item.thumbnail" :thumbnail="item.thumbnail"
:captures="item.captures"
/> />
<captureCard v-else :capture-state="item" /> <captureCard v-else :capture-state="item" />
</div> </div>