Updated to new API structure
This commit is contained in:
parent
733b6f4b61
commit
fcdb30eedf
11 changed files with 113 additions and 115 deletions
|
|
@ -313,7 +313,7 @@ export default {
|
||||||
return `${this.$store.getters.baseUri}/api/v2/actions/camera/capture`;
|
return `${this.$store.getters.baseUri}/api/v2/actions/camera/capture`;
|
||||||
},
|
},
|
||||||
pluginsUri: function() {
|
pluginsUri: function() {
|
||||||
return `${this.$store.getters.baseUri}/api/v2/plugins`;
|
return `${this.$store.getters.baseUri}/api/v2/extensions`;
|
||||||
},
|
},
|
||||||
settingsFovUri: function() {
|
settingsFovUri: function() {
|
||||||
return `${this.$store.getters.baseUri}/api/v2/settings/fov`;
|
return `${this.$store.getters.baseUri}/api/v2/settings/fov`;
|
||||||
|
|
@ -395,7 +395,7 @@ export default {
|
||||||
// Flash the stream (capture animation)
|
// Flash the stream (capture animation)
|
||||||
this.$root.$emit("globalFlashStream");
|
this.$root.$emit("globalFlashStream");
|
||||||
// Update the global capture list
|
// Update the global capture list
|
||||||
this.$root.$emit("globalUpdateCaptureList");
|
this.$root.$emit("globalUpdateCaptures");
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.modalError(error); // Let mixin handle error
|
this.modalError(error); // Let mixin handle error
|
||||||
|
|
@ -407,12 +407,13 @@ export default {
|
||||||
.get(this.pluginsUri) // Get a list of plugins
|
.get(this.pluginsUri) // Get a list of plugins
|
||||||
.then(response => {
|
.then(response => {
|
||||||
var plugins = response.data;
|
var plugins = response.data;
|
||||||
|
var foundExtension = plugins.find(
|
||||||
|
e => e.title === "org.openflexure.scan"
|
||||||
|
);
|
||||||
// if ScanPlugin is enabled
|
// if ScanPlugin is enabled
|
||||||
if ("ScanPlugin" in plugins) {
|
if (foundExtension) {
|
||||||
// Get plugin action link
|
// Get plugin action link
|
||||||
var link = plugins.ScanPlugin.views.tile.links.self;
|
this.scanUri = foundExtension.links.tile.href;
|
||||||
// Store plugin action URI
|
|
||||||
this.scanUri = `${this.$store.getters.baseUri}${link}`;
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|
@ -422,7 +423,7 @@ export default {
|
||||||
|
|
||||||
updateScanStepSize: function() {
|
updateScanStepSize: function() {
|
||||||
axios
|
axios
|
||||||
.get(this.settingsFovUri) // Get a list of plugins
|
.get(this.settingsFovUri) // Get the microscope FOV
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.scanStepSize = {
|
this.scanStepSize = {
|
||||||
x: parseInt(0.5 * response.data[0]),
|
x: parseInt(0.5 * response.data[0]),
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ export default {
|
||||||
return `${this.$store.getters.baseUri}/api/v2/status/stage/position`;
|
return `${this.$store.getters.baseUri}/api/v2/status/stage/position`;
|
||||||
},
|
},
|
||||||
pluginsUri: function() {
|
pluginsUri: function() {
|
||||||
return `${this.$store.getters.baseUri}/api/v2/plugins`;
|
return `${this.$store.getters.baseUri}/api/v2/extensions`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -352,17 +352,14 @@ export default {
|
||||||
.get(this.pluginsUri) // Get a list of plugins
|
.get(this.pluginsUri) // Get a list of plugins
|
||||||
.then(response => {
|
.then(response => {
|
||||||
var plugins = response.data;
|
var plugins = response.data;
|
||||||
|
var foundExtension = plugins.find(
|
||||||
|
e => e.title === "org.openflexure.autofocus"
|
||||||
|
);
|
||||||
// if ScanPlugin is enabled
|
// if ScanPlugin is enabled
|
||||||
if ("AutofocusPlugin" in plugins) {
|
if (foundExtension) {
|
||||||
// Get plugin action link
|
// Get plugin action link
|
||||||
var fastLink =
|
this.fastAutofocusUri = foundExtension.links.fast_autofocus.href;
|
||||||
plugins.AutofocusPlugin.views.fast_autofocus.links.self;
|
this.normalAutofocusUri = foundExtension.links.autofocus.href;
|
||||||
var normalLink = plugins.AutofocusPlugin.views.autofocus.links.self;
|
|
||||||
// Store plugin action URI
|
|
||||||
this.fastAutofocusUri = `${this.$store.getters.baseUri}${fastLink}`;
|
|
||||||
this.normalAutofocusUri = `${
|
|
||||||
this.$store.getters.baseUri
|
|
||||||
}${normalLink}`;
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|
|
||||||
|
|
@ -144,16 +144,14 @@ export default {
|
||||||
.get(this.actionsUri)
|
.get(this.actionsUri)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if ("reboot" in response.data) {
|
if ("reboot" in response.data) {
|
||||||
this.systemActionLinks.reboot = `${this.$store.getters.baseUri}${
|
this.systemActionLinks.reboot =
|
||||||
response.data.reboot.links.self
|
response.data.reboot.links.self.href;
|
||||||
}`;
|
|
||||||
} else {
|
} else {
|
||||||
delete this.systemActionLinks.reboot;
|
delete this.systemActionLinks.reboot;
|
||||||
}
|
}
|
||||||
if ("shutdown" in response.data) {
|
if ("shutdown" in response.data) {
|
||||||
this.systemActionLinks.shutdown = `${this.$store.getters.baseUri}${
|
this.systemActionLinks.shutdown =
|
||||||
response.data.shutdown.links.self
|
response.data.shutdown.links.self.href;
|
||||||
}`;
|
|
||||||
} else {
|
} else {
|
||||||
delete this.systemActionLinks.shutdown;
|
delete this.systemActionLinks.shutdown;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ export default {
|
||||||
return `${this.$store.getters.baseUri}/api/v2/settings`;
|
return `${this.$store.getters.baseUri}/api/v2/settings`;
|
||||||
},
|
},
|
||||||
pluginsUri: function() {
|
pluginsUri: function() {
|
||||||
return `${this.$store.getters.baseUri}/api/v2/plugins`;
|
return `${this.$store.getters.baseUri}/api/v2/extensions`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -122,13 +122,13 @@ export default {
|
||||||
.get(this.pluginsUri) // Get a list of plugins
|
.get(this.pluginsUri) // Get a list of plugins
|
||||||
.then(response => {
|
.then(response => {
|
||||||
var plugins = response.data;
|
var plugins = response.data;
|
||||||
|
var foundExtension = plugins.find(
|
||||||
|
e => e.title === "org.openflexure.calibration.picamera"
|
||||||
|
);
|
||||||
// if AutocalibrationPlugin is enabled
|
// if AutocalibrationPlugin is enabled
|
||||||
if ("AutocalibrationPlugin" in plugins) {
|
if (foundExtension) {
|
||||||
// Get plugin action link
|
// Get plugin action link
|
||||||
var link =
|
this.recalibrationUri = foundExtension.links.recalibrate.href;
|
||||||
plugins.AutocalibrationPlugin.views.recalibrate.links.self;
|
|
||||||
// Store plugin action URI
|
|
||||||
this.recalibrationUri = `${this.$store.getters.baseUri}${link}`;
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export default {
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: Number,
|
type: Number,
|
||||||
required: false,
|
required: false,
|
||||||
default: NaN
|
default: 0
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,6 @@
|
||||||
:route="form.route"
|
:route="form.route"
|
||||||
:is-task="form.isTask"
|
:is-task="form.isTask"
|
||||||
:submit-label="form.submitLabel"
|
:submit-label="form.submitLabel"
|
||||||
:self-update="form.selfUpdate"
|
|
||||||
:schema="form.schema"
|
:schema="form.schema"
|
||||||
@reloadForms="updatePlugins()"
|
@reloadForms="updatePlugins()"
|
||||||
/>
|
/>
|
||||||
|
|
@ -158,7 +157,7 @@ export default {
|
||||||
|
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
plugins: {},
|
plugins: [],
|
||||||
currentTab: "status",
|
currentTab: "status",
|
||||||
showControlBar: true,
|
showControlBar: true,
|
||||||
unwatchStoreFunction: null
|
unwatchStoreFunction: null
|
||||||
|
|
@ -167,15 +166,15 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
pluginsUri: function() {
|
pluginsUri: function() {
|
||||||
return `${this.$store.getters.baseUri}/api/v2/plugins`;
|
return `${this.$store.getters.baseUri}/api/v2/extensions`;
|
||||||
},
|
},
|
||||||
pluginsGuiList: function() {
|
pluginsGuiList: function() {
|
||||||
// List of plugin GUIs, obtained from this.plugins values
|
// List of plugin GUIs, obtained from this.plugins values
|
||||||
console.log("Recalculating plugins");
|
console.log("Recalculating plugins");
|
||||||
var pluginGuis = [];
|
var pluginGuis = [];
|
||||||
for (let plugin of Object.values(this.plugins)) {
|
for (let plugin of Object.values(this.plugins)) {
|
||||||
if (plugin.gui) {
|
if (plugin.meta.gui) {
|
||||||
pluginGuis.push(plugin.gui);
|
pluginGuis.push(plugin.meta.gui);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pluginGuis;
|
return pluginGuis;
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ export default {
|
||||||
// If entering the gallery
|
// If entering the gallery
|
||||||
if (index == "gallery") {
|
if (index == "gallery") {
|
||||||
console.log("Gallery tab entered");
|
console.log("Gallery tab entered");
|
||||||
this.$root.$emit("globalUpdateCaptureList");
|
this.$root.$emit("globalUpdateCaptures");
|
||||||
}
|
}
|
||||||
// If entering the stream
|
// If entering the stream
|
||||||
if (index == "preview") {
|
if (index == "preview") {
|
||||||
|
|
|
||||||
|
|
@ -111,11 +111,6 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
required: false,
|
required: false,
|
||||||
default: "Submit"
|
default: "Submit"
|
||||||
},
|
|
||||||
selfUpdate: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
default: false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -127,7 +122,7 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
pluginApiUri: function() {
|
pluginApiUri: function() {
|
||||||
return `${this.$store.getters.baseUri}/api/v2/plugins`;
|
return `${this.$store.getters.baseUri}/api/v2/extensions`;
|
||||||
},
|
},
|
||||||
|
|
||||||
submitApiUri: function() {
|
submitApiUri: function() {
|
||||||
|
|
@ -136,12 +131,15 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
// Whenever the form schema updates, re-check server for field values
|
||||||
|
schema: function() {
|
||||||
|
this.updateFormValues();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.initialiseFormData();
|
this.initialiseFormData();
|
||||||
|
|
||||||
if (this.selfUpdate) {
|
|
||||||
this.getFormData();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -158,38 +156,49 @@ export default {
|
||||||
var defaultValue; // Initial value of the form component
|
var defaultValue; // Initial value of the form component
|
||||||
for (const subfield of field) {
|
for (const subfield of field) {
|
||||||
// If a default value is given in the schema, use this
|
// If a default value is given in the schema, use this
|
||||||
defaultValue = subfield.default ? subfield.default : null;
|
if (subfield.value) {
|
||||||
|
defaultValue = subfield.value;
|
||||||
|
} else if (subfield.default) {
|
||||||
|
defaultValue = subfield.default;
|
||||||
|
} else {
|
||||||
|
defaultValue = null;
|
||||||
|
}
|
||||||
this.$set(this.formData, subfield.name, defaultValue);
|
this.$set(this.formData, subfield.name, defaultValue);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If a default value is given in the schema, use this
|
// If a default value is given in the schema, use this
|
||||||
defaultValue = field.default ? field.default : null;
|
if (field.value) {
|
||||||
|
defaultValue = field.value;
|
||||||
|
} else if (field.default) {
|
||||||
|
defaultValue = field.default;
|
||||||
|
} else {
|
||||||
|
defaultValue = null;
|
||||||
|
}
|
||||||
this.$set(this.formData, field.name, defaultValue);
|
this.$set(this.formData, field.name, defaultValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateFormValues() {
|
||||||
|
for (const field of this.schema) {
|
||||||
|
if (Array.isArray(field)) {
|
||||||
|
for (const subfield of field) {
|
||||||
|
// If a default value is given in the schema, use this
|
||||||
|
if (subfield.value) {
|
||||||
|
this.$set(this.formData, subfield.name, subfield.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (field.value) {
|
||||||
|
this.$set(this.formData, field.name, field.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
updateForm() {
|
updateForm() {
|
||||||
// Trigger a plugin form update
|
// Trigger a plugin form update
|
||||||
this.$emit("reloadForms");
|
this.$emit("reloadForms");
|
||||||
// If the form can self-update (GET request to update component values)
|
|
||||||
if (this.selfUpdate) {
|
|
||||||
// Update form data values using a GET request
|
|
||||||
this.getFormData();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
getFormData: function() {
|
|
||||||
// Send a quick request
|
|
||||||
axios
|
|
||||||
.get(this.submitApiUri)
|
|
||||||
.then(response => {
|
|
||||||
console.log(response.data);
|
|
||||||
Object.assign(this.formData, response.data);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.modalError(error); // Let mixin handle error
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
newQuickRequest: function(params) {
|
newQuickRequest: function(params) {
|
||||||
|
|
|
||||||
|
|
@ -195,20 +195,19 @@ export default {
|
||||||
return "#" + this.metadataModalID;
|
return "#" + this.metadataModalID;
|
||||||
},
|
},
|
||||||
thumbURL: function() {
|
thumbURL: function() {
|
||||||
return `${this.$store.getters.baseUri}${
|
return `${this.captureState.links.download.href}?thumbnail=true`;
|
||||||
this.captureState.links.download
|
|
||||||
}?thumbnail=true`;
|
|
||||||
},
|
},
|
||||||
imgURL: function() {
|
imgURL: function() {
|
||||||
return `${this.$store.getters.baseUri}${
|
return this.captureState.links.download.href;
|
||||||
this.captureState.links.download
|
|
||||||
}`;
|
|
||||||
},
|
},
|
||||||
tagsURL: function() {
|
tagsURL: function() {
|
||||||
return `${this.$store.getters.baseUri}${this.captureState.links.tags}`;
|
return this.captureState.links.tags.href;
|
||||||
|
},
|
||||||
|
metadataURL: function() {
|
||||||
|
return this.captureState.links.metadata.href;
|
||||||
},
|
},
|
||||||
captureURL: function() {
|
captureURL: function() {
|
||||||
return `${this.$store.getters.baseUri}${this.captureState.links.self}`;
|
return this.captureState.links.self.href;
|
||||||
},
|
},
|
||||||
betterTimestring: function() {
|
betterTimestring: function() {
|
||||||
var dtSplit = this.captureState.metadata.time.split("_");
|
var dtSplit = this.captureState.metadata.time.split("_");
|
||||||
|
|
@ -250,7 +249,7 @@ export default {
|
||||||
.delete(this.captureURL)
|
.delete(this.captureURL)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// Emit signal to update capture list
|
// Emit signal to update capture list
|
||||||
this.$root.$emit("globalUpdateCaptureList");
|
this.$root.$emit("globalUpdateCaptures");
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.modalError(error); // Let mixin handle error
|
this.modalError(error); // Let mixin handle error
|
||||||
|
|
@ -273,7 +272,7 @@ export default {
|
||||||
putMetadataRequest: function(metadataObject) {
|
putMetadataRequest: function(metadataObject) {
|
||||||
// Send metadata PUT request
|
// Send metadata PUT request
|
||||||
axios
|
axios
|
||||||
.put(this.captureURL, metadataObject)
|
.put(this.metadataURL, metadataObject)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// Update metadata object
|
// Update metadata object
|
||||||
this.getMetadataRequest();
|
this.getMetadataRequest();
|
||||||
|
|
@ -319,9 +318,9 @@ export default {
|
||||||
getMetadataRequest: function() {
|
getMetadataRequest: function() {
|
||||||
// Send tag request
|
// Send tag request
|
||||||
axios
|
axios
|
||||||
.get(this.captureURL)
|
.get(this.metadataURL)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.customMetadata = response.data.metadata.custom;
|
this.customMetadata = response.data.custom;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.modalError(error); // Let mixin handle error
|
this.modalError(error); // Let mixin handle error
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
pluginsUri: function() {
|
pluginsUri: function() {
|
||||||
return `${this.$store.getters.baseUri}/api/v2/plugins`;
|
return `${this.$store.getters.baseUri}/api/v2/extensions`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -73,14 +73,14 @@ export default {
|
||||||
.get(this.pluginsUri) // Get a list of plugins
|
.get(this.pluginsUri) // Get a list of plugins
|
||||||
.then(response => {
|
.then(response => {
|
||||||
var plugins = response.data;
|
var plugins = response.data;
|
||||||
|
var foundExtension = plugins.find(
|
||||||
|
e => e.title === "org.openflexure.zipbuilder"
|
||||||
|
);
|
||||||
// if ZipBuilderPlugin is enabled
|
// if ZipBuilderPlugin is enabled
|
||||||
if ("ZipBuilderPlugin" in plugins) {
|
if (foundExtension) {
|
||||||
// Get plugin action link
|
// Get plugin action links
|
||||||
var builderLink = plugins.ZipBuilderPlugin.views.build.links.self;
|
this.zipBuilderUri = foundExtension.links.build.href;
|
||||||
var getterLink = plugins.ZipBuilderPlugin.views.get.links.self;
|
this.zipGetterUri = foundExtension.links.get.href;
|
||||||
// Store plugin action URI
|
|
||||||
this.zipBuilderUri = `${this.$store.getters.baseUri}${builderLink}`;
|
|
||||||
this.zipGetterUri = `${this.$store.getters.baseUri}${getterLink}`;
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ export default {
|
||||||
|
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
captures: {},
|
captures: [],
|
||||||
checkedTags: [],
|
checkedTags: [],
|
||||||
sortDescending: true,
|
sortDescending: true,
|
||||||
galleryFolder: "",
|
galleryFolder: "",
|
||||||
|
|
@ -123,14 +123,10 @@ export default {
|
||||||
capturesUri: function() {
|
capturesUri: function() {
|
||||||
return `${this.$store.getters.baseUri}/api/v2/captures`;
|
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() {
|
allTags: function() {
|
||||||
// Return an array of unique tags across all captures
|
// Return an array of unique tags across all captures
|
||||||
var tags = [];
|
var tags = [];
|
||||||
for (var capture of this.captureList) {
|
for (var capture of this.captures) {
|
||||||
for (var tag of capture.metadata.tags) {
|
for (var tag of capture.metadata.tags) {
|
||||||
if (!tags.includes(tag)) {
|
if (!tags.includes(tag)) {
|
||||||
tags.push(tag);
|
tags.push(tag);
|
||||||
|
|
@ -140,10 +136,10 @@ export default {
|
||||||
return tags.sort();
|
return tags.sort();
|
||||||
},
|
},
|
||||||
|
|
||||||
noScanCaptureList: function() {
|
noScanCaptures: function() {
|
||||||
// List of captures that are not part of a scan
|
// List of captures that are not part of a scan
|
||||||
var captures = [];
|
var captures = [];
|
||||||
for (var capture of this.captureList) {
|
for (var capture of this.captures) {
|
||||||
// Filter by selected tags
|
// Filter by selected tags
|
||||||
var tags = capture.metadata.tags;
|
var tags = capture.metadata.tags;
|
||||||
|
|
||||||
|
|
@ -160,7 +156,7 @@ export default {
|
||||||
// List of scans as capture-like objects
|
// List of scans as capture-like objects
|
||||||
var scans = {};
|
var scans = {};
|
||||||
|
|
||||||
for (var capture of this.captureList) {
|
for (var capture of this.captures) {
|
||||||
var custom = capture.metadata.custom;
|
var custom = capture.metadata.custom;
|
||||||
var tags = capture.metadata.tags;
|
var tags = capture.metadata.tags;
|
||||||
|
|
||||||
|
|
@ -171,7 +167,7 @@ export default {
|
||||||
if (!(id in scans)) {
|
if (!(id in scans)) {
|
||||||
scans[id] = {};
|
scans[id] = {};
|
||||||
scans[id].isScan = true;
|
scans[id].isScan = true;
|
||||||
scans[id].captureList = [];
|
scans[id].captures = [];
|
||||||
scans[id].metadata = {
|
scans[id].metadata = {
|
||||||
filename: custom.basename,
|
filename: custom.basename,
|
||||||
time: custom.time,
|
time: custom.time,
|
||||||
|
|
@ -182,7 +178,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the capture object to the scan
|
// Add the capture object to the scan
|
||||||
scans[id].captureList.push(capture);
|
scans[id].captures.push(capture);
|
||||||
|
|
||||||
// Add missing scan metadata, prioritising first capture
|
// Add missing scan metadata, prioritising first capture
|
||||||
for (var key of Object.keys(custom)) {
|
for (var key of Object.keys(custom)) {
|
||||||
|
|
@ -199,10 +195,9 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a preview thumbnail
|
// Create a preview thumbnail
|
||||||
// TODO: Use URI defined in capture representation
|
|
||||||
if (!("thumbnail" in scans[id])) {
|
if (!("thumbnail" in scans[id])) {
|
||||||
scans[id].thumbnail = `${this.$store.getters.baseUri}${
|
scans[id].thumbnail = `${
|
||||||
capture.links.download
|
capture.links.download.href
|
||||||
}?thumbnail=true`;
|
}?thumbnail=true`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -220,24 +215,24 @@ export default {
|
||||||
// If galleryFolder (ie inside a scan folder), show scan captures
|
// If galleryFolder (ie inside a scan folder), show scan captures
|
||||||
// Otherwise, show root captures and scan cards
|
// Otherwise, show root captures and scan cards
|
||||||
if (this.galleryFolder) {
|
if (this.galleryFolder) {
|
||||||
console.log(this.allScans[this.galleryFolder].captureList);
|
console.log(this.allScans[this.galleryFolder].captures);
|
||||||
return this.allScans[this.galleryFolder].captureList;
|
return this.allScans[this.galleryFolder].captures;
|
||||||
} else {
|
} else {
|
||||||
return this.noScanCaptureList.concat(this.scanList);
|
return this.noScanCaptures.concat(this.scanList);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
filteredItems: function() {
|
filteredItems: function() {
|
||||||
// Filter itemList by checkedTags
|
// Filter itemList by checkedTags
|
||||||
return this.filterCaptureList(this.itemList, this.checkedTags);
|
return this.filterCaptures(this.itemList, this.checkedTags);
|
||||||
},
|
},
|
||||||
|
|
||||||
filteredCaptures: function() {
|
filteredCaptures: function() {
|
||||||
var captures = {};
|
var captures = {};
|
||||||
|
|
||||||
for (var item of this.filteredItems) {
|
for (var item of this.filteredItems) {
|
||||||
if ("captureList" in item) {
|
if ("captures" in item) {
|
||||||
for (var capture of item.captureList) {
|
for (var capture of item.captures) {
|
||||||
captures[capture.metadata.id] = capture;
|
captures[capture.metadata.id] = capture;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -249,15 +244,15 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
sortedItems: function() {
|
sortedItems: function() {
|
||||||
// Sort filteredItems using sortCaptureList function
|
// Sort filteredItems using sortCaptures function
|
||||||
return this.sortCaptureList(this.filteredItems);
|
return this.sortCaptures(this.filteredItems);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
// A global signal listener to perform a gallery refresh
|
// A global signal listener to perform a gallery refresh
|
||||||
this.$root.$on("globalUpdateCaptureList", () => {
|
this.$root.$on("globalUpdateCaptures", () => {
|
||||||
this.updateCaptureList();
|
this.updateCaptures();
|
||||||
});
|
});
|
||||||
// A global signal listener to set the gallery folder
|
// A global signal listener to set the gallery folder
|
||||||
this.$root.$on("globalUpdateCaptureFolder", folder => {
|
this.$root.$on("globalUpdateCaptureFolder", folder => {
|
||||||
|
|
@ -274,7 +269,7 @@ export default {
|
||||||
ready => {
|
ready => {
|
||||||
if (ready) {
|
if (ready) {
|
||||||
// If the connection is now ready, update capture list
|
// If the connection is now ready, update capture list
|
||||||
this.updateCaptureList();
|
this.updateCaptures();
|
||||||
} else {
|
} else {
|
||||||
// If the connection is now disconnected, empty capture list
|
// If the connection is now disconnected, empty capture list
|
||||||
this.captures = {};
|
this.captures = {};
|
||||||
|
|
@ -285,7 +280,7 @@ export default {
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
// Remove global signal listener to perform a gallery refresh
|
// Remove global signal listener to perform a gallery refresh
|
||||||
this.$root.$off("globalUpdateCaptureList");
|
this.$root.$off("globalUpdateCaptures");
|
||||||
// Remove global signal listener to set the gallery folder
|
// Remove global signal listener to set the gallery folder
|
||||||
this.$root.$off("globalUpdateCaptureFolder");
|
this.$root.$off("globalUpdateCaptureFolder");
|
||||||
// Then we call that function here to unwatch
|
// Then we call that function here to unwatch
|
||||||
|
|
@ -296,7 +291,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
updateCaptureList: function() {
|
updateCaptures: function() {
|
||||||
console.log("Updating capture list...");
|
console.log("Updating capture list...");
|
||||||
axios
|
axios
|
||||||
.get(this.capturesUri)
|
.get(this.capturesUri)
|
||||||
|
|
@ -308,7 +303,7 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
filterCaptureList: function(list, filterTags) {
|
filterCaptures: function(list, filterTags) {
|
||||||
// Filter a list of captures by an array of tags
|
// Filter a list of captures by an array of tags
|
||||||
var result = [];
|
var result = [];
|
||||||
for (var capture of list) {
|
for (var capture of list) {
|
||||||
|
|
@ -330,7 +325,7 @@ export default {
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
sortCaptureList: function(list) {
|
sortCaptures: function(list) {
|
||||||
// Sort a list of captures by metadata time
|
// Sort a list of captures by metadata time
|
||||||
function compare(a, b) {
|
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