2020-01-29 11:40:15 -05:00
|
|
|
<template>
|
2020-01-30 11:17:26 -05:00
|
|
|
<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 11:56:33 -04:00
|
|
|
<b-form class="login-form" @submit.prevent="login">
|
2020-01-30 11:17:26 -05:00
|
|
|
<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 12:07:53 -04: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>
|
2020-01-30 11:17:26 -05:00
|
|
|
</b-form>
|
|
|
|
</div>
|
|
|
|
</b-container>
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
|
|
|
<b-container class="login-container">
|
|
|
|
<div>
|
|
|
|
<b-row cols="3">
|
|
|
|
<b-col cols="4" class="chart-col chart1">
|
|
|
|
<br>
|
|
|
|
<div class="stat-div">
|
|
|
|
<div class="stat-center" style="text-align: left;">
|
|
|
|
<h1>ffplayout</h1>
|
|
|
|
<h3 v-if="stat.system">
|
|
|
|
{{ stat.system }}<br>
|
|
|
|
{{ stat.node }}<br>
|
|
|
|
{{ stat.machine }}
|
|
|
|
</h3>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</b-col>
|
|
|
|
<b-col cols="4" class="chart-col chart2">
|
2020-04-30 03:42:50 -04:00
|
|
|
<div v-if="stat.cpu_usage || stat.cpu_usage >= 0">
|
2020-01-30 11:17:26 -05:00
|
|
|
<div>
|
|
|
|
<strong>CPU</strong>
|
|
|
|
</div>
|
|
|
|
<div class="stat-div">
|
|
|
|
<div class="stat-center">
|
|
|
|
<div style="text-align: left;">
|
|
|
|
<strong>Usage: </strong>{{ stat.cpu_usage }}%<br>
|
|
|
|
<strong>Load: </strong> {{ stat.cpu_load[0] }} {{ stat.cpu_load[1] }} {{ stat.cpu_load[2] }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</b-col>
|
|
|
|
<b-col cols="4" class="chart-col chart3">
|
|
|
|
<div v-if="stat.ram_total">
|
|
|
|
<div>
|
|
|
|
<strong>RAM</strong>
|
|
|
|
</div>
|
|
|
|
<div class="stat-div">
|
|
|
|
<div class="stat-center">
|
|
|
|
<div style="text-align: left;">
|
|
|
|
<strong>Total: </strong> {{ stat.ram_total[1] }}<br>
|
|
|
|
<strong>Used: </strong> {{ stat.ram_used[1] }}<br>
|
|
|
|
<strong>Free: </strong> {{ stat.ram_free[1] }}<br>
|
|
|
|
<strong>Cached: </strong> {{ stat.ram_cached[1] }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</b-col>
|
|
|
|
<b-col cols="4" class="chart-col chart4">
|
|
|
|
<div v-if="stat.swap_total">
|
|
|
|
<div>
|
|
|
|
<strong>SWAP</strong>
|
|
|
|
</div>
|
|
|
|
<div class="stat-div">
|
|
|
|
<div class="stat-center">
|
|
|
|
<div style="text-align: left;">
|
|
|
|
<strong>Total: </strong> {{ stat.swap_total[1] }}<br>
|
|
|
|
<strong>Used: </strong> {{ stat.swap_used[1] }}<br>
|
|
|
|
<strong>Free: </strong> {{ stat.swap_free[1] }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</b-col>
|
|
|
|
<b-col cols="4" class="chart-col chart5">
|
|
|
|
<div v-if="stat.disk_total">
|
|
|
|
<div>
|
|
|
|
<strong>DISK</strong>
|
|
|
|
</div>
|
|
|
|
<div class="stat-div">
|
|
|
|
<div class="stat-center">
|
|
|
|
<div style="text-align: left;">
|
|
|
|
<strong>Total: </strong> {{ stat.disk_total[1] }}<br>
|
|
|
|
<strong>Used: </strong> {{ stat.disk_used[1] }}<br>
|
|
|
|
<strong>Free: </strong> {{ stat.disk_free[1] }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</b-col>
|
|
|
|
<b-col cols="4" class="chart-col chart6">
|
|
|
|
<div v-if="stat.net_send">
|
|
|
|
<div>
|
|
|
|
<strong>NET</strong>
|
|
|
|
</div>
|
|
|
|
<div class="stat-div">
|
|
|
|
<div class="stat-center">
|
|
|
|
<div style="text-align: left;">
|
|
|
|
<strong>Download: </strong> {{ stat.net_speed_recv[1] }}/s<br>
|
|
|
|
<strong>Upload: </strong> {{ stat.net_speed_send[1] }}/s<br>
|
|
|
|
<strong>Downloaded: </strong> {{ stat.net_recv[1] }}<br>
|
|
|
|
<strong>Uploaded: </strong> {{ stat.net_send[1] }}<br>
|
|
|
|
<strong>Recived Errors: </strong> {{ stat.net_errin }}<br>
|
|
|
|
<strong>Sended Errors: </strong> {{ stat.net_errout }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
2020-01-29 11:40:15 -05:00
|
|
|
|
2020-01-30 11:17:26 -05:00
|
|
|
<div class="actions">
|
|
|
|
<b-button-group class="actions-grp">
|
2020-04-30 04:53:13 -04:00
|
|
|
<b-button to="/player" variant="primary">
|
|
|
|
Player
|
2020-04-07 11:56:33 -04:00
|
|
|
</b-button>
|
2020-04-15 12:11:04 -04:00
|
|
|
<b-button to="/media" variant="primary">
|
2020-01-31 07:45:56 -05:00
|
|
|
Media
|
|
|
|
</b-button>
|
2020-04-22 11:19:14 -04:00
|
|
|
<b-button to="/message" variant="primary">
|
|
|
|
Message
|
|
|
|
</b-button>
|
2020-04-15 12:11:04 -04:00
|
|
|
<b-button to="logging" variant="primary">
|
|
|
|
Logging
|
|
|
|
</b-button>
|
|
|
|
<b-button to="/configure" variant="primary">
|
2020-04-09 12:30:28 -04:00
|
|
|
Configure
|
|
|
|
</b-button>
|
2020-04-15 12:11:04 -04:00
|
|
|
<b-button variant="primary" @click="logout()">
|
2020-01-30 11:17:26 -05:00
|
|
|
Logout
|
|
|
|
</b-button>
|
|
|
|
</b-button-group>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</b-container>
|
2020-01-29 11:40:15 -05:00
|
|
|
</div>
|
2020-01-30 11:17:26 -05:00
|
|
|
</div>
|
2020-01-29 11:40:15 -05:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
components: {},
|
|
|
|
|
|
|
|
data () {
|
|
|
|
return {
|
2020-05-12 12:07:53 -04:00
|
|
|
showError: false,
|
2020-01-29 11:40:15 -05:00
|
|
|
formError: null,
|
|
|
|
formUsername: '',
|
2020-01-30 11:17:26 -05:00
|
|
|
formPassword: '',
|
|
|
|
interval: null,
|
|
|
|
stat: {}
|
2020-01-29 11:40:15 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created () {
|
|
|
|
this.init()
|
|
|
|
},
|
2020-01-30 11:17:26 -05:00
|
|
|
beforeDestroy () {
|
2020-04-21 09:30:36 -04:00
|
|
|
clearInterval(this.interval)
|
2020-01-30 11:17:26 -05:00
|
|
|
},
|
2020-01-29 11:40:15 -05:00
|
|
|
methods: {
|
|
|
|
async init () {
|
|
|
|
await this.$store.dispatch('auth/inspectToken')
|
|
|
|
this.checkLogin()
|
|
|
|
},
|
|
|
|
async login () {
|
|
|
|
try {
|
2020-05-12 12:07:53 -04:00
|
|
|
const status = await this.$store.dispatch('auth/obtainToken', {
|
2020-01-29 11:40:15 -05:00
|
|
|
username: this.formUsername,
|
|
|
|
password: this.formPassword
|
|
|
|
})
|
|
|
|
this.formUsername = ''
|
|
|
|
this.formPassword = ''
|
|
|
|
this.formError = null
|
|
|
|
|
2020-05-12 12:07:53 -04:00
|
|
|
if (status === 401) {
|
|
|
|
this.formError = 'Wrong user or password!'
|
|
|
|
this.showError = true
|
|
|
|
}
|
|
|
|
|
2020-01-29 11:40:15 -05:00
|
|
|
this.checkLogin()
|
2021-04-08 04:35:31 -04:00
|
|
|
await this.$store.dispatch('config/nuxtClientInit')
|
2020-01-29 11:40:15 -05:00
|
|
|
} catch (e) {
|
|
|
|
this.formError = e.message
|
|
|
|
}
|
|
|
|
},
|
2021-03-22 11:44:26 -04:00
|
|
|
logout () {
|
2020-04-21 09:30:36 -04:00
|
|
|
clearInterval(this.interval)
|
|
|
|
|
2020-01-29 11:40:15 -05:00
|
|
|
try {
|
2021-03-22 11:44:26 -04:00
|
|
|
this.$store.commit('auth/REMOVE_TOKEN')
|
|
|
|
this.$store.commit('auth/UPDATE_IS_LOGIN', false)
|
2020-01-29 11:40:15 -05:00
|
|
|
} catch (e) {
|
|
|
|
this.formError = e.message
|
|
|
|
}
|
|
|
|
},
|
|
|
|
checkLogin () {
|
|
|
|
if (this.$store.state.auth.isLogin) {
|
2020-01-30 11:17:26 -05:00
|
|
|
this.sysStats()
|
2020-01-29 11:40:15 -05:00
|
|
|
}
|
2020-01-30 11:17:26 -05:00
|
|
|
},
|
|
|
|
|
2020-04-16 12:30:31 -04:00
|
|
|
async sysStats () {
|
2020-05-03 15:11:25 -04:00
|
|
|
const response = await this.$axios.get('api/player/stats/?stats=all')
|
2020-05-08 09:32:12 -04:00
|
|
|
|
|
|
|
if (!response.data) {
|
|
|
|
this.$router.push('/configure')
|
|
|
|
}
|
2020-04-16 12:30:31 -04:00
|
|
|
this.stat = response.data
|
|
|
|
|
2020-09-15 04:26:47 -04:00
|
|
|
if (process.browser && !this.interval) {
|
2020-04-21 09:30:36 -04:00
|
|
|
this.interval = setInterval(async () => {
|
2021-04-03 15:11:56 -04:00
|
|
|
if (this.$store.state.auth.isLogin && this.$route.path === '/') {
|
|
|
|
const response = await this.$axios.get('api/player/stats/?stats=all')
|
|
|
|
this.stat = response.data
|
|
|
|
} else {
|
|
|
|
clearInterval(this.interval)
|
|
|
|
}
|
2020-04-21 09:30:36 -04:00
|
|
|
}, 2000)
|
|
|
|
}
|
2020-01-29 11:40:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.login-container {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
height: 100vh;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header {
|
|
|
|
text-align: center;
|
|
|
|
margin-bottom: 3em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.login-form {
|
|
|
|
min-width: 300px;
|
|
|
|
}
|
2020-01-30 11:17:26 -05:00
|
|
|
|
|
|
|
.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 11:40:15 -05:00
|
|
|
</style>
|