mirror of https://github.com/openspug/spug
U 优化dashboard移除最近登录
parent
2d9c2fc8b4
commit
b5d0e4a320
|
@ -62,7 +62,7 @@ def get_request(request):
|
||||||
data = {x.id: {'name': x.name, 'count': 0} for x in App.objects.all()}
|
data = {x.id: {'name': x.name, 'count': 0} for x in App.objects.all()}
|
||||||
for req in DeployRequest.objects.filter(created_at__gt=s_date, created_at__lt=e_date):
|
for req in DeployRequest.objects.filter(created_at__gt=s_date, created_at__lt=e_date):
|
||||||
data[req.deploy.app_id]['count'] += 1
|
data[req.deploy.app_id]['count'] += 1
|
||||||
data = sorted(data.values(), key=lambda x: x['count'], reverse=True)[:10]
|
data = sorted(data.values(), key=lambda x: x['count'], reverse=True)[:20]
|
||||||
return json_response(data)
|
return json_response(data)
|
||||||
return json_response(error=error)
|
return json_response(error=error)
|
||||||
|
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) OpenSpug Organization. https://github.com/openspug/spug
|
|
||||||
* Copyright (c) <spug.dev@gmail.com>
|
|
||||||
* Released under the AGPL-3.0 License.
|
|
||||||
*/
|
|
||||||
import React, { useState, useEffect } from 'react';
|
|
||||||
import { Card, List, Tag } from 'antd';
|
|
||||||
import { http } from 'libs';
|
|
||||||
import styles from './index.module.css';
|
|
||||||
|
|
||||||
export default function () {
|
|
||||||
const [name, setName] = useState(null);
|
|
||||||
const [ip, setIp] = useState(null);
|
|
||||||
const [rawData, setRawData] = useState([]);
|
|
||||||
const [dataSource, setDataSource] = useState([]);
|
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
http.get('/api/account/login/history/')
|
|
||||||
.then(res => setRawData(res))
|
|
||||||
.finally(() => setLoading(false))
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let data = rawData;
|
|
||||||
if (name) data = data.filter(x => x.nickname === name);
|
|
||||||
if (ip) data = data.filter(x => x.ip === ip);
|
|
||||||
setDataSource(data)
|
|
||||||
}, [name, ip, rawData])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Card loading={loading} title="最近30天登录" bodyStyle={{paddingTop: 0}} extra={(
|
|
||||||
<div>
|
|
||||||
{name !== null && <Tag closable color="#1890ff" onClose={() => setName(null)}>{name}</Tag>}
|
|
||||||
{ip !== null && <Tag closable color="#1890ff" onClose={() => setIp(null)}>{ip}</Tag>}
|
|
||||||
</div>
|
|
||||||
)}>
|
|
||||||
<List className={styles.loginActive} dataSource={dataSource} renderItem={item => (
|
|
||||||
<List.Item>
|
|
||||||
<span>{item.created_at}</span>
|
|
||||||
<span className={styles.spanText} onClick={() => setName(item.nickname)}>{item.nickname}</span>
|
|
||||||
<span>通过</span>
|
|
||||||
<span className={styles.spanText} onClick={() => setIp(item.ip)}>{item.ip}</span>
|
|
||||||
<span>登录</span>
|
|
||||||
</List.Item>
|
|
||||||
)}/>
|
|
||||||
</Card>
|
|
||||||
)
|
|
||||||
}
|
|
|
@ -50,7 +50,7 @@ export default function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card loading={loading} title="发布申请Top10" extra={(
|
<Card loading={loading} title="发布申请Top20" style={{marginTop: 20}} bodyStyle={{height: 353}} extra={(
|
||||||
<div style={{display: 'flex', alignItems: 'center'}}>
|
<div style={{display: 'flex', alignItems: 'center'}}>
|
||||||
<span className={range === 'day' ? styles.spanButtonActive : styles.spanButton}
|
<span className={range === 'day' ? styles.spanButtonActive : styles.spanButton}
|
||||||
onClick={() => handleClick('day')}>今日</span>
|
onClick={() => handleClick('day')}>今日</span>
|
||||||
|
|
|
@ -4,12 +4,10 @@
|
||||||
* Released under the AGPL-3.0 License.
|
* Released under the AGPL-3.0 License.
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Row, Col } from 'antd';
|
|
||||||
import { AuthDiv } from 'components';
|
import { AuthDiv } from 'components';
|
||||||
import StatisticsCard from './StatisticCard';
|
import StatisticsCard from './StatisticCard';
|
||||||
import AlarmTrend from './AlarmTrend';
|
import AlarmTrend from './AlarmTrend';
|
||||||
import RequestTop from './RequestTop';
|
import RequestTop from './RequestTop';
|
||||||
import LoginActive from './LoginActive';
|
|
||||||
|
|
||||||
class HomeIndex extends React.Component {
|
class HomeIndex extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
|
@ -17,14 +15,7 @@ class HomeIndex extends React.Component {
|
||||||
<AuthDiv auth="dashboard.dashboard.view">
|
<AuthDiv auth="dashboard.dashboard.view">
|
||||||
<StatisticsCard/>
|
<StatisticsCard/>
|
||||||
<AlarmTrend/>
|
<AlarmTrend/>
|
||||||
<Row style={{marginTop: 20}}>
|
|
||||||
<Col span={13}>
|
|
||||||
<RequestTop/>
|
<RequestTop/>
|
||||||
</Col>
|
|
||||||
<Col span={10} offset={1}>
|
|
||||||
<LoginActive/>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</AuthDiv>
|
</AuthDiv>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue