App.vue 2.87 KB
Newer Older
1
2
<template>
  <div id="app">
3
    <app-header v-bind:modules="modules" v-bind:user="user"></app-header>
4
    <router-view/>
5
6
7
8
9
    <app-footer></app-footer>
  </div>
</template>

<script>
10
11
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
12
import oidc from 'oidc-client'
13
14
15
16
17
18
19
20
21
22
23
import header from './components/Header.vue'
import footer from './components/Footer.vue'

export default {
  name: 'app',
  components: {
    'app-header': header,
    'app-footer': footer
  },
  data () {
    return {
24
25
26
27
28
29
      modules_logged_out: [
        { slug: 'home', title: 'Home' },
        { slug: 'credits', title: 'Credits' },
        { slug: 'debug', title: 'Debug' }
      ],
      modules_logged_in: [
30
        { slug: 'home', title: 'Home' },
31
        { slug: 'shows', title: 'Sendungen verwalten' },
32
33
        { slug: 'files', title: 'Dateien und Playlists' },
        { slug: 'settings', title: 'Settings' },
34
35
        { slug: 'credits', title: 'Credits' },
        { slug: 'debug', title: 'Debug' }
36
      ],
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
      user: {
        name: '',
        email: '',
        access_token: '',
        logged_in: false
      },
      userOIDC: null,
      mgr: new oidc.UserManager({
        userStore: new oidc.WebStorageStateStore(),
        authority: process.env.API_STEERING_OIDC_URI,
        client_id: '174626',
        redirect_uri: process.env.API_STEERING_OIDC_REDIRECT_URI,
        // redirect_uri: process.env.API_STEERING_OIDC_REDIRECT_URI,
        response_type: 'id_token token',
        scope: 'openid profile email',
        post_logout_redirect_uri: process.env.API_STEERING_OIDC_REDIRECT_URI_POSTLOGOUT,
        loadUserInfo: true
      })
55
    }
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
  },
  computed: {
    modules: function () {
      if (this.user.logged_in === true) return this.modules_logged_in
      else return this.modules_logged_out
    }
  },
  methods: {
    signIn () {
      this.mgr.signinRedirect().catch(function (err) {
        console.log(err)
      })
    },
    signOut () {
      let self = this
      this.mgr.signoutRedirect().then(function (resp) {
        self.user.logged_in = false
        console.log('signed out', resp)
      }).catch(function (err) {
        console.log(err)
      })
    },
    getUser () {
      let self = this
      this.mgr.getUser().then(function (u) {
        if (u == null) {
          self.user.logged_in = false
          self.user.name = ''
          self.user.email = ''
          self.user.access_token = ''
        } else {
          self.userOIDC = u
          self.user.logged_in = true
          self.user.name = u.profile.nickname
          self.user.email = u.profile.email
          self.user.access_token = u.access_token
        }
      }).catch(function (err) {
        console.log(err)
      })
    }
  },
  mounted () {
    this.getUser()
100
101
102
103
104
105
  }
}
</script>

<style>
#app {
106
  color: #2e3436;
107
}
108
/*
109
110
111
112
113
#app .content-width {
  margin: auto;
  width: 920px;
  max-width: 920px;
}
114
*/
115
</style>