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

3 lines
13 KiB
JavaScript

import{_ as w,j as s,o as l,e as m,k as v,h as u,m as M,n as H,c as x,u as b,w as i,f as r,p as B,l as E,a as F,r as p,g,b as k,d as C,t as d,N as Z,i as T}from"./_plugin-vue_export-helper-DvKvVMbC.chunk.mjs";import{N as S,a as U,s as L,b as _}from"./index-hZPKu-D6-DGE8lsH0.chunk.mjs";import{l as I}from"./logger-Cbb8pkmX.chunk.mjs";const j='<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>',q='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-check" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" /></svg>',G={name:"AccountIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},J=["aria-hidden","aria-label"],K=["fill","width","height"],P={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"},Q={key:0};function W(a,t,e,o,n,c){return l(),s("span",M(a.$attrs,{"aria-hidden":e.title?null:"true","aria-label":e.title,class:"material-design-icon account-icon",role:"img",onClick:t[0]||(t[0]=h=>a.$emit("click",h))}),[(l(),s("svg",{fill:e.fillColor,class:"material-design-icon__svg",width:e.size,height:e.size,viewBox:"0 0 24 24"},[m("path",P,[e.title?(l(),s("title",Q,u(e.title),1)):v("",!0)])],8,K))],16,J)}const X=w(G,[["render",W]]),Y={name:"RestoreIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},ee=["aria-hidden","aria-label"],te=["fill","width","height"],ae={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"},ne={key:0};function le(a,t,e,o,n,c){return l(),s("span",M(a.$attrs,{"aria-hidden":e.title?null:"true","aria-label":e.title,class:"material-design-icon restore-icon",role:"img",onClick:t[0]||(t[0]=h=>a.$emit("click",h))}),[(l(),s("svg",{fill:e.fillColor,class:"material-design-icon__svg",width:e.size,height:e.size,viewBox:"0 0 24 24"},[m("path",ae,[e.title?(l(),s("title",ne,u(e.title),1)):v("",!0)])],8,te))],16,ee)}const $=w(Y,[["render",le]]),ie={name:"TrayArrowUpIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},oe=["aria-hidden","aria-label"],se=["fill","width","height"],ce={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 de(a,t,e,o,n,c){return l(),s("span",M(a.$attrs,{"aria-hidden":e.title?null:"true","aria-label":e.title,class:"material-design-icon tray-arrow-up-icon",role:"img",onClick:t[0]||(t[0]=h=>a.$emit("click",h))}),[(l(),s("svg",{fill:e.fillColor,class:"material-design-icon__svg",width:e.size,height:e.size,viewBox:"0 0 24 24"},[m("path",ce,[e.title?(l(),s("title",re,u(e.title),1)):v("",!0)])],8,se))],16,oe)}const R=w(ie,[["render",de]]),pe={name:"TrayArrowDownIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},ue=["aria-hidden","aria-label"],me=["fill","width","height"],he={d:"M2 12H4V17H20V12H22V17C22 18.11 21.11 19 20 19H4C2.9 19 2 18.11 2 17V12M12 15L17.55 9.54L16.13 8.13L13 11.25V2H11V11.25L7.88 8.13L6.46 9.55L12 15Z"},ve={key:0};function fe(a,t,e,o,n,c){return l(),s("span",M(a.$attrs,{"aria-hidden":e.title?null:"true","aria-label":e.title,class:"material-design-icon tray-arrow-down-icon",role:"img",onClick:t[0]||(t[0]=h=>a.$emit("click",h))}),[(l(),s("svg",{fill:e.fillColor,class:"material-design-icon__svg",width:e.size,height:e.size,viewBox:"0 0 24 24"},[m("path",he,[e.title?(l(),s("title",ve,u(e.title),1)):v("",!0)])],8,me))],16,ue)}const ge=w(pe,[["render",fe]]),Ce={class:"download-button"},we={class:"download-button__label"},ye=H({__name:"ExampleContentDownloadButton",props:{href:{}},setup(a){return(t,e)=>(l(),x(b(S),{variant:"tertiary",href:a.href},{icon:i(()=>[B(t.$slots,"icon",{},void 0,!0)]),default:i(()=>[m("div",Ce,[m("span",we,[B(t.$slots,"default",{},void 0,!0)]),r(ge,{class:"download-button__icon",size:20})])]),_:3},8,["href"]))}}),O=w(ye,[["__scopeId","data-v-be40807a"]]),be=E("dav","enableDefaultContact",!1),xe=E("dav","hasCustomDefaultContact",!1),ke={name:"ExampleContactSettings",components:{NcDialog:U,NcButton:S,NcCheckboxRadioSwitch:F,IconUpload:R,IconRestore:$,IconAccount:X,ExampleContentDownloadButton:O},setup(){return{t:d}},data(){return{enableDefaultContact:be,hasCustomDefaultContact:xe,isModalOpen:!1,loading:!1,buttons:[{label:d("dav","Cancel"),icon:j,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(){k.put(C("apps/dav/api/defaultcontact/config"),{allow:!this.enableDefaultContact}).then(()=>{this.enableDefaultContact=!this.enableDefaultContact}).catch(()=>{_(d("dav","Error while saving settings"))})},toggleModal(){this.isModalOpen=!this.isModalOpen},clickImportInput(){this.$refs.exampleContactImportInput.click()},resetContact(){this.loading=!0,k.put(C("/apps/dav/api/defaultcontact/contact")).then(()=>{this.hasCustomDefaultContact=!1,L(d("dav","Contact reset successfully"))}).catch(a=>{I.error("Error importing contact:",{error:a}),_(d("dav","Error while resetting contact"))}).finally(()=>{this.loading=!1})},processFile(a){this.loading=!0;const t=a.target.files[0],e=new FileReader;e.onload=async()=>{this.isModalOpen=!1;try{await k.put(C("/apps/dav/api/defaultcontact/contact"),{contactData:e.result}),this.hasCustomDefaultContact=!0,L(d("dav","Contact imported successfully"))}catch(o){I.error("Error importing contact:",{error:o}),_(d("dav","Error while importing contact"))}finally{this.loading=!1,a.target.value=""}},e.readAsText(t)}}},_e={class:"example-contact-settings"},Ee={key:0,class:"example-contact-settings__buttons"},Ie=["disabled"];function Me(a,t,e,o,n,c){const h=p("NcCheckboxRadioSwitch"),V=p("IconAccount"),z=p("ExampleContentDownloadButton"),D=p("IconUpload"),y=p("NcButton"),A=p("IconRestore"),N=p("NcDialog");return l(),s("div",_e,[r(h,{checked:n.enableDefaultContact,type:"switch","onUpdate:modelValue":c.updateEnableDefaultContact},{default:i(()=>[g(u(o.t("dav","Add example contact to user's address book when they first log in")),1)]),_:1},8,["checked","onUpdate:modelValue"]),n.enableDefaultContact?(l(),s("div",Ee,[r(z,{href:c.downloadUrl},{icon:i(()=>[r(V,{size:20})]),default:i(()=>[t[2]||(t[2]=g(" example_contact.vcf ",-1))]),_:1},8,["href"]),r(y,{variant:"secondary",onClick:c.toggleModal},{icon:i(()=>[r(D,{size:20})]),default:i(()=>[g(" "+u(o.t("dav","Import contact")),1)]),_:1},8,["onClick"]),n.hasCustomDefaultContact?(l(),x(y,{key:0,variant:"tertiary",onClick:c.resetContact},{icon:i(()=>[r(A,{size:20})]),default:i(()=>[g(" "+u(o.t("dav","Reset to default")),1)]),_:1},8,["onClick"])):v("",!0)])):v("",!0),r(N,{open:n.isModalOpen,"onUpdate:open":t[0]||(t[0]=f=>n.isModalOpen=f),name:o.t("dav","Import contacts"),buttons:n.buttons},{default:i(()=>[m("div",null,[m("p",null,u(o.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:t[1]||(t[1]=(...f)=>c.processFile&&c.processFile(...f))},null,40,Ie)])}const De=w(ke,[["render",Me],["__scopeId","data-v-cd78f96d"]]),Le={name:"CalendarBlankIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},Ve=["aria-hidden","aria-label"],ze=["fill","width","height"],Ae={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"},Ne={key:0};function Se(a,t,e,o,n,c){return l(),s("span",M(a.$attrs,{"aria-hidden":e.title?null:"true","aria-label":e.title,class:"material-design-icon calendar-blank-icon",role:"img",onClick:t[0]||(t[0]=h=>a.$emit("click",h))}),[(l(),s("svg",{fill:e.fillColor,class:"material-design-icon__svg",width:e.size,height:e.size,viewBox:"0 0 24 24"},[m("path",Ae,[e.title?(l(),s("title",Ne,u(e.title),1)):v("",!0)])],8,ze))],16,Ve)}const Be=w(Le,[["render",Se]]);async function He(a){const t=C("/apps/dav/api/exampleEvent/enable");await k.post(t,{enable:a})}async function Fe(a){const t=C("/apps/dav/api/exampleEvent/event");await k.post(t,{ics:a})}async function Ue(){const a=C("/apps/dav/api/exampleEvent/event");await k.delete(a)}const $e={name:"ExampleEventSettings",components:{NcButton:S,NcCheckboxRadioSwitch:F,NcDialog:U,IconCalendarBlank:Be,IconUpload:R,IconRestore:$,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 He(a)}catch(t){_(d("dav","Failed to save example event creation setting")),I.error("Failed to save example event creation setting",{error:t,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 t=a.result;try{await Fe(t)}catch(e){_(d("dav","Failed to upload the example event")),I.error("Failed to upload example ICS",{error:e,ics:t});return}finally{this.uploading=!1}L(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 Ue()}catch(a){_(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}L(d("dav","Custom example event was deleted successfully")),this.hasCustomEvent=!1}}},Re={class:"example-event-settings"},Oe={key:0,class:"example-event-settings__buttons"},Ze={class:"import-event-modal"},Te=["disabled"],je={class:"import-event-modal__buttons"};function qe(a,t,e,o,n,c){const h=p("NcCheckboxRadioSwitch"),V=p("IconCalendarBlank"),z=p("ExampleContentDownloadButton"),D=p("IconUpload"),y=p("NcButton"),A=p("IconRestore"),N=p("NcDialog");return l(),s("div",Re,[r(h,{checked:n.createExampleEvent,disabled:n.savingConfig,type:"switch","onUpdate:modelValue":c.updateCreateExampleEvent},{default:i(()=>[g(u(o.t("dav","Add example event to user's calendar when they first log in")),1)]),_:1},8,["checked","disabled","onUpdate:modelValue"]),n.createExampleEvent?(l(),s("div",Oe,[r(z,{href:c.downloadUrl},{icon:i(()=>[r(V,{size:20})]),default:i(()=>[t[4]||(t[4]=g(" example_event.ics ",-1))]),_:1},8,["href"]),r(y,{variant:"secondary",onClick:t[0]||(t[0]=f=>n.showImportModal=!0)},{icon:i(()=>[r(D,{size:20})]),default:i(()=>[g(" "+u(o.t("dav","Import calendar event")),1)]),_:1}),n.hasCustomEvent?(l(),x(y,{key:0,variant:"tertiary",disabled:n.deleting,onClick:c.deleteCustomEvent},{icon:i(()=>[r(A,{size:20})]),default:i(()=>[g(" "+u(o.t("dav","Reset to default")),1)]),_:1},8,["disabled","onClick"])):v("",!0)])):v("",!0),r(N,{open:n.showImportModal,"onUpdate:open":t[3]||(t[3]=f=>n.showImportModal=f),name:o.t("dav","Import calendar event")},{default:i(()=>[m("div",Ze,[m("p",null,u(o.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:t[1]||(t[1]=(...f)=>c.selectFile&&c.selectFile(...f))},null,40,Te),m("div",je,[r(y,{disabled:n.uploading||!n.selectedFile,variant:"primary",onClick:t[2]||(t[2]=f=>c.uploadCustomEvent())},{icon:i(()=>[r(D,{size:20})]),default:i(()=>[g(" "+u(o.t("dav","Upload event")),1)]),_:1},8,["disabled"])])])]),_:1},8,["open","name"])])}const Ge=w($e,[["render",qe],["__scopeId","data-v-6e8ec0f6"]]),Je=H({__name:"ExampleContentSettingsSection",setup(a){const t=E("dav","contactsEnabled"),e=E("dav","calendarEnabled");return(o,n)=>(l(),x(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:i(()=>[b(t)?(l(),x(De,{key:0})):v("",!0),b(e)?(l(),x(Ge,{key:1})):v("",!0)]),_:1},8,["name","description"]))}}),Ke=T(Je);Ke.mount("#settings-example-content");
//# sourceMappingURL=dav-settings-admin-example-content.mjs.map