im so tired rn
All checks were successful
Build and Deploy Frontend / build-and-deploy (push) Successful in 6s
All checks were successful
Build and Deploy Frontend / build-and-deploy (push) Successful in 6s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
## agologum
|
||||
A web server/web client template.
|
||||
Backend: a .NET web API with a [READACTED] database (probably sql for tinkering)
|
||||
Backend: a .NET web API with a [READACTED] database (probably prostgressql for tinkering)
|
||||
Frontend: Vue.js because I enjoy life and the splendor of God's creation
|
||||
|
||||
9
client/scripts/launch_dev.sh
Normal file
9
client/scripts/launch_dev.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
# this script builds and launches the vue client served raw and locally
|
||||
# (without docker) on localhost (default) or via the machine's ip given the argument -I
|
||||
|
||||
|
||||
# launch the app
|
||||
npm run dev
|
||||
|
||||
# TODO: more configuration
|
||||
@@ -1,13 +1,9 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import Header from './components/Header.vue'
|
||||
import index from './pages/index.vue'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>straight up gargoyling it !</h1>
|
||||
<Header />
|
||||
<Header />
|
||||
<Header />
|
||||
<Header />
|
||||
<h1>imagining what I could do with themes :o</h1>
|
||||
</template>
|
||||
<index />
|
||||
<router-view /> <!-- Routed components appear here -->
|
||||
</template>
|
||||
@@ -0,0 +1,33 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import { onMounted } from "vue";
|
||||
import { useUsersStore} from "../stores/UsersStore.ts";
|
||||
|
||||
const store = useUsersStore();
|
||||
|
||||
onMounted(() => { // register callback for when component is loaded on page
|
||||
store.fetchUsers();
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<div>
|
||||
<h1>Users</h1>
|
||||
|
||||
<router-link to="/users/new">Create User</router-link>
|
||||
|
||||
<table>
|
||||
<tr v-for="user in store.users" :key="user.id">
|
||||
<td>{{ user.name }}</td>
|
||||
<td>
|
||||
<router-link :to="`/users/${user.id}`">Edit</router-link>
|
||||
<button @click="store.removeUser(user.id)">Delete</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from "pinia"
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
app.use(createPinia())
|
||||
app.use(router)
|
||||
|
||||
app.mount('#app')
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<!-- pages/views in vue are basically root-level full-page components -->
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import { useUsersStore } from "../stores/UsersStore.ts";
|
||||
import type { User } from "../models/User.ts";
|
||||
|
||||
const store = useUsersStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const user = ref<User>({
|
||||
name: "",
|
||||
id: 0,
|
||||
email: "",
|
||||
});
|
||||
|
||||
const id: string | undefined = route.params.id as string | undefined
|
||||
|
||||
onMounted(() => {
|
||||
if(id) {
|
||||
const existing = store.users.find(i => i.id == Number(id));
|
||||
if (existing) user.value = { ...existing };
|
||||
}
|
||||
});
|
||||
|
||||
async function save(): Promise<void> {
|
||||
if(id) {
|
||||
await store.updateUser(Number(id), user.value);
|
||||
} else {
|
||||
await store.addUser(user.value);
|
||||
}
|
||||
|
||||
router.push("/users"); // redirect
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<div>
|
||||
<h2>{{ id ? "Edit User" : "Create User" }}</h2> <!-- omg I love ternary operator :D -->
|
||||
|
||||
<form @submit.prevent="save">
|
||||
<input v-model="user.name" placeholder="Name" />
|
||||
|
||||
<button type="submit">Save</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import { onMounted } from "vue"
|
||||
import { useUsersStore } from "../stores/UsersStore.ts"
|
||||
|
||||
const store = useUsersStore()
|
||||
|
||||
onMounted(() => {
|
||||
store.fetchUsers()
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<h1>Users</h1>
|
||||
|
||||
<router-link to="/users/new">Create User</router-link>
|
||||
|
||||
<table>
|
||||
<tr v-for="user in store.users" :key="user.id">
|
||||
<td>{{ user.name }}</td>
|
||||
<td>
|
||||
<router-link :to="`/users/${user.id}`">Edit</router-link>
|
||||
<button @click="store.removeUser(user.id)">Delete</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,2 +1,12 @@
|
||||
|
||||
<!-- pages are the base instance for routes. an endpoint serves a page, and the page loads components -->
|
||||
<!-- pages are the base instance for routes. an endpoint serves a page, and the page loads components -->
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>straight up gargoyling it !</h1>
|
||||
<h3>yeah im so cool rn</h3>
|
||||
<h1>imagining what I could do with themes :o</h1>
|
||||
</template>
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
|
||||
// generated by vue
|
||||
// the router creates front-end endpoints and serves pages to them
|
||||
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import UsersList from "../pages/UsersList.vue";
|
||||
import UserForm from "../pages/UserForm.vue";
|
||||
import index from "../pages/index.vue";
|
||||
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
// link path to the page component
|
||||
const routes = [
|
||||
{ path: "/", component: index },
|
||||
{ path: "/users", component: UsersList },
|
||||
{ path: "/user/new", component: UserForm },
|
||||
{ path: "/user/:id", component: UserForm }
|
||||
]; // I really like this
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
routes: [],
|
||||
})
|
||||
});
|
||||
|
||||
export default router
|
||||
export default router;
|
||||
|
||||
@@ -21,7 +21,7 @@ export const useUsersStore = defineStore("users", {
|
||||
}),
|
||||
|
||||
actions: {
|
||||
async fetchItems() {
|
||||
async fetchUsers() {
|
||||
this.loading = true;
|
||||
const response = await api.getUsers();
|
||||
this.users = response.data;
|
||||
|
||||
@@ -15,4 +15,7 @@ export default defineConfig({
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
},
|
||||
},
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user