mirror of https://github.com/Lissy93/dashy.git
✨ Implements multi-tasking functionality in Workspace view
This commit is contained in:
parent
6f3c9d36a1
commit
21509c727d
|
@ -1,7 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="web-content" ref="container">
|
<div class="multi-taking-view" ref="container"></div>
|
||||||
<button @click="launchApp">Click Me</button>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -11,14 +9,17 @@ import WebContent from '@/components/Workspace/WebContent';
|
||||||
export default {
|
export default {
|
||||||
name: 'WebContent',
|
name: 'WebContent',
|
||||||
props: {
|
props: {
|
||||||
url: String,
|
url: String, // The URL of currently visible app
|
||||||
currentApp: String,
|
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
openApps: [],
|
openApps: [], // List of all currently open apps
|
||||||
activeApp: '',
|
|
||||||
}),
|
}),
|
||||||
|
watch: {
|
||||||
|
/* Update the currently open app, when URL changes */
|
||||||
|
url() { this.launchApp(); },
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
/* Check if app already open or not, and call appropriate opener */
|
||||||
launchApp() {
|
launchApp() {
|
||||||
if (this.openApps.includes(this.url)) {
|
if (this.openApps.includes(this.url)) {
|
||||||
this.openExistingApp();
|
this.openExistingApp();
|
||||||
|
@ -27,17 +28,21 @@ export default {
|
||||||
this.appendNewApp();
|
this.appendNewApp();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/* Opens a new app */
|
||||||
appendNewApp() {
|
appendNewApp() {
|
||||||
const ComponentClass = Vue.extend(WebContent);
|
const ComponentClass = Vue.extend(WebContent);
|
||||||
const instance = new ComponentClass({
|
const instance = new ComponentClass({
|
||||||
propsData: { url: this.url },
|
propsData: { url: this.url, id: btoa(this.url) },
|
||||||
});
|
});
|
||||||
instance.$mount(); // pass nothing
|
instance.$mount(); // pass nothing
|
||||||
this.$refs.container.appendChild(instance.$el);
|
this.$refs.container.appendChild(instance.$el);
|
||||||
},
|
},
|
||||||
|
/* Switches visibility to an already open app */
|
||||||
openExistingApp() {
|
openExistingApp() {
|
||||||
console.log('Already Exists', this.url);
|
Array.from(document.getElementsByClassName('web-content')).forEach((frame) => {
|
||||||
// TODO: Find open frame, and set visibility
|
frame.classList.add('hide');
|
||||||
|
});
|
||||||
|
document.getElementById(btoa(this.url)).classList.remove('hide');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,8 +44,6 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import '@/styles/media-queries.scss';
|
|
||||||
@import '@/styles/style-helpers.scss';
|
|
||||||
|
|
||||||
div.side-bar-item {
|
div.side-bar-item {
|
||||||
color: var(--side-bar-color);
|
color: var(--side-bar-color);
|
||||||
|
@ -56,8 +54,10 @@ div.side-bar-item {
|
||||||
border: none;
|
border: none;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
p.small-title {
|
p.small-title {
|
||||||
margin: 0.1rem auto;
|
margin: 0.1rem 0 0 -0.5rem;
|
||||||
font-size: 0.6rem;
|
font-size: 0.6rem;
|
||||||
|
transform: rotate(-25deg);
|
||||||
|
padding: 0.5rem 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="web-content">
|
<div class="web-content" :id="id">
|
||||||
<iframe :src="url" />
|
<iframe :src="url" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -10,13 +10,15 @@ export default {
|
||||||
name: 'WebContent',
|
name: 'WebContent',
|
||||||
props: {
|
props: {
|
||||||
url: String,
|
url: String,
|
||||||
|
id: {
|
||||||
|
type: String,
|
||||||
|
default: 'web-app-view',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import '@/styles/media-queries.scss';
|
|
||||||
@import '@/styles/style-helpers.scss';
|
|
||||||
|
|
||||||
iframe {
|
iframe {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -27,4 +29,8 @@ iframe {
|
||||||
background: white;
|
background: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.web-content.hide {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue