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.
|
* Alerts box should not be clickable, bar should be.
|
||||||
* Issue page: Captcha.
|
* Issue page: Captcha.
|
||||||
* Issue page: Check for success and then redirect to /.
|
|
||||||
* Enable text search for `locationName` on find-code page.
|
* Enable text search for `locationName` on find-code page.
|
||||||
* Responsive text sizes for boards.
|
* Responsive text sizes for boards.
|
||||||
|
|
||||||
@ -19,7 +18,10 @@
|
|||||||
* Implement error pages.
|
* Implement error pages.
|
||||||
* Issue page: Submit using API.
|
* Issue page: Submit using API.
|
||||||
* Issue page: Collect diagnostics such as browser features etc.
|
* Issue page: Collect diagnostics such as browser features etc.
|
||||||
|
* Add sanitizing to Gitea Issue API, currently considered to be unsafe.
|
||||||
* Add Gitea Issue API
|
* 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:
|
## Backend:
|
||||||
@ -27,7 +29,5 @@
|
|||||||
* DB Indexes:
|
* DB Indexes:
|
||||||
- "stations": 3ALPHA, STANOX, TIPLOC
|
- "stations": 3ALPHA, STANOX, TIPLOC
|
||||||
- "corpus": 3ALPHA, NLC, NLCDESC(TEXT)
|
- "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.
|
* Rewrite sanitizing functions to remove external dependancy.
|
||||||
* Undo changed to make everything an array - frontend code to handle this.
|
* Undo changed to make everything an array - frontend code to handle this.
|
@ -1,17 +1,12 @@
|
|||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const clean = require('../utils/sanitizer.utils')
|
|
||||||
|
|
||||||
async function processor(data) {
|
async function processor(data) {
|
||||||
let out = {}
|
let out = {}
|
||||||
out.title = await cleanData(data.subject)
|
out.title = data.subject.replace(/<[^>]+>|[\*\$]/g, '');
|
||||||
out.body = await cleanData(data.msg)
|
out.body = data.msg.replace(/<[^>]+>|[\*\$]/g, '')
|
||||||
sendToGitea(out);
|
sendToGitea(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function cleanData(data) {
|
|
||||||
return data //clean.cleanApiEndpointTxt(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function sendToGitea(body) {
|
async function sendToGitea(body) {
|
||||||
let key = process.env.OWL_GIT_ISSUEBOT
|
let key = process.env.OWL_GIT_ISSUEBOT
|
||||||
let url = process.env.OWL_GIT_APIENDPOINT
|
let url = process.env.OWL_GIT_APIENDPOINT
|
||||||
@ -20,8 +15,13 @@ async function sendToGitea(body) {
|
|||||||
Authorization: key
|
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.
|
// 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 = {
|
module.exports = {
|
||||||
|
@ -33,12 +33,11 @@ async function getBrowserData() {
|
|||||||
async function preflight(data) {
|
async function preflight(data) {
|
||||||
document.getElementById("pre_subject").textContent = data.formData.subject
|
document.getElementById("pre_subject").textContent = data.formData.subject
|
||||||
pre_msg = `UserAgent: ${data.browserData.userAgent}
|
pre_msg = `UserAgent: ${data.browserData.userAgent}
|
||||||
\nUserAgentData: ${data.browserData.userAgentData}
|
\nUserAgentData: ${data.browserData.userAgentData}
|
||||||
\nlocalStorage Avail: ${data.browserData.localStorage}
|
\nlocalStorage Avail: ${data.browserData.localStorage}
|
||||||
\nsessionStorage Avail: ${data.browserData.sessionStorage}
|
\nsessionStorage Avail: ${data.browserData.sessionStorage}
|
||||||
\nViewport size: ${data.browserData.viewport}
|
\nViewport size: ${data.browserData.viewport}
|
||||||
\nUser message:\n
|
\nUser message:\n\n${data.formData.message}`
|
||||||
${data.formData.message}`
|
|
||||||
document.getElementById("pre_message").innerText = pre_msg
|
document.getElementById("pre_message").innerText = pre_msg
|
||||||
hideLoading()
|
hideLoading()
|
||||||
document.getElementById("preflight").style = "display: block"
|
document.getElementById("preflight").style = "display: block"
|
||||||
@ -73,6 +72,16 @@ async function send() {
|
|||||||
redirect: 'follow',
|
redirect: 'follow',
|
||||||
body: payload
|
body: payload
|
||||||
}
|
}
|
||||||
await fetch("/api/v1/issue", opt)
|
var res = await fetch("/api/v1/issue", opt)
|
||||||
hideLoading();
|
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