Skip to content

Commit

Permalink
fix: fix refresh issues
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 30, 2022
1 parent 5301bc5 commit 0b4de12
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 36 deletions.
5 changes: 1 addition & 4 deletions archguard/src/api/module/containerService.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import axios from "../axios";
import { storage } from "@/store/storage/sessionStorage";
import qs from 'qs';

export function queryContainerServices() {
const systemId = storage.getSystemId();

export function queryContainerServices(systemId: number) {
return axios<any>({
url: `/api/container-service/${systemId}/`,
method: "GET"
Expand Down
8 changes: 2 additions & 6 deletions archguard/src/api/module/gitFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@ export function queryHotFiles() {
});
}

export function getGitPathChanges() {
const systemId = storage.getSystemId();

export function getGitPathChanges(systemId: String) {
return axios<GitPathChange[]>({
url: `/api/systems/${systemId}/git/path-change-count`,
method: "GET",
});
}
export function queryUnstableFiles() {
const systemId = storage.getSystemId();

export function queryUnstableFiles(systemId: String) {
return axios<GitPathChange[]>({
url: `/api/systems/${systemId}/git/unstable-file`,
method: "GET",
Expand Down
37 changes: 20 additions & 17 deletions archguard/src/pages/system/systemSummary/Summary/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BaButton } from "@/components/Basic/Button/Button";
import { BaLabel } from "@/components/Basic/Label/Label";
import { BuGrade } from "@/components/Business/Grade/Grade";
import { useOverviewCount } from "@/api/module/codeLine";
import { history } from "umi";
import { history, useParams } from "umi";
import { storage } from "@/store/storage/sessionStorage";
import useSystemList from "@/store/global-cache-state/useSystemList";
import { queryContainerServices } from "@/api/module/containerService";
Expand All @@ -21,28 +21,29 @@ function Summary() {
const [services, setServices] = useState({} as any);
const [unstableFiles, setUnstableFiles] = useState([]);

const { systemId } = useParams();
storage.setSystemId(systemId)

const [systemList] = useSystemList();
const [systemName, setSystemName] = useState<string>("");

const getSystemName = (): string => {
const list = systemList?.value || [];
const id = storage.getSystemId();

return list.find((system) => system.id === parseInt(id))?.systemName || "";
return list.find((system) => system.id === parseInt(systemId))?.systemName || "";
};

useEffect(() => {
setSystemName(getSystemName());
}, [systemList]);

useEffect(() => {
queryContainerServices().then((res) => {
queryContainerServices(systemId).then((res) => {
setServices(res);
});
}, []);

useEffect(() => {
queryUnstableFiles().then((res) => {
queryUnstableFiles(systemId).then((res) => {
setUnstableFiles(res as any);
});
}, []);
Expand Down Expand Up @@ -87,10 +88,10 @@ function Summary() {
<div className={ styles.body }>
<div className={ styles.detail }>
<div className={ styles.overview }>
<BaLabel value={ overviewCount?.repoCount } text="代码仓数"></BaLabel>
<BaLabel value={ overviewCount?.moduleCount } text="模块数"></BaLabel>
<BaLabel value={ overviewCount?.contributorCount } text="代码贡献人数"></BaLabel>
<BuGrade text="架构质量等级" grade={ overviewCount?.qualityLevel }></BuGrade>
<BaLabel value={ overviewCount?.repoCount } text="代码仓数"/>
<BaLabel value={ overviewCount?.moduleCount } text="模块数"/>
<BaLabel value={ overviewCount?.contributorCount } text="代码贡献人数"/>
<BuGrade text="架构质量等级" grade={ overviewCount?.qualityLevel }/>
</div>
</div>
<div className={ styles.changes }>
Expand All @@ -116,11 +117,11 @@ function Summary() {
<div className={ styles.changes }>
<div className={ styles.graph }>
<h2>提交变更频率(大小)</h2>
<FileSizing/>
<FileSizing systemId={systemId}/>
</div>
<div className={ styles.graph }>
<h2>提交变更频率(大小)-文件长度(颜色深浅)</h2>
<FileChangeSizing/>
<FileChangeSizing systemId={systemId}/>
</div>
</div>
<div>
Expand All @@ -135,11 +136,13 @@ function Summary() {
<h2>API 使用清单 ({ services["demands"]?.length })</h2>
<Table dataSource={ services["demands"] } columns={ demandColumns }/>
</div>
<div className={ styles.resource }>
<h2>API 提供清单 ({ services["resources"]?.length })</h2>
<Table dataSource={ services["resources"] } columns={ resourceColumns }/>
<ApiResourceTree dataSource={ services["resources"] }/>
</div>
{ services["resources"]?.length &&
<div className={ styles.resource }>
<h2>API 提供清单 ({ services["resources"]?.length })</h2>
<Table dataSource={ services["resources"] } columns={ resourceColumns }/>
<ApiResourceTree dataSource={ services["resources"] }/>
</div>
}
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import ReactECharts from 'echarts-for-react';
import { useEffect, useState } from "react";
import CodeSupport from "@/pages/system/systemSummary/Summary/d3Support/CodeSupport";

interface ApiResourceTreeProps {
data: any[]
dataSource: any
}

const ApiResourceTree = (props: ApiResourceTreeProps) => {
console.log(props)
// const [data] = useState(props.data);
const [ dataSource ] = useState(props.dataSource);
const [data] = useState({
name: 'flare',
children: [
Expand All @@ -30,6 +30,18 @@ const ApiResourceTree = (props: ApiResourceTreeProps) => {
const [options, setOptions] = useState(null)

useEffect(() => {
let apiMap = {}
for (let element of dataSource) {
apiMap[element.sourceUrl] = {
name: element.sourceUrl,
value: 0
}
}

console.log(apiMap)
// let hierarchy = CodeSupport.hierarchy(apiMap);
// console.log(hierarchy)

setOptions({
tooltip: {
trigger: 'item',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import CodeSupport from "@/pages/system/systemSummary/Summary/d3Support/CodeSupp
import { getGitPathChanges } from "@/api/module/gitFile";
import { voronoiTreemap } from "d3-voronoi-treemap"

const FileSizing = () => {
interface FileChangeSizingProps {
systemId: String
}

const FileChangeSizing = (props: FileChangeSizingProps) => {
const [data, setData] = useState(null);
const svgRef = useRef(null);
const tooltipRef = useRef(null);
Expand Down Expand Up @@ -127,10 +131,10 @@ const FileSizing = () => {
}

useEffect(() => {
getGitPathChanges().then((res) => {
getGitPathChanges(props.systemId).then((res) => {
setData(res);
});
}, [setData]);
}, [props.systemId, setData]);

useEffect(() => {
if (!!data) {
Expand All @@ -145,4 +149,4 @@ const FileSizing = () => {
</div>;
};

export default FileSizing;
export default FileChangeSizing;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import CodeSupport from "@/pages/system/systemSummary/Summary/d3Support/CodeSupp
import { getGitPathChanges } from "@/api/module/gitFile";
import MenuSupport from "@/pages/system/systemSummary/Summary/d3Support/MenuSupport";

const FileSizing = () => {
interface FileSizingProps {
systemId: String
}

const FileSizing = (props: FileSizingProps) => {
const [ data, setData ] = useState(null);
const svgRef = useRef(null);
const svgEl = d3.select(svgRef.current);
Expand Down Expand Up @@ -135,7 +139,7 @@ const FileSizing = () => {
}

useEffect(() => {
getGitPathChanges().then((res) => {
getGitPathChanges(props.systemId).then((res) => {
setData(res as any);
});
}, [setData]);
Expand Down

0 comments on commit 0b4de12

Please sign in to comment.