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

This commit is contained in:
Alicia Sykes
2021-09-29 20:26:24 +01:00
parent 5ec2abcf81
commit 2f1dd2a9fa
3 changed files with 29 additions and 8 deletions

View File

@@ -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>

View File

@@ -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();
},
};