Files
sera-new-hp/src-manager/pages/update-gallery-image.html

67 lines
2.4 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Content Manager - update gallery image</title>
<script src="https://unpkg.com/htmx.org@2.0.2" integrity="sha384-Y7hw+L/jvKeWIRRkqWYfPcvVxHzVzn5REgzbawhxAuQGwX1XWe70vji+VSeHOThJ" crossorigin="anonymous"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<style>
form fieldset {
display: grid;
grid-auto-flow: row;
}
#new-news {
display: grid;
grid-template-columns: 1fr 1fr;
}
#preview {
border: black solid 1px;
height: 100%;
}
</style>
</head>
<body>
<div id="new-gallery-image">
<h3></h3>
<form id="create-entry" hx-put="/api/gallery-image" hx-swap="none">
<fieldset>
<legend>Create Entry</legend>
<label for="imagePath">Image Path:</label>
<input type="text" name="imagePath" id="imagePath">
<label for="caption">Caption of Image:</label>
<input type="text" name="caption" id="caption">
<input type="hidden" name="target" id="targetValue" value="test">
</fieldset>
<button id="submit-button" type="submit">Update Entry</button>
<a href="/index.html">
<button role="none" type="button">
Cancel
</button>
</a>
</form>
</div>
<script>
const submitButton = document.getElementById('submit-button');
const imagePathInput = document.getElementById('imagePath');
const captionInput = document.getElementById('caption');
const targetInput = document.getElementById('targetValue');
const urlParams = new URLSearchParams(window.location.search);
const targetEntry = urlParams.get('target');
axios.get('/api/gallery-image', {params: {target: targetEntry}})
.then((response) => {
targetInput.value = response.data.id;
imagePathInput.value = response.data.imagePath;
captionInput.value = response.data.caption;
})
.catch((err) => {console.error(err)});
submitButton.addEventListener('click', () => {
window.location.href = "/index.html";
});
</script>
</body>