From c6458046ec2a2bced91520f6a2c11ac319fd87a1 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Fri, 13 Nov 2020 12:34:08 +0000 Subject: [PATCH] Data-driven tab layout --- .../api/static/src/components/appContent.vue | 247 ++++++++---------- 1 file changed, 109 insertions(+), 138 deletions(-) diff --git a/openflexure_microscope/api/static/src/components/appContent.vue b/openflexure_microscope/api/static/src/components/appContent.vue index 51e3cd0f..c5e0919d 100644 --- a/openflexure_microscope/api/static/src/components/appContent.vue +++ b/openflexure_microscope/api/static/src/components/appContent.vue @@ -16,63 +16,27 @@ id="switcher-left" class="uk-flex uk-flex-column uk-padding-remove uk-width-auto uk-height-1-1 uk-text-center" > - - visibility - - - - photo_library - - -
- - - gamepad - - - camera_alt - - - @@ -252,14 +162,69 @@ export default { return { plugins: [], currentTab: "view", - unwatchStoreFunction: null + unwatchStoreFunction: null, + topTabs: [ + { + id: "view", + icon: "visibility", + component: viewContent + }, + { + id: "gallery", + icon: "photo_library", + component: galleryContent, + divide: true // Add a divider after this tab icon + }, + { + id: "navigate", + icon: "gamepad", + component: navigateContent + }, + { + id: "capture", + icon: "camera_alt", + component: captureContent, + divide: true // Add a divider after this tab icon + } + ], + bottomTabs: [ + { + id: "settings", + icon: "settings", + component: settingsContent, + class: "uk-margin-auto-top" + }, + { + id: "logging", + icon: "assignment_late", + component: loggingContent + }, + { + id: "about", + icon: "info", + component: aboutContent + } + ] }; }, computed: { + enabledTopTabs: function() { + var enabledTabs = this.topTabs; + if (this.$store.state.globalSettings.IHIEnabled) { + enabledTabs.push({ + id: "slidescan", + icon: "settings_overscan", + component: slideScanContent + }); + } + return enabledTabs; + }, + pluginsUri: function() { return `${this.$store.getters.baseUri}/api/v2/extensions`; }, + pluginsGuiList: function() { // List of plugin GUIs, obtained from this.plugins values console.log("Recalculating plugins"); @@ -271,15 +236,21 @@ export default { } return pluginGuis; }, + tabOrder: function() { - // TODO: There must be a better way to do this, somehow reading the order of the HTML elements? - var ind = ["view", "gallery", "navigate", "capture", "settings"]; + var ind = []; + for (const tab of this.enabledTopTabs) { + ind.push(tab.id); + } for (const plugin of this.pluginsGuiList) { ind.push(plugin.id); } - ind.push("about"); + for (const tab of this.bottomTabs) { + ind.push(tab.id); + } return ind; }, + currentTabIndex: function() { return this.tabOrder.indexOf(this.currentTab); }