Show salutation based on the time of day
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2021-07-06 17:13:13 +02:00
parent f3715c7900
commit c7c9b5ee47
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 43 additions and 17 deletions

View File

@ -1,6 +1,9 @@
{ {
"home": { "home": {
"welcome": "Hi {username}", "welcomeNight": "Good Night {username}",
"welcomeMorning": "Good Morning {username}",
"welcomeDay": "Hi {username}",
"welcomeEvening": "Good Evening {username}",
"list": { "list": {
"newText": "You can create a new list for your new tasks:", "newText": "You can create a new list for your new tasks:",
"new": "Create a new list", "new": "Create a new list",

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="content has-text-centered"> <div class="content has-text-centered">
<h2> <h2>
{{ $t('home.welcome', {username: userInfo.name !== '' ? userInfo.name : userInfo.username}) }}! {{ $t(`home.welcome${welcome}`, {username: userInfo.name !== '' ? userInfo.name : userInfo.username}) }}!
</h2> </h2>
<template v-if="!hasTasks"> <template v-if="!hasTasks">
<p>{{ $t('home.list.newText') }}</p> <p>{{ $t('home.list.newText') }}</p>
@ -43,25 +43,48 @@ export default {
tasks: [], tasks: [],
} }
}, },
computed: mapState({ computed: {
migratorsEnabled: state => state.config.availableMigrators !== null && state.config.availableMigrators.length > 0, welcome() {
authenticated: state => state.auth.authenticated, const now = new Date()
userInfo: state => state.auth.info,
hasTasks: state => state.hasTasks, if (now.getHours() < 5) {
defaultNamespaceId: state => { return 'Night'
if (state.namespaces.namespaces.length === 0) {
return 0
} }
return state.namespaces.namespaces[0].id if(now.getHours() < 11) {
}, return 'Morning'
hasLists: state => {
if (state.namespaces.namespaces.length === 0) {
return false
} }
return state.namespaces.namespaces[0].lists.length > 0 if(now.getHours() < 18) {
return 'Day'
}
if(now.getHours() < 23) {
return 'Evening'
}
return 'Night'
}, },
}), ...mapState({
migratorsEnabled: state => state.config.availableMigrators !== null && state.config.availableMigrators.length > 0,
authenticated: state => state.auth.authenticated,
userInfo: state => state.auth.info,
hasTasks: state => state.hasTasks,
defaultNamespaceId: state => {
if (state.namespaces.namespaces.length === 0) {
return 0
}
return state.namespaces.namespaces[0].id
},
hasLists: state => {
if (state.namespaces.namespaces.length === 0) {
return false
}
return state.namespaces.namespaces[0].lists.length > 0
},
}),
}
} }
</script> </script>