nextcloud-server/dist/dav-settings-admin-example-...

3 lines
12 KiB
JavaScript

import{_ as w,D as r,o as l,h as m,E as v,t as u,C as A,j as U,c as y,u as b,w as o,b as c,A as S,l as E,a as H,r as p,d as g,e as _,i as C,f as d,N as Z,g as T}from"./NcSettingsSection-DFav6ob5-DwBgvX10.chunk.mjs";import{j as B,I as j,k as L,e as M,s as k,l as q}from"./check-JUc8IOXP.chunk.mjs";import{l as I}from"./logger-CTnaoMpD.chunk.mjs";const G='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-cancel" viewBox="0 0 24 24"><path d="M12 2C17.5 2 22 6.5 22 12S17.5 22 12 22 2 17.5 2 12 6.5 2 12 2M12 4C10.1 4 8.4 4.6 7.1 5.7L18.3 16.9C19.3 15.5 20 13.8 20 12C20 7.6 16.4 4 12 4M16.9 18.3L5.7 7.1C4.6 8.4 4 10.1 4 12C4 16.4 7.6 20 12 20C13.9 20 15.6 19.4 16.9 18.3Z" /></svg>',J={name:"AccountIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},K=["aria-hidden","aria-label"],P=["fill","width","height"],Q={d:"M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z"},W={key:0};function X(a,e,t,i,n,s){return l(),r("span",A(a.$attrs,{"aria-hidden":t.title?null:"true","aria-label":t.title,class:"material-design-icon account-icon",role:"img",onClick:e[0]||(e[0]=h=>a.$emit("click",h))}),[(l(),r("svg",{fill:t.fillColor,class:"material-design-icon__svg",width:t.size,height:t.size,viewBox:"0 0 24 24"},[m("path",Q,[t.title?(l(),r("title",W,u(t.title),1)):v("",!0)])],8,P))],16,K)}const Y=w(J,[["render",X]]),ee={name:"RestoreIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},te=["aria-hidden","aria-label"],ae=["fill","width","height"],ne={d:"M13,3A9,9 0 0,0 4,12H1L4.89,15.89L4.96,16.03L9,12H6A7,7 0 0,1 13,5A7,7 0 0,1 20,12A7,7 0 0,1 13,19C11.07,19 9.32,18.21 8.06,16.94L6.64,18.36C8.27,20 10.5,21 13,21A9,9 0 0,0 22,12A9,9 0 0,0 13,3Z"},le={key:0};function oe(a,e,t,i,n,s){return l(),r("span",A(a.$attrs,{"aria-hidden":t.title?null:"true","aria-label":t.title,class:"material-design-icon restore-icon",role:"img",onClick:e[0]||(e[0]=h=>a.$emit("click",h))}),[(l(),r("svg",{fill:t.fillColor,class:"material-design-icon__svg",width:t.size,height:t.size,viewBox:"0 0 24 24"},[m("path",ne,[t.title?(l(),r("title",le,u(t.title),1)):v("",!0)])],8,ae))],16,te)}const R=w(ee,[["render",oe]]),ie={name:"TrayArrowUpIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},se=["aria-hidden","aria-label"],ce=["fill","width","height"],de={d:"M2 12H4V17H20V12H22V17C22 18.11 21.11 19 20 19H4C2.9 19 2 18.11 2 17V12M12 2L6.46 7.46L7.88 8.88L11 5.75V15H13V5.75L16.13 8.88L17.55 7.45L12 2Z"},re={key:0};function pe(a,e,t,i,n,s){return l(),r("span",A(a.$attrs,{"aria-hidden":t.title?null:"true","aria-label":t.title,class:"material-design-icon tray-arrow-up-icon",role:"img",onClick:e[0]||(e[0]=h=>a.$emit("click",h))}),[(l(),r("svg",{fill:t.fillColor,class:"material-design-icon__svg",width:t.size,height:t.size,viewBox:"0 0 24 24"},[m("path",de,[t.title?(l(),r("title",re,u(t.title),1)):v("",!0)])],8,ce))],16,se)}const $=w(ie,[["render",pe]]),ue={class:"download-button"},me={class:"download-button__label"},he=U({__name:"ExampleContentDownloadButton",props:{href:{}},setup(a){return(e,t)=>(l(),y(b(B),{variant:"tertiary",href:a.href},{icon:o(()=>[S(e.$slots,"icon",{},void 0,!0)]),default:o(()=>[m("div",ue,[m("span",me,[S(e.$slots,"default",{},void 0,!0)]),c(j,{class:"download-button__icon",size:20})])]),_:3},8,["href"]))}}),O=w(he,[["__scopeId","data-v-be40807a"]]),ve=E("dav","enableDefaultContact",!1),fe=E("dav","hasCustomDefaultContact",!1),ge={name:"ExampleContactSettings",components:{NcDialog:L,NcButton:B,NcCheckboxRadioSwitch:H,IconUpload:$,IconRestore:R,IconAccount:Y,ExampleContentDownloadButton:O},setup(){return{t:d}},data(){return{enableDefaultContact:ve,hasCustomDefaultContact:fe,isModalOpen:!1,loading:!1,buttons:[{label:d("dav","Cancel"),icon:G,callback:()=>{this.isModalOpen=!1}},{label:d("dav","Import"),icon:q,variant:"primary",callback:()=>{this.clickImportInput()}}]}},computed:{downloadUrl(){return C("/apps/dav/api/defaultcontact/contact")}},methods:{updateEnableDefaultContact(){_.put(C("apps/dav/api/defaultcontact/config"),{allow:!this.enableDefaultContact}).then(()=>{this.enableDefaultContact=!this.enableDefaultContact}).catch(()=>{k(d("dav","Error while saving settings"))})},toggleModal(){this.isModalOpen=!this.isModalOpen},clickImportInput(){this.$refs.exampleContactImportInput.click()},resetContact(){this.loading=!0,_.put(C("/apps/dav/api/defaultcontact/contact")).then(()=>{this.hasCustomDefaultContact=!1,M(d("dav","Contact reset successfully"))}).catch(a=>{I.error("Error importing contact:",{error:a}),k(d("dav","Error while resetting contact"))}).finally(()=>{this.loading=!1})},processFile(a){this.loading=!0;const e=a.target.files[0],t=new FileReader;t.onload=async()=>{this.isModalOpen=!1;try{await _.put(C("/apps/dav/api/defaultcontact/contact"),{contactData:t.result}),this.hasCustomDefaultContact=!0,M(d("dav","Contact imported successfully"))}catch(i){I.error("Error importing contact:",{error:i}),k(d("dav","Error while importing contact"))}finally{this.loading=!1,a.target.value=""}},t.readAsText(e)}}},Ce={class:"example-contact-settings"},we={key:0,class:"example-contact-settings__buttons"},xe=["disabled"];function be(a,e,t,i,n,s){const h=p("NcCheckboxRadioSwitch"),z=p("IconAccount"),V=p("ExampleContentDownloadButton"),D=p("IconUpload"),x=p("NcButton"),F=p("IconRestore"),N=p("NcDialog");return l(),r("div",Ce,[c(h,{checked:n.enableDefaultContact,type:"switch","onUpdate:modelValue":s.updateEnableDefaultContact},{default:o(()=>[g(u(i.t("dav","Add example contact to user's address book when they first log in")),1)]),_:1},8,["checked","onUpdate:modelValue"]),n.enableDefaultContact?(l(),r("div",we,[c(V,{href:s.downloadUrl},{icon:o(()=>[c(z,{size:20})]),default:o(()=>[e[2]||(e[2]=g(" example_contact.vcf ",-1))]),_:1},8,["href"]),c(x,{variant:"secondary",onClick:s.toggleModal},{icon:o(()=>[c(D,{size:20})]),default:o(()=>[g(" "+u(i.t("dav","Import contact")),1)]),_:1},8,["onClick"]),n.hasCustomDefaultContact?(l(),y(x,{key:0,variant:"tertiary",onClick:s.resetContact},{icon:o(()=>[c(F,{size:20})]),default:o(()=>[g(" "+u(i.t("dav","Reset to default")),1)]),_:1},8,["onClick"])):v("",!0)])):v("",!0),c(N,{open:n.isModalOpen,"onUpdate:open":e[0]||(e[0]=f=>n.isModalOpen=f),name:i.t("dav","Import contacts"),buttons:n.buttons},{default:o(()=>[m("div",null,[m("p",null,u(i.t("dav","Importing a new .vcf file will delete the existing default contact and replace it with the new one. Do you want to continue?")),1)])]),_:1},8,["open","name","buttons"]),m("input",{id:"example-contact-import",ref:"exampleContactImportInput",disabled:n.loading,type:"file",accept:".vcf",class:"hidden-visually",onChange:e[1]||(e[1]=(...f)=>s.processFile&&s.processFile(...f))},null,40,xe)])}const ye=w(ge,[["render",be],["__scopeId","data-v-cd78f96d"]]),_e={name:"CalendarBlankIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},ke=["aria-hidden","aria-label"],Ee=["fill","width","height"],Ie={d:"M19,19H5V8H19M16,1V3H8V1H6V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3H18V1"},De={key:0};function Me(a,e,t,i,n,s){return l(),r("span",A(a.$attrs,{"aria-hidden":t.title?null:"true","aria-label":t.title,class:"material-design-icon calendar-blank-icon",role:"img",onClick:e[0]||(e[0]=h=>a.$emit("click",h))}),[(l(),r("svg",{fill:t.fillColor,class:"material-design-icon__svg",width:t.size,height:t.size,viewBox:"0 0 24 24"},[m("path",Ie,[t.title?(l(),r("title",De,u(t.title),1)):v("",!0)])],8,Ee))],16,ke)}const Ae=w(_e,[["render",Me]]);async function ze(a){const e=C("/apps/dav/api/exampleEvent/enable");await _.post(e,{enable:a})}async function Ve(a){const e=C("/apps/dav/api/exampleEvent/event");await _.post(e,{ics:a})}async function Fe(){const a=C("/apps/dav/api/exampleEvent/event");await _.delete(a)}const Ne={name:"ExampleEventSettings",components:{NcButton:B,NcCheckboxRadioSwitch:H,NcDialog:L,IconCalendarBlank:Ae,IconUpload:$,IconRestore:R,ExampleContentDownloadButton:O},setup(){return{t:d}},data(){return{createExampleEvent:E("dav","create_example_event",!1),hasCustomEvent:E("dav","has_custom_example_event",!1),showImportModal:!1,uploading:!1,deleting:!1,savingConfig:!1,selectedFile:void 0}},computed:{downloadUrl(){return C("/apps/dav/api/exampleEvent/event")}},methods:{selectFile(){this.selectedFile=this.$refs["event-file"]?.files[0]},async updateCreateExampleEvent(){this.savingConfig=!0;const a=!this.createExampleEvent;try{await ze(a)}catch(e){k(d("dav","Failed to save example event creation setting")),I.error("Failed to save example event creation setting",{error:e,enable:a})}finally{this.savingConfig=!1}this.createExampleEvent=a},uploadCustomEvent(){if(!this.selectedFile)return;this.uploading=!0;const a=new FileReader;a.addEventListener("load",async()=>{const e=a.result;try{await Ve(e)}catch(t){k(d("dav","Failed to upload the example event")),I.error("Failed to upload example ICS",{error:t,ics:e});return}finally{this.uploading=!1}M(d("dav","Custom example event was saved successfully")),this.showImportModal=!1,this.hasCustomEvent=!0}),a.readAsText(this.selectedFile)},async deleteCustomEvent(){this.deleting=!0;try{await Fe()}catch(a){k(d("dav","Failed to delete the custom example event")),I.error("Failed to delete the custom example event",{error:a});return}finally{this.deleting=!1}M(d("dav","Custom example event was deleted successfully")),this.hasCustomEvent=!1}}},Be={class:"example-event-settings"},Se={key:0,class:"example-event-settings__buttons"},Ue={class:"import-event-modal"},He=["disabled"],Le={class:"import-event-modal__buttons"};function Re(a,e,t,i,n,s){const h=p("NcCheckboxRadioSwitch"),z=p("IconCalendarBlank"),V=p("ExampleContentDownloadButton"),D=p("IconUpload"),x=p("NcButton"),F=p("IconRestore"),N=p("NcDialog");return l(),r("div",Be,[c(h,{checked:n.createExampleEvent,disabled:n.savingConfig,type:"switch","onUpdate:modelValue":s.updateCreateExampleEvent},{default:o(()=>[g(u(i.t("dav","Add example event to user's calendar when they first log in")),1)]),_:1},8,["checked","disabled","onUpdate:modelValue"]),n.createExampleEvent?(l(),r("div",Se,[c(V,{href:s.downloadUrl},{icon:o(()=>[c(z,{size:20})]),default:o(()=>[e[4]||(e[4]=g(" example_event.ics ",-1))]),_:1},8,["href"]),c(x,{variant:"secondary",onClick:e[0]||(e[0]=f=>n.showImportModal=!0)},{icon:o(()=>[c(D,{size:20})]),default:o(()=>[g(" "+u(i.t("dav","Import calendar event")),1)]),_:1}),n.hasCustomEvent?(l(),y(x,{key:0,variant:"tertiary",disabled:n.deleting,onClick:s.deleteCustomEvent},{icon:o(()=>[c(F,{size:20})]),default:o(()=>[g(" "+u(i.t("dav","Reset to default")),1)]),_:1},8,["disabled","onClick"])):v("",!0)])):v("",!0),c(N,{open:n.showImportModal,"onUpdate:open":e[3]||(e[3]=f=>n.showImportModal=f),name:i.t("dav","Import calendar event")},{default:o(()=>[m("div",Ue,[m("p",null,u(i.t("dav","Uploading a new event will overwrite the existing one.")),1),m("input",{ref:"event-file",disabled:n.uploading,type:"file",accept:".ics,text/calendar",class:"import-event-modal__file-picker",onChange:e[1]||(e[1]=(...f)=>s.selectFile&&s.selectFile(...f))},null,40,He),m("div",Le,[c(x,{disabled:n.uploading||!n.selectedFile,variant:"primary",onClick:e[2]||(e[2]=f=>s.uploadCustomEvent())},{icon:o(()=>[c(D,{size:20})]),default:o(()=>[g(" "+u(i.t("dav","Upload event")),1)]),_:1},8,["disabled"])])])]),_:1},8,["open","name"])])}const $e=w(Ne,[["render",Re],["__scopeId","data-v-6e8ec0f6"]]),Oe=U({__name:"ExampleContentSettingsSection",setup(a){const e=E("dav","contactsEnabled"),t=E("dav","calendarEnabled");return(i,n)=>(l(),y(b(Z),{id:"example-content",name:b(d)("dav","Example content"),description:b(d)("dav","Example content serves to showcase the features of Nextcloud. Default content is shipped with Nextcloud, and can be replaced by custom content.")},{default:o(()=>[b(e)?(l(),y(ye,{key:0})):v("",!0),b(t)?(l(),y($e,{key:1})):v("",!0)]),_:1},8,["name","description"]))}}),Ze=T(Oe);Ze.mount("#settings-example-content");
//# sourceMappingURL=dav-settings-admin-example-content.mjs.map