diff options
Diffstat (limited to 'packages/client/src/views')
-rw-r--r-- | packages/client/src/views/Home.vue | 2 | ||||
-rw-r--r-- | packages/client/src/views/PageNotFound.vue | 9 | ||||
-rw-r--r-- | packages/client/src/views/Repository.vue | 25 | ||||
-rw-r--r-- | packages/client/src/views/RepositoryCommit.vue | 6 | ||||
-rw-r--r-- | packages/client/src/views/RepositoryLog.vue | 5 | ||||
-rw-r--r-- | packages/client/src/views/RepositoryRedirect.vue | 0 | ||||
-rw-r--r-- | packages/client/src/views/RepositoryTree.vue | 7 |
7 files changed, 37 insertions, 17 deletions
diff --git a/packages/client/src/views/Home.vue b/packages/client/src/views/Home.vue index 87adf4a..309fa8b 100644 --- a/packages/client/src/views/Home.vue +++ b/packages/client/src/views/Home.vue @@ -54,7 +54,7 @@ export default { const projects_data = await fetchData("repos", fetch_failed, is_loading, "projects"); projects_data.reduce((result, project) => { - project.last_updated = formatDistance(Date.parse(project.last_updated), new Date(), { addSuffix: true }); + project.last_updated = formatDistance(new Date(project.last_updated * 1000), new Date(), { addSuffix: true }); result.push(projects); return result; }, []); diff --git a/packages/client/src/views/PageNotFound.vue b/packages/client/src/views/PageNotFound.vue new file mode 100644 index 0000000..d2b6fbb --- /dev/null +++ b/packages/client/src/views/PageNotFound.vue @@ -0,0 +1,9 @@ +<template> + 404 lmao +</template> + +<script> +export default { + name: "PageNotFound" +}; +</script> diff --git a/packages/client/src/views/Repository.vue b/packages/client/src/views/Repository.vue index 24000d4..7b31545 100644 --- a/packages/client/src/views/Repository.vue +++ b/packages/client/src/views/Repository.vue @@ -24,18 +24,29 @@ export default { const description = ref(""); const has_readme = ref(null); - const fetchProjects = async(repository) => { - console.log(repository); - const repository_data = await (await fetch(`${window.location.protocol}//${window.location.host}/api/v1/repos/${repository}`)).json(); - name.value = repository_data.data.name; - description.value = repository_data.data.description; - has_readme.value = repository_data.data.has_readme; + const fetchProjects = async(router, path) => { + const repository = router.currentRoute._rawValue.params.repo; + + const repository_data = await fetch(`${window.location.protocol}//${window.location.host}/api/v1/repos/${repository}`) + .catch(() => { + if(path.split("/").length === 2) { + router.replace(`/${repository}/log`); + }; + return null; + }); + + if(repository_data) { + const data = (await repository_data.json()).data; + name.value = data.name; + description.value = data.description; + has_readme.value = data.has_readme; + } }; return { name, description, has_readme, fetchProjects }; }, created() { - this.fetchProjects(this.$router.currentRoute._rawValue.params.repo); + this.fetchProjects(this.$router, this.$route.path); } }; </script> diff --git a/packages/client/src/views/RepositoryCommit.vue b/packages/client/src/views/RepositoryCommit.vue index 447549b..a2caa74 100644 --- a/packages/client/src/views/RepositoryCommit.vue +++ b/packages/client/src/views/RepositoryCommit.vue @@ -10,7 +10,7 @@ <td class="commit-info-title"> Author </td> - <td>{{ commit["author"] }}</td> + <td>{{ commit.author.name }} <{{ commit.author.email }}></td> </tr> <tr> <td class="commit-info-title"> @@ -27,7 +27,7 @@ </tbody> </table> <div - v-for="(patch, index) in commit['patches']" :key="index" + v-for="(patch, index) in commit['diff']" :key="index" class="commit-patch"> <div class="commit-patch-header"> <span>{{ (patch.to === "/dev/null") ? patch.from : patch.to }} </span> @@ -75,7 +75,7 @@ export default { const commit_data = await fetchData(`repos/${repository}/log/${commit_id}`, fetch_failed, is_loading, "commit"); if(commit_data) { - commit_data.date = format(new Date(commit_data.date), "yyyy-MM-dd hh:mm"); + commit_data.date = format(new Date(commit_data.date * 1000), "yyyy-MM-dd hh:mm"); commit.value = commit_data; } }; diff --git a/packages/client/src/views/RepositoryLog.vue b/packages/client/src/views/RepositoryLog.vue index efedd87..cda2889 100644 --- a/packages/client/src/views/RepositoryLog.vue +++ b/packages/client/src/views/RepositoryLog.vue @@ -31,7 +31,7 @@ </router-link> </td> <td>{{ commit.author.name }}</td> - <td>{{ format(new Date(commit.date), "yyyy-MM-dd hh:mm") }}</td> + <td>{{ format(new Date(commit.date * 1000), "yyyy-MM-dd hh:mm") }}</td> <td>{{ commit.files_changed }}</td> <td class="add-del"> <span>-{{ commit.deletions }}</span> / <span>+{{ commit.insertions }}</span> @@ -104,7 +104,8 @@ table { background-color: lighten(colors.$background, 5%); } td { - padding-bottom: 1em; + padding-bottom: 0.5rem; + padding-top: 0.5rem; } } } diff --git a/packages/client/src/views/RepositoryRedirect.vue b/packages/client/src/views/RepositoryRedirect.vue new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/packages/client/src/views/RepositoryRedirect.vue diff --git a/packages/client/src/views/RepositoryTree.vue b/packages/client/src/views/RepositoryTree.vue index 351591a..6a788d3 100644 --- a/packages/client/src/views/RepositoryTree.vue +++ b/packages/client/src/views/RepositoryTree.vue @@ -58,23 +58,22 @@ export default { const tree = ref(null); const blob_content = ref(null); const is_loading = ref(true); - const fetch_failed = ref(null); + const fetch_failed = ref(""); const path = ref(""); const fetchTree = async(repository) => { blob_content.value = null; tree.value = null; - path.value = props.pathArr ? props.pathArr.join("/") : undefined; const tree_data = await fetchData(`repos/${repository}/tree${path.value ? "?path=" + path.value : ""}`, fetch_failed, is_loading, "tree"); if(tree_data) { if(tree_data.type === "tree") { - let tree_trees = tree_data.tree.filter((entry) => entry.type === "tree"); + let tree_trees = tree_data.content.filter((entry) => entry.type === "tree"); tree_trees = tree_trees.sort((a, b) => a.name.localeCompare(b.name)); - let tree_blobs = tree_data.tree.filter((entry) => entry.type === "blob"); + let tree_blobs = tree_data.content.filter((entry) => entry.type === "blob"); tree_blobs = tree_blobs.sort((a, b) => a.name.localeCompare(b.name)); tree.value = tree_trees.concat(tree_blobs); |