From 2f1dd2a9fa002e22e4735fe07303a0ebed65703c Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Wed, 29 Sep 2021 20:26:24 +0100 Subject: [PATCH] :sparkles: Re: #255 - Adds an option for landing URL in workspace --- docs/alternate-views.md | 4 +++- src/components/Workspace/SideBar.vue | 14 ++++++++++++++ src/views/Workspace.vue | 19 ++++++++++++------- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/docs/alternate-views.md b/docs/alternate-views.md index de72cd1a..29dc032c 100644 --- a/docs/alternate-views.md +++ b/docs/alternate-views.md @@ -14,7 +14,9 @@ This is the main page that you will land on when you first launch the applicatio ### Workspace The workspace view displays your links in a sidebar on the left-hand side, and apps are launched within Dashy. This enables you to use all of your self-hosted apps from one place, and makes multi-tasking easy. -In the workspace view, you can keep previously opened websites/ apps open in the background, by setting `appConfig.enableMultiTasking: true`. This comes at the cost of performance, but does mean that your session with each app is preserved, enabling you to quickly switch between your apps. +In the workspace view, you can opt to keep previously opened websites/ apps open in the background, by setting `appConfig.enableMultiTasking: true`. This comes at the cost of performance, but does mean that your session with each app is preserved, enabling you to quickly switch between your apps. + +You can also specify a default app to be opened when you land on the workspace, by setting `appConfig.workspaceLandingUrl: https://app-to-open/`. If this app exists within your sections.items, then the corresponding section will also be expanded.

Example of Workspace View
diff --git a/src/components/Workspace/SideBar.vue b/src/components/Workspace/SideBar.vue index b75fba72..e3115d17 100644 --- a/src/components/Workspace/SideBar.vue +++ b/src/components/Workspace/SideBar.vue @@ -39,6 +39,7 @@ export default { inject: ['config'], props: { sections: Array, + initUrl: String, }, data() { return { @@ -56,9 +57,22 @@ export default { openSection(index) { this.isOpen = this.isOpen.map((val, ind) => (ind !== index ? false : !val)); }, + /* When item clicked, emit a launch event */ launchApp(url) { this.$emit('launch-app', url); }, + /* If an initial URL is specified, then open relevant section */ + openDefaultSection() { + if (!this.initUrl) return; + const process = (url) => url.replace(/[^\w\s]/gi, '').toLowerCase(); + const compare = (item) => (process(item.url) === process(this.initUrl)); + this.sections.forEach((section, sectionIndex) => { + if (section.items.findIndex(compare) !== -1) this.openSection(sectionIndex); + }); + }, + }, + mounted() { + this.openDefaultSection(); }, }; diff --git a/src/views/Workspace.vue b/src/views/Workspace.vue index 2878885c..bebbba1e 100644 --- a/src/views/Workspace.vue +++ b/src/views/Workspace.vue @@ -1,6 +1,6 @@