fixes #18: introduce motd

This commit is contained in:
Davide Alberani 2017-03-04 20:34:02 +01:00
parent 4cbb8dca8a
commit b92b0799ac
2 changed files with 80 additions and 51 deletions

View file

@ -21,6 +21,18 @@
<md-switch v-model="shownSettings.protectDayNotes" class="md-warn">day notes</md-switch> <md-switch v-model="shownSettings.protectDayNotes" class="md-warn">day notes</md-switch>
</div> </div>
<br />
<div class="md-headline">
Message of the day
</div>
<md-switch v-model="shownSettings.showMotd" class="md-warn">show motd</md-switch>
<md-input-container>
<label>message</label>
<md-textarea v-model="shownSettings.motd"></md-textarea>
</md-input-container>
<br /> <br />
<md-button id="save-button" class="md-raised md-primary" @click="save()">Save</md-button> <md-button id="save-button" class="md-raised md-primary" @click="save()">Save</md-button>
</md-card-content> </md-card-content>

View file

@ -1,60 +1,64 @@
<template> <template>
<md-toolbar id="toolbar" class="md-dense"> <div>
<span v-if="currentPath != 'home' && currentPath != 'day' && currentPath != 'days'"> <md-toolbar id="toolbar" class="md-dense">
<md-button class="md-icon-button" @click="goBack()"> <span v-if="currentPath != 'home' && currentPath != 'day' && currentPath != 'days'">
<md-tooltip md-direction="right">back</md-tooltip> <md-button class="md-icon-button" @click="goBack()">
<md-icon>backspace</md-icon>&nbsp; <md-tooltip md-direction="right">back</md-tooltip>
</md-button> <md-icon>backspace</md-icon>&nbsp;
</span> </md-button>
<span v-else class="button-spacer">&nbsp;</span>
<h2 id="toolbar-title" class="md-title">
<router-link :to="{name: 'home'}" class="home-link">ibt2</router-link>
</h2>
<span v-if="loggedInUser.username">
<md-button v-if="loggedInUser.isAdmin" id="users-icon" class="md-icon-button" @click="toSettingsPage()">
<md-tooltip md-direction="left">global settings</md-tooltip>
<md-icon>settings</md-icon>
</md-button>
<md-button v-if="loggedInUser.isAdmin" id="users-icon" class="md-icon-button" @click="toUsersPage()">
<md-tooltip md-direction="left">list of users</md-tooltip>
<md-icon>people_outline</md-icon>
</md-button>
<md-button id="logged-in-icon" class="md-icon-button" @click="toUserPage()">
<md-tooltip md-direction="left">personal page</md-tooltip>
<md-icon>person_pin</md-icon>
</md-button>
<span id="logged-in" class="md-subheading">
<router-link :to="userUrl" class="username-link">{{ loggedInUser.username }}</router-link>
</span> </span>
<md-button id="logout-icon" class="md-icon-button" @click="logout()"> <span v-else class="button-spacer">&nbsp;</span>
<md-tooltip md-direction="left">logout</md-tooltip> <h2 id="toolbar-title" class="md-title">
<md-icon>exit_to_app</md-icon> <router-link :to="{name: 'home'}" class="home-link">ibt2</router-link>
</md-button> </h2>
</span> <span v-if="loggedInUser.username">
<span v-else> <md-button v-if="loggedInUser.isAdmin" id="users-icon" class="md-icon-button" @click="toSettingsPage()">
<span id="login-form"> <md-tooltip md-direction="left">global settings</md-tooltip>
<md-input-container id="username-input" class="login-input" md-inline> <md-icon>settings</md-icon>
<md-tooltip md-direction="bottom">login name or create a new user if it doesn't exist</md-tooltip> </md-button>
<md-input ref="usernameInput" @keyup.enter.native="focusToPassword()" v-model="username" placeholder="username" md-inline /> <md-button v-if="loggedInUser.isAdmin" id="users-icon" class="md-icon-button" @click="toUsersPage()">
</md-input-container>&nbsp; <md-tooltip md-direction="left">list of users</md-tooltip>
<span id="password-block"> <md-icon>people_outline</md-icon>
<md-input-container id="password-input" class="login-input" md-has-password md-inline> </md-button>
<md-tooltip md-direction="bottom">login password or create a new user if it doesn't exist</md-tooltip> <md-button id="logged-in-icon" class="md-icon-button" @click="toUserPage()">
<md-input ref="passwordInput" @keyup.enter.native="login()" v-model="password" placeholder="password" type="password" md-line /> <md-tooltip md-direction="left">personal page</md-tooltip>
</md-input-container> <md-icon>person_pin</md-icon>
<md-button id="login-button" class="md-icon-button" @click="login()"> </md-button>
<md-tooltip md-direction="left">login or create a new user if it doesn't exist</md-tooltip> <span id="logged-in" class="md-subheading">
<md-icon>play_circle_outline</md-icon> <router-link :to="userUrl" class="username-link">{{ loggedInUser.username }}</router-link>
</md-button> </span>
<md-button id="logout-icon" class="md-icon-button" @click="logout()">
<md-tooltip md-direction="left">logout</md-tooltip>
<md-icon>exit_to_app</md-icon>
</md-button>
</span>
<span v-else>
<span id="login-form">
<md-input-container id="username-input" class="login-input" md-inline>
<md-tooltip md-direction="bottom">login name or create a new user if it doesn't exist</md-tooltip>
<md-input ref="usernameInput" @keyup.enter.native="focusToPassword()" v-model="username" placeholder="username" md-inline />
</md-input-container>&nbsp;
<span id="password-block">
<md-input-container id="password-input" class="login-input" md-has-password md-inline>
<md-tooltip md-direction="bottom">login password or create a new user if it doesn't exist</md-tooltip>
<md-input ref="passwordInput" @keyup.enter.native="login()" v-model="password" placeholder="password" type="password" md-line />
</md-input-container>
<md-button id="login-button" class="md-icon-button" @click="login()">
<md-tooltip md-direction="left">login or create a new user if it doesn't exist</md-tooltip>
<md-icon>play_circle_outline</md-icon>
</md-button>
</span>
</span> </span>
</span> </span>
</span> <ibt-snackbar ref="snackbarObj" />
<ibt-snackbar ref="snackbarObj" /> <ibt-dialog ref="dialogObj" />
<ibt-dialog ref="dialogObj" /> </md-toolbar>
</md-toolbar> <vue-markdown v-if="settings.showMotd && settings.motd" class="motd" :source="settings.motd"></vue-markdown>
</div>
</template> </template>
<script> <script>
import VueMarkdown from 'vue-markdown';
import IbtDialog from './IbtDialog.vue'; import IbtDialog from './IbtDialog.vue';
import IbtSnackbar from './IbtSnackbar.vue'; import IbtSnackbar from './IbtSnackbar.vue';
@ -79,6 +83,10 @@ export default {
return '/user/' + this.loggedInUser._id; return '/user/' + this.loggedInUser._id;
}, },
settings() {
return this.$store.state.settings || {};
},
loggedInUser() { loggedInUser() {
return this.$store.state.loggedInUser; return this.$store.state.loggedInUser;
}, },
@ -183,7 +191,7 @@ export default {
} }
}, },
components: { IbtDialog, IbtSnackbar } components: { IbtDialog, IbtSnackbar, VueMarkdown }
} }
</script> </script>
@ -254,4 +262,13 @@ export default {
color: white !important; color: white !important;
} }
.motd p {
margin-top: 0px;
margin-bottom: 0px;
padding-top: 4px;
padding-bottom: 4px;
text-align: center;
background-color: #ffcdd2;
}
</style> </style>