Updated to new metadata semantics

This commit is contained in:
Joel Collins 2020-01-29 17:53:14 +00:00
parent 32545e850c
commit b9ae730c73
10 changed files with 106 additions and 116 deletions

View file

@ -326,7 +326,7 @@ export default {
},
checkServerVersion: function() {
var versionUri = `${this.$store.getters.baseUri}/api/v2/status/version`;
var versionUri = `${this.$store.getters.baseUri}/api/v2/instrument/configuration/application/version`;
axios
.get(versionUri)
.then(response => {
@ -383,7 +383,7 @@ export default {
saveHost: function() {
// URI to get hostname directly from settings
var hostnameUri = `${this.$store.getters.baseUri}/api/v2/settings/name`;
var hostnameUri = `${this.$store.getters.baseUri}/api/v2/instrument/settings/name`;
axios
.get(hostnameUri)
.then(response => {

View file

@ -8,7 +8,7 @@
<img
class="uk-width-1-1"
:data-src="thumbURL"
:alt="captureState.metadata.id"
:alt="captureState.metadata.image.id"
width="300"
height="225"
uk-img
@ -34,7 +34,7 @@
<div
class="uk-text-meta uk-margin-remove-top uk-padding-remove uk-width-expand"
>
<time>{{ betterTimestring }}</time>
<time>{{ captureState.metadata.image.acquisitionDate }}</time>
</div>
<div
class="uk-text-meta uk-margin-remove-top uk-padding-remove uk-width-auto"
@ -77,13 +77,13 @@
<button class="uk-modal-close-default" type="button" uk-close></button>
<h2 class="uk-modal-title">{{ fileName }}</h2>
<p><b>Path: </b>{{ captureState.path }}</p>
<p><b>Time: </b>{{ betterTimestring }}</p>
<p><b>ID: </b>{{ captureState.metadata.id }}</p>
<p><b>Format: </b>{{ captureState.metadata.format }}</p>
<p><b>Time: </b>{{ captureState.metadata.image.acquisitionDate }}</p>
<p><b>ID: </b>{{ captureState.metadata.image.id }}</p>
<p><b>Format: </b>{{ captureState.metadata.image.format }}</p>
<hr />
<div v-for="(value, key) in customMetadata" :key="key">
<div v-for="(value, key) in annotations" :key="key">
<p>
<b>{{ key }}: </b>{{ value }}
</p>
@ -93,14 +93,14 @@
<div class="uk-flex-bottom" uk-grid>
<div class="uk-width-2-3">
<keyvalList v-model="newCustomMetadata" />
<keyvalList v-model="newAnnotations" />
</div>
<div class="uk-width-1-3">
<button
class="uk-button uk-button-primary uk-form-small uk-width-1-1"
@click="handleMetadataSubmit()"
@click="handleAnnotationsSubmit()"
>
Add metadata
Add annotation
</button>
</div>
</div>
@ -171,15 +171,15 @@ export default {
return {
tags: [],
newTag: "",
customMetadata: {},
newCustomMetadata: {}
annotations: {},
newAnnotations: {}
};
},
computed: {
fileName: function() {
return this.captureState.filename // If this.captureState.filename exists
? this.captureState.filename // Use this.captureState.filename
return this.captureState.name // If this.captureState.filename exists
? this.captureState.name // Use this.captureState.filename
: this.captureState.metadata.filename; // Otherwise use old this.captureState.metadata.filename
},
tagModalID: function() {
@ -203,23 +203,17 @@ export default {
tagsURL: function() {
return this.captureState.links.tags.href;
},
metadataURL: function() {
return this.captureState.links.metadata.href;
annotationsURL: function() {
return this.captureState.links.annotations.href;
},
captureURL: function() {
return this.captureState.links.self.href;
},
betterTimestring: function() {
var dtSplit = this.captureState.metadata.time.split("_");
var date = dtSplit[0];
var time = dtSplit[1].replace(/-/g, ":");
return date + " " + time;
}
},
created: function() {
this.getTagRequest();
this.getMetadataRequest();
this.getAnnotationsRequest();
},
methods: {
@ -231,9 +225,9 @@ export default {
UIkit.modal(event.target.parentNode).hide();
},
handleMetadataSubmit: function() {
this.putMetadataRequest(this.newCustomMetadata);
this.newCustomMetadata = {};
handleAnnotationsSubmit: function() {
this.putAnnotationsRequest(this.newAnnotations);
this.newAnnotations = {};
},
delCaptureConfirm: function() {
@ -269,13 +263,13 @@ export default {
});
},
putMetadataRequest: function(metadataObject) {
putAnnotationsRequest: function(annotationsObject) {
// Send metadata PUT request
axios
.put(this.metadataURL, metadataObject)
.put(this.annotationsURL, annotationsObject)
.then(() => {
// Update metadata object
this.getMetadataRequest();
this.getAnnotationsRequest();
})
.catch(error => {
this.modalError(error); // Let mixin handle error
@ -315,12 +309,12 @@ export default {
});
},
getMetadataRequest: function() {
getAnnotationsRequest: function() {
// Send tag request
axios
.get(this.metadataURL)
.get(this.annotationsURL)
.then(response => {
this.customMetadata = response.data.custom;
this.annotations = response.data;
})
.catch(error => {
this.modalError(error); // Let mixin handle error
@ -328,7 +322,7 @@ export default {
},
makeModalName: function(prefix) {
return prefix + this.captureState.metadata.id;
return prefix + this.captureState.metadata.image.id;
}
}
};

View file

@ -7,13 +7,11 @@
<img
class="uk-width-1-1"
:data-src="thumbnail"
:alt="metadata.scan_id"
:alt="metadata.id"
width="300"
height="225"
uk-img
@click="
$root.$emit('globalUpdateCaptureFolder', metadata.custom.scan_id)
"
@click="$root.$emit('globalUpdateCaptureFolder', metadata.id)"
/>
</a>
</div>
@ -24,14 +22,14 @@
uk-grid
>
<div class="uk-margin-remove-top uk-padding-remove uk-width-expand">
<b>Scan:</b> {{ metadata.custom.basename }}
<b>{{ metadata.type || "Dataset" }}: </b> {{ metadata.name }}
</div>
</div>
<div
class="uk-text-meta uk-margin-remove-top uk-padding-remove uk-width-expand"
>
<time>{{ betterTimestring }}</time>
<time>{{ metadata.acquisitionDate }}</time>
</div>
<div
class="uk-text-meta uk-margin-remove-top uk-padding-remove uk-width-auto"
@ -54,10 +52,12 @@
<div class="uk-modal-dialog uk-modal-body">
<button class="uk-modal-close-default" type="button" uk-close></button>
<h2 class="uk-modal-title">{{ metadata.basename }}</h2>
<p><b>Time: </b>{{ betterTimestring }}</p>
<p><b>Scan ID: </b>{{ metadata.custom.scan_id }}</p>
<p><b>Time: </b>{{ metadata.acquisitionDate }}</p>
<p><b>ID: </b>{{ metadata.id }}</p>
<div v-for="(value, key) in metadata.custom" :key="key">
<hr />
<div v-for="(value, key) in metadata.annotations" :key="key">
<p>
<b>{{ key }}: </b>{{ value }}
</p>
@ -95,12 +95,6 @@ export default {
},
metadataModalTarget: function() {
return "#" + this.metadataModalID;
},
betterTimestring: function() {
var dtSplit = this.metadata.custom.time.split("_");
var date = dtSplit[0];
var time = dtSplit[1].replace(/-/g, ":");
return date + " " + time;
}
},

View file

@ -127,7 +127,7 @@ export default {
// Return an array of unique tags across all captures
var tags = [];
for (var capture of this.captures) {
for (var tag of capture.metadata.tags) {
for (var tag of capture.metadata.image.tags) {
if (!tags.includes(tag)) {
tags.push(tag);
}
@ -140,11 +140,8 @@ export default {
// List of captures that are not part of a scan
var captures = [];
for (var capture of this.captures) {
// Filter by selected tags
var tags = capture.metadata.tags;
// Add to capture list if matched
if (!tags.includes(this.scanTag)) {
if (!capture.metadata.dataset) {
captures.push(capture);
}
}
@ -157,11 +154,12 @@ export default {
var scans = {};
for (var capture of this.captures) {
var custom = capture.metadata.custom;
var tags = capture.metadata.tags;
var annotations = capture.metadata.image.annotations;
var tags = capture.metadata.image.tags;
var dataset = capture.metadata.dataset;
if ("scan_id" in custom) {
var id = custom["scan_id"];
if (dataset) {
var id = dataset["id"];
// If this scan ID hasn't been seen before
if (!(id in scans)) {
@ -169,21 +167,22 @@ export default {
scans[id].isScan = true;
scans[id].captures = [];
scans[id].metadata = {
filename: custom.basename,
time: custom.time,
id: custom.scan_id
name: dataset.name,
acquisitionDate: dataset.acquisitionDate,
id: dataset.id,
type: dataset.type
};
scans[id].metadata.tags = [];
scans[id].metadata.custom = {};
scans[id].metadata.annotations = {};
}
// Add the capture object to the scan
scans[id].captures.push(capture);
// Add missing scan metadata, prioritising first capture
for (var key of Object.keys(custom)) {
if (!(key in scans[id].metadata.custom)) {
scans[id].metadata.custom[key] = custom[key];
for (var key of Object.keys(annotations)) {
if (!(key in scans[id].metadata.annotations)) {
scans[id].metadata.annotations[key] = annotations[key];
}
}
@ -196,9 +195,9 @@ export default {
// Create a preview thumbnail
if (!("thumbnail" in scans[id])) {
scans[id].thumbnail = `${
capture.links.download.href
}?thumbnail=true`;
scans[
id
].thumbnail = `${capture.links.download.href}?thumbnail=true`;
}
}
}
@ -231,12 +230,15 @@ export default {
var captures = {};
for (var item of this.filteredItems) {
// If it's a dataset
if ("captures" in item) {
for (var capture of item.captures) {
captures[capture.metadata.id] = capture;
// Get the ID of each capture in the set
captures[capture.metadata.image.id] = capture;
}
} else {
captures[item.metadata.id] = item;
// If it's a single capture, get the ID of the capture
captures[item.metadata.image.id] = item;
}
}

View file

@ -70,7 +70,7 @@ export default {
}/api/v2/actions/camera/preview/stop`;
},
settingsUri: function() {
return `${this.$store.getters.baseUri}/api/v2/settings`;
return `${this.$store.getters.baseUri}/api/v2/instrument/settings`;
}
},