mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
import{b as S,a0 as Q,r as b,v as $,c as _,o as p,w as g,k as v,e as m,j as C,l as B,t as y,u as e,g as U,a1 as N,a2 as J,S as te,a3 as le,y as ne,Z as L,n as k,N as ie,p as X,m as oe,J as se,x as re,F as Z,h as ue}from"./runtime-dom.esm-bundler-DSTOTAEf.chunk.mjs";import{l as V,a as A}from"./index-xFugdZPW.chunk.mjs";import{N as de}from"./NcNoteCard-CVhtNL04-CdF6Qoal.chunk.mjs";import{c as T,i as R}from"./index-D9L8KHF3.chunk.mjs";import{a as x}from"./index-JpgrUA2Z-D4yQFKNw.chunk.mjs";import{t}from"./translation-DoG5ZELJ-2ffMJaM4.chunk.mjs";import{g as w}from"./createElementId-DhjFt1I9-Bjk2333q.chunk.mjs";import{N as G}from"./NcCheckboxRadioSwitch-BCSKF7Tk-BDM2s1GW.chunk.mjs";import{N as me}from"./NcSelect-Czzsi3P_-wYuKB0zM.chunk.mjs";import{N as O}from"./ContentCopy-caJ7vqeg.chunk.mjs";import{l as D,A as ce,g as pe,r as P}from"./refreshStyles-f-d6PTSt.chunk.mjs";import{N as q,g as ge,h as Y,i as he}from"./mdi-kAZc0JKn.chunk.mjs";import{_ as fe}from"./TrashCanOutline-DKx7CxBb.chunk.mjs";import{w as ee}from"./index-Dzo4H_NA.chunk.mjs";import{c as M,N as z}from"./logger-D3RVzcfQ-iUjwSNGe.chunk.mjs";import{N as ye}from"./NcColorPicker-Kc0JqRtp-DZI9oazy.chunk.mjs";import"./modulepreload-polyfill-BxzAKjcf.chunk.mjs";import"./index-6_gsQFyp.chunk.mjs";import"./string_decoder-BO00msnV.chunk.mjs";import"./NcInputField-Bwsh2aHY-Bf_22pmD.chunk.mjs";import"./colors-Go3zmZRD-Bml2X1sg.chunk.mjs";const ve={class:"info-note"},be=["aria-labelledby"],_e=["id"],ke={class:"info-note"},we=S({__name:"AdminSectionAppMenu",setup(l){const d=Q(),{defaultApps:a}=V("theming","adminThemingParameters"),n=V("core","apps").map(({id:r,name:s,icon:u})=>({label:s,id:r,icon:u})),i=b(a.map(r=>n.find(s=>s.id===r)).filter(Boolean));$(i,async r=>{try{await c("defaultApps",r.map(s=>s.id))}catch(s){D.error("Could not set global default apps",{error:s}),x(t("theming","Could not set global default apps"))}});const o=b(a.length>0);$(o,r=>{i.value=r?n.filter(s=>["dashboard","files"].includes(s.id)):[]});async function c(r,s){const u=w("/apps/theming/ajax/updateAppMenu");return await T.put(u,{setting:r,value:s})}return(r,s)=>(p(),_(e(O),{name:e(t)("theming","Navigation bar settings")},{default:g(()=>[v("h3",null,y(e(t)("theming","Default app")),1),v("p",ve,y(e(t)("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(G),{modelValue:o.value,"onUpdate:modelValue":s[0]||(s[0]=u=>o.value=u),type:"switch"},{default:g(()=>[U(y(e(t)("theming","Use custom default app")),1)]),_:1},8,["modelValue"]),o.value?(p(),C("section",{key:0,"aria-labelledby":e(d)},[v("h4",{id:e(d)},y(e(t)("theming","Global default app")),9,_e),m(e(me),{modelValue:i.value,"onUpdate:modelValue":s[1]||(s[1]=u=>i.value=u),keepOpen:"",multiple:"",placeholder:e(t)("theming","Global default apps"),options:e(n)},null,8,["modelValue","placeholder","options"]),v("h5",null,y(e(t)("theming","Default app priority")),1),v("p",ke,y(e(t)("theming","If an app is not enabled for a user, the next app with lower priority is used.")),1),m(ce,{modelValue:i.value,"onUpdate:modelValue":s[2]||(s[2]=u=>i.value=u)},null,8,["modelValue"])],8,be)):B("",!0)]),_:1},8,["name"]))}}),Ve=A(we,[["__scopeId","data-v-a9baec70"]]);function E(l,d,a){let n=!1;const i=b(!1),o=b(!1);ee(d,async()=>{if(!i.value){if(n){n=!1;return}i.value=!0,o.value=!1;try{await Fe(N(l),N(d)),o.value=!0,window.setTimeout(()=>{o.value=!1},2e3)}finally{i.value=!1}}},{debounce:800,flush:"sync"});async function c(){i.value=!0,o.value=!1;try{const r=await Te(N(l));r&&te(a)&&!le(a)&&(a.value=r),n=!0,d.value=N(a)}finally{i.value=!1}}return{isSaving:J(i),isSaved:J(o),reset:c}}async function Fe(l,d){const a=w("/apps/theming/ajax/updateStylesheet");try{await T.post(a,{setting:l,value:String(d)})}catch(n){throw D.error("Failed to save changes",{error:n,setting:l,value:d}),R(n)&&n.response?.data?.data?.message&&x(n.response.data.data.message),n}}async function Te(l){const d=w("/apps/theming/ajax/undoChanges");try{const{data:a}=await T.post(d,{setting:l});return a.data.value}catch(a){if(D.error("Failed to reset theming value",{error:a,setting:l}),R(a)&&a.response?.data?.data?.message)return x(a.response.data.data.message),!1;throw a}}const I=S({__name:"TextField",props:{name:{},label:{},defaultValue:{},type:{default:"text"}},setup(l){const d=l,a=b(V("theming","adminThemingParameters")[d.name].toString()),{isSaving:n,isSaved:i,reset:o}=E(L(()=>d.name),a,L(()=>d.defaultValue));return ee(a,c=>{if(d.type==="url"&&c.includes('"'))try{const r=new URL(c);r.pathname=r.pathname.replaceAll(/"/g,"%22"),a.value=r.href}catch{return}},{debounce:600}),(c,r)=>(p(),_(e(fe),{modelValue:a.value,"onUpdate:modelValue":r[0]||(r[0]=s=>a.value=s),label:l.label,readonly:e(n),success:e(i),type:l.type,showTrailingButton:a.value!==l.defaultValue,trailingButtonIcon:l.defaultValue?"undo":"close",onTrailingButtonClick:e(o)},ne({_:2},[e(n)?{name:"icon",fn:g(()=>[m(e(q))]),key:"0"}:void 0]),1032,["modelValue","label","readonly","success","type","showTrailingButton","trailingButtonIcon","onTrailingButtonClick"]))}}),Ue=S({__name:"AdminSectionTheming",setup(l){const d=V("theming","adminThemingInfo");return(a,n)=>(p(),_(e(O),{name:e(t)("theming","Theming"),description:e(t)("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(()=>[v("div",{class:k(a.$style.adminSectionTheming)},[m(I,{name:"name",label:e(t)("theming","Name"),defaultValue:"Nextcloud",maxlength:"250"},null,8,["label"]),m(I,{name:"url",label:e(t)("theming","Web link"),defaultValue:"https://nextcloud.com",placeholder:"https://…",type:"url",maxlength:"500"},null,8,["label"]),m(I,{name:"slogan",label:e(t)("theming","Slogan"),defaultValue:e(t)("settings","a safe home for all your data"),maxlength:"500"},null,8,["label","defaultValue"]),n[0]||(n[0]=v("hr",null,null,-1)),m(I,{name:"legalNoticeUrl",label:e(t)("theming","Legal notice link"),defaultValue:"",type:"url",placeholder:"https://…",maxlength:"500"},null,8,["label"]),m(I,{name:"privacyPolicyUrl",label:e(t)("theming","Privacy policy link"),defaultValue:"",type:"url",placeholder:"https://…",maxlength:"500"},null,8,["label"])],2)]),_:1},8,["name","description","docUrl"]))}}),xe="_adminSectionTheming_1p8pd_2",Se={adminSectionTheming:xe},Pe={$style:Se},Ce=A(Ue,[["__cssModules",Pe]]),Ie=S({__name:"ColorPickerField",props:{name:{},label:{},defaultValue:{}},emits:["updated"],setup(l,{emit:d}){const a=l,n=d,i=Q(),o=b(V("theming","adminThemingParameters")[a.name]),c=b(o.value);$(o,h=>{c.value=h});const{isSaving:r,reset:s}=E(()=>a.name,o,L(a,"defaultValue"));$(r,h=>!h&&n("updated"));const u=X(()=>pe(c.value));return(h,f)=>(p(),C("div",{class:k(h.$style.colorPickerField)},[v("div",{class:k(h.$style.colorPickerField__row)},[m(e(ye),{id:e(i),modelValue:c.value,"onUpdate:modelValue":f[0]||(f[0]=F=>c.value=F),advancedFields:"",onSubmit:f[1]||(f[1]=F=>o.value=F)},{default:g(()=>[m(e(M),{class:k(h.$style.colorPickerField__button),size:"large",variant:"primary",style:ie({"--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(r)?(p(),_(e(q),{key:0,appearance:u.value==="#ffffff"?"light":"dark"},null,8,["appearance"])):(p(),_(e(z),{key:1,path:e(ge)},null,8,["path"]))]),default:g(()=>[U(" "+y(l.label),1)]),_:1},8,["class","style"])]),_:1},8,["id","modelValue"]),o.value!==l.defaultValue?(p(),_(e(M),{key:0,variant:"tertiary","aria-label":e(t)("theming","Reset to default"),title:e(t)("theming","Reset to default"),onClick:e(s)},{icon:g(()=>[m(e(z),{path:e(Y)},null,8,["path"])]),_:1},8,["aria-label","title","onClick"])):B("",!0)],2),v("p",{class:k(h.$style.colorPickerField__description)},[oe(h.$slots,"description")],2)],2))}}),$e="_colorPickerField_o0yey_2",Ae="_colorPickerField__row_o0yey_7",Ne="_colorPickerField__button_o0yey_14",je="_colorPickerField__description_o0yey_18",Be={colorPickerField:$e,colorPickerField__row:Ae,colorPickerField__button:Ne,colorPickerField__description:je},Me={$style:Be},H=A(Ie,[["__cssModules",Me]]),ze=["aria-label"],Re=["disabled","name"],De=S({__name:"FileInputField",props:{name:{},label:{},disabled:{type:Boolean}},emits:["updated"],setup(l,{emit:d}){se(f=>({v64992c7e:r.value}));const a=l,n=d,i=b(!1),o=b(V("theming","adminThemingParameters")[a.name+"Mime"]),c=re("input"),r=X(()=>`url(${w("/apps/theming/image/{key}",{key:a.name})}?v=${Date.now()}&m=${encodeURIComponent(o.value)})`);function s(){i.value||(c.value.files=null,c.value.click())}async function u(){if(!c.value.files?.[0])return;const f=c.value.files[0];if(f.type&&!f.type.startsWith("image/")){x(t("theming","Non image file selected"));return}i.value=!0;const F=new FormData;F.append("image",f),F.append("key",a.name);try{await T.post(w("/apps/theming/ajax/uploadImage"),F,{headers:{"Content-Type":"multipart/form-data"}}),o.value=f.type,n("updated")}catch(W){if(R(W)&&W.response?.status===422){const ae=W.response.data?.data?.message;x(ae||t("theming","Failed to upload image"))}else x(t("theming","Failed to upload image"))}finally{i.value=!1,c.value.value=""}}async function h(){if(!i.value){i.value=!0;try{await T.post(w("/apps/theming/ajax/undoChanges"),{setting:a.name}),o.value="",n("updated")}finally{i.value=!1}}}return(f,F)=>(p(),C("div",{class:k(f.$style.fileInputField)},[m(e(M),{class:k(f.$style.fileInputField__button),alignment:"start",disabled:l.disabled,size:"large",onClick:s},{icon:g(()=>[i.value?(p(),_(e(q),{key:0})):(p(),_(e(z),{key:1,path:e(he)},null,8,["path"]))]),default:g(()=>[U(" "+y(l.label),1)]),_:1},8,["class","disabled"]),o.value.startsWith("image/")?(p(),C("div",{key:0,class:k(f.$style.fileInputField__preview),role:"img","aria-label":e(t)("theming","Preview of the selected image")},null,10,ze)):B("",!0),o.value&&!l.disabled?(p(),_(e(M),{key:1,"aria-label":e(t)("theming","Reset to default"),title:e(t)("theming","Reset to default"),size:"large",variant:"tertiary",onClick:h},{icon:g(()=>[m(e(z),{path:e(Y)},null,8,["path"])]),_:1},8,["aria-label","title"])):B("",!0),v("input",{ref:"input",class:"hidden-visually","aria-hidden":"true",disabled:l.disabled,type:"file",accept:"image/*",name:l.name,onChange:u},null,40,Re)],2))}}),We="_fileInputField_1u7zs_2",Le="_fileInputField__button_1u7zs_10",Ge="_fileInputField__preview_1u7zs_14",Oe={fileInputField:We,fileInputField__button:Le,fileInputField__preview:Ge},qe={$style:Oe},j=A(De,[["__cssModules",qe]]),Ee=S({__name:"AdminSectionThemingAdvanced",setup(l){const{defaultBackgroundColor:d}=V("theming","adminThemingInfo"),a=V("theming","adminThemingParameters"),n=b(a.disableUserTheming),{isSaving:i}=E("disableUserTheming",n,!1),o=b(!1),c=b(a.backgroundMime==="backgroundColor");$(c,r);async function r(s){o.value=!0;try{s?(await T.post(w("/apps/theming/ajax/undoChanges"),{setting:"background"}),await T.post(w("/apps/theming/ajax/updateStylesheet"),{setting:"backgroundMime",value:"backgroundColor"})):await T.post(w("/apps/theming/ajax/undoChanges"),{setting:"backgroundMime"}),await P()}catch(u){if(D.error("Failed to remove background image",{error:u}),R(u)&&u.response?.data?.data?.message){x(u.response.data.data.message);return}throw u}finally{o.value=!1}}return(s,u)=>(p(),_(e(O),{name:e(t)("theming","Background and color")},{default:g(()=>[v("div",{class:k(s.$style.adminSectionThemingAdvanced)},[m(H,{name:"primaryColor",label:e(t)("theming","Primary color"),defaultValue:"#00679e",onUpdated:e(P)},{description:g(()=>[U(y(e(t)("theming","Set the default primary color, used to highlight important elements."))+" "+y(e(t)("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(H,{name:"backgroundColor",label:e(t)("theming","Background color"),defaultValue:e(d),onUpdated:e(P)},{description:g(()=>[U(y(e(t)("theming","When no background image is set the background color will be used."))+" "+y(e(t)("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(G),{modelValue:c.value,"onUpdate:modelValue":u[0]||(u[0]=h=>c.value=h),type:"switch",loading:o.value,description:e(t)("theming","Use a plain background color instead of a background image.")},{default:g(()=>[U(y(e(t)("theming","Remove background image")),1)]),_:1},8,["modelValue","loading","description"]),m(j,{name:"background",disabled:c.value,label:e(t)("theming","Background image"),onUpdated:e(P)},null,8,["disabled","label","onUpdated"]),m(j,{name:"favicon",label:e(t)("theming","Favicon")},null,8,["label"]),m(j,{name:"logo",label:e(t)("theming","Logo"),onUpdated:e(P)},null,8,["label","onUpdated"]),m(j,{name:"logoheader",label:e(t)("theming","Navigation bar logo"),onUpdated:e(P)},null,8,["label","onUpdated"]),u[2]||(u[2]=v("hr",null,null,-1)),m(e(G),{modelValue:n.value,"onUpdate:modelValue":u[1]||(u[1]=h=>n.value=h),type:"switch",loading:e(i),description:e(t)("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(()=>[U(y(e(t)("theming","Disable user theming")),1)]),_:1},8,["modelValue","loading","description"])],2)]),_:1},8,["name"]))}}),Je="_adminSectionThemingAdvanced_dyaj4_2",Ze={adminSectionThemingAdvanced:Je},He={$style:Ze},Ke=A(Ee,[["__cssModules",He]]),Qe=S({__name:"AdminTheming",setup(l){const{isThemeable:d,notThemeableErrorMessage:a}=V("theming","adminThemingInfo");return(n,i)=>(p(),C(Z,null,[e(d)?(p(),C(Z,{key:1},[m(Ce),m(Ke)],64)):(p(),_(e(de),{key:0,text:e(a),showAlert:"",type:"error"},null,8,["text"])),m(Ve)],64))}}),K=ue(Qe);K.config.idPrefix="settings",K.mount("#settings-admin-theming");
|
|
//# sourceMappingURL=theming-settings-admin.mjs.map
|