UNPKG

airdcpp-webui

Version:
2 lines 14.4 kB
"use strict";(self.webpackChunkairdcpp_webui=self.webpackChunkairdcpp_webui||[]).push([[976],{19430:(e,t,o)=>{o.d(t,{T:()=>i,v:()=>r});var n=o(86818);const r=(e,{formatSize:t})=>{let o=e.str;return e.id!==n.A.HIDDEN_PROFILE_ID&&(o+=` (${t(e.size)})`),o},i=(e,t)=>({id:e.id,name:r(e,t)})},20576:(e,t,o)=>{o.r(t),o.d(t,{default:()=>me});var n=o(74848),r=o(22005),i=o.n(r),a=o(52267),s=o(68135);const l=i().createStore({_viewName:`${s.A.VIEW_ID}_view`,_apiUrl:s.A.MODULE_URL,mixins:[(0,a.A)("path")]});var c=o(3570),d=o(44247),p=o(68465),u=o(96540),m=o(99671),h=o(42191),f=o(4425),A=o(65385),E=o(71299),R=o(32728),v=o(6061),y=o(33968),_=o(94413),O=o(59315),S=o(13712),D=o(85072),I=o.n(D),L=o(97825),w=o.n(L),g=o(77659),T=o.n(g),U=o(55056),b=o.n(U),x=o(10540),P=o.n(x),C=o(41113),j=o.n(C),N=o(39291),F={};F.styleTagTransform=j(),F.setAttributes=b(),F.insert=T().bind(null,"head"),F.domAPI=w(),F.insertStyleElement=P(),I()(N.A,F),N.A&&N.A.locals&&N.A.locals;var H=o(86038),k=o(47456),V=o(32389),M=o(19430),$=o(74416);const K=[{key:"path",title:"Path",type:H.OP.DIRECTORY_PATH},{key:"virtual_name",title:"Virtual name",type:H.OP.STRING,help:"Directories with identical virtual names will be merged in filelist"},{key:"profiles",type:H.OP.LIST,item_type:H.OP.NUMBER,title:"Share profiles",help:"New share profiles can be created from application settings"},{key:"incoming",title:"Incoming",type:H.OP.BOOLEAN}],B=(0,A.A)((0,E.A)(e=>{var{shareT:t,profiles:o,rootEntry:r,socket:i,virtualNames:a}=e,l=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(e,["shareT","profiles","rootEntry","socket","virtualNames"]);const c=(0,$.k)(),d=(0,u.useMemo)(()=>{const e=(0,k.Nn)(K,t),n=e.find(e=>"profiles"===e.key);return Object.assign(n,{options:o.map(e=>(0,M.T)(e,c)),default_value:[o.find(e=>e.default).id]}),e},[]),p=(0,u.useRef)(null),h=!r,A=t.translate(h?"Add share directory":"Edit share directory");return(0,n.jsxs)(m.A,Object.assign({className:"share-directory",title:A,onApprove:()=>p.current.save(),closable:!1,icon:f.A.FOLDER},l,{children:[(0,n.jsx)(R.A,{title:t.translate("Hashing information"),icon:f.A.INFO,description:(0,n.jsx)(V.x6,{i18nKey:t.toI18nKey("hashingInformationDesc"),children:(0,n.jsx)("p",{children:"New files will appear in share only after they have finished hashing (the client has calculated checksums for them). Information about hashing progress will be posted to the event log."})})}),(0,n.jsx)(_.A,{ref:p,fieldDefinitions:d,onFieldChanged:(e,t,o)=>{if(e.includes("path")){const e={virtual_name:t.path?(0,y.ap)(t.path):void 0};return Promise.resolve(e)}return null},onFieldSetting:(e,t,o)=>{"path"===e?(t.disabled=!h,t.config=Object.assign(Object.assign({},t.config||{}),{historyId:O.A.LOCATION_DOWNLOAD})):"virtual_name"===e&&(t.factory=v.Ay.form.Textbox,t.template=S.I9,t.config={suggestionGetter:()=>a})},onSave:e=>h?i.post(s.A.ROOTS_URL,e):i.patch(`${s.A.ROOTS_URL}/${r.id}`,e),sourceValue:r})]}))},!1,{urls:{virtualNames:h.A.GROUPED_ROOTS_GET_URL,rootEntry:({params:e},t)=>e.directoryId?t.get(`${s.A.ROOTS_URL}/${e.directoryId}`):Promise.resolve(void 0)},dataConverters:{virtualNames:e=>e.map(e=>e.name,[])}}),"/directories/:directoryId?");var G=o(31104),z=o(19247),W=o(27725),Y=o(36995),q=o(42695);const J=(e,t)=>e?(0,M.v)(e,t):(0,q.Tl)("All profiles",t.t,"table.filter"),X=(0,u.memo)(function(e){const t=(0,$.k)(),{t:o}=(0,V.Bd)(),[r,i]=(0,u.useState)(null),a=t=>{e.onFilterUpdated(t?t.id:null),i(t)};return(0,n.jsx)(G.A,{className:"top right pointing",caption:J(r,t),triggerIcon:"filter",button:!0,children:(0,n.jsx)(z.A,{caption:(0,q.Tl)("Filter by profile",o,"table.filter"),icon:f.A.FILTER,children:[null,...e.profiles].map(e=>((e,t,o,r)=>(0,n.jsx)(W.A,{active:o===e,onClick:()=>t(e),children:J(e,r)},e?e.id:"all"))(e,a,r,t))})})}),Q=(0,E.A)((0,Y.A)(X,"profiles"),!1);var Z=o(71352),ee=o(53632),te=o(99347),oe=o(67749),ne=o(59548),re=o(36076),ie=o(83994),ae=o(48249);const se=(0,ee.A)(({rowDataGetter:e,cellData:t,t:o})=>{const{formatRelativeTime:r}=(0,$.k)(),i=e().status,a=(0,ae.F)();return i.id!==H.hZ.NORMAL?(0,n.jsxs)("div",{style:{display:"flex"},children:[(0,n.jsx)(ie.A,{icon:f.A.CANCEL,color:"red",size:"large",onClick:()=>{const t=e().status.refresh_task_id;t&&(0,re.bd)(()=>(0,ne.Lt)(t,a),o)}}),(0,n.jsx)(te.A,{size:"small",inline:!0,text:i.str})]}):(0,n.jsxs)("div",{children:[(0,n.jsx)(ie.A,{icon:f.A.REFRESH_COLORED,size:"large",onClick:()=>(0,re.bd)(()=>(0,ne.sf)([e().path],a),o)}),0===t?(0,q.Tl)("Unknown",o,oe.KV.SHARE):r(t)]})});var le=o(39115),ce=o(63252),de=o(39364),pe=o(70756);const ue={actions:{create:ce.EU},moduleData:ce.QC},me=()=>{const e=(0,de.wV)(),{t}=(0,V.Bd)(),o=(0,q.lw)(t,oe.KV.SHARE),{translate:r}=o,i=(0,pe.z)(e,H.US.SHARE_EDIT);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(c.A,{store:l,customFilter:Q,rowClassNameGetter:e=>e.incoming?"incoming":"",footerData:(0,n.jsx)(Z.Wy,{className:"top left pointing",caption:r("Actions..."),actions:ue,header:r("Share actions"),triggerIcon:"chevron up",ids:["create"],button:!0,remoteMenuId:le.Ay.SHARE_ROOTS,children:(0,n.jsx)(Z.Wy,{actions:ce.t6,ids:["refresh"]})}),moduleId:oe.KV.SHARE,children:[(0,n.jsx)(p.VP,{name:"Path",width:200,columnKey:"path",cell:(0,n.jsx)(d.tC,{actions:ce.VY,remoteMenuId:le.Ay.SHARE_ROOT}),flexGrow:10}),(0,n.jsx)(p.VP,{name:"Size",width:60,columnKey:"size",cell:(0,n.jsx)(d.us,{}),flexGrow:2}),(0,n.jsx)(p.VP,{name:"Content",width:150,columnKey:"type",hideWidth:1e3}),(0,n.jsx)(p.VP,{name:"Virtual name",width:120,columnKey:"virtual_name",flexGrow:5}),(0,n.jsx)(p.VP,{name:"Profiles",width:65,columnKey:"profiles"}),(0,n.jsx)(p.VP,{name:"Last refreshed",width:80,flexGrow:3,columnKey:"last_refresh_time",cell:i?(0,n.jsx)(se,{}):(0,n.jsx)(d.Jo,{})})]}),(0,n.jsx)(B,{shareT:o})]})}},29112:(e,t,o)=>{o.d(t,{RS:()=>s,eP:()=>c,t6:()=>d});var n=o(42191),r=o(4425),i=o(86038),a=o(67749);const s={id:"refreshAll",displayName:"Refresh all",access:i.US.SHARE_EDIT,icon:r.A.REFRESH_COLORED,handler:({socket:e})=>e.post(n.A.REFRESH_URL)},l={refresh:s},c={moduleId:a.KV.SHARE},d={moduleData:c,actions:l}},39291:(e,t,o)=>{o.d(t,{A:()=>s});var n=o(71354),r=o.n(n),i=o(76314),a=o.n(i)()(r());a.push([e.id,".share-directory .Select {\n margin-bottom: 0px;\n}\n\n\n.virtual-table .cell-wrapper.incoming,\n.virtual-table .cell-wrapper.incoming span,\n.virtual-table .cell-wrapper.incoming strong {\n font-weight: bold;\n}\n","",{version:3,sources:["webpack://./src/routes/Share/style.css"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;;;AAGA;;;EAGE,iBAAiB;AACnB",sourcesContent:[".share-directory .Select {\n margin-bottom: 0px;\n}\n\n\n.virtual-table .cell-wrapper.incoming,\n.virtual-table .cell-wrapper.incoming span,\n.virtual-table .cell-wrapper.incoming strong {\n font-weight: bold;\n}\n"],sourceRoot:""}]);const s=a},53632:(e,t,o)=>{o.d(t,{A:()=>i});var n=o(74848),r=o(96540);function i(e,t=60){class o extends r.Component{constructor(){super(...arguments),this.scheduleComponentRefresh=()=>{this.redrawTimeout=window.setTimeout(()=>{this.forceUpdate(),this.scheduleComponentRefresh()},1e3*t)}}componentDidMount(){this.scheduleComponentRefresh()}componentWillUnmount(){clearTimeout(this.redrawTimeout)}render(){return(0,n.jsx)(e,Object.assign({},this.props))}}return o}},59548:(e,t,o)=>{o.d(t,{Lt:()=>c,eo:()=>a,sf:()=>s,t7:()=>l});var n=o(42191),r=o(88569),i=o(86038);const a=(e,t,o)=>{return i=void 0,a=[e,t,o],l=function*({file:e,hubUrl:t,cid:o},{auth_token:i},a){try{const s=yield(0,r.U)(e,i);return yield a.post(n.A.TEMP_SHARES_URL,{name:e.name,file_id:s,hub_url:t,cid:o})}catch(e){throw e}},new((s=void 0)||(s=Promise))(function(e,t){function o(e){try{r(l.next(e))}catch(e){t(e)}}function n(e){try{r(l.throw(e))}catch(e){t(e)}}function r(t){var r;t.done?e(t.value):(r=t.value,r instanceof s?r:new s(function(e){e(r)})).then(o,n)}r((l=l.apply(i,a||[])).next())});var i,a,s,l},s=(e,t)=>t.post(n.A.REFRESH_PATHS_URL,{paths:e,priority:i.DH.MANUAL}),l=(e,t)=>t.post(n.A.REFRESH_VIRTUAL_URL,{path:e}),c=(e,t)=>t.delete(`${n.A.REFRESH_TASKS_URL}/${e}`)},63252:(e,t,o)=>{o.d(t,{t6:()=>n.t6,Ds:()=>r.Ds,An:()=>r.An,tx:()=>r.tx,QC:()=>p,EU:()=>c,VY:()=>u});var n=o(29112),r=(o(91510),o(94899)),i=o(68135),a=o(4425),s=o(86038),l=o(67749);const c={id:"create",displayName:"Add directory",access:s.US.SHARE_EDIT,icon:a.A.CREATE,handler:({navigate:e})=>{e("directories")}},d={edit:{id:"edit",displayName:"Edit directory",access:s.US.SHARE_EDIT,icon:a.A.EDIT,handler:({itemData:e,navigate:t})=>{t(`directories/${e.id}`)}},remove:{id:"remove",displayName:"Remove directory",access:s.US.SHARE_EDIT,icon:a.A.REMOVE,confirmation:{content:"Are you sure that you want to remove the directory {{item.virtual_name}} from share? It will be removed from all share profiles.",approveCaption:"Remove directory",rejectCaption:"Don't remove"},handler:({itemData:e,socket:t})=>t.delete(i.A.ROOTS_URL+"/"+e.id)}},p={moduleId:l.KV.SHARE,subId:"root"},u={moduleData:p,actions:d}},68135:(e,t,o)=>{o.d(t,{A:()=>r});const n="share_roots",r={MODULE_URL:n,ROOTS_URL:n,CREATED:"share_root_created",UPDATED:"share_root_updated",REMOVED:"share_root_removed",VIEW_ID:"share_root"}},71299:(e,t,o)=>{o.d(t,{A:()=>a});var n=o(2543),r=o(86818),i=o(56484);const a=function(e,t,o){return(0,i.A)(e,(0,n.merge)(o,{urls:{profiles:r.A.PROFILES_URL},dataConverters:{profiles:(e,{t:o})=>e.filter(e=>t||e.id!==r.A.HIDDEN_PROFILE_ID)},onSocketConnected:(e,{refetchData:t})=>{e(r.A.MODULE_URL,r.A.PROFILE_ADDED,()=>t()),e(r.A.MODULE_URL,r.A.PROFILE_UPDATED,()=>t()),e(r.A.MODULE_URL,r.A.PROFILE_REMOVED,()=>t())}}))}},86818:(e,t,o)=>{o.d(t,{A:()=>r});const n="share_profiles",r={MODULE_URL:n,PROFILES_URL:n,PROFILE_ADDED:"share_profile_added",PROFILE_UPDATED:"share_profile_updated",PROFILE_REMOVED:"share_profile_removed",HIDDEN_PROFILE_ID:1}},88569:(e,t,o)=>{o.d(t,{H:()=>a,U:()=>i});var n=o(41110),r=function(e,t,o,n){return new(o||(o=Promise))(function(r,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})};const i=(e,t)=>r(void 0,void 0,void 0,function*(){try{return(yield(0,n.F)(`${getBasePath()}temp`,{method:"POST",headers:{"X-Authorization":t,Authorization:t},body:e})).headers.get("Location")}catch(e){throw e}}),a=(e,t,...o)=>r(void 0,[e,t,...o],void 0,function*(e,t,o={isJSON:!0}){try{const r=yield(0,n.F)((e=>`${window.location.origin}${getBasePath()}proxy?url=${encodeURIComponent(e)}`)(e),Object.assign({headers:{"X-Authorization":t.auth_token,"Cache-Control":"no-store, must-revalidate, max-age=0"}},o));return(yield o.isJSON)?r.json():r.text()}catch(t){throw console.error(`CORS HTTP request failed (${e})`,t),t}})},91510:(e,t,o)=>{o.d(t,{MB:()=>c,Tw:()=>s,nH:()=>d});var n=o(42191),r=o(4425),i=o(86038),a=o(67749);const s={id:"add",displayName:"Add path",access:i.US.SHARE_EDIT,icon:r.A.CREATE,handler:({navigate:e})=>{e("browse")}},l={remove:{id:"remove",displayName:"Remove path",access:i.US.SHARE_EDIT,icon:r.A.REMOVE,confirmation:{content:"Are you sure that you want to remove the excluded path {{item}}?",approveCaption:"Remove path",rejectCaption:"Don't remove"},handler:({itemData:e,socket:t})=>t.post(n.A.EXCLUDES_REMOVE_URL,{path:e})}},c={moduleId:a.KV.SETTINGS,subId:"shareExclude"},d={moduleData:c,actions:l}},94899:(e,t,o)=>{o.d(t,{An:()=>m,Ds:()=>v,YS:()=>y,tx:()=>u});var n=o(86818),r=o(4425),i=o(86038),a=o(67749),s=o(48844),l=o(68135),c=o(94310);const d=({itemData:e})=>!e.default,p=({socket:e},t)=>e.post(n.A.PROFILES_URL,{name:t}),u={id:"create",displayName:"Add profile",access:i.US.SHARE_EDIT,icon:r.A.CREATE,input:{approveCaption:"Create",content:"Enter name for the profile",inputProps:{placeholder:"Enter name",required:!0}},handler:p},m={id:"clone",displayName:"Clone profile",access:i.US.SHARE_EDIT,icon:r.A.COPY,input:{approveCaption:"Create",content:"Enter name for the profile (cloned from {{item.name}})",inputProps:{placeholder:"Enter name",required:!0}},handler:(e,t)=>{return o=void 0,n=void 0,i=function*(){const o=yield p(e,t),{itemData:n,socket:r}=e,i=yield r.get(`${l.A.MODULE_URL}`);for(const e of i){const t=e.profiles.map(e=>e.id);t.includes(n.id)&&(yield r.patch(`${l.A.MODULE_URL}/${e.id}`,{profiles:[...t,o.id]}))}},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{l(i.next(e))}catch(e){t(e)}}function s(e){try{l(i.throw(e))}catch(e){t(e)}}function l(t){var o;t.done?e(t.value):(o=t.value,o instanceof r?o:new r(function(e){e(o)})).then(a,s)}l((i=i.apply(o,n||[])).next())});var o,n,r,i}},h={id:"browse",displayName:"Browse files",access:i.US.FILELISTS_VIEW,icon:r.A.FILELIST,handler:e=>{var{itemData:t}=e,o=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(e,["itemData"]);return c.u.initCreateLocalSession(o.appStore.login.getSession())({shareProfileId:t.id},o)}},f={id:"edit",displayName:"Rename profile",access:i.US.SHARE_EDIT,icon:r.A.EDIT,input:e=>({approveCaption:"Rename",content:"Enter new name for the profile {{item.name}}",inputProps:{placeholder:"Enter name",defaultValue:e.name,required:!0}}),handler:({itemData:e,socket:t},o)=>t.patch(`${n.A.PROFILES_URL}/${e.id}`,{name:o})},A={id:"default",displayName:"Set as default",access:i.US.SHARE_EDIT,filter:d,icon:r.A.DEFAULT,handler:({itemData:e,socket:t})=>t.post(`${n.A.PROFILES_URL}/${e.id}/default`)},E={id:"remove",displayName:"Remove profile",access:i.US.SHARE_EDIT,icon:r.A.REMOVE,filter:d,confirmation:{content:"Are you sure that you want to remove the profile {{item.name}}?",approveCaption:"Remove profile",rejectCaption:"Don't remove"},handler:({itemData:e,socket:t})=>t.delete(n.A.PROFILES_URL+"/"+e.id)},R={browse:h,divider:s.o,edit:f,default:A,remove:E},v={moduleId:a.KV.SETTINGS,subId:"profile"},y={moduleData:v,actions:R}}}]); //# sourceMappingURL=share.3d87d65e17afebd94b44.chunk.js.map