PageSourceSearch

https://speednuvem.com.br/assets/AdminVps-BRuJcaZp.js

js speednuvem.com.br collected 2026-09-30 06:38:35 UTC 11,488 bytes, 1 lines download raw bytes

1import{h as n,o as e,B as N,t as k,ab as te,z as ae,w as O}from"./index-D-GBr4OT.js";import{A as re}from"./AdminLayout-DPVaJfs7.js";import{T as ie,a as ne,b as B,c as p,d as le,e as h}from"./table-ISi2tFx3.js";import{B as L}from"./badge-u3waVycK.js";import{D as X,f as ce,b as G,c as W,d as Q}from"./dialog-BrYf6emB.js";import{I as oe}from"./input-D6LAVBj1.js";import{L as v}from"./label-znFVWv-D.js";import{S as C,a as I,b as P,c as V,d}from"./select-c7EgGzNU.js";import{P as U}from"./plus-DcPx_ap3.js";import{C as D}from"./circle-alert-BvdgRX_v.js";import{L as Y}from"./loader-circle-COluazb2.js";import{A as de}from"./activity-DvoJRyey.js";import{P as me}from"./pause-Cw5Cxlv8.js";import{P as ue}from"./play-C5gvBqdI.js";import"./sidebar-DGkNvcst.js";import"./server-BreT6a2k.js";import"./gamepad-2-Cq3c7WUI.js";import"./shopping-cart-sVwxESaO.js";import"./mail-VfMeEExt.js";import"./hard-drive-cU2UDrlK.js";import"./tag-Dzb1TaB-.js";import"./ThemeToggle-CpFdVCpJ.js";import"./index-Ch4cfzOk.js";import"./index-BdQq_4o_.js";import"./useQuery-BQqi4bll.js";import"./search-CPnmhyre.js";import"./index-BCaDnGsR.js";import"./chevron-down-Dx4NE3AC.js";import"./check-B7suo32t.js";const xe=/^[a-zA-Z0-9][a-zA-Z0-9.-]*\.[a-zA-Z]{2,}$/;function he({plans:j,clients:b,loading:c,onSubmit:S}){const[T,y]=n.useState(!1),[r,m]=n.useState({hostname:"",os:"ubuntu-22.04",plan_id:"",region:"br-south",user_id:""}),[A,u]=n.useState({}),[g,o]=n.useState(!1),a={};r.hostname.trim()?xe.test(r.hostname)||(a.hostname="Formato inválido (ex: vps01.exemplo.com)"):a.hostname="Hostname é obrigatório",r.plan_id||(a.plan_id="Selecione um plano"),r.user_id||(a.user_id="Selecione um cliente");const x=t=>(A[t]||g)&&a[t],E=t=>u(l=>({...l,[t]:!0})),_=async t=>{t.preventDefault(),o(!0),!(Object.keys(a).length>0)&&(await S(r),y(!1),m({hostname:"",os:"ubuntu-22.04",plan_id:"",region:"br-south",user_id:""}),u({}),o(!1))},f=t=>{y(t),t||(u({}),o(!1))};return e.jsxs(X,{open:T,onOpenChange:f,children:[e.jsx(ce,{asChild:!0,children:e.jsxs(N,{variant:"hero",size:"sm",children:[e.jsx(U,{className:"w-4 h-4 mr-1"})," Criar VPS"]})}),e.jsxs(G,{className:"glass border-border",children:[e.jsx(W,{children:e.jsx(Q,{children:"Criar VPS via Virtualizor"})}),e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(v,{className:"flex items-center gap-1",children:["Hostname ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(oe,{value:r.hostname,onChange:t=>m({...r,hostname:t.target.value}),onBlur:()=>E("hostname"),placeholder:"vps01.seudominio.com",className:k("bg-secondary/50",x("hostname")&&"border-destructive focus-visible:ring-destructive")}
1),x("hostname")&&e.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1",children:[e.jsx(D,{className:"w-3 h-3"})," ",a.hostname]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"FQDN do servidor (ex: vps01.exemplo.com)"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(v,{className:"flex items-center gap-1",children:["Plano ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(C,{value:r.plan_id,onValueChange:t=>{m({...r,plan_id:t}),u(l=>({...l,plan_id:!0}))},children:[e.jsx(I,{className:k("bg-secondary/50",x("plan_id")&&"border-destructive"),children:e.jsx(P,{placeholder:"Escolha o plano de recursos"})}),e.jsx(V,{children:j.map(t=>e.jsx(d,{value:t.id,children:t.name},t.id))})]}),x("plan_id")&&e.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1",children:[e.jsx(D,{className:"w-3 h-3"})," ",a.plan_id]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Sistema Operacional"}),e.jsxs(C,{value:r.os,onValueChange:t=>m({...r,os:t}),children:[e.jsx(I,{className:"bg-secondary/50",children:e.jsx(P,{})}),e.jsxs(V,{children:[e.jsx(d,{value:"ubuntu-22.04",children:"Ubuntu 22.04 LTS"}),e.jsx(d,{value:"ubuntu-24.04",children:"Ubuntu 24.04 LTS"}),e.jsx(d,{value:"debian-12",children:"Debian 12"}),e.jsx(d,{value:"centos-9",children:"CentOS 9 Stream"}),e.jsx(d,{value:"almalinux-9",children:"AlmaLinux 9"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Região"}),e.jsxs(C,{value:r.region,onValueChange:t=>m({...r,region:t}),children:[e.jsx(I,{className:"bg-secondary/50",children:e.jsx(P,{})}),e.jsxs(V,{children:[e.jsx(d,{value:"br-south",children:"🇧🇷 Brasil Sul"}),e.jsx(d,{value:"br-southeast",children:"🇧🇷 Brasil Sudeste"}),e.jsx(d,{value:"us-east",children:"🇺🇸 US East"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(v,{className:"flex items-center gap-1",children:["Cliente ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(C,{value:r.user_id,onValueChange:t=>{m({...r,user_id:t}),u(l=>({...l,user_id:!0}))},children:[e.jsx(I,{className:k("bg-secondary/50",x("user_id")&&"border-destructive"),children:e.jsx(P,{placeholder:"Selecione o cliente proprietário"})}),e.jsx(V,{children:b.map(t=>e.jsx(d,{value:t.user_id,children:t.full_name||t.user_id},t.user_id))})]}),x("user_id")&&e.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1",children:[e.jsx(D,{className:"w-3 h-3"})," ",a.user_id]})]}),e.jsxs(N,{type:"submit",variant:"hero",className:"w-full",disabled:c,children:[c?e.jsx(Y,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(U,{className:"w-4 h-4 mr-1"}),"Provisionar VPS"]})]})]})]})}const $={active:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",pending:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",provisioning:"bg-primary/20 text-primary border-primary/30",suspended:"bg-destructive/20 text-destructive border-destructive/30",terminated:"bg-muted text-muted-foreground border-border"};async function z(j,b={}){const{data:{session:c}}=await O.auth.getSession();return(await fetch(`https://rrihdzmgfblieriotrpc.supabase.co/functions/v1/virtualizor?action=${j}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c==null?void 0:c.access_token}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJyaWhkem1nZmJsaWVyaW90cnBjIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA3NTM5OTIsImV4cCI6MjA4NjMyOTk5Mn0.5ul_L0-Hbw_1k1dvBLuRhe271G13mkkgL9mI-cxv0ME"},body:JSON.stringify({action:j,...b})})).json()}function Ze(){var H,M,F,R,Z;const[j,b]=te(),[c,S]=n.useState([]),[T,y]=n.useState([]),[r,m]=n.useState([]),[A,u]=n.useState(!1),[g,o]=n.useState(null),[a,x]=n.useState(null),[E,_]=n.useState(!1),[f,t]=n.useState(""),{toast:l}=ae();n.useEffect(()=>{const s=j.get("client");s&&(t(s),b({},{replace:!0}))},[]);const J=n.useMemo(()=>f?c.filter(s=>s.user_id===f):c,[c,f]),w=async()=>{const{data:s}=await O.from("vps_instances").select("*, vps_plans(name)");S(s||[])};n.useEffect(()=>{w(),O.from("vps_plans").select("id, name").eq("is_active",!0).then(({data:s})=>y(s||[])),O.from("profiles").select("user_id, full_name").then(({data:s})=>m(s||[]))},[]);const q=async s=>{u(!0);const i=await z("create",s);if(u(!1),i.error)throw l({title:"Erro",description:i.error,variant:"destructive"}),new Error(i.error);l({title:"VPS criada com sucesso!",description:`Hostname: ${s.hostname}`}),w()},K=async s=>{o(s);const i=await z("suspend",{instance_id:s});o(null),i.error?l({title:"Erro ao suspender",description:i.error,variant:"destructive"}):(l({title:"VPS suspensa"}),w())},ee=async s=>{o(s);const i=await z("unsuspend",{instance_id:s});o(null),i.error?l({title:"Erro ao reativar",description:i.error,variant:"destructive"}):(l({title:"VPS reativada"}),w())},se=async s=>{o(s);const i=await z("status",{instance_id:s});o(null),i.error?l({title:"Erro",description:i.error,variant:"destructive"}):(x(i),_(!0))};return e.jsx(re,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"font-heading text-2xl font-bold text-foreground",children:"Instâncias VPS"}),f&&e.jsxs(L,{variant:"outline",className:"text-xs gap-1",children:["Filtrado por cliente",e.jsx("button",{onClick:()=>t(""),className:"ml-1 hover:text-destructive",children:"✕"})]})]}),e.jsx(he,{plans:T,clients:r,loading:A,onSubmit:q})]}),e.jsx("div",{className:"glass rounded-xl border border-border overflow-hidden",children:e.jsxs(ie,{children:[e.jsx(ne,{children:e.jsxs(B,{children:[e.jsx(p,{children:"Hostname"}),e.jsx(p,{children:"Plano"}),e.jsx(p,{children:"IP"}),e.jsx(p,{children:"OS"}),e.jsx(p,{children:"Região"}),e.jsx(p,{children:"Status"}),e.jsx(p,{className:"text-right",children:"Ações"})]})}),e.jsx(le,{children:J.length===0?e.jsx(B,{children:e.jsx(h,{colSpan:7,className:"text-center text-muted-foreground py-8",children:"Nenhuma instância VPS encontrada."})}):J.map(s=>{var i;return e.jsxs(B,{children:[e.jsx(h,{className:"font-medium",children:s.hostname}),e.jsx(h,{children:((i=s.vps_plans)==null?void 0:i.name)||"—"}),e.jsx(h,{className:"font-mono text-sm",children:s.ip_address||"—"}),e.jsx(h,{children:s.os}),e.jsx(h,{children:s.region}),e.jsx(h,{children:e.jsx(L,{variant:"outline",className:$[s.status]||"",children:s.status})}),e.jsx(h,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(N,{size:"icon",variant:"ghost",className:"h-8 w-8",title:"Monitorar",disabled:g===s.id,onClick:()=>se(s.id),children:g===s.id?e.jsx(Y,{className:"w-4 h-4 animate-spin"}):e.jsx(de,{className:"w-4 h-4"})}),s.status==="active"||s.status==="provisioning"?e.jsx(N,{size:"icon",variant:"ghost",className:"h-8 w-8 text-yellow-400 hover:text-yellow-300",title:"Suspender",disabled:g===s.id,onClick:()=>K(s.id),children:e.jsx(me,{className:"w-4 h-4"})}):s.status==="suspended"?e.jsx(N,{size:"icon",variant:"ghost",className:"h-8 w-8 text-emerald-400 hover:text-emerald-300",title:"Reativar",disabled:g===s.id,onClick:()=>ee(s.id),children:e.jsx(ue,{className:"w-4 h-4"})}):null]})})]},s.id)})})]})}),e.jsx(X,{open:E,onOpenChange:_,children:e.jsxs(G,{className:"glass border-border max-w-lg",children:[e.jsx(W,{children:e.jsx(Q,{children:"Status da VPS"})}),a?e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"Hostname"}),e.jsx("p",{className:"font-medium",children:(H=a.db)==null?void 0:H.hostname})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"Status DB"}),e.jsx(L,{variant:"outline",className:$[(M=a.db)==null?void 0:M.status]||"",children:(F=a.db)==null?void 0:F.status})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"IP"}),e.jsx("p",{className:"font-mono",children:((R=a.db)==null?void 0:R.ip_address)||"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"OS"}),e.jsx("p",{children:(Z=a.db)==null?void 0:Z.os})]})]}),a.virtualizor&&e.jsxs("div",{className:"border-t border-border pt-3 space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Virtualizor"}),e.jsx("pre",{className:"bg-secondary/50 rounded-lg p-3 text-xs overflow-auto max-h-48",children:JSON.stringify(a.virtualizor,null,2)})]})]}):e.jsx("p",{className:"text-muted-foreground",children:"Carregando..."})]})})]})})}export{Ze 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.