diff --git a/server/static/assets/index-c16bf6d2.js b/server/static/assets/index-0618fb87.js similarity index 99% rename from server/static/assets/index-c16bf6d2.js rename to server/static/assets/index-0618fb87.js index 0fa3097..56ec2c8 100644 --- a/server/static/assets/index-c16bf6d2.js +++ b/server/static/assets/index-0618fb87.js @@ -243,7 +243,7 @@ to { } `,vs=16,ig=({reverseOrder:e,position:t="top-center",toastOptions:n,gutter:r,children:i,containerStyle:o,containerClassName:a})=>{let{toasts:s,handlers:l}=Tw(n);return C.createElement("div",{style:{position:"fixed",zIndex:9999,top:vs,left:vs,right:vs,bottom:vs,pointerEvents:"none",...o},className:a,onMouseEnter:l.startPause,onMouseLeave:l.endPause},s.map(u=>{let c=u.position||t,v=l.calculateOffset(u,{reverseOrder:e,gutter:r,defaultPosition:t}),m=t2(c,v);return C.createElement(e2,{id:u.id,key:u.id,onHeightUpdate:l.updateHeight,className:u.visible?n2:"",style:m},u.type==="custom"?ul(u.message,u):i?i(u):C.createElement(Zw,{toast:u,position:c}))}))},Fe=Ce;const r2=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-panel-left-close",children:[d.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),d.jsx("path",{d:"M9 3v18"}),d.jsx("path",{d:"m16 15-3-3 3-3"})]}),i2=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-layout-grid",children:[d.jsx("rect",{width:"7",height:"7",x:"3",y:"3",rx:"1"}),d.jsx("rect",{width:"7",height:"7",x:"14",y:"3",rx:"1"}),d.jsx("rect",{width:"7",height:"7",x:"14",y:"14",rx:"1"}),d.jsx("rect",{width:"7",height:"7",x:"3",y:"14",rx:"1"})]}),o2=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-book-key",children:[d.jsx("path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H14"}),d.jsx("path",{d:"M20 8v14H6.5a2.5 2.5 0 0 1 0-5H20"}),d.jsx("circle",{cx:"14",cy:"8",r:"2"}),d.jsx("path",{d:"m20 2-4.5 4.5"}),d.jsx("path",{d:"m19 3 1 1"})]}),a2=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-fingerprint",children:[d.jsx("path",{d:"M2 12C2 6.5 6.5 2 12 2a10 10 0 0 1 8 4"}),d.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12c0-.7.12-1.37.34-2"}),d.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),d.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),d.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),d.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),d.jsx("path",{d:"M2 16h.01"}),d.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),d.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2c0 .47 0 1.17-.02 2"})]}),s2=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-circle-user-round",children:[d.jsx("path",{d:"M18 20a6 6 0 0 0-12 0"}),d.jsx("circle",{cx:"12",cy:"10",r:"4"}),d.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),l2=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-settings",children:[d.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),d.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),qd=e=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e.className,children:[d.jsx("path",{d:"M18 6 6 18"}),d.jsx("path",{d:"m6 6 12 12"})]}),vo=e=>d.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:`${e.black?"":"invert"}`,xmlns:"http://www.w3.org/2000/svg",children:[d.jsx("path",{d:"M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z",opacity:".25"}),d.jsx("path",{d:"M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z",children:d.jsx("animateTransform",{attributeName:"transform",type:"rotate",dur:"0.75s",values:"0 12 12;360 12 12",repeatCount:"indefinite"})})]}),Al=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-x-circle text-red-400",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("path",{d:"m15 9-6 6"}),d.jsx("path",{d:"m9 9 6 6"})]}),Fl=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-alert-circle text-yellow-500",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),d.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),u2=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-help-circle",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),d.jsx("path",{d:"M12 17h.01"})]}),c2=()=>d.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:d.jsx("path",{d:"M3 2C2.44772 2 2 2.44772 2 3V12C2 12.5523 2.44772 13 3 13H12C12.5523 13 13 12.5523 13 12V8.5C13 8.22386 12.7761 8 12.5 8C12.2239 8 12 8.22386 12 8.5V12H3V3L6.5 3C6.77614 3 7 2.77614 7 2.5C7 2.22386 6.77614 2 6.5 2H3ZM12.8536 2.14645C12.9015 2.19439 12.9377 2.24964 12.9621 2.30861C12.9861 2.36669 12.9996 2.4303 13 2.497L13 2.5V2.50049V5.5C13 5.77614 12.7761 6 12.5 6C12.2239 6 12 5.77614 12 5.5V3.70711L6.85355 8.85355C6.65829 9.04882 6.34171 9.04882 6.14645 8.85355C5.95118 8.65829 5.95118 8.34171 6.14645 8.14645L11.2929 3H9.5C9.22386 3 9 2.77614 9 2.5C9 2.22386 9.22386 2 9.5 2H12.4999H12.5C12.5678 2 12.6324 2.01349 12.6914 2.03794C12.7504 2.06234 12.8056 2.09851 12.8536 2.14645Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})}),d2=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-scroll-text",children:[d.jsx("path",{d:"M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"}),d.jsx("path",{d:"M19 17V5a2 2 0 0 0-2-2H4"}),d.jsx("path",{d:"M15 8h-5"}),d.jsx("path",{d:"M15 12h-5"})]}),f2=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-trash-2",children:[d.jsx("path",{d:"M3 6h18"}),d.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),d.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),d.jsx("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),d.jsx("line",{x1:"14",x2:"14",y1:"11",y2:"17"})]}),p2=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-refresh-ccw-dot",children:[d.jsx("path",{d:"M3 2v6h6"}),d.jsx("path",{d:"M21 12A9 9 0 0 0 6 5.3L3 8"}),d.jsx("path",{d:"M21 22v-6h-6"}),d.jsx("path",{d:"M3 12a9 9 0 0 0 15 6.7l3-2.7"}),d.jsx("circle",{cx:"12",cy:"12",r:"1"})]}),h2=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-pen-line text-white/80 hover:text-white",children:[d.jsx("path",{d:"M12 20h9"}),d.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),m2=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-user-x text-red-400",children:[d.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),d.jsx("circle",{cx:"9",cy:"7",r:"4"}),d.jsx("line",{x1:"17",x2:"22",y1:"8",y2:"13"}),d.jsx("line",{x1:"22",x2:"17",y1:"8",y2:"13"})]}),v2=e=>d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e.className,children:d.jsx("path",{d:"M20 6 9 17l-5-5"})}),g2=()=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-red-400/80 hover:text-red-400",children:[d.jsx("path",{d:"M3 6h18"}),d.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),d.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]});function Dr(e,t,n){const r=e.length;let i="";for(let o=0;o47&&a<58||a>64&&a<91||a>96&&a<123||t.includes(e[o])?i+=e[o]:Ce.error(`${e[o]} is not allowed in input here!`,{position:n?"bottom-right":"top-center"})}return i}function y2({openWindow:e,setOpenWindow:t,setRefresh:n}){return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`fixed z-50 overflow-auto bg-white h-full w-[40%] top-0 left-[60%] p-4 text-black ${e?"":"hidden"}`,children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("button",{onClick:r=>{r.preventDefault(),t(!1)},className:"hover:bg-red-200 p-1 rounded",children:d.jsx(qd,{})}),d.jsx("p",{className:"text-xl",children:"Creating a new Application"})]}),d.jsx("div",{className:"h-full px-8 py-16",children:d.jsx(x2,{setRefresh:n,setOpenWindow:t})})]}),d.jsx("div",{className:`fixed h-full w-full top-0 left-0 bg-black/50 ${e?"":"hidden"}`})]})}function x2({setRefresh:e,setOpenWindow:t}){const n=Pt(),r={name:"",refresh_timer:"3m0s",source:{path:"",repoURL:"",targetRevision:"HEAD"}},[i,o]=C.useState(r),a=s=>{s.preventDefault();const l=fetch("/api/apps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});Fe.promise(l,{loading:"Creating new application",success:u=>{let c=!0;return u.status===401&&n("/login"),u.status!==200&&(c=!1),u.json().then(v=>{c?(Fe.success(v.message),e(!0),t(!1)):Fe.error(v.message)}).catch(v=>{console.log(v),Fe.error("Failed to create new application")}),"Executing task"},error:u=>(console.log(u),"Failed to create new application")})};return d.jsxs("form",{className:"flex flex-col gap-8",onSubmit:a,children:[d.jsx(Lo,{name:"Name",placeholder:"auth_backend_server",value:i.name,onChange:s=>{o({...i,name:Dr(s.target.value,["_"])})}}),d.jsx(Lo,{name:"Sync Timer",placeholder:"3m30s (Default, for 3 minute and 30 seconds)",value:i.refresh_timer,onChange:s=>{o({...i,refresh_timer:Dr(s.target.value,[])})}}),d.jsx(Lo,{name:"Repository URL",placeholder:"https://github.com/username/repo",value:i.source.repoURL,onChange:s=>{o({...i,source:{...i.source,repoURL:Dr(s.target.value,[":","/",".","_","-"])}})}}),d.jsx(Lo,{name:"Service File Path",placeholder:"deploy/service.yaml",value:i.source.path,onChange:s=>{o({...i,source:{...i.source,path:Dr(s.target.value,[".","/","_","-"])}})}}),d.jsx(Lo,{name:"Target Revision",placeholder:"HEAD (Default, can be master, main, my_branch)",value:i.source.targetRevision,onChange:s=>{o({...i,source:{...i.source,targetRevision:Dr(s.target.value,[])}})}}),d.jsxs("div",{className:"flex items-center gap-4",children:[d.jsx("input",{className:"text-black py-2 px-4 rounded font-bold bg-green-400 hover:bg-green-500 cursor-pointer",value:"Create",type:"submit"}),d.jsx("input",{className:"text-black py-2 px-4 rounded font-bold border hover:bg-gray-100 border-1 border-black cursor-pointer",onClick:s=>{s.preventDefault(),o(r),Fe.success("Input data reset")},type:"button",value:"Clear"})]})]})}function Lo(e){const t=e.name.replace(" ","_");return d.jsxs("label",{htmlFor:t,className:"flex flex-col",children:[d.jsx("span",{className:"font-semibold my-1",children:e.name}),d.jsx("input",{id:t,required:!0,className:"border p-1 rounded px-2 bg-white",type:"text",placeholder:e.placeholder,value:e.value,onChange:e.onChange})]})}const w2=e=>fetch("/api/apps").then(async t=>{if(t.status===401)e("/login");else if(t.status!==200){Ce.error("Something wend wrong, server didn't respond with 200");return}return await t.json()});function S2({refresh:e}){const t=Pt(),{data:n,isLoading:r,isError:i,refetch:o}=Dl({queryKey:["GET /api/apps","GET_ALL_APPLICATIONS"],queryFn:()=>w2(t)});return C.useEffect(()=>{const a=setInterval(()=>{o()},5e3);return()=>{clearInterval(a)}},[o]),e===!0&&o(),i?d.jsx(It,{icon:d.jsx(Al,{}),message:"Something wend wrong while fetching applications"}):r||n===void 0?d.jsx(It,{icon:d.jsx(vo,{}),message:"Loading"}):n.data===null||n.data.length===0?d.jsx(It,{icon:d.jsx(Fl,{}),message:"No Application"}):d.jsx("ul",{className:"xl:w-[70%] mx-auto",children:n.data.map((a,s)=>d.jsxs("li",{className:"p-2 md:p-4 my-2 md:my-4 rounded bg-[#373d49]/30 hover:bg-[#373d49]/80 cursor-pointer",onClick:l=>{l.preventDefault(),t(`/apps/${a.name}`)},children:[d.jsx("div",{className:"flex items-center justify-between",children:d.jsxs("div",{className:"flex items-center justify-center",children:[d.jsx("span",{className:"md:font-bold md:text-xl mr-1 md:mr-4",children:a.name}),d.jsx(E2,{health:a.health})]})}),d.jsxs("div",{className:"md:flex md:items-center md:justify-start mt-4 text-sm md:gap-8",children:[d.jsxs("div",{children:[d.jsx("span",{className:"opacity-50",children:"Last synched: "}),d.jsx(Fi,{time:a.last_synced_at})]}),d.jsxs("div",{children:[d.jsx("span",{className:"opacity-50",children:"Updated: "}),d.jsx(Fi,{time:a.updated_at})]})," ",d.jsxs("div",{children:[d.jsx("span",{className:"opacity-50",children:"Created: "}),d.jsx(Fi,{time:a.created_at})]})]})]},s))})}function It({icon:e,message:t}){return d.jsx("div",{className:"h-64 flex justify-center items-center",children:d.jsxs("div",{className:"flex items-center gap-2",children:[e,d.jsx("p",{className:"text-xl",children:t})]})})}function E2({health:e}){switch(e){case"healthy":return d.jsx("span",{className:"text-xs text-green-400 font-semibold rounded-lg py-1 px-2 bg-green-400/20",children:"healthy"});case"progressing":return d.jsx("span",{className:"text-xs text-blue-400 font-semibold rounded-lg py-1 px-2 bg-blue-400/20",children:"progressing"});case"degraded":return d.jsx("span",{className:"text-xs text-yellow-400 font-semibold rounded-lg py-1 px-2 bg-yellow-400/20",children:"degraded"});case"suspended":return d.jsx("span",{className:"text-xs text-red-400 font-semibold rounded-lg py-1 px-2 bg-red-400/20",children:"suspended"});default:return d.jsx("span",{className:"text-xs text-gray-400 font-semibold rounded-lg py-1 px-2 bg-gray-400/20",children:"Status: N/A"})}}function Fi({time:e}){const[t,n]=C.useState(Date.now());if(C.useEffect(()=>{const m=setInterval(()=>{n(Date.now())},1e4);return()=>{clearInterval(m)}},[]),e==="0001-01-01T00:00:00Z")return d.jsx("span",{className:"opacity-90",children:"N/A"});const r=new Date(e),i=t-r.getTime();if(isNaN(i))return"Just now";let a=i/1e3/60,s=a/60,l=s/24,u=l/7,c=u/4.34524,v=c/12;return v=Math.floor(v),v>0?`${v} year ago`:(c=Math.floor(c),c>0?`${c} months ago`:(u=Math.floor(u),u>0?`${u} weeks ago`:(l=Math.floor(l),l>0?`${l} days ago`:(s=Math.floor(s),s>0?`${s} hours ago`:(a=Math.floor(a),a>0?`${a} minutes ago`:"Just now")))))}function C2(){const e=Pt(),[t]=fw(),n=t.get("redirect"),[r,i]=C.useState(!1),[o,a]=C.useState(!1);return C.useEffect(()=>{document.title=Er("Applications"),n&&e(n)},[n,e]),d.jsxs("div",{className:"h-screen p-8",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("p",{className:"text-2xl",children:"Applications"}),d.jsx("button",{onClick:s=>{s.preventDefault(),i(!0)},className:"bg-white text-black py-2 px-4 rounded font-bold hover:bg-white/90",children:"New Application"})]}),d.jsx(y2,{openWindow:r,setOpenWindow:i,setRefresh:a}),d.jsx("div",{className:"m-4 md:m-8 mt-8 md:mt-16 overflow-auto h-[84%]",children:d.jsx(S2,{refresh:o})})]})}const zp=e=>{window.outerWidth<=1e3&&e(!1)};function j2({openHelpPanel:e,setOpenHelpPanel:t}){const[n,r]=C.useState(!0);return C.useEffect(()=>{zp(r)},[]),window.onresize=()=>{zp(r)},d.jsxs("div",{className:`bg-sidebar relative flex flex-col ${n?"w-64":"w-18"} p-4`,children:[d.jsxs("div",{className:`flex ${n?"":"flex-col"} justify-between items-center`,children:[d.jsxs("div",{className:"flex items-center gap-2 px-1 py-3",children:[d.jsx("img",{src:"/logo.png",className:"h-8 w-8",alt:"Meltcd Logo"}),d.jsx("p",{className:`font-bold text-lg ${n?"":"hidden"} `,children:"Meltcd"})]}),d.jsx("span",{onClick:i=>{i.preventDefault(),r(!n)},className:`${n?"":"rotate-180 mt-4"} hover:bg-sidebarLite rounded p-2 cursor-pointer`,children:d.jsx(r2,{})})]}),d.jsxs("div",{className:"mt-8 flex flex-col gap-4 flex-1",children:[d.jsx(mi,{name:"Apps",to:"/apps",icon:d.jsx(i2,{}),panelOpen:n}),d.jsx(mi,{name:"Repos",to:"/repos",icon:d.jsx(o2,{}),panelOpen:n}),d.jsx(mi,{name:"Secrets",to:"/secrets",icon:d.jsx(a2,{}),panelOpen:n}),d.jsx(mi,{name:"Logs",to:"/logs",icon:d.jsx(d2,{}),panelOpen:n})]}),d.jsxs("div",{className:"mb-2 flex flex-col gap-4",children:[d.jsx(k2,{panelOpen:n}),d.jsx(mi,{name:"Settings",to:"/settings",icon:d.jsx(l2,{}),panelOpen:n}),d.jsxs("div",{className:`hover:bg-sidebarLite hover:border-l hover:border-l-[5px] hover:border-white/40 rounded-r px-2 flex gap-2 items-center cursor-pointer ${n?"py-1":"justify-center py-2"} ${e?"bg-sidebarLite rounded":""} - `,onClick:i=>{i.preventDefault(),t(!e)},children:[d.jsx(u2,{}),d.jsx("span",{className:`text-lg ${n?"":"hidden"}`,children:"Help & Support"})]})]})]})}function mi({name:e,to:t,icon:n,panelOpen:r}){return d.jsxs(uw,{to:t,className:`hover:bg-sidebarLite hover:border-l hover:border-l-[5px] hover:border-white/40 rounded-r px-2 flex gap-2 items-center ${r?"py-1":"justify-center py-2"}`,children:[n,d.jsx("span",{className:`text-lg ${r?"":"hidden"}`,children:e})]})}function k2({panelOpen:e}){const t=C.useContext(xa);return t===null?null:d.jsx(mi,{name:t.username,to:"/users",icon:d.jsx(s2,{}),panelOpen:e})}const P2="dev";function og(){return d.jsxs("div",{className:"flex items-center mb-6 text-2xl font-semibold text-white",children:[d.jsx("img",{className:"w-8 h-8 mr-2 select-none",src:"/icon.png",alt:"Meltcd logo"}),"Meltcd"]})}const xa=C.createContext(null);function N2(){const[e,t]=C.useState(!1),[n,r]=C.useState(null),i=Pt(),o=oi();return C.useEffect(()=>{(async()=>{try{const s=await fetch("/api/users/current");if(s.status===401)i("/login");else if(s.status===200){const l=await s.text();if(l.split(" ").length!=1)return;r(l),o.pathname==="/"&&i("/apps")}else Fe.error("Something wend wrong, server does not respond with 200")}catch{Fe.error("Something wend wrong, try again!")}})()},[i]),n?d.jsxs("div",{className:"flex flex-row h-screen w-screen overflow-hidden",children:[d.jsx(xa.Provider,{value:{username:n,setUsername:r},children:d.jsx(j2,{openHelpPanel:e,setOpenHelpPanel:t})}),d.jsxs("div",{className:"flex-1 relative",children:[d.jsx(xa.Provider,{value:{username:n,setUsername:r},children:d.jsx(Bx,{})}),d.jsxs("div",{className:`absolute h-auto rounded bg-sidebar w-48 left-4 bottom-4 p-4 flex flex-col gap-2 + `,onClick:i=>{i.preventDefault(),t(!e)},children:[d.jsx(u2,{}),d.jsx("span",{className:`text-lg ${n?"":"hidden"}`,children:"Help & Support"})]})]})]})}function mi({name:e,to:t,icon:n,panelOpen:r}){return d.jsxs(uw,{to:t,className:`hover:bg-sidebarLite hover:border-l hover:border-l-[5px] hover:border-white/40 rounded-r px-2 flex gap-2 items-center ${r?"py-1":"justify-center py-2"}`,children:[n,d.jsx("span",{className:`text-lg ${r?"":"hidden"}`,children:e})]})}function k2({panelOpen:e}){const t=C.useContext(xa);return t===null?null:d.jsx(mi,{name:t.username,to:"/users",icon:d.jsx(s2,{}),panelOpen:e})}const P2="dev";function og(){return d.jsxs("div",{className:"flex items-center mb-6 text-2xl font-semibold text-white",children:[d.jsx("img",{className:"w-8 h-8 mr-2 select-none",src:"/icon.png",alt:"Meltcd logo"}),"Meltcd"]})}const xa=C.createContext(null);function N2(){const[e,t]=C.useState(!1),[n,r]=C.useState(null),i=Pt(),o=oi();return C.useEffect(()=>{(async()=>{try{const s=await fetch("/api/users/current");if(s.status===401)i("/login");else if(s.status===200){const l=await s.text();if(l.split(" ").length!=1)return;r(l),o.pathname==="/"&&i("/apps")}else Fe.error("Something wend wrong, server does not respond with 200")}catch{Fe.error("Something wend wrong, try again!")}})()}),n?d.jsxs("div",{className:"flex flex-row h-screen w-screen overflow-hidden",children:[d.jsx(xa.Provider,{value:{username:n,setUsername:r},children:d.jsx(j2,{openHelpPanel:e,setOpenHelpPanel:t})}),d.jsxs("div",{className:"flex-1 relative",children:[d.jsx(xa.Provider,{value:{username:n,setUsername:r},children:d.jsx(Bx,{})}),d.jsxs("div",{className:`absolute h-auto rounded bg-sidebar w-48 left-4 bottom-4 p-4 flex flex-col gap-2 ${e?"":"hidden"} `,children:[d.jsx(To,{name:"Documentation",url:"https://cd.meltred.tech/docs"}),d.jsx(To,{name:"File bug or issue",url:"https://github.com/meltred/meltcd/issues"}),d.jsx(To,{name:"GitHub",url:"https://github.com/meltred/meltcd"}),d.jsx(To,{name:"Discord",url:"https://discord.gg/Y2C6mEhhf3"}),d.jsx(To,{name:"Twitter",url:"https://twitter.com/meltredhq"}),d.jsxs("div",{className:"text-center border-t border-t-white/20 pt-2",children:["v",d.jsx("span",{className:"font-bold",children:P2})]})]})]}),d.jsx(ig,{})]}):d.jsx("div",{className:"h-screen w-screen fixed top-0 left-0 bg-inherit flex justify-center items-center",children:d.jsx(og,{})})}function To({name:e,url:t}){return d.jsxs("a",{href:t,target:"_blank",className:"flex items-center gap-2 hover:text-white/70",children:[d.jsx("p",{children:e}),d.jsx(c2,{})]})}function R2(){return C.useEffect(()=>{document.title=Er("Secrets")},[]),d.jsx("div",{className:"h-screen p-8",children:d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("p",{className:"text-2xl",children:"Secrets"}),d.jsx("button",{onClick:e=>{e.preventDefault()},className:"bg-white text-black py-2 px-4 rounded font-bold hover:bg-white/90",children:"New Secret"})]})})}const O2=e=>fetch("/api/users").then(async t=>(t.status===401&&e("/login"),await t.json()));function L2(){return C.useEffect(()=>{document.title=Er("Users")},[]),d.jsxs("div",{className:"h-screen p-8 overflow-auto",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("p",{className:"text-2xl",children:"Users"}),d.jsx("button",{onClick:e=>{e.preventDefault()},className:"bg-white text-black py-2 px-4 rounded font-bold xhover:bg-white/90 cursor-not-allowed opacity-60",children:"New User"})]}),d.jsx("div",{className:"m-4 md:m-8 mt-8 md:mt-16 overflow-auto h-[84%]",children:d.jsx(T2,{})})]})}function T2(){const e=Pt(),t=C.useContext(xa),{data:n,isLoading:r,isError:i,refetch:o}=Dl({queryKey:["GET /api/users","GET_ALL_USERS"],queryFn:()=>O2(e)});return i?d.jsx(It,{icon:d.jsx(Al,{}),message:"Something wend wrong while fetching users"}):r||n===void 0||t===null?d.jsx(It,{icon:d.jsx(vo,{}),message:"Loading"}):n.data.length===0?d.jsx(It,{icon:d.jsx(Fl,{}),message:"No Users"}):d.jsx("ul",{className:"xl:w-[70%] mx-auto",children:n.data.map((a,s)=>d.jsxs("li",{className:"p-2 md:p-4 my-2 md:my-4 rounded bg-[#373d49]/30",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center justify-center",children:[d.jsx("span",{className:"md:font-bold md:text-xl mr-1 md:mr-4",children:a.username}),a.role==="admin"?d.jsx("span",{className:"text-xs text-green-400 font-semibold rounded-lg py-1 px-2 bg-green-400/20 mr-1 md:mr-4",children:"admin"}):null,t.username===a.username?d.jsx("span",{className:"text-xs text-yellow-400 font-semibold rounded-lg py-1 px-2 bg-yellow-400/20",children:"you"}):null]}),d.jsx(D2,{username:a.username,refetch:o})]}),d.jsxs("div",{className:"md:flex md:items-center md:justify-start mt-4 text-sm md:gap-8",children:[d.jsxs("div",{children:[d.jsx("span",{className:"opacity-50",children:"Last Logged-In: "}),d.jsx(Fi,{time:a.lastLoggedIn})]}),d.jsxs("div",{children:[d.jsx("span",{className:"opacity-50",children:"Updated: "}),d.jsx(Fi,{time:a.updatedAt})]})," ",d.jsxs("div",{children:[d.jsx("span",{className:"opacity-50",children:"Created: "}),d.jsx(Fi,{time:a.createdAt})]})]})]},s))})}function D2({username:e,refetch:t}){const[n,r]=C.useState(!1),[i,o]=C.useState(""),[a,s]=C.useState(""),[l,u]=C.useState(""),[c,v]=C.useState(""),[m,x]=C.useState("username"),S=C.useContext(xa);return S===null?null:d.jsxs("div",{className:"flex items-center gap-4 relative",children:[d.jsxs("div",{className:`relative ${n?"bg-sidebarLite rounded":""}`,children:[d.jsx("div",{className:"cursor-pointer hover:bg-sidebarLite rounded p-2 ",onClick:()=>{r(!n)},children:d.jsx(h2,{})}),d.jsxs("div",{className:`absolute right-12 -top-0 p-4 rounded bg-sidebarLite z-10 diff --git a/server/static/index.html b/server/static/index.html index eac56dd..82e6a8e 100644 --- a/server/static/index.html +++ b/server/static/index.html @@ -21,7 +21,7 @@ Meltcd - + diff --git a/ui/src/components/Layout.tsx b/ui/src/components/Layout.tsx index 168176e..0af4790 100644 --- a/ui/src/components/Layout.tsx +++ b/ui/src/components/Layout.tsx @@ -71,7 +71,7 @@ export default function Layout() { }; getUser(); - }, [navigate]); + }); if (!username) { return (