Merge pull request '修改代码溯源' (#425) from tongChong/forgeplus-react:gitlink_server into gitlink_server

This commit is contained in:
tongChong 2022-07-29 18:24:10 +08:00
commit 8eb2eb2157
4 changed files with 154 additions and 77 deletions

37
package-lock.json generated
View File

@ -7209,7 +7209,8 @@
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
"optional": true
},
"aproba": {
"version": "1.2.0",
@ -7230,12 +7231,14 @@
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -7256,12 +7259,14 @@
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4="
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -7378,7 +7383,8 @@
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"optional": true
},
"ini": {
"version": "1.3.5",
@ -7405,6 +7411,7 @@
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -7412,12 +7419,14 @@
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"optional": true
},
"minipass": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz",
"integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==",
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -7436,6 +7445,7 @@
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.3.tgz",
"integrity": "sha512-P+2gwrFqx8lhew375MQHHeTlY8AuOJSrGf0R5ddkEndUkmwpgUob/vQuBD1V22/Cw1/lJr4x+EjllSezBThzBg==",
"optional": true,
"requires": {
"minimist": "^1.2.5"
}
@ -7497,7 +7507,8 @@
"npm-normalize-package-bin": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz",
"integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA=="
"integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==",
"optional": true
},
"npm-packlist": {
"version": "1.4.8",
@ -7538,6 +7549,7 @@
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"optional": true,
"requires": {
"wrappy": "1"
}
@ -7615,7 +7627,8 @@
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -7651,6 +7664,7 @@
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -7670,6 +7684,7 @@
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -7713,12 +7728,14 @@
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"optional": true
},
"yallist": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
"optional": true
}
}
},

View File

@ -1,55 +1,91 @@
import React, { useEffect, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import DataEmpty from './dataEmpty';
import DetectionModal from './detectionModal';
import { Table , Spin, message } from 'antd';
import { Table, Spin, message } from 'antd';
import axios from 'axios';
function Data(props){
const [ detectionVisible , setDetectionVisible ] = useState(false);
const [ dataSource , setDataSource ] = useState(undefined);
const [ page , setPage ] = useState(1);
const [ spining , setSpining ] = useState(true);
const [ relayCount , setRelayCount ] = useState(5);
const [ repeatId , setRepeatId ] = useState(undefined);
const [ repeatBranch , setRepeatBranch ] = useState(undefined);
function Data(props) {
const [detectionVisible, setDetectionVisible] = useState(false);
const [dataSource, setDataSource] = useState(undefined);
const [page, setPage] = useState(1);
const [spining, setSpining] = useState(true);
const [relayCount, setRelayCount] = useState(5);
const [repeatId, setRepeatId] = useState(undefined);
const [repeatBranch, setRepeatBranch] = useState(undefined);
const [lookResultUrl, setLookResultUrl] = useState(undefined);
const [openResultTaskId, setOpenResultTaskId] = useState(undefined);
const [viewBase, setViewBase] = useState('https://cjntest.trustie.net/');
const { owner , projectsId } = props.match.params;
const { current_user , isManager } = props;
const { owner, projectsId } = props.match.params;
const { current_user, isManager } = props;
const limit = 15;
function onDetectionOk(){
function onDetectionOk() {
props.showNotification("新建分析成功,可在“检测状态”处查看扫描检测进度");
setDetectionVisible(false);
setSpining(true);
Init();
}
function Init(){
function Init() {
const url = `/traces/${owner}/${projectsId}/task_results.json`;
axios.get(url,{
params:{
page,limit
axios.get(url, {
params: {
page, limit
}
}).then(result=>{
if(result){
setDataSource(result.data.data);
setRelayCount(result.data.left_tasks_count);
}).then(result => {
if (result) {
if (Array.isArray(result.data.data)) {
setDataSource(result.data.data);
setRelayCount(result.data.left_tasks_count);
setLookResultUrl(result.data.view_base);
setViewBase(result.data.view_base);
for (const item of result.data.data) {
if (item.detect_status === "detecting" || item.detect_status === "waiting") {
setTimeout(Init, 2000);
break;
}
}
} else {
result && result.data.message && props.showNotification(result.data.message);
}
setSpining(false);
}
}).catch(error=>{})
}).catch(error => { })
}
useEffect(()=>{
useEffect(() => {
setSpining(true);
Init();
},[])
}, [])
useEffect(() => {
window.addEventListener("message", iframeHeight, false);
return () => {
window.removeEventListener("message", iframeHeight, false);
}
})
function iframeHeight(e){
console.log('iframeHeight');
console.log(e.data);
if (e && e.data && viewBase && e.origin && viewBase.indexOf(e.origin)>-1) {
let myHeight = JSON.parse(e.data);
if (document.querySelector("#htmlIframe")) {
document.querySelector("#htmlIframe").height = myHeight.height;
}
}
}
//
function repeatCheck(project_id,branch){
if(relayCount <= 0){
function repeatCheck(project_id, branch) {
if (relayCount <= 0) {
message.error("无可用检测次数");
return;
}
@ -58,8 +94,8 @@ function Data(props){
setDetectionVisible(true);
}
function createCheck(){
if(relayCount <= 0){
function createCheck() {
if (relayCount <= 0) {
message.error("无可用检测次数");
return;
}
@ -68,7 +104,7 @@ function Data(props){
setDetectionVisible(true);
}
function handleDownExcel(task_id){
function handleDownExcel(task_id) {
setSpining(true);
const url = `/api/traces/${owner}/${projectsId}/task_pdf.json?task_id=${task_id}`;
// window.open(`/api/traces/${owner}/${projectsId}/task_pdf.json?task_id=${task_id}`);
@ -85,15 +121,35 @@ function Data(props){
setSpining(false);
}
x.send();
console.log("spining");
}
return(
function lookResult(taskId) {
if (!openResultTaskId || (openResultTaskId && openResultTaskId !== taskId)) {
setOpenResultTaskId(taskId);
} else {
setOpenResultTaskId(undefined);
}
}
function iframeLoad() {
try {
let myIframe = document.getElementById("htmlIframe");
console.log('myIframe', myIframe, myIframe.contentDocument);
if (myIframe.contentDocument) {
console.log(myIframe.contentDocument.querySelector('.el-main'));
myIframe.height = myIframe.contentDocument.querySelector('.el-main').clientHeight + 260;
// myIframe.contentDocument.querySelector('.admin-body-container').style.overflow = 'hidden';
}
} catch (err) {
console.error(err);
}
}
return (
<div>
<DetectionModal
visible={detectionVisible}
onCancel={()=>setDetectionVisible(false)}
onOk={onDetectionOk}
<DetectionModal
visible={detectionVisible}
onCancel={() => setDetectionVisible(false)}
onOk={onDetectionOk}
owner={owner}
projectsId={projectsId}
relayCount={relayCount}
@ -102,12 +158,12 @@ function Data(props){
/>
<div className="servertitle">
<span className="systitle">重晴鸟代码溯源系统</span>
{ isManager && <a className="btnhover" onClick={createCheck}>新建分析</a> }
{isManager && <a className="btnhover" onClick={createCheck}>新建分析</a>}
</div>
<Spin spinning={spining}>
<div style={{minHeight:"400px"}}>
<div style={{ minHeight: "400px" }}>
{
dataSource && dataSource.length >0 &&
dataSource && dataSource.length > 0 &&
<div>
<ul className="dataUl">
<li className="dataUlhead">
@ -115,26 +171,29 @@ function Data(props){
<span>分支名称</span>
<span>检测状态</span>
<span>检测时间</span>
{ isManager && <span>操作</span> }
{isManager && <span>操作</span>}
</li>
{
dataSource.map((e,key)=>{
return(
dataSource.map((e, key) => {
return (
<div key={key}>
<li className="dataUlbody">
<span>{key + 1 }</span>
<span>{key + 1}</span>
<span title={e.branch_tag}>{e.branch_tag}</span>
<span>
{
e.detect_status === "fail" ?
<span className="failure">失败</span>
: e.detect_status==="detecting" ?
<div className="running">
<span className="percentline" style={{width:`${e.detect_process}%`}}></span>
<span className="percentNum" style={{left:`${e.detect_process+5}%`}}>{e.detect_process}%</span>
</div>
:
<span className="success">成功</span>
<span className="failure">失败</span>
: e.detect_status === "detecting" ?
<div className="running">
<span className="percentline" style={{ width: `${e.detect_process}%` }}></span>
<span className="percentNum" style={{ left: `${e.detect_process + 5}%` }}>{e.detect_process}%</span>
</div>
: e.detect_status === "detected" ?
<span className="success">成功</span> : <div className="running">
<span className="percentline" style={{ width: `0%` }}></span>
<span className="percentNum" style={{ left: `5%` }}>0%</span>
</div>
}
</span>
<span>{e.detect_startdate}</span>
@ -143,28 +202,29 @@ function Data(props){
<span>
<div className="operationBtns">
{
e.detect_status ==="detecting" ?
<span>重新扫描</span>
:
<a onClick={()=>repeatCheck(e.project_id,e.branch_tag)}>重新扫描</a>
e.detect_status === "detecting" || e.detect_status === "waiting" ?
<span>重新扫描</span>
:
<a onClick={() => repeatCheck(e.project_id, e.branch_tag)}>重新扫描</a>
}
{/* {
(e.detect_status ==="fail" || e.detect_status ==="detecting") ?
<span>查看<i className="iconfont icon-sanjiaoxing-down"></i></span>
:
<a>查看<i className="iconfont icon-sanjiaoxing-down"></i></a>
} */}
{
(e.detect_status ==="fail" || e.detect_status ==="detecting") ?
<span>下载报告</span>
:
<a onClick={()=>handleDownExcel(e.task_id)}>下载报告</a>
(e.detect_status === "fail" || e.detect_status === "detecting" || e.detect_status === "waiting") ?
<span>查看<i className="iconfont icon-sanjiaoxing-down"></i></span>
:
<a onClick={() => { lookResult(e.task_id) }}>查看<i className={`iconfont ${openResultTaskId === e.task_id ? 'icon-sanjiaoxing-up' : 'icon-sanjiaoxing-down'}`}></i></a>
}
{
(e.detect_status === "fail" || e.detect_status === "detecting" || e.detect_status === "waiting") ?
<span>下载报告</span>
:
<a onClick={() => handleDownExcel(e.task_id)}>下载报告</a>
}
</div>
</span>
}
</li>
{false && <iframe src="www.baidu.com" id={`htmlIframe_${key}`} frameBorder="0" name={`htmlIframe_${key}`} style={{ background: '#fff', height: '100%', width: '100%' }}></iframe>}
{/* lookResultUrl+e.task_id */}
{openResultTaskId && openResultTaskId === e.task_id && <iframe title={`htmlIframe_${key}`} src={lookResultUrl + e.task_id} id={`htmlIframe`} frameBorder="0" name={`htmlIframe_${key}`} width="100%" onLoad={iframeLoad} height={'auto'}></iframe>}
</div>
)
})

View File

@ -137,7 +137,7 @@ function DetectionModal({form , visible , onCancel , onOk , projectsId, owner ,
}
<div>
<span>检测类型</span>
<p>快速-组件</p>
<p>深度-文件代码</p>
</div>
<div>
<span>检测参数</span>

View File

@ -79,7 +79,7 @@ function Register(props){
}).then(response => {
if (response.data.status === -1) {
setGetCaptchaBut(false);
callback('该邮箱已被注册');
callback(response.data.message);
} else {
setEmailStr(value);
setGetCaptchaBut(true);