perf: 调试接口

This commit is contained in:
“huailei000”
2022-11-28 17:11:18 +08:00
parent ebe85219eb
commit 26c021fc77
7 changed files with 95 additions and 82 deletions

View File

@@ -592,6 +592,8 @@
"LoginTo": "Login to",
"LoginUsers": "Active users",
"Monthly": "Monthly",
"CurrentConnections": "Current connections",
"TodayFailedConnections": "Connections failed today",
"OnlineSessions": "Online sessions",
"OnlineUsers": "Online users",
"ConnectUsers": "Connect users",

View File

@@ -603,6 +603,8 @@
"LoginTo": "ログインしました",
"LoginUsers": "アクティブユーザー",
"Monthly": "月ごと",
"CurrentConnections": "現在の接続数",
"TodayFailedConnections": "今日の接続に失敗しました",
"OnlineSessions": "オンラインセッション",
"OnlineUsers": "オンラインユーザー",
"ConnectUsers": "ユーザーの接続",

View File

@@ -624,7 +624,9 @@
"LoginTo": "登录了",
"LoginUsers": "活跃用户",
"Monthly": "按月",
"OnlineSessions": "在线会话",
"CurrentConnections": "当前连接数",
"TodayFailedConnections": "今日连接失败数",
"OnlineSessions": "在线会话数",
"OnlineUsers": "在线用户",
"ConnectUsers": "连接用户",
"TimesWeekUnit": "次/周",

View File

@@ -21,22 +21,37 @@ export default {
return {
userConfig: {
title: '登录用户排名',
url: '/api/v1/users/users/',
url: '/api/v1/index/?dates_login_times_top10_users=1',
note: '登录用户排名',
columns: ['username'],
columnsMeta: {
username: {
showOverflowTooltip: true
data: 'dates_login_times_top10_users',
columns: [
{
prop: 'user',
label: '用户名'
},
{
prop: 'total',
label: '登录次数'
}
}
]
},
assetConfig: {
title: '活跃资产排名',
url: '/api/v1/assets/assets/',
url: '/api/v1/index/?dates_login_times_top10_assets=1',
note: '活跃资产排名',
columns: ['name'],
columnsMeta: {}
}
data: 'dates_login_times_top10_assets',
columns: [
{
prop: 'asset',
label: '资产名称'
},
{
prop: 'total',
label: '访问次数'
}
]
},
columnsMeta: {}
}
},
methods: {

View File

@@ -5,7 +5,7 @@
用户/资产活跃情况
<i class="fa fa-exclamation-circle icon" />
</span>
<span class="time">更新时间2022-11-17</span>
<!-- <span class="time">更新时间2022-11-17</span> -->
</div>
<echarts
ref="echarts"
@@ -37,8 +37,7 @@ export default {
metricsData: {
dates_metrics_date: [],
dates_metrics_total_count_active_assets: [],
dates_metrics_total_count_active_users: [],
dates_metrics_total_count_login: []
dates_metrics_total_count_active_users: []
}
}
},
@@ -46,13 +45,11 @@ export default {
themeColor() {
const documentStyle = document.documentElement.style
return {
primary: documentStyle.getPropertyValue('--color-primary'),
info: documentStyle.getPropertyValue('--color-info'),
success: documentStyle.getPropertyValue('--color-success')
primary: documentStyle.getPropertyValue('--color-primary')
}
},
options() {
const { primary, info, success } = this.themeColor
const { primary } = this.themeColor
return {
title: {
show: false
@@ -84,7 +81,7 @@ export default {
bottom: '3%',
containLabel: true
},
color: [primary, info, success],
color: [primary, '#F3B44B'],
xAxis: [
{
type: 'category',
@@ -136,13 +133,6 @@ export default {
animationDuration: 500,
series: [
{
name: this.$t('dashboard.LoginCount'),
type: 'line',
areaStyle: {},
smooth: true,
data: this.metricsData.dates_metrics_total_count_login
},
{
name: this.$t('dashboard.LoginUsers'),
type: 'line',
@@ -171,11 +161,17 @@ export default {
},
methods: {
async getMetricData() {
let url = '/api/v1/index/?dates_metrics=1&'
if (this.range === 'monthly') {
url = `${url}&monthly=1`
const url = '/api/v1/index/?dates_metrics=1&'
const data = await this.$axios.get(url)
this.metricsData = data
const activeAssets = 'dates_metrics_total_count_active_assets'
const activeUsers = 'dates_metrics_total_count_active_users'
if (data[activeAssets].length < 1) {
this.metricsData[activeAssets] = [0]
}
if (data[activeUsers].length < 1) {
this.metricsData[activeUsers] = [0]
}
this.metricsData = await this.$axios.get(url)
},
getDataUrl() {
this.dataUrl = this.$refs.echarts.getDataURL({

View File

@@ -26,16 +26,32 @@
</el-radio-group>
</span>
</div>
<AutoDataTable class="table" :config="tableConfig" />
<el-table
:data="tableData"
style="width: 100%"
class="table"
>
<el-table-column :label="'排名'">
<template v-slot="scope">
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column
v-for="i in columns"
:key="i.prop"
:prop="i.prop"
:label="i.label"
>
{{ i.prop }}
</el-table-column>
</el-table>
</div>
</template>
<script>
import AutoDataTable from '@/components/AutoDataTable'
export default {
components: {
AutoDataTable
},
props: {
title: {
@@ -50,24 +66,20 @@ export default {
type: String,
default: ''
},
data: {
type: String,
default: () => ''
},
columns: {
type: Array,
default: () => []
},
columnsMeta: {
type: Object,
default: () => ({})
},
config: {
type: Object,
default: () => ({})
},
options: {
type: Array,
default: () => [
{
label: '今天',
value: 'today'
value: '1'
},
{
label: '近7天',
@@ -82,29 +94,23 @@ export default {
},
data() {
return {
select: 'today',
tableConfig: {
url: this.url,
columns: [...new Set(['index', ...this.columns])],
columnsMeta: {
index: {
label: '排名',
width: 60,
formatter: (row, column, value, index) => index + 1
},
...this.columnsMeta
},
hasSelection: false,
paginationSize: 10
}
select: '1',
tableData: [],
tableUrl: this.url + `&days=1`
}
},
created() {
this.init()
},
methods: {
init() {
this.$axios.get(this.tableUrl).then(res => {
this.tableData = this.data ? res?.[this.data] : res
})
},
onChange() {
this.tableConfig.url = this.url + `?range=${this.select}`
this.tableUrl = this.url + `&days=${this.select}`
this.init()
}
}
}
@@ -155,15 +161,7 @@ export default {
}
}
}
.table {
&>>> .el-table .el-table__header-wrapper thead {
th, tr {
height: 46px;
background-color: #F5F6F7!important;
}
}
&>>> .el-data-table .el-pagination {
display: none;
}
>>> .el-table th, .el-table tr {
background-color: #F5F6F7!important;
}
</style>

View File

@@ -2,7 +2,7 @@
<div class="box">
<div style="margin-bottom: 12px;">
<span class="title">实时数据</span>
<span class="time">更新时间2022-11-17</span>
<!-- <span class="time">更新时间2022-11-17</span> -->
</div>
<div class="content">
<el-row type="flex" justify="space-between">
@@ -25,10 +25,9 @@ export default {
data() {
return {
counter: {
total_count_assets: '.',
total_count_users: '.',
total_count_online_sessions: '.',
total_count_online_users: '.',
total_count_online_sessions: '.'
total_count_today_failed_sessions: '.'
}
}
},
@@ -36,15 +35,15 @@ export default {
summaryItems() {
return [
{
title: this.$t('dashboard.AssetsTotal'),
title: this.$t('dashboard.OnlineSessions'),
body: {
route: { name: 'AssetList' },
count: this.counter.total_count_assets,
disabled: !this.$hasPerm('assets.view_asset')
route: { name: `SessionList`, params: { activeMenu: 'OnlineList' }},
count: this.counter.total_count_online_sessions,
disabled: !this.$hasPerm('terminal.view_session')
}
},
{
title: this.$t('dashboard.ConnectUsers'),
title: this.$t('dashboard.CurrentConnections'),
body: {
route: { name: `SessionList`, params: { activeMenu: 'OnlineList' }},
count: this.counter.total_count_online_users,
@@ -52,11 +51,10 @@ export default {
}
},
{
title: this.$t('dashboard.OnlineSessions'),
title: this.$t('dashboard.TodayFailedConnections'),
body: {
route: { name: `SessionList`, params: { activeMenu: 'OnlineList' }},
count: this.counter.total_count_online_sessions,
disabled: !this.$hasPerm('terminal.view_session')
count: this.counter.total_count_today_failed_sessions,
disabled: true
}
}
]