You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nextcloud-server/dist/theming-settings-admin.mjs

2 lines
14 KiB

import{b as x,U as Y,p as v,B as $,o as p,c as _,w as g,h as b,t as f,u as e,l as m,z as T,g as C,i as M,a1 as B,a2 as J,a3 as te,a4 as ne,v as ie,a5 as G,k,n as oe,j as se,y as Z,$ as re,s as ue,F as K,f as de}from"./Web-CGrAivgv.chunk.mjs";import{l as V,_ as A}from"./public-C1mLBHT3.chunk.mjs";import{N as me}from"./TrashCanOutline-CSbixKR2.chunk.mjs";import{c as F,i as D}from"./index-ChXuPuJU.chunk.mjs";import{a as U}from"./index-DYY4wUHN.chunk.mjs";import{t as l}from"./translation-DoG5ZELJ-Cnt4vXgN.chunk.mjs";import{b as w}from"./index-kP1pdrFW.chunk.mjs";import{N as O}from"./NcCheckboxRadioSwitch-DVdt5Hkq-Br1OKBC8.chunk.mjs";import{N as ce}from"./index-C9vOCEFf.chunk.mjs";import{N as q}from"./ContentCopy-Dp2WhVww.chunk.mjs";import{A as pe,l as W,g as ge,r as S}from"./refreshStyles-DUFbqZJ1.chunk.mjs";import{N as E}from"./Check-B8g3wLRC.chunk.mjs";import{_ as he}from"./NcTextField.vue_vue_type_script_setup_true_lang-Bx2esFU2-TaokGzY3.chunk.mjs";import{w as ee}from"./index-Axi4fOCK.chunk.mjs";import{n as fe,o as ae,p as ye}from"./mdi-CVr4TDRq.chunk.mjs";import{N as z}from"./logger-D3RVzcfQ-k6GV3wRV.chunk.mjs";import ve from"./index-DnejXa67.chunk.mjs";import{N as R}from"./createElementId-DhjFt1I9-DwrDuyxe.chunk.mjs";import"./modulepreload-polyfill-BxzAKjcf.chunk.mjs";import"./util-C9Hc1fff.chunk.mjs";import"./NcModal-DiDvgcU8-AyGpO2Wl.chunk.mjs";import"./NcInputField-5Sg6EUP6-Bm503eyF.chunk.mjs";import"./colors-Cv9F-jWS-BOqQ6yCH.chunk.mjs";const be={class:"info-note"},_e=["aria-labelledby"],ke=["id"],we={class:"info-note"},Ve=x({__name:"AdminSectionAppMenu",setup(n){const d=Y(),{defaultApps:a}=V("theming","adminThemingParameters"),i=V("core","apps").map(({id:t,name:r,icon:u})=>({label:r,id:t,icon:u})),o=v(a.map(t=>i.find(r=>r.id===t)).filter(Boolean));$(o,async t=>{try{await c("defaultApps",t.map(r=>r.id))}catch(r){W.error("Could not set global default apps",{error:r}),U(l("theming","Could not set global default apps"))}});const s=v(a.length>0);$(s,t=>{o.value=t?i.filter(r=>["dashboard","files"].includes(r.id)):[]});async function c(t,r){const u=w("/apps/theming/ajax/updateAppMenu");return await F.put(u,{setting:t,value:r})}return(t,r)=>(p(),_(e(q),{name:e(l)("theming","Navigation bar settings")},{default:g(()=>[b("h3",null,f(e(l)("theming","Default app")),1),b("p",be,f(e(l)("theming","The default app is the app that is e.g. opened after login or when the logo in the menu is clicked.")),1),m(e(O),{modelValue:s.value,"onUpdate:modelValue":r[0]||(r[0]=u=>s.value=u),type:"switch"},{default:g(()=>[T(f(e(l)("theming","Use custom default app")),1)]),_:1},8,["modelValue"]),s.value?(p(),C("section",{key:0,"aria-labelledby":e(d)},[b("h4",{id:e(d)},f(e(l)("theming","Global default app")),9,ke),m(e(ce),{modelValue:o.value,"onUpdate:modelValue":r[1]||(r[1]=u=>o.value=u),keepOpen:"",multiple:"",placeholder:e(l)("theming","Global default apps"),options:e(i)},null,8,["modelValue","placeholder","options"]),b("h5",null,f(e(l)("theming","Default app priority")),1),b("p",we,f(e(l)("theming","If an app is not enabled for a user, the next app with lower priority is used.")),1),m(pe,{modelValue:o.value,"onUpdate:modelValue":r[2]||(r[2]=u=>o.value=u)},null,8,["modelValue"])],8,_e)):M("",!0)]),_:1},8,["name"]))}}),Fe=A(Ve,[["__scopeId","data-v-a9baec70"]]);function H(n,d,a){let i=!1;const o=v(!1),s=v(!1);ee(d,async()=>{if(!o.value){if(i){i=!1;return}o.value=!0,s.value=!1;try{await Te(B(n),B(d)),s.value=!0,window.setTimeout(()=>{s.value=!1},2e3)}finally{o.value=!1}}},{debounce:800,flush:"sync"});async function c(){o.value=!0,s.value=!1;try{const t=await Ue(B(n));t&&te(a)&&!ne(a)&&(a.value=t),i=!0,d.value=B(a)}finally{o.value=!1}}return{isSaving:J(o),isSaved:J(s),reset:c}}async function Te(n,d){const a=w("/apps/theming/ajax/updateStylesheet");try{await F.post(a,{setting:n,value:String(d)})}catch(i){throw W.error("Failed to save changes",{error:i,setting:n,value:d}),D(i)&&i.response?.data?.data?.message&&U(i.response.data.data.message),i}}async function Ue(n){const d=w("/apps/theming/ajax/undoChanges");try{const{data:a}=await F.post(d,{setting:n});return a.data.value}catch(a){if(W.error("Failed to reset theming value",{error:a,setting:n}),D(a)&&a.response?.data?.data?.message)return U(a.response.data.data.message),!1;throw a}}const I=x({__name:"TextField",props:{name:{},label:{},defaultValue:{},type:{default:"text"}},setup(n){const d=n,a=v(V("theming","adminThemingParameters")[d.name].toString()),{isSaving:i,isSaved:o,reset:s}=H(G(()=>d.name),a,G(()=>d.defaultValue));return ee(a,c=>{if(d.type==="url"&&c.includes('"'))try{const t=new URL(c);t.pathname=t.pathname.replaceAll(/"/g,"%22"),a.value=t.href}catch{return}},{debounce:600}),(c,t)=>(p(),_(e(he),{modelValue:a.value,"onUpdate:modelValue":t[0]||(t[0]=r=>a.value=r),label:n.label,readonly:e(i),success:e(o),type:n.type,showTrailingButton:a.value!==n.defaultValue,trailingButtonIcon:n.defaultValue?"undo":"close",onTrailingButtonClick:e(s)},ie({_:2},[e(i)?{name:"icon",fn:g(()=>[m(e(E))]),key:"0"}:void 0]),1032,["modelValue","label","readonly","success","type","showTrailingButton","trailingButtonIcon","onTrailingButtonClick"]))}}),xe=x({__name:"AdminSectionTheming",setup(n){const d=V("theming","adminThemingInfo");return(a,i)=>(p(),_(e(q),{name:e(l)("theming","Theming"),description:e(l)("theming","Theming makes it possible to easily customize the look and feel of your instance and supported clients. This will be visible for all users."),docUrl:e(d).docUrl,"data-admin-theming-settings":""},{default:g(()=>[b("div",{class:k(a.$style.adminSectionTheming)},[m(I,{name:"name",label:e(l)("theming","Name"),defaultValue:"Nextcloud",maxlength:"250"},null,8,["label"]),m(I,{name:"url",label:e(l)("theming","Web link"),defaultValue:"https://nextcloud.com",placeholder:"https://…",type:"url",maxlength:"500"},null,8,["label"]),m(I,{name:"slogan",label:e(l)("theming","Slogan"),defaultValue:e(l)("settings","a safe home for all your data"),maxlength:"500"},null,8,["label","defaultValue"]),i[0]||(i[0]=b("hr",null,null,-1)),m(I,{name:"legalNoticeUrl",label:e(l)("theming","Legal notice link"),defaultValue:"",type:"url",placeholder:"https://…",maxlength:"500"},null,8,["label"]),m(I,{name:"privacyPolicyUrl",label:e(l)("theming","Privacy policy link"),defaultValue:"",type:"url",placeholder:"https://…",maxlength:"500"},null,8,["label"])],2)]),_:1},8,["name","description","docUrl"]))}}),Pe="_adminSectionTheming_1p8pd_2",Se={adminSectionTheming:Pe},Ce={$style:Se},Ie=A(xe,[["__cssModules",Ce]]),$e=x({__name:"ColorPickerField",props:{name:{},label:{},defaultValue:{}},emits:["updated"],setup(n,{emit:d}){const a=n,i=d,o=Y(),s=v(V("theming","adminThemingParameters")[a.name]),c=v(s.value);$(s,h=>{c.value=h});const{isSaving:t,reset:r}=H(()=>a.name,s,G(a,"defaultValue"));$(t,h=>!h&&i("updated"));const u=Z(()=>ge(c.value));return(h,P)=>(p(),C("div",{class:k(h.$style.colorPickerField)},[b("div",{class:k(h.$style.colorPickerField__row)},[m(e(ve),{id:e(o),modelValue:c.value,"onUpdate:modelValue":P[0]||(P[0]=y=>c.value=y),advancedFields:"",onSubmit:P[1]||(P[1]=y=>s.value=y)},{default:g(()=>[m(e(z),{class:k(h.$style.colorPickerField__button),size:"large",variant:"primary",style:oe({"--color-primary-element":c.value,"--color-primary-element-text":u.value,"--color-primary-element-hover":"color-mix(in srgb, var(--color-primary-element) 70%, var(--color-primary-element-text))"})},{icon:g(()=>[e(t)?(p(),_(e(E),{key:0,appearance:u.value==="#ffffff"?"light":"dark"},null,8,["appearance"])):(p(),_(e(R),{key:1,path:e(fe)},null,8,["path"]))]),default:g(()=>[T(" "+f(n.label),1)]),_:1},8,["class","style"])]),_:1},8,["id","modelValue"]),s.value!==n.defaultValue?(p(),_(e(z),{key:0,variant:"tertiary","aria-label":e(l)("theming","Reset to default"),title:e(l)("theming","Reset to default"),onClick:e(r)},{icon:g(()=>[m(e(R),{path:e(ae)},null,8,["path"])]),_:1},8,["aria-label","title","onClick"])):M("",!0)],2),b("p",{class:k(h.$style.colorPickerField__description)},[se(h.$slots,"description")],2)],2))}}),Ae="_colorPickerField_o0yey_2",Ne="_colorPickerField__row_o0yey_7",Be="_colorPickerField__button_o0yey_14",je="_colorPickerField__description_o0yey_18",Me={colorPickerField:Ae,colorPickerField__row:Ne,colorPickerField__button:Be,colorPickerField__description:je},ze={$style:Me},Q=A($e,[["__cssModules",ze]]),Re=["aria-label"],De=["disabled","name"],We=x({__name:"FileInputField",props:{name:{},label:{},disabled:{type:Boolean}},emits:["updated"],setup(n,{emit:d}){re(y=>({v6c51c3da:r.value}));const a=n,i=d,o=v(!1),s=v(V("theming","adminThemingParameters")[a.name+"Mime"]),c=v(Date.now()),t=ue("input"),r=Z(()=>`url(${w("/apps/theming/image/{key}",{key:a.name})}?v=${c.value}&m=${encodeURIComponent(s.value)})`);function u(){o.value||(t.value.files=null,t.value.click())}async function h(){if(!t.value.files?.[0])return;const y=t.value.files[0];if(y.type&&!y.type.startsWith("image/")){U(l("theming","Non image file selected"));return}o.value=!0;const N=new FormData;N.append("image",y),N.append("key",a.name);try{await F.post(w("/apps/theming/ajax/uploadImage"),N,{headers:{"Content-Type":"multipart/form-data"}}),s.value=y.type,c.value=Date.now(),i("updated")}catch(L){if(D(L)&&L.response?.status===422){const le=L.response.data?.data?.message;U(le||l("theming","Failed to upload image"))}else U(l("theming","Failed to upload image"))}finally{o.value=!1,t.value.value=""}}async function P(){if(!o.value){o.value=!0;try{await F.post(w("/apps/theming/ajax/undoChanges"),{setting:a.name}),s.value="",i("updated")}finally{o.value=!1}}}return(y,N)=>(p(),C("div",{class:k(y.$style.fileInputField)},[m(e(z),{class:k(y.$style.fileInputField__button),alignment:"start",disabled:n.disabled,size:"large",onClick:u},{icon:g(()=>[o.value?(p(),_(e(E),{key:0})):(p(),_(e(R),{key:1,path:e(ye)},null,8,["path"]))]),default:g(()=>[T(" "+f(n.label),1)]),_:1},8,["class","disabled"]),s.value.startsWith("image/")?(p(),C("div",{key:0,class:k(y.$style.fileInputField__preview),role:"img","aria-label":e(l)("theming","Preview of the selected image")},null,10,Re)):M("",!0),s.value&&!n.disabled?(p(),_(e(z),{key:1,"aria-label":e(l)("theming","Reset to default"),title:e(l)("theming","Reset to default"),size:"large",variant:"tertiary",onClick:P},{icon:g(()=>[m(e(R),{path:e(ae)},null,8,["path"])]),_:1},8,["aria-label","title"])):M("",!0),b("input",{ref:"input",class:"hidden-visually","aria-hidden":"true",disabled:n.disabled,type:"file",accept:"image/*",name:n.name,onChange:h},null,40,De)],2))}}),Le="_fileInputField_1u7zs_2",Ge="_fileInputField__button_1u7zs_10",Oe="_fileInputField__preview_1u7zs_14",qe={fileInputField:Le,fileInputField__button:Ge,fileInputField__preview:Oe},Ee={$style:qe},j=A(We,[["__cssModules",Ee]]),He=x({__name:"AdminSectionThemingAdvanced",setup(n){const{defaultBackgroundColor:d}=V("theming","adminThemingInfo"),a=V("theming","adminThemingParameters"),i=v(a.disableUserTheming),{isSaving:o}=H("disableUserTheming",i,!1),s=v(!1),c=v(a.backgroundMime==="backgroundColor");$(c,t);async function t(r){s.value=!0;try{r?(await F.post(w("/apps/theming/ajax/undoChanges"),{setting:"background"}),await F.post(w("/apps/theming/ajax/updateStylesheet"),{setting:"backgroundMime",value:"backgroundColor"})):await F.post(w("/apps/theming/ajax/undoChanges"),{setting:"backgroundMime"}),await S()}catch(u){if(W.error("Failed to remove background image",{error:u}),D(u)&&u.response?.data?.data?.message){U(u.response.data.data.message);return}throw u}finally{s.value=!1}}return(r,u)=>(p(),_(e(q),{name:e(l)("theming","Background and color")},{default:g(()=>[b("div",{class:k(r.$style.adminSectionThemingAdvanced)},[m(Q,{name:"primaryColor",label:e(l)("theming","Primary color"),defaultValue:"#00679e",onUpdated:e(S)},{description:g(()=>[T(f(e(l)("theming","Set the default primary color, used to highlight important elements."))+" "+f(e(l)("theming","The color used for elements such as primary buttons might differ a bit as it gets adjusted to fulfill accessibility requirements.")),1)]),_:1},8,["label","onUpdated"]),m(Q,{name:"backgroundColor",label:e(l)("theming","Background color"),defaultValue:e(d),onUpdated:e(S)},{description:g(()=>[T(f(e(l)("theming","When no background image is set the background color will be used."))+" "+f(e(l)("theming","Otherwise the background color is by default generated from the background image, but can be adjusted to fine tune the color of the navigation icons.")),1)]),_:1},8,["label","defaultValue","onUpdated"]),m(e(O),{modelValue:c.value,"onUpdate:modelValue":u[0]||(u[0]=h=>c.value=h),type:"switch",loading:s.value,description:e(l)("theming","Use a plain background color instead of a background image.")},{default:g(()=>[T(f(e(l)("theming","Remove background image")),1)]),_:1},8,["modelValue","loading","description"]),m(j,{name:"background",disabled:c.value,label:e(l)("theming","Background image"),onUpdated:e(S)},null,8,["disabled","label","onUpdated"]),m(j,{name:"favicon",label:e(l)("theming","Favicon")},null,8,["label"]),m(j,{name:"logo",label:e(l)("theming","Logo"),onUpdated:e(S)},null,8,["label","onUpdated"]),m(j,{name:"logoheader",label:e(l)("theming","Navigation bar logo"),onUpdated:e(S)},null,8,["label","onUpdated"]),u[2]||(u[2]=b("hr",null,null,-1)),m(e(O),{modelValue:i.value,"onUpdate:modelValue":u[1]||(u[1]=h=>i.value=h),type:"switch",loading:e(o),description:e(l)("theming","Although you can select and customize your instance, users can change their background and colors. If you want to enforce your customization, you can toggle this on.")},{default:g(()=>[T(f(e(l)("theming","Disable user theming")),1)]),_:1},8,["modelValue","loading","description"])],2)]),_:1},8,["name"]))}}),Je="_adminSectionThemingAdvanced_dyaj4_2",Ke={adminSectionThemingAdvanced:Je},Qe={$style:Ke},Xe=A(He,[["__cssModules",Qe]]),Ye=x({__name:"AdminTheming",setup(n){const{isThemeable:d,notThemeableErrorMessage:a}=V("theming","adminThemingInfo");return(i,o)=>(p(),C(K,null,[e(d)?(p(),C(K,{key:1},[m(Ie),m(Xe)],64)):(p(),_(e(me),{key:0,text:e(a),showAlert:"",type:"error"},null,8,["text"])),m(Fe)],64))}}),X=de(Ye);X.config.idPrefix="settings",X.mount("#settings-admin-theming");
//# sourceMappingURL=theming-settings-admin.mjs.map