Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

:sparkles: Re: #255 - Adds an option for landing URL in workspace

Alicia Sykes2f1dd2a9fa00
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.
<p align="center">
<b>Example of Workspace View</b><br>
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();
},
};
</script>
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 @@
<template>
<div class="work-space">
- <SideBar :sections="sections" @launch-app="launchApp" />
+ <SideBar :sections="sections" @launch-app="launchApp" :initUrl="getInitialUrl()" />
<WebContent :url="url" v-if="!isMultiTaskingEnabled" />
<MultiTaskingWebComtent :url="url" v-else />
</div>
@@ -21,7 +21,7 @@ export default {
appConfig: Object,
},
data: () => ({
- url: '', // this.$route.query.url || '',
+ url: '',
GetTheme,
ApplyLocalTheme,
ApplyCustomVariables,
@@ -51,16 +51,21 @@ export default {
fontAwesomeScript.setAttribute('src', `https://kit.fontawesome.com/${faKey}.js`);
document.head.appendChild(fontAwesomeScript);
},
- repositionFooter() {
- document.getElementsByTagName('footer')[0].style.position = 'fixed';
+ /* Returns a service URL, if set as a URL param, or if user has specified landing URL */
+ getInitialUrl() {
+ const route = this.$route;
+ if (route.query && route.query.url) {
+ return decodeURI(route.query.url);
+ } else if (this.appConfig.workspaceLandingUrl) {
+ return this.appConfig.workspaceLandingUrl;
+ }
+ return undefined;
},
},
mounted() {
- const route = this.$route;
- if (route.query && route.query.url) this.url = decodeURI(route.query.url);
this.setTheme();
this.initiateFontAwesome();
- // this.repositionFooter();
+ this.url = this.getInitialUrl();
},
};