Skip to content

Commit dbb39ee

Browse files
committed
feat: Load settings and add gitconfig edit field to settings page
1 parent 8212aca commit dbb39ee

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

pages/settings.vue

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Created Date: 2024-03-25 17:46:47
66
* Author: 3urobeat
77
*
8-
* Last Modified: 2024-03-25 21:05:46
8+
* Last Modified: 2024-04-11 18:52:19
99
* Modified By: 3urobeat
1010
*
1111
* Copyright (c) 2024 3urobeat <https://github.com/3urobeat>
@@ -18,12 +18,53 @@
1818

1919

2020
<template>
21-
<div id="title" class="font-semibold underline underline-offset-4 pb-5 lg:pb-7 pt-10 select-none">
22-
Settings
21+
<div id="title" class="flex w-full pb-5 lg:pb-7 pt-10 select-none">
22+
<p class="w-full font-semibold underline underline-offset-4">Settings</p>
23+
24+
<!-- Save button -->
25+
<div class="flex justify-end items-center">
26+
<button class="flex items-center justify-center py-1 px-3 rounded-sm bg-gray-100 outline outline-black outline-2 hover:bg-gray-200 hover:transition-all" @click="saveChanges">
27+
<PhCheck class="mr-2 size-5 text-green-600"></PhCheck>
28+
Save
29+
</button>
30+
</div>
31+
</div>
32+
33+
<div class="lg:flex lg:flex-col lg:mx-12"> <!-- Offset content to the right on desktop to give headline more presence -->
34+
<div id="gitconfig">
35+
<p class="font-semibold">Git Config:</p>
36+
<textarea class="lg:w-2/4 w-full h-64 opacity-60 my-1 px-1 bg-slate-200 rounded-sm outline outline-black outline-2" v-model="settings.gitConfig"></textarea>
37+
</div>
2338
</div>
2439
</template>
2540

2641

2742
<script setup lang="ts">
43+
import { PhCheck } from "@phosphor-icons/vue";
44+
import type { Settings } from "~/model/settings";
45+
46+
47+
// Refs
48+
const settings: Ref<Settings> = ref({
49+
gitConfig: ""
50+
});
51+
52+
53+
// Load data
54+
const serverData = await useFetch<any>("/api/get-settings");
55+
56+
settings.value = serverData.data.value;
57+
58+
59+
// Sends changes to the database
60+
async function saveChanges() {
61+
await useFetch("/api/set-settings", {
62+
method: "POST",
63+
headers: {
64+
"Content-Type": "application/json"
65+
},
66+
body: JSON.stringify(settings.value)
67+
});
68+
}
2869
2970
</script>

0 commit comments

Comments
 (0)