2022-08-11 15:49:41 +08:00
|
|
|
<template>
|
2022-08-12 15:25:54 +08:00
|
|
|
<div class="npm-sessions">
|
|
|
|
|
<div class="npm-sessions-title">{{$t('npm.relatedSessions')}}</div>
|
|
|
|
|
<div class="npm-sessions-div">
|
|
|
|
|
<div class="npm-sessions-div-green" id="green" v-show="clientSessions > 0"></div>
|
|
|
|
|
<div class="npm-sessions-div-red" id="red" v-show="serverSessions > 0"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="npm-sessions-body">
|
|
|
|
|
<div class="npm-sessions-body-left">
|
|
|
|
|
<div class="npm-sessions-as-clients right">
|
|
|
|
|
<div class="npm-sessions-as-client">
|
|
|
|
|
<div class="npm-sessions-as-client-green"></div>
|
|
|
|
|
<div class="npm-sessions-as-client-i18n">{{$t('npm.asClient')}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="npm-sessions-as-client-percent">{{sessionData.clientSessions}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="npm-sessions-as-clients">
|
|
|
|
|
<div class="npm-sessions-as-client">
|
|
|
|
|
<div class="npm-sessions-as-client-red"></div>
|
2022-08-24 16:58:34 +08:00
|
|
|
<div class="npm-sessions-as-client-i18n">{{$t('npm.asServer')}}</div>
|
2022-08-12 15:25:54 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="npm-sessions-as-client-percent">{{sessionData.serverSessions}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="npm-sessions-body-right">
|
|
|
|
|
<span class="npm-sessions-Progress-number">{{unitConvert(sessionData.sessionsRate, unitTypes.number)[0]}}</span> <span class="npm-sessions-Progress-unit">{{unitConvert(sessionData.sessionsRate, unitTypes.number)[1]}}Sessions/s</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2022-08-11 15:49:41 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-08-12 15:25:54 +08:00
|
|
|
import { get } from '@/utils/http'
|
|
|
|
|
import { api } from '@/utils/api'
|
|
|
|
|
import { getSecond } from '@/utils/date-util'
|
|
|
|
|
import unitConvert from '@/utils/unit-convert'
|
|
|
|
|
import { unitTypes } from '@/utils/constants'
|
2022-08-22 15:49:38 +08:00
|
|
|
import chartMixin from '@/views/charts2/chart-mixin'
|
2022-08-12 15:25:54 +08:00
|
|
|
|
2022-08-11 15:49:41 +08:00
|
|
|
export default {
|
2022-08-12 15:25:54 +08:00
|
|
|
name: 'RelatedSessions',
|
2022-08-22 15:49:38 +08:00
|
|
|
mixins: [chartMixin],
|
2022-08-12 15:25:54 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
sessionData: {},
|
|
|
|
|
unitConvert,
|
|
|
|
|
unitTypes,
|
|
|
|
|
clientSessions: 0,
|
2022-08-22 15:49:38 +08:00
|
|
|
serverSessions: 0
|
2022-08-12 15:25:54 +08:00
|
|
|
}
|
|
|
|
|
},
|
2022-08-24 17:09:42 +08:00
|
|
|
watch: {
|
|
|
|
|
timeFilter: {
|
|
|
|
|
handler (n) {
|
|
|
|
|
this.relatedSessionsData()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-08-12 15:25:54 +08:00
|
|
|
methods: {
|
|
|
|
|
relatedSessionsData () {
|
2022-09-20 09:33:49 +08:00
|
|
|
const conditionStr = this.$route.query.queryCondition ? this.$route.query.queryCondition : ''
|
|
|
|
|
const condition = conditionStr.split(/["|'](.*?)["|']/)
|
2022-08-12 15:25:54 +08:00
|
|
|
const params = {
|
|
|
|
|
startTime: getSecond(this.timeFilter.startTime),
|
|
|
|
|
endTime: getSecond(this.timeFilter.endTime),
|
2022-08-22 15:49:38 +08:00
|
|
|
ip: condition[1]
|
2022-08-12 15:25:54 +08:00
|
|
|
}
|
|
|
|
|
const divGreen = document.getElementById('green')
|
|
|
|
|
const divred = document.getElementById('red')
|
|
|
|
|
get(api.npm.overview.relatedSessions, params).then(res => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
this.sessionData = res.data.result
|
2022-08-22 19:54:41 +08:00
|
|
|
this.clientSessions = this.sessionData.clientSessions / (this.sessionData.clientSessions * 1 + this.sessionData.serverSessions * 1)
|
|
|
|
|
this.serverSessions = this.sessionData.serverSessions / (this.sessionData.clientSessions * 1 + this.sessionData.serverSessions * 1)
|
2022-08-12 15:25:54 +08:00
|
|
|
this.sessionData.clientSessions = unitConvert(this.clientSessions, unitTypes.percent).join('')
|
|
|
|
|
this.sessionData.serverSessions = unitConvert(this.serverSessions, unitTypes.percent).join('')
|
|
|
|
|
if (this.clientSessions === 1) {
|
|
|
|
|
divGreen.style.borderRadius = 4 + 'px'
|
|
|
|
|
} else if (this.serverSessions === 1) {
|
|
|
|
|
divred.style.borderRadius = 4 + 'px'
|
|
|
|
|
}
|
|
|
|
|
divGreen.style.width = this.sessionData.clientSessions
|
|
|
|
|
divred.style.width = this.sessionData.serverSessions
|
|
|
|
|
}
|
2022-08-22 15:49:38 +08:00
|
|
|
}).finally(() => {
|
|
|
|
|
this.toggleLoading(false)
|
2022-08-12 15:25:54 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted () {
|
|
|
|
|
this.relatedSessionsData()
|
|
|
|
|
}
|
2022-08-11 15:49:41 +08:00
|
|
|
}
|
|
|
|
|
</script>
|