FullStack: Add response to issue API
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
8213eacde5
commit
bbdaf4308a
@ -4,7 +4,6 @@
|
||||
|
||||
* Alerts box should not be clickable, bar should be.
|
||||
* Issue page: Captcha.
|
||||
* Issue page: Check for success and then redirect to /.
|
||||
* Enable text search for `locationName` on find-code page.
|
||||
* Responsive text sizes for boards.
|
||||
|
||||
@ -19,7 +18,10 @@
|
||||
* Implement error pages.
|
||||
* Issue page: Submit using API.
|
||||
* Issue page: Collect diagnostics such as browser features etc.
|
||||
* Add sanitizing to Gitea Issue API, currently considered to be unsafe.
|
||||
* Add Gitea Issue API
|
||||
* Issue page: Check for success and then redirect to /.
|
||||
* Add success test for Gitea Issue API and send the result onto the client.
|
||||
|
||||
|
||||
## Backend:
|
||||
@ -27,7 +29,5 @@
|
||||
* DB Indexes:
|
||||
- "stations": 3ALPHA, STANOX, TIPLOC
|
||||
- "corpus": 3ALPHA, NLC, NLCDESC(TEXT)
|
||||
* Add sanitizing to Gitea Issue API, currently considered to be unsafe.
|
||||
* Add success test for Gitea Issue API and send the result onto the client.
|
||||
* Rewrite sanitizing functions to remove external dependancy.
|
||||
* Undo changed to make everything an array - frontend code to handle this.
|
@ -1,15 +1,10 @@
|
||||
const axios = require('axios')
|
||||
const clean = require('../utils/sanitizer.utils')
|
||||
|
||||
async function processor(data) {
|
||||
let out = {}
|
||||
out.title = await cleanData(data.subject)
|
||||
out.body = await cleanData(data.msg)
|
||||
out.title = data.subject.replace(/<[^>]+>|[\*\$]/g, '');
|
||||
out.body = data.msg.replace(/<[^>]+>|[\*\$]/g, '')
|
||||
sendToGitea(out);
|
||||
}
|
||||
|
||||
async function cleanData(data) {
|
||||
return data //clean.cleanApiEndpointTxt(data)
|
||||
}
|
||||
|
||||
async function sendToGitea(body) {
|
||||
@ -20,8 +15,13 @@ async function sendToGitea(body) {
|
||||
Authorization: key
|
||||
}
|
||||
}
|
||||
await axios.post(url, body, opts)
|
||||
var res = await axios.post(url, body, opts)
|
||||
// Need to read the output from the POST and pass the result upwards to the client.
|
||||
if (res.status == 201) {
|
||||
return {status: res.status,message:"issue created"}
|
||||
} else {
|
||||
return {status: res.status,message:"issue not created"}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
@ -33,12 +33,11 @@ async function getBrowserData() {
|
||||
async function preflight(data) {
|
||||
document.getElementById("pre_subject").textContent = data.formData.subject
|
||||
pre_msg = `UserAgent: ${data.browserData.userAgent}
|
||||
\nUserAgentData: ${data.browserData.userAgentData}
|
||||
\nlocalStorage Avail: ${data.browserData.localStorage}
|
||||
\nsessionStorage Avail: ${data.browserData.sessionStorage}
|
||||
\nViewport size: ${data.browserData.viewport}
|
||||
\nUser message:\n
|
||||
${data.formData.message}`
|
||||
\nUserAgentData: ${data.browserData.userAgentData}
|
||||
\nlocalStorage Avail: ${data.browserData.localStorage}
|
||||
\nsessionStorage Avail: ${data.browserData.sessionStorage}
|
||||
\nViewport size: ${data.browserData.viewport}
|
||||
\nUser message:\n\n${data.formData.message}`
|
||||
document.getElementById("pre_message").innerText = pre_msg
|
||||
hideLoading()
|
||||
document.getElementById("preflight").style = "display: block"
|
||||
@ -73,6 +72,16 @@ async function send() {
|
||||
redirect: 'follow',
|
||||
body: payload
|
||||
}
|
||||
await fetch("/api/v1/issue", opt)
|
||||
hideLoading();
|
||||
var res = await fetch("/api/v1/issue", opt)
|
||||
if (res.status == 200) {
|
||||
setLoadingDesc("Success")
|
||||
await delay(2500)
|
||||
window.location.replace("/")
|
||||
} else {
|
||||
setLoadingDesc("Error")
|
||||
navigator.vibrate(1500)
|
||||
await delay(2500)
|
||||
hideLoading()
|
||||
document.getElementById("preflight").style = "display: none;"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user