aboutsummaryrefslogtreecommitdiff
path: root/packages/client/src/views/Repository.vue
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/client/src/views/Repository.vue
parent7ee871e391cd2d2057175d54767fc71e708e32eb (diff)
Made a bunch of frontend stuff work
Diffstat (limited to 'packages/client/src/views/Repository.vue')
-rw-r--r--packages/client/src/views/Repository.vue25
1 files changed, 18 insertions, 7 deletions
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>