this codebase is kindof a mess now
This commit is contained in:
@@ -43,14 +43,14 @@ app.get("/api/auth/logout", (rreq,rres) => {
|
||||
if (dbRes.count > 0) {
|
||||
rres.send("Success")
|
||||
} else {
|
||||
rres.status(400).send("Error: Token does not exist.")
|
||||
rres.status(400).send("Token does not exist.")
|
||||
}
|
||||
}).catch(dbErr => {
|
||||
logRequest(rres,rreq,500,dbErr)
|
||||
rres.status(500).send("Error: Exception occured while invalidating token, details: "+dbErr)
|
||||
rres.status(500).send("Exception occured while invalidating token, details: "+dbErr)
|
||||
})
|
||||
} else {
|
||||
rres.status(400).send("Error: Missing token or authorization header, you may not be logged in.")
|
||||
rres.status(400).send("Missing token or authorization header, you may not be logged in.")
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -8,4 +8,12 @@ app.get("/helpdesk/articles/*", (rreq, rres) => {
|
||||
rres.sendFile(process.cwd()+"/website/helpdesk/kbas/"+rreq.url.replace("/helpdesk/articles/",""))
|
||||
})
|
||||
|
||||
app.get("/helpdesk/ticket/new", (rreq,rres) => {
|
||||
rres.sendFile(process.cwd()+"/website/helpdesk/templates/newticket.html")
|
||||
})
|
||||
|
||||
app.get("/api/helpdesk/forms/*", (rreq, rres) => {
|
||||
rres.sendFile(process.cwd()+"/website/helpdesk/forms/"+rreq.url.replace("/api/helpdesk/forms/",""))
|
||||
})
|
||||
|
||||
export { app }
|
||||
10
website/helpdesk/forms/manifest.json
Normal file
10
website/helpdesk/forms/manifest.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"general_inquiry": "General Inquiry",
|
||||
"legalrequest": "Legal Request",
|
||||
"responsibledisclosure": "Responsible Disclosure",
|
||||
"general_techsupport": "General Technical Support",
|
||||
"ecls_deleteaccount": "ECLS: Delete Account",
|
||||
"ecls_passwordreset": "ECLS: Password Reset",
|
||||
"ecls_personalinfochange": "ECLS: Personal Information Change",
|
||||
"enstrayedcloud_quotachange": "Enstrayed Cloud: Quota Change"
|
||||
}
|
||||
@@ -4,30 +4,8 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Enstrayed Helpdesk</title>
|
||||
<link rel="stylesheet" href="/static/helpdesk.css">
|
||||
<script>
|
||||
var globalLoggedIn = false
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
fetch(`/api/auth/whoami`).then(fetchRes => {
|
||||
fetchRes.json().then(jsonRes => {
|
||||
if (jsonRes.loggedIn) {
|
||||
globalLoggedIn = true
|
||||
document.getElementById("loginButton").innerText = `Logout ${jsonRes.username}`
|
||||
} else {
|
||||
globalLoggedIn = false
|
||||
document.getElementById("loginButton").innerText = `Login`
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
function loginFunction() {
|
||||
if (globalLoggedIn === true) {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="/static/helpdesk/helpdesk.css">
|
||||
<script src="/static/helpdesk/login.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -88,9 +66,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<dialog id="globalDialog">
|
||||
<h2>Warning</h2>
|
||||
<p>This is a warning</p>
|
||||
<button>woag</button>
|
||||
<h2 id="globalDialogHeader">Warning</h2>
|
||||
<p id="globalDialogText">This is a warning</p>
|
||||
<button onclick="document.getElementById('globalDialog').close()">Dismiss</button>
|
||||
</dialog>
|
||||
</body>
|
||||
</html>
|
||||
56
website/helpdesk/templates/newticket.html
Normal file
56
website/helpdesk/templates/newticket.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Enstrayed Helpdesk: New Ticket</title>
|
||||
<link rel="stylesheet" href="/static/helpdesk/helpdesk.css">
|
||||
<script src="/static/helpdesk/login.js"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.getElementById('formSelection').value = 'none'
|
||||
document.getElementById('formSelection').addEventListener('change', function() {
|
||||
useGlobalDialog(`Info`, `You selected ${this.value}`)
|
||||
})
|
||||
|
||||
fetch(`/api/helpdesk/forms/manifest.json`).then(fetchRes => {
|
||||
fetchRes.json().then(jsonRes => {
|
||||
for (let x in jsonRes) {
|
||||
let newElement = document.createElement('option')
|
||||
newElement.value = x
|
||||
newElement.textContent = jsonRes[x]
|
||||
document.getElementById('formSelection').appendChild(newElement)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="headerbar">
|
||||
<h1>Enstrayed Helpdesk</h1>
|
||||
<a href="/helpdesk">Main Page</a>
|
||||
<a href="/helpdesk/articles">Knowledgebase</a>
|
||||
|
||||
<div class="headerbarright">
|
||||
<button id="loginButton" onclick="loginFunction()">Login</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="maincontent">
|
||||
<div class="newticketmaincontent">
|
||||
<h2>New Ticket</h2>
|
||||
<label for="formSelection">Please select a form: </label>
|
||||
<select name="Form Selection" id="formSelection">
|
||||
<option value="none" disabled selected>-- Choose From List --</option>
|
||||
</select>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
<dialog id="globalDialog">
|
||||
<h2 id="globalDialogHeader">Warning</h2>
|
||||
<p id="globalDialogText">This is a warning</p>
|
||||
<button onclick="document.getElementById('globalDialog').close()">Dismiss</button>
|
||||
</dialog>
|
||||
</body>
|
||||
</html>
|
||||
@@ -37,11 +37,16 @@ body {
|
||||
gap: 2em;
|
||||
}
|
||||
|
||||
.cardrow > div {
|
||||
.cardrow > div, .newticketmaincontent {
|
||||
background-color: #fff;
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.newticketmaincontent {
|
||||
min-width: 80ch;
|
||||
max-width: 80ch;
|
||||
}
|
||||
|
||||
.cardrow > div > h1 {
|
||||
margin: 0 0 0.5em 0;
|
||||
}
|
||||
@@ -65,7 +70,7 @@ dialog {
|
||||
border: none;
|
||||
}
|
||||
|
||||
dialog > h2 {
|
||||
dialog > h2, .newticketmaincontent > h2 {
|
||||
margin: 0 0 0.5em 0;
|
||||
}
|
||||
|
||||
54
website/static/helpdesk/login.js
Normal file
54
website/static/helpdesk/login.js
Normal file
@@ -0,0 +1,54 @@
|
||||
var globalLoggedIn = false
|
||||
|
||||
function useGlobalDialog(title,body) {
|
||||
document.getElementById("globalDialogHeader").innerText = title
|
||||
document.getElementById("globalDialogText").innerText = body
|
||||
document.getElementById("globalDialog").showModal()
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
fetch(`/api/auth/whoami`).then(fetchRes => {
|
||||
fetchRes.json().then(jsonRes => {
|
||||
if (jsonRes.loggedIn) {
|
||||
globalLoggedIn = true
|
||||
document.getElementById("loginButton").innerText = `Logout ${jsonRes.username}`
|
||||
} else {
|
||||
globalLoggedIn = false
|
||||
document.getElementById("loginButton").innerText = `Login`
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
function loginFunction() {
|
||||
if (globalLoggedIn === true) {
|
||||
fetch(`/api/auth/logout`).then(fetchRes => {
|
||||
if (fetchRes.status === 200) {
|
||||
globalLoggedIn = false
|
||||
document.getElementById("loginButton").innerText = `Login`
|
||||
} else {
|
||||
fetchRes.text().then(textRes => {
|
||||
useGlobalDialog("Error", `An error occurred during logout: ${textRes}`)
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
let loginWindow = window.open(`/api/auth/login?state=close`, `_blank`)
|
||||
let loginWatcher = setInterval(() => {
|
||||
if (loginWindow.closed) {
|
||||
fetch(`/api/auth/whoami`).then(fetchRes => {
|
||||
fetchRes.json().then(jsonRes => {
|
||||
if (jsonRes.loggedIn) {
|
||||
globalLoggedIn = true
|
||||
document.getElementById("loginButton").innerText = `Logout ${jsonRes.username}`
|
||||
} else {
|
||||
useGlobalDialog("Error", `You are not logged in. Please try logging in again.`)
|
||||
}
|
||||
clearInterval(loginWatcher);
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user