diff --git a/static/issue.html b/static/issue.html index 6d84303..6715f1c 100644 --- a/static/issue.html +++ b/static/issue.html @@ -7,12 +7,20 @@ + - + + OwlBoard - Report + +
+
+
+

Loading

+
@@ -23,13 +31,22 @@ OwlBoard Logo

Report an Issue

-

This page's functionality is not yet implemented.

-
+

To help diagnosing an issue, data about your browser and device will be + collected alongside the data that you enter below.

+

The data will be available publically in the + OwlBoard Issue Tracker. A preview will be shown before the data is sent.




-
- -
+
+ +
+

Check & Send

+

---

+

+

+ + +
\ No newline at end of file diff --git a/static/js/issue.js b/static/js/issue.js new file mode 100644 index 0000000..89fdd4c --- /dev/null +++ b/static/js/issue.js @@ -0,0 +1,77 @@ +init(); + +async function init() { + hideLoading() +} + +async function submit() { + setLoadingDesc("Collecting\nData") + showLoading() + var browserData = await getBrowserData(); + setLoadingDesc("Reading\nForm") + var formData = await getFormData(); + preflight({browserData: browserData, formData: formData}) +} + +async function getFormData() { + let data = {} + data.subject = document.getElementById("subject").value + data.message = document.getElementById("message").value + return data +} + +async function getBrowserData() { + let data = {} + data.userAgent = navigator.userAgent + data.userAgentData = JSON.stringify(navigator.userAgentData) + data.localStorage = JSON.stringify(await storageAvailable('localStorage')) + data.sessionStorage = JSON.stringify(await storageAvailable('sessionStorage')) + data.viewport = `${window.innerWidth} x ${window.innerHeight}` + return data +} + +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}` + document.getElementById("pre_message").innerText = pre_msg + hideLoading() + document.getElementById("preflight").style = "display: block" + sessionStorage.setItem("preflight_subject", data.formData.subject) + sessionStorage.setItem("preflight_msg", pre_msg) +} + +async function cancel() { + document.getElementById("preflight").style = "display: none" +} + +async function send() { + setLoadingDesc("Sending\nData") + showLoading() + var subject = sessionStorage.getItem("preflight_subject"); + var msg = sessionStorage.getItem("preflight_msg") + if (typeof subject != "string") { + subject = document.getElementById("preflight_subject").innerText + } + if (typeof msg != "string") { + msg = document.getElementById("preflight_msg") + } + var payload = JSON.stringify({subject: subject, msg: msg}) + console.log(payload); + let opt = { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, + redirect: 'follow', + body: payload + } + await fetch("/api/v1/issue", opt) + hideLoading(); +} \ No newline at end of file diff --git a/static/js/settings.js b/static/js/settings.js index 9db69e6..99b5f89 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -42,6 +42,7 @@ async function clearQl(){ getQl() await hideLoading(); await showDone(); + navigator.vibrate(500); await delay(600); hideDone(); } diff --git a/static/styles/issue.css b/static/styles/issue.css new file mode 100644 index 0000000..b59d231 --- /dev/null +++ b/static/styles/issue.css @@ -0,0 +1,20 @@ +#preflight { + display: none; + border-radius: 20px; + width: 93%; + max-height: 80%; + position: fixed; + z-index: 10; + top: 50px; + left: 0; + margin: 2%; + padding-top: 30px; + padding-left: 5px; + padding-right: 5px; + padding-bottom: 10px; + margin-bottom: 25px; + background-color: var(--overlay-color); + color: var(--second-text-color); + overflow: auto; +} +