-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathWorkspace.vue
More file actions
107 lines (103 loc) · 3.1 KB
/
Workspace.vue
File metadata and controls
107 lines (103 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<template>
<div class="work-space">
<SideBar
:sections="sections"
@launch-app="launchApp"
@launch-widget="launchWidget"
:initUrl="getInitialUrl()"
/>
<WebContent :url="url" v-if="!isMultiTaskingEnabled" />
<MultiTaskingWebComtent :url="url" v-else />
<WidgetView :widgets="widgets" v-if="widgets" />
</div>
</template>
<script>
import HomeMixin from '@/mixins/HomeMixin';
import SideBar from '@/components/Workspace/SideBar';
import WebContent from '@/components/Workspace/WebContent';
import WidgetView from '@/components/Workspace/WidgetView';
import MultiTaskingWebComtent from '@/components/Workspace/MultiTaskingWebComtent';
import Defaults from '@/utils/defaults';
import ErrorHandler from '@/utils/ErrorHandler';
export default {
name: 'Workspace',
mixins: [HomeMixin],
data: () => ({
url: '',
widgets: null,
}),
computed: {
sections() {
return this.$store.getters.sections;
},
appConfig() {
return this.$store.getters.appConfig;
},
isMultiTaskingEnabled() {
return this.appConfig.enableMultiTasking || false;
},
},
components: {
SideBar,
WebContent,
WidgetView,
MultiTaskingWebComtent,
},
methods: {
launchApp(options) {
if (options.target === 'newtab') {
window.open(options.url, '_blank');
} else if (options.target === 'newwindow') {
const { width, height } = window.screen;
window.open(options.url, '_blank', `width=${width},height=${height},noopener,noreferrer`);
} else if (options.target === 'clipboard') {
if (navigator.clipboard) {
navigator.clipboard.writeText(options.url);
this.$toasted.show(this.$t('context-menus.item.copied-toast'), { className: 'toast-success' });
} else {
ErrorHandler('Clipboard access requires HTTPS. See: https://bit.ly/3N5WuAA');
this.$toasted.show('Unable to copy, see log', { className: 'toast-error' });
}
return;
} else {
this.url = options.url;
}
this.widgets = null;
},
launchWidget(widgets) {
this.url = '';
this.widgets = widgets;
},
initiateFontAwesome() {
const fontAwesomeScript = document.createElement('script');
const faKey = this.appConfig.fontAwesomeKey || Defaults.fontAwesomeKey;
fontAwesomeScript.setAttribute('src', `https://kit.fontawesome.com/${faKey}.js`);
document.head.appendChild(fontAwesomeScript);
},
/* 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() {
this.initiateFontAwesome();
this.initiateMaterialDesignIcons();
this.setTheme();
this.url = this.getInitialUrl();
},
};
</script>
<style scoped lang="scss">
.work-space {
min-height: fit-content;
}
:global(footer) {
display: none;
}
</style>