2 lines
4.1 KiB
JavaScript
2 lines
4.1 KiB
JavaScript
"use strict";(self["webpackChunkmiriamgemeinde"]=self["webpackChunkmiriamgemeinde"]||[]).push([[446],{446:function(e,a,l){l.r(a),l.d(a,{default:function(){return w}});var t=l(641),n=l(3751),i=l(33);const o={class:"upload-files"},r={class:"file-list"},u={class:"file-info"},d=["onClick"],s=["onClick"],c={class:"file-date"};function f(e,a,l,f,h,p){return(0,t.uX)(),(0,t.CE)("div",o,[a[5]||(a[5]=(0,t.Lk)("h2",null,"Dateien hochladen",-1)),(0,t.Lk)("div",null,[a[3]||(a[3]=(0,t.Lk)("label",{for:"file-upload"},"Datei auswählen:",-1)),(0,t.Lk)("input",{id:"file-upload",type:"file",onChange:a[0]||(a[0]=(...e)=>f.handleFileUpload&&f.handleFileUpload(...e))},null,32)]),(0,t.Lk)("div",null,[a[4]||(a[4]=(0,t.Lk)("label",{for:"file-title"},"Titel eingeben:",-1)),(0,t.bo)((0,t.Lk)("input",{id:"file-title",type:"text","onUpdate:modelValue":a[1]||(a[1]=e=>f.fileTitle=e)},null,512),[[n.Jo,f.fileTitle]])]),(0,t.Lk)("button",{onClick:a[2]||(a[2]=(...e)=>f.uploadFiles&&f.uploadFiles(...e))},"Hochladen"),(0,t.Lk)("ul",r,[((0,t.uX)(!0),(0,t.CE)(t.FK,null,(0,t.pI)(f.uploadedFiles,e=>((0,t.uX)(),(0,t.CE)("li",{key:e.id},[(0,t.Lk)("div",u,[(0,t.Lk)("span",{class:"file-title",onClick:a=>f.downloadFile(e)},(0,i.v_)(e.title),9,d),(0,t.Lk)("span",{class:"file-name",onClick:a=>f.downloadFile(e)},(0,i.v_)(e.originalName),9,s),(0,t.Lk)("span",c,(0,i.v_)(f.formatDate(e.createdAt)),1)])]))),128))])])}l(4114),l(4603),l(7566),l(8721);var h=l(953),p=l(6296),v={name:"UploadFilesComponent",setup(){const e=(0,h.KR)(null),a=(0,h.KR)(""),l=(0,h.KR)([]),n=a=>{e.value=a.target.files[0]},i=async()=>{if(!e.value||!a.value)return void alert("Bitte wählen Sie eine Datei aus und geben Sie einen Titel ein.");const t=new FormData;t.append("file",e.value),t.append("title",a.value);try{const n=await p.A.post("/files",t,{headers:{"Content-Type":"multipart/form-data"}}),i=n.data;l.value.push({id:i.id,title:i.title,originalName:i.originalName,createdAt:i.createdAt,hash:i.hash}),e.value=null,a.value=""}catch(n){console.error("Fehler beim Hochladen der Datei:",n)}},o=async e=>{const a=e.originalName.substring(e.originalName.lastIndexOf(".")),l=await p.A.get(`/files/download/${e.hash}`,{responseType:"blob"}),t=new Blob([l.data],{type:l.data.type}),n=document.createElement("a");n.href=window.URL.createObjectURL(t),n.download=`${e.title}${a}`,n.click(),window.URL.revokeObjectURL(n.href)},r=e=>{const a={year:"numeric",month:"long",day:"numeric"};return new Date(e).toLocaleDateString(void 0,a)},u=async()=>{try{const e=await p.A.get("/files");l.value=e.data}catch(e){console.error("Fehler beim Abrufen der Dateien:",e)}};return(0,t.sV)(u),{fileToUpload:e,fileTitle:a,uploadedFiles:l,handleFileUpload:n,uploadFiles:i,downloadFile:o,formatDate:r}}},m=l(6262);const k=(0,m.A)(v,[["render",f],["__scopeId","data-v-f2694614"]]);var w=k},2812:function(e){var a=TypeError;e.exports=function(e,l){if(e<l)throw new a("Not enough arguments");return e}},4603:function(e,a,l){var t=l(6840),n=l(9504),i=l(655),o=l(2812),r=URLSearchParams,u=r.prototype,d=n(u.append),s=n(u["delete"]),c=n(u.forEach),f=n([].push),h=new r("a=1&a=2&b=3");h["delete"]("a",1),h["delete"]("b",void 0),h+""!=="a=2"&&t(u,"delete",function(e){var a=arguments.length,l=a<2?void 0:arguments[1];if(a&&void 0===l)return s(this,e);var t=[];c(this,function(e,a){f(t,{key:a,value:e})}),o(a,1);var n,r=i(e),u=i(l),h=0,p=0,v=!1,m=t.length;while(h<m)n=t[h++],v||n.key===r?(v=!0,s(this,n.key)):p++;while(p<m)n=t[p++],n.key===r&&n.value===u||d(this,n.key,n.value)},{enumerable:!0,unsafe:!0})},7566:function(e,a,l){var t=l(6840),n=l(9504),i=l(655),o=l(2812),r=URLSearchParams,u=r.prototype,d=n(u.getAll),s=n(u.has),c=new r("a=1");!c.has("a",2)&&c.has("a",void 0)||t(u,"has",function(e){var a=arguments.length,l=a<2?void 0:arguments[1];if(a&&void 0===l)return s(this,e);var t=d(this,e);o(a,1);var n=i(l),r=0;while(r<t.length)if(t[r++]===n)return!0;return!1},{enumerable:!0,unsafe:!0})},8721:function(e,a,l){var t=l(3724),n=l(9504),i=l(2106),o=URLSearchParams.prototype,r=n(o.forEach);t&&!("size"in o)&&i(o,"size",{get:function(){var e=0;return r(this,function(){e++}),e},configurable:!0,enumerable:!0})}}]);
|
|
//# sourceMappingURL=446.a766133d.js.map
|