2 lines
5.0 KiB
JavaScript
2 lines
5.0 KiB
JavaScript
"use strict";(self["webpackChunkmiriamgemeinde"]=self["webpackChunkmiriamgemeinde"]||[]).push([[636],{531:function(e,t,a){var n=a(6518),i=a(9565),l=a(9306),r=a(8551),o=a(1767),u=a(8646),s=a(9462),d=a(9539),c=a(6395),p=a(684),m=a(4549),h=!c&&!p("flatMap",function(){}),g=!c&&!h&&m("flatMap",TypeError),f=c||h||g,k=s(function(){var e,t,a=this.iterator,n=this.mapper;while(1){if(t=this.inner)try{if(e=r(i(t.next,t.iterator)),!e.done)return e.value;this.inner=null}catch(l){d(a,"throw",l)}if(e=r(i(this.next,a)),this.done=!!e.done)return;try{this.inner=u(n(e.value,this.counter++),!1)}catch(l){d(a,"throw",l)}}});n({target:"Iterator",proto:!0,real:!0,forced:f},{flatMap:function(e){r(this);try{l(e)}catch(t){d(this,"throw",t)}return g?i(g,this,e):new k(o(this),{mapper:e,inner:null})}})},636:function(e,t,a){a.r(t),a.d(t,{default:function(){return k}});var n=a(641),i=a(3751),l=a(33);const r=["value"],o={key:0},u=["src","alt"],s=["onUpdate:modelValue","onChange"],d=["onUpdate:modelValue","onChange"];function c(e,t,a,c,p,m){return(0,n.uX)(),(0,n.CE)("div",null,[t[12]||(t[12]=(0,n.Lk)("h1",null,"Bild hochladen",-1)),(0,n.Lk)("form",{onSubmit:t[4]||(t[4]=(0,i.D$)((...e)=>m.uploadImage&&m.uploadImage(...e),["prevent"]))},[(0,n.Lk)("div",null,[t[5]||(t[5]=(0,n.Lk)("label",{for:"title"},"Titel",-1)),(0,n.bo)((0,n.Lk)("input",{type:"text",id:"title","onUpdate:modelValue":t[0]||(t[0]=e=>p.title=e)},null,512),[[i.Jo,p.title]])]),(0,n.Lk)("div",null,[t[6]||(t[6]=(0,n.Lk)("label",{for:"description"},"Beschreibung",-1)),(0,n.bo)((0,n.Lk)("textarea",{id:"description","onUpdate:modelValue":t[1]||(t[1]=e=>p.description=e)},null,512),[[i.Jo,p.description]])]),(0,n.Lk)("div",null,[t[7]||(t[7]=(0,n.Lk)("label",{for:"image"},"Bild",-1)),(0,n.Lk)("input",{type:"file",id:"image",onChange:t[2]||(t[2]=(...e)=>m.onFileChange&&m.onFileChange(...e))},null,32)]),(0,n.Lk)("div",null,[t[9]||(t[9]=(0,n.Lk)("label",{for:"page"},"Seite",-1)),(0,n.bo)((0,n.Lk)("select",{id:"page","onUpdate:modelValue":t[3]||(t[3]=e=>p.selectedPage=e)},[t[8]||(t[8]=(0,n.Lk)("option",{value:""},"Keine Seite",-1)),((0,n.uX)(!0),(0,n.CE)(n.FK,null,(0,n.pI)(p.pages,e=>((0,n.uX)(),(0,n.CE)("option",{key:e.value,value:e.value},(0,l.v_)(e.caption),9,r))),128))],512),[[i.u1,p.selectedPage]])]),t[10]||(t[10]=(0,n.Lk)("button",{type:"submit"},"Hochladen",-1))],32),p.images.length?((0,n.uX)(),(0,n.CE)("div",o,[t[11]||(t[11]=(0,n.Lk)("h2",null,"Hochgeladene Bilder",-1)),((0,n.uX)(!0),(0,n.CE)(n.FK,null,(0,n.pI)(p.images,e=>((0,n.uX)(),(0,n.CE)("div",{key:e.id,class:"uploaded-image"},[(0,n.Lk)("img",{src:`/images/uploads/${e.filename}`,alt:e.title,width:"100"},null,8,u),(0,n.bo)((0,n.Lk)("input",{type:"text","onUpdate:modelValue":t=>e.title=t,onChange:t=>m.updateImage(e)},null,40,s),[[i.Jo,e.title]]),(0,n.bo)((0,n.Lk)("textarea",{"onUpdate:modelValue":t=>e.description=t,onChange:t=>m.updateImage(e)},null,40,d),[[i.Jo,e.description]]),(0,n.Lk)("p",null,(0,l.v_)(m.formatDate(e.uploadDate))+" "+(0,l.v_)(m.formatTimeFromDate(e.uploadDate)),1)]))),128))])):(0,n.Q3)("",!0)])}a(8111),a(531);var p=a(6296),m=a(9654),h={name:"ImageUpload",data(){return{title:"",description:"",image:null,selectedPage:"",pages:[],images:[]}},methods:{formatDate:m.Yq,formatTimeFromDate:m.ry,onFileChange(e){this.image=e.target.files[0]},async uploadImage(){const e=new FormData;e.append("title",this.title),e.append("description",this.description),e.append("image",this.image),e.append("page",this.selectedPage);try{await p.A.post("/image/",e),this.fetchImages(),this.resetForm()}catch(t){console.error("Fehler beim Hochladen des Bildes:",t)}},async fetchImages(){try{const e=await p.A.get("/image");this.images=e.data}catch(e){console.error("Fehler beim Abrufen der Bilder:",e)}},async fetchPages(){try{const e=await p.A.get("/menu-data"),t=function(e,a=""){return e.flatMap(e=>{let n=[];return e.submenu&&e.submenu.length&&(n=t(e.submenu,a+e.name+" -> ")),[{value:e.link,caption:a+e.name},...n]})};this.pages=t(e.data)}catch(e){console.error("Fehler beim Abrufen der Seiten:",e)}},async updateImage(e){try{await p.A.put(`/image/${e.id}`,{title:e.title,description:e.description}),this.fetchImages()}catch(t){console.error("Fehler beim Aktualisieren des Bildes:",t)}},resetForm(){this.title="",this.description="",this.image=null,this.selectedPage="",document.getElementById("image").value=null}},mounted(){this.fetchImages(),this.fetchPages()}},g=a(6262);const f=(0,g.A)(h,[["render",c],["__scopeId","data-v-403a0e0b"]]);var k=f},8646:function(e,t,a){var n=a(9565),i=a(8551),l=a(1767),r=a(851);e.exports=function(e,t){t&&"string"===typeof e||i(e);var a=r(e);return l(i(void 0!==a?n(a,e):e))}},9654:function(e,t,a){function n(e){const[t,a]=e.split(":");return`${t}:${a}`}function i(e){const t={year:"numeric",month:"2-digit",day:"2-digit"};return new Date(e).toLocaleDateString("de-DE",t)}function l(e){const t=new Date(e),a=String(t.getHours()).padStart(2,"0"),n=String(t.getMinutes()).padStart(2,"0");return`${a}:${n}`}a.d(t,{Yq:function(){return i},fU:function(){return n},ry:function(){return l}})}}]);
|
|
//# sourceMappingURL=636.cdb315d8.js.map
|