You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

App.vue 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template lang="pug">
  2. w-app
  3. TopNav(@on-open="openDrawer = !openDrawer")
  4. w-drawer(v-model="openDrawer")
  5. SideBar(@updatePid="setPid" :pid="profile.id.value")
  6. RouterView(
  7. v-if="profile.isLoggedIn"
  8. :pid="profile.id.value"
  9. @updatePid="setPid"
  10. @show-sidebar="showSidebar = !showSidebar"
  11. )
  12. </template>
  13. <script>
  14. import 'wave-ui/dist/wave-ui.css'
  15. import SideBar from './components/SideBar.vue'
  16. import TopNav from './components/TopNav.vue'
  17. import { currentProfile } from './services'
  18. import { surveyFactory } from './utils'
  19. const DEV_MODE = import.meta.env.VITE_DEV == 'true'
  20. // const DEV_MODE = false
  21. const DEV_PID = 45
  22. export default {
  23. components: { TopNav, SideBar },
  24. data: () => ({
  25. sliderVal: 1,
  26. openDrawer: false,
  27. }),
  28. computed: {
  29. profile: () => {
  30. return currentProfile
  31. },
  32. },
  33. async created() {
  34. /** Get questions so we can compare against profile responses */
  35. await surveyFactory.getQuestions()
  36. /**
  37. * Development mode turns router guards off so
  38. * we hard set the profile id instead of
  39. * using the login form
  40. */
  41. if (DEV_MODE) {
  42. await this.setPid(DEV_PID)
  43. }
  44. },
  45. methods: {
  46. /**
  47. * Sync up this components state with
  48. * the currentProfile handler
  49. */
  50. async setPid(profileId) {
  51. if (currentProfile.isLoggedIn) {
  52. currentProfile.logout()
  53. }
  54. await currentProfile.login(profileId, this.$waveui.notify)
  55. console.log('---')
  56. /**
  57. * Default to the HomeView and alter as needed (side-effects!)
  58. */
  59. const toRoute = { name: 'HomeView' }
  60. this.$router.push(toRoute)
  61. },
  62. },
  63. }
  64. </script>
  65. <style lang="sass">
  66. #app > .w-app > main
  67. position: relative
  68. top: 50px
  69. </style>