fix(docker): fix configuration endpoint, add configuration export (@fehmer) (#6317)

- fixes /configure endpoint not working in docker image because of the
missing `private` directory
- adds `export configuration` button to api server configuration
This commit is contained in:
Christian Fehmer 2025-02-27 10:48:59 +01:00 committed by GitHub
parent 41b02155f2
commit 642c03abdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 36 additions and 4 deletions

View file

@ -2,4 +2,5 @@ backend/dist
backend/__migration__
docker
backend/scripts
backend/private
**/vitest.config.js

View file

@ -55,6 +55,7 @@
<span id="form-loader" class="loader"></span>
</div>
<div id="save">Save Changes</div>
<div id="export">Export Configuration</div>
<script src="script.js"></script>
</body>
</html>

View file

@ -281,4 +281,27 @@ window.onload = async () => {
saveButton.disabled = false;
}, 3000);
});
const exportButton = document.querySelector("#export");
exportButton.addEventListener("click", async () => {
download(
"backend-configuration.json",
JSON.stringify({ configuration: state })
);
});
};
function download(filename, text) {
let element = document.createElement("a");
element.setAttribute(
"href",
"data:text/plain;charset=utf-8," + encodeURIComponent(text)
);
element.setAttribute("download", filename);
element.style.display = "none";
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}

View file

@ -74,7 +74,8 @@ body {
background-color: #d84b4b;
}
#save {
#save,
#export {
position: fixed;
right: 6rem;
bottom: 3rem;
@ -90,7 +91,12 @@ body {
transition: 0.125s;
}
#save:hover {
#export {
bottom: 9rem;
}
#save:hover,
#export:hover {
background-color: var(--text-color);
color: var(--bg-color);
}

View file

@ -29,6 +29,7 @@ COPY --from=builder /prod/backend/node_modules /app/backend/node_modules
COPY --from=builder /prod/backend/dist /app/backend/dist
COPY --from=builder /prod/backend/email-templates /app/backend/email-templates
COPY --from=builder /prod/backend/redis-scripts /app/backend/redis-scripts
COPY --from=builder /prod/backend/private /app/backend/private
## to build directory
WORKDIR /app/backend/dist

View file

@ -168,8 +168,8 @@ If you don't want to update this file manually you can
- open the backend url in your browser, e.g. `http://localhost:5005/configure/`
- adjust the settings and click `Save Changes`
- open the configuration in your browser, e.g. `http://localhost:5005/configuration`
- copy everything from `data` into the `backend-configuration.json` file.
- click `Export Configuration`
- save the file as `backend-configuration.json`, overwriting the existing one.
Example output from `http://localhost:5005/configuration`:
```json