Started to refactor dashboard.py with dashboard_new.py and trying really hard to figure out sqlalchemy lol

This commit is contained in:
Donald Zou
2024-01-09 00:25:47 -05:00
parent f671c992e1
commit 864f82ba11
12 changed files with 1310 additions and 66 deletions
+32 -15
View File
@@ -6,17 +6,29 @@ export default {
data(){
return {
username: "",
password: ""
password: "",
loginError: false,
loginErrorMessage: ""
}
},
methods: {
async auth(){
if (this.username && this.password){
await fetchPost("/auth", {
await fetchPost("/api/authenticate", {
username: this.username,
password: this.password
}, (response) => {
console.log(response)
if (response.status){
this.loginError = false;
this.$router.push('/')
}else{
this.loginError = true;
this.loginErrorMessage = response.message;
document.querySelectorAll("input[required]").forEach(x => {
x.classList.remove("is-valid")
x.classList.add("is-invalid")
});
}
})
}else{
document.querySelectorAll("input[required]").forEach(x => {
@@ -27,7 +39,7 @@ export default {
x.classList.remove("is-invalid")
x.classList.add("is-valid")
}
})
});
}
}
}
@@ -37,19 +49,24 @@ export default {
<template>
<div class="container-fluid login-container-fluid h-100 d-flex">
<div class="login-box m-auto" style="width: 500px;">
<h1 class="text-center">Sign in</h1>
<h5 class="text-center">to WGDashboard</h5>
<h5 class="text-center">Welcome to</h5>
<h1 class="text-center">WGDashboard</h1>
<div class="m-auto">
<div class="alert alert-danger d-none" role="alert" style="margin-top: 1rem; margin-bottom: 0rem;"></div>
<div class="form-group">
<label for="username" class="text-left" style="font-size: 1rem"><i class="bi bi-person-circle"></i></label>
<input type="text" v-model="username" class="form-control" id="username" name="username" placeholder="Username" required>
<div class="alert alert-danger mt-2 mb-0" role="alert" v-if="loginError">
{{this.loginErrorMessage}}
</div>
<div class="form-group">
<label for="password" class="text-left" style="font-size: 1rem"><i class="bi bi-key-fill"></i></label>
<input type="password" v-model="password" class="form-control" id="password" name="password" placeholder="Password" required>
</div>
<button class="btn btn-dark w-100 mt-4" @click="this.auth()">Sign In</button>
<form @submit="(e) => {e.preventDefault(); this.auth();}">
<div class="form-group">
<label for="username" class="text-left" style="font-size: 1rem"><i class="bi bi-person-circle"></i></label>
<input type="text" v-model="username" class="form-control" id="username" name="username" placeholder="Username" required>
</div>
<div class="form-group">
<label for="password" class="text-left" style="font-size: 1rem"><i class="bi bi-key-fill"></i></label>
<input type="password" v-model="password" class="form-control" id="password" name="password" placeholder="Password" required>
</div>
<button class="btn btn-dark ms-auto mt-4 w-100 d-flex">
Sign In<i class="ms-auto bi bi-chevron-right"></i></button>
</form>
</div>
</div>
</div>