2020-06-08 16:39:26 +03:00
|
|
|
<template>
|
|
|
|
<div id="app-dashboard">
|
2020-06-23 18:01:55 +03:00
|
|
|
<h2>{{ greeting.icon }} {{ greeting.text }}, {{ name }}</h2>
|
2020-06-08 16:39:26 +03:00
|
|
|
|
|
|
|
<div class="panels">
|
|
|
|
<div v-for="panel in panels" :key="panel.id" class="panel">
|
|
|
|
<a :href="panel.url">
|
|
|
|
<h3 :class="panel.iconClass">
|
|
|
|
{{ panel.title }}
|
|
|
|
</h3>
|
|
|
|
</a>
|
|
|
|
<div :ref="panel.id" :data-id="panel.id" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Vue from 'vue'
|
|
|
|
import { loadState } from '@nextcloud/initial-state'
|
|
|
|
import { getCurrentUser } from '@nextcloud/auth'
|
|
|
|
|
|
|
|
const panels = loadState('dashboard', 'panels')
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'App',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
timer: new Date(),
|
|
|
|
callbacks: {},
|
|
|
|
panels,
|
|
|
|
name: getCurrentUser()?.displayName,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
greeting() {
|
|
|
|
const time = this.timer.getHours()
|
|
|
|
|
|
|
|
if (time > 18) {
|
2020-06-23 18:01:55 +03:00
|
|
|
return { icon: '🌙', text: t('dashboard', 'Good evening') }
|
2020-06-08 16:39:26 +03:00
|
|
|
}
|
|
|
|
if (time > 12) {
|
2020-06-23 18:01:55 +03:00
|
|
|
return { icon: '☀', text: t('dashboard', 'Good afternoon') }
|
2020-06-08 16:39:26 +03:00
|
|
|
}
|
|
|
|
if (time === 12) {
|
2020-06-23 18:01:55 +03:00
|
|
|
return { icon: '🍽', text: t('dashboard', 'Time for lunch') }
|
2020-06-08 16:39:26 +03:00
|
|
|
}
|
2020-06-11 05:20:57 +03:00
|
|
|
if (time > 5) {
|
2020-06-23 18:01:55 +03:00
|
|
|
return { icon: '🌄', text: t('dashboard', 'Good morning') }
|
2020-06-11 05:20:57 +03:00
|
|
|
}
|
2020-06-23 18:01:55 +03:00
|
|
|
return { icon: '🦉', text: t('dashboard', 'Have a night owl') }
|
2020-06-08 16:39:26 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
callbacks() {
|
|
|
|
for (const app in this.callbacks) {
|
|
|
|
const element = this.$refs[app]
|
|
|
|
if (this.panels[app].mounted) {
|
2020-07-10 11:02:44 +03:00
|
|
|
continue
|
2020-06-08 16:39:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (element) {
|
|
|
|
this.callbacks[app](element[0])
|
|
|
|
Vue.set(this.panels[app], 'mounted', true)
|
|
|
|
} else {
|
|
|
|
console.error('Failed to register panel in the frontend as no backend data was provided for ' + app)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
setInterval(() => {
|
|
|
|
this.timer = new Date()
|
|
|
|
}, 30000)
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
register(app, callback) {
|
|
|
|
Vue.set(this.callbacks, app, callback)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
#app-dashboard {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
h2 {
|
|
|
|
text-align: center;
|
2020-06-11 05:21:24 +03:00
|
|
|
font-size: 32px;
|
|
|
|
line-height: 130%;
|
|
|
|
padding: 80px 16px 32px;
|
2020-06-08 16:39:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
.panels {
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
2020-06-11 05:21:24 +03:00
|
|
|
flex-direction: row;
|
2020-07-10 11:02:44 +03:00
|
|
|
align-items: flex-start;
|
2020-06-11 05:21:24 +03:00
|
|
|
flex-wrap: wrap;
|
2020-06-08 16:39:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
.panel {
|
|
|
|
width: 250px;
|
2020-06-11 05:21:24 +03:00
|
|
|
margin: 16px;
|
2020-06-08 16:39:26 +03:00
|
|
|
|
2020-06-11 05:21:24 +03:00
|
|
|
& > a {
|
2020-06-08 16:39:26 +03:00
|
|
|
position: sticky;
|
|
|
|
top: 50px;
|
2020-06-11 05:21:24 +03:00
|
|
|
display: block;
|
|
|
|
background: linear-gradient(var(--color-main-background-translucent), var(--color-main-background-translucent) 80%, rgba(255, 255, 255, 0));
|
|
|
|
backdrop-filter: blur(4px);
|
2020-06-08 16:39:26 +03:00
|
|
|
|
2020-06-11 05:21:24 +03:00
|
|
|
h3 {
|
|
|
|
margin: 0;
|
|
|
|
font-size: 20px;
|
|
|
|
font-weight: bold;
|
|
|
|
background-size: 32px;
|
|
|
|
background-position: 10px 10px;
|
|
|
|
padding: 16px 8px 16px 52px;
|
|
|
|
}
|
|
|
|
}
|
2020-06-08 16:39:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|