Compare commits

...

10 Commits

Author SHA1 Message Date
f8b9b5407b Improved styling on buttons 2023-07-21 17:27:08 +01:00
31a96558bf More descriptive login screen 2023-07-21 17:26:38 +01:00
bba55bfc0e Custom item styling 2023-07-21 17:26:13 +01:00
cfb643832b Added the db to git 2023-07-21 17:25:19 +01:00
497c916d93 Removed the database from gitignore 2023-07-21 17:25:06 +01:00
8c07677a01 Display different buttons based on role 2023-07-21 15:45:12 +01:00
677ac0241d Basic screen switching 2023-07-21 15:33:45 +01:00
d014848e71 Updated packages 2023-07-21 15:06:52 +01:00
05d1952c84 Added release mode toggle 2023-07-21 15:06:29 +01:00
fae7507407 Added release mode toggle 2023-07-21 15:06:17 +01:00
8 changed files with 86 additions and 14 deletions

3
.gitignore vendored
View File

@@ -155,8 +155,5 @@ dist
# custom
# database
database/data.db
#
.idea

BIN
database/data.db Normal file

Binary file not shown.

View File

@@ -1,8 +1,42 @@
.flex {
margin-left: 0;
}
.loginSpacer {
height: 33%;
}
#menu {
#login {
width: 100%;
height: 100%;
}
#content {
height: 85%;
width: 100%;
padding: 5%;
}
#menu {
height: fit-content;
width: 100%;
padding: 5%;
}
#mainPage {
width: 100%;
height: 100%;
}
.screen {
width: 95%;
height: 100%;
}
.button {
width: 100%;
}
#taskButton {
padding-left: 0;
}

View File

@@ -9,7 +9,7 @@
</head>
<body>
<script src="/frontend/index.js"></script>
<div id="login" class="flex three" style="height: 100%">
<div id="login" class="flex three">
<div class="fourth two-fifth-1000"></div>
<div class="flex one half fifth-1000" style="height: 100%">
<div class="loginSpacer"></div>
@@ -26,14 +26,20 @@
</div>
<div id="mainPage" style="display: none;">
<div id="content">
<div id="tasks"></div>
<div id="history"></div>
<div id="addTask"></div>
<div id="tasks" class="screen" style="">Tasks</div>
<div id="history" class="screen" style="display: none;">History</div>
<div id="addTask" class="screen" style="display: none;">Add Task</div>
</div>
<div id="menu" class="flex three">
<button class="third">Tasks</button>
<button class="third">History</button>
<button class="third">Add Task</button>
<div id="menu" class="flex three demo">
<div class="third" id="taskButton">
<span class="button" onclick="switchScreen('task')">Tasks</span>
</div>
<div class="third" id="historyButton">
<span class="button" onclick="switchScreen('history')">History</span>
</div>
<div class="third" id="addButton">
<span class="button" onclick="switchScreen('add')" >Add Task</span>
</div>
</div>
</div>
</body>

View File

@@ -1,4 +1,6 @@
async function login() {
// tell the user the app is loading
document.getElementById("loginSubmit").value = "Loading";
// this.preventDefault();
// get login details
let name = document.getElementById("name").value;
@@ -18,9 +20,38 @@ async function login() {
// else switch screen
if (response.status !== 200) {
document.getElementById("loginSubmit").classList.add("error");
document.getElementById("loginSubmit").value = "Failed";
return;
} else {
// switch screen
document.getElementById("login").setAttribute("style", "display: none;");
document.getElementById("mainPage").setAttribute("style", "");
}
// store user data in session storage
let data = await response.json();
sessionStorage.setItem("name", data.name);
sessionStorage.setItem("role", data.role);
// if role is admin, keep auto styling
if (sessionStorage.getItem("role") !== "admin") {
document.getElementById("addButton").setAttribute("style", "display: none;");
document.getElementById("taskButton").classList.value = "half";
document.getElementById("historyButton").classList.value = "half";
document.getElementById("menu").classList.value = "flex two";
}
}
function switchScreen(button) {
document.getElementById("tasks").setAttribute("style", "display: none;");
document.getElementById("history").setAttribute("style", "display: none;");
document.getElementById("addTask").setAttribute("style", "display: none;");
if (button === "task") {
document.getElementById("tasks").setAttribute("style", "");
} else if (button === "history") {
document.getElementById("history").setAttribute("style", "");
} else if (button === "add") {
document.getElementById("addTask").setAttribute("style", "");
}
}

6
go.mod
View File

@@ -2,7 +2,10 @@ module giacPoints
go 1.20
require github.com/gin-gonic/gin v1.9.1
require (
github.com/gin-gonic/gin v1.9.1
github.com/mattn/go-sqlite3 v1.14.17
)
require (
github.com/bytedance/sonic v1.9.1 // indirect
@@ -19,7 +22,6 @@ require (
github.com/kr/pretty v0.3.1 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect

BIN
main

Binary file not shown.

View File

@@ -162,6 +162,8 @@ func addTask(c *gin.Context) {
}
func main() {
//release mode
//gin.SetMode(gin.ReleaseMode)
router := gin.Default()
// api routes