airdcpp-webui
Version:
2 lines • 11 kB
JavaScript
;(self.webpackChunkairdcpp_webui=self.webpackChunkairdcpp_webui||[]).push([[580],{19430:(e,t,n)=>{n.d(t,{T:()=>r,v:()=>o});var a=n(86818);const o=(e,{formatSize:t})=>{let n=e.str;return e.id!==a.A.HIDDEN_PROFILE_ID&&(n+=` (${t(e.size)})`),n},r=(e,t)=>({id:e.id,name:o(e,t)})},23896:(e,t,n)=>{n.d(t,{A:()=>s});var a=n(71354),o=n.n(a),r=n(76314),i=n.n(r)()(o());i.push([e.id,".virtual-table .cell-wrapper.connected,\n.virtual-table .cell-wrapper.connected span,\n.virtual-table .cell-wrapper.connected strong {\n color: green;\n}\n\n.virtual-table .cell-wrapper.connecting,\n.virtual-table .cell-wrapper.connecting span,\n.virtual-table .cell-wrapper.connecting strong {\n color: orange;\n}\n\n.virtual-table .cell-wrapper.disconnected,\n.virtual-table .cell-wrapper.disconnected span,\n.virtual-table .cell-wrapper.disconnected strong {\n color: dimslategray;\n}\n","",{version:3,sources:["webpack://./src/routes/FavoriteHubs/style.css"],names:[],mappings:"AAAA;;;EAGE,YAAY;AACd;;AAEA;;;EAGE,aAAa;AACf;;AAEA;;;EAGE,mBAAmB;AACrB",sourcesContent:[".virtual-table .cell-wrapper.connected,\n.virtual-table .cell-wrapper.connected span,\n.virtual-table .cell-wrapper.connected strong {\n color: green;\n}\n\n.virtual-table .cell-wrapper.connecting,\n.virtual-table .cell-wrapper.connecting span,\n.virtual-table .cell-wrapper.connecting strong {\n color: orange;\n}\n\n.virtual-table .cell-wrapper.disconnected,\n.virtual-table .cell-wrapper.disconnected span,\n.virtual-table .cell-wrapper.disconnected strong {\n color: dimslategray;\n}\n"],sourceRoot:""}]);const s=i},54248:(e,t,n)=>{n.r(t),n.d(t,{default:()=>Ie});var a=n(74848),o=n(96540),r=n(22005),i=n.n(r);const s="favorite_hubs",c=s,l=s;var d=n(52267);const p=i().createStore({_viewName:"favorite_hub_view",_apiUrl:c,mixins:[(0,d.A)("name")]});var u=n(99671),m=n(65385),v=n(86818),h=n(71299),E=n(4425),A=n(6061),_=n(94413),y=n(47456),O=n(86038);const f=({locals:e})=>{const t=(0,o.useRef)(null);return(0,o.useEffect)(()=>{t.current&&("boolean"==typeof e.value?t.current.indeterminate=!1:t.current.indeterminate=!0)},[e.value]),(0,a.jsx)("input",Object.assign({ref:t,type:"checkbox"},e.attrs,{onChange:t=>{!1===e.value?e.onChange(null):e.onChange(t.target.checked)}}))},I={renderCheckbox:e=>(0,a.jsx)(f,{locals:e})},w=A.Ay.form.Form.templates.checkbox.clone(I);var b=n(19430),D=n(74416);const g=[{id:O.uu.DISABLED,name:"Disabled"},{id:O.uu.ACTIVE_MODE,name:"Active mode"},{id:O.uu.PASSIVE_MODE,name:"Passive mode"}],T=[{key:"generic",title:"Hub properties",type:O.OP.STRUCT,definitions:[{key:"name",title:"Name",type:O.OP.STRING},{key:"hub_url",title:"Hub URL",type:O.OP.STRING},{key:"hub_description",title:"Hub description",type:O.OP.STRING,optional:!0},{key:"share_profile",title:"Share profile",type:O.OP.NUMBER,help:"Custom share profiles can be selected only after entering an ADC hub address (starting with adc:// or adcs://)",optional:!0},{key:"auto_connect",title:"Auto connect",type:O.OP.BOOLEAN}]},{key:"user",title:"User setting overrides",type:O.OP.STRUCT,definitions:[{key:"nick",title:"Nick",type:O.OP.STRING,optional:!0},{key:"user_description",title:"User description",type:O.OP.STRING,optional:!0}]},{key:"connectivityV4",title:"Connectivity setting overrides (IPv4)",type:O.OP.STRUCT,definitions:[{key:"connection_mode_v4",title:"Connectivity mode",type:O.OP.NUMBER,optional:!0,options:g},{key:"connection_ip_v4",title:"IP address",type:O.OP.STRING,optional:!0}]},{key:"connectivityV6",title:"Connectivity setting overrides (IPv6)",type:O.OP.STRUCT,definitions:[{key:"connection_mode_v6",title:"Connectivity mode",type:O.OP.NUMBER,optional:!0,options:g},{key:"connection_ip_v6",title:"IP address",type:O.OP.STRING,optional:!0}]},{key:"misc",title:"Miscellaneous overrides",type:O.OP.STRUCT,definitions:[{key:"use_main_chat_notify",title:"Use chat notification",type:O.OP.BOOLEAN,optional:!0},{key:"show_joins",title:"Show joins/parts",type:O.OP.BOOLEAN,optional:!0},{key:"away_message",title:"Away message",type:O.OP.TEXT,optional:!0}]}],R=e=>!!e&&(e.startsWith("adc://")||e.startsWith("adcs://")),S=(e,t,n)=>e.filter(e=>R(t)||e.id===v.A.HIDDEN_PROFILE_ID).map(e=>(0,b.T)(e,n)).map(y.UM),N=(0,m.A)((0,h.A)(({hubEntry:e,favT:t,profiles:n,socket:r})=>{const i=(0,D.k)(),s=(0,o.useMemo)(()=>(e=>{if(e)return{generic:e,user:e,connectivityV4:e,connectivityV6:e,misc:e}})(e),[]),c=(0,o.useMemo)(()=>(0,y.Nn)(T,t),[]),d=(0,o.useMemo)(()=>({value:"null",text:t.translate("Global default")}),[]),p=!e,m=(0,o.useRef)(null),{translate:h}=t,O=h(p?"Add favorite hub":"Edit favorite hub");return(0,a.jsx)(u.A,{className:"fav-hub",title:O,onApprove:()=>m.current.save(),closable:!1,icon:E.A.FAVORITE,children:(0,a.jsx)(_.A,{ref:m,onFieldChanged:(e,t,n)=>e.includes("hub_url")&&!R(t.generic.hub_url)&&t.share_profile!==v.A.HIDDEN_PROFILE_ID?Promise.resolve({share_profile:null}):null,onFieldSetting:(e,t,a)=>{if("share_profile"===e){const e=a.generic?a.generic.hub_url:void 0;Object.assign(t,{nullOption:d,factory:A.Ay.form.Select,options:S(n,e,i),transformer:y.xs})}else"connection_mode_v4"===e||"connection_mode_v6"===e?Object.assign(t,{nullOption:d,transformer:y.xs}):"use_main_chat_notify"!==e&&"show_joins"!==e||Object.assign(t,{template:w,transformer:{format:e=>void 0===e?null:e,parse:e=>e}})},onSave:t=>{const n=(a=t,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},a.generic),a.user),a.connectivityV4),a.connectivityV6),a.misc));var a;return p?r.post(l,n):r.patch(`${l}/${e.id}`,n)},fieldDefinitions:c,sourceValue:s})})},!0,{urls:{hubEntry:({params:e},t)=>e.entryId?t.get(`${l}/${e.entryId}`):Promise.resolve(void 0)}}),"entries/:entryId?");var C=n(3570),P=n(68465),U=n(44247),V=n(46942),k=n.n(V),j=n(83994),F=n(13017),x=n(44657),L=n(97145),B=n(48249),H=n(32389);const G=e=>{switch(e.id){case O.uv.CONNECTING:return"yellow remove";case O.uv.CONNECTED:return"grey remove";case O.uv.DISCONNECTED:return"green video play"}return""},M=({width:e,cellData:t,rowDataGetter:n})=>{const o=(0,F.Zp)(),r=(0,L.tf)(),i=(0,B.F)(),{t:s}=(0,H.Bd)(),c=()=>{const e={hubUrl:n().hub_url};x.$.createSession(e,{navigate:o,sessionStore:r.getState(),socket:i,t:s})},l=()=>{x.$.removeSession({id:t.current_hub_id},i)};return(0,a.jsxs)("div",{className:"connect-state",children:[(0,a.jsx)(j.A,{icon:k()("icon large link",G(t)),onClick:(()=>{switch(t.id){case O.uv.CONNECTING:case O.uv.CONNECTED:return l;case O.uv.DISCONNECTED:default:return c}})()}),e>120&&t.str]})};var K=n(71352),$=n(85072),W=n.n($),z=n(97825),Y=n.n(z),J=n(77659),X=n.n(J),Z=n(55056),q=n.n(Z),Q=n(10540),ee=n.n(Q),te=n(41113),ne=n.n(te),ae=n(23896),oe={};oe.styleTagTransform=ne(),oe.setAttributes=q(),oe.insert=X().bind(null,"head"),oe.domAPI=Y(),oe.insertStyleElement=ee(),W()(ae.A,oe),ae.A&&ae.A.locals&&ae.A.locals;var re=n(67749),ie=n(42695),se=n(36076),ce=n(39115);const le={create:{id:"create",displayName:"Add new",access:O.US.FAVORITE_HUBS_EDIT,icon:E.A.CREATE,handler:({navigate:e})=>{e("/favorite-hubs/entries")}}},de={edit:{id:"edit",displayName:"Edit",access:O.US.FAVORITE_HUBS_EDIT,icon:E.A.EDIT,handler:({itemData:e,navigate:t})=>{t(`/favorite-hubs/entries/${e.id}`)}},remove:{id:"remove",displayName:"Remove",access:O.US.FAVORITE_HUBS_EDIT,icon:E.A.REMOVE,confirmation:{content:"Are you sure that you want to remove the favorite hub {{item.name}}?",approveCaption:"Remove favorite hub",rejectCaption:"Don't remove"},handler:({itemData:e,socket:t})=>t.delete(l+"/"+e.id)}},pe={moduleId:re.KV.FAVORITE_HUBS},ue={moduleData:pe,actions:de},me={moduleData:pe,actions:le},ve=(e,t,n)=>e.patch(l+"/"+t.id,{password:n}),he=({itemData:e,socket:t},n)=>ve(t,e,n),Ee=({itemData:e})=>e.has_password,Ae={create:{id:"create",displayName:"Set password",access:O.US.FAVORITE_HUBS_EDIT,icon:E.A.LOCK,filter:e=>!Ee(e),input:{content:"Set password for the hub {{item.name}}",approveCaption:"Set password",inputProps:{placeholder:"Enter password",type:"password"}},handler:he},change:{id:"change",displayName:"Change password",access:O.US.FAVORITE_HUBS_EDIT,icon:E.A.EDIT,filter:Ee,input:{content:"Enter new password for the hub {{item.name}}",approveCaption:"Update password",inputProps:{placeholder:"Enter password",type:"password"}},handler:he},remove:{id:"remove",displayName:"Remove password",access:O.US.FAVORITE_HUBS_EDIT,icon:E.A.REMOVE,filter:Ee,confirmation:{content:"Are you sure that you want to reset the password of the hub {{item.name}}?",approveCaption:"Remove password",rejectCaption:"Don't remove"},handler:({itemData:e,socket:t})=>ve(t,e,null)}},_e={moduleData:{moduleId:re.KV.FAVORITE_HUBS,subId:"password"},actions:Ae};var ye=n(39364),Oe=n(70756);const fe=({cellData:e,rowDataGetter:t,t:n})=>(0,a.jsx)(K.yj,{caption:e?(0,a.jsx)("strong",{children:(0,ie.Tl)("Set",n,re.KV.FAVORITE_HUBS)}):(0,ie.Tl)("Not set",n,re.KV.FAVORITE_HUBS),actions:_e,itemData:t}),Ie=()=>{const{t:e}=(0,H.Bd)(),t=(0,B.F)(),n=(0,ie.lw)(e,re.KV.FAVORITE_HUBS),o=(0,ye.wV)(),{translate:r}=n,i=(0,Oe.z)(o,O.US.HUBS_EDIT);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(C.A,{rowClassNameGetter:e=>{switch(e.connect_state.id){case O.uv.CONNECTING:return"connecting";case O.uv.CONNECTED:return"connected";case O.uv.DISCONNECTED:return"disconnected"}return""},footerData:(0,a.jsx)(K.Wy,{className:"top left pointing",caption:r("Actions..."),actions:me,header:r("Favorite hub actions"),triggerIcon:"chevron up",button:!0,remoteMenuId:ce.Ay.FAVORITE_HUBS,direction:"upward"}),store:p,moduleId:re.KV.FAVORITE_HUBS,children:[(0,a.jsx)(P.VP,{name:"State",width:45,columnKey:"connect_state",cell:i?(0,a.jsx)(M,{}):void 0,flexGrow:3}),(0,a.jsx)(P.VP,{name:"Name",width:150,columnKey:"name",flexGrow:6,cell:(0,a.jsx)(U.K,{actions:ue,remoteMenuId:ce.Ay.FAVORITE_HUB})}),(0,a.jsx)(P.VP,{name:"Address",width:270,columnKey:"hub_url",flexGrow:3,hideWidth:700}),(0,a.jsx)(P.VP,{name:"Auto connect",width:65,columnKey:"auto_connect",cell:i?(0,a.jsx)(U.AJ,{onChange:(n,a)=>(0,se.bd)(()=>((e,t,n)=>n.patch(l+"/"+e.id,t))(a,{auto_connect:n},t),e),type:"toggle"}):void 0}),(0,a.jsx)(P.VP,{name:"Share profile",width:100,columnKey:"share_profile",flexGrow:1}),(0,a.jsx)(P.VP,{name:"Nick",width:100,columnKey:"nick",flexGrow:1}),(0,a.jsx)(P.VP,{name:"Password",width:100,columnKey:"has_password",cell:(0,a.jsx)(fe,{})})]}),(0,a.jsx)(N,{favT:n})]})}},71299:(e,t,n)=>{n.d(t,{A:()=>i});var a=n(2543),o=n(86818),r=n(56484);const i=function(e,t,n){return(0,r.A)(e,(0,a.merge)(n,{urls:{profiles:o.A.PROFILES_URL},dataConverters:{profiles:(e,{t:n})=>e.filter(e=>t||e.id!==o.A.HIDDEN_PROFILE_ID)},onSocketConnected:(e,{refetchData:t})=>{e(o.A.MODULE_URL,o.A.PROFILE_ADDED,()=>t()),e(o.A.MODULE_URL,o.A.PROFILE_UPDATED,()=>t()),e(o.A.MODULE_URL,o.A.PROFILE_REMOVED,()=>t())}}))}},86818:(e,t,n)=>{n.d(t,{A:()=>o});const a="share_profiles",o={MODULE_URL:a,PROFILES_URL:a,PROFILE_ADDED:"share_profile_added",PROFILE_UPDATED:"share_profile_updated",PROFILE_REMOVED:"share_profile_removed",HIDDEN_PROFILE_ID:1}}}]);
//# sourceMappingURL=favorite-hubs.295f583c2e1befcbbbbb.chunk.js.map