From 8f07643201f37c66be81e3009e7261ae5bec6fdc Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 18 Mar 2022 18:45:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=89=E5=85=A8=E4=B8=AD?= =?UTF-8?q?=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sysom_web/config/routes.js | 27 +- sysom_web/src/locales/zh-CN/menu.js | 5 +- .../src/pages/Monitor/SystemDashboard.jsx | 10 +- sysom_web/src/pages/Welcome.jsx | 22 +- sysom_web/src/pages/Welcome.less | 2 +- .../Memory/Market/MarketCacheTable.jsx | 44 --- .../diagnose/Memory/Market/MarketEvent.jsx | 57 ---- .../diagnose/Memory/Market/MarketMemory.jsx | 28 -- .../Memory/Market/MarketMemoryTable.jsx | 57 ---- .../Memory/Market/MarketTableList.jsx | 88 ------ .../diagnose/Memory/Market/MarketTaskForm.jsx | 53 ---- .../pages/diagnose/Memory/Market/index.jsx | 93 ------ .../Net/{Network => }/NetTableList.jsx | 4 +- .../Net/{Network => }/NetTaskForm.jsx | 2 +- .../diagnose/Net/{Network => }/NetworkFlow.js | 2 +- .../diagnose/Net/{Network => }/PacketLoss.js | 0 .../diagnose/Net/{Network => }/index.jsx | 4 +- .../pages/diagnose/Storage/Io/IOResults.jsx | 5 +- .../pages/diagnose/Storage/Io/IOTableList.jsx | 2 +- .../src/pages/diagnose/Storage/Io/index.jsx | 75 ++--- sysom_web/src/pages/diagnose/_mock.js | 298 ------------------ .../pages/diagnose/components/MetricShow.js | 2 + .../pages/diagnose/components/PieCharts.js | 32 -- .../pages/diagnose/oscheck/osCheckList.jsx | 2 +- .../diagnose/oscheck/osCheckTaskForm.jsx | 1 + sysom_web/src/pages/diagnose/service.js | 23 -- sysom_web/src/pages/journal/service.js | 4 +- .../src/pages/security/Historical/hist.less | 2 +- .../src/pages/security/Historical/index.jsx | 33 +- .../security/Historicalist/historicalist.less | 7 +- .../pages/security/Historicalist/index.jsx | 53 +++- .../src/pages/security/Homelist/index.jsx | 100 +++--- sysom_web/src/pages/security/List/index.jsx | 233 ++++++++------ .../src/pages/security/Viewdetails/index.jsx | 123 +++++--- sysom_web/src/pages/security/auth.js | 3 - sysom_web/src/pages/security/axios.js | 51 --- .../pages/security/components/Headcard.jsx | 32 ++ sysom_web/src/pages/security/products.js | 32 -- sysom_web/src/pages/security/service.js | 113 +++++++ sysom_web/src/pages/user/Login/agreem.jsx | 6 +- sysom_web/src/pages/user/Login/index.jsx | 2 + sysom_web/src/pages/user/Login/index.less | 10 + sysom_web/yarn.lock | 12 - 43 files changed, 544 insertions(+), 1210 deletions(-) delete mode 100644 sysom_web/src/pages/diagnose/Memory/Market/MarketCacheTable.jsx delete mode 100644 sysom_web/src/pages/diagnose/Memory/Market/MarketEvent.jsx delete mode 100644 sysom_web/src/pages/diagnose/Memory/Market/MarketMemory.jsx delete mode 100644 sysom_web/src/pages/diagnose/Memory/Market/MarketMemoryTable.jsx delete mode 100644 sysom_web/src/pages/diagnose/Memory/Market/MarketTableList.jsx delete mode 100644 sysom_web/src/pages/diagnose/Memory/Market/MarketTaskForm.jsx delete mode 100644 sysom_web/src/pages/diagnose/Memory/Market/index.jsx rename sysom_web/src/pages/diagnose/Net/{Network => }/NetTableList.jsx (96%) rename sysom_web/src/pages/diagnose/Net/{Network => }/NetTaskForm.jsx (98%) rename sysom_web/src/pages/diagnose/Net/{Network => }/NetworkFlow.js (99%) rename sysom_web/src/pages/diagnose/Net/{Network => }/PacketLoss.js (100%) rename sysom_web/src/pages/diagnose/Net/{Network => }/index.jsx (95%) delete mode 100644 sysom_web/src/pages/diagnose/components/PieCharts.js delete mode 100644 sysom_web/src/pages/security/auth.js delete mode 100644 sysom_web/src/pages/security/axios.js create mode 100644 sysom_web/src/pages/security/components/Headcard.jsx delete mode 100644 sysom_web/src/pages/security/products.js create mode 100644 sysom_web/src/pages/security/service.js diff --git a/sysom_web/config/routes.js b/sysom_web/config/routes.js index 79bb098f..57ed78d0 100644 --- a/sysom_web/config/routes.js +++ b/sysom_web/config/routes.js @@ -125,32 +125,7 @@ export default [ { path: '/diagnose/net', name: 'net', - routes: [ - { - path: '/diagnose/net', - redirect: '/diagnose/net/network', - }, - { - path: '/diagnose/net/network', - name: 'network', - component: './diagnose/Net/Network', - } - ] - }, - { - path: '/diagnose/memory', - name: 'memory', - routes: [ - { - path: '/diagnose/memory', - redirect: '/diagnose/memory/market', - }, - { - path: '/diagnose/memory/market', - name: 'market', - component: './diagnose/Memory/Market', - } - ] + component: './diagnose/Net', }, ], }, diff --git a/sysom_web/src/locales/zh-CN/menu.js b/sysom_web/src/locales/zh-CN/menu.js index cea3e055..b6b5523d 100644 --- a/sysom_web/src/locales/zh-CN/menu.js +++ b/sysom_web/src/locales/zh-CN/menu.js @@ -66,13 +66,10 @@ export default { 'menu.diagnose.storage': '存储诊断中心', 'menu.diagnose.storage.io': 'IO延时诊断', 'menu.diagnose.net': '网络诊断中心', - 'menu.diagnose.net.network': '网络延时诊断', 'menu.diagnose.oscheck': '系统健康检查', - 'menu.diagnose.memory': '内存诊断中心', - 'menu.diagnose.memory.market': '内存大盘', 'menu.vmcore.analyse': '在线分析', 'menu.journal': '日志中心', 'menu.journal.audit': '审计日志', 'menu.security':'安全中心', - 'menu.security.list':'安全列表' + 'menu.security.list':'漏洞中心' }; diff --git a/sysom_web/src/pages/Monitor/SystemDashboard.jsx b/sysom_web/src/pages/Monitor/SystemDashboard.jsx index 5aebf17d..737e3af8 100644 --- a/sysom_web/src/pages/Monitor/SystemDashboard.jsx +++ b/sysom_web/src/pages/Monitor/SystemDashboard.jsx @@ -4,11 +4,11 @@ import ProTable from '@ant-design/pro-table'; import { Card, Statistic } from 'antd'; import { Space, Row, Col } from 'antd'; import { useIntl, useRequest, useParams, FormattedMessage } from 'umi'; -import {useState, useRef} from 'react' +import { useState } from 'react' import { getHost } from '../host/service'; const ServerList = (props) => { - const actionRef = useRef(); + const ServerListColumns = [ { title: "机器HostName(IP)", @@ -58,10 +58,10 @@ const ServerList = (props) => { { - setHostIP(ip)}/> + setHostIP(ip)}/> diff --git a/sysom_web/src/pages/Welcome.jsx b/sysom_web/src/pages/Welcome.jsx index 2ffe7aa8..608ec046 100644 --- a/sysom_web/src/pages/Welcome.jsx +++ b/sysom_web/src/pages/Welcome.jsx @@ -20,7 +20,7 @@ const Welcome = () => {
- 系统运维平台 + 系统运维平台
首页 @@ -33,23 +33,17 @@ const Welcome = () => { 宕机匹配 - 系统健康检查 - - IO延时诊断 - - - 网络延时诊断 - - - 内存大盘 - + 系统健康检查 + 存储诊断中心 + 网络诊断中心 + + + 漏洞中心 审计日志 - - 安全列表 - +
diff --git a/sysom_web/src/pages/Welcome.less b/sysom_web/src/pages/Welcome.less index 5ace2ebb..7c21ea83 100644 --- a/sysom_web/src/pages/Welcome.less +++ b/sysom_web/src/pages/Welcome.less @@ -19,7 +19,7 @@ .logo{ position: absolute; left: 84px; - width: 120px; + width: 240px; font-size: 16px; } .menuCenter{ diff --git a/sysom_web/src/pages/diagnose/Memory/Market/MarketCacheTable.jsx b/sysom_web/src/pages/diagnose/Memory/Market/MarketCacheTable.jsx deleted file mode 100644 index fd54fd88..00000000 --- a/sysom_web/src/pages/diagnose/Memory/Market/MarketCacheTable.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import React, { useRef } from "react"; -import ProTable from "@ant-design/pro-table"; - -const MarketCacheTable = React.forwardRef((props, ref) => { - const actionRef = useRef(); - const columns = [ - { - title: "文件名", - dataIndex: "file", - valueType: "textarea", - }, - { - title: "cached", - dataIndex: "cached", - valueType: "textarea", - renderText: (val) => `${val} KB`, - }, - { - title: "进程", - dataIndex: "task", - renderText: (val) => `${val.toString()}`, - } - ]; - const pagination=(props.pagination) ? props.pagination : {pageSize: 5} - return ( - { - return Promise.resolve({ - data: props.data.filecacheTop, - success: true, - }); - }} - columns={columns} - pagination={pagination} - search={false} - /> - ); -}); - -export default MarketCacheTable; diff --git a/sysom_web/src/pages/diagnose/Memory/Market/MarketEvent.jsx b/sysom_web/src/pages/diagnose/Memory/Market/MarketEvent.jsx deleted file mode 100644 index 9fe33728..00000000 --- a/sysom_web/src/pages/diagnose/Memory/Market/MarketEvent.jsx +++ /dev/null @@ -1,57 +0,0 @@ -import { Statistic } from 'antd'; -import { useState } from 'react'; -import ProCard from '@ant-design/pro-card'; -import RcResizeObserver from 'rc-resize-observer'; -import styles from '../../diagnose.less'; - -const { Divider } = ProCard; - -const DiagExtra = (props) => { - return ( - <> -
诊断ID:
-
{props.dataSour.task_id}
-
诊断时间:
-
{props.dataSour.created_at}
- - ) -} - -export default (props) => { - const [responsive, setResponsive] = useState(false); - return ( - { - setResponsive(offset.width < 596); - }} - > - , - ]} - split={responsive ? 'horizontal' : 'vertical'} - headerBordered - > - - - "50" ? "red" : "green" }} /> - - - - - - - - - - - - - - - - - ); -} \ No newline at end of file diff --git a/sysom_web/src/pages/diagnose/Memory/Market/MarketMemory.jsx b/sysom_web/src/pages/diagnose/Memory/Market/MarketMemory.jsx deleted file mode 100644 index 613dea28..00000000 --- a/sysom_web/src/pages/diagnose/Memory/Market/MarketMemory.jsx +++ /dev/null @@ -1,28 +0,0 @@ -import { Row, Col } from 'antd'; -import { useState } from 'react'; -import RcResizeObserver from 'rc-resize-observer'; -import PieCharts from '../../components/PieCharts' - -export default (props) => { - const [responsive, setResponsive] = useState(false); - return ( - { - setResponsive(offset.width < 596); - }} - > - - - - - - - - - - - - - ); -} \ No newline at end of file diff --git a/sysom_web/src/pages/diagnose/Memory/Market/MarketMemoryTable.jsx b/sysom_web/src/pages/diagnose/Memory/Market/MarketMemoryTable.jsx deleted file mode 100644 index cea22516..00000000 --- a/sysom_web/src/pages/diagnose/Memory/Market/MarketMemoryTable.jsx +++ /dev/null @@ -1,57 +0,0 @@ -import React, { useRef } from "react"; -import ProTable from "@ant-design/pro-table"; - -const MarketMemoryTable = React.forwardRef((props, ref) => { - const actionRef = useRef(); - const columns = [ - { - title: "进程名", - dataIndex: "comm", - valueType: "textarea", - }, - { - title: "总内存", - dataIndex: "total_mem", - valueType: "textarea", - renderText: (val) => `${val} KB`, - }, - { - title: "anon", - dataIndex: "RssAnon", - valueType: "textarea", - renderText: (val) => `${val} KB`, - }, - { - title: 'file', - dataIndex: 'RssFile', - valueType: "textarea", - renderText: (val) => `${val} KB`, - }, - { - title: "RssShmem", - dataIndex: "RssShmem", - valueType: "textarea", - renderText: (val) => `${val} KB`, - } - ]; - const pagination=(props.pagination) ? props.pagination : {pageSize: 5} - return ( - { - return Promise.resolve({ - data: props.data.taskMemTop, - success: true, - }); - }} - columns={columns} - pagination={pagination} - search={false} - /> - ); -}); - -export default MarketMemoryTable; diff --git a/sysom_web/src/pages/diagnose/Memory/Market/MarketTableList.jsx b/sysom_web/src/pages/diagnose/Memory/Market/MarketTableList.jsx deleted file mode 100644 index 1276bb54..00000000 --- a/sysom_web/src/pages/diagnose/Memory/Market/MarketTableList.jsx +++ /dev/null @@ -1,88 +0,0 @@ -import React, { useRef } from "react"; -import ProTable from "@ant-design/pro-table"; -import { getTaskList } from "../../service"; - -const getMemList = async () => { - try { - let msg = await getTaskList({ service_name: "memgraph" }); - msg.data = msg.data.map((item) => ({ ...item, ...JSON.parse(item.params) })) - return { - data: msg.data.reverse(), - success: true, - total: msg.total, - }; - } catch (e) { - return { success: false } - } -} - -const MarketTableList = React.forwardRef((props, ref) => { - const actionRef = useRef(); - - const columns = [ - { - title: "实例IP", - dataIndex: "实例IP", - valueType: "textarea", - }, - { - title: "创建时间", - dataIndex: "created_at", - valueType: "dateTime", - }, - { - title: "诊断ID", - dataIndex: "task_id", - valueType: "textarea", - }, - { - title: '状态', - dataIndex: 'status', - width: 150, - valueEnum: { - Running: { text: '运行中', status: 'Processing' }, - Success: { text: '诊断完毕', status: 'Success' }, - Fail: { text: '异常', status: 'Error' }, - }, - }, - { - title: "操作", - dataIndex: "option", - valueType: "option", - render: (_, record) => { - if (record.status == "Success") { - return ( - { - props?.onClick?.(record) - }}>查看诊断结果 - ) - } - else if (record.status == "Fail") { - return ( - { - props?.onError?.(record) - }}>查看出错信息 - ) - } - else { - return (暂无可用操作); - } - }, - } - ]; - const pagination=(props.pagination) ? props.pagination : {pageSize: 5} - return ( - - ); -}); - -export default MarketTableList; diff --git a/sysom_web/src/pages/diagnose/Memory/Market/MarketTaskForm.jsx b/sysom_web/src/pages/diagnose/Memory/Market/MarketTaskForm.jsx deleted file mode 100644 index 8afe589e..00000000 --- a/sysom_web/src/pages/diagnose/Memory/Market/MarketTaskForm.jsx +++ /dev/null @@ -1,53 +0,0 @@ -import ProForm, { ProFormText } from '@ant-design/pro-form'; -import { Button } from 'antd'; -import { useRequest } from 'umi'; -import ProCard from '@ant-design/pro-card'; -import { postTask } from '../../service'; - -export default (props) => { - const { loading, error, run } = useRequest(postTask, { - manual: true, - onSuccess: (result, params) => { - props?.onSuccess?.(result, params) - }, - }); - - return ( - - { - run(values) - }} - submitter={{ - submitButtonProps: { - style: { - display: 'none', - }, - }, - resetButtonProps: { - style: { - display: 'none', - }, - }, - }} - layout={"horizontal"} - autoFocusFirstInput - > - - - ) -} \ No newline at end of file diff --git a/sysom_web/src/pages/diagnose/Memory/Market/index.jsx b/sysom_web/src/pages/diagnose/Memory/Market/index.jsx deleted file mode 100644 index 8374a44f..00000000 --- a/sysom_web/src/pages/diagnose/Memory/Market/index.jsx +++ /dev/null @@ -1,93 +0,0 @@ -import { PageContainer } from '@ant-design/pro-layout'; -import { useState, useRef } from 'react'; -import { Modal } from "antd"; -import { request } from 'umi'; -import ProCard from '@ant-design/pro-card'; -import MarketTaskForm from './MarketTaskForm'; -import MarketTableList from './MarketTableList'; -import MarketEvent from './MarketEvent' -import MarketMemory from './MarketMemory' -import MarketMemoryTable from './MarketMemoryTable' -import MarketCacheTable from './MarketCacheTable' -import { getTask } from '../../service' - -const { Divider } = ProCard; - -const MarketList = () => { - const refIoTableList = useRef(); - const [data, setData] = useState(); - - const onListClick = async (record) => { - const recorded = record; - const msg = await request('/api/v1/tasks/' + record.id); - msg.data.result = JSON.parse(msg.data.result) - const memgraph = Object.entries(msg.data.result.memgraph).reduce((memgraph, items) => { - memgraph.push( - { - type: items[0], - value: items[1] - } - ); - return memgraph; - }, []) - const kernel = Object.entries(msg.data.result.kernel).reduce((kernel, items) => { - kernel.push( - { - type: items[0], - value: items[1] - } - ); - return kernel; - }, []) - const user = Object.entries(msg.data.result.user).reduce((user, items) => { - user.push( - { - type: items[0], - value: items[1] - } - ); - return user; - }, []) - setData({rawData:msg.data.result, recorded:recorded, memgraph:memgraph, kernel: kernel, user:user}); - } - - const onPostTask = () => { - refIoTableList.current.reload(); - } - - const onError = async (record) => { - const msg = await getTask(record.id); - Modal.error({ - title: '诊断失败', - content: ( -
-
错误信息: {msg.result}
-
- ), - }); - } - return ( - - - - onListClick(record)} onError={onError} ref={refIoTableList} /> - - { - data ? - <> - - - - - - - - - : - <> - } - - ); -}; - -export default MarketList; diff --git a/sysom_web/src/pages/diagnose/Net/Network/NetTableList.jsx b/sysom_web/src/pages/diagnose/Net/NetTableList.jsx similarity index 96% rename from sysom_web/src/pages/diagnose/Net/Network/NetTableList.jsx rename to sysom_web/src/pages/diagnose/Net/NetTableList.jsx index 7af558da..435966d0 100644 --- a/sysom_web/src/pages/diagnose/Net/Network/NetTableList.jsx +++ b/sysom_web/src/pages/diagnose/Net/NetTableList.jsx @@ -1,6 +1,6 @@ import React, { useRef } from "react"; import ProTable from "@ant-design/pro-table"; -import { getTaskList } from "../../service"; +import { getTaskList } from "../service"; import { Button } from "antd"; function parseJsonString(str) { @@ -76,7 +76,7 @@ const DiagnoTableList = React.forwardRef((props, ref) => { dataIndex: 'status', width: 150, valueEnum: { - Running: { text: '运行中', status: 'Processing' }, + Ready: { text: '运行中', status: 'Processing' }, Success: { text: '诊断完毕', status: 'Success' }, Fail: { text: '异常', status: 'Error' }, }, diff --git a/sysom_web/src/pages/diagnose/Net/Network/NetTaskForm.jsx b/sysom_web/src/pages/diagnose/Net/NetTaskForm.jsx similarity index 98% rename from sysom_web/src/pages/diagnose/Net/Network/NetTaskForm.jsx rename to sysom_web/src/pages/diagnose/Net/NetTaskForm.jsx index a1eaa114..631a6e45 100644 --- a/sysom_web/src/pages/diagnose/Net/Network/NetTaskForm.jsx +++ b/sysom_web/src/pages/diagnose/Net/NetTaskForm.jsx @@ -2,7 +2,7 @@ import ProForm, { ProFormSelect, ProFormText, ProFormDigit } from '@ant-design/p import { message, Button, Row, Col } from 'antd'; import { useRequest } from 'umi'; import ProCard from '@ant-design/pro-card'; -import { postTask } from '../../service' +import { postTask } from '../service' export default (props) => { const { loading, error, run } = useRequest(postTask, { diff --git a/sysom_web/src/pages/diagnose/Net/Network/NetworkFlow.js b/sysom_web/src/pages/diagnose/Net/NetworkFlow.js similarity index 99% rename from sysom_web/src/pages/diagnose/Net/Network/NetworkFlow.js rename to sysom_web/src/pages/diagnose/Net/NetworkFlow.js index 62743034..0c2caac4 100644 --- a/sysom_web/src/pages/diagnose/Net/Network/NetworkFlow.js +++ b/sysom_web/src/pages/diagnose/Net/NetworkFlow.js @@ -1,6 +1,6 @@ import { useState} from 'react'; import { Popover, Modal, Button } from 'antd'; -import MetricShow from '../../components/MetricShow' +import MetricShow from '../components/MetricShow' import ProCard from '@ant-design/pro-card'; import { Line } from '@ant-design/charts'; diff --git a/sysom_web/src/pages/diagnose/Net/Network/PacketLoss.js b/sysom_web/src/pages/diagnose/Net/PacketLoss.js similarity index 100% rename from sysom_web/src/pages/diagnose/Net/Network/PacketLoss.js rename to sysom_web/src/pages/diagnose/Net/PacketLoss.js diff --git a/sysom_web/src/pages/diagnose/Net/Network/index.jsx b/sysom_web/src/pages/diagnose/Net/index.jsx similarity index 95% rename from sysom_web/src/pages/diagnose/Net/Network/index.jsx rename to sysom_web/src/pages/diagnose/Net/index.jsx index 34072bf3..d90c7c3c 100644 --- a/sysom_web/src/pages/diagnose/Net/Network/index.jsx +++ b/sysom_web/src/pages/diagnose/Net/index.jsx @@ -7,8 +7,8 @@ import NetTableList from './NetTableList'; import PacketLoss from './PacketLoss' import NetworkFlow from './NetworkFlow'; import NetTaskForm from './NetTaskForm'; -import MetricShow from '../../components/MetricShow' -import { getTask } from '../../service' +import MetricShow from '../components/MetricShow' +import { getTask } from '../service' const { Divider } = ProCard; diff --git a/sysom_web/src/pages/diagnose/Storage/Io/IOResults.jsx b/sysom_web/src/pages/diagnose/Storage/Io/IOResults.jsx index 196f660f..54bef14e 100644 --- a/sysom_web/src/pages/diagnose/Storage/Io/IOResults.jsx +++ b/sysom_web/src/pages/diagnose/Storage/Io/IOResults.jsx @@ -81,7 +81,6 @@ export default (props) => { > {props.data[count].delays.map((item, index) => { - const length = props.data[count].delays.length return ( {
AVG: {item.avg}
MIN: {item.min}
- {index !== (length - 1) ? ( + {index !== 3 ? ( { ); -}; +}; \ No newline at end of file diff --git a/sysom_web/src/pages/diagnose/Storage/Io/IOTableList.jsx b/sysom_web/src/pages/diagnose/Storage/Io/IOTableList.jsx index 776ae4ea..02d2f6cc 100644 --- a/sysom_web/src/pages/diagnose/Storage/Io/IOTableList.jsx +++ b/sysom_web/src/pages/diagnose/Storage/Io/IOTableList.jsx @@ -64,7 +64,7 @@ const IOTableList = React.forwardRef((props, ref) => { dataIndex: 'status', width: 150, valueEnum: { - Running: { text: '运行中', status: 'Processing' }, + Ready: { text: '运行中', status: 'Running' }, Success: { text: '诊断完毕', status: 'Success' }, Fail: { text: '异常', status: 'Error' }, }, diff --git a/sysom_web/src/pages/diagnose/Storage/Io/index.jsx b/sysom_web/src/pages/diagnose/Storage/Io/index.jsx index c35e4970..8ec36701 100644 --- a/sysom_web/src/pages/diagnose/Storage/Io/index.jsx +++ b/sysom_web/src/pages/diagnose/Storage/Io/index.jsx @@ -22,46 +22,39 @@ const IOList = () => { )) const onListClick = async (record) => { - const recorded = record; - const msg = await request('/api/v1/tasks/' + record.id); - if (msg.data.result == '{\n \"status\": \"success\",\n \"IO timeout\": \"false\"\n}\n') { - Modal.success({ - title: '诊断成功', - content: ( -
-
诊断完成: {msg.data.result}
-
- ), - }); - return - } - const metlist = []; - msg.data.result = JSON.parse(msg.data.result) - const ioList = msg.data.result.seq.reduce((ioList, item, index, arr) => { - const block = item["slow ios"].filter((item2,index2) => { - const block2 = item2.delays.filter((item3,index3) => { - metlist.push({ - x:item2.time, - y:item3.delay, - category:item3.component, - }); - }) - }); - ioList.push({ - diskname: item.diskname, - delays: msg.data.result.stat[index].delays, - }); - return ioList - }, []) - const metric = []; - const size = metlist.length / ioList.length; - for(let i = 0;i { + // const recorded = record; + // const msg = await getTask(record.id); + // const metlist = []; + // const metric = msg.data.seq.reduce((metric, item, index, arr) => { + // const block = item["slow ios"].filter((item2,index2) => { + // const block2 = item2.delays.filter((item3,index3) => { + // metlist.push({ + // x:item2.time, + // y:item3.delay, + // category:item3.component, + // }); + // }) + // }); + // metric.push({ + // diskname: item.diskname, + // slowios: item["slow ios"], + // delays: msg.data.stat[index].delays, + // }); + // return metric + // }, []) + // const restlist = []; + // const size = metlist.length / metric.length; + // for(let i = 0;i { refIoTableList.current.reload(); @@ -87,8 +80,8 @@ const IOList = () => { { data ? <> - - + + : <> diff --git a/sysom_web/src/pages/diagnose/_mock.js b/sysom_web/src/pages/diagnose/_mock.js index 613e17c3..e9ee7b5a 100644 --- a/sysom_web/src/pages/diagnose/_mock.js +++ b/sysom_web/src/pages/diagnose/_mock.js @@ -29,8 +29,6 @@ const genList = (current, pageSize) => { const time = Math.random() * 100; const items = ["icmp","tcp"]; const agreement = items[Math.floor(Math.random() * items.length)]; - const sta = ["Ready","Success","Fail"]; - const status = sta[Math.floor(Math.random() * sta.length)]; tableListDataSource.push({ id: index, name: name, @@ -45,7 +43,6 @@ const genList = (current, pageSize) => { threshold: threshold, agreement: agreement, core_time: new Date(), - status: status, ver: "3.10.0-327.ali2008." + name + ".alios7.x86_64", ping: "pt-" + name + "bm", vmcore_file: Boolean(Math.round(Math.random())), @@ -22891,304 +22888,9 @@ async function postIOTask(req, res, u) { return res.json(result); } -async function getMarketTable(req, res, u) { - let realUrl = u; - - if ( - !realUrl || - Object.prototype.toString.call(realUrl) !== "[object String]" - ) { - realUrl = req.url; - } - - const { current = 1, pageSize = 10 } = req.query; - const params = parse(realUrl, true).query; - let dataSource = tableListDataSource; - - if (params.sorter) { - const sorter = JSON.parse(params.sorter); - dataSource = dataSource.sort((prev, next) => { - let sortNumber = 0; - Object.keys(sorter).forEach((key) => { - if (sorter[key] === "descend") { - if (prev[key] - next[key] > 0) { - sortNumber += -1; - } else { - sortNumber += 1; - } - - return; - } - - if (prev[key] - next[key] > 0) { - sortNumber += 1; - } else { - sortNumber += -1; - } - }); - return sortNumber; - }); - } - - if (params.filter) { - const filter = JSON.parse(params.filter); - - if (Object.keys(filter).length > 0) { - dataSource = dataSource.filter((item) => { - return Object.keys(filter).some((key) => { - if (!filter[key]) { - return true; - } - - if (filter[key].includes(`${item[key]}`)) { - return true; - } - - return false; - }); - }); - } - } - - if (params.hostname) { - dataSource = dataSource.filter((data) => - data.hostname.includes(params.hostname || "") - ); - } - - if (params.similar == 1) { - dataSource = dataSource.filter((data) => - data.ip.includes(params.vmcore_id || "") - ); - } - - let finalPageSize = 10; - - if (params.pageSize) { - finalPageSize = parseInt(`${params.pageSize}`, 10); - } - const length = dataSource.length; - dataSource = [...dataSource].slice( - (current - 1) * pageSize, - current * pageSize - ); - - const result = { - data: dataSource, - total: length, - success: true, - pageSize: finalPageSize, - current: parseInt(`${params.currentPage}`, 10) || 1, - }; - return res.json(result); -} - -async function getMarket(req, res, u) { - let realUrl = u; - - if ( - !realUrl || - Object.prototype.toString.call(realUrl) !== "[object String]" - ) { - realUrl = req.url; - } - - const dataSource = { - "filecacheTop": [ - { - "cached": 69004, - "task": [ - "syslog-ng_68406 " - ], - "file": "/var/log/messages" - }, - { - "cached": 67816, - "task": [ - "syslog-ng_68406 " - ], - "file": "/var/log/journal/da4b86843a464cc18ac897729463ef74/system@9a57abf447d44e578c8ee95d84eddbee-0000000005425f10-0005d9a9bb01fe00.journal" - }, - { - "cached": 67616, - "task": [ - "syslog-ng_68406 " - ], - "file": "/var/log/journal/da4b86843a464cc18ac897729463ef74/system@9a57abf447d44e578c8ee95d84eddbee-00000000053f2bd4-0005d99aee9fb330.journal" - }, - { - "cached": 67592, - "task": [ - "syslog-ng_68406 " - ], - "file": "/var/log/journal/da4b86843a464cc18ac897729463ef74/system@9a57abf447d44e578c8ee95d84eddbee-0000000005414e2c-0005d9a4cb789d8a.journal" - }, - { - "cached": 67576, - "task": [ - "syslog-ng_68406 " - ], - "file": "/var/log/journal/da4b86843a464cc18ac897729463ef74/system@9a57abf447d44e578c8ee95d84eddbee-0000000005403d47-0005d99fdc2a1ed8.journal" - }, - { - "cached": 11722112, - "task": [], - "file": "total cached of close file" - } - ], - "kernel": { - "SReclaimable": 927448, - "VmallocUsed": 40952, - "allocPage": 1024, - "KernelStack": 6516, - "PageTables": 11512, - "SUnreclaim": 53432 - }, - "taskMemTop": [ - { - "RssShmem": 0, - "pid": "116787", - "total_mem": 410236, - "RssFile": 21312, - "comm": "crash", - "RssAnon": 388924 - }, - { - "RssShmem": 0, - "pid": "119220", - "total_mem": 123112, - "RssFile": 6964, - "comm": "java", - "RssAnon": 116148 - }, - { - "RssShmem": 0, - "pid": "25669", - "total_mem": 103500, - "RssFile": 16740, - "comm": "java", - "RssAnon": 86760 - }, - { - "RssShmem": 0, - "pid": "10417", - "total_mem": 93312, - "RssFile": 56400, - "comm": "ilogtail", - "RssAnon": 36912 - }, - { - "RssShmem": 0, - "pid": "41785", - "total_mem": 79580, - "RssFile": 4940, - "comm": "java", - "RssAnon": 74640 - }, - { - "RssShmem": 4, - "pid": "68409", - "total_mem": 69768, - "RssFile": 67268, - "comm": "systemd-journal", - "RssAnon": 2496 - }, - { - "RssShmem": 0, - "pid": "10570", - "total_mem": 61696, - "RssFile": 40632, - "comm": "telegraf", - "RssAnon": 21064 - }, - { - "RssShmem": 0, - "pid": "94955", - "total_mem": 42468, - "RssFile": 8176, - "comm": "AliYunDun", - "RssAnon": 34292 - }, - { - "RssShmem": 0, - "pid": "68406", - "total_mem": 41176, - "RssFile": 39424, - "comm": "syslog-ng", - "RssAnon": 1752 - }, - { - "RssShmem": 0, - "pid": "111008", - "total_mem": 30868, - "RssFile": 16768, - "comm": "argusagent", - "RssAnon": 14100 - } - ], - "user": { - "cache": 13944196, - "anon": 837196, - "mlock": 0, - "huge1G": 0, - "huge2M": 0, - "buffers": 322444, - "shmem": 860 - }, - "memgraph": { - "available": 14833036, - "cache": 13945056, - "used": 933268, - "free": 279884 - }, - "memleak": { - "usage": 0, - "leak": "No", - "type": "No" - }, - "event": { - "util": 8, - "memcg": false, - "memfrag": false, - "leak": false - } - }; - - const result = { - data: dataSource, - success: true, - }; - return res.json(result); -} - -async function postMarketTask(req, res, u) { - let realUrl = u; - - if ( - !realUrl || - Object.prototype.toString.call(realUrl) !== "[object String]" - ) { - realUrl = req.url; - } - - const dataSource = { - "status": "success", - "data": [] - }; - - const result = { - data: dataSource, - success: true, - }; - return res.json(result); -} - export default { "GET /api/getable/": getIoTable, "GET /api/metric/": getMetric, "GET /api/curve/": getCurve, "POST /api/iotask/": postIOTask, - "GET /api/marketable/": getMarketTable, - "GET /api/market/": getMarket, - "POST /api/marketask/": postMarketTask, }; diff --git a/sysom_web/src/pages/diagnose/components/MetricShow.js b/sysom_web/src/pages/diagnose/components/MetricShow.js index c3b88717..f4d16e91 100644 --- a/sysom_web/src/pages/diagnose/components/MetricShow.js +++ b/sysom_web/src/pages/diagnose/components/MetricShow.js @@ -3,6 +3,7 @@ import ProCard from '@ant-design/pro-card'; import { Line } from '@ant-design/charts'; const MetricShow = (props) => { + console.log(props); const config = { data: props.data, padding: 'auto', @@ -12,6 +13,7 @@ const MetricShow = (props) => { xAxis: { tickCount: 5, }, + // props.slider === "false" ? slider:false : slider: { start: 0,end: 1}, slider: { start: 0.1, end: 0.5, diff --git a/sysom_web/src/pages/diagnose/components/PieCharts.js b/sysom_web/src/pages/diagnose/components/PieCharts.js deleted file mode 100644 index 80192f58..00000000 --- a/sysom_web/src/pages/diagnose/components/PieCharts.js +++ /dev/null @@ -1,32 +0,0 @@ -import ProCard from '@ant-design/pro-card'; -import { Pie } from '@ant-design/plots'; - -const PieCharts = (props) => { - const config = { - appendPadding: 10, - data: props.data, - angleField: 'value', - colorField: 'type', - radius: 0.8, - label: { - type: 'outer', - content: '{name} {percentage}' - }, - interactions: [ - { - type: 'pie-legend-active', - }, - { - type: 'element-active', - }, - ], - }; - return ( - <> - - - - - ); -} -export default PieCharts \ No newline at end of file diff --git a/sysom_web/src/pages/diagnose/oscheck/osCheckList.jsx b/sysom_web/src/pages/diagnose/oscheck/osCheckList.jsx index 995efdd5..64ad396a 100644 --- a/sysom_web/src/pages/diagnose/oscheck/osCheckList.jsx +++ b/sysom_web/src/pages/diagnose/oscheck/osCheckList.jsx @@ -52,7 +52,7 @@ const DiagnoTableList = React.forwardRef((props, ref) => { title: '状态', dataIndex: 'status', valueEnum: { - Running: { text: '运行中', status: 'Processing' }, + Ready: { text: '运行中', status: 'Processing' }, Success: { text: '诊断完毕', status: 'Success' }, Fail: { text: '异常', status: 'Error' }, }, diff --git a/sysom_web/src/pages/diagnose/oscheck/osCheckTaskForm.jsx b/sysom_web/src/pages/diagnose/oscheck/osCheckTaskForm.jsx index 699d2337..bb0dc0ac 100644 --- a/sysom_web/src/pages/diagnose/oscheck/osCheckTaskForm.jsx +++ b/sysom_web/src/pages/diagnose/oscheck/osCheckTaskForm.jsx @@ -8,6 +8,7 @@ export default (props) => { const { loading, error, run } = useRequest(postTask, { manual: true, onSuccess: (result, params) => { + console.log(result); props?.onSuccess?.(result, params); }, }); diff --git a/sysom_web/src/pages/diagnose/service.js b/sysom_web/src/pages/diagnose/service.js index aa992297..985c9292 100644 --- a/sysom_web/src/pages/diagnose/service.js +++ b/sysom_web/src/pages/diagnose/service.js @@ -103,26 +103,3 @@ export async function postIOTask(params, options) { }); } -/** 获取内存诊断大盘列表 GET /api/market */ -export async function getMarketTable(params, options) { - const msg = await request('/api/marketable/', { - method: 'GET', - params: { ...params }, - ...(options || {}), - }); - return { - data: msg.data, - success: true, - total: msg.total, - }; -} -/** 内存诊断大盘 诊断 POST /api/marketask */ -export async function postMarketTask(params, options) { - return request('/api/marketask/', { - method: 'POST', - data: params, - ...(options || {}), - }); -} - - diff --git a/sysom_web/src/pages/journal/service.js b/sysom_web/src/pages/journal/service.js index ac1a9cc4..db9f703e 100644 --- a/sysom_web/src/pages/journal/service.js +++ b/sysom_web/src/pages/journal/service.js @@ -7,7 +7,7 @@ import { export async function getAudit(params, options) { const token = localStorage.getItem('token'); - const msg = await request('/api/v1/journal/', { + return request('/api/v1/journal/', { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -16,6 +16,4 @@ export async function getAudit(params, options) { params: params, ...(options || {}), }); - msg.data.reverse() - return msg } \ No newline at end of file diff --git a/sysom_web/src/pages/security/Historical/hist.less b/sysom_web/src/pages/security/Historical/hist.less index 02fa0170..b8b3168e 100644 --- a/sysom_web/src/pages/security/Historical/hist.less +++ b/sysom_web/src/pages/security/Historical/hist.less @@ -1,7 +1,7 @@ .blue{ width: 18px; height: 18px; -background: #49AA19; +background:green; border-radius: 50%; text-align: center; margin-left: 55px; diff --git a/sysom_web/src/pages/security/Historical/index.jsx b/sysom_web/src/pages/security/Historical/index.jsx index cc38c94d..67111e69 100644 --- a/sysom_web/src/pages/security/Historical/index.jsx +++ b/sysom_web/src/pages/security/Historical/index.jsx @@ -1,19 +1,15 @@ import React ,{useState,useEffect}from 'react'; import {Button,Card,Table,Col,Row} from 'antd' import './hist.less' -import {histApi} from '../products' - - - - +import {histApi} from '../service' +import { PageContainer } from '@ant-design/pro-layout'; + function index(props) { const [dataSource,setdataSource]=useState([]) const [total,setTotal]=useState(0) - useEffect(() => { - histApi().then((res) => { - console.log(res.data); - setdataSource(res.data) - }); + useEffect(async() => { + const msg=await histApi() + setdataSource(msg.data) }, []); const columns=[ @@ -31,13 +27,13 @@ function index(props) { align: "center", }, { - title:"恢复时间", + title:"修复时间", dataIndex:"fixed_time", key:"fixed_time", align: "center", }, { - title:"恢复者", + title:"修复者", dataIndex:"fix_user", key:"fix_user", align: "center", @@ -60,7 +56,7 @@ function index(props) { } }, },{ - title:"CVE恢复状态", + title:"CVE修复状态", dataIndex:"status", key:"status", align: "center", @@ -92,18 +88,18 @@ function index(props) { showSizeChanger: true, showQuickJumper: true, total: total, // 数据总数 - pageSizeOptions: [4,6,8] , - defaultPageSize:6, + pageSizeOptions: [10,20,50,100] , + defaultPageSize:20, // current: pageNum, // 当前页码 showTotal: ((total,ranage) => `共 ${total} 条`), - position:["bottomLeft"], + position:["bottomRight"], // size:"small" }; return (
+ -
- +
@@ -111,6 +107,7 @@ function index(props) { props.history.push("/security/list") }}>返回 +
); } diff --git a/sysom_web/src/pages/security/Historicalist/historicalist.less b/sysom_web/src/pages/security/Historicalist/historicalist.less index 00ae7094..06c6ee97 100644 --- a/sysom_web/src/pages/security/Historicalist/historicalist.less +++ b/sysom_web/src/pages/security/Historicalist/historicalist.less @@ -1,7 +1,7 @@ .blue{ width: 20px; height: 20px; -background: blue; +background: green; border-radius: 50%; margin-left: 55px; @@ -25,3 +25,8 @@ margin-left: 55px; .ant-table-pagination.ant-pagination{ margin-top: 30px; } +.err_Button{ + margin-left: 92%; + margin-top: 20px; + + } \ No newline at end of file diff --git a/sysom_web/src/pages/security/Historicalist/index.jsx b/sysom_web/src/pages/security/Historicalist/index.jsx index c8937274..c43079de 100644 --- a/sysom_web/src/pages/security/Historicalist/index.jsx +++ b/sysom_web/src/pages/security/Historicalist/index.jsx @@ -1,28 +1,39 @@ import React,{useEffect,useState} from 'react'; -import {Button,Card,Table} from 'antd' +import {Button,Card,Table,Row,Col} from 'antd' import './historicalist.less' -import {histidApi} from '../products' - +import { PageContainer } from '@ant-design/pro-layout'; +import {histidApi,summaryApi} from '../service' + function index(props) { const [dataSource,setdataSource]=useState([]) const [total,setTotal]=useState(0) - useEffect(()=>{ - histidApi(props.match.params.id).then(res=>{ - console.log(res.data) - setdataSource(res.data) - - }) + useEffect( async()=>{ + const msg=await histidApi(props.match.params.id) + console.log(msg) + setdataSource(msg.data) + },[]) + const [affectcount,setaffectcount]=useState(0); + const [cvecount,setcvecount]=useState(0); + const [higtcount,sethigtcount]=useState(0) + + useEffect(async() => { + const msg=await summaryApi(); + console.log(msg) + setaffectcount(msg.affect) + setcvecount(msg.cvecount) + sethigtcount(msg.highcount) + }, []); const paginationProps = { showSizeChanger: true, showQuickJumper: true, total: total, // 数据总数 - pageSizeOptions: [10, 20, 50, 100], - defaultPageSize: 10, + pageSizeOptions: [10,20,50,100], + defaultPageSize:20, // current: pageNum, // 当前页码 showTotal: ((total,ranage) => `共 ${total} 条`), - position:["bottomLeft"], + position:["bottomRight"], // size:"small" }; const columns=[ @@ -65,13 +76,13 @@ function index(props) { align: "center", render:(txt,record)=>{ if(record.host_status==="running"){ - return
on
+ return
运行中
}else{ return
off
} } },{ - title:"CVE恢复状态", + title:"CVE修复状态", dataIndex:"status", key:"status", align: "center", @@ -92,7 +103,7 @@ function index(props) { onFilter: (value, record) => record.status.includes(value), }, { - title:"操作", + title:"CVE修复详情", align: "center", render:(txt,record,index)=>{ return ( @@ -107,13 +118,21 @@ function index(props) { ] return (
- 200台主机存在被攻击风险,涉及CVE漏洞1000个,其中高危漏洞100个,请尽快修复。 + + {affectcount}台主机存在被攻击风险,涉及CVE漏洞{cvecount}个,其中高危漏洞{higtcount}个,请尽快修复。 - +
+ + + + + ); } diff --git a/sysom_web/src/pages/security/Homelist/index.jsx b/sysom_web/src/pages/security/Homelist/index.jsx index 7837917a..b1a3611a 100644 --- a/sysom_web/src/pages/security/Homelist/index.jsx +++ b/sysom_web/src/pages/security/Homelist/index.jsx @@ -1,8 +1,10 @@ import React ,{useState,useEffect}from 'react'; import { Card, Table, Button,Progress,Row, Col} from "antd"; import './homelist.less' -import {getOneById,manyApi} from '../products' +import { PageContainer } from '@ant-design/pro-layout'; +import {getOneById,manyApi} from '../service' +import Headcard from "../components/Headcard"; function index(props) { const [data,setdata]=useState([]) const [lovodata,setlovodata]=useState([]) @@ -11,16 +13,17 @@ function index(props) { const [selectedRows, setselectedRows] = useState([]); - useEffect(()=>{ - getOneById(props.match.params.id).then(res=>{ - setlovodata(res.data.hosts) - setdata(res.data.software) - }) + useEffect(async()=>{ + const msg=await getOneById(props.match.params.id); + setlovodata(msg.data.hosts) + setdata(msg.data.software) },[]) const[succesvisible,setsuccesvisible]=useState(false); const [errvisible,seterrvisible]=useState(false) - + const fn = () => { + props.history.push("/security/historical"); + }; const rowSelection = { selectedRowKeys, onChange: (selectedRowKeys, selectedRows) => { @@ -91,23 +94,22 @@ function index(props) { render:(txt,record,index)=>{ return (
-
@@ -116,50 +118,53 @@ function index(props) { } ] -const repair=()=>{ +const repair=async()=>{ const arry=[]; const leght =selectedRows.length; - const id=props.match.params.id -for(let i = 0; i < leght; i++){ - arry.push({"cve_id":id, "hostname":selectedRows[i].hostname }) -} + + if(leght>0){ + + const id=props.match.params.id + for(let i = 0; i < leght; i++){ + arry.push({"cve_id":id, "hostname":selectedRows[i].hostname }) + } + const msg=await manyApi({cve_id_list:arry}); + if(msg.message=="fix cve failed"){ + seterrvisible(true) + }else{ + setsuccesvisible(true) + setTimeout(() => { + props.history.push("/security/list") + }, 1000); + } + }else{ + setsuccesvisible(false) + } + - manyApi({cve_id_list:arry}).then((res)=>{ - console.log(res) - if(res.message=="fix cve failed"){ - seterrvisible(true) - }else{ - setsuccesvisible(true) - setTimeout(() => { - props.history.push("/security/list") - - }, 1000); - } - }) } const paginationProps = { showSizeChanger: true, showQuickJumper: true, total: total, // 数据总数 - pageSizeOptions: [4,6,8] , - defaultPageSize:6, + pageSizeOptions: [10,20,50,100] , + defaultPageSize:20, // current: pageNum, // 当前页码 showTotal: ((total,ranage) => `共 ${total} 条`), - position:["bottomLeft"], + position:["bottomRight"], // size:"small" }; return (
- 200台主机存在被攻击风险,涉及CVE漏洞1000个,其中高危漏洞100个,请尽快修复。 - - + + -
+
-
+
{succesvisible?(< Progress width={150} percent={90} size="small" />):null} @@ -169,9 +174,8 @@ for(let i = 0; i < leght; i++){ - - -
+ +
); } diff --git a/sysom_web/src/pages/security/List/index.jsx b/sysom_web/src/pages/security/List/index.jsx index aba3f677..78f1bf1d 100644 --- a/sysom_web/src/pages/security/List/index.jsx +++ b/sysom_web/src/pages/security/List/index.jsx @@ -1,71 +1,68 @@ -import React, { useState, useEffect ,useRef} from "react"; -import { Card, Table, Button, Progress ,Modal,Tooltip} from "antd"; +import React, { useState, useEffect, useRef } from "react"; +import { Card, Table, Button, Progress, Modal, Tooltip, message } from "antd"; import "./list.less"; +import { listApi, manyApi, summaryApi } from "../service"; +import { PageContainer } from "@ant-design/pro-layout"; +import Headcard from "../components/Headcard"; -import { listApi ,manyApi} from "../products"; - +function List(props) { + // console.log(props) + const [data, setdata] = useState([]); + useEffect(async () => { + const msg = await listApi(); -function List(props) { - const [data,setdata]=useState([]) - - useEffect(() => { - listApi().then((res) => { - // console.log(res.data); - setdata(res.data) - }); + setdata(msg.data); }, []); - + + const fn = () => { + props.history.push("/security/historical"); + }; const [isModalVisible, setIsModalVisible] = useState(false); - const[succesvisible,setsuccesvisible]=useState(false); - const[errvisible,seterrvisible]=useState(false) - const [confirmLoading,setconfirmLoading]=useState(false) + const [succesvisible, setsuccesvisible] = useState(false); + const [errvisible, seterrvisible] = useState(false); + const [confirmLoading, setconfirmLoading] = useState(false); const showModal = () => { - const leght =selectedRows.length; - console.log('点击',leght) - if(leght>0){ - setIsModalVisible(true); - } - + const leght = selectedRows.length; + if (leght > 0) { + setIsModalVisible(true); + } }; - const handleOk = () => { - setconfirmLoading(true); - setTimeout(() => { + const handleOk = async () => { + setconfirmLoading(true); + setTimeout(() => { setIsModalVisible(false); setconfirmLoading(false); - }, 11000); - const arry=[]; - const leght =selectedRows.length; - for(let i = 0; i < leght; i++){ - arry.push({"cve_id":selectedRows[i].cve_id, "hostname":selectedRows[i].hosts }) + }, 11000); + const arry = []; + const leght = selectedRows.length; + for (let i = 0; i < leght; i++) { + arry.push({ + cve_id: selectedRows[i].cve_id, + hostname: selectedRows[i].hosts, + }); + } + const msg = await manyApi({ cve_id_list: arry }); + if (msg.message == "fix cve failed") { + seterrvisible(true); + } else { + setsuccesvisible(true); + setTimeout(() => { + props.history.push("/security"); + }, 1000); } - manyApi({cve_id_list:arry}).then((res)=>{ - console.log(res) - if(res.message=="fix cve failed"){ - seterrvisible(true) - - }else{ - setsuccesvisible(true) - setTimeout(() => { - - props.history.push("/security") - - }, 1000); - } - - }) -}; -const handleCancel = () => { - setIsModalVisible(false); + }; + const handleCancel = () => { + setIsModalVisible(false); }; - const columns = [ + const columns = [ { title: "序号", key: "index", width: 80, align: "center", - + render: (txt, record, index) => index + 1, }, { @@ -86,18 +83,17 @@ const handleCancel = () => { dataIndex: "vul_level", key: "vul_level", align: "center", - render:(txt,record)=>{ - - if(record.vul_level=="high"){ - return
高危
- }else if(record.vul_level=="medium"){ - return
中危
- }else if(record.vul_level=="critical"){ - return
严重
- }else{ - return
低危
+ render: (txt, record) => { + if (record.vul_level == "high") { + return
高危
; + } else if (record.vul_level == "medium") { + return
中危
; + } else if (record.vul_level == "critical") { + return
严重
; + } else { + return
低危
; } - }, + }, filters: [ { text: "严重", value: "critical" }, { text: "高危", value: "high" }, @@ -107,7 +103,7 @@ const handleCancel = () => { onFilter: (value, record) => record.vul_level.includes(value), }, { - width: '20%', + width: "20%", title: "涉及主机", align: "center", dataIndex: "hosts", @@ -116,15 +112,18 @@ const handleCancel = () => { return { style: { maxWidth: 260, - overflow: 'hidden', - whiteSpace: 'nowrap', - textOverflow: 'ellipsis', - cursor: 'pointer', - } - } + overflow: "hidden", + whiteSpace: "nowrap", + textOverflow: "ellipsis", + cursor: "pointer", + }, + }; }, - render: (text) => {text}, - + render: (text) => ( + + {text} + + ), }, { title: "操作", @@ -132,15 +131,23 @@ const handleCancel = () => { render: (txt, record, index) => { return (
- +
); }, }, ]; - const [selectedRowKeys, setselectedRowKeys] = useState([]); - const [selectedRows, setselectedRows] = useState([]); - const [total,setTotal]=useState(0) + const [selectedRowKeys, setselectedRowKeys] = useState(0); + const [selectedRows, setselectedRows] = useState(0); + const [total, setTotal] = useState(0); const rowSelection = { selectedRowKeys, onChange: (selectedRowKeys, selectedRows) => { @@ -152,36 +159,66 @@ const handleCancel = () => { showSizeChanger: true, showQuickJumper: true, total: total, // 数据总数 - pageSizeOptions: [5,20,50] , - defaultPageSize:5, + pageSizeOptions: [10, 20, 50, 100], + defaultPageSize: 20, // current: pageNum, // 当前页码 - showTotal: ((total,ranage) => `共 ${total} 条`), - position:["bottomLeft"], + showTotal: (total, ranage) => `共 ${total} 条`, + position: ["bottomRight"], // size:"small" }; return (
- - 200台主机存在被攻击风险,涉及CVE漏洞1000个,其中高危漏洞100个,请尽快修复。 - - - 修复 - } - > - - -

确定修复吗

-
- -

正在修复中...

+ + + + 修复 + + } + > +
+ +

确定修复吗

+
+ +

正在修复中...

-
- -

恢复出错了,

-
- + + +

+ 恢复出错了, + +

+
+ + ); } diff --git a/sysom_web/src/pages/security/Viewdetails/index.jsx b/sysom_web/src/pages/security/Viewdetails/index.jsx index d8373c45..d42032e4 100644 --- a/sysom_web/src/pages/security/Viewdetails/index.jsx +++ b/sysom_web/src/pages/security/Viewdetails/index.jsx @@ -1,55 +1,80 @@ -import React ,{useState,useEffect}from 'react'; -import { Card, Table, Button, Progress ,Modal, Row, Col} from "antd"; -import './Viewdetails.less' -import {viewApi} from '../products' +import React, { useState, useEffect } from "react"; +import { Card, Table, Button, Progress, Modal, Row, Col } from "antd"; +import "./Viewdetails.less"; +import { viewApi, summaryApi } from "../service"; +import { PageContainer } from "@ant-design/pro-layout"; function index(props) { - // console.log(props.match.params) - const [home,sethome]=useState("") - - - const [reason,setreason]=useState("") - const [Svisible,setSvisible]=useState(false) - const [errvisible,seterrvisible]=useState(false) - useEffect(()=>{ - viewApi(props.match.params.id,props.match.params.homename).then(res=>{ - console.log(res) - if(res.data.status=="fail"){ - seterrvisible(true) - sethome(res.data.hostname) - setreason(res.data.details) - }else{ - setSvisible(true) - sethome(res.data.hostname) - } - - }) - },[]) + const [home, sethome] = useState(""); + const [reason, setreason] = useState(""); + const [Svisible, setSvisible] = useState(false); + const [errvisible, seterrvisible] = useState(false); + useEffect(async () => { + const msg = await viewApi( + props.match.params.id, + props.match.params.homename + ); + + if (msg.data.status == "fail") { + seterrvisible(true); + sethome(msg.data.hostname); + setreason(msg.data.details); + } else { + setSvisible(true); + sethome(msg.data.hostname); + } + }, []); + const [affectcount, setaffectcount] = useState(0); + const [cvecount, setcvecount] = useState(0); + const [higtcount, sethigtcount] = useState(0); + useEffect(async () => { + const msg = await summaryApi(); + setaffectcount(msg.affect); + setcvecount(msg.cvecount); + sethigtcount(msg.highcount); + }, []); return (
- - 200台主机存在被攻击风险,涉及CVE漏洞1000个,其中高危漏洞100个,请尽快修复。 - - - - {Svisible?( -

主机名称{home}

-

CVE修复成功.

-
):null} - - - {errvisible?( -

主机名称{home}

- -

CVE修复失败,失败原因:{reason}

-
):null} - - -
- - - + + + {affectcount}台主机存在被攻击风险,涉及CVE漏洞{cvecount} + 个,其中高危漏洞{higtcount}个,请尽快修复。 + + + {Svisible ? ( + +

+ 主机名称 + {home} +

+

CVE修复成功.

+
+ ) : null} + {errvisible ? ( + +

+ 主机名称 + {home} +

+ +

CVE修复失败,失败原因:{reason}

+
+ ) : null} + + +
+ + {" "} + + + + ); } diff --git a/sysom_web/src/pages/security/auth.js b/sysom_web/src/pages/security/auth.js deleted file mode 100644 index 8df0e5a2..00000000 --- a/sysom_web/src/pages/security/auth.js +++ /dev/null @@ -1,3 +0,0 @@ -export function getToken() { - return localStorage.getItem("token"); - } \ No newline at end of file diff --git a/sysom_web/src/pages/security/axios.js b/sysom_web/src/pages/security/axios.js deleted file mode 100644 index f302c8e6..00000000 --- a/sysom_web/src/pages/security/axios.js +++ /dev/null @@ -1,51 +0,0 @@ -import axios from "axios"; -import { getToken } from "./auth"; - -const instance = axios.create({ - baseURL: "http://127.0.0.1:8001/", - // timeout: 5000 - }); - - - -// Add a request interceptor -// 全局请求拦截,发送请求之前执行 -instance.interceptors.request.use( - function(config) { - - config.headers["Authorization"] = getToken(); - return config; - }, - function(error) { - - return Promise.reject(error); - } -); - -// Add a response interceptor -// 请求返回之后执行 -instance.interceptors.response.use( - function(response) { - - return response.data; - }, - function(error) { - - return Promise.reject(error); - } -); - - - - -export function get(url){ - return instance.get(url) -} - - -export function post(url, data) { - return instance.post(url, data); -} - - - diff --git a/sysom_web/src/pages/security/components/Headcard.jsx b/sysom_web/src/pages/security/components/Headcard.jsx new file mode 100644 index 00000000..56784a7c --- /dev/null +++ b/sysom_web/src/pages/security/components/Headcard.jsx @@ -0,0 +1,32 @@ +import React,{useState,useEffect} from 'react'; +import { Card, Button} from "antd"; +import {summaryApi} from '../service' + + +function Headcard(param) { + const [affectcount,setaffectcount]=useState(0); + const [cvecount,setcvecount]=useState(0); + const [higtcount,sethigtcount]=useState(0) + + useEffect(async() => { + const msg=await summaryApi(); + setaffectcount(msg.affect) + setcvecount(msg.cvecount) + sethigtcount(msg.highcount) + + }, []); + + + + + return ( +
+ + {affectcount}台主机存在被攻击风险,涉及CVE漏洞{cvecount}个,其中高危漏洞{higtcount}个,请尽快修复。 + + +
+ ); +} + +export default Headcard; diff --git a/sysom_web/src/pages/security/products.js b/sysom_web/src/pages/security/products.js deleted file mode 100644 index 406846c4..00000000 --- a/sysom_web/src/pages/security/products.js +++ /dev/null @@ -1,32 +0,0 @@ -import {post,get} from '../security/axios' -// export function listApi(data){ -// return post("api/v1/list",data) -// } -export function xiufuApi(data){ - return post("api/v1/Progress",data) -} -export function listApi(){ - return get("api/v1/vul") -} - -export function histApi(){ - return get("api/v1/vul/hist/") -} - -export function getOneById(id) { - return get(`api/v1/vul/${id}`); - } - - -export function manyApi(data){ - return post("api/v1/vul/",data) -} - -export function histidApi(id){ - return get (`api/v1/vul/hist/${id}`) -} - -export function viewApi(id,name){ - return get (`api/v1/vul/hist/${id}/${name}`) -} - \ No newline at end of file diff --git a/sysom_web/src/pages/security/service.js b/sysom_web/src/pages/security/service.js new file mode 100644 index 00000000..92955dac --- /dev/null +++ b/sysom_web/src/pages/security/service.js @@ -0,0 +1,113 @@ +import { request} from 'umi'; + + +const token = localStorage.getItem('token'); + +// 漏洞中心 + export async function listApi(options) { + const msg= await request('/api/v1/vul', { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'Authorization': token, + }, + ...(options || {}), + + }); + return msg + } + + export async function summaryApi(options) { + const msg= await request('/api/v1/vul/summary', { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'Authorization': token, + }, + ...(options || {}), + + }); + return { + affect:msg.data.fixed_cve.affect_host_count, + cvecount:msg.data.fixed_cve.cve_count, + highcount:msg.data.fixed_cve.high_cve_count + } + } + + + + export async function histApi(options) { + const msg= await request('/api/v1/vul/hist/', { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'Authorization': token, + }, + ...(options || {}), + + }); + return msg + } + + export async function histidApi(id,options) { + const msg = await request('/api/v1/vul/hist/' + id, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'Authorization': token, + }, + ...(options || {}), + }); + + return msg; + }; + + + export async function getOneById(id,options) { + const msg = await request('/api/v1/vul/' + id, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'Authorization': token, + }, + ...(options || {}), + }); + + return msg; + }; + + + + export async function viewApi(id,name,options) { + const msg = await request('/api/v1/vul/hist/' + id +'/'+ name, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'Authorization': token, + }, + ...(options || {}), + }); + + return msg; + }; + + + export async function manyApi(body, options) { + const msg = await request('/api/v1/vul/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': token, + }, + data: body, + ...(options || {}), + }); + return msg; + } + + + + + + + diff --git a/sysom_web/src/pages/user/Login/agreem.jsx b/sysom_web/src/pages/user/Login/agreem.jsx index 4e325b1b..b3712e06 100644 --- a/sysom_web/src/pages/user/Login/agreem.jsx +++ b/sysom_web/src/pages/user/Login/agreem.jsx @@ -1,5 +1,6 @@ import React,{useState} from 'react'; import {Button,Modal,Card} from 'antd' +import './index.less'; function agreem() { const [isModalVisible, setIsModalVisible] = useState(false); @@ -21,9 +22,10 @@ function agreem() { - + + - + diff --git a/sysom_web/src/pages/user/Login/index.jsx b/sysom_web/src/pages/user/Login/index.jsx index f86b51f9..2ac23809 100644 --- a/sysom_web/src/pages/user/Login/index.jsx +++ b/sysom_web/src/pages/user/Login/index.jsx @@ -50,6 +50,7 @@ const Login = () => { const token = msg.data.token localStorage.setItem('userId', userId); localStorage.setItem('token', token); + message.success(defaultLoginSuccessMessage); await fetchUserInfo(userId, token); @@ -63,6 +64,7 @@ const Login = () => { console.log(msg); // 如果失败去设置用户错误信息 setUserLoginState(msg); + console.log(msg) } catch (error) { const defaultLoginFailureMessage = intl.formatMessage({ id: 'pages.login.failure', diff --git a/sysom_web/src/pages/user/Login/index.less b/sysom_web/src/pages/user/Login/index.less index 84c5fddd..3fcd1a2f 100644 --- a/sysom_web/src/pages/user/Login/index.less +++ b/sysom_web/src/pages/user/Login/index.less @@ -48,3 +48,13 @@ color: @primary-color; } } + + +.Popup-crad{ + width: 100%; + height: 80vh; + overflow-y: auto; +} +.font{ + font-weight: 900; +} \ No newline at end of file diff --git a/sysom_web/yarn.lock b/sysom_web/yarn.lock index 4b4fee6e..e830f18b 100644 --- a/sysom_web/yarn.lock +++ b/sysom_web/yarn.lock @@ -4635,13 +4635,6 @@ aws4@^1.8.0: resolved "https://registry.npm.taobao.org/aws4/download/aws4-1.11.0.tgz?cache=0&sync_timestamp=1604101244098&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Faws4%2Fdownload%2Faws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" integrity sha1-1h9G2DslGSUOJ4Ta9bCUeai0HFk= -axios@^0.26.1: - version "0.26.1" - resolved "https://registry.npmmirror.com/axios/-/axios-0.26.1.tgz#1ede41c51fcf51bbbd6fd43669caaa4f0495aaa9" - integrity sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA== - dependencies: - follow-redirects "^1.14.8" - babel-core@7.0.0-bridge.0: version "7.0.0-bridge.0" resolved "https://registry.npm.taobao.org/babel-core/download/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece" @@ -7877,11 +7870,6 @@ fmin@^0.0.2: tape "^4.5.1" uglify-js "^2.6.2" -follow-redirects@^1.14.8: - version "1.14.9" - resolved "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7" - integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w== - for-each@^0.3.3, for-each@~0.3.3: version "0.3.3" resolved "https://registry.npm.taobao.org/for-each/download/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" -- Gitee