Files
dotfiles/qbit/vuetorrent/public/assets/TorrentCreator-Cz_3yngv.js
2024-12-12 18:12:07 -05:00

4 lines
14 KiB
JavaScript

import{a0 as ye,d as R,h as te,Z as ve,_ as Se,u as a,B as d,D as c,r as _e,c as K,G as e,m as t,I as p,J as u,K as Q,M as E,N as F,F as U,O as he,P as Te,Q as Fe,H as xe,q as we,S as b,X as Le,n as se,T as ne}from"./vue-DFryKk-1.js";import{$ as I,G as ae,a9 as De,aa as ze,a as me,c as Ue,u as ce,ab as x,a5 as pe,d as M,e as J,J as W,K as X,k as v,f as Z,g as Ie,q as fe,s as V,x as B,v as ie,ac as j,ad as H,i as Ae,l as ee,F as Pe,o as He,ae as Ne,p as Ee,af as w,r as Y,ag as Me,j as q,t as N,a0 as Re,ah as de,ai as Be,V as L,D as G,aj as $e,ak as Oe}from"./index-BhWmfNB5.js";import{a as je}from"./vuetify-XtA0Y0Oj.js";var ke=(g=>(g.ALL="all",g.ONLY_FILES="files",g.ONLY_DIRECTORIES="dirs",g))(ke||{});const Ve=ye("torrentCreator",()=>{const g=R([]);async function S(){g.value=await I.getTorrentCreatorStatus()}async function C(f){return await I.addTorrentCreatorTask(f)}async function o(f){return await I.deleteTorrentCreatorTask(f)}async function _(f){return await I.getTorrentCreatorOutput(f)}return{tasks:g,fetchTasks:S,createTask:C,deleteTask:o,downloadTorrent:_}}),ue=te({__name:"ServerPathField",props:ve({title:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(g){const S=Se(g,"modelValue"),C=R([]),o=ae(),_=De(async f=>{if(!f)return;const k=await I.getDirectoryContent(f,ke.ALL);k&&(C.value=k)},500);return(f,k)=>a(o).usesQbit5?(d(),c(ze,{key:0,modelValue:S.value,"onUpdate:modelValue":k[0]||(k[0]=y=>S.value=y),items:C.value,label:f.title,"onUpdate:search":a(_)},null,8,["modelValue","items","label","onUpdate:search"])):(d(),c(me,{key:1,modelValue:S.value,"onUpdate:modelValue":k[1]||(k[1]=y=>S.value=y),label:f.title},null,8,["modelValue","label"]))}}),Ye=te({__name:"TorrentCreatorFormDialog",props:{guid:{}},setup(g){const S=g,{isOpened:C}=Ue(S.guid),{t:o}=ce(),_=ae(),f=Ve(),k=R(),y=R(!1),n=_e({sourcePath:"",format:x.HYBRID,pieceSize:0,optimizeAlignment:!1,paddedFileSizeLimit:0,private:!1,startSeeding:!1,torrentFilePath:"",trackers:"",urlSeeds:"",source:"",comment:""}),A=[{title:o("constants.torrentFormat.v1"),value:x.V1},{title:o("constants.torrentFormat.v2"),value:x.V2},{title:o("constants.torrentFormat.hybrid"),value:x.HYBRID}],D=K(()=>{const T=[{title:o("common.auto"),value:0}];for(let r=16*1024;r<5e8;r*=2)T.push({title:pe(r,!0,0),value:r});return T}),$=[T=>!T||T<-1||o("dialogs.torrentCreator.paddedFileSizeLimitRule")];async function P(){y.value&&(await f.createTask(n),z())}const z=()=>{C.value=!1};return(T,r)=>(d(),c(ee,{modelValue:a(C),"onUpdate:modelValue":r[14]||(r[14]=s=>he(C)?C.value=s:null),"max-width":"1250"},{default:e(()=>[t(M,null,{default:e(()=>[t(J,{class:"ios-margin"},{default:e(()=>[t(W,{color:"transparent"},{default:e(()=>[t(X,null,{default:e(()=>[p(u(a(o)("dialogs.torrentCreator.title")),1)]),_:1}),t(v,{icon:"mdi-close",onClick:z})]),_:1})]),_:1}),t(Z,null,{default:e(()=>[t(a(Ie),{modelValue:y.value,"onUpdate:modelValue":r[12]||(r[12]=s=>y.value=s),ref_key:"form",ref:k,onSubmit:r[13]||(r[13]=Q(()=>{},["prevent"]))},{default:e(()=>[t(fe,null,{default:e(()=>[t(V,{cols:"12"},{default:e(()=>[t(ue,{modelValue:n.sourcePath,"onUpdate:modelValue":r[0]||(r[0]=s=>n.sourcePath=s),title:a(o)("dialogs.torrentCreator.sourcePath"),rules:[s=>!!s||a(o)("dialogs.torrentCreator.rules.sourcePathRequired")]},null,8,["modelValue","title","rules"])]),_:1}),t(V,{cols:"12"},{default:e(()=>[t(ue,{modelValue:n.torrentFilePath,"onUpdate:modelValue":r[1]||(r[1]=s=>n.torrentFilePath=s),title:a(o)("dialogs.torrentCreator.torrentFilePath"),rules:[s=>!s||s.endsWith(".torrent")||a(o)("dialogs.torrentCreator.rules.outputFileExtension")]},null,8,["modelValue","title","rules"])]),_:1}),t(B),a(_).usesLibtorrent2?(d(),c(V,{key:0,cols:"12",sm:"6",class:"pb-0"},{default:e(()=>[t(ie,{modelValue:n.format,"onUpdate:modelValue":r[2]||(r[2]=s=>n.format=s),"hide-details":"",items:A,label:a(o)("dialogs.torrentCreator.format")},null,8,["modelValue","label"])]),_:1})):E("",!0),t(V,{cols:"12",sm:a(_).usesLibtorrent2?6:void 0,class:"pb-0"},{default:e(()=>[t(ie,{modelValue:n.pieceSize,"onUpdate:modelValue":r[3]||(r[3]=s=>n.pieceSize=s),"hide-details":"",items:D.value,label:a(o)("dialogs.torrentCreator.pieceSize")},null,8,["modelValue","items","label"])]),_:1},8,["sm"]),a(_).usesLibtorrent1?(d(),F(U,{key:1},[t(V,{cols:"12",sm:"6",class:"py-0"},{default:e(()=>[t(j,{modelValue:n.optimizeAlignment,"onUpdate:modelValue":r[4]||(r[4]=s=>n.optimizeAlignment=s),"hide-details":"",label:a(o)("dialogs.torrentCreator.optimizeAlignment")},null,8,["modelValue","label"])]),_:1}),t(V,{cols:"12",sm:"6",class:"py-0"},{default:e(()=>[t(me,{modelValue:n.paddedFileSizeLimit,"onUpdate:modelValue":r[5]||(r[5]=s=>n.paddedFileSizeLimit=s),modelModifiers:{number:!0},min:"-1",rules:$,label:a(o)("dialogs.torrentCreator.paddedFileSizeLimit"),hint:a(o)("dialogs.torrentCreator.paddedFileSizeLimitHint"),suffix:"kiB"},null,8,["modelValue","label","hint"])]),_:1})],64)):E("",!0),t(V,{cols:"12",sm:"6",class:"py-0"},{default:e(()=>[t(j,{modelValue:n.private,"onUpdate:modelValue":r[6]||(r[6]=s=>n.private=s),"hide-details":"",label:a(o)("dialogs.torrentCreator.private")},null,8,["modelValue","label"])]),_:1}),t(V,{cols:"12",sm:"6",class:"py-0"},{default:e(()=>[t(j,{modelValue:n.startSeeding,"onUpdate:modelValue":r[7]||(r[7]=s=>n.startSeeding=s),"hide-details":"",label:a(o)("dialogs.torrentCreator.startSeeding")},null,8,["modelValue","label"])]),_:1}),t(B),t(V,{cols:"12"},{default:e(()=>[t(H,{modelValue:n.trackers,"onUpdate:modelValue":r[8]||(r[8]=s=>n.trackers=s),label:a(o)("dialogs.torrentCreator.trackers"),hint:a(o)("dialogs.torrentCreator.trackersHint")},null,8,["modelValue","label","hint"])]),_:1}),t(V,{cols:"12"},{default:e(()=>[t(H,{modelValue:n.urlSeeds,"onUpdate:modelValue":r[9]||(r[9]=s=>n.urlSeeds=s),"hide-details":"",label:a(o)("dialogs.torrentCreator.urlSeeds")},null,8,["modelValue","label"])]),_:1}),a(_).version>="5.0.3"?(d(),c(V,{key:2,cols:"12"},{default:e(()=>[t(H,{modelValue:n.source,"onUpdate:modelValue":r[10]||(r[10]=s=>n.source=s),"hide-details":"",label:a(o)("dialogs.torrentCreator.source")},null,8,["modelValue","label"])]),_:1})):E("",!0),t(V,{cols:"12"},{default:e(()=>[t(H,{modelValue:n.comment,"onUpdate:modelValue":r[11]||(r[11]=s=>n.comment=s),"hide-details":"",label:a(o)("dialogs.torrentCreator.comment")},null,8,["modelValue","label"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1}),t(Ae,null,{default:e(()=>[t(v,{disabled:!y.value,color:"accent",onClick:P},{default:e(()=>[p(u(a(o)("dialogs.torrentCreator.actions.submit")),1)]),_:1},8,["disabled"]),t(v,{color:"error",onClick:z},{default:e(()=>[p(u(a(o)("common.close")),1)]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]))}}),qe={class:"pa-3"},Ge={style:{"font-size":"1.6em !important"},class:"subtitle-1 ml-2"},Ke={class:"d-flex justify-end"},Qe={class:"d-flex align-center flex-gap"},Je={class:"text-no-wrap"},We={class:"text-no-wrap"},Xe={class:"text-no-wrap"},Ze={class:"text-no-wrap"},et={key:1},tt={class:"text-no-wrap"},at={key:1},ot=["innerHTML"],lt=["innerHTML"],it=te({__name:"TorrentCreator",setup(g){const{height:S}=je(),C=Te(),{t:o}=ce(),_=ae(),f=Pe(),k=Ve(),{tasks:y}=Fe(k),n=He(),A=Ne(function*(){yield k.fetchTasks()}).drop(),{isActive:D,pause:$,resume:P}=Ee(A.perform,1e3,{immediate:!0,immediateCallback:!0}),z=P,T=K(()=>S.value-64-12*2-48),r=K(()=>[{key:"actions",sortable:!1},{title:o("torrentCreator.table.sourcePath"),key:"sourcePath"},{title:o("torrentCreator.table.status"),key:"status"},{title:o("torrentCreator.table.progress"),key:"progress"},_.usesLibtorrent2?{title:o("torrentCreator.table.format"),key:"format"}:{title:o("torrentCreator.table.optimizeAlignment"),key:"optimizeAlignment"},{title:o("torrentCreator.table.pieceSize"),key:"pieceSize"},{title:o("torrentCreator.table.private"),key:"private"},{title:o("torrentCreator.table.timeAdded"),key:"timeAdded"},{title:o("torrentCreator.table.timeStarted"),key:"timeStarted"},{title:o("torrentCreator.table.timeFinished"),key:"timeFinished"},{title:o("torrentCreator.table.trackers.header"),key:"trackers",sortable:!1},{title:o("torrentCreator.table.urlSeeds.header"),key:"urlSeeds",sortable:!1},{title:o("torrentCreator.table.source"),key:"source"},{title:o("torrentCreator.table.comment"),key:"comment"},{title:o("torrentCreator.table.errorMessage"),key:"errorMessage"}]),s={[w.FAILED]:"error",[w.RUNNING]:"torrent-ul_stalled",[w.QUEUED]:"warning",[w.FINISHED]:"success"},be={[x.V1]:"V1",[x.V2]:"V2",[x.HYBRID]:"Hybrid"};function oe(){f.createDialog(Ye,{},k.fetchTasks)}async function ge(h){const m=await k.downloadTorrent(h.taskID),l=$e(h.torrentFilePath);let i;l&&l.endsWith(".torrent")?i=l.slice(0,-8):l?i=l:i=h.taskID,Oe(`${i}.torrent`,m)}async function Ce(h){await k.deleteTask(h.taskID),z()}const le=()=>{C.push({name:"dashboard"})};function re(h){if(f.hasActiveDialog)return!1;h.key==="Escape"&&(h.preventDefault(),le())}return xe(async()=>{document.addEventListener("keydown",re),A.perform()}),we(()=>{document.removeEventListener("keydown",re)}),(h,m)=>(d(),F("div",qe,[t(fe,{"no-gutters":"",align:"center",justify:"center"},{default:e(()=>[t(V,null,{default:e(()=>[b("h1",Ge,u(a(o)("torrentCreator.title")),1)]),_:1}),t(V,null,{default:e(()=>[b("div",Ke,[t(v,{icon:"mdi-close",variant:"plain",onClick:le})])]),_:1})]),_:1}),a(y).length?(d(),c(Y,{key:1},{default:e(()=>[t(N,null,{default:e(()=>[b("div",Qe,[t(q),t(v,{color:"accent","prepend-icon":a(D)?"mdi-timer-pause":"mdi-timer-play",text:a(D)?a(o)("common.pause"):a(o)("common.resume"),onClick:m[1]||(m[1]=l=>a(D)?a($)():a(P)())},null,8,["prepend-icon","text"]),t(v,{color:"accent","prepend-icon":"mdi-plus",text:a(o)("torrentCreator.table.create"),onClick:oe},null,8,["text"])])]),_:1}),t(B,{class:"my-3"}),t(N,{class:"text-select"},{default:e(()=>[t(Re,{"header-props":{class:"text-no-wrap"},mobile:null,headers:r.value,items:a(y),"multi-sort":"","footer-props":{itemsPerPageOptions:[10,25,50,100,-1]}},{"item.status":e(({item:l,value:i})=>[b("span",{class:Le(`text-${s[l.status]}`)},u(a(o)(`constants.torrentCreatorTaskStatus.${i.toLowerCase()}`)),3)]),"item.progress":e(({item:l,value:i})=>[l.status===a(w).RUNNING?(d(),c(de,{key:0,"model-value":i,color:s[l.status],height:20,rounded:"sm",style:{width:"10em"}},{default:e(()=>[p(u(i)+" % ",1)]),_:2},1032,["model-value","color"])):(d(),c(de,{key:1,"model-value":100,color:s[l.status],height:20,rounded:"sm",style:{width:"10em"}},{default:e(()=>[p(u(a(Be)(1)),1)]),_:2},1032,["color"]))]),"item.format":e(({value:l})=>[p(u(be[l]),1)]),"item.pieceSize":e(({value:l})=>[p(u(a(pe)(l,a(n).useBinarySize,0)),1)]),"item.private":e(({value:l})=>[l?(d(),c(L,{key:0,color:"accent"},{default:e(()=>m[2]||(m[2]=[p("mdi-check-bold")])),_:1})):(d(),c(L,{key:1,color:"error"},{default:e(()=>m[3]||(m[3]=[p("mdi-close-thick")])),_:1}))]),"item.optimizeAlignment":e(({value:l})=>[l?(d(),c(L,{key:0,color:"accent"},{default:e(()=>m[4]||(m[4]=[p("mdi-check-bold")])),_:1})):(d(),c(L,{key:1,color:"error"},{default:e(()=>m[5]||(m[5]=[p("mdi-close-thick")])),_:1}))]),"item.timeAdded":e(({value:l})=>[b("div",Je,u(a(G)(l).format(a(n).dateFormat)),1)]),"item.timeFinished":e(({value:l})=>[b("div",We,u(a(G)(l).format(a(n).dateFormat)),1)]),"item.timeStarted":e(({value:l})=>[b("div",Xe,u(a(G)(l).format(a(n).dateFormat)),1)]),"item.trackers":e(({value:l})=>[l&&l.length&&!l.every(i=>!i.length)?(d(),c(ee,{key:0},{activator:e(({props:i})=>[b("div",Ze,[b("span",null,u(a(o)("torrentCreator.table.trackers.activator",l.filter(O=>O.length).length)),1),t(L,se({class:"ml-1"},i),{default:e(()=>m[6]||(m[6]=[p("mdi-information")])),_:2},1040)])]),default:e(()=>[t(M,null,{default:e(()=>[t(J,{class:"ios-margin"},{default:e(()=>[t(W,{color:"transparent"},{default:e(()=>[t(X,null,{default:e(()=>[p(u(a(o)("torrentCreator.table.trackers.title")),1)]),_:1}),t(q),t(v,{icon:"mdi-close"})]),_:1})]),_:1}),t(Z,null,{default:e(()=>[t(Y,null,{default:e(()=>[(d(!0),F(U,null,ne(l,i=>(d(),F(U,null,[i?(d(),c(N,{key:0},{default:e(()=>[p(u(i),1)]),_:2},1024)):(d(),c(B,{key:1}))],64))),256))]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1024)):(d(),F("span",et,u(a(o)("common.none")),1))]),"item.urlSeeds":e(({value:l})=>[l&&l.length&&!l.every(i=>!i.length)?(d(),c(ee,{key:0},{activator:e(({props:i})=>[b("div",tt,[b("span",null,u(a(o)("torrentCreator.table.urlSeeds.activator",l.filter(O=>O.length).length)),1),t(L,se({class:"ml-1"},i),{default:e(()=>m[7]||(m[7]=[p("mdi-information")])),_:2},1040)])]),default:e(()=>[t(M,null,{default:e(()=>[t(J,{class:"ios-margin"},{default:e(()=>[t(W,{color:"transparent"},{default:e(()=>[t(X,null,{default:e(()=>[p(u(a(o)("torrentCreator.table.urlSeeds.title")),1)]),_:1}),t(q),t(v,{icon:"mdi-close"})]),_:1})]),_:1}),t(Z,null,{default:e(()=>[t(Y,null,{default:e(()=>[(d(!0),F(U,null,ne(l.filter(i=>i.length),i=>(d(),F(U,null,[i?(d(),c(N,{key:0},{default:e(()=>[p(u(i),1)]),_:2},1024)):E("",!0)],64))),256))]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1024)):(d(),F("span",at,u(a(o)("common.none")),1))]),"item.comment":e(({value:l})=>[b("div",{class:"text-no-wrap",innerHTML:l?.length?l.replaceAll(`
`,"<br>"):""},null,8,ot)]),"item.errorMessage":e(({value:l})=>[b("div",{class:"text-no-wrap",innerHTML:l?.length?l.replaceAll(`
`,"<br>"):""},null,8,lt)]),"item.actions":e(({item:l})=>[t(v,{disabled:l.status!==a(w).FINISHED,color:"accent",icon:"mdi-download",variant:"text",density:"compact",onClick:Q(i=>ge(l),["stop"])},null,8,["disabled","onClick"]),t(v,{color:"red",icon:"mdi-delete",variant:"text",density:"compact",onClick:Q(i=>Ce(l),["stop"])},null,8,["onClick"])]),_:2},1032,["headers","items"])]),_:1})]),_:1})):(d(),c(M,{key:0,height:T.value},{default:e(()=>[t(Me,{title:a(o)("torrentCreator.empty.value"),color:"accent",icon:"mdi-cog-off"},{actions:e(()=>[t(v,{text:a(o)("torrentCreator.empty.action"),color:"accent",onClick:m[0]||(m[0]=l=>oe())},null,8,["text"])]),_:1},8,["title"])]),_:1},8,["height"]))]))}});export{it as default};