95 lines
3.3 KiB
Vue
95 lines
3.3 KiB
Vue
<template>
|
|
<!-- note, we do not show anything at all until we have user info -->
|
|
<div class="main-container" v-show="$store.state.session_established">
|
|
<slot>
|
|
<p>TODO: put your nav in the default slot!</p>
|
|
</slot>
|
|
<div class="page-content-wrapper">
|
|
<div class="page-content">
|
|
<router-view />
|
|
</div>
|
|
</div>
|
|
<footer v-if="includeFooter"
|
|
class="footer">
|
|
<slot name="footer">
|
|
<router-link to="/about">{{ appsettings.appTitle }} {{ appsettings.version }}</router-link>
|
|
</slot>
|
|
</footer>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'ByjoveApp',
|
|
props: {
|
|
appsettings: Object,
|
|
includeFooter: {
|
|
type: Boolean,
|
|
default: true,
|
|
},
|
|
},
|
|
beforeCreate: function() {
|
|
|
|
// TODO: even with beforeCreate() this logic is still happening "too
|
|
// slowly" for us to reliably check perms on first page load,
|
|
// i.e. after browser refresh. maybe can avoid async for the GET?
|
|
|
|
// when main app is first created, fetch user session data from
|
|
// backend; this will tell us who the user is (or if they're not yet
|
|
// logged in) which in turn is used to control which features are
|
|
// exposed. also this gives us the XSRF token cookie from the server.
|
|
// TODO: make this API URL configurable, somehow..?
|
|
this.$http.get('/api/session').then(response => {
|
|
|
|
// let all of app know who the user is(n't)
|
|
this.$store.commit('SET_USER', response.data.user)
|
|
this.$store.commit('SET_USER_IS_ADMIN', response.data.user ? response.data.user.is_admin : false)
|
|
this.$store.commit('SET_USER_IS_ROOT', response.data.user ? response.data.user.is_root : false)
|
|
|
|
// also keep track of user's permissions
|
|
this.$store.commit('SET_PERMISSIONS', response.data.permissions)
|
|
|
|
// declare the session established
|
|
this.$store.commit('SET_SESSION_ESTABLISHED', true)
|
|
|
|
// set background color, to whatever api said
|
|
// TODO: should this be the custom app's responsibility?
|
|
if (response.data.background_color) {
|
|
document.body.style.backgroundColor = response.data.background_color
|
|
}
|
|
})
|
|
},
|
|
mounted: function () {
|
|
|
|
// add "testing" watermark unless running in production mode
|
|
// if (!appsettings.production) {
|
|
if (!this.appsettings.production) {
|
|
// document.body.style.backgroundImage = appsettings.watermark;
|
|
document.body.style.backgroundImage = this.appsettings.watermark;
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<!-- TODO: grr, why does this not work?! -->
|
|
<!-- <style scoped> -->
|
|
<!-- /* #app { */ -->
|
|
<!-- /* font-family: 'Avenir', Helvetica, Arial, sans-serif; */ -->
|
|
<!-- /* -webkit-font-smoothing: antialiased; */ -->
|
|
<!-- /* -moz-osx-font-smoothing: grayscale; */ -->
|
|
<!-- /* color: #2c3e50; */ -->
|
|
<!-- /* } */ -->
|
|
<!-- .main-container { -->
|
|
<!-- display: flex; -->
|
|
<!-- min-height: 100vh; -->
|
|
<!-- flex-direction: column; -->
|
|
<!-- } -->
|
|
<!-- .page-content { -->
|
|
<!-- flex: 1; -->
|
|
<!-- padding: 0.5rem 1rem 0.5rem 0.5rem; -->
|
|
<!-- } -->
|
|
<!-- .footer { -->
|
|
<!-- text-align: center; -->
|
|
<!-- } -->
|
|
<!-- </style> -->
|