PageSourceSearch

https://crm.ifnmu.edu.ua/assets/Shells-BS8srJUz.js

js ifnmu.edu.ua collected 2026-09-25 22:56:28 UTC 13,782 bytes, 1 lines download raw bytes

1import{n as e,ax as D,aK as ge,aL as je}from"./antdProComponents-CFjaKfty.js";import{r as m,L as _e}from"./react-_5RlvHhi.js";import{S as B}from"./ShellEditorAPI-0zfKC0ir.js";import{i as te,S as se,a as ue,b as he,g as pe,c as De}from"./ShellCommands-CPd8hqBh.js";import{b as Fe,aR as Ee,aC as Re,aI as Ae,am as Le,an as Me,dn as re,C as Oe,aB as qe,bj as Ke,d as Qe,P as $e,s as ze,aq as Pe}from"./index-CR8yoNY4.js";import{a1 as I,a3 as le}from"./antdForm-D_29pKbP.js";import{aG as V,aF as me,d3 as ne,cU as We,bf as ke}from"./antdBase-DlFOY6T8.js";import{T as ie,h as Be,j as Ve}from"./antdTable-CU40bWxf.js";import{c as ce,u as oe,b as O}from"./query-BM65dpYW.js";import{B as fe,J as He,L as Ue,bp as Ge,k as Je,ae as Xe,a9 as xe,a7 as Ye,q as Ze,z as es,M as ss,l as ls}from"./antdIcons-BdMX_pWi.js";import{a as be,M as we}from"./antdModal-tqe9k7Ax.js";import"./monaco-CsZ7OqaL.js";import"./index-jDc_2R3q.js";import"./pdfjs-Jc8nWIli.js";import"./jspdf-Dp8Wz4gx.js";import"./utils-BGnmWEL9.js";import"./tiptap-BdEHFol7.js";import"./reactPdf-CWXH5nfV.js";import"./antdMaskInput-Bpz7D-sT.js";import"./antdProTable-Ds9khEp6.js";import"./chart-BVWW38sX.js";import"./others-D2FK10gv.js";import"./x6-8W7Bzdfz.js";import"./pdfLib-_sLH-ZSH.js";const ts=({form:k,isOpen:x,onCancel:F,tagsList:b,foldersList:q,onFinish:K})=>{const{t:w}=Fe(),h=i=>i.map(p=>({id:p,name:p,value:p})),E=i=>{const{folders:p,...u}=i,y={...u,...p&&p.length>0&&{folders:p}};K(y)};return e.jsx(Ee,{width:400,title:"New script",isOpen:x,onCancel:F,children:e.jsxs(I,{form:k,onFinish:E,children:[e.jsx(I.Item,{name:"name",children:e.jsx(le,{placeholder:"Shell name",autoComplete:"off"})}),e.jsx(I.Item,{name:"description",children:e.jsx(le,{placeholder:"Shell description",autoComplete:"off"})}),e.jsx(I.Item,{name:"tags",children:e.jsx(Re,{mode:"tags",providedOptions:b,transformData:h,placeholder:"Shell tags (press enter to create a tag)"})}),e.jsx(I.Item,{name:"folders",children:e.jsx(ie,{treeData:q,placeholder:"Select a folder",treeDefaultExpandAll:!0,style:{width:"100%"},multiple:!0})}),e.jsx(V,{className:"ml-auto d-block",type:"primary",htmlType:"submit",children:w("base.save")})]})})},Ce=()=>{const[k]=I.useForm(),x=ce(),[F,b]=m.useState(te),{filterDropdown:q,filterIcon:K,onFilterDropdownOpen:w}=Ae(),[h,E]=m.useState(""),{sortedSearchParams:i,setSearchParamsToQuery:p}=Le(),{tags:u}=i,y=u!=null&&u.length?u==null?void 0:u.split(" "):[],{data:C,queryKeys:Q,isFetching:c}=Me({keys:["shells-list"],fetcher:B.fetchShells}),{data:v,queryKeys:$,isLoading:X}=oe({queryKey:["shell-tags-list"],queryFn:B.fetchShellTags,select:s=>{var l;return(l=Object.keys(s).sort((t,S)=>s[S]-s[t]))==null?void 0:l.filter(t=>t.includes(h))}}),{data:z,queryKeys:R,isLoading:T}=oe({queryKey:["shell-folders-list"],queryFn:se.fetchShellFolders,select:s=>(s==null?void 0:s.sort((l,t)=>l.name.localeCompare(t.name)))||[]}),{mutate:A}=O({mutationFn:se.postNewFolder,onSuccess:()=>{x.invalidateQueries(R)}}),{mutate:Y}=O({mutationFn:se.deleteFolder,onSuccess:()=>{x.invalidateQueries(R)}}),{mutate:P}=O({mutationFn:({id:s,body:l})=>se.patchFolder(s,l),onSuccess:()=>{x.invalidateQueries(R)}}),{mutate:Z}=O({mutationFn:B.postNewShell,onSuccess:s=>{x.setQueryData(Q,l=>[...Array.isArray(l)?l:[],s]),x.invalidateQueries($),b(te)}}),{mutate:W,isLoading:H}=O({mutationFn:B.deleteShell,onSuccess:(s,l)=>{x.setQueryData(Q,t=>(Array.isArray(t)?t:[]).filter(ee=>ee.id!==l))}}),{mutate:L}=O({mutationFn:({id:s,body:l})=>B.patchShell(s,l),onSuccess:s=>{x.setQueryData(Q,l=>(Array.isArray(l)?l:[]).map(S=>S.id===s.id?s:S)),b(te)}}),r=s=>{var t;const l={...s,tags:(t=s.tags)==null?void 0:t.join(" "),folders:Array.isArray(s.folders)&&s.folders.length>0?s.folders:void 0};if(F.type==="new")return Z(l);L({id:F.id,body:l})},a=s=>()=>{y.includes(s)||(y.push(s),p({tags:y.join(" ")}))},M=s=>{const l=y.filter(t=>t!==s);p({tags:l.join(" ")})},_=[{title:"Name",filterIcon:K,filterDropdown:q,filterDropdownProps:{onOpenChange:w},render:({name:s,id:l,is_editable:t,is_report:S})=>e.jsxs(D,{justify:"space-between",align:"flex-start",children:[e.jsx(_e,{to:l,children:s}),e.jsxs(D,{gap:5,className:"Shells__status",children:[e.jsx(me,{title:`Can${ue(t)}be edited`,children:e.jsx(fe,{className:he(t)})}),e.jsx(me,{title:`This is${ue(S)}a report`,children:e.jsx(He,{className:he(S)})})]})]})},{title:"Description",render:({description:s})=>e.jsx("p",{className:"Shells__description",children:s})},{title:"Tags",width:150,render:({tags:s})=>{var l;return e.jsx(D,{gap:5,wrap:"wrap",children:(l=pe(s))==null?void 0:l.map((t,S)=>e.jsx(ne,{color:re(t),onClick:a(t),className:"cursor-pointer",children:t},S))})}},{title:"Folder",width:150,render:({folders:s})=>e.jsx(D,{gap:5,wrap:"wrap",children:s.map((l,t)=>e.jsx(ne,{color:re(l.name),className:"cursor-pointer",children:l.name},t))})},{title:" Actions",width:100,align:"center",render:s=>e.jsxs("div",{className:"flex fl-justify-content-center fl-1",children:[e.jsx(V,{type:"text",onClick:()=>{k.setFieldsValue({...s,tags:pe(s.tags),folders:s.folders.map(l=>l.id)}
1),b({isOpen:!0,type:"edit",id:s.id})},children:e.jsx(fe,{})}),e.jsx(be,{title:"Are you sure you want to delete this shell?",icon:e.jsx(Ge,{}),content:"Delete",okText:"yes",okType:"danger",cancelText:"no",onConfirm:()=>W(s.id),children:e.jsx(V,{type:"text",danger:!0,loading:H,children:e.jsx(Ue,{})})})]})}],n=(s={})=>{k.setFieldsValue(s),b({isOpen:!0,type:"new"})},o=()=>{k.resetFields(),b(te)},f=s=>E(s.target.value);return{openNewModal:n,tagsList:y,removeTagFromSearch:M,isTagsLoading:X,tagsDropdownRender:()=>e.jsxs(Oe,{adaptive:!0,children:[e.jsx(le,{placeholder:"Search for tag",defaultValue:h,onChange:qe(f,Ke),allowClear:!0}),e.jsx(D,{gap:5,className:"mt-1 mb-3",wrap:"wrap",children:v==null?void 0:v.map((s,l)=>e.jsx(ne,{color:re(s),onClick:a(s),className:"cursor-pointer",children:s},l))})]}),columns:_,shells:C,isFetching:c,form:k,modalState:F,closeModal:o,existingTags:v,existingFolders:z,postNewFolderCall:A,deleteFolderCall:Y,patchFolderCall:P,isFoldersLoading:T,onFinish:r}},rs={edit:"Edit folder",add:"Add new folder"},ye={folderName:[{required:!0,message:"Input folder name"}],parentFolder:[{required:!1,message:"Select parent folder"}]},ns=({onSelectFolder:k,menuItems:x,openNewShellModal:F})=>{const{postNewFolderCall:b,deleteFolderCall:q,patchFolderCall:K}=Ce(),[w]=I.useForm(),[h,E]=m.useState([]),[i,p]=m.useState(null),[u,y]=m.useState(null),[C,Q]=m.useState(""),c=ce(),v=u?rs[u]:"",$=()=>u==="edit"?{name:i==null?void 0:i.title,parent:(i==null?void 0:i.parent)||null}:{},X=r=>{if(!Array.isArray(r))return[];const a={},M=[];r.forEach(n=>{!n||!n.id||(a[n.id]=a[n.id]||{...n,children:[]},n.parent===null||!a[n.parent]?M.push(a[n.id]):a[n.parent]&&a[n.parent].children.push(a[n.id]),n.workbooks&&n.workbooks.length>0&&n.workbooks.forEach(o=>{a[n.id].children.push({id:`${n.id}_${o.id}`,name:o.name,isWorkbook:!0,parent:n.id})}))});const _=n=>n.sort((o,f)=>!o.isWorkbook&&f.isWorkbook?-1:o.isWorkbook&&!f.isWorkbook?1:o.name.localeCompare(f.name)).map(o=>{const U=!o.isWorkbook?o.children&&o.children.length>0?h.includes(o.id)?e.jsx(Xe,{}):e.jsx(xe,{}):e.jsx(xe,{}):e.jsx(Ye,{className:"file-icon"});return{title:o.name||"No Name",key:o.id.toString(),value:o.id.toString(),parent:o.parent||null,icon:U,isWorkbook:o.isWorkbook||!1,children:_(o.children||[])}});return _(M)},{data:z=[],isLoading:R}=oe({queryKey:["shellFolders"],queryFn:()=>se.fetchShellFolders(),select:r=>X(r)}),T=({key:r})=>{switch(r){case"add":p(null),y("add");break;case"edit":i&&y("edit");break;case"delete":i&&Z(i.key);break;case"add_shell":i&&F({folders:[{value:i.key,label:i.title}]});break}},A=()=>{w.validateFields().then(r=>{w.resetFields(),u==="edit"?K({id:i.key,body:{name:r.name,parent:r.parent||null}}):u==="add"&&b({name:r.name,parent:r.parent||null}),y(null)})},Y=()=>{w.resetFields(),y(null)},P=(r,a)=>{p(a.node),k(r,a)},Z=r=>{q(r,{onSuccess:()=>{p(null),c.invalidateQueries(["shellFolders"])}})},W=(r,a)=>{if(!a)return r;const M=a.toLowerCase(),_=[],n=f=>{const U=f.title.toLowerCase().includes(M),s=f.children?f.children.map(n).filter(Boolean):[];return U||s.length>0?(s.length>0&&_.push(f.key),{...f,children:s}):null};return{filtered:r.map(n).filter(Boolean),keysToExpand:_}},{filtered:H,keysToExpand:L}=C?W(z,C):{filtered:z,keysToExpand:[]};return m.useEffect(()=>{C&&L.length>0&&E(L)},[C,L]),e.jsx(Be,{spinning:R,children:e.jsxs("div",{className:"directory-tree",children:[e.jsx(We.Title,{level:5,className:"directory-tree__header",children:"Folders"}),e.jsx(le,{placeholder:"Search folders and files...",prefix:e.jsx(Je,{}),value:C,onChange:r=>Q(r.target.value),allowClear:!0,style:{marginBottom:12,borderRadius:0}}),e.jsx(Ve,{draggable:!0,blockNode:!0,showIcon:!0,showLine:{showLeafIcon:!1},treeData:H,expandedKeys:h,onExpand:E,onSelect:P,defaultExpandAll:!0,titleRender:r=>e.jsx(ke,{menu:{items:x.map(a=>({key:a.key,label:a.label})),onClick:T},trigger:["contextMenu"],overlayClassName:"directory-tree-context-menu",children:e.jsx("span",{style:{whiteSpace:"normal",wordWrap:"break-word"},children:r.title})})}),e.jsx(we,{title:v,open:!!u,onOk:A,onCancel:Y,children:e.jsxs(I,{form:w,layout:"vertical",initialValues:$(),children:[e.jsx(I.Item,{name:"name",label:"Folder name",rules:ye.folderName,children:e.jsx(le,{})}),e.jsx(I.Item,{name:"parent",label:"Parent folder",rules:ye.parentFolder,children:e.jsx(ie,{showSearch:!0,style:{width:"100%"},styles:{popup:{root:{maxHeight:400,overflow:"auto"}}},placeholder:"Select parent folder",allowClear:!0,treeData:z})})]})})]})})},{Sider:as,Content:os}=ge,{Panel:Se}=je,J={open:{sidebar:"25%",content:"75%"},close:{sidebar:0,content:"100%"}},Es=()=>{const k=ce(),{openNewModal:x,tagsList:F,removeTagFromSearch:b,isTagsLoading:q,tagsDropdownRender:K,columns:w,shells:h,isFetching:E,form:i,modalState:p,closeModal:u,existingTags:y,existingFolders:C,onFinish:Q}=Ce(),{t:c}=Fe(),v=c("shell.shell_editor"),[$,X]=m.useState(null),[z,R]=m.useState((h==null?void 0:h.results)||[]),[T,A]=m.useState([]),[Y,P]=m.useState(!1),[Z,W]=m.useState(null),[H,L]=m.useState(null),r=[{key:"add",label:c("shell.add_new_folder")},{key:"edit",label:c("shell.rename_folder")},{key:"delete",label:c("shell.remove_folder")},{key:"add_shell",label:c("shell.new_shell")}];Qe(v),m.useEffect(()=>{if($){const d=h==null?void 0:h.filter(N=>N.folders.some(G=>G.id===$));R(d)}else R(h||[])},[$,h]);const a=(d,N)=>{if(N.node.isWorkbook){const G=N.node.key.split("_")[1];L({id:G})}else X(d[0]),L(null)},M=d=>{A(d)},{mutate:_}=O({mutationFn:({selectedRowKeys:d,selectedFolderForMove:N})=>B.addShellToFolder(d,N),onSuccess:()=>{k.invalidateQueries(["shells-list"]),P(!1),A([]),W(null)}}),{mutate:n}=O({mutationFn:({selectedRowKeys:d})=>B.deleteShells({workbooks:d}),onSuccess:()=>{k.invalidateQueries(["shells-list"]),A([])}}),o=()=>{_({selectedRowKeys:T,selectedFolderForMove:Z})},f=d=>{if(!Array.isArray(d))return[];const N=ae=>{const g={},de=[];return ae.forEach(j=>
1{j&&j.id&&(g[j.id]?Object.assign(g[j.id],{...j}):g[j.id]={...j,children:[]},j.parent===null?de.push(g[j.id]):(g[j.parent]||(g[j.parent]={children:[]}),g[j.parent].children.push(g[j.id])))}),de},G=ae=>ae.map(g=>({title:g.name||"No Name",value:g.id,key:g.id,children:g.children?G(g.children):[]})),ve=N(d);return G(ve)},U=f(C),s={selectedRowKeys:T,onChange:M},l=T.length>0,[t,S]=m.useState([J.open.sidebar,J.open.content]),[ee,Te]=m.useState(!1),Ne=ee?e.jsx(ss,{}):e.jsx(ls,{}),Ie=()=>{S(ee?[J.open.sidebar,J.open.content]:[J.close.sidebar,J.close.content]),Te(!ee)};return e.jsx(e.Fragment,{children:e.jsxs(ge,{className:"Shells",children:[e.jsx("div",{className:"Shells__sidebar-trigger-tree",children:e.jsx(V,{className:"Shell__sidebar-button",icon:Ne,onClick:Ie})}),e.jsxs(je,{layout:"horizontal",onResize:S,children:[e.jsx(Se,{size:t[0],collapsible:!0,resizable:!0,children:e.jsx(as,{width:"100%",className:"Shells__sider",children:e.jsx(ns,{className:"Shells__directory-tree",onSelectFolder:a,menuItems:r,openNewShellModal:x})})}),e.jsx(Se,{size:t[1],collapsible:!0,resizable:!0,children:e.jsx(os,{children:H?e.jsx(De,{fileId:H.id}):e.jsxs(e.Fragment,{children:[e.jsxs(D,{justify:"space-between",align:"center",children:[e.jsx($e,{text:v,resetMargin:!0}),e.jsx("div",{className:"custom-elements"}),e.jsx(V,{type:"primary",onClick:x,children:c("shell.new_shell")})]}),e.jsx("div",{className:"mb-2",children:e.jsxs(ze,{spinning:q,children:[!!(F!=null&&F.length)&&e.jsxs(D,{gap:5,className:"mb-1",children:[e.jsx("div",{className:"custom-tag"}),c("shell.some_tag"),":",e.jsx(D,{gap:5,children:F.map((d,N)=>e.jsxs(ne,{color:re(d),children:[d," ",e.jsx(Ze,{className:"cursor-pointer",onClick:()=>b(d)})]},N))})]}),e.jsx(ke,{popupRender:K,trigger:["click"],destroyOnHidden:!0,children:e.jsxs("div",{className:"text-blue cursor-pointer",children:[c("shell.existing_tags"),":",e.jsx(es,{})]})})]})}),l&&e.jsxs(D,{gap:10,className:"mb-2",children:[e.jsx(V,{type:"default",onClick:()=>P(!0),children:c("shell.add_to_folder")}),e.jsx(be,{title:c("shell.confirm_delete"),description:c("shell.confirm_delete_message",{count:T.length}),okText:c("shell.delete"),cancelText:c("shell.cancel"),onConfirm:()=>n({selectedRowKeys:T}),children:e.jsx(V,{type:"default",danger:!0,disabled:!l,children:c("shell.remove_shells")})}),e.jsxs("p",{children:["Selected ",T.length," items"]})]}),e.jsx(Pe,{rowKey:"id",columns:w,dataSource:z,loading:E,rowSelection:s,size:"small",pageSize:100}),e.jsx(ts,{form:i,isOpen:p.isOpen,onCancel:u,tagsList:y,foldersList:U,onFinish:Q}),e.jsx(we,{title:c("shell.select_folder"),open:Y,onCancel:()=>{P(!1),W(null),A([])},onOk:o,okText:c("shell.add"),children:e.jsx(ie,{multiple:!0,style:{width:"100%"},placeholder:c("shell.select_folder"),treeData:f(C),onChange:d=>W(d),treeDefaultExpandAll:!0,allowClear:!0})})]})})})]})]})})};export{Es as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.