platypush/platypush/backend/http/webapp/src/App.vue

91 lines
2.0 KiB
Vue
Raw Normal View History

2020-11-21 01:12:08 +01:00
<template>
2020-11-28 01:12:47 +01:00
<Events ref="events" :ws-port="config['backend.http'].websocket_port" v-if="hasWebsocket" />
2020-11-27 23:12:10 +01:00
<Notifications ref="notifications" />
2020-11-28 01:12:47 +01:00
<VoiceAssistant ref="voice-assistant" v-if="hasAssistant" />
<Pushbullet ref="pushbullet" v-if="hasPushbullet" />
<router-view />
2020-11-21 01:12:08 +01:00
</template>
<script>
2020-11-27 23:12:10 +01:00
import Notifications from "@/components/Notifications";
2020-11-21 01:12:08 +01:00
import Utils from "@/Utils";
2020-11-27 23:12:10 +01:00
import Events from "@/Events";
import VoiceAssistant from "@/components/VoiceAssistant";
import { bus } from "@/bus";
2020-11-28 01:12:47 +01:00
import Pushbullet from "@/components/Pushbullet";
2020-11-21 01:12:08 +01:00
export default {
name: 'App',
mixins: [Utils],
2020-11-28 01:12:47 +01:00
components: {Pushbullet, Notifications, Events, VoiceAssistant},
2020-11-21 01:12:08 +01:00
data() {
return {
config: {},
2020-11-21 01:12:08 +01:00
}
},
2020-11-28 01:12:47 +01:00
computed: {
hasWebsocket() {
return Object.keys(this.config).length > 0 &&
'backend.http' in this.config
},
hasAssistant() {
return this.hasWebsocket
},
hasPushbullet() {
return this.hasWebsocket && (
'pushbullet' in this.config ||
'backend.pushbullet' in this.config
)
},
},
2020-11-21 01:12:08 +01:00
methods: {
onNotification(notification) {
this.$refs.notifications.create(notification)
},
async initConfig() {
this.config = await this.request('config.get')
2020-11-21 01:12:08 +01:00
}
},
created() {
this.initConfig()
},
2020-11-21 01:12:08 +01:00
mounted() {
bus.on('notification-create', this.onNotification)
},
2020-11-21 01:12:08 +01:00
}
</script>
<!--suppress CssUnusedSymbol -->
<style lang="scss">
$fa-font-path: "~@fortawesome/fontawesome-free/webfonts";
@import "~@fortawesome/fontawesome-free/scss/fontawesome";
@import "~@fortawesome/fontawesome-free/scss/solid"; // fas
@import "~@fortawesome/fontawesome-free/scss/regular"; // far
@import "~@fortawesome/fontawesome-free/scss/brands"; // fab
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: auto;
}
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
width: 100%;
height: 100%;
color: #2c3e50;
}
</style>