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