mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-30 01:35:32 +00:00
Reworked Publish View
This commit is contained in:
@@ -37,16 +37,9 @@
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<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">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>
|
||||
<a class="ha-publishbutton" asp-controller="Upload" asp-action="Index" asp-route-id="@string.Empty">
|
||||
<div class="ha-publishtext">Veröffentlichen</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -82,6 +75,10 @@
|
||||
|
||||
@* Start Page File List *@
|
||||
else {
|
||||
<div class="ha-publishfilelist">
|
||||
@await Html.PartialAsync("/Views/Shared/_PublishForm.cshtml", Model)
|
||||
</div>
|
||||
|
||||
<div class="ha-hamannfilechooser">
|
||||
@await Html.PartialAsync("/Views/Shared/_FileList.cshtml", (Model.HamannFiles, "Verfügbare Hamann-Dateien", "API", "SetUsedHamann", string.Empty, "/Download/XML/", false))
|
||||
</div>
|
||||
@@ -110,7 +107,6 @@ else {
|
||||
"use strict";
|
||||
const hideshowfiles = function() {
|
||||
let elem = document.getElementById("ha-availablefileslist");
|
||||
console.log("hello!");
|
||||
if (elem.classList.contains('hidden')) {
|
||||
|
||||
elem.classList.remove('hidden');
|
||||
@@ -147,39 +143,6 @@ else {
|
||||
ev.preventDefault();
|
||||
}
|
||||
|
||||
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!";
|
||||
})
|
||||
}
|
||||
|
||||
const UPLOADSubmit = async function (oFormElement, file = null) {
|
||||
var fd = new FormData();
|
||||
if (file !== null) fd.append("file", file);
|
||||
@@ -230,12 +193,11 @@ else {
|
||||
var submitelement = document.getElementById("file");
|
||||
var formelement = document.getElementById("uploadForm");
|
||||
var dropzone = document.getElementById("dropzone");
|
||||
var publishelement = document.getElementById("ha-publishform");
|
||||
var publishbutton = document.getElementById("ha-publishfilelabel");
|
||||
|
||||
var filesbutton = document.getElementById("ha-availablefiles");
|
||||
if (filesbutton !== null)
|
||||
filesbutton.addEventListener("click", () => hideshowfiles());
|
||||
publishbutton.addEventListener("click", () => LOCALPUBLISHSubmit(publishelement));
|
||||
|
||||
submitelement.addEventListener("change", () => UPLOADSubmit(formelement));
|
||||
dropzone.addEventListener("drop", (ev) => dropHandler(formelement, ev, dropzone));
|
||||
dropzone.addEventListener("dragover", (ev) => dragOverHandler(ev, dropzone));
|
||||
|
||||
@@ -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