tide-commander 1.87.0 → 1.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{BossLogsModal-S3Rke-8g.js → BossLogsModal-BK6N5fG2.js} +1 -1
- package/dist/assets/{BossSpawnModal-BjWGNCnz.js → BossSpawnModal-BTy-lus4.js} +1 -1
- package/dist/assets/{ControlsModal-6yfU0XjZ.js → ControlsModal-B4MhaF1V.js} +1 -1
- package/dist/assets/{DockerLogsModal-CYq0hNz6.js → DockerLogsModal-C33dAwy1.js} +1 -1
- package/dist/assets/{EmbeddedEditor-ZBdqRDqm.js → EmbeddedEditor-BfjjT-GF.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-BcV5jAse.js → GmailOAuthSetup-TQyjHs3_.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-DyUW_STE.js → GoogleOAuthSetup-DAIzYKy8.js} +1 -1
- package/dist/assets/{IframeModal-D9A3dUUc.js → IframeModal-g8tC4aah.js} +1 -1
- package/dist/assets/IntegrationsPanel-CuKr7702.js +2 -0
- package/dist/assets/{LogViewerModal-BWkbY7wa.js → LogViewerModal-DO45Kea0.js} +1 -1
- package/dist/assets/{MonitoringModal-AZzokZAZ.js → MonitoringModal-OIwmagj2.js} +1 -1
- package/dist/assets/{PM2LogsModal-q98eiBfq.js → PM2LogsModal-BRQzSiFN.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-CTxRP2qE.js → RestoreArchivedAreaModal-CBRN9Xpb.js} +1 -1
- package/dist/assets/{Scene2DCanvas-C11dztp1.js → Scene2DCanvas-4J4ZefT6.js} +1 -1
- package/dist/assets/{SceneManager-CsW9MYrD.js → SceneManager-DZsJcYvW.js} +1 -1
- package/dist/assets/{SkillsPanel-BeZr9w6E.js → SkillsPanel-DHk7h3Ja.js} +1 -1
- package/dist/assets/SlackMultiInstanceSetup-Dp1q2zM1.js +2 -0
- package/dist/assets/{SpawnModal-DY_KM6lX.js → SpawnModal-CfozYMNI.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-D6RvjGX9.js → SubordinateAssignmentModal-BBfbpVUr.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-BmqjXv9T.js → TriggerManagerPanel-DQw9nt1r.js} +2 -2
- package/dist/assets/{WorkflowEditorPanel-Rd5ZjJmt.js → WorkflowEditorPanel-BM2ec8CS.js} +1 -1
- package/dist/assets/{index-DSvJOrb7.js → index-BiAZinYH.js} +2 -2
- package/dist/assets/{index-BYVHgVEo.js → index-BqbR55dr.js} +1 -1
- package/dist/assets/{index-DRGyDtmm.js → index-CcSJA57k.js} +1 -1
- package/dist/assets/{index-BtJyOo4p.js → index-DNEUJDeO.js} +1 -1
- package/dist/assets/{index-BoORE9Q1.js → index-DY9w7IcH.js} +1 -1
- package/dist/assets/{index-DHHRkTG1.js → index-bcwTXJ6F.js} +1 -1
- package/dist/assets/index-fZfyvIUZ.js +2 -0
- package/dist/assets/{index-BxaEkSIx.js → index-jXkaBxIq.js} +3 -3
- package/dist/assets/index-xEvpFBA8.js +8 -0
- package/dist/assets/main-Bw5ZddEN.css +1 -0
- package/dist/assets/main-D-YFCprA.js +213 -0
- package/dist/assets/{web-D3zCwsS9.js → web-BrBkKQlr.js} +1 -1
- package/dist/assets/{web-DS0FHmg8.js → web-DCu3NTho.js} +1 -1
- package/dist/assets/{web-DEq3Te_H.js → web-DX588C-g.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/src/packages/server/data/builtin-skills/explore-database.js +175 -0
- package/dist/src/packages/server/data/builtin-skills/index.js +2 -0
- package/dist/src/packages/server/data/event-queries.js +2 -0
- package/dist/src/packages/server/data/index.js +56 -2
- package/dist/src/packages/server/data/migrations/006_slack_messages_integration_instance.sql +9 -0
- package/dist/src/packages/server/index.js +2 -1
- package/dist/src/packages/server/integrations/gmail/gmail-trigger-handler.js +9 -1
- package/dist/src/packages/server/integrations/slack/index.js +65 -19
- package/dist/src/packages/server/integrations/slack/slack-client.js +44 -602
- package/dist/src/packages/server/integrations/slack/slack-config.js +229 -29
- package/dist/src/packages/server/integrations/slack/slack-instance-manifest.js +150 -0
- package/dist/src/packages/server/integrations/slack/slack-instance.js +801 -0
- package/dist/src/packages/server/integrations/slack/slack-polling-client.js +522 -0
- package/dist/src/packages/server/integrations/slack/slack-routes.js +243 -24
- package/dist/src/packages/server/integrations/slack/slack-trigger-handler.js +53 -20
- package/dist/src/packages/server/integrations/slack/slack-watermark-store.js +124 -0
- package/dist/src/packages/server/integrations/whatsapp/index.js +5 -4
- package/dist/src/packages/server/integrations/whatsapp/whatsapp-client.js +10 -0
- package/dist/src/packages/server/integrations/whatsapp/whatsapp-routes.js +68 -0
- package/dist/src/packages/server/integrations/whatsapp/whatsapp-trigger-handler.js +127 -0
- package/dist/src/packages/server/routes/database.js +221 -0
- package/dist/src/packages/server/routes/files.js +219 -18
- package/dist/src/packages/server/routes/index.js +2 -0
- package/dist/src/packages/server/services/building-service.js +41 -0
- package/dist/src/packages/server/services/database-service.js +61 -9
- package/dist/src/packages/server/services/index.js +1 -0
- package/dist/src/packages/server/services/ssh-tunnel-service.js +255 -0
- package/dist/src/packages/server/websocket/handler.js +2 -1
- package/dist/src/packages/server/websocket/handlers/database-handler.js +35 -0
- package/package.json +3 -1
- package/dist/assets/IntegrationsPanel-CHaNJBJW.js +0 -2
- package/dist/assets/index-BOr_tbLK.js +0 -2
- package/dist/assets/index-Co7njQ0Q.js +0 -8
- package/dist/assets/main-BrZe9Zbd.js +0 -201
- package/dist/assets/main-kpU9m5LW.css +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{bg as ta,u as B,j as e,aL as j,bj as Ms,bk as Fs,aM as Ue,s as D,bl as $s,r as d,D as Z,I as F,a2 as Us,aV as Ve,f as na,bm as la,J as ia,S as oa,h as ra,bn as Ks,aW as He}from"./main-D-YFCprA.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ca=[{value:"",labelKey:"terminal:building.colorDefault"},{value:"#2a2a3a",labelKey:"terminal:building.colorDarkGray"},{value:"#3a2a2a",labelKey:"terminal:building.colorDarkRed"},{value:"#2a3a2a",labelKey:"terminal:building.colorDarkGreen"},{value:"#2a2a4a",labelKey:"terminal:building.colorDarkBlue"},{value:"#3a3a2a",labelKey:"terminal:building.colorDarkYellow"},{value:"#3a2a3a",labelKey:"terminal:building.colorDarkPurple"},{value:"#2a3a3a",labelKey:"terminal:building.colorDarkCyan"},{value:"#4a3a3a",labelKey:"terminal:building.colorWarmBrown"},{value:"#3a4a4a",labelKey:"terminal:building.colorCoolSteel"}];function ma(o){return ta.t(o)}function qe(o){if(o===0)return"0 B";const p=1024,u=["B","KB","MB","GB"],x=Math.floor(Math.log(o)/Math.log(p));return parseFloat((o/Math.pow(p,x)).toFixed(1))+" "+u[x]}function da(o){const u=Date.now()-o,x=Math.floor(u/(1e3*60*60)),n=Math.floor(u%(1e3*60*60)/(1e3*60));return x>0?`${x}h ${n}m`:`${n}m`}const Hs={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function Vs(o){const p=[],u=/\x1B\[([0-9;]*)m/g;let x=0,n=null,y;for(;(y=u.exec(o))!==null;){if(y.index>x){const g=o.slice(x,y.index);n?p.push(e.jsx("span",{style:{color:n},children:g},p.length)):p.push(g)}const C=y[1].split(";").map(Number);for(const g of C)g===0||g===39?n=null:Hs[g]&&(n=Hs[g]);x=u.lastIndex}if(x<o.length){const C=o.slice(x);n?p.push(e.jsx("span",{style:{color:n},children:C},p.length)):p.push(C)}return p.length>0?p:[o]}function ua({buildingName:o,onClose:p,onConfirm:u}){const{t:x}=B(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:p,children:e.jsxs("div",{className:"modal confirm-modal",onClick:n=>n.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:x("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:x("terminal:building.deleteConfirm",{name:o})}),e.jsx("p",{className:"confirm-modal-note",children:x("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:p,children:x("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:u,autoFocus:!0,children:x("common:buttons.delete")})]})]})})}function pa({usePM2:o,setUsePM2:p}){const{t:u}=B(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:o,onChange:x=>p(x.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),u("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:u("terminal:building.pm2Hint")})]})}function ha({usePM2:o,pm2Script:p,setPm2Script:u,pm2Args:x,setPm2Args:n,pm2Interpreter:y,setPm2Interpreter:C,pm2InterpreterArgs:g,setPm2InterpreterArgs:v,pm2Env:s,setPm2Env:h,isEditMode:a,building:t,handleCommand:r}){var N;const{t:i}=B(["terminal","common"]);return o?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:i("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Script"),e.jsx(j,{text:i("terminal:building.helpPm2Script"),title:i("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:p,onChange:b=>u(b.target.value),placeholder:"npm, java, python, ./app.js",required:o})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Arguments"),e.jsx(j,{text:i("terminal:building.helpPm2Arguments"),title:i("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:b=>n(b.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Interpreter"),e.jsx(j,{text:i("terminal:building.helpPm2Interpreter"),title:i("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:y,onChange:b=>C(b.target.value),children:Object.keys(Ms).map(b=>e.jsx("option",{value:b,children:Ms[b].label},b))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2InterpArgs"),e.jsx(j,{text:i("terminal:building.helpPm2InterpArgs"),title:i("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:b=>v(b.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Environment"),e.jsx(j,{text:i("terminal:building.helpPm2Environment"),title:i("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:b=>h(b.target.value),placeholder:`KEY=value
|
|
2
|
+
SERVER_PORT=7201
|
|
3
|
+
NODE_ENV=production`,rows:3})]}),e.jsx("div",{className:"pm2-examples",children:e.jsxs("details",{children:[e.jsx("summary",{children:i("terminal:building.pm2Examples")}),e.jsxs("div",{className:"pm2-examples-content",children:[e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Node.js:"})," Script: ",e.jsx("code",{children:"npm"}),", Args: ",e.jsx("code",{children:"run dev"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Symfony:"})," Script: ",e.jsx("code",{children:"symfony"}),", Args: ",e.jsx("code",{children:"serve --no-daemon"}),", Interpreter: ",e.jsx("code",{children:"None"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Java JAR:"})," Script: ",e.jsx("code",{children:"app.jar"}),", Interpreter: ",e.jsx("code",{children:"Java"}),", Interp. Args: ",e.jsx("code",{children:"-jar"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Python:"})," Script: ",e.jsx("code",{children:"app.py"}),", Interpreter: ",e.jsx("code",{children:"Python 3"})]})]})]})}),a&&(t==null?void 0:t.pm2Status)&&e.jsx("div",{className:"pm2-status-display",children:e.jsxs("div",{className:"pm2-status-row",children:[e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"PID"}),e.jsx("span",{className:"pm2-metric-value",children:t.pm2Status.pid||"-"})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"CPU"}),e.jsxs("span",{className:"pm2-metric-value",children:[((N=t.pm2Status.cpu)==null?void 0:N.toFixed(1))||"0","%"]})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"MEM"}),e.jsx("span",{className:"pm2-metric-value",children:qe(t.pm2Status.memory||0)})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Restarts"}),e.jsx("span",{className:"pm2-metric-value",children:t.pm2Status.restarts||0})]}),t.pm2Status.uptime&&e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Uptime"}),e.jsx("span",{className:"pm2-metric-value",children:da(t.pm2Status.uptime)})]})]})}),a&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>r("start"),children:i("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>r("stop"),children:i("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>r("restart"),children:i("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>r("logs"),children:i("terminal:logs.title")})]})]}):null}function xa({dockerMode:o,setDockerMode:p,dockerImage:u,setDockerImage:x,dockerContainerName:n,setDockerContainerName:y,dockerCommand:C,setDockerCommand:g,dockerPorts:v,setDockerPorts:s,dockerVolumes:h,setDockerVolumes:a,dockerNetwork:t,setDockerNetwork:r,dockerRestart:i,setDockerRestart:N,dockerPull:b,setDockerPull:L,dockerEnv:T,setDockerEnv:A,dockerComposePath:$,setDockerComposePath:R,dockerComposeProject:K,setDockerComposeProject:I,dockerComposeServices:H,setDockerComposeServices:O,selectedExistingContainer:c,setSelectedExistingContainer:E,dockerContainersList:V,isEditMode:q,building:k,handleCommand:_}){const{t:M}=B(["config","common"]);return e.jsxs("div",{className:"form-section docker-config-section",children:[e.jsx("label",{className:"form-label",children:M("config:buildings.dockerConfig")}),e.jsxs("div",{className:"docker-mode-selector",children:[e.jsxs("label",{className:`docker-mode-option ${o==="container"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"container",checked:o==="container",onChange:()=>p("container")}),e.jsx("span",{className:"docker-mode-icon",children:"📦"}),e.jsx("span",{className:"docker-mode-label",children:"Container"}),e.jsx("span",{className:"docker-mode-desc",children:"Create a new container"})]}),e.jsxs("label",{className:`docker-mode-option ${o==="compose"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"compose",checked:o==="compose",onChange:()=>p("compose")}),e.jsx("span",{className:"docker-mode-icon",children:"🛠"}),e.jsx("span",{className:"docker-mode-label",children:"Compose"}),e.jsx("span",{className:"docker-mode-desc",children:"Manage multiple services"})]}),e.jsxs("label",{className:`docker-mode-option ${o==="existing"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"existing",checked:o==="existing",onChange:()=>p("existing")}),e.jsx("span",{className:"docker-mode-icon",children:"🔎"}),e.jsx("span",{className:"docker-mode-label",children:"Existing"}),e.jsx("span",{className:"docker-mode-desc",children:"Adopt existing container"})]})]}),o==="container"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Image:",e.jsx(j,{text:"Docker image to run, e.g., nginx:latest, redis:alpine, my-app:v1",title:"Image",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:u,onChange:l=>x(l.target.value),placeholder:"nginx:latest",required:!0})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Container Name:",e.jsx(j,{text:"Custom name for the container. If empty, auto-generated based on building name.",title:"Container Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:n,onChange:l=>y(l.target.value),placeholder:"Auto-generated (tc-{name}-{id})"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Command:",e.jsx(j,{text:"Override the default container command. Leave empty to use image's CMD.",title:"Command Override",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:C,onChange:l=>g(l.target.value),placeholder:"Optional command override"})]}),e.jsxs("div",{className:"form-section docker-ports-section",children:[e.jsxs("label",{className:"form-label",children:["Port Mappings",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>s([...v,""]),children:"+ Add"})]}),v.map((l,S)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:l,onChange:U=>{const z=[...v];z[S]=U.target.value,s(z)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(v.filter((U,z)=>z!==S)),children:"x"})]},S)),v.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host:container (e.g., 8080:80) or same port (e.g., 3000)"})]}),e.jsxs("div",{className:"form-section docker-volumes-section",children:[e.jsxs("label",{className:"form-label",children:["Volume Mounts",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>a([...h,""]),children:"+ Add"})]}),h.map((l,S)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:l,onChange:U=>{const z=[...h];z[S]=U.target.value,a(z)},placeholder:"./data:/app/data or /host/path:/container/path"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>a(h.filter((U,z)=>z!==S)),children:"x"})]},S)),h.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host_path:container_path (relative paths resolved from working directory)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Network:",e.jsx(j,{text:"Docker network to connect to. Leave empty for default bridge network.",title:"Network",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:l=>r(l.target.value),placeholder:"bridge (default)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Restart Policy:",e.jsx(j,{text:"When should Docker restart the container automatically?",title:"Restart Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:i,onChange:l=>N(l.target.value),children:Object.keys(Fs).map(l=>e.jsx("option",{value:l,children:Fs[l].label},l))})]})]}),o==="compose"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Compose File:",e.jsx(j,{text:"Path to docker-compose.yml file, relative to working directory.",title:"Compose File",position:"top",size:"sm"})]}),e.jsx(Ue,{value:$,onChange:R,placeholder:"docker-compose.yml",className:"form-input",directoriesOnly:!1})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Project Name:",e.jsx(j,{text:"Override the compose project name. Leave empty for auto-generated name.",title:"Project Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:K,onChange:l=>I(l.target.value),placeholder:"Auto-generated"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Services:",e.jsx(j,{text:"Specific services to manage (comma-separated). Leave empty for all services.",title:"Services",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:H,onChange:l=>O(l.target.value),placeholder:"All services (or: api, db, redis)"})]})]}),o==="existing"&&e.jsxs("div",{className:"docker-existing-section",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Select Container:",e.jsx(j,{text:"Choose an existing Docker container to monitor and control. The container will not be deleted when removing the building.",title:"Existing Container",position:"top",size:"sm"})]}),e.jsxs("div",{className:"docker-existing-select-wrapper",children:[e.jsxs("select",{className:"form-input form-select",value:c,onChange:l=>E(l.target.value),required:o==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),V.map(l=>e.jsxs("option",{value:l.name,children:[l.name," (",l.image,") - ",l.state]},l.id))]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>D.requestDockerContainersList(),title:"Refresh container list",children:"↻"})]})]}),V.length===0&&e.jsx("div",{className:"form-hint docker-existing-hint",children:"No containers found. Make sure Docker is running and you have containers available."}),c&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const l=V.find(S=>S.name===c);return l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Image:"}),e.jsx("span",{className:"docker-existing-info-value",children:l.image})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Status:"}),e.jsx("span",{className:`docker-existing-info-value docker-status-${l.status}`,children:l.state})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"ID:"}),e.jsx("span",{className:"docker-existing-info-value",children:l.id.slice(0,12)})]}),l.ports.length>0&&e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Ports:"}),e.jsx("span",{className:"docker-existing-info-value",children:l.ports.map(S=>`${S.host}:${S.container}/${S.protocol}`).join(", ")})]})]}):null})()}),e.jsx("div",{className:"form-hint",children:"Note: Existing containers will not be deleted when you remove this building."})]}),o!=="existing"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Pull Policy:",e.jsx(j,{text:"When to pull images: always, only if missing, or never.",title:"Pull Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:b,onChange:l=>L(l.target.value),children:Object.keys($s).map(l=>e.jsx("option",{value:l,children:$s[l].label},l))})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:["Environment:",e.jsx(j,{text:"Environment variables in KEY=value format, one per line.",title:"Environment Variables",position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:T,onChange:l=>A(l.target.value),placeholder:`KEY=value
|
|
4
|
+
DATABASE_URL=postgres://...
|
|
5
|
+
NODE_ENV=production`,rows:3})]})]}),q&&(k==null?void 0:k.dockerStatus)&&e.jsxs("div",{className:"docker-status-display",children:[e.jsxs("div",{className:"docker-status-row",children:[e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"ID"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.containerId||"-"})]}),e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Status"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.status||"-"})]}),k.dockerStatus.health&&k.dockerStatus.health!=="none"&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Health"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.health})]}),k.dockerStatus.cpu!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"CPU"}),e.jsxs("span",{className:"docker-metric-value",children:[k.dockerStatus.cpu.toFixed(1),"%"]})]}),k.dockerStatus.memory!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"MEM"}),e.jsxs("span",{className:"docker-metric-value",children:[qe(k.dockerStatus.memory),k.dockerStatus.memoryLimit?` / ${qe(k.dockerStatus.memoryLimit)}`:""]})]})]}),k.dockerStatus.ports&&k.dockerStatus.ports.length>0&&e.jsxs("div",{className:"docker-ports-row",children:[e.jsx("span",{className:"docker-metric-label",children:"Ports:"}),k.dockerStatus.ports.map((l,S)=>e.jsxs("a",{href:`http://${window.location.hostname}:${l.host}`,target:"_blank",rel:"noopener noreferrer",className:"docker-port-link",children:[l.host,":",l.container,"/",l.protocol]},S))]}),k.dockerStatus.services&&k.dockerStatus.services.length>0&&e.jsxs("div",{className:"docker-services-status",children:[e.jsx("span",{className:"docker-metric-label",children:"Services:"}),e.jsx("div",{className:"docker-services-grid",children:k.dockerStatus.services.map((l,S)=>e.jsxs("div",{className:"docker-service-item",children:[e.jsx("span",{className:"docker-service-indicator",style:{backgroundColor:l.status==="running"?"#4ade80":"#f87171"}}),e.jsx("span",{className:"docker-service-name",children:l.name}),e.jsx("span",{className:"docker-service-status",children:l.status})]},S))})]})]}),q&&e.jsxs("div",{className:"docker-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>_("start"),children:"Start"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>_("stop"),children:"Stop"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>_("restart"),children:"Restart"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>_("logs"),children:"Logs"})]})]})}const ba={enabled:!1,host:"",port:22,username:"",authMethod:"password"};function ja({dbConnections:o,setDbConnections:p,activeDbConnectionId:u,setActiveDbConnectionId:x}){const{t:n}=B(["terminal","common"]),[y,C]=d.useState({}),g=d.useRef(new Map);d.useEffect(()=>{const a=t=>{const r=t.detail;if(!r||!r.requestId)return;const i=g.current.get(r.requestId);i&&(g.current.delete(r.requestId),C(N=>({...N,[i]:r.success?{status:"success",serverVersion:r.serverVersion}:{status:"error",error:r.error||"Connection failed"}})))};return window.addEventListener("tide:db-test-result",a),()=>window.removeEventListener("tide:db-test-result",a)},[]);const v=(a,t)=>{const r=[...o];r[a]={...r[a],...t},p(r)},s=(a,t)=>{const i={...o[a].ssh??ba,...t};v(a,{ssh:i})},h=a=>{const t=`test_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;g.current.set(t,a.id),C(r=>({...r,[a.id]:{status:"testing"}})),D.testDatabaseConnectionTransient(t,a),window.setTimeout(()=>{g.current.has(t)&&(g.current.delete(t),C(r=>{const i=r[a.id];return(i==null?void 0:i.status)!=="testing"?r:{...r,[a.id]:{status:"error",error:"Test connection timed out after 30s"}}}))},3e4)};return e.jsxs("div",{className:"form-section database-config-section",children:[e.jsxs("label",{className:"form-label",children:[n("terminal:building.dbConnections"),e.jsx(j,{text:n("terminal:building.helpDbConnections"),title:n("terminal:building.dbConnections"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>{const a={id:`conn_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,name:`Connection ${o.length+1}`,engine:"mysql",host:"localhost",port:3306,username:"root"};p([...o,a]),u||x(a.id)},children:n("terminal:database.addConnection")})]}),o.length===0&&e.jsx("div",{className:"form-hint",children:n("terminal:building.dbGetStarted")}),o.map((a,t)=>{var N,b,L,T,A,$,R,K,I,H,O;const r=y[a.id]??{status:"idle"},i=((N=a.ssh)==null?void 0:N.enabled)===!0;return e.jsxs("div",{className:"db-connection-card",children:[e.jsxs("div",{className:"db-connection-header",children:[e.jsxs("label",{className:"db-connection-active",children:[e.jsx("input",{type:"radio",name:"activeConnection",checked:u===a.id,onChange:()=>x(a.id)}),n("common:labels.default"),e.jsx(j,{text:n("terminal:building.helpDbDefault"),position:"top",size:"sm"})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>{const c=o.filter(E=>E.id!==a.id);p(c),u===a.id&&c.length>0?x(c[0].id):c.length===0&&x(void 0)},children:n("common:buttons.remove")})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:n("common:labels.name")}),e.jsx("input",{type:"text",className:"form-input",value:a.name,onChange:c=>v(t,{name:c.target.value}),placeholder:"My Database"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:n("terminal:building.dbEngine")}),e.jsx("select",{className:"form-input form-select",value:a.engine,onChange:c=>{const E=c.target.value;v(t,{engine:E,port:Z[E].defaultPort})},children:Object.keys(Z).map(c=>e.jsxs("option",{value:c,children:[Z[c].icon," ",Z[c].label]},c))})]})]}),a.engine==="sqlite"?e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:n("terminal:building.dbFilepath")}),e.jsx("input",{type:"text",className:"form-input",value:a.filepath||"",onChange:c=>v(t,{filepath:c.target.value||void 0}),placeholder:"/path/to/database.db"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsxs("label",{children:[n("terminal:building.dbHost"),i&&e.jsx(j,{text:"Host as seen FROM the SSH server (often 'localhost' or 127.0.0.1).",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:a.host,onChange:c=>v(t,{host:c.target.value}),placeholder:i?"127.0.0.1":"localhost"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:n("terminal:building.dbPort")}),e.jsx("input",{type:"number",className:"form-input",value:a.port,onChange:c=>v(t,{port:parseInt(c.target.value)||Z[a.engine].defaultPort})})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:n("terminal:building.dbUsername")}),e.jsx("input",{type:"text",className:"form-input",value:a.username,onChange:c=>v(t,{username:c.target.value}),placeholder:"root"})]}),e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:n("terminal:building.dbPassword")}),e.jsx("input",{type:"password",className:"form-input",value:a.password||"",onChange:c=>v(t,{password:c.target.value||void 0}),placeholder:"Optional",autoComplete:"off"})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:n("terminal:building.dbDefaultDatabase")}),e.jsx("input",{type:"text",className:"form-input",value:a.database||"",onChange:c=>v(t,{database:c.target.value||void 0}),placeholder:"Optional - select after connecting"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsxs("label",{children:["SSL",e.jsx(j,{text:n("terminal:building.helpDbSsl"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"toggle-switch toggle-switch--small",children:[e.jsx("input",{type:"checkbox",checked:a.ssl||!1,onChange:c=>v(t,{ssl:c.target.checked})}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})})]})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsx("div",{className:"db-field db-field--grow",children:e.jsxs("label",{children:["SSH Tunnel",e.jsx(j,{text:"Forward DB traffic through an SSH jump host. Required when the DB is only reachable from inside a private network.",position:"top",size:"sm"})]})}),e.jsx("div",{className:"db-field db-field--small",children:e.jsxs("label",{className:"toggle-switch toggle-switch--small",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:c=>s(t,{enabled:c.target.checked})}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})})]})})]}),i&&e.jsxs("div",{className:"db-ssh-subsection",children:[e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:"SSH Host"}),e.jsx("input",{type:"text",className:"form-input",value:((b=a.ssh)==null?void 0:b.host)||"",onChange:c=>s(t,{host:c.target.value}),placeholder:"bastion.example.com"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:"SSH Port"}),e.jsx("input",{type:"number",className:"form-input",value:((L=a.ssh)==null?void 0:L.port)||22,onChange:c=>s(t,{port:parseInt(c.target.value)||22})})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:"SSH Username"}),e.jsx("input",{type:"text",className:"form-input",value:((T=a.ssh)==null?void 0:T.username)||"",onChange:c=>s(t,{username:c.target.value}),placeholder:"ubuntu"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:"Auth Method"}),e.jsxs("select",{className:"form-input form-select",value:((A=a.ssh)==null?void 0:A.authMethod)||"password",onChange:c=>s(t,{authMethod:c.target.value}),children:[e.jsx("option",{value:"password",children:"Password"}),e.jsx("option",{value:"privateKey",children:"Private Key"})]})]})]}),((($=a.ssh)==null?void 0:$.authMethod)||"password")==="password"?e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:"SSH Password"}),e.jsx("input",{type:"password",className:"form-input",value:((R=a.ssh)==null?void 0:R.password)||"",onChange:c=>s(t,{password:c.target.value||void 0}),placeholder:"SSH password",autoComplete:"off"})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsxs("label",{children:["Private Key Path",e.jsx(j,{text:"Path to a private key file on the server, e.g. ~/.ssh/id_rsa. Use this OR paste the key contents below.",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:((K=a.ssh)==null?void 0:K.privateKeyPath)||"",onChange:c=>s(t,{privateKeyPath:c.target.value||void 0}),placeholder:"/home/user/.ssh/id_rsa"})]})}),e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsxs("label",{children:["Private Key Contents (PEM)",e.jsx(j,{text:"Paste the full private key contents inline. Encrypted at rest.",position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input",value:((I=a.ssh)==null?void 0:I.privateKey)||"",onChange:c=>s(t,{privateKey:c.target.value||void 0}),placeholder:"-----BEGIN OPENSSH PRIVATE KEY-----\\n...",rows:4,style:{fontFamily:"monospace",fontSize:12}})]})}),e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:"Key Passphrase (optional)"}),e.jsx("input",{type:"password",className:"form-input",value:((H=a.ssh)==null?void 0:H.passphrase)||"",onChange:c=>s(t,{passphrase:c.target.value||void 0}),placeholder:"If your key is encrypted",autoComplete:"off"})]})})]}),e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--small",children:[e.jsxs("label",{children:["Local Port",e.jsx(j,{text:"Optional fixed local forwarded port. Leave blank to auto-assign.",position:"top",size:"sm"})]}),e.jsx("input",{type:"number",className:"form-input",value:((O=a.ssh)==null?void 0:O.localPort)??"",onChange:c=>{const E=c.target.value.trim();s(t,{localPort:E?parseInt(E):void 0})},placeholder:"auto"})]})})]}),e.jsxs("div",{className:"db-connection-row",style:{alignItems:"center",gap:8},children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-primary",disabled:r.status==="testing",onClick:()=>h(a),children:r.status==="testing"?"Testing…":"Test Connection"}),r.status==="success"&&e.jsxs("span",{style:{color:"#4aff9e",fontSize:12},children:["✓ Connected",r.serverVersion?` — ${r.serverVersion}`:""]}),r.status==="error"&&e.jsxs("span",{style:{color:"#ff6b6b",fontSize:12},title:r.error,children:["✗ ",r.error]})]})]})]},a.id)}),o.length>0&&e.jsx("div",{className:"form-hint",children:n("terminal:building.dbAfterSaving")})]})}function ga({buildings:o,buildingId:p,subordinateBuildingIds:u,setSubordinateBuildingIds:x,isEditMode:n,showBossLogs:y,setShowBossLogs:C,currentBossLogs:g,bossLogsContainerRef:v}){const{t:s}=B(["terminal","common"]);return e.jsxs("div",{className:"form-section boss-building-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.managedBuildings"),e.jsx(j,{text:s("terminal:building.helpManagedBuildings"),title:s("terminal:building.managedBuildings"),position:"top",size:"sm"})]}),e.jsx("div",{className:"form-hint",children:s("terminal:building.managedBuildingsHint")}),e.jsxs("div",{className:"subordinate-buildings-list",children:[Array.from(o.values()).filter(h=>h.id!==p&&h.type!=="boss"&&h.type!=="link"&&h.type!=="folder").map(h=>e.jsxs("label",{className:"subordinate-building-item",children:[e.jsx("input",{type:"checkbox",checked:u.includes(h.id),onChange:a=>{a.target.checked?x([...u,h.id]):x(u.filter(t=>t!==h.id))}}),e.jsx("span",{className:"subordinate-building-icon",children:e.jsx(F,{name:Us(h.type),size:14})}),e.jsx("span",{className:"subordinate-building-name",children:h.name}),e.jsx("span",{className:"subordinate-building-status",style:{backgroundColor:Ve[h.status]}})]},h.id)),Array.from(o.values()).filter(h=>h.id!==p&&h.type!=="boss"&&h.type!=="link"&&h.type!=="folder").length===0&&e.jsx("div",{className:"form-hint no-buildings-hint",children:s("terminal:building.noManageableBuildings")})]}),n&&u.length>0&&e.jsxs("div",{className:"boss-building-actions",children:[e.jsxs("div",{className:"boss-actions-header",children:[s("terminal:building.bulkActions"),e.jsx(j,{text:s("terminal:building.helpBulkActions"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"boss-actions-row",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>D.sendBossBuildingCommand(p,"start_all"),children:s("terminal:building.startAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>D.sendBossBuildingCommand(p,"stop_all"),children:s("terminal:building.stopAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>D.sendBossBuildingCommand(p,"restart_all"),children:s("terminal:building.restartAll")}),e.jsx("button",{type:"button",className:`btn btn-sm ${y?"btn-primary":""}`,onClick:()=>{y?(D.stopBossLogStreaming(p),C(!1)):(D.startBossLogStreaming(p),C(!0))},children:s(y?"terminal:building.hideLogs":"terminal:building.unifiedLogs")})]}),e.jsxs("div",{className:"boss-subordinates-status",children:[e.jsx("div",{className:"boss-status-header",children:s("terminal:building.statusOverview")}),e.jsx("div",{className:"boss-status-grid",children:u.map(h=>{const a=o.get(h);return a?e.jsxs("div",{className:"boss-status-item",children:[e.jsx("span",{className:"boss-status-indicator",style:{backgroundColor:Ve[a.status]}}),e.jsx("span",{className:"boss-status-name",children:a.name}),e.jsx("span",{className:"boss-status-label",children:a.status})]},h):null})})]})]}),n&&y&&e.jsxs("div",{className:"form-section boss-logs-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.unifiedLogs"),e.jsx(j,{text:s("terminal:building.helpUnifiedLogs"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>D.clearBossStreamingLogs(p),children:s("common:buttons.clear")})]}),e.jsxs("div",{className:"boss-logs-container",ref:v,children:[g.map((h,a)=>e.jsxs("div",{className:"boss-log-entry",children:[e.jsxs("span",{className:"boss-log-source",children:["[",h.subordinateName,"]"]}),e.jsx("span",{className:"boss-log-content",children:Vs(h.chunk)})]},a)),g.length===0&&e.jsx("div",{className:"boss-logs-empty",children:s("terminal:building.waitingForLogs")})]})]})]})}function va({startCmd:o,setStartCmd:p,stopCmd:u,setStopCmd:x,restartCmd:n,setRestartCmd:y,healthCheckCmd:C,setHealthCheckCmd:g,logsCmd:v,setLogsCmd:s,isEditMode:h,handleCommand:a}){const{t}=B(["terminal","common"]);return e.jsxs("div",{className:"form-section commands-section",children:[e.jsxs("label",{className:"form-label",children:[t("terminal:building.commands"),e.jsx(j,{text:t("terminal:building.helpCommands"),title:t("terminal:building.commands"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"command-inputs",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[t("terminal:building.cmdStart"),e.jsx(j,{text:t("terminal:building.helpCmdStart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:o,onChange:r=>p(r.target.value),placeholder:"npm run dev"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>a("start"),disabled:!o,children:t("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[t("terminal:building.cmdStop"),e.jsx(j,{text:t("terminal:building.helpCmdStop"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:u,onChange:r=>x(r.target.value),placeholder:"pkill -f 'npm run dev'"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>a("stop"),disabled:!u,children:t("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[t("terminal:building.cmdRestart"),e.jsx(j,{text:t("terminal:building.helpCmdRestart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:n,onChange:r=>y(r.target.value),placeholder:"npm run restart"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>a("restart"),disabled:!n,children:t("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[t("terminal:building.cmdHealthCheck"),e.jsx(j,{text:t("terminal:building.helpCmdHealthCheck"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:C,onChange:r=>g(r.target.value),placeholder:"curl -s http://localhost:3000/health"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>a("healthCheck"),disabled:!C,children:t("terminal:building.check")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[t("terminal:building.cmdLogs"),e.jsx(j,{text:t("terminal:building.helpCmdLogs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:v,onChange:r=>s(r.target.value),placeholder:"tail -n 100 /var/log/app.log"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>a("logs"),children:t("terminal:building.fetch")})]})]})]})}const Na=[{value:"",label:"Default ($SHELL)"},{value:"/bin/bash",label:"Bash"},{value:"/bin/zsh",label:"Zsh"},{value:"/usr/bin/fish",label:"Fish"},{value:"/bin/sh",label:"sh"}];function fa({terminalShell:o,setTerminalShell:p,terminalPort:u,setTerminalPort:x,terminalSaveSession:n,setTerminalSaveSession:y,terminalArgs:C,setTerminalArgs:g,isEditMode:v,building:s,handleCommand:h,onOpenTerminal:a,onOpenBelow:t}){const{t:r}=B(["config"]),i=(s==null?void 0:s.status)==="running",N=s==null?void 0:s.terminalStatus;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:r("config:buildings.terminalConfig",{defaultValue:"Terminal Configuration"})}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:r("config:buildings.terminalShell",{defaultValue:"Shell"})}),e.jsx("select",{className:"form-input",value:o,onChange:b=>p(b.target.value),children:Na.map(b=>e.jsx("option",{value:b.value,children:b.label},b.value))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:r("config:buildings.terminalPort",{defaultValue:"Port"})}),e.jsx("input",{type:"number",className:"form-input",value:u,onChange:b=>x(b.target.value),placeholder:"Auto",min:1024,max:65535})]})]}),e.jsx("div",{className:"form-row",style:{marginTop:"8px"},children:e.jsxs("label",{className:"form-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:b=>y(b.target.checked)}),e.jsx("span",{children:r("config:buildings.terminalSaveSession",{defaultValue:"Persist session (tmux)"})})]})}),e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("label",{className:"form-sublabel",children:r("config:buildings.terminalArgs",{defaultValue:"Extra ttyd args"})}),e.jsx("input",{type:"text",className:"form-input",value:C,onChange:b=>g(b.target.value),placeholder:"--client-option titleFixed=Terminal"}),e.jsx("div",{className:"form-hint",children:"Additional command-line arguments passed to ttyd"})]})]}),v&&s&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:r("config:buildings.terminalControls",{defaultValue:"Terminal Controls"})}),N&&e.jsxs("div",{className:"building-runtime-info",children:[e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Proxy"}),e.jsx("span",{className:"runtime-value",style:{color:"#4a9eff"},children:N.url})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"PID"}),e.jsx("span",{className:"runtime-value",children:N.pid})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Port"}),e.jsx("span",{className:"runtime-value",children:N.port})]}),N.tmuxSession&&e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Session"}),e.jsx("span",{className:"runtime-value",children:N.tmuxSession})]})]}),e.jsxs("div",{className:"building-actions",style:{marginTop:"8px"},children:[!i&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>h("start"),children:[e.jsx(F,{name:"play",size:12})," Start"]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>h("restart"),children:[e.jsx(F,{name:"refresh",size:12})," Restart"]}),e.jsxs("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>h("stop"),children:[e.jsx(F,{name:"stop",size:12})," Stop"]}),(N==null?void 0:N.url)&&e.jsxs(e.Fragment,{children:[a&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>a(N.url),children:[e.jsx(F,{name:"desktop",size:12})," Modal"]}),t&&s&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>t(s.id),children:[e.jsx(F,{name:"arrow-down",size:12})," Below"]})]})]})]})]})]})}function ka({logs:o,buildingId:p,logsContainerRef:u}){return e.jsxs("div",{className:"form-section logs-section",children:[e.jsxs("label",{className:"form-label",children:["Logs",e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>D.clearBuildingLogs(p),children:"Clear"})]}),e.jsx("div",{className:"logs-container",ref:u,children:o.map((x,n)=>e.jsx("pre",{className:"log-entry",children:Vs(x)},n))})]})}function wa({isOpen:o,onClose:p,buildingId:u,initialPosition:x}){const{t:n}=B(["config","common"]),{buildings:y,buildingLogs:C,bossStreamingLogs:g}=na(),v=la(),s=u?y.get(u):null,h=u?g.get(u)||[]:[],a=!!s,[t,r]=d.useState(""),[i,N]=d.useState("server"),[b,L]=d.useState("server-rack"),[T,A]=d.useState(""),[$,R]=d.useState(""),[K,I]=d.useState(""),[H,O]=d.useState(""),[c,E]=d.useState(""),[V,q]=d.useState(""),[k,_]=d.useState(""),[M,l]=d.useState([]),[S,U]=d.useState(!1),[z,se]=d.useState(""),[J,Q]=d.useState(1),[W,ae]=d.useState(!1),[Ge,te]=d.useState(""),[Ye,ne]=d.useState(""),[Je,le]=d.useState(""),[We,ie]=d.useState(""),[Ze,oe]=d.useState(""),[qs,re]=d.useState(!1),[P,ce]=d.useState("container"),[me,de]=d.useState(""),[Qe,ue]=d.useState(""),[pe,he]=d.useState(""),[xe,be]=d.useState([]),[je,ge]=d.useState([]),[Xe,ve]=d.useState(""),[Ne,fe]=d.useState(""),[ke,ye]=d.useState(""),[es,Ce]=d.useState("unless-stopped"),[ss,Se]=d.useState("missing"),[we,Pe]=d.useState(""),[De,Ee]=d.useState(""),[ze,Le]=d.useState(""),[Ae,Be]=d.useState([]),[Gs,Ys]=d.useState(!1),[Te,Re]=d.useState([]),[as,Ie]=d.useState(void 0),[ts,Oe]=d.useState(""),[_e,Me]=d.useState(""),[ns,Fe]=d.useState(!1),[ls,$e]=d.useState(""),is=d.useRef(null),Js=d.useRef(null),X=d.useRef(null);d.useEffect(()=>{var m,f,w,G,ms,ds,us,ps,hs,xs,bs,js,gs,vs,Ns,fs,ks,ys,Cs,Ss,ws,Ps,Ds,Es,zs,Ls,As,Bs,Ts,Rs,Is,Os,_s;o&&(s?(r(s.name),N(s.type),L(s.style||"server-rack"),A(s.color||""),R(s.cwd||""),I(((m=s.commands)==null?void 0:m.start)||""),O(((f=s.commands)==null?void 0:f.stop)||""),E(((w=s.commands)==null?void 0:w.restart)||""),q(((G=s.commands)==null?void 0:G.healthCheck)||""),_(((ms=s.commands)==null?void 0:ms.logs)||""),l(s.urls||[]),se(s.folderPath||""),Q(s.scale||1),ae(((ds=s.pm2)==null?void 0:ds.enabled)||!1),te(((us=s.pm2)==null?void 0:us.script)||""),ne(((ps=s.pm2)==null?void 0:ps.args)||""),le(((hs=s.pm2)==null?void 0:hs.interpreter)||""),ie(((xs=s.pm2)==null?void 0:xs.interpreterArgs)||""),oe((bs=s.pm2)!=null&&bs.env?Object.entries(s.pm2.env).map(([Y,Ke])=>`${Y}=${Ke}`).join(`
|
|
6
|
+
`):""),ce(((js=s.docker)==null?void 0:js.mode)||"container"),de(((gs=s.docker)==null?void 0:gs.mode)==="existing"&&((vs=s.docker)==null?void 0:vs.containerName)||""),ue(((Ns=s.docker)==null?void 0:Ns.image)||""),he(((fs=s.docker)==null?void 0:fs.containerName)||""),be(((ks=s.docker)==null?void 0:ks.ports)||[]),ge(((ys=s.docker)==null?void 0:ys.volumes)||[]),ve((Cs=s.docker)!=null&&Cs.env?Object.entries(s.docker.env).map(([Y,Ke])=>`${Y}=${Ke}`).join(`
|
|
7
|
+
`):""),fe(((Ss=s.docker)==null?void 0:Ss.network)||""),ye(((ws=s.docker)==null?void 0:ws.command)||""),Ce(((Ps=s.docker)==null?void 0:Ps.restart)||"unless-stopped"),Se(((Ds=s.docker)==null?void 0:Ds.pull)||"missing"),Pe(((Es=s.docker)==null?void 0:Es.composePath)||""),Ee(((zs=s.docker)==null?void 0:zs.composeProject)||""),Le(((As=(Ls=s.docker)==null?void 0:Ls.services)==null?void 0:As.join(", "))||""),Be(s.subordinateBuildingIds||[]),Re(((Bs=s.database)==null?void 0:Bs.connections)||[]),Ie((Ts=s.database)==null?void 0:Ts.activeConnectionId),Oe(((Rs=s.terminal)==null?void 0:Rs.shell)||""),Me((Is=s.terminal)!=null&&Is.port?String(s.terminal.port):""),Fe(((Os=s.terminal)==null?void 0:Os.saveSession)||!1),$e(((_s=s.terminal)==null?void 0:_s.args)||"")):(r("New Server"),N("server"),L("server-rack"),A(""),R(ia(oa.LAST_CWD)),I(""),O(""),E(""),q(""),_(""),l([]),se(""),Q(1),ae(!1),te(""),ne(""),le(""),ie(""),oe(""),ce("container"),de(""),ue(""),he(""),be([]),ge([]),ve(""),fe(""),ye(""),Ce("unless-stopped"),Se("missing"),Pe(""),Ee(""),Le(""),Be([]),Re([]),Ie(void 0),Oe(""),Me(""),Fe(!1),$e("")),setTimeout(()=>{var Y;return(Y=is.current)==null?void 0:Y.focus()},100))},[o,s]),d.useEffect(()=>{X.current&&(X.current.scrollTop=X.current.scrollHeight)},[C]),d.useEffect(()=>{i==="docker"&&P==="existing"&&D.requestDockerContainersList()},[i,P]);const os=m=>{if(m.trim())return Object.fromEntries(m.trim().split(`
|
|
8
|
+
`).map(f=>f.trim()).filter(f=>f&&f.includes("=")).map(f=>{const w=f.indexOf("=");return[f.slice(0,w),f.slice(w+1)]}))},Ws=m=>{m.preventDefault();const f={name:t,type:i,style:b,color:T||void 0,position:x||(s==null?void 0:s.position)||{x:0,z:0},cwd:$||void 0,folderPath:z||void 0,commands:W?void 0:{start:K||void 0,stop:H||void 0,restart:c||void 0,healthCheck:V||void 0,logs:k||void 0},pm2:W?{enabled:!0,script:Ge,args:Ye||void 0,interpreter:Je||void 0,interpreterArgs:We||void 0,env:os(Ze)}:void 0,docker:i==="docker"?{enabled:!0,mode:P,image:P==="container"?Qe:void 0,containerName:P==="container"&&pe?pe:P==="existing"&&me?me:void 0,ports:P==="container"&&xe.length>0?xe:void 0,volumes:P==="container"&&je.length>0?je:void 0,env:os(Xe),network:P==="container"&&Ne?Ne:void 0,command:P==="container"&&ke?ke:void 0,restart:P==="container"?es:void 0,pull:P!=="existing"?ss:void 0,composePath:P==="compose"&&we?we:void 0,composeProject:P==="compose"&&De?De:void 0,services:P==="compose"&&ze?ze.split(",").map(w=>w.trim()).filter(w=>w):void 0}:void 0,urls:M.length>0?M:void 0,scale:J!==1?J:void 0,subordinateBuildingIds:i==="boss"&&Ae.length>0?Ae:void 0,database:i==="database"&&Te.length>0?{connections:Te,activeConnectionId:as}:void 0,terminal:i==="terminal"?{enabled:!0,shell:ts||void 0,port:_e?parseInt(_e,10):void 0,saveSession:ns||void 0,args:ls||void 0}:void 0};a&&u?D.updateBuilding(u,f):D.createBuilding(f),p()},Zs=()=>{re(!0)},Qs=()=>{u&&(D.deleteBuilding(u),re(!1),p())},ee=m=>{u&&(D.sendBuildingCommand(u,m),m==="logs"&&U(!0))},Xs=()=>{l([...M,{label:"",url:""}])},ea=m=>{l(M.filter((f,w)=>w!==m))},rs=(m,f,w)=>{const G=[...M];G[m]={...G[m],[f]:w},l(G)},{handleMouseDown:sa,handleClick:aa}=ra(p);if(!o)return null;const cs=u?D.getBuildingLogs(u):[];return e.jsxs("div",{className:"modal-overlay visible",onMouseDown:sa,onClick:aa,children:[e.jsxs("div",{className:"modal building-config-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("span",{children:n(a?"config:buildings.editBuilding":"config:buildings.addBuilding")}),a&&s&&e.jsx("span",{className:"building-status-badge",style:{backgroundColor:Ve[s.status]},children:s.status})]}),e.jsxs("form",{onSubmit:Ws,children:[e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("common:labels.name")}),e.jsx("input",{ref:is,type:"text",className:"form-input",value:t,onChange:m=>r(m.target.value),placeholder:n("config:buildings.namePlaceholder"),required:!0})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("common:labels.type")}),e.jsx("div",{className:"building-type-selector",children:Object.keys(Ks).map(m=>e.jsxs("button",{type:"button",className:`building-type-btn ${i===m?"active":""}`,onClick:()=>{N(m),m==="database"&&b==="server-rack"&&L("filing-cabinet")},title:Ks[m].description,children:[e.jsx("span",{className:"building-type-icon",children:e.jsx(F,{name:Us(m),size:16})}),e.jsx("span",{className:"building-type-name",children:m})]},m))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("config:buildings.style")}),e.jsx("div",{className:"building-style-selector",children:Object.keys(He).map(m=>e.jsxs("button",{type:"button",className:`building-style-btn ${b===m?"active":""}`,onClick:()=>L(m),title:He[m].description,children:[e.jsx("span",{className:"building-style-preview","data-style":m}),e.jsx("span",{className:"building-style-name",children:He[m].label})]},m))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("common:labels.color")}),e.jsxs("div",{className:"building-color-selector",children:[ca.map(m=>e.jsx("button",{type:"button",className:`building-color-btn ${T===m.value?"active":""}`,onClick:()=>A(m.value),title:ma(m.labelKey),style:m.value?{backgroundColor:m.value}:void 0,children:!m.value&&e.jsx("span",{className:"color-default-icon",children:e.jsx(F,{name:"gear",size:12})})},m.value||"default")),e.jsx("input",{type:"color",className:"building-color-picker",value:T||"#2a2a3a",onChange:m=>A(m.target.value),title:"Custom color"})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("common:labels.size")}),e.jsxs("div",{className:"building-size-control",children:[e.jsxs("div",{className:"size-slider-row",children:[e.jsx("input",{type:"range",className:"size-slider",min:"0",max:"100",step:"1",value:Math.log(J/.1)/Math.log(100)*100,onChange:m=>{const f=parseFloat(m.target.value),w=.1*Math.pow(100,f/100);Q(Math.round(w*100)/100)}}),e.jsxs("span",{className:"size-value",children:[J.toFixed(2),"x"]})]}),e.jsx("div",{className:"size-presets",children:[.5,.75,1,1.25,1.5,2].map(m=>e.jsxs("button",{type:"button",className:`size-preset-btn ${J===m?"active":""}`,onClick:()=>Q(m),children:[m,"x"]},m))})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("config:buildings.directory")}),e.jsx(Ue,{value:$,onChange:R,placeholder:"/path/to/project",className:"form-input",directoriesOnly:!0})]}),i==="folder"&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("config:buildings.folderPath")}),e.jsx(Ue,{value:z,onChange:se,placeholder:"/path/to/folder",className:"form-input",directoriesOnly:!0}),e.jsx("div",{className:"form-hint",children:"Click this building to open the file explorer at this path"})]}),i==="boss"&&e.jsx(ga,{buildings:y,buildingId:u,subordinateBuildingIds:Ae,setSubordinateBuildingIds:Be,isEditMode:a,showBossLogs:Gs,setShowBossLogs:Ys,currentBossLogs:h,bossLogsContainerRef:Js}),i==="database"&&e.jsx(ja,{dbConnections:Te,setDbConnections:Re,activeDbConnectionId:as,setActiveDbConnectionId:Ie}),i==="server"&&e.jsx(pa,{usePM2:W,setUsePM2:ae}),i==="server"&&e.jsx(ha,{usePM2:W,pm2Script:Ge,setPm2Script:te,pm2Args:Ye,setPm2Args:ne,pm2Interpreter:Je,setPm2Interpreter:le,pm2InterpreterArgs:We,setPm2InterpreterArgs:ie,pm2Env:Ze,setPm2Env:oe,isEditMode:a,building:s??null,handleCommand:ee}),i==="docker"&&e.jsx(xa,{dockerMode:P,setDockerMode:ce,dockerImage:Qe,setDockerImage:ue,dockerContainerName:pe,setDockerContainerName:he,dockerCommand:ke,setDockerCommand:ye,dockerPorts:xe,setDockerPorts:be,dockerVolumes:je,setDockerVolumes:ge,dockerNetwork:Ne,setDockerNetwork:fe,dockerRestart:es,setDockerRestart:Ce,dockerPull:ss,setDockerPull:Se,dockerEnv:Xe,setDockerEnv:ve,dockerComposePath:we,setDockerComposePath:Pe,dockerComposeProject:De,setDockerComposeProject:Ee,dockerComposeServices:ze,setDockerComposeServices:Le,selectedExistingContainer:me,setSelectedExistingContainer:de,dockerContainersList:v,isEditMode:a,building:s??null,handleCommand:ee}),i==="terminal"&&e.jsx(fa,{terminalShell:ts,setTerminalShell:Oe,terminalPort:_e,setTerminalPort:Me,terminalSaveSession:ns,setTerminalSaveSession:Fe,terminalArgs:ls,setTerminalArgs:$e,isEditMode:a,building:s??null,handleCommand:ee,onOpenTerminal:()=>{s!=null&&s.id&&window.dispatchEvent(new CustomEvent("tide:open-iframe-modal",{detail:{buildingId:s.id}}))},onOpenBelow:m=>{window.dispatchEvent(new CustomEvent("tide:open-bottom-terminal",{detail:{buildingId:m}}))}}),i==="server"&&!W&&e.jsx(va,{startCmd:K,setStartCmd:I,stopCmd:H,setStopCmd:O,restartCmd:c,setRestartCmd:E,healthCheckCmd:V,setHealthCheckCmd:q,logsCmd:k,setLogsCmd:_,isEditMode:a,handleCommand:ee}),e.jsxs("div",{className:"form-section",children:[e.jsxs("label",{className:"form-label",children:[n("config:buildings.links"),e.jsxs("button",{type:"button",className:"btn btn-sm btn-add",onClick:Xs,children:["+ ",n("common:buttons.add")]})]}),M.map((m,f)=>e.jsxs("div",{className:"url-row",children:[e.jsx("input",{type:"text",className:"form-input url-label",value:m.label,onChange:w=>rs(f,"label",w.target.value),placeholder:"Label"}),e.jsx("input",{type:"text",className:"form-input url-value",value:m.url,onChange:w=>rs(f,"url",w.target.value),placeholder:"https://..."}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>ea(f),children:"x"})]},f))]}),a&&S&&cs.length>0&&e.jsx(ka,{logs:cs,buildingId:u,logsContainerRef:X})]}),e.jsxs("div",{className:"modal-footer",children:[a&&e.jsx("button",{type:"button",className:"btn btn-danger",onClick:Zs,children:n("common:buttons.delete")}),e.jsx("div",{className:"footer-spacer"}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:p,children:n("common:buttons.cancel")}),e.jsx("button",{type:"submit",className:"btn btn-primary",children:n(a?"common:buttons.save":"common:buttons.create")})]})]})]}),qs&&s&&e.jsx(ua,{buildingName:s.name,onClose:()=>re(!1),onConfirm:Qs})]})}export{wa as BuildingConfigModal};
|