Skip to content

Commit

Permalink
✨ Re: #255 - Adds an option for landing URL in workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 committed Sep 29, 2021
1 parent 5ec2abc commit 2f1dd2a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
4 changes: 3 additions & 1 deletion docs/alternate-views.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
14 changes: 14 additions & 0 deletions src/components/Workspace/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default {
inject: ['config'],
props: {
sections: Array,
initUrl: String,
},
data() {
return {
Expand All @@ -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>
Expand Down
19 changes: 12 additions & 7 deletions src/views/Workspace.vue
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -21,7 +21,7 @@ export default {
appConfig: Object,
},
data: () => ({
url: '', // this.$route.query.url || '',
url: '',
GetTheme,
ApplyLocalTheme,
ApplyCustomVariables,
Expand Down Expand Up @@ -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();
},
};
Expand Down

0 comments on commit 2f1dd2a

Please sign in to comment.