Files
miriamgemeinde/public/js/353.5e96c713.js

2 lines
4.3 KiB
JavaScript

"use strict";(self["webpackChunkmiriamgemeinde"]=self["webpackChunkmiriamgemeinde"]||[]).push([[353],{655:function(e,a,t){var l=t(6955),n=String;e.exports=function(e){if("Symbol"===l(e))throw new TypeError("Cannot convert a Symbol value to a string");return n(e)}},2353:function(e,a,t){t.r(a),t.d(a,{default:function(){return L}});var l=t(641),n=t(3751),i=t(33);const o=e=>((0,l.Qi)("data-v-f2694614"),e=e(),(0,l.jt)(),e),r={class:"upload-files"},u=o((()=>(0,l.Lk)("h2",null,"Dateien hochladen",-1))),s=o((()=>(0,l.Lk)("label",{for:"file-upload"},"Datei auswählen:",-1))),d=o((()=>(0,l.Lk)("label",{for:"file-title"},"Titel eingeben:",-1))),c={class:"file-list"},f={class:"file-info"},h=["onClick"],p=["onClick"],v={class:"file-date"};function m(e,a,t,o,m,k){return(0,l.uX)(),(0,l.CE)("div",r,[u,(0,l.Lk)("div",null,[s,(0,l.Lk)("input",{id:"file-upload",type:"file",onChange:a[0]||(a[0]=(...e)=>o.handleFileUpload&&o.handleFileUpload(...e))},null,32)]),(0,l.Lk)("div",null,[d,(0,l.bo)((0,l.Lk)("input",{id:"file-title",type:"text","onUpdate:modelValue":a[1]||(a[1]=e=>o.fileTitle=e)},null,512),[[n.Jo,o.fileTitle]])]),(0,l.Lk)("button",{onClick:a[2]||(a[2]=(...e)=>o.uploadFiles&&o.uploadFiles(...e))},"Hochladen"),(0,l.Lk)("ul",c,[((0,l.uX)(!0),(0,l.CE)(l.FK,null,(0,l.pI)(o.uploadedFiles,(e=>((0,l.uX)(),(0,l.CE)("li",{key:e.id},[(0,l.Lk)("div",f,[(0,l.Lk)("span",{class:"file-title",onClick:a=>o.downloadFile(e)},(0,i.v_)(e.title),9,h),(0,l.Lk)("span",{class:"file-name",onClick:a=>o.downloadFile(e)},(0,i.v_)(e.originalName),9,p),(0,l.Lk)("span",v,(0,i.v_)(o.formatDate(e.createdAt)),1)])])))),128))])])}t(4114),t(4603),t(7566),t(8721);var k=t(953),w=t(3173),g={name:"UploadFilesComponent",setup(){const e=(0,k.KR)(null),a=(0,k.KR)(""),t=(0,k.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 l=new FormData;l.append("file",e.value),l.append("title",a.value);try{const n=await w.A.post("/files",l,{headers:{"Content-Type":"multipart/form-data"}}),i=n.data;t.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(".")),t=await w.A.get(`/files/download/${e.hash}`,{responseType:"blob"}),l=new Blob([t.data],{type:t.data.type}),n=document.createElement("a");n.href=window.URL.createObjectURL(l),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 w.A.get("/files");t.value=e.data}catch(e){console.error("Fehler beim Abrufen der Dateien:",e)}};return(0,l.sV)(u),{fileToUpload:e,fileTitle:a,uploadedFiles:t,handleFileUpload:n,uploadFiles:i,downloadFile:o,formatDate:r}}},y=t(6262);const b=(0,y.A)(g,[["render",m],["__scopeId","data-v-f2694614"]]);var L=b},2812:function(e){var a=TypeError;e.exports=function(e,t){if(e<t)throw new a("Not enough arguments");return e}},4603:function(e,a,t){var l=t(6840),n=t(9504),i=t(655),o=t(2812),r=URLSearchParams,u=r.prototype,s=n(u.append),d=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"&&l(u,"delete",(function(e){var a=arguments.length,t=a<2?void 0:arguments[1];if(a&&void 0===t)return d(this,e);var l=[];c(this,(function(e,a){f(l,{key:a,value:e})})),o(a,1);var n,r=i(e),u=i(t),h=0,p=0,v=!1,m=l.length;while(h<m)n=l[h++],v||n.key===r?(v=!0,d(this,n.key)):p++;while(p<m)n=l[p++],n.key===r&&n.value===u||s(this,n.key,n.value)}),{enumerable:!0,unsafe:!0})},7566:function(e,a,t){var l=t(6840),n=t(9504),i=t(655),o=t(2812),r=URLSearchParams,u=r.prototype,s=n(u.getAll),d=n(u.has),c=new r("a=1");!c.has("a",2)&&c.has("a",void 0)||l(u,"has",(function(e){var a=arguments.length,t=a<2?void 0:arguments[1];if(a&&void 0===t)return d(this,e);var l=s(this,e);o(a,1);var n=i(t),r=0;while(r<l.length)if(l[r++]===n)return!0;return!1}),{enumerable:!0,unsafe:!0})},8721:function(e,a,t){var l=t(3724),n=t(9504),i=t(2106),o=URLSearchParams.prototype,r=n(o.forEach);l&&!("size"in o)&&i(o,"size",{get:function(){var e=0;return r(this,(function(){e++})),e},configurable:!0,enumerable:!0})}}]);
//# sourceMappingURL=353.5e96c713.js.map