From 421a2e396017aea1ed7b2f7fcd0a700d32d433b0 Mon Sep 17 00:00:00 2001 From: Joel Collins <2579603-jtc42@users.noreply.gitlab.com> Date: Tue, 17 Nov 2020 17:17:06 +0000 Subject: [PATCH] Replace top-level actions View with builtin LabThings --- openflexure_microscope/api/app.py | 2 -- .../aboutComponents/statusPane.vue | 14 +++++----- .../api/v2/views/actions/__init__.py | 27 ------------------- 3 files changed, 7 insertions(+), 36 deletions(-) diff --git a/openflexure_microscope/api/app.py b/openflexure_microscope/api/app.py index 8c991be5..4c8b0ef0 100644 --- a/openflexure_microscope/api/app.py +++ b/openflexure_microscope/api/app.py @@ -140,8 +140,6 @@ labthing.add_view(views.MjpegStream, "/streams/mjpeg") labthing.add_view(views.SnapshotStream, "/streams/snapshot") # Attach microscope action resources -labthing.add_view(views.actions.ActionsView, "/actions") -labthing.add_root_link(views.actions.ActionsView, "actions") for name, action in views.enabled_root_actions().items(): view_class = action["view_class"] rule = action["rule"] diff --git a/openflexure_microscope/api/static/src/components/tabContentComponents/aboutComponents/statusPane.vue b/openflexure_microscope/api/static/src/components/tabContentComponents/aboutComponents/statusPane.vue index b5b013bb..361b5ac7 100644 --- a/openflexure_microscope/api/static/src/components/tabContentComponents/aboutComponents/statusPane.vue +++ b/openflexure_microscope/api/static/src/components/tabContentComponents/aboutComponents/statusPane.vue @@ -100,8 +100,8 @@ export default { configurationUri: function() { return `${this.$store.getters.baseUri}/api/v2/instrument/configuration`; }, - actionsUri: function() { - return `${this.$store.getters.baseUri}/api/v2/actions`; + rootUri: function() { + return `${this.$store.getters.baseUri}/api/v2`; } }, @@ -135,22 +135,22 @@ export default { }, updateSystemActions: function() { axios - .get(this.actionsUri) + .get(this.rootUri) .then(response => { - if ("reboot" in response.data) { + if ("RebootAPI" in response.data.actions) { this.$set( this.systemActionLinks, "reboot", - response.data.reboot.links.self.href + `${this.$store.getters.baseUri}/api/v2/actions/system/reboot/` ); } else { delete this.systemActionLinks.reboot; } - if ("shutdown" in response.data) { + if ("ShutdownAPI" in response.data.actions) { this.$set( this.systemActionLinks, "shutdown", - response.data.shutdown.links.self.href + `${this.$store.getters.baseUri}/api/v2/actions/system/shutdown/` ); } else { delete this.systemActionLinks.shutdown; diff --git a/openflexure_microscope/api/v2/views/actions/__init__.py b/openflexure_microscope/api/v2/views/actions/__init__.py index 7ac028af..782f5342 100644 --- a/openflexure_microscope/api/v2/views/actions/__init__.py +++ b/openflexure_microscope/api/v2/views/actions/__init__.py @@ -54,30 +54,3 @@ _actions = { def enabled_root_actions(): return {k: v for k, v in _actions.items() if v["conditions"]} - - -class ActionsView(View): - def get(self): - """ - List of enabled default API actions. - - This list does not include any actions added by LabThings extensions, only - those part of the default OpenFlexure Microscope API. - """ - actions = {} - for name, action in enabled_root_actions().items(): - d = { - "links": { - "self": { - "href": url_for(action["view_class"].endpoint, _external=True), - "mimetype": "application/json", - **description_from_view(action["view_class"]), - } - }, - "rule": action["rule"], - "view_class": str(action["view_class"]), - } - - actions[name] = d - - return actions