-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from piypil/#docker_zap_in_to
zap docker
- Loading branch information
Showing
19 changed files
with
1,067 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,111 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { Space, Table, Spin, Modal, Button } from 'antd'; | ||
import { ExclamationCircleOutlined } from '@ant-design/icons'; | ||
import { Space, Table, Spin, notification, Button } from 'antd'; | ||
import { ExclamationCircleOutlined, DownloadOutlined, DeleteOutlined } from '@ant-design/icons'; | ||
import type { ColumnsType } from 'antd/es/table'; | ||
import axios from 'axios'; | ||
import { Link } from 'react-router-dom'; | ||
import moment from 'moment'; | ||
import { useTheme } from '../components/ThemeContext'; | ||
|
||
const { confirm } = Modal; | ||
import { Link } from 'react-router-dom'; | ||
|
||
const API_BASE_URL = process.env.REACT_APP_API_URL; | ||
|
||
interface ProjectData { | ||
id: number; | ||
interface DASTData { | ||
uuid: string; | ||
project_name: string; | ||
url: string; | ||
scan_date: string; | ||
results: any; | ||
} | ||
|
||
export function TableViewDAST() { | ||
const [data, setData] = useState<ProjectData[]>([]); | ||
const [data, setData] = useState<DASTData[]>([]); | ||
const [loading, setLoading] = useState<boolean>(true); | ||
const { theme } = useTheme(); | ||
|
||
const deleteRecord = (id: number) => { | ||
// Надо добавить удаление записи | ||
console.log('Delete record with id:', id); | ||
} | ||
|
||
const showDeleteConfirm = (id: number) => { | ||
confirm({ | ||
title: 'Are you sure delete this record?', | ||
icon: <ExclamationCircleOutlined />, | ||
onOk() { | ||
deleteRecord(id); | ||
}, | ||
onCancel() { | ||
console.log('Cancel'); | ||
}, | ||
const handleError = (message: string) => { | ||
notification.error({ | ||
message: "Error", | ||
description: message | ||
}); | ||
} | ||
}; | ||
|
||
const columns: ColumnsType<ProjectData> = [ | ||
const columns: ColumnsType<DASTData> = [ | ||
{ | ||
title: 'Project', | ||
dataIndex: 'project_name', | ||
key: 'project_name', | ||
render: (project_name, record) => ( | ||
render: (name, record) => ( | ||
<Space size="middle"> | ||
<Link to={`/results-dast/${record.id}`}>{project_name}</Link> | ||
<Link to={`/results-dast/${record.uuid}`}>{name}</Link> | ||
</Space> | ||
), | ||
}, | ||
{ | ||
title: 'ID', | ||
dataIndex: 'id', | ||
key: 'id', | ||
dataIndex: 'uuid', | ||
key: 'uuid', | ||
}, | ||
{ | ||
title: 'URL', | ||
dataIndex: 'url', | ||
key: 'url', | ||
render: (url) => ( | ||
<a href={url} target="_blank" rel="noopener noreferrer">{url}</a> | ||
), | ||
}, | ||
{ | ||
title: 'Scan Date', | ||
dataIndex: 'scan_date', | ||
key: 'scan_date', | ||
render: (date) => moment(date).format('YYYY.MM.DD -> HH:mm'), | ||
}, | ||
{ | ||
title: 'Action', | ||
key: 'action', | ||
render: (_, record) => ( | ||
<Space size="middle"> | ||
<Button danger onClick={() => showDeleteConfirm(record.id)}> | ||
Delete | ||
<a target="_blank" rel="noopener noreferrer"> | ||
<DownloadOutlined /> Download | ||
</a> | ||
<Button> | ||
<DeleteOutlined /> Delete | ||
</Button> | ||
</Space> | ||
), | ||
}, | ||
}, | ||
]; | ||
|
||
useEffect(() => { | ||
axios | ||
.get(`${API_BASE_URL}/scanned-projects/`) | ||
.get(`${API_BASE_URL}/dast-projects/`) | ||
.then((response) => { | ||
setData(response.data); | ||
setLoading(false); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
handleError('Error fetching DAST data.'); | ||
console.error(error); | ||
setLoading(false); | ||
}); | ||
}, []); | ||
|
||
const tableClassName = theme === 'dark' ? 'dark-theme' : ''; | ||
|
||
if (loading) { | ||
return <Spin size="large" />; | ||
return ( | ||
<div style={{ textAlign: 'center', marginTop: '5rem' }}> | ||
<Spin size="large" /> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<Table | ||
className={tableClassName} | ||
columns={columns} | ||
dataSource={data} | ||
rowKey={(record) => record.id.toString()} | ||
/> | ||
); | ||
<div style={{ padding: '1rem' }}> | ||
<Table | ||
className={tableClassName} | ||
columns={columns} | ||
dataSource={data} | ||
rowKey={(record) => record.uuid} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default TableViewDAST; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,8 +87,8 @@ export function TableViewSAST() { | |
</Button> | ||
</Space> | ||
), | ||
}, | ||
]; | ||
}, | ||
]; | ||
|
||
useEffect(() => { | ||
axios | ||
|
Oops, something went wrong.