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

fix ui issue #671

Merged
merged 1 commit into from
Nov 5, 2024
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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ sha1 = "0.10.6"
futures = "0.3.30"
futures-util = "0.3.30"
go-defer = "0.1.0"
russh = "0.45.0"
russh-keys = "0.45.0"
russh = "0.46.0"
russh-keys = "0.46.0"
axum = "0.7.7"
axum-extra = "0.9.4"
axum-server = "0.7.1"
tower-http = "0.6.1"
tower = "0.5.1"
hex = "0.4.3"
sea-orm = "1.1.0"
sea-orm = "1.1.1"
flate2 = "1.0.34"
bstr = "1.10.0"
colored = "2.1.0"
Expand Down
2 changes: 1 addition & 1 deletion mono/src/server/ssh_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub fn load_key() -> KeyPair {
KeyPair::Ed25519(keypair)
} else {
// generate a keypair if not exists
let keys = KeyPair::generate_ed25519().unwrap();
let keys = KeyPair::generate_ed25519();
if let KeyPair::Ed25519(inner_pair) = &keys {
let secret = serde_json::json!({
"secret_key": *inner_pair.to_pkcs8_pem(LineEnding::CR).unwrap()
Expand Down
2 changes: 1 addition & 1 deletion moon/src/app/(dashboard)/blob/[...path]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function BlobPage({ params }: { params: Params }) {
<div>
<Flex gap="middle" wrap>
<Layout style={breadStyle}>
<Bread path={new_path} />
<Bread path={path} />
</Layout>
<Layout style={treeStyle}>
{/* <RepoTree directory={directory} /> */}
Expand Down
40 changes: 26 additions & 14 deletions moon/src/app/(dashboard)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
'use client'

import CodeTable from '@/components/CodeTable'
export const revalidate = 0
import { useEffect, useState } from 'react';

export default function HomePage() {
const [directory, setDirectory] = useState([]);
const [readmeContent, setReadmeContent] = useState("");

const fetchData = async () => {
try {
let directory = await getDirectory("/");
setDirectory(directory);
let readmeContent = await getReadmeContent("/", directory);
setReadmeContent(readmeContent);
} catch (error) {
console.error('Error fetching data:', error);
}
};

export default async function HomePage() {
let directory = await getDirectory()
let readmeContent = await getReadmeContent(directory)
useEffect(() => {
fetchData();
}, []);

return (
<div>
<CodeTable directory={directory} readmeContent={readmeContent} />
</div>
);
}

async function getDirectory() {
const res = await fetch(`http://localhost:3000/api/tree/commit-info?path=/`);

async function getDirectory(pathname: string) {
const res = await fetch(`/api/tree/commit-info?path=${pathname}`);
const response = await res.json();
const directory = response.data.data;

return directory
}

async function getReadmeContent(directory) {
let readmeContent = '';

async function getReadmeContent(pathname, directory) {
var readmeContent = '';
for (const project of directory || []) {
if (project.name === 'README.md' && project.content_type === 'file') {
const res = await fetch(`http://localhost:3000/api/blob?path=/README.md`);
const res = await fetch(`/api/blob?path=${pathname}/README.md`);
const response = await res.json();
readmeContent = response.data.data;
break;
}
}

return readmeContent
}
4 changes: 2 additions & 2 deletions moon/src/app/(dashboard)/tree/[...path]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function Page({ params }: { params: Params }) {
try {
let directory = await getDirectory(new_path);
setDirectory(directory);
let readmeContent = await getReadmeContent(path, directory);
let readmeContent = await getReadmeContent(new_path, directory);
setReadmeContent(readmeContent);
let shown_clone_btn = await pathCanClone(new_path);
setCloneBtn(shown_clone_btn);
Expand All @@ -34,7 +34,7 @@ export default function Page({ params }: { params: Params }) {
}
};
fetchData();
}, [path]);
}, [new_path]);

const treeStyle = {
borderRadius: 8,
Expand Down
2 changes: 0 additions & 2 deletions moon/src/components/BreadCrumb.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import 'github-markdown-css/github-markdown-light.css'
import { useRouter } from 'next/navigation'
import { Breadcrumb } from 'antd/lib'
import styles from './BreadCrumb.module.css'

const Bread = ({ path }) => {
const router = useRouter();
const breadCrumbItems = path.map((sub_path, index) => {
if (index == path.length - 1) {
return {
Expand Down
3 changes: 2 additions & 1 deletion moon/src/components/CodeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ const CodeTable = ({ directory, readmeContent }) => {
<div style={fileCodeContainerStyle}>
<Table style={{ clear: "none" }} rowClassName={styles.dirShowTr}
pagination={false} columns={columns}
dataSource={directory} rowKey="oid"
dataSource={directory}
rowKey="name"
onRow={(record) => {
return {
onClick: (event) => { handleRowClick(record) }
Expand Down
Loading