forked from Gitlink/forgeplus-react
feat: 更改增加定时请求任务
This commit is contained in:
parent
bfc51c04aa
commit
29592bc423
|
|
@ -1,23 +1,22 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import MonacoEditor from '../../components/monaco-editor/index'
|
||||
import Meditor from "../Newfile/m_editor";
|
||||
// import Meditor from "../Newfile/m_editor";
|
||||
import moment from "moment"
|
||||
import codesmell from '../Images/quality/codesmell.svg'
|
||||
import bug from '../Images/quality/bug.svg'
|
||||
import semibold from '../Images/quality/semibold.svg'
|
||||
import bugRed from '../Images/quality/bug-red.svg'
|
||||
import {Button} from "antd";
|
||||
import {Button, Spin} from "antd";
|
||||
import axios from "axios";
|
||||
import './index.scss'
|
||||
|
||||
function Quality(props){
|
||||
var timer = null;
|
||||
const { projectsId , owner } = props.match.params;
|
||||
const [sonarList,setSonarList] = useState({}) //问题列表分析
|
||||
const [statuts,setStatus] = useState(-1)
|
||||
const [statuts,setStatus] = useState(2)
|
||||
const [questionList,setQuestionList] = useState([]) //对应问题列表
|
||||
const [isDetail,setDetail] = useState(false) //对应问题列表
|
||||
const [codeDetailValue,setCodeDetailValue] = useState({}) //对应问题列表
|
||||
const [isDetail,setDetail] = useState(false) // 是否为查看对应问题
|
||||
const [codeDetailValue,setCodeDetailValue] = useState({}) //问题详情 单个数据
|
||||
const [indexValue,setIndexValue] = useState(null)
|
||||
const severityList = {
|
||||
'BLOCKER': "致命缺陷",
|
||||
|
|
@ -27,7 +26,9 @@ function Quality(props){
|
|||
"MAJOR":"一般缺陷",
|
||||
}
|
||||
useEffect(()=>{
|
||||
getTask()
|
||||
timer = setInterval(()=>{
|
||||
getTask()
|
||||
},3000)
|
||||
},[])
|
||||
|
||||
useEffect(()=>{
|
||||
|
|
@ -41,6 +42,12 @@ function Quality(props){
|
|||
divs.style.cssText='border:1px solid red; padding: 5px;border-radius: 10px;color: black;background: lemonchiffon;'
|
||||
}
|
||||
},[indexValue])
|
||||
useEffect(()=>{
|
||||
if(sonarList.complete_status > 0) {
|
||||
setStatus(0)
|
||||
clearInterval(timer)
|
||||
}
|
||||
},[sonarList.complete_status])
|
||||
const getTask = () => {
|
||||
axios.get(`/${owner}/${projectsId}/sonar_tasks.json`)
|
||||
.then(({data:{data,message,status}}) => {
|
||||
|
|
@ -62,6 +69,7 @@ function Quality(props){
|
|||
axios.post(`/${owner}/${projectsId}/sonar_tasks.json`)
|
||||
.then(({data:{data,message,status}}) => {
|
||||
if(status===0){
|
||||
setStatus(2)
|
||||
getTask()
|
||||
}
|
||||
}).catch(function (error) {
|
||||
|
|
@ -73,16 +81,17 @@ function Quality(props){
|
|||
axios.get(`/${owner}/${projectsId}/sonar_tasks/type_detail.json?task_id=${task_id}&type=ALL`)
|
||||
.then(({data:{data,message,status}})=>{
|
||||
document.body.scrollIntoView()
|
||||
setStatus(0)
|
||||
setQuestionList(data);
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
const handlecheck = () => {
|
||||
if(statuts === 2 ) return
|
||||
if(statuts === 2 || statuts === -1 ) return
|
||||
timer = setInterval(()=>{
|
||||
getTask()
|
||||
},3000)
|
||||
setStatus(2)
|
||||
getTaskData()
|
||||
}
|
||||
const getCodeDetailData = (item,index) => {
|
||||
axios.get(`/${owner}/${projectsId}/sonar_tasks/code_source.json?component=${item.component}&task_id=${sonarList.task_id}`)
|
||||
|
|
@ -128,7 +137,7 @@ function Quality(props){
|
|||
<div className={`wrap-header-btn ${statuts===-1?'blue':statuts===0?'green':'orange'}`} onClick={handlecheck}>{(statuts===-1)?"开始检测":(statuts===0)?"重新检测":"正在检测"}</div>
|
||||
</div>
|
||||
<div>
|
||||
{questionList.map((item,index)=>{
|
||||
{sonarList.complete_status >0 ?questionList.map((item,index)=>{
|
||||
return <div key={index} className='message-item' onClick={()=>handleCodeDetail(item,index)}>
|
||||
{item.component}
|
||||
<div className="message-item-content mb30 mt10" >
|
||||
|
|
@ -136,7 +145,7 @@ function Quality(props){
|
|||
<div className="message-item-content-serverity">缺陷类型:{severityList[item.severity]}<span className="ml15">line:{item.line}行</span></div>
|
||||
</div>
|
||||
</div>
|
||||
})}
|
||||
}):<div className="empty-status"><Spin size="large" /></div>}
|
||||
|
||||
</div>
|
||||
</div>:
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@
|
|||
}
|
||||
.blue{
|
||||
background: #165DFF;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 0 12px rgba(22,93,255,1);
|
||||
}
|
||||
|
||||
|
|
@ -98,4 +97,9 @@
|
|||
.span{
|
||||
margin-top: 20px;
|
||||
}
|
||||
}
|
||||
.empty-status{
|
||||
padding: 60px 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
Loading…
Reference in New Issue