diff --git a/src/forge/Main/list.scss b/src/forge/Main/list.scss index 918a01e4..95fe2b70 100644 --- a/src/forge/Main/list.scss +++ b/src/forge/Main/list.scss @@ -298,7 +298,7 @@ li{ text-align: center; padding:0px; - margin-right: 40px; + margin-right: 35px; display: flex; & > a{ position: relative; diff --git a/src/forge/Main/sub/DetailBanner.jsx b/src/forge/Main/sub/DetailBanner.jsx index 4999ba44..d86f0498 100644 --- a/src/forge/Main/sub/DetailBanner.jsx +++ b/src/forge/Main/sub/DetailBanner.jsx @@ -8,11 +8,13 @@ function DetailBanner({ history,list , owner , projectsId , isManager , url , pa useEffect(()=>{ if(list){ // 没有资源库banner但是通过连接进资源库页面时 - if(pathname && pathname==="source"){ - let a = list.filter(item=>item.menu_name === "resources"); - if(a && a.length === 0){ - history.push(`/${owner}/${projectsId}`); - } + let a = list.filter(item=>item.menu_name === "resources"); + if((pathname && pathname==="source") && (a && a.length === 0)){ + history.push(`/${owner}/${projectsId}`); + } + let b = list.filter(item=>item.menu_name === "server"); + if((pathname && pathname.indexOf("server") > 0) && (b && b.length === 0)){ + history.push(`/${owner}/${projectsId}`); } setMenuName(list); } diff --git a/src/forge/Server/List.jsx b/src/forge/Server/List.jsx index 37614a18..3e49e815 100644 --- a/src/forge/Server/List.jsx +++ b/src/forge/Server/List.jsx @@ -1,20 +1,44 @@ -import React from 'react'; -import { Link } from 'react-router-dom'; - +import React,{useState , useEffect} from 'react'; +import AgreementModal from './agreementModal'; function Main(props){ + const [ visible , setVisible ] = useState(false); const { owner , projectsId } = props.match.params; + const [ has_trace_user , setHas_trace_user ] = useState(false); + + const { current_user , resetUserInfo } = props; + + useEffect(()=>{ + if(current_user){ + setHas_trace_user(current_user.has_trace_user); + } + },[current_user]) + + function onOk(){ + setVisible(false); + resetUserInfo && resetUserInfo(); + props.history.push(`/${owner}/${projectsId}/server/1`); + } + + function openDetail(){ + if(!has_trace_user){ + setVisible(true); + }else{ + props.history.push(`/${owner}/${projectsId}/server/1`); + } + } return(
+ setVisible(false)} onOk={onOk}/> diff --git a/src/forge/Server/agreementModal.jsx b/src/forge/Server/agreementModal.jsx index ae5c070e..2e7a91b3 100644 --- a/src/forge/Server/agreementModal.jsx +++ b/src/forge/Server/agreementModal.jsx @@ -1,8 +1,9 @@ import React, { useState } from 'react'; import { Modal , Checkbox } from 'antd'; +import axios from 'axios'; -function AgreementModal({ visible , onCancel , onOk }){ +function AgreementModal({ visible , onCancel , onOk}){ const [ agree , setAgree ] = useState(false); function changeAgree(e){ setAgree(e.target.checked); @@ -12,11 +13,15 @@ function AgreementModal({ visible , onCancel , onOk }){ setAgree(false); onCancel(); } - // 同意协议 function agreeFunc(){ - agree && onOk(); - setAgree(false); + const url = `/traces/trace_users.json`; + axios.post(url).then(result=>{ + if(result){ + agree && onOk(); + setAgree(false); + } + }).catch(error=>{}) } return( { - if(current_user){ - setHas_trace_user(has_trace_user); - } - },[current_user]) - - function onOk(){ - setVisible(false); - setDetectionVisible(true); - } function onDetectionOk(){ props.showNotification("扫描成功!"); @@ -48,8 +35,7 @@ function Data(props){ }).then(result=>{ if(result){ setDataSource(result.data.data); - let count = result.data.data && result.data.data.length; - setRelayCount(relayCount-count); + setRelayCount(result.data.left_tasks_count); setSpining(false); } }).catch(error=>{}) @@ -60,84 +46,6 @@ function Data(props){ Init(); },[]) - const columns=[ - { - title:"序号", - dataIndex:"number", - key:"number", - width:"7%", - align:"center", - render: (k,e,e1) => {return e1+1} - }, - { - title:"分支名称", - dataIndex:"branch_tag", - key:"branch_tag", - width:"30%", - align:"left", - ellipsis:true - }, - { - title:"检测状态", - dataIndex:"detect_status", - key:"detect_status", - align:"left", - render: (k,e,e1) => { - return ( - k === "fail" ? - 失败 - : k==="detecting" ? -
- - {e.detect_process}% -
- : - 成功 - ) - } - }, - { - title:"检测时间", - dataIndex:"detect_startdate", - key:"detect_startdate", - align:"left", - }, - { - title:"操作", - dataIndex:"operation", - key:"operation", - align:"center", - width:"30%", - render: (k,e,e1) => { - return( -
- repeatCheck(e.project_id,e.branch_tag)}>重新扫描 - { - (e.detect_status ==="fail" || e.detect_status ==="detecting") ? - 查看 - : - 查看 - } - { - (e.detect_status ==="fail" || e.detect_status ==="detecting") ? - 下载报告 - : - downloadFunc(e.task_id)}>下载报告 - } -
- ) - } - } - ] - - // 下载报告 - function downloadFunc(task_id){ - setSpining(true); - const url = `/traces/${owner}/${projectsId}/task_pdf.json?task_id=${task_id}`; - axios.get(url).then(result=>{ - setSpining(false); - }).catch(error=>{}) - } // 重新扫描 function repeatCheck(project_id,branch){ @@ -150,7 +58,6 @@ function Data(props){ setDetectionVisible(true); } - // 新建分析:判断是否签订过协议,签订过就弹出检测弹框 function createCheck(){ if(relayCount <= 0){ message.error("无可用检测次数"); @@ -158,16 +65,21 @@ function Data(props){ } setRepeatBranch(undefined); setRepeatId(undefined); - if(has_trace_user){ - setVisible(true); - }else{ - setDetectionVisible(true); - } + setDetectionVisible(true); + } + + function handleDownExcel(task_id){ + const oa = document.createElement('a'); + oa.href = `/api/traces/${owner}/${projectsId}/task_pdf.json?task_id=${task_id}`; + oa.setAttribute('target', '_blank'); + oa.setAttribute("download","report.pdf"); + document.body.appendChild(oa); + oa.click(); + document.body.removeChild(oa); } return(
- setVisible(false)} onOk={onOk}/> setDetectionVisible(false)} @@ -180,18 +92,80 @@ function Data(props){ />
重晴鸟代码溯源系统 - 新建分析 + { isManager && 新建分析 }
{ dataSource && dataSource.length >0 &&
- +
    +
  • + 序号 + 分支名称 + 检测状态 + 检测时间 + 操作 +
  • + { + dataSource.map((e,key)=>{ + return( +
    +
  • + {key + 1 } + {e.branch_tag} + + { + e.detect_status === "fail" ? + 失败 + : e.detect_status==="detecting" ? +
    + + {e.detect_process}% +
    + : + 成功 + } +
    + {e.detect_startdate} + + { +
    + { isManager && ( + e.detect_status ==="detecting" ? + 重新扫描 + : + repeatCheck(e.project_id,e.branch_tag)}>重新扫描 + ) + } + { + (e.detect_status ==="fail" || e.detect_status ==="detecting") ? + 查看 + : + 查看 + } + { + isManager && ( + (e.detect_status ==="fail" || e.detect_status ==="detecting") ? + 下载报告 + : + handleDownExcel(e.task_id)}>下载报告 + ) + } +
    + } +
    +
  • + {false && } +
    + ) + }) + } +
} { - dataSource === null || (dataSource && dataSource.length === 0) && + (dataSource === null || (dataSource && dataSource.length === 0)) && } diff --git a/src/forge/Server/detectionModal.jsx b/src/forge/Server/detectionModal.jsx index 34440088..5e9acef2 100644 --- a/src/forge/Server/detectionModal.jsx +++ b/src/forge/Server/detectionModal.jsx @@ -7,7 +7,7 @@ function DetectionModal({form , visible , onCancel , onOk , projectsId, owner , const [ check , setCheck ] = useState(false); const [ branch , setBranch ] = useState(""); const [ branchList , setBranchList ] = useState([]); - + const source = axios.CancelToken.source(); const layout = { labelCol: { span: 5 }, wrapperCol: { span: 18 }, @@ -26,13 +26,13 @@ function DetectionModal({form , visible , onCancel , onOk , projectsId, owner , // 取消检测 function onCancelFunc(){ + source.cancel(); if(check) { setCheck(false); } else{ onCancel(); } } - // 开始检测 function onOkFunc(){ validateFields((error,values)=>{ @@ -47,6 +47,8 @@ function DetectionModal({form , visible , onCancel , onOk , projectsId, owner , project_id:repeatId, branch_name:repeatBranch } + },{ + CancelToken:source.token }).then(result=>{ if(result){ onOk(); @@ -58,6 +60,8 @@ function DetectionModal({form , visible , onCancel , onOk , projectsId, owner , const url = `/traces/${owner}/${projectsId}/tasks.json`; axios.post(url,{ branch_name:values.branch + },{ + CancelToken:source.token }).then(result=>{ if(result){ onOk(); @@ -125,10 +129,10 @@ function DetectionModal({form , visible , onCancel , onOk , projectsId, owner , }
{ - (check && branch) || repeatBranch && + ((check && branch) || repeatBranch) &&
检测分支 -

{branch || repeatBranch}

+

{branch || repeatBranch}

}
diff --git a/src/forge/Server/index.scss b/src/forge/Server/index.scss index b19ec7b0..62aa00cc 100644 --- a/src/forge/Server/index.scss +++ b/src/forge/Server/index.scss @@ -6,7 +6,7 @@ background-color: #466aff; color: #fff!important; &:hover{ - background-color: rgba(26, 71, 255, 1); + background-color: rgba(26, 71, 255, 1)!important; color: #fff!important; } } @@ -191,7 +191,7 @@ } } } -.dataTable{ +.dataTable,.dataUl{ .ant-table-thead > tr > th{ background-color: #fff; div{ @@ -199,6 +199,10 @@ font-size: 16px; } } + .ant-table-tbody > tr:hover > td{ + background-color: rgba(248, 250, 255, 1)!important; + } + .failure{ display: block; height:32px; @@ -279,6 +283,48 @@ } } } +.dataUl{ + &>div{ + border-bottom: 1px solid #eee; + } + li{ + display: flex; + flex-wrap: wrap; + height: 66px; + align-items: center; + color:#333333; + &>span{ + padding:0px 10px; + text-align: left; + } + &>span:first-child{ + width: 7%; + text-align: center; + } + &>span:nth-child(2){ + width: 30%; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + &>span:nth-child(3),&>span:nth-child(4){ + width: 16%; + } + &>span:last-child{ + width: 30%; + text-align: center; + } + &.dataUlhead{ + font-size:16px; + } + &.dataUlbody{ + font-size: 14px; + &:hover{ + background-color:#f8faff + } + } + } +} .formDiv{ width: 430px; margin:0px auto; @@ -292,6 +338,10 @@ height: 32px; line-height: 32px; margin-top: 4px; + label{ + color:#20294a; + font-size:15px; + } } .ant-row.ant-form-item{ margin-bottom: 12px!important; @@ -307,6 +357,8 @@ width: 70px; line-height: 32px; text-align: left; + color:#20294a; + font-size:15px; } ul{ display: flex; diff --git a/src/forge/users/Infos.js b/src/forge/users/Infos.js index 722e24d0..db063c9e 100644 --- a/src/forge/users/Infos.js +++ b/src/forge/users/Infos.js @@ -102,7 +102,7 @@ class Infos extends Component { }else if(pathname === `/${username}/followers`){ this.setState({menuKey:undefined,route_type:"followers"}); }else{ - this.setState({menuKey:undefined,route_type:undefined}); + this.setState({menuKey:"6",route_type:undefined}); } } @@ -244,7 +244,6 @@ class Infos extends Component { const { current_user } = this.props; const { username } = this.props.match.params; const { user, isSpin, route_type , undo_events , menuKey , avatarVisible } = this.state; - return (
{