Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair navigation bar #1207

Merged
merged 2 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions frontend/packages/core/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"empty": "Nothing to display",
"error": "Error occurred",
"graph": "Graphs",
"graphDynamic": "dynamic",
"dynamic_graph": "dynamic",
"ToggleGraph": "X2Paddle",
"graphStatic": "static",
"static_graph": "static",
"high-dimensional": "High Dimensional",
"profiler":"performance analysis",
"profiler": "performance analysis",
"histogram": "Histogram",
"hyper-parameter": "Hyper Parameters",
"image": "Image",
Expand Down
4 changes: 2 additions & 2 deletions frontend/packages/core/public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"empty": "暂无数据",
"error": "发生错误",
"graph": "网络结构",
"graphDynamic": "动态",
"dynamic_graph": "动态",
"ToggleGraph": "X2Paddle",
"graphStatic": "静态",
"static_graph": "静态",
"high-dimensional": "数据降维",
"profiler": "性能分析",
"histogram": "直方图",
Expand Down
45 changes: 35 additions & 10 deletions frontend/packages/core/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,16 @@ const SubNav: FunctionComponent<{
const Navbar: FunctionComponent = () => {
const history = useHistory();
const {t, i18n} = useTranslation('common');
// const {pathname: pathnames} = useLocation();
// console.log('pathnames', pathnames);
// const paths = pathnames.split('/');
// paths.shift();
// paths.shift();
// // join('/');
// const pathname = '/' + paths.join('/');
// console.log('pathname', pathname);
const {pathname} = useLocation();

const [navList, setNavlist] = useState<string[]>([]);
const changeLanguage = useCallback(() => {
const language = i18n.language;
Expand All @@ -285,8 +294,8 @@ const Navbar: FunctionComponent = () => {
audio: 'audio',
text: 'text',
fastdeploy_server: 'fastdeploy_server',
graphStatic: 'static_graph',
graphDynamic: 'dynamic_graph',
static_graph: 'static_graph',
dynamic_graph: 'dynamic_graph',
'high-dimensional': 'embeddings',
'pr-curve': 'pr_curve',
'roc-curve': 'roc_curve',
Expand Down Expand Up @@ -397,14 +406,18 @@ const Navbar: FunctionComponent = () => {
id = `/${route.id}`;
}
// debugger;
if (routeEm[route.id] === path) {
console.log('path', route);
const paths = path.split('/');
if (routeEm[route.id] === paths[paths.length - 1]) {
console.log('path', route.id);
history.push(id);
return;
return true;
}
if (route.children) {
for (const Route of route.children) {
routesChange(Route, id, path);
const flag = routesChange(Route, id, path);
if (flag) {
return true;
}
}
}
};
Expand All @@ -427,13 +440,25 @@ const Navbar: FunctionComponent = () => {
// const path = routeEm[pathNames];
if (pathname === '/index') {
const path = navList[0];
for (const route of routes) {
routesChange(route, '', path);
// for (const route of routes) {
// routesChange(route, '', path);
// }
for (let index = 0; index < routes.length; index++) {
const route = routes[index];
const flag = routesChange(route, '', path);
if (flag) {
return;
}
}
} else {
const path = pathname;
for (const route of routes) {
routesChange(route, '', path);
//
for (let index = 0; index < routes.length; index++) {
const route = routes[index];
const flag = routesChange(route, '', path);
if (flag) {
return;
}
}
}

Expand Down
14 changes: 8 additions & 6 deletions frontend/packages/core/src/pages/graphStatic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ const Graph = React.forwardRef<pageRef, GraphProps>(({changeName, changeshowdata
},
[setModelFile]
);
const {loading} = useRequest<BlobResponse>(files ? null : '/graph/graph');

// useEffect(() => {
// if (data?.data?.size) {
// setFiles([new File([data.data], data.filename || 'unknown_model')]);
// }
// }, [data]);
const {data, loading} = useRequest<BlobResponse>(files ? null : '/graph/static_graph');

useEffect(() => {
if (data?.data?.size) {
setFiles([new File([data.data], data.filename || 'unknown_model')]);
}
}, [data]);
// const {loading} = useRequest<BlobResponse>(files ? null : '/graph/graph');

const [modelGraphs, setModelGraphs] = useState<OpenedResult['graphs']>([]);
const [selectedGraph, setSelectedGraph] = useState<NonNullable<OpenedResult['selected']>>('');
Expand Down
Loading