parsley/app/javascript/components/App.vue

77 lines
1.9 KiB
Vue
Raw Normal View History

2018-03-29 01:57:00 -05:00
<template>
2018-03-30 14:31:09 -05:00
<div>
2018-04-01 21:43:23 -05:00
<vue-progress-bar></vue-progress-bar>
2018-03-30 14:31:09 -05:00
<app-navbar></app-navbar>
2018-04-01 21:43:23 -05:00
<section id="app" class="">
2018-03-30 14:31:09 -05:00
<div class="container">
<router-view v-if="!hasError"></router-view>
<div v-else>
<h1>Error!</h1>
<p>{{error}}</p>
</div>
</div>
</section>
2018-03-29 01:57:00 -05:00
</div>
</template>
<script>
2018-03-30 17:08:09 -05:00
import { mapMutations, mapState } from "vuex";
import api from "../lib/Api";
2018-03-30 14:31:09 -05:00
2018-03-29 01:57:00 -05:00
export default {
2018-04-01 21:43:23 -05:00
data() {
return {
api: api
};
},
2018-03-30 14:31:09 -05:00
computed: {
...mapState({
hasError: state => state.error !== null,
2018-03-30 17:08:09 -05:00
error: state => state.error,
authChecked: state => state.authChecked
2018-03-30 14:31:09 -05:00
})
},
2018-03-29 01:57:00 -05:00
2018-04-01 21:43:23 -05:00
watch: {
isLoading(val) {
if (val) {
this.$Progress.start();
} else {
this.$Progress.finish();
}
}
},
created() {
2018-03-30 17:08:09 -05:00
if (this.user === null && this.authChecked === false) {
2018-06-09 12:36:46 -05:00
this.checkAuthentication();
2018-04-01 21:43:23 -05:00
}
// Hard coded values taken directly from Bulma css
const mediaQueries = {
mobile: "screen and (max-width: 768px)",
tablet: "screen and (min-width: 769px)",
tabletOnly: "screen and (min-width: 769px) and (max-width: 1023px)",
touch: "screen and (max-width: 1023px)",
desktop: "screen and (min-width: 1024px)",
desktopOnly: "screen and (min-width: 1024px) and (max-width: 1215px)",
widescreen: "screen and (min-width: 1216px)",
widescreenOnly: "screen and (min-width: 1216px) and (max-width: 1407px)",
fullhd: "screen and (min-width: 1408px)"
};
for (let device in mediaQueries) {
const query = window.matchMedia(mediaQueries[device]);
query.onchange = (q) => {
this.$store.commit("setMediaQuery", {mediaName: device, value: q.matches});
};
query.onchange(query);
2018-03-30 17:08:09 -05:00
}
},
2018-03-30 14:31:09 -05:00
components: {
}
2018-03-29 01:57:00 -05:00
}
</script>