mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-30 17:55:32 +00:00
Reworked Publish View
This commit is contained in:
@@ -37,11 +37,11 @@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<input class="btn ha-filelistbutton" type="submit" value="Laden" />
|
||||
<output id ="ha-filelistoutput"></output><input class="btn ha-filelistbutton" type="submit" value="Laden" />
|
||||
</form>
|
||||
}
|
||||
else {
|
||||
<div>Keine Hamann-Dateien gefunden! Es wird eine fallback-Datei verwendet!</div>
|
||||
<div>Keine Dateien gefunden! Es wird eine fallback-Datei verwendet!</div>
|
||||
}
|
||||
</fieldset>
|
||||
|
||||
@@ -58,14 +58,16 @@
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
if ("Error" in json) {
|
||||
|
||||
document.getElementById("ha-filelistoutput").textContent = json.Error;
|
||||
}
|
||||
else {
|
||||
location.reload();
|
||||
}
|
||||
})
|
||||
.catch ((e) => {
|
||||
location.reload();
|
||||
document.getElementById("ha-filelistoutput").textContent = e;
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
76
HaWeb/Views/Shared/_PublishForm.cshtml
Normal file
76
HaWeb/Views/Shared/_PublishForm.cshtml
Normal file
@@ -0,0 +1,76 @@
|
||||
@model UploadViewModel;
|
||||
@if (Model.UsedFiles != null && Model.UsedFiles.Any()) {
|
||||
<div class="ha-publishfilelisttitle">Aktuell geladene Dateien</div>
|
||||
<table class="ha-publishfilelistlist">
|
||||
@foreach (var (category, files) in Model.UsedFiles.OrderBy(x => x.Key))
|
||||
{
|
||||
<tr>
|
||||
<td>@Model.AvailableRoots.Where(x => x.Prefix == category).First().Type:</td>
|
||||
<td>
|
||||
@foreach (var item in files)
|
||||
{
|
||||
if (item != files.Last()) {
|
||||
<span>@item.FileName,</span>
|
||||
}
|
||||
else {
|
||||
<span>@item.FileName</span>
|
||||
}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
|
||||
<form class="ha-publishform" id="ha-publishform" asp-controller="API" asp-action="LocalPublish" method="post" enctype="multipart/form-data">
|
||||
<label class="ha-publishfilelabel" id="ha-publishfilelabel">
|
||||
<div class="ha-publishtext">Dateien Veröffentlichen</div>
|
||||
<div class="ha-lds-ellipsis" id="ha-lds-ellipsis-publish"><div></div><div></div><div></div><div></div></div>
|
||||
</label>
|
||||
<div class="ha-publishmessage" id="ha-publishmessage">
|
||||
@* Fehler!<br/> *@
|
||||
<output form="uploadForm" name="publish-result" id="publish-result"></output>
|
||||
</div>
|
||||
</form>
|
||||
}
|
||||
|
||||
<script>
|
||||
const LOCALPUBLISHSubmit = async function (oFormElement) {
|
||||
var fd = new FormData();
|
||||
document.getElementById("ha-publishfilelabel").style.pointerEvents = "none";
|
||||
document.getElementById("ha-lds-ellipsis-publish").style.display = "inline-block";
|
||||
document.getElementById("ha-publishmessage").style.opacity = "0";
|
||||
await fetch(oFormElement.action, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'RequestVerificationToken': getCookie('RequestVerificationToken')
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
if ("Error" in json) {
|
||||
document.getElementById("ha-publishfilelabel").style.pointerEvents = "auto";
|
||||
document.getElementById("ha-lds-ellipsis-publish").style.display = "none";
|
||||
document.getElementById("ha-publishmessage").style.opacity = "1";
|
||||
document.getElementById("publish-result").value = json.Error;
|
||||
} else {
|
||||
document.getElementById("ha-publishfilelabel").style.pointerEvents = "auto";
|
||||
document.getElementById("ha-lds-ellipsis-publish").style.display = "none";
|
||||
document.getElementById("ha-publishmessage").style.opacity = "1";
|
||||
document.getElementById("publish-result").value = "Erfolg!";
|
||||
window.location.replace("/Admin/Upload/");
|
||||
}
|
||||
})
|
||||
.catch ((e) => {
|
||||
document.getElementById("ha-publishfilelabel").style.pointerEvents = "auto";
|
||||
document.getElementById("ha-lds-ellipsis-publish").style.display = "none";
|
||||
document.getElementById("publish-result").value = "Keine Antwort. Bitte Seite neu laden!";
|
||||
})
|
||||
}
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
var publishelement = document.getElementById("ha-publishform");
|
||||
var publishbutton = document.getElementById("ha-publishfilelabel");
|
||||
publishbutton.addEventListener("click", () => LOCALPUBLISHSubmit(publishelement));
|
||||
})
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user