概览页数据绑定完成,只差数据统计页

This commit is contained in:
caishi 2021-05-31 09:48:30 +08:00
parent a9e3513706
commit eab68ac270
5 changed files with 131 additions and 89 deletions

View File

@ -9,16 +9,17 @@ function Calendar({ userLogin , time , chooseTime }) {
useEffect(()=>{ useEffect(()=>{
if(time){ if(time){
let e = `${time}-12-31`; let e,b = "";
let b = `${time}-01-01`; if(time === "0"){
setEndT(e); let y = moment().get('year');
setBaginT(b); let m = moment().get('month');
}else if(time === ""){ let d = moment().get('date');
let y = moment().get('year'); e = `${y}-${m+1}-${d}`;
let m = moment().get('month'); b = `${y-1}-${m+1}-${d}`;
let d = moment().get('date'); }else{
let e = `${y}-${m+1}-${d}`; e = `${time}-12-31`;
let b = `${y-1}-${m+1}-${d}`; b = `${time}-01-01`;
}
setEndT(e); setEndT(e);
setBaginT(b); setBaginT(b);
} }

View File

@ -2,21 +2,18 @@ import React ,{ useEffect } from 'react';
import * as echarts from 'echarts'; import * as echarts from 'echarts';
function Line({data}) { function Line({data}) {
useEffect(()=>{
Init();
},[])
useEffect(()=>{ useEffect(()=>{
if(data){ if(data){
Init(); Init(data);
} }
},[data]) },[data])
function Init() { function Init(d) {
var huan_val = document.getElementById("Line"); var huan_val = document.getElementById("Line");
var myEcharts = echarts.init(huan_val); var myEcharts = echarts.init(huan_val);
let option = { let option = {
color: ["#f8e367", "#99dfff", "#58c0f0", "#5ea6ff", "#ff9e48", "#bcbcbc"], color: ["#f8e367", "#58c0f0", "#ff9e48"],
title: { title: {
text: '近期活动统计', text: '近期活动统计',
left: '3%', left: '3%',
@ -26,7 +23,7 @@ function Line({data}) {
trigger: 'axis' trigger: 'axis'
}, },
legend: { legend: {
data: ['邮件营销', '联盟广告', '视频广告', '直接访问', '搜索引擎'], data: ['commits', 'issues', 'pull_requests'],
right: 'center', right: 'center',
bottom: '0', bottom: '0',
}, },
@ -37,58 +34,43 @@ function Line({data}) {
containLabel: true containLabel: true
}, },
toolbox: { toolbox: {
feature: { feature: {
// saveAsImage: {} // saveAsImage: {}
} }
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
boundaryGap: false, boundaryGap: false,
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'], data: d.dates,
axisTick:{ axisTick:{
show:false show:false
} }
}, },
yAxis: { yAxis: {
type: 'value', type: 'value',
axisLine:{ axisLine:{
show:false show:false
}, },
axisTick:{ axisTick:{
show:false show:false
} }
}, },
series: [ series: [
{ {
name: '邮件营销', name: 'commits',
type: 'line', type: 'line',
stack: '总量', data: d.commits_count
data: [120, 132, 101, 134, 90, 230, 210] },
}, {
{ name: 'issues',
name: '联盟广告', type: 'line',
type: 'line', data: d.issues_count
stack: '总量', },
data: [220, 182, 191, 234, 290, 330, 310] {
}, name: 'pull_requests',
{ type: 'line',
name: '视频广告', data: d.pull_requests_count
type: 'line', }
stack: '总量',
data: [150, 232, 201, 154, 190, 330, 410]
},
{
name: '直接访问',
type: 'line',
stack: '总量',
data: [320, 332, 301, 334, 390, 330, 320]
},
{
name: '搜索引擎',
type: 'line',
stack: '总量',
data: [820, 932, 901, 934, 1290, 1330, 1320]
}
] ]
}; };
myEcharts.setOption(option); myEcharts.setOption(option);

View File

@ -4,21 +4,27 @@ import { AlignCenter } from '../../Component/layout';
import { TagInfo } from '../../Utils/TagColor'; import { TagInfo } from '../../Utils/TagColor';
import { getImageUrl } from 'educoder'; import { getImageUrl } from 'educoder';
function Activity() { function Activity({list}) {
return( return(
<ul className="infosActivity"> <ul className="infosActivity">
<li> {
<Link to={``}><img src={getImageUrl(`/system/lets/letter_avatars/2/D/169_162_140/120.png`)} alt="" className="aImg"/></Link> list.map((i,k)=>{
<div className="aInfos"> return(
<AlignCenter> <li>
<Link to={``} className="name">蔡世</Link> <Link to={``}><img src={getImageUrl(`/system/lets/letter_avatars/2/D/169_162_140/120.png`)} alt="" className="aImg"/></Link>
<span className="time">1小时前</span> <div className="aInfos">
{TagInfo("立刻","")} <AlignCenter>
<span className="status">已关闭</span> <Link to={``} className="name">{i.user_name}</Link>
</AlignCenter> <span className="time">{i.action_time}</span>
<p className="aDesc">更新了问题状态动态详情动态详情动态详情动态详情动态详情</p> {i.priority && TagInfo(`${i.priority}`,"")}
</div> {i.issue_status && <span className="status">{i.issue_status}</span> }
</li> </AlignCenter>
<p className="aDesc">{i.action_type}{i.name}</p>
</div>
</li>
)
})
}
</ul> </ul>
) )
} }

View File

@ -13,12 +13,20 @@ import Calendar from '../Echart/Calendar';
import ConcentrateProject from './ConcentrateProject'; import ConcentrateProject from './ConcentrateProject';
import Activity from './Activity'; import Activity from './Activity';
import moment from 'moment'; import moment from 'moment';
import Axios from 'axios';
const { Option } = Select;
const aLimit = 5; const aLimit = 5;
function Index(props) { function Index(props) {
const [ page , setPage ] = useState(1); const [ page , setPage ] = useState(1);
const [ total , setTotal ] = useState(0); const [ total , setTotal ] = useState(0);
const [ createYear , setCreateYear ] = useState(undefined); const [ projectTrends , setProjectTrends ] = useState(undefined);
const [ year , setYear ] = useState("0");
const [ yearList , setYearList ] = useState(undefined);
const [ activityDate , setActivityDate ] = useState(undefined);
const [ statisticData , setStatisticData ] = useState(undefined);
const username = props.match.params.username; const username = props.match.params.username;
const current_user = props.current_user; const current_user = props.current_user;
@ -27,21 +35,63 @@ function Index(props) {
useEffect(()=>{ useEffect(()=>{
if(user){ if(user){
let c = user.created_time && user.created_time.split("-")[0]; let c = user.created_time && user.created_time.split("-")[0];
setCreateYear(parseInt(c,0)); let y = moment().get('year');
let array = []
for(var i = y ; i >= parseInt(c,0);i--){
array.push(i);
}
setYearList(array);
} }
},[user]) },[user])
// //
function chooseTime(data) { function chooseTime(data) {
if(data){ if(data){
console.log(data); setActivityDate(data[0]);
} }
} }
function renderYear(){ // option
let y = moment().get('year'); function renderYear(list){
for(var i = y ; i > createYear;i--){ return list.map((i,k)=>{
} return(
<Option key={i}>{i}</Option>
)
})
}
useEffect(()=>{
getActivity();
},[activityDate,page])
//
function getActivity() {
const url = `/users/${username}/project_trends.json`;
Axios.get(url,{
params:{
date:activityDate,
limit:aLimit,page
}
}).then(result=>{
if(result && result.data){
setProjectTrends(result.data.project_trends);
setTotal(result.data.total_count);
}
}).catch(error=>{})
}
//
useEffect(()=>{
getStatistics();
},[])
function getStatistics() {
const url = `/users/${username}/statistics/activity.json`;
Axios.get(url).then(result=>{
if(result && result.data){
setStatisticData(result.data);
}
}).catch(error=>{})
} }
return( return(
@ -50,21 +100,21 @@ function Index(props) {
<ConcentrateProject userLogin={username} current={current_user && (current_user.login === username)}/> <ConcentrateProject userLogin={username} current={current_user && (current_user.login === username)}/>
</div> </div>
<div className="recentStatic"> <div className="recentStatic">
<Line /> <Line data={statisticData}/>
</div> </div>
<div className="calendarStatic"> <div className="calendarStatic">
<FlexAJ> <FlexAJ>
<span className="font-18">贡献度</span> <span className="font-18">贡献度</span>
<Select style={{width:"200px"}} placeholder="选择年份"> <Select style={{width:"200px"}} placeholder="选择年份" value={year} onSelect={(e)=>setYear(e)}>
<Select.Option key="">选择年份</Select.Option> <Option key={"0"}>选择年份</Option>
{ createYear && renderYear()} { yearList && renderYear(yearList) }
</Select> </Select>
</FlexAJ> </FlexAJ>
<Calendar time={''} userLogin={username} chooseTime={chooseTime}/> <Calendar time={year} userLogin={username} chooseTime={chooseTime}/>
</div> </div>
<div className="activeStatic"> <div className="activeStatic">
<span className="font-18">动态</span> <span className="font-18">动态</span>
<Activity /> { projectTrends && projectTrends.length > 0 && <Activity list = {projectTrends}/> }
{ total > aLimit && <div style={{textAlign:'center',paddingBottom:"30px"}}><Pagination pageSize={aLimit} current={page} total={total} onChange={(p)=>setPage(p)}/></div> } { total > aLimit && <div style={{textAlign:'center',paddingBottom:"30px"}}><Pagination pageSize={aLimit} current={page} total={total} onChange={(p)=>setPage(p)}/></div> }
</div> </div>
</div> </div>

View File

@ -123,6 +123,9 @@
line-height: 20px; line-height: 20px;
} }
} }
&:last-child{
border-bottom:none;
}
} }
} }
} }