MainLayout.vue 7.28 KB
Newer Older
Azrul Amir's avatar
Azrul Amir committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
<template>
  <q-layout view="hHh lpR fFf" class="bg-grey-1">
    <q-header elevated class="bg-white text-grey-8 q-py-xs" height-hint="58">
      <q-toolbar>
        <q-btn
          flat
          dense
          round
          @click="leftDrawerOpen = !leftDrawerOpen"
          aria-label="Menu"
          icon="menu"
        />

        <q-btn flat no-caps no-wrap class="q-ml-xs" v-if="$q.screen.gt.xs">
          <q-icon :name="fabYoutube" color="red" size="28px" />
          <q-toolbar-title shrink class="text-weight-bold">
            YouTube
          </q-toolbar-title>
        </q-btn>



        <q-space />

        <div class="q-gutter-sm row items-center no-wrap">
          <q-btn round dense flat color="grey-8" icon="video_call" v-if="$q.screen.gt.sm">
            <q-tooltip>Create a video or post</q-tooltip>
          </q-btn>
          <q-btn round dense flat color="grey-8" icon="apps" v-if="$q.screen.gt.sm">
            <q-tooltip>Apps</q-tooltip>
          </q-btn>
          <q-btn round dense flat color="grey-8" icon="message" v-if="$q.screen.gt.sm">
            <q-tooltip>Messages</q-tooltip>
          </q-btn>
          <q-btn round dense flat color="grey-8" icon="notifications">
            <q-badge color="red" text-color="white" floating>
              2
            </q-badge>
            <q-tooltip>Notifications</q-tooltip>
          </q-btn>
          <q-btn round flat>
adamrusly's avatar
adamrusly committed
42 43
            <q-avatar size="26px" @click="loginGoogle">
              <img :src="defaultAvatar">
Azrul Amir's avatar
Azrul Amir committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
            </q-avatar>
            <q-tooltip>Account</q-tooltip>
          </q-btn>
        </div>
      </q-toolbar>
    </q-header>

    <q-drawer
      v-model="leftDrawerOpen"
      show-if-above
      bordered
      content-class="bg-grey-2"
      :width="240"
    >
      <q-scroll-area class="fit">
        <q-list padding>
Azrul Amir's avatar
Azrul Amir committed
60
          <q-item exact v-for="link in links1" :key="link.text" v-ripple clickable :to="link.url">
Azrul Amir's avatar
Azrul Amir committed
61 62 63 64 65 66 67 68 69 70 71 72
            <q-item-section avatar>
              <q-icon color="grey" :name="link.icon" />
            </q-item-section>
            <q-item-section>
              <q-item-label>{{ link.text }}</q-item-label>
            </q-item-section>
          </q-item>

          <q-separator class="q-my-md" />
          <q-item-label header class="text-weight-bold text-uppercase">
            MORE ABOUT US
          </q-item-label>
Azrul Amir's avatar
Azrul Amir committed
73
          <q-item exact v-for="link in links2" :key="link.text" v-ripple clickable :to="link.url">
Azrul Amir's avatar
Azrul Amir committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
            <q-item-section avatar>
              <q-icon color="grey" :name="link.icon" />
            </q-item-section>
            <q-item-section>
              <q-item-label>{{ link.text }}</q-item-label>
            </q-item-section>
          </q-item>
         

          <q-item v-for="link in links3" :key="link.text" v-ripple clickable>
            <q-item-section avatar>
              <q-icon color="grey" :name="link.icon" />
            </q-item-section>
            <q-item-section>
              <q-item-label>{{ link.text }}</q-item-label>
            </q-item-section>
          </q-item>

          <q-separator class="q-my-md" />

          <q-item v-for="link in links4" :key="link.text" v-ripple clickable>
            <q-item-section avatar>
              <q-icon color="grey" :name="link.icon" />
            </q-item-section>
            <q-item-section>
              <q-item-label>{{ link.text }}</q-item-label>
            </q-item-section>
          </q-item>

          <q-separator class="q-mt-md q-mb-lg" />

          <div class="q-px-md text-grey-9">
            <div class="row items-center q-gutter-x-sm q-gutter-y-xs">
              <a
                v-for="button in buttons1"
                :key="button.text"
                class="YL__drawer-footer-link"
                href="javascript:void(0)"
              >
                {{ button.text }}
              </a>
            </div>
          </div>
          <div class="q-py-md q-px-md text-grey-9">
            <div class="row items-center q-gutter-x-sm q-gutter-y-xs">
              <a
                v-for="button in buttons2"
                :key="button.text"
                class="YL__drawer-footer-link"
                href="javascript:void(0)"
              >
                {{ button.text }}
              </a>
            </div>
          </div>
        </q-list>
      </q-scroll-area>
    </q-drawer>

    <q-page-container>
      <router-view />
    </q-page-container>
  </q-layout>
</template>

<script>
import { fabYoutube } from '@quasar/extras/fontawesome-v5'
export default {
  name: 'MyLayout',
  data () {
    return {
adamrusly's avatar
adamrusly committed
145 146 147 148 149 150 151 152 153 154 155 156
      defaultAvatar: 'https://cdn.quasar.dev/img/boy-avatar.png',
      userUpdate: {
        token: '',
        firstName: '',
        lastName: '',
        email: '',
        avatar: '',
        fullname: '',
        id: '',
        isAdmin: false,
        isAuth: false
      },
Azrul Amir's avatar
Azrul Amir committed
157 158 159
      leftDrawerOpen: false,
      search: '',
      links1: [
Azrul Amir's avatar
Azrul Amir committed
160 161
        { icon: 'home', text: 'Home', url: '/' },
        { icon: 'subscriptions', text: 'My Account', url: 'my-account' },
Azrul Amir's avatar
Azrul Amir committed
162 163
      ],
      links2: [
Azrul Amir's avatar
Azrul Amir committed
164
        { icon: 'phone', text: 'Contact Us', url: 'contact-us' },
Azrul Amir's avatar
Azrul Amir committed
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
      ],
      links3: [

      ],
      links4: [
        { icon: 'settings', text: 'Settings' },
        { icon: 'help', text: 'Help' },
        { icon: 'feedback', text: 'Send feedback' }
      ],
      buttons1: [
        { text: 'About' },
        { text: 'Press' },
        { text: 'Copyright' },
        { text: 'Contact us' },
        { text: 'Creators' },
        { text: 'Advertise' },
        { text: 'Developers' }
      ],
      buttons2: [
        { text: 'Terms' },
        { text: 'Privacy' },
        { text: 'Policy & Safety' },
        { text: 'Test new features' }
      ]
    }
  },
  created () {
    this.fabYoutube = fabYoutube
adamrusly's avatar
adamrusly committed
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
  },
  methods: {
    async loginGoogle() {
      try {
        const googleUser = await this.$gAuth.signIn()
        // const authCode = await this.$gAuth.getAuthCode()
        // console.log('getAuthCode()',authCode)
        if (!googleUser) {
          return null
        }
        else{
          const bio = googleUser.getBasicProfile()
          this.userUpdate.token = ''
          this.userUpdate.firstName = bio.getGivenName()
          this.userUpdate.lastName = bio.getFamilyName()
          this.userUpdate.email = bio.getEmail()
          this.userUpdate.avatar = bio.getImageUrl()
          this.userUpdate.fullname = bio.getName()
          this.userUpdate.id = bio.getId()
          this.userUpdate.isAdmin = false
          this.userUpdate.isAuth = true
          this.defaultAvatar = this.userUpdate.avatar
          console.log(bio)
          
          // this.upsertUser()
          if (this.$route.query.redirect){
            this.$router.push(this.$route.query.redirect)
          }
          else{
            // this.$router.push('/')

          }
        }
      } catch (error) {
        //on fail do something
        console.error(error)
        return null
      }
    }
Azrul Amir's avatar
Azrul Amir committed
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
  }
}
</script>

<style lang="sass">
.YL
  &__toolbar-input-container
    min-width: 100px
    width: 55%
  &__toolbar-input-btn
    border-radius: 0
    border-style: solid
    border-width: 1px 1px 1px 0
    border-color: rgba(0,0,0,.24)
    max-width: 60px
    width: 100%
  &__drawer-footer-link
    color: inherit
    text-decoration: none
    font-weight: 500
    font-size: .75rem
    &:hover
      color: #000
</style>