aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/views/RepositoryCommit.vue
blob: d3ba174065094bc72245866349ac11c385d9e8e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<template>
	<RepositoryNavbar active-page="log" :repository="repository" />
	<div class="row mx-0">
		<div class="col ms-2 ps-4 ps-sm-5 fs-5 vld-parent">
			<BaseBreadcrumb :items="[{ name: 'Log', path: '/' + repository + '/log' }]" :active-item="commit" />
			<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 BaseBreadcrumb from "../components/BaseBreadcrumb";
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,
		BaseBreadcrumb
	},
	props: {
		repository: {
			type: String,
			required: true
		},
		commit: {
			type: String,
			required: true
		}
	},
	setup(props)
	{
		const state = reactive({ commit_data: {}, is_loading: true });

		watch(() =>
		{
			fetch(`${window.location.protocol}//${window.location.host}/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>