Upgraded to API v2
This commit is contained in:
parent
fce7d2ee93
commit
a33329b77d
2 changed files with 37 additions and 30 deletions
|
|
@ -44,7 +44,7 @@
|
|||
</div>
|
||||
|
||||
<div class="uk-card-footer uk-padding-small">
|
||||
<div v-for="tag in captureState.metadata.tags" :key="tag">
|
||||
<div v-for="tag in tags" :key="tag" class="uk-display-inline">
|
||||
<span
|
||||
v-if="tag === 'temporary'"
|
||||
class="uk-label uk-label-danger uk-margin-small-right"
|
||||
|
|
@ -166,20 +166,20 @@ export default {
|
|||
return "#" + this.metadataModalID;
|
||||
},
|
||||
thumbURL: function() {
|
||||
return this.captureURL + "/download?thumbnail=true";
|
||||
return `${this.$store.getters.baseUri}${
|
||||
this.captureState.links.download
|
||||
}?thumbnail=true`;
|
||||
},
|
||||
imgURL: function() {
|
||||
return this.captureURL + "/download/" + this.fileName;
|
||||
return `${this.$store.getters.baseUri}${
|
||||
this.captureState.links.download
|
||||
}`;
|
||||
},
|
||||
tagURL: function() {
|
||||
return this.captureURL + "/tags";
|
||||
tagsURL: function() {
|
||||
return `${this.$store.getters.baseUri}${this.captureState.links.tags}`;
|
||||
},
|
||||
captureURL: function() {
|
||||
return (
|
||||
this.$store.getters.uri +
|
||||
"/camera/capture/" +
|
||||
this.captureState.metadata.id
|
||||
);
|
||||
return `${this.$store.getters.baseUri}${this.captureState.links.self}`;
|
||||
},
|
||||
betterTimestring: function() {
|
||||
var dtSplit = this.captureState.metadata.time.split("_");
|
||||
|
|
@ -195,8 +195,6 @@ export default {
|
|||
|
||||
methods: {
|
||||
handleTagSubmit: function(event) {
|
||||
console.log(this.tagURL);
|
||||
console.log(this.newtag);
|
||||
this.newTagRequest(this.newtag);
|
||||
this.newtag = "";
|
||||
UIkit.modal(event.target.parentNode).hide(); // TODO: Remove somehow
|
||||
|
|
@ -225,7 +223,7 @@ export default {
|
|||
newTagRequest: function(tag_string) {
|
||||
// Send tag PUT request
|
||||
axios
|
||||
.put(this.tagURL, [tag_string])
|
||||
.put(this.tagsURL, [tag_string])
|
||||
.then(() => {
|
||||
// Update tag array
|
||||
this.getTagRequest();
|
||||
|
|
@ -246,7 +244,7 @@ export default {
|
|||
console.log(tag_string);
|
||||
// Send tag DELETE request
|
||||
axios
|
||||
.delete(this.tagURL, { data: [tag_string] })
|
||||
.delete(this.tagsURL, { data: [tag_string] })
|
||||
.then(() => {
|
||||
// Update tag array
|
||||
this.getTagRequest();
|
||||
|
|
@ -259,9 +257,9 @@ export default {
|
|||
getTagRequest: function() {
|
||||
// Send tag request
|
||||
axios
|
||||
.get(this.tagURL)
|
||||
.get(this.tagsURL)
|
||||
.then(response => {
|
||||
this.tags = response.data.metadata.tags;
|
||||
this.tags = response.data;
|
||||
})
|
||||
.catch(error => {
|
||||
this.modalError(error); // Let mixin handle error
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ export default {
|
|||
|
||||
data: function() {
|
||||
return {
|
||||
captureList: [],
|
||||
captures: {},
|
||||
checkedTags: [],
|
||||
sortDescending: true,
|
||||
galleryFolder: "",
|
||||
|
|
@ -112,10 +112,13 @@ export default {
|
|||
},
|
||||
|
||||
computed: {
|
||||
captureApiUri: function() {
|
||||
return this.$store.getters.uri + "/camera/capture";
|
||||
capturesUri: function() {
|
||||
return `${this.$store.getters.baseUri}/api/v2/captures`;
|
||||
},
|
||||
captureList: function() {
|
||||
// List of captures, obtained from this.captures values
|
||||
return Object.values(this.captures);
|
||||
},
|
||||
|
||||
allTags: function() {
|
||||
// Return an array of unique tags across all captures
|
||||
var tags = [];
|
||||
|
|
@ -130,6 +133,7 @@ export default {
|
|||
},
|
||||
|
||||
noScanCaptureList: function() {
|
||||
// List of captures that are not part of a scan
|
||||
var captures = [];
|
||||
for (var capture of this.captureList) {
|
||||
// Filter by selected tags
|
||||
|
|
@ -145,7 +149,7 @@ export default {
|
|||
},
|
||||
|
||||
allScans: function() {
|
||||
// Return an array of unique tags across all captures
|
||||
// List of scans as capture-like objects
|
||||
var scans = {};
|
||||
|
||||
for (var capture of this.captureList) {
|
||||
|
|
@ -187,12 +191,11 @@ export default {
|
|||
}
|
||||
|
||||
// Create a preview thumbnail
|
||||
// TODO: Use URI defined in capture representation
|
||||
if (!("thumbnail" in scans[id])) {
|
||||
scans[id].thumbnail =
|
||||
this.$store.getters.uri +
|
||||
"/camera/capture/" +
|
||||
capture.metadata.id +
|
||||
"/download?thumbnail=true";
|
||||
scans[id].thumbnail = `${this.$store.getters.baseUri}${
|
||||
capture.links.download
|
||||
}?thumbnail=true`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -200,10 +203,14 @@ export default {
|
|||
},
|
||||
|
||||
scanList: function() {
|
||||
// List of scans, obtained from this.allScans values
|
||||
return Object.values(this.allScans);
|
||||
},
|
||||
|
||||
itemList: function() {
|
||||
// Get list of current items to show
|
||||
// If galleryFolder (ie inside a scan folder), show scan captures
|
||||
// Otherwise, show root captures and scan cards
|
||||
if (this.galleryFolder) {
|
||||
console.log(this.allScans[this.galleryFolder].captureList);
|
||||
return this.allScans[this.galleryFolder].captureList;
|
||||
|
|
@ -213,10 +220,12 @@ export default {
|
|||
},
|
||||
|
||||
filteredItems: function() {
|
||||
// Filter itemList by checkedTags
|
||||
return this.filterCaptureList(this.itemList, this.checkedTags);
|
||||
},
|
||||
|
||||
sortedItems: function() {
|
||||
// Sort filteredItems using sortCaptureList function
|
||||
return this.sortCaptureList(this.filteredItems);
|
||||
}
|
||||
},
|
||||
|
|
@ -235,12 +244,10 @@ export default {
|
|||
methods: {
|
||||
updateCaptureList: function() {
|
||||
console.log("Updating capture list...");
|
||||
// Send move request
|
||||
axios
|
||||
.get(this.captureApiUri)
|
||||
.get(this.capturesUri)
|
||||
.then(response => {
|
||||
this.$store.dispatch("updateState"); // Update store state for good measure
|
||||
this.captureList = response.data; // Update boxes from response
|
||||
this.captures = response.data;
|
||||
})
|
||||
.catch(error => {
|
||||
this.modalError(error); // Let mixin handle error
|
||||
|
|
@ -248,6 +255,7 @@ export default {
|
|||
},
|
||||
|
||||
filterCaptureList: function(list, filterTags) {
|
||||
// Filter a list of captures by an array of tags
|
||||
var result = [];
|
||||
for (var capture of list) {
|
||||
// Assume exclusion
|
||||
|
|
@ -269,6 +277,7 @@ export default {
|
|||
},
|
||||
|
||||
sortCaptureList: function(list) {
|
||||
// Sort a list of captures by metadata time
|
||||
function compare(a, b) {
|
||||
if (a.metadata.time < b.metadata.time) return -1;
|
||||
if (a.metadata.time > b.metadata.time) return 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue