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 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template lang="pug">
  2. w-app
  3. TopNav(@on-open='openDrawer = !openDrawer')
  4. w-drawer(v-model='openDrawer')
  5. SideBar(:pid='profile.id.value' @updatePid='setPid')
  6. RouterView(@updatePid='setPid')
  7. </template>
  8. <script>
  9. import 'wave-ui/dist/wave-ui.css'
  10. import SideBar from './components/SideBar.vue'
  11. import TopNav from './components/TopNav.vue'
  12. import { currentProfile } from './services'
  13. import { surveyFactory } from './utils'
  14. const DEV_MODE = import.meta.env.VITE_DEV == 'true'
  15. const DEV_PID = 46
  16. export default {
  17. components: { TopNav, SideBar },
  18. data: () => ({
  19. sliderVal: 1,
  20. openDrawer: false,
  21. }),
  22. computed: {
  23. profile: () => {
  24. return currentProfile
  25. },
  26. },
  27. async created() {
  28. /** Get questions so we can compare against profile responses */
  29. await surveyFactory.getQuestions()
  30. /**
  31. * Development mode turns router guards off so
  32. * we hard set the profile id instead of
  33. * using the login form
  34. */
  35. if (DEV_MODE) {
  36. console.info('===============================================')
  37. console.info('- SIIMEE -')
  38. console.info('-----------------------------------------------')
  39. console.info('[Siimee App]: You are in development mode:', DEV_MODE)
  40. console.info('[Siimee App]: Starting application...')
  41. console.info('-----------------------------------------------')
  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. @import '../assets/sass/main'
  67. #app > .w-app > main
  68. position: relative
  69. top: 50px
  70. max-width: 960px
  71. width:100%
  72. margin: 0 auto
  73. </style>