ffplayout/pages/index.vue

210 lines
5.7 KiB
Vue
Raw Normal View History

2020-01-29 17:40:15 +01:00
<template>
<div>
<div v-if="!$store.state.auth.isLogin">
<div class="logout-div" />
<b-container class="login-container">
<div>
<div class="header">
<h1>ffplayout</h1>
</div>
2020-04-07 17:56:33 +02:00
<b-form class="login-form" @submit.prevent="login">
<b-form-group id="input-group-1" label="User:" label-for="input-user">
<b-form-input id="input-user" v-model="formUsername" type="text" required placeholder="Username" />
</b-form-group>
<b-form-group id="input-group-1" label="Password:" label-for="input-pass">
<b-form-input id="input-pass" v-model="formPassword" type="password" required placeholder="Password" />
</b-form-group>
2020-05-12 18:07:53 +02:00
<b-row>
<b-col cols="3">
<b-button type="submit" variant="primary">
Login
</b-button>
</b-col>
<b-col cols="9">
<b-alert variant="danger" :show="showError" dismissible @dismissed="showError=false">
{{ formError }}
</b-alert>
</b-col>
</b-row>
</b-form>
</div>
</b-container>
</div>
<div v-else>
<b-container class="login-container">
<div>
2022-06-30 18:39:01 +02:00
<div class="logo-div">
<b-img-lazy
src="/images/ffplayout.png"
alt="Logo"
fluid
/>
</div>
<div class="actions">
<b-button-group class="actions-grp">
2020-04-30 10:53:13 +02:00
<b-button to="/player" variant="primary">
Player
2020-04-07 17:56:33 +02:00
</b-button>
2020-04-15 18:11:04 +02:00
<b-button to="/media" variant="primary">
2020-01-31 13:45:56 +01:00
Media
</b-button>
2020-04-22 17:19:14 +02:00
<b-button to="/message" variant="primary">
Message
</b-button>
2020-04-15 18:11:04 +02:00
<b-button to="logging" variant="primary">
Logging
</b-button>
<b-button to="/configure" variant="primary">
2020-04-09 18:30:28 +02:00
Configure
</b-button>
2020-04-15 18:11:04 +02:00
<b-button variant="primary" @click="logout()">
Logout
</b-button>
</b-button-group>
</div>
</div>
</b-container>
2020-01-29 17:40:15 +01:00
</div>
</div>
2020-01-29 17:40:15 +01:00
</template>
<script>
export default {
components: {},
data () {
return {
2020-05-12 18:07:53 +02:00
showError: false,
2020-01-29 17:40:15 +01:00
formError: null,
formUsername: '',
formPassword: '',
interval: null,
stat: {}
2020-01-29 17:40:15 +01:00
}
},
created () {
this.init()
},
beforeDestroy () {
clearInterval(this.interval)
},
2020-01-29 17:40:15 +01:00
methods: {
async init () {
await this.$store.dispatch('auth/inspectToken')
},
async login () {
try {
2020-05-12 18:07:53 +02:00
const status = await this.$store.dispatch('auth/obtainToken', {
2020-01-29 17:40:15 +01:00
username: this.formUsername,
password: this.formPassword
})
this.formUsername = ''
this.formPassword = ''
this.formError = null
2022-06-30 18:39:01 +02:00
if (status === 401 || status === 400) {
2020-05-12 18:07:53 +02:00
this.formError = 'Wrong user or password!'
this.showError = true
}
2021-04-08 10:35:31 +02:00
await this.$store.dispatch('config/nuxtClientInit')
2020-01-29 17:40:15 +01:00
} catch (e) {
this.formError = e.message
}
},
2021-03-22 16:44:26 +01:00
logout () {
clearInterval(this.interval)
2020-01-29 17:40:15 +01:00
try {
2021-03-22 16:44:26 +01:00
this.$store.commit('auth/REMOVE_TOKEN')
this.$store.commit('auth/UPDATE_IS_LOGIN', false)
2020-01-29 17:40:15 +01:00
} catch (e) {
this.formError = e.message
}
}
}
}
</script>
<style>
.login-container {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
.header {
text-align: center;
margin-bottom: 3em;
}
2022-06-30 18:39:01 +02:00
.logo-div {
width: 100%;
text-align: center;
margin-bottom: 5em;
}
2020-01-29 17:40:15 +01:00
.login-form {
min-width: 300px;
}
.manage-btn {
margin: 0 auto 0 auto;
}
.chart-col {
text-align: center;
min-width: 10em;
min-height: 15em;
border: solid #c3c3c3;
}
.stat-div {
padding-top: .5em;
position: relative;
height: 12em;
}
.stat-center {
margin: 0;
position: absolute;
width: 100%;
top: 50%;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.chart1 {
background: rgba(210, 85, 23, 0.1);
}
.chart2 {
background: rgba(122, 210, 23, 0.1);
}
.chart3 {
background: rgba(23, 210, 149, 0.1);
}
.chart4 {
background: rgba(23, 160, 210, 0.1);
}
.chart5 {
background: rgba(122, 23, 210, 0.1);
}
.chart6 {
background: rgba(210, 23, 74, 0.1);
}
.actions {
text-align: center;
margin-top: 1em;
}
@media (max-width: 380px) {
.actions-grp {
display: flex;
flex-direction: column;
margin: 0 2em 0 2em;
}
}
2020-01-29 17:40:15 +01:00
</style>