More changes on axios
This commit is contained in:
parent
878da11d40
commit
8523041810
58
frontend/src/components/LineChart.vue
Normal file
58
frontend/src/components/LineChart.vue
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<template>
|
||||||
|
<v-chart ref="lineChart" :option="option" autoresize />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { use } from 'echarts/core'
|
||||||
|
import { CanvasRenderer } from 'echarts/renderers'
|
||||||
|
import { LineChart } from 'echarts/charts'
|
||||||
|
import { GridComponent, LegendComponent, TooltipComponent } from 'echarts/components'
|
||||||
|
import VChart from 'vue-echarts'
|
||||||
|
use([CanvasRenderer, LineChart, LegendComponent, GridComponent, TooltipComponent])
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'LineChart',
|
||||||
|
props: {
|
||||||
|
data: { type: Object, default: () => {} }
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
VChart,
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
option() {
|
||||||
|
const option = {
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'axis'
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
data: this.data.series.map(ser => ser.name) || []
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
boundaryGap: false,
|
||||||
|
data: this.data.xData || [],
|
||||||
|
axisLabel: {
|
||||||
|
showMaxLabel: true,
|
||||||
|
showMinLabel: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
type: 'value',
|
||||||
|
minInterval: 1
|
||||||
|
},
|
||||||
|
series: this.data.series || []
|
||||||
|
}
|
||||||
|
return option
|
||||||
|
}
|
||||||
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
// 手动销毁实例
|
||||||
|
if (this.$refs.lineChart && this.$refs.lineChart.dispose) {
|
||||||
|
this.$refs.lineChart.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
||||||
@ -445,7 +445,7 @@
|
|||||||
{{ $t('TO BE IMPLEMENTED.') }}
|
{{ $t('TO BE IMPLEMENTED.') }}
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class="chart-container">
|
<div class="chart-container">
|
||||||
<custom-chart :customOption="getCodeChartOption(project.project.code)" />
|
<line-chart :data="getCodeChartData(project.project.code)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -493,7 +493,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="chart-container">
|
<div class="chart-container">
|
||||||
<custom-chart :customOption="getIssueChartOption(project.project.issue)" />
|
<line-chart :data="getIssueChartData(project.project.issue)" />
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="project-invite-collaborator-containter">
|
<!-- <div class="project-invite-collaborator-containter">
|
||||||
<button
|
<button
|
||||||
@ -615,11 +615,11 @@ import {
|
|||||||
convertIntoToMilestoneStatus,
|
convertIntoToMilestoneStatus,
|
||||||
convertIntoToProjectIssueStatus
|
convertIntoToProjectIssueStatus
|
||||||
} from '@/types/index'
|
} from '@/types/index'
|
||||||
import CustomChart from '@/components/CustomChart.vue'
|
import LineChart from '@/components/LineChart.vue'
|
||||||
import EmptyContent from '@/components/EmptyContent.vue'
|
import EmptyContent from '@/components/EmptyContent.vue'
|
||||||
export default {
|
export default {
|
||||||
name: 'Workspace',
|
name: 'Workspace',
|
||||||
components: { CustomChart, EmptyContent },
|
components: { LineChart, EmptyContent },
|
||||||
props: {},
|
props: {},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
@ -989,27 +989,20 @@ export default {
|
|||||||
this.websocketOnClose
|
this.websocketOnClose
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
getCodeChartOption(code) {
|
getCodeChartData(code) {
|
||||||
const { weekly_commits } = code
|
const { weekly_commits } = code
|
||||||
if (weekly_commits) {
|
if (weekly_commits) {
|
||||||
// 把数据按日期排序
|
// 把数据按日期排序
|
||||||
const sortData = Object.entries(weekly_commits).sort((a, b) => new Date(a[0]) - new Date(b[0]))
|
const sortData = Object.entries(weekly_commits).sort((a, b) => new Date(a[0]) - new Date(b[0]));
|
||||||
const xData = sortData.map(data => data[0])
|
|
||||||
return {
|
return {
|
||||||
xAxis: {
|
xData: sortData.map(data => data[0]),
|
||||||
data: xData
|
|
||||||
},
|
|
||||||
yAxis: {
|
|
||||||
minInterval: 1
|
|
||||||
},
|
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
data: sortData.map(data => data[1]),
|
data: sortData.map(data => data[1]),
|
||||||
type: 'line',
|
type: 'line',
|
||||||
name: this.$t('Commits'),
|
name: 'commits',
|
||||||
lineStyle: {
|
areaStyle: { color: 'rgba(63,73,255,0.1)' },
|
||||||
color: 'rgb(23,72,248)'
|
smooth: true,
|
||||||
},
|
|
||||||
symbol: 'none',
|
symbol: 'none',
|
||||||
connectNulls: true
|
connectNulls: true
|
||||||
}
|
}
|
||||||
@ -1018,48 +1011,32 @@ export default {
|
|||||||
}
|
}
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
getIssueChartOption(issue) {
|
getIssueChartData(issue) {
|
||||||
const { weekly_open_issues, weekly_resolved_issues } = issue
|
const { weekly_open_issues, weekly_resolved_issues } = issue
|
||||||
if (weekly_open_issues && weekly_resolved_issues) {
|
if (weekly_open_issues && weekly_resolved_issues) {
|
||||||
// 把数据按日期排序
|
// 把数据按日期排序
|
||||||
const sortOpenData = Object.entries(weekly_open_issues).sort((a, b) => new Date(a[0]) - new Date(b[0]))
|
const sortOpenData = Object.entries(weekly_open_issues).sort((a, b) => new Date(a[0]) - new Date(b[0]));
|
||||||
const sortResolvedData = Object.entries(weekly_resolved_issues).sort((a, b) => new Date(a[0]) - new Date(b[0]))
|
const sortResolvedData = Object.entries(weekly_resolved_issues).sort((a, b) => new Date(a[0]) - new Date(b[0]));
|
||||||
const openSerData = sortOpenData.map(data => data[1])
|
|
||||||
const resolvedSerData = sortResolvedData.map(data => data[1])
|
|
||||||
const unresolvedSerData = openSerData.map((data, index) => data - resolvedSerData[index]).reduce((acc, cur, index) => {
|
|
||||||
acc.push(index === 0 ? cur : cur + acc[index - 1]);
|
|
||||||
return acc
|
|
||||||
}, [])
|
|
||||||
const xData = sortOpenData.map(data => data[0])
|
|
||||||
return {
|
return {
|
||||||
xAxis: {
|
xData: sortOpenData.map(data => data[0]),
|
||||||
data: xData
|
|
||||||
},
|
|
||||||
yAxis: {
|
|
||||||
minInterval: 1
|
|
||||||
},
|
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
data: openSerData,
|
data: sortOpenData.map(data => data[1]),
|
||||||
name: this.$t('open'),
|
name: 'open',
|
||||||
type: 'line',
|
type: 'line',
|
||||||
|
stack: 'issue',
|
||||||
|
areaStyle: { color: 'rgba(63,73,255,0.1)' },
|
||||||
|
smooth: true,
|
||||||
symbol: 'none',
|
symbol: 'none',
|
||||||
connectNulls: true
|
connectNulls: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: resolvedSerData,
|
data: sortResolvedData.map(data => data[1]),
|
||||||
name: this.$t('resolved'),
|
name: 'resolved',
|
||||||
type: 'line',
|
type: 'line',
|
||||||
symbol: 'none',
|
stack: 'issue',
|
||||||
connectNulls: true
|
areaStyle: { color: 'rgba(63,73,255,0.2)' },
|
||||||
},
|
smooth: true,
|
||||||
{
|
|
||||||
data: unresolvedSerData,
|
|
||||||
name: this.$t('unresolved'),
|
|
||||||
type: 'line',
|
|
||||||
lineStyle: {
|
|
||||||
type: 'dashed'
|
|
||||||
},
|
|
||||||
symbol: 'none',
|
symbol: 'none',
|
||||||
connectNulls: true
|
connectNulls: true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,6 @@ function isTokenExpired(token) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const decodedToken = jwtDecode(token)
|
const decodedToken = jwtDecode(token)
|
||||||
console.log('this is decoded token', decodedToken)
|
|
||||||
const now = Math.floor(Date.now() / 1000)
|
const now = Math.floor(Date.now() / 1000)
|
||||||
// Buffer as 5 minu = 300 seconds
|
// Buffer as 5 minu = 300 seconds
|
||||||
return decodedToken.exp - 300 < now
|
return decodedToken.exp - 300 < now
|
||||||
|
|||||||
0
start_frontend.sh
Normal file → Executable file
0
start_frontend.sh
Normal file → Executable file
Loading…
Reference in New Issue
Block a user