From b5d0e4a3206cd23bfc90bbedf0459632e8703293 Mon Sep 17 00:00:00 2001 From: vapao Date: Wed, 13 Jul 2022 18:12:27 +0800 Subject: [PATCH] =?UTF-8?q?U=20=E4=BC=98=E5=8C=96dashboard=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=9C=80=E8=BF=91=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_api/apps/home/views.py | 2 +- spug_web/src/pages/dashboard/LoginActive.js | 49 --------------------- spug_web/src/pages/dashboard/RequestTop.js | 2 +- spug_web/src/pages/dashboard/index.js | 11 +---- 4 files changed, 3 insertions(+), 61 deletions(-) delete mode 100644 spug_web/src/pages/dashboard/LoginActive.js diff --git a/spug_api/apps/home/views.py b/spug_api/apps/home/views.py index 45f9446..22938d9 100644 --- a/spug_api/apps/home/views.py +++ b/spug_api/apps/home/views.py @@ -62,7 +62,7 @@ def get_request(request): 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): 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(error=error) diff --git a/spug_web/src/pages/dashboard/LoginActive.js b/spug_web/src/pages/dashboard/LoginActive.js deleted file mode 100644 index d26fe29..0000000 --- a/spug_web/src/pages/dashboard/LoginActive.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) OpenSpug Organization. https://github.com/openspug/spug - * Copyright (c) - * 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 ( - - {name !== null && setName(null)}>{name}} - {ip !== null && setIp(null)}>{ip}} - - )}> - ( - - {item.created_at} - setName(item.nickname)}>{item.nickname} - 通过 - setIp(item.ip)}>{item.ip} - 登录 - - )}/> - - ) -} diff --git a/spug_web/src/pages/dashboard/RequestTop.js b/spug_web/src/pages/dashboard/RequestTop.js index db22eaa..2beaed2 100644 --- a/spug_web/src/pages/dashboard/RequestTop.js +++ b/spug_web/src/pages/dashboard/RequestTop.js @@ -50,7 +50,7 @@ export default function () { } return ( - handleClick('day')}>今日 diff --git a/spug_web/src/pages/dashboard/index.js b/spug_web/src/pages/dashboard/index.js index 7445929..3273bd3 100644 --- a/spug_web/src/pages/dashboard/index.js +++ b/spug_web/src/pages/dashboard/index.js @@ -4,12 +4,10 @@ * Released under the AGPL-3.0 License. */ import React from 'react'; -import { Row, Col } from 'antd'; import { AuthDiv } from 'components'; import StatisticsCard from './StatisticCard'; import AlarmTrend from './AlarmTrend'; import RequestTop from './RequestTop'; -import LoginActive from './LoginActive'; class HomeIndex extends React.Component { render() { @@ -17,14 +15,7 @@ class HomeIndex extends React.Component { - - - - - - - - + ) }