mirror of
				https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
				synced 2025-10-29 09:15:33 +00:00 
			
		
		
		
	Added Models for displaying files and all kinds of stuff
This commit is contained in:
		| @@ -169,6 +169,25 @@ public class APIController : Controller { | ||||
|         _ = _lib.SetLibrary(savedfile.PhysicalPath, ModelState); | ||||
|         if (!ModelState.IsValid) | ||||
|             return BadRequest(ModelState); | ||||
|         return Created("/", _xmlProvider.GetHamannFiles()); | ||||
|     } | ||||
|  | ||||
|     [HttpPost] | ||||
|     [Route("API/SetUsed/{id}")] | ||||
|     [DisableFormValueModelBinding] | ||||
|     [ValidateAntiForgeryToken] | ||||
|     [FeatureGate(Features.UploadService, Features.AdminService)] | ||||
|     public async Task<IActionResult> SetUsed(string id) { | ||||
|         return Ok(); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     [HttpPost] | ||||
|     [Route("API/SetUsedHamann")] | ||||
|     [DisableFormValueModelBinding] | ||||
|     [ValidateAntiForgeryToken] | ||||
|     [FeatureGate(Features.UploadService, Features.AdminService)] | ||||
|     public async Task<IActionResult> SetUsedHamann() { | ||||
|         return Ok(); | ||||
|     } | ||||
| } | ||||
| @@ -10,6 +10,7 @@ using HaWeb.Filters; | ||||
| using HaWeb.XMLParser; | ||||
| using HaWeb.Models; | ||||
| using HaWeb.FileHelpers; | ||||
| using Microsoft.AspNetCore.Mvc.Rendering; | ||||
|  | ||||
| public class UploadController : Controller { | ||||
|     // DI | ||||
| @@ -43,28 +44,56 @@ public class UploadController : Controller { | ||||
|     [FeatureGate(Features.AdminService)] | ||||
|     [GenerateAntiforgeryTokenCookie] | ||||
|     public IActionResult Index(string? id) { | ||||
|         var roots = _xmlService.GetRootsList(); | ||||
|         if (roots == null) return error404(); | ||||
|  | ||||
|         var hF = _xmlProvider.GetHamannFiles(); | ||||
|         List<(string, DateTime)>? hamannFiles = null; | ||||
|         if (hF != null) | ||||
|             hamannFiles = hF | ||||
|                 .OrderByDescending(x => x.LastModified) | ||||
|                 .Select(x => (x.Name, x.LastModified.LocalDateTime)) | ||||
|                 .ToList(); | ||||
|          | ||||
|         var uF = _xmlService.GetUsedDictionary(); | ||||
|         var pF = _xmlService.GetInProduction(); | ||||
|  | ||||
|         Dictionary<string, List<FileModel>?>? usedFiles = null; | ||||
|         if (uF != null)  { | ||||
|             usedFiles = new Dictionary<string, List<FileModel>?>(); | ||||
|             foreach (var kv in uF) { | ||||
|                 if (kv.Value == null) continue; | ||||
|                 usedFiles.Add(kv.Key, XMLFileHelpers.ToFileModel(kv.Value, pF, uF)); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         Dictionary<string, List<FileModel>?>? productionFiles = null; | ||||
|         if (pF != null)  { | ||||
|             productionFiles = new Dictionary<string, List<FileModel>?>(); | ||||
|             foreach (var kv in pF) { | ||||
|                 if (kv.Value == null) continue; | ||||
|                 productionFiles.Add(kv.Key, XMLFileHelpers.ToFileModel(kv.Value, pF, uF)); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (id != null) { | ||||
|             id = id.ToLower(); | ||||
|  | ||||
|             var root = _xmlService.GetRoot(id); | ||||
|             if (root == null) return error404(); | ||||
|  | ||||
|             var roots = _xmlService.GetRootsList(); | ||||
|             if (roots == null) return error404(); | ||||
|  | ||||
|             var usedFiles = _xmlService.GetUsedDictionary(); | ||||
|             var availableFiles = _xmlProvider.GetFiles(id); | ||||
|  | ||||
|             var model = new UploadViewModel(root.Type, id, roots, availableFiles, usedFiles); | ||||
|              | ||||
|             var model = new UploadViewModel(root.Type, id, roots, usedFiles); | ||||
|             model.ProductionFiles = productionFiles; | ||||
|             model.HamannFiles = hamannFiles; | ||||
|             model.AvailableFiles = XMLFileHelpers.ToFileModel(_xmlProvider.GetFiles(id), pF, uF); | ||||
|              | ||||
|             return View("../Admin/Upload/Index", model); | ||||
|         } | ||||
|         else { | ||||
|             var roots = _xmlService.GetRootsList(); | ||||
|             if (roots == null) return error404(); | ||||
|             var model = new UploadViewModel("Upload", id, roots, usedFiles); | ||||
|             model.ProductionFiles = productionFiles; | ||||
|             model.HamannFiles = hamannFiles; | ||||
|  | ||||
|             var usedFiles = _xmlService.GetUsedDictionary(); | ||||
|  | ||||
|             var model = new UploadViewModel("Upload", id, roots, null, usedFiles); | ||||
|             return View("../Admin/Upload/Index", model); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -1,26 +1,43 @@ | ||||
| namespace HaWeb.FileHelpers; | ||||
| using HaDocument.Interfaces; | ||||
| using Microsoft.AspNetCore.Mvc.ModelBinding; | ||||
| using Microsoft.Extensions.FileProviders; | ||||
|  | ||||
| public class HaDocumentWrapper : IHaDocumentWrappper { | ||||
|     public ILibrary Library; | ||||
|     private ILibrary Library; | ||||
|     private IXMLProvider _xmlProvider; | ||||
|  | ||||
|     private int _startYear; | ||||
|     private int _endYear; | ||||
|  | ||||
|     public HaDocumentWrapper(IXMLProvider xmlProvider, IConfiguration configuration) { | ||||
|         _xmlProvider = xmlProvider; | ||||
|  | ||||
|         _startYear = configuration.GetValue<int>("AvailableStartYear"); | ||||
|         _endYear = configuration.GetValue<int>("AvailableEndYear"); | ||||
|  | ||||
|         var filelist = xmlProvider.GetHamannFiles(); | ||||
|         if (filelist != null && filelist.Any()) | ||||
|             _AutoLoad(filelist); | ||||
|  | ||||
|         // Use Fallback library | ||||
|         if (Library == null) | ||||
|             Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions() { AvailableYearRange = (_startYear, _endYear) }); | ||||
|  | ||||
|     public HaDocumentWrapper() { | ||||
|         Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions()); | ||||
|     } | ||||
|  | ||||
|     public ILibrary SetLibrary() { | ||||
|         Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions()); | ||||
|     public ILibrary ResetLibrary() { | ||||
|         Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions() { AvailableYearRange = (_startYear, _endYear) }); | ||||
|         return Library; | ||||
|     } | ||||
|  | ||||
|     public ILibrary? SetLibrary(string filepath, ModelStateDictionary ModelState) { | ||||
|     public ILibrary? SetLibrary(string filepath, ModelStateDictionary? ModelState = null) { | ||||
|         try  | ||||
|         { | ||||
|             Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions() { HamannXMLFilePath = filepath }); | ||||
|             Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions() { HamannXMLFilePath = filepath, AvailableYearRange = (_startYear, _endYear) }); | ||||
|         } | ||||
|         catch (Exception ex) { | ||||
|             ModelState.AddModelError("Error:", "Das Dokument konnte nicht geparst werden: " + ex.Message); | ||||
|             if (ModelState != null) ModelState.AddModelError("Error:", "Das Dokument konnte nicht geparst werden: " + ex.Message); | ||||
|             return null; | ||||
|         } | ||||
|         return Library; | ||||
| @@ -29,4 +46,11 @@ public class HaDocumentWrapper : IHaDocumentWrappper { | ||||
|     public ILibrary GetLibrary() { | ||||
|         return Library; | ||||
|     } | ||||
|  | ||||
|     private void _AutoLoad(List<IFileInfo> files) { | ||||
|         var orderdlist = files.OrderByDescending(x => x.LastModified); | ||||
|         foreach(var item in orderdlist) { | ||||
|             if (SetLibrary(item.PhysicalPath) != null) return; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -3,7 +3,7 @@ using HaDocument.Interfaces; | ||||
| using Microsoft.AspNetCore.Mvc.ModelBinding; | ||||
|  | ||||
| public interface IHaDocumentWrappper { | ||||
|     public ILibrary SetLibrary(); | ||||
|     public ILibrary ResetLibrary(); | ||||
|     public ILibrary? SetLibrary(string filepath, ModelStateDictionary ModelState); | ||||
|     public ILibrary GetLibrary(); | ||||
| } | ||||
| @@ -9,4 +9,5 @@ public interface IXMLProvider { | ||||
|         public FileList? GetFiles(string prefix); | ||||
|         public Task Save(XMLRootDocument doc, string basefilepath, ModelStateDictionary ModelState); | ||||
|         public Task<IFileInfo?> SaveHamannFile(XElement element, string basefilepath, ModelStateDictionary ModelState); | ||||
|         public List<IFileInfo>? GetHamannFiles(); | ||||
| } | ||||
| @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Http; | ||||
| using Microsoft.AspNetCore.Mvc.ModelBinding; | ||||
| using Microsoft.AspNetCore.WebUtilities; | ||||
| using Microsoft.Net.Http.Headers; | ||||
| using HaWeb.Models; | ||||
|  | ||||
| public static class XMLFileHelpers { | ||||
|     //  File Signatures Database (https://www.filesignatures.net/) | ||||
| @@ -139,6 +140,34 @@ public static class XMLFileHelpers { | ||||
|     //     return Array.Empty<byte>(); | ||||
|     // } | ||||
|  | ||||
|     public static List<FileModel>? ToFileModel(FileList? fileList, Dictionary<string, FileList?>? productionFiles = null, Dictionary<string, FileList?>? usedFiles = null) { | ||||
|         if (fileList == null) return null; | ||||
|         var fL = fileList.GetFileList(); | ||||
|         if (fL == null) return null; | ||||
|         var ret = new List<FileModel>(); | ||||
|         foreach (var f in fL) { | ||||
|             if (f.File == null) continue; | ||||
|             ret.Add(ToFileModel(f, productionFiles, usedFiles)); | ||||
|         }; | ||||
|         return ret.OrderBy(x => x.LastModified).ToList(); | ||||
|     } | ||||
|  | ||||
|     public static FileModel ToFileModel(XMLRootDocument document, Dictionary<string, FileList?>? productionFiles = null, Dictionary<string, FileList?>? usedFiles = null) { | ||||
|         string id = document.Prefix; | ||||
|  | ||||
|         bool inProduction = false; | ||||
|         if (productionFiles != null && productionFiles.ContainsKey(id)) { | ||||
|             inProduction = productionFiles[id]!.Contains(document); | ||||
|         } | ||||
|  | ||||
|         bool isUsed = false; | ||||
|         if (usedFiles != null && usedFiles.ContainsKey(id)) { | ||||
|             isUsed = usedFiles[id]!.Contains(document); | ||||
|         } | ||||
|  | ||||
|         return new FileModel(document.FileName, document.Prefix, document.File.LastModified.LocalDateTime, isUsed, inProduction) { Fields = document.Fields }; | ||||
|     } | ||||
|  | ||||
|     public static async Task<byte[]?> ProcessStreamedFile( | ||||
|         MultipartSection section, ContentDispositionHeaderValue contentDisposition, | ||||
|         ModelStateDictionary modelState, string[] permittedExtensions, long sizeLimit) { | ||||
|   | ||||
| @@ -10,11 +10,13 @@ public class XMLProvider : IXMLProvider { | ||||
|     private Dictionary<string, FileList?>? _Files; | ||||
|     private Dictionary<string, IXMLRoot>? _Roots; | ||||
|     private List<IFileInfo>? _HamannFiles; | ||||
|     private IFileInfo? _InProduction; | ||||
|  | ||||
|     public XMLProvider(IFileProvider provider, IXMLService xmlservice) { | ||||
|         _fileProvider = provider; | ||||
|         _Roots = xmlservice.GetRootsDictionary(); | ||||
|         _Files = _ScanFiles(); | ||||
|         _HamannFiles = _ScanHamannFiles(); | ||||
|  | ||||
|         if (_Files != null) | ||||
|             foreach(var category in _Files)  | ||||
| @@ -22,6 +24,8 @@ public class XMLProvider : IXMLProvider { | ||||
|                     xmlservice.AutoUse(category.Value); | ||||
|     } | ||||
|  | ||||
|     public List<IFileInfo>? GetHamannFiles() => this._HamannFiles; | ||||
|  | ||||
|     public FileList? GetFiles(string prefix) | ||||
|         => _Files != null && _Files.ContainsKey(prefix) ? _Files[prefix] : null; | ||||
|  | ||||
| @@ -80,7 +84,7 @@ public class XMLProvider : IXMLProvider { | ||||
|  | ||||
|         if (_HamannFiles == null) _HamannFiles = new List<IFileInfo>(); | ||||
|         _HamannFiles.Add(info); | ||||
|  | ||||
|         _InProduction = info; | ||||
|         return info; | ||||
|     } | ||||
|  | ||||
| @@ -110,4 +114,12 @@ public class XMLProvider : IXMLProvider { | ||||
|         } | ||||
|         return res; | ||||
|     } | ||||
|  | ||||
|     private List<IFileInfo>? _ScanHamannFiles() { | ||||
|         var dir = _fileProvider.GetDirectoryContents(string.Empty).Where(x => x.IsDirectory && x.Name == "hamann"); | ||||
|         if (dir == null || !dir.Any()) return null; | ||||
|         var files = _fileProvider.GetDirectoryContents(dir.First().Name).Where(x => !x.IsDirectory && x.Name.StartsWith("hamann") && x.Name.EndsWith(".xml")); | ||||
|         if (files == null || !files.Any()) return null; | ||||
|         return files.ToList(); | ||||
|     } | ||||
| } | ||||
| @@ -20,6 +20,19 @@ public class FileList { | ||||
|         if (!_Files.Contains(document)) _Files.Add(document); | ||||
|     } | ||||
|  | ||||
|     public bool Contains(XMLRootDocument doc) { | ||||
|         if (_Files == null) return false; | ||||
|         return _Files.Contains(doc); | ||||
|     } | ||||
|  | ||||
|     public List<XMLRootDocument>? GetFileList() | ||||
|         => this._Files != null ? this._Files.ToList() : null; | ||||
|  | ||||
|     public FileList Clone() { | ||||
|         var ret = new FileList(this.XMLRoot); | ||||
|         foreach (var file in _Files) { | ||||
|             ret.Add(file); | ||||
|         } | ||||
|         return ret; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										17
									
								
								HaWeb/Models/FileModel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								HaWeb/Models/FileModel.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| namespace HaWeb.Models; | ||||
|  | ||||
| public class FileModel { | ||||
|     public string FileName { get; private set; } | ||||
|     public string Prefix { get; private set; } | ||||
|     public DateTime LastModified { get; private set; } | ||||
|     public bool IsUsed { get; private set; } | ||||
|     public bool InProduction { get; private set; } | ||||
|     public List<(string, string?)>? Fields { get; set; } | ||||
|  | ||||
|     public FileModel(string name, string prefix, DateTime lastModified, bool isUSed, bool inProduction) { | ||||
|         FileName = name; | ||||
|         IsUsed = IsUsed; | ||||
|         LastModified = lastModified; | ||||
|         InProduction = InProduction; | ||||
|     } | ||||
| } | ||||
| @@ -1,19 +1,22 @@ | ||||
| namespace HaWeb.Models; | ||||
| using HaWeb.XMLParser; | ||||
| using Microsoft.Extensions.FileProviders; | ||||
| using Microsoft.AspNetCore.Mvc.Rendering; | ||||
|  | ||||
| public class UploadViewModel { | ||||
|     public string ActiveTitle { get; private set; } | ||||
|     public string? Prefix { get; private set; } | ||||
|     public List<IXMLRoot>? AvailableRoots { get; private set; } | ||||
|     public FileList? AvailableFiles { get; private set; } | ||||
|     public Dictionary<string, FileList>? UsedFiles { get; private set; } | ||||
|     public List<FileModel>? AvailableFiles { get; set; } | ||||
|     public Dictionary<string, List<FileModel>?>? UsedFiles { get; private set; } | ||||
|     public Dictionary<string, List<FileModel>?>? ProductionFiles { get; set; } | ||||
|  | ||||
|     public List<(string, DateTime)>? HamannFiles { get; set; } | ||||
|  | ||||
|     public UploadViewModel(string title, string? prefix, List<IXMLRoot>? roots, FileList? availableFiles, Dictionary<string, FileList>? usedFiles) { | ||||
|     public UploadViewModel(string title, string? prefix, List<IXMLRoot>? roots, Dictionary<string, List<FileModel>?>? usedFiles) { | ||||
|         Prefix = prefix; | ||||
|         ActiveTitle = title; | ||||
|         AvailableRoots = roots; | ||||
|         AvailableFiles = availableFiles; | ||||
|         UsedFiles = usedFiles; | ||||
|     } | ||||
| } | ||||
| @@ -44,6 +44,6 @@ TODO pills are not mobile friendly (hover / click) | ||||
| TODO Evtl alignment von center / right an der letzten oder nächsten zeile | ||||
| TODO Abhärten des Konstruktors von XMLRootDokument für von außerhalb platzierte Dokumente | ||||
| TODO XML-Check im Client | ||||
| TODO Lock für die Liste | ||||
| TODO Lock für die Liste, Bzw ConcurretBag | ||||
| TODO Up-Button | ||||
| TODO Neue Forschungsliteratur einsenden | ||||
| @@ -1,13 +1,13 @@ | ||||
| @model UploadViewModel?; | ||||
| @model UploadViewModel; | ||||
|  | ||||
| <div class="ha-adminuploadfields" id="ha-adminuploadfields"> | ||||
|   @foreach (var item in Model.AvailableRoots.OrderBy(x => x.Type)) { | ||||
|   @foreach (var item in Model.AvailableRoots!.OrderBy(x => x.Type)) { | ||||
|       <a class="ha-uploadfield" asp-controller="Upload" asp-action="Index" asp-route-id="@item.Prefix"> | ||||
|         <div class="ha-uploadfieldname">@item.Type</div> | ||||
|         @if (Model.UsedFiles != null && Model.UsedFiles.ContainsKey(item.Prefix)) { | ||||
|           <div class="ha-uploadusedfiles"> | ||||
|           @foreach(var file in Model.UsedFiles[item.Prefix].GetFileList()!) { | ||||
|             @if (file == Model.UsedFiles[item.Prefix].GetFileList()!.Last()) | ||||
|           @foreach(var file in Model.UsedFiles[item.Prefix]!) { | ||||
|             @if (file == Model.UsedFiles[item.Prefix]!.Last()) | ||||
|             { | ||||
|               <span class="ha-uploadusedfile">@file.FileName</span> | ||||
|             } | ||||
| @@ -38,7 +38,7 @@ | ||||
|  | ||||
|     <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"> | ||||
|           Veröffentlichen | ||||
|           <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"> | ||||
| @@ -56,9 +56,9 @@ | ||||
|   <div class="ha-usedfilesheader"> | ||||
|     <div class="ha-usedfilesheaderlist"> | ||||
|       @if(Model.UsedFiles != null && Model.UsedFiles.ContainsKey(Model.Prefix)) { | ||||
|         @foreach (var item in Model.UsedFiles[Model.Prefix].GetFileList()) | ||||
|         @foreach (var item in Model.UsedFiles[Model.Prefix]!) | ||||
|         { | ||||
|           <div class="ha-usedfilesheaderfile">@item.File.Name</div> | ||||
|           <div class="ha-usedfilesheaderfile">@item.FileName</div> | ||||
|         } | ||||
|       } | ||||
|       else { | ||||
| @@ -88,6 +88,11 @@ | ||||
|      | ||||
|   </div> | ||||
| } | ||||
| else { | ||||
|   <form class="ha-selecthamannfilesform" id="selecthamannfilesform" asp-controller="API" asp-action="SetUsedHamann" method="post" enctype="multipart/form-data"> | ||||
|      | ||||
|   </form> | ||||
| } | ||||
| </div> | ||||
|  | ||||
| @section Scripts { | ||||
| @@ -121,6 +126,8 @@ | ||||
|  | ||||
|     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', | ||||
| @@ -131,19 +138,29 @@ | ||||
|         .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"; | ||||
|             oFormElement.elements.namedItem("update-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"; | ||||
|             oFormElement.elements.namedItem("update-result").value = "Erfolg!"; | ||||
|           } | ||||
|         }) | ||||
|         .catch ((e) => console.log('Error:', e)) | ||||
|         .catch ((e) => { | ||||
|           document.getElementById("ha-publishfilelabel").style.pointerEvents = "auto"; | ||||
|           document.getElementById("ha-lds-ellipsis-publish").style.display = "none"; | ||||
|           console.log('Error:', e); | ||||
|       }) | ||||
|     } | ||||
|  | ||||
|     const UPLOADSubmit = async function (oFormElement, file = null) { | ||||
|       var fd = new FormData(); | ||||
|       if (file !== null) fd.append("file", file); | ||||
|       else fd = new FormData(oFormElement); | ||||
|       document.getElementById("dropzone").style.pointerEvents = "none"; | ||||
|       document.getElementById("ha-lds-ellipsis").style.display = "inline-block"; | ||||
|       document.getElementById("ha-uploadmessage").style.opacity = "0"; | ||||
|       await fetch(oFormElement.action, { | ||||
| @@ -156,18 +173,27 @@ | ||||
|         .then(response => response.json()) | ||||
|         .then(json => { | ||||
|           if ("Error" in json) { | ||||
|             document.getElementById("dropzone").style.pointerEvents = "auto"; | ||||
|             document.getElementById("ha-lds-ellipsis").style.display = "none"; | ||||
|             document.getElementById("ha-uploadmessage").style.opacity = "1"; | ||||
|             oFormElement.elements.namedItem("upload-result").value = json.Error; | ||||
|           } else { | ||||
|             document.getElementById("dropzone").style.pointerEvents = "auto"; | ||||
|             document.getElementById("ha-lds-ellipsis").style.display = "none"; | ||||
|             oFormElement.elements.namedItem("upload-result").value = "Erfolg!"; | ||||
|             if ("Prefix" in json[0]) { | ||||
|               document.getElementById("dropzone").style.pointerEvents = "auto"; | ||||
|               document.getElementById("ha-lds-ellipsis").style.display = "none"; | ||||
|               window.location.replace("/Admin/Upload/" + json[0].Prefix); | ||||
|             } | ||||
|           } | ||||
|         }) | ||||
|         .catch ((e) => console.log('Error:', e)) | ||||
|         .catch ((e) => {  | ||||
|           document.getElementById("dropzone").style.pointerEvents = "auto"; | ||||
|           document.getElementById("ha-lds-ellipsis").style.display = "none"; | ||||
|           document.getElementById("ha-uploadmessage").style.opacity = "1"; | ||||
|           oFormElement.elements.namedItem("upload-result").value = "Keine Antwort. Bitte Seite neu laden!"; | ||||
|         }) | ||||
|     } | ||||
|  | ||||
|     function getCookie(name) { | ||||
|   | ||||
| @@ -13,4 +13,5 @@ public interface IXMLService { | ||||
|     public void Use(XMLRootDocument doc); | ||||
|     public void AutoUse(string prefix); | ||||
|     public void AutoUse(FileList filelist); | ||||
|     public Dictionary<string, FileList?>? GetInProduction(); | ||||
| } | ||||
| @@ -7,6 +7,8 @@ public class XMLService : IXMLService { | ||||
|     private Dictionary<string, FileList?>? _Used; | ||||
|     private Dictionary<string, IXMLRoot>? _Roots; | ||||
|  | ||||
|     private Dictionary<string, FileList?>? _InProduction; | ||||
|  | ||||
|     public XMLService() { | ||||
|         // Getting all classes which implement IXMLRoot for possible document endpoints | ||||
|         var types = _GetAllTypesThatImplementInterface<IXMLRoot>().ToList(); | ||||
| @@ -30,6 +32,8 @@ public class XMLService : IXMLService { | ||||
|  | ||||
|     public Dictionary<string, IXMLRoot>? GetRootsDictionary() => this._Roots == null ? null : this._Roots; | ||||
|  | ||||
|     public Dictionary<string, FileList?>? GetInProduction() => this._InProduction; | ||||
|  | ||||
|     public List<XMLRootDocument>? ProbeHamannFile(XDocument document, ModelStateDictionary ModelState) { | ||||
|         if (document.Root!.Name != "opus") { | ||||
|             ModelState.AddModelError("Error", "A valid Hamann-Docuemnt must begin with <opus>"); | ||||
| @@ -93,17 +97,20 @@ public class XMLService : IXMLService { | ||||
|         } | ||||
|  | ||||
|         var opus = new XElement("opus"); | ||||
|         var inProduction = new Dictionary<string, FileList?>(); | ||||
|         foreach (var category in _Used) { | ||||
|             if (category.Value == null || category.Value.GetFileList() == null || !category.Value.GetFileList()!.Any()) { | ||||
|                 ModelState.AddModelError("Error", _Roots![category.Key].Type + " nicht vorhanden."); | ||||
|                 return null; | ||||
|             } | ||||
|  | ||||
|             inProduction.Add(category.Key, category.Value); | ||||
|             var documents = category.Value.GetFileList(); | ||||
|             foreach (var document in documents!) { | ||||
|                 document.XMLRoot.MergeIntoFile(opus, document); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         _InProduction = inProduction; | ||||
|         return opus; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -15,5 +15,7 @@ | ||||
|   "AllowedHosts": "*", | ||||
|   "StoredFilePathLinux": "/home/simon/Downloads/test/", | ||||
|   "StoredFilePathWindows": "D:/test/", | ||||
|   "FileSizeLimit": 52428800 | ||||
|   "FileSizeLimit": 52428800, | ||||
|   "AvailableStartYear": 1700, | ||||
|   "AvailableEndYear": 1800 | ||||
| } | ||||
|   | ||||
| @@ -900,7 +900,7 @@ body { | ||||
| .ha-letterheader .ha-lettermetalinks { | ||||
|   border-bottom-width: 2px; | ||||
|   --tw-border-opacity: 1; | ||||
|   border-color: rgb(226 232 240 / var(--tw-border-opacity)); | ||||
|   border-color: rgb(203 213 225 / var(--tw-border-opacity)); | ||||
| } | ||||
|  | ||||
| .ha-letterheader .ha-lettermetalinks a { | ||||
| @@ -1943,6 +1943,11 @@ body { | ||||
|   padding-top: 0.5rem; | ||||
| } | ||||
|  | ||||
| .ha-adminuploadfields .ha-uploadform .ha-uploadfilelabel:hover { | ||||
|   --tw-bg-opacity: 1; | ||||
|   background-color: rgb(241 245 249 / var(--tw-bg-opacity)); | ||||
| } | ||||
|  | ||||
| .ha-adminuploadfields .ha-uploadform .ha-uploadmessage { | ||||
|   border-radius: 0.125rem; | ||||
|   background-color: rgb(51 65 85 / var(--tw-bg-opacity)); | ||||
| @@ -1980,6 +1985,15 @@ body { | ||||
|   padding-top: 0.5rem; | ||||
| } | ||||
|  | ||||
| .ha-adminuploadfields .ha-publishform .ha-publishfilelabel:hover { | ||||
|   --tw-bg-opacity: 1; | ||||
|   background-color: rgb(241 245 249 / var(--tw-bg-opacity)); | ||||
| } | ||||
|  | ||||
| .ha-adminuploadfields .ha-publishform .ha-publishtext { | ||||
|   text-align: center; | ||||
| } | ||||
|  | ||||
| .ha-adminuploadfields .ha-publishform .ha-publishmessage { | ||||
|   border-radius: 0.125rem; | ||||
|   background-color: rgb(51 65 85 / var(--tw-bg-opacity)); | ||||
| @@ -2674,8 +2688,8 @@ body { | ||||
|  | ||||
| .ha-added, .ha-added *:not(.ha-linecount *, .ha-linecount, .ha-marginalbox *, .ha-marginalbox, .ha-marginal, .ha-marginal *, .ha-btn-collapsed-box) { | ||||
|   border-radius: 0.125rem; | ||||
|   padding-left: 0.25rem; | ||||
|   padding-right: 0.25rem; | ||||
|   padding-left: 0.125rem; | ||||
|   padding-right: 0.125rem; | ||||
| } | ||||
|  | ||||
| .ha-note, .ha-note *:not(.ha-linecount *, .ha-linecount, .ha-marginalbox *, .ha-marginalbox, .ha-marginal, .ha-marginal *, .ha-btn-collapsed-box) { | ||||
|   | ||||
| @@ -229,7 +229,7 @@ | ||||
|   } | ||||
|  | ||||
|   .ha-letterheader .ha-lettermetalinks { | ||||
|     @apply border-b-2 border-slate-200 | ||||
|     @apply border-b-2 border-slate-300 | ||||
|   } | ||||
|  | ||||
|   .ha-letterheader .ha-lettermetalinks a { | ||||
| @@ -698,7 +698,7 @@ | ||||
|   } | ||||
|  | ||||
|   .ha-adminuploadfields .ha-uploadform { | ||||
|     @apply bg-slate-50 rounded shadow grow relative | ||||
|     @apply bg-slate-50 rounded shadow grow relative  | ||||
|   } | ||||
|  | ||||
|   .ha-adminuploadfields .ha-uploadform .ha-uploadtext { | ||||
| @@ -710,7 +710,7 @@ | ||||
|   } | ||||
|  | ||||
|   .ha-adminuploadfields .ha-uploadform .ha-uploadfilelabel { | ||||
|     @apply inline-block px-2 py-1 pt-2 cursor-pointer w-full h-full | ||||
|     @apply inline-block px-2 py-1 pt-2 cursor-pointer w-full h-full hover:bg-slate-100 | ||||
|   } | ||||
|  | ||||
|   .ha-adminuploadfields .ha-uploadform .ha-uploadmessage { | ||||
| @@ -726,7 +726,11 @@ | ||||
|   } | ||||
|  | ||||
|   .ha-adminuploadfields .ha-publishform .ha-publishfilelabel { | ||||
|     @apply inline-block px-2 py-1 pt-2 cursor-pointer w-full h-full | ||||
|     @apply inline-block px-2 py-1 pt-2 cursor-pointer w-full h-full hover:bg-slate-100 | ||||
|   } | ||||
|  | ||||
|   .ha-adminuploadfields .ha-publishform .ha-publishtext { | ||||
|     @apply text-center | ||||
|   } | ||||
|  | ||||
|   .ha-adminuploadfields .ha-publishform .ha-publishmessage { | ||||
| @@ -1107,7 +1111,7 @@ | ||||
|  | ||||
|   .ha-added, | ||||
|   .ha-added *:not(.ha-linecount *, .ha-linecount, .ha-marginalbox *, .ha-marginalbox, .ha-marginal, .ha-marginal *, .ha-btn-collapsed-box) { | ||||
|     @apply px-1 rounded-sm | ||||
|     @apply px-0.5 rounded-sm | ||||
|   } | ||||
|  | ||||
|   .ha-note, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 schnulller
					schnulller