<template>
    <div>
        <dialog-odhlasenie-component :show="zobrazitDialogOdhlasenia" @zrusitOdhlasenie="zobrazitDialogOdhlasenia = false" @odhlasenie="odhlaseniePouzivatela()"></dialog-odhlasenie-component>
        <toolbar-component :avatar="avatar" @vyzadovaneOdhlasenie="zobrazitDialogOdhlasenia = true"></toolbar-component>
        <navigation-component :items="polozkyNavigacnehoMenu" :pouzivatel="pouzivatel"></navigation-component>
        <v-content>
            <v-container fluid fill-height>
                <router-view></router-view>
            </v-container>
        </v-content>
    </div>
</template>

<script>
  import LocalAuth from '../localAuth'
  import ToolbarComponent from '../components/ToolbarComponent.vue'
  import NavigationComponent from '../components/NavigationComponent.vue'
  import DialogOdhlasenieComponent from '../components/DialogOdhlasenieComponent.vue'
  import Pouzivatel from '../store/models/Pouzivatel'

  export default {
    name: 'VzdelavanieIndexView',
    components: {
      ToolbarComponent,
      NavigationComponent,
      DialogOdhlasenieComponent
    },
    props: {},
    data() {
      return {
        zobrazitDialogOdhlasenia: false,
        zoznamPoloziekNavigacnehoMenu: [
          {
            text: 'Plocha',
            icon: 'mdi-view-dashboard',
            to: 'Plocha'
          },
          {
            text: 'Knižnica',
            icon: 'mdi-library',
            to: 'Knižnica'
          }
        ]
      }
    },
    methods: {
      spracujPolozkuMenu (polozka, role) {
        if (polozka.hasOwnProperty('role')) {
          return Acl.evaluate(polozka.role, role)
        } else {
          return polozka
        }
      },
      odhlaseniePouzivatela () {
        this.zobrazitDialogOdhlasenia = false
        LocalAuth.odstranitUdajePouzivatela()
        this.$router.push({name: 'Prihlásenie'})
      },
      zmenaDrawera (stav) {
        this.drawer = stav
      }
    },
    computed: {
      polozkyNavigacnehoMenu () {
        return this.zoznamPoloziekNavigacnehoMenu
      },
      avatar () {
        return this.pouzivatel.avatar
      },
      pouzivatel () {
        return new Pouzivatel(LocalAuth.udajePouzivatela());
      }
    }
  }
</script>

<style scoped></style>
