aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/views
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-05-24 10:49:41 +0200
committerHampusM <hampus@hampusmat.com>2021-05-24 10:49:41 +0200
commit518bd58c5aba1a6eaa645074f3ae2d780c45f6dc (patch)
treea99acd3b434422e019bc76064ad0798c8472f07d /src/frontend/views
parent21e52ba2fa323e8aebf291882083c1eca9f6a5af (diff)
Restructured the whole project & added Nodemon and Concurrently
Diffstat (limited to 'src/frontend/views')
-rw-r--r--src/frontend/views/Home.vue62
-rw-r--r--src/frontend/views/Repository.vue29
-rw-r--r--src/frontend/views/RepositoryCommit.vue98
-rw-r--r--src/frontend/views/RepositoryLog.vue91
4 files changed, 280 insertions, 0 deletions
diff --git a/src/frontend/views/Home.vue b/src/frontend/views/Home.vue
new file mode 100644
index 0000000..79ec4ab
--- /dev/null
+++ b/src/frontend/views/Home.vue
@@ -0,0 +1,62 @@
+<template>
+ <HomeHeader />
+ <div class="row mx-0 mt-5">
+ <div id="projects-header" class="col ms-4">
+ <p class="fs-1">
+ Projects
+ </p>
+ </div>
+ <div id="projects-search" class="col d-flex justify-content-end">
+ <form>
+ <input type="search" name="q">
+ <input type="submit" value="Search">
+ </form>
+ </div>
+ </div>
+ <div class="row mx-0">
+ <div class="col ms-4">
+ <ul id="repos">
+ <li v-for="(project, project_name, index) in projects" :key="index">
+ <div v-if="(search !== null && project_name.includes(search)) || search == null">
+ <p class="fs-3">
+ <router-link :to="project_name">
+ {{ project_name }}
+ </router-link>
+ </p>
+ <span class="repo-last-updated fs-5">Last updated about {{ project["last_updated"] }} ago</span>
+ <span class="fs-5">{{ project["description"] }}</span>
+ </div>
+ </li>
+ </ul>
+ </div>
+ </div>
+</template>
+
+<script>
+import HomeHeader from "../components/HomeHeader";
+import { watch, reactive, toRefs } from "vue";
+
+export default {
+ name: "Home",
+ components: {
+ HomeHeader
+ },
+ setup()
+ {
+ const state = reactive({ projects: Object, search: String });
+
+ watch(() =>
+ {
+ fetch(`http://localhost:1337/api/v1/repos`)
+ .then((res) => res.json())
+ .then((data) => state.projects = data["data"]);
+ });
+
+ state.search = (new URLSearchParams(window.location.search)).get("q");
+
+ return {
+ ... toRefs(state)
+ };
+ }
+}
+</script> \ No newline at end of file
diff --git a/src/frontend/views/Repository.vue b/src/frontend/views/Repository.vue
new file mode 100644
index 0000000..8863529
--- /dev/null
+++ b/src/frontend/views/Repository.vue
@@ -0,0 +1,29 @@
+<template>
+ <RepositoryHeader :repository="repository" />
+ <router-view :repository="repository" />
+</template>
+
+<script>
+import RepositoryHeader from "../components/RepositoryHeader";
+
+export default {
+ name: "Repository",
+ components: {
+ RepositoryHeader
+ },
+ props: {
+ repository: {
+ type: String,
+ required: true
+ }
+ },
+ created()
+ {
+ if(/^\/[a-zA-Z0-9.\-_]+[/]?$/.test(window.location.pathname)) {
+ this.$router.push({ path: `${window.location.pathname}${( window.location.pathname.endsWith("/") ) ? "log" : "/log"}`, replace: true});
+ }
+
+ console.log(this.repository);
+ }
+}
+</script> \ No newline at end of file
diff --git a/src/frontend/views/RepositoryCommit.vue b/src/frontend/views/RepositoryCommit.vue
new file mode 100644
index 0000000..283ed69
--- /dev/null
+++ b/src/frontend/views/RepositoryCommit.vue
@@ -0,0 +1,98 @@
+<template>
+ <RepositoryNavbar active-page="log" />
+ <div class="row mx-0">
+ <div class="col ms-2 ps-4 ps-sm-5 fs-5 vld-parent">
+ <nav aria-label="breadcrumb">
+ <ol class="breadcrumb">
+ <li class="breadcrumb-item">
+ <router-link :to="'/' + repository + '/log'">
+ Log
+ </router-link>
+ </li>
+ <li class="breadcrumb-item active" aria-current="page">
+ {{ commit }}
+ </li>
+ </ol>
+ </nav>
+ <Loading
+ v-model:active="is_loading" :height="24"
+ :width="24" color="#ffffff"
+ :opacity="0" />
+ <table id="commit-info" class="table table-dark">
+ <tbody>
+ <tr>
+ <td class="commit-info-title">
+ Author
+ </td>
+ <td>{{ commit_data["author"] }}</td>
+ </tr>
+ <tr>
+ <td class="commit-info-title">
+ Date
+ </td>
+ <td>{{ commit_data["date"] }}</td>
+ </tr>
+ <tr>
+ <td class="commit-info-title">
+ Message
+ </td>
+ <td>{{ commit_data["message"] }}</td>
+ </tr>
+ </tbody>
+ </table>
+
+ <template
+ v-for="(patch, index) in commit_data['patches']" :key="index">
+ <CommitPatch :patch="patch" />
+ </template>
+ </div>
+ </div>
+</template>
+
+<script>
+import RepositoryNavbar from "../components/RepositoryNavbar";
+import CommitPatch from "../components/CommitPatch";
+import Loading from "vue-loading-overlay";
+import 'vue-loading-overlay/dist/vue-loading.css';
+import { watch, reactive, toRefs } from "vue";
+import { format } from "date-fns";
+
+export default {
+ name: "RepositoryCommit",
+ components: {
+ RepositoryNavbar,
+ CommitPatch,
+ Loading
+ },
+ props: {
+ repository: {
+ type: String,
+ required: true
+ },
+ commit: {
+ type: String,
+ required: true
+ }
+ },
+ setup(props)
+ {
+ const state = reactive({ commit_data: {}, is_loading: true });
+
+ watch(() =>
+ {
+ fetch(`http://localhost:1337/api/v1/repos/${props.repository}/log/${props.commit}`)
+ .then((res) => res.json())
+ .then((data) =>
+ {
+ data["data"]["date"] = format(new Date(data["data"]["date"]), "yyyy-MM-dd hh:mm");
+ state.commit_data = data["data"]
+ state.is_loading = false;
+ });
+ });
+
+ return {
+ ... toRefs(state)
+ };
+ }
+}
+</script>
diff --git a/src/frontend/views/RepositoryLog.vue b/src/frontend/views/RepositoryLog.vue
new file mode 100644
index 0000000..399fc78
--- /dev/null
+++ b/src/frontend/views/RepositoryLog.vue
@@ -0,0 +1,91 @@
+<template>
+ <RepositoryNavbar active-page="log" />
+ <div class="row mx-0 vld-parent">
+ <Loading
+ v-model:active="is_loading" :height="24"
+ :width="24" color="#ffffff"
+ :opacity="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 Loading from "vue-loading-overlay";
+import 'vue-loading-overlay/dist/vue-loading.css';
+import { format } from "date-fns";
+import { watch, reactive, toRefs } from "vue";
+
+export default {
+ name: "RepositoryLog",
+ components: {
+ RepositoryNavbar,
+ Loading
+ },
+ props: {
+ repository: {
+ type: String,
+ required: true
+ }
+ },
+ data()
+ {
+ return {
+ format: format
+ };
+ },
+ setup(props)
+ {
+ const state = reactive({ commits: {}, is_loading: true });
+
+ watch(() =>
+ {
+ fetch(`http://localhost:1337/api/v1/repos/${props.repository}/log`)
+ .then((res) => res.json())
+ .then((data) => {
+ state.commits = data["data"];
+ state.is_loading = false;
+ });
+ });
+
+ return {
+ ... toRefs(state)
+ };
+ }
+}
+</script> \ No newline at end of file