Move static files into html/ for Docker bind mount
This commit is contained in:
48
html/feedback-config.js
Normal file
48
html/feedback-config.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/* ──────────────────────────────────────────────────────────────────────────
|
||||
CENTRAL FEEDBACK CONFIGURATION
|
||||
----------------------------------------------------------------------------
|
||||
By default the suite stores all feedback in each user's own browser
|
||||
(localStorage) and reviewers share it via Export / Import. That needs no
|
||||
server and works behind any firewall.
|
||||
|
||||
To ALSO collect feedback automatically into one central place, set
|
||||
FEEDBACK_ENDPOINT below to a URL that accepts an HTTP POST of JSON. This
|
||||
works with either:
|
||||
• a small backend on your host (Node/PHP/Python/ASP.NET) that appends the
|
||||
body to a feedback.json / .csv you can download, or
|
||||
• a Microsoft Power Automate "When an HTTP request is received" trigger
|
||||
that writes to a SharePoint list / Excel table.
|
||||
|
||||
Leave it as an empty string to stay fully local (export/import only).
|
||||
See DEPLOYMENT.md for setup details and sample receivers.
|
||||
|
||||
This is set to the same-origin path '/api/feedback', which the NGINX reverse
|
||||
proxy (see nginx-wp-suite.conf) forwards to the Power Automate HTTP trigger.
|
||||
Keeping it relative means no CORS and the secret trigger URL never appears in
|
||||
client code. Locally (no proxy) the POST simply fails silently and feedback is
|
||||
still saved/exported from the browser.
|
||||
────────────────────────────────────────────────────────────────────────── */
|
||||
window.FEEDBACK_ENDPOINT = '/api/feedback';
|
||||
|
||||
/* Best-effort send to the central endpoint. Never throws and never blocks the
|
||||
UI: feedback is always saved locally first by the caller, so a failed or
|
||||
disabled POST simply means "not centrally collected." Returns a Promise that
|
||||
resolves true on success, false otherwise. */
|
||||
window.postFeedback = function (payload) {
|
||||
if (!window.FEEDBACK_ENDPOINT) return Promise.resolve(false);
|
||||
try {
|
||||
return fetch(window.FEEDBACK_ENDPOINT, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
app: 'Work Package Suite',
|
||||
page: (typeof location !== 'undefined' && location.pathname) || '',
|
||||
submittedAt: new Date().toISOString(),
|
||||
...payload
|
||||
}),
|
||||
keepalive: true // allow the send to complete even if the page unloads
|
||||
}).then(function (r) { return r.ok; }).catch(function () { return false; });
|
||||
} catch (e) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user