aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-07-03 17:45:18 +0200
committerHampusM <hampus@hampusmat.com>2021-07-03 17:45:18 +0200
commit505c18041bebf533ec63fed3790f54f5c6e1843b (patch)
treea1e4661449e8757ac6b0ad83088759c1609ebc96 /packages
parent7ee871e391cd2d2057175d54767fc71e708e32eb (diff)
Made a bunch of frontend stuff work
Diffstat (limited to 'packages')
-rw-r--r--packages/client/src/components/RepositoryTreeTree.vue8
-rw-r--r--packages/client/src/router/index.js15
-rw-r--r--packages/client/src/views/Home.vue2
-rw-r--r--packages/client/src/views/PageNotFound.vue9
-rw-r--r--packages/client/src/views/Repository.vue25
-rw-r--r--packages/client/src/views/RepositoryCommit.vue6
-rw-r--r--packages/client/src/views/RepositoryLog.vue5
-rw-r--r--packages/client/src/views/RepositoryRedirect.vue0
-rw-r--r--packages/client/src/views/RepositoryTree.vue7
9 files changed, 50 insertions, 27 deletions
diff --git a/packages/client/src/components/RepositoryTreeTree.vue b/packages/client/src/components/RepositoryTreeTree.vue
index 23811f7..821251e 100644
--- a/packages/client/src/components/RepositoryTreeTree.vue
+++ b/packages/client/src/components/RepositoryTreeTree.vue
@@ -35,12 +35,12 @@
</div>
</td>
<td>
- <a @click="routeToCommit(entry.last_commit.id, $event)" :href="`/${repository}/log/${entry.last_commit.id}`">
- {{ entry.last_commit.message }}
+ <a @click="routeToCommit(entry.latest_commit.id, $event)" :href="`/${repository}/log/${entry.latest_commit.id}`">
+ {{ entry.latest_commit.message }}
</a>
</td>
<td>
- {{ getPrettyLastUpdated(entry.last_commit.date) }}
+ {{ getPrettyLastUpdated(entry.latest_commit.date) }}
</td>
</tr>
</tbody>
@@ -76,7 +76,7 @@ export default {
this.$router.push(`/${this.repository}/log/${commit_id}`);
},
getPrettyLastUpdated(date) {
- return formatDistance(new Date(date), new Date(), { addSuffix: true });
+ return formatDistance(new Date(date * 1000), new Date(), { addSuffix: true });
}
}
};
diff --git a/packages/client/src/router/index.js b/packages/client/src/router/index.js
index ed53590..b20a473 100644
--- a/packages/client/src/router/index.js
+++ b/packages/client/src/router/index.js
@@ -1,11 +1,10 @@
import { createRouter, createWebHashHistory } from "vue-router";
-import Home from "../views/Home";
const routes = [
{
path: "/",
name: "Home",
- component: Home
+ component: () => import("../views/Home")
},
{
path: "/:repo([a-zA-Z0-9\\.\\-_]+)",
@@ -34,12 +33,16 @@ const routes = [
name: "Tree",
component: () => import("../views/RepositoryTree"),
props: route => ({ pathArr: route.params.path ? route.params.path : [] })
- },
- {
- path: "",
- redirect: to => `/${to.params.repo}/log`
}
+ /* {
+ path: "",
+ component: () => import("../views/RepositoryRedirect")
+ } */
]
+ },
+ {
+ path: "/:PageNotFound(.*)*",
+ component: () => import("../views/PageNotFound")
}
];
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 }} &lt;{{ 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);