diff options
author | HampusM <hampus@hampusmat.com> | 2021-05-23 21:53:08 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2021-05-23 21:53:08 +0200 |
commit | b183160763955596dbdf179524b75fc10ab2a03c (patch) | |
tree | 870a0c6fb1a61af8fc08a4c0be435f98ccfa1ed8 /src/views/RepositoryLog.vue | |
parent | 7e828a5eb04afe476e596cf88000e53c2f93f45e (diff) |
Frontend used Vue.js & Added ESLint
Diffstat (limited to 'src/views/RepositoryLog.vue')
-rw-r--r-- | src/views/RepositoryLog.vue | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/views/RepositoryLog.vue b/src/views/RepositoryLog.vue new file mode 100644 index 0000000..da93624 --- /dev/null +++ b/src/views/RepositoryLog.vue @@ -0,0 +1,81 @@ +<template> + <RepositoryNavbar active-page="log" /> + <div class="row mx-0"> + <div class="col ms-4 ps-4 ps-sm-5 mt-3"> + <table id="log" class="table table-dark fs-5"> + <thead> + <tr> + <th class="text-secondary"> + Subject + </th> + <th class="text-secondary"> + Author + </th> + <th class="text-secondary"> + Date + </th> + <th class="text-secondary"> + Files + </th> + <th class="text-secondary"> + Del/Add + </th> + </tr> + </thead> + <tbody> + <tr v-for="(commit, index) in commits" :key="index"> + <td> + <router-link :to="'log/' + commit['commit']"> + {{ commit["message"] }} + </router-link> + </td> + <td>{{ commit["author_name"] }}</td> + <td>{{ format(new Date(commit["date"]), "yyyy-MM-dd hh:mm") }}</td> + <td>{{ commit["files_changed"] }}</td> + <td><span class="text-danger">-{{ commit["deletions"] }}</span> / <span class="text-success">+{{ commit["insertions"] }}</span></td> + </tr> + </tbody> + </table> + </div> + </div> +</template> + +<script> +import RepositoryNavbar from "../components/RepositoryNavbar"; +import { format } from "date-fns"; +import { watch, reactive, toRefs } from "vue"; + +export default { + name: "RepositoryLog", + components: { + RepositoryNavbar + }, + props: { + repository: { + type: String, + required: true + } + }, + data() + { + return { + format: format + }; + }, + setup(props) + { + const state = reactive({ commits: {} }); + + watch(() => + { + fetch(`http://localhost:1337/api/v1/repos/${props.repository}/log`) + .then((res) => res.json()) + .then((data) => state.commits = data["data"]); + }); + + return { + ... toRefs(state) + }; + } +} +</script>
\ No newline at end of file |