skypilot-nightly 1.0.0.dev20251022__py3-none-any.whl → 1.0.0.dev20251024__py3-none-any.whl
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.
Potentially problematic release.
This version of skypilot-nightly might be problematic. Click here for more details.
- sky/__init__.py +2 -2
- sky/client/cli/command.py +118 -30
- sky/client/cli/table_utils.py +14 -8
- sky/dashboard/out/404.html +1 -1
- sky/dashboard/out/_next/static/{IgACOQPupLbX9z-RYVEDx → KxZarRnMeQID-gZkBfhzv}/_buildManifest.js +1 -1
- sky/dashboard/out/_next/static/chunks/1141-145e542070a6b615.js +11 -0
- sky/dashboard/out/_next/static/chunks/1871-5f68bb683940d23f.js +6 -0
- sky/dashboard/out/_next/static/chunks/2755.210d4b7c92c6efb2.js +26 -0
- sky/dashboard/out/_next/static/chunks/3015-2dcace420c8939f4.js +1 -0
- sky/dashboard/out/_next/static/chunks/3294.bdfea6492fdf845a.js +1 -0
- sky/dashboard/out/_next/static/chunks/{3785.483a3dda2d52f26e.js → 3785.e4aaef3b6c460dfb.js} +1 -1
- sky/dashboard/out/_next/static/chunks/{4725.10f7a9a5d3ea8208.js → 4725.a830b5c9e7867c92.js} +1 -1
- sky/dashboard/out/_next/static/chunks/8632-396a81107ba407c3.js +1 -0
- sky/dashboard/out/_next/static/chunks/9360.07d78b8552bc9d17.js +31 -0
- sky/dashboard/out/_next/static/chunks/pages/{_app-ce361c6959bc2001.js → _app-7d2f4467a685de9b.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/{[job]-602eeead010ec1d6.js → [job]-1d90fbf8f0ffd194.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-5edf81da6677352c.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/{clusters-57221ec2e4e01076.js → clusters-d887733ca514d22e.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/infra/{[context]-44ce535a0a0ad4ec.js → [context]-79b68556c00d284e.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/{infra-872e6a00165534f4.js → infra-e1c3789e69102cdb.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-10f12af2b199ff68.js +16 -0
- sky/dashboard/out/_next/static/chunks/pages/{users-3a543725492fb896.js → users-0befb1254ac5c965.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/workspaces/{[name]-9ad108cd67d16d96.js → [name]-ecc38434a21e8a1e.js} +1 -1
- sky/dashboard/out/_next/static/chunks/{webpack-919e3c01ab6b2633.js → webpack-31acb2000f9b372c.js} +1 -1
- sky/dashboard/out/_next/static/css/4c052b4444e52a58.css +3 -0
- sky/dashboard/out/clusters/[cluster]/[job].html +1 -1
- sky/dashboard/out/clusters/[cluster].html +1 -1
- sky/dashboard/out/clusters.html +1 -1
- sky/dashboard/out/config.html +1 -1
- sky/dashboard/out/index.html +1 -1
- sky/dashboard/out/infra/[context].html +1 -1
- sky/dashboard/out/infra.html +1 -1
- sky/dashboard/out/jobs/[job].html +1 -1
- sky/dashboard/out/jobs/pools/[pool].html +1 -1
- sky/dashboard/out/jobs.html +1 -1
- sky/dashboard/out/users.html +1 -1
- sky/dashboard/out/volumes.html +1 -1
- sky/dashboard/out/workspace/new.html +1 -1
- sky/dashboard/out/workspaces/[name].html +1 -1
- sky/dashboard/out/workspaces.html +1 -1
- sky/jobs/client/sdk.py +28 -9
- sky/jobs/client/sdk_async.py +9 -3
- sky/jobs/server/core.py +3 -1
- sky/jobs/utils.py +33 -22
- sky/server/auth/oauth2_proxy.py +2 -5
- sky/server/requests/requests.py +39 -6
- sky/server/requests/serializers/decoders.py +23 -10
- sky/server/requests/serializers/encoders.py +4 -3
- sky/server/rest.py +35 -1
- sky/skylet/log_lib.py +8 -1
- sky/skylet/subprocess_daemon.py +103 -29
- sky/utils/db/db_utils.py +21 -0
- sky/utils/subprocess_utils.py +13 -1
- {skypilot_nightly-1.0.0.dev20251022.dist-info → skypilot_nightly-1.0.0.dev20251024.dist-info}/METADATA +33 -33
- {skypilot_nightly-1.0.0.dev20251022.dist-info → skypilot_nightly-1.0.0.dev20251024.dist-info}/RECORD +60 -60
- sky/dashboard/out/_next/static/chunks/1141-ec6f902ffb865853.js +0 -11
- sky/dashboard/out/_next/static/chunks/1871-df9f87fcb7f24292.js +0 -6
- sky/dashboard/out/_next/static/chunks/2755.9b1e69c921b5a870.js +0 -26
- sky/dashboard/out/_next/static/chunks/3015-d014dc5b9412fade.js +0 -1
- sky/dashboard/out/_next/static/chunks/3294.998db87cd52a1238.js +0 -1
- sky/dashboard/out/_next/static/chunks/6135-4b4d5e824b7f9d3c.js +0 -1
- sky/dashboard/out/_next/static/chunks/9360.14326e329484b57e.js +0 -31
- sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-18b334dedbd9f6f2.js +0 -1
- sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-8677af16befde039.js +0 -16
- sky/dashboard/out/_next/static/css/4614e06482d7309e.css +0 -3
- /sky/dashboard/out/_next/static/{IgACOQPupLbX9z-RYVEDx → KxZarRnMeQID-gZkBfhzv}/_ssgManifest.js +0 -0
- {skypilot_nightly-1.0.0.dev20251022.dist-info → skypilot_nightly-1.0.0.dev20251024.dist-info}/WHEEL +0 -0
- {skypilot_nightly-1.0.0.dev20251022.dist-info → skypilot_nightly-1.0.0.dev20251024.dist-info}/entry_points.txt +0 -0
- {skypilot_nightly-1.0.0.dev20251022.dist-info → skypilot_nightly-1.0.0.dev20251024.dist-info}/licenses/LICENSE +0 -0
- {skypilot_nightly-1.0.0.dev20251022.dist-info → skypilot_nightly-1.0.0.dev20251024.dist-info}/top_level.txt +0 -0
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2755],{81260:function(e,s,t){t.d(s,{Z:function(){return r}});/**
|
|
2
|
-
* @license lucide-react v0.407.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/let r=(0,t(60998).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},47603:function(e,s,t){t.d(s,{Z:function(){return r}});/**
|
|
7
|
-
* @license lucide-react v0.407.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/let r=(0,t(60998).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1812:function(e,s,t){t.d(s,{X:function(){return l}});var r=t(85893),n=t(67294);let a=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let s=e.message;return s.includes("failed:")&&(s=s.split("failed:")[1].trim()),s},l=e=>{let{error:s,title:t="Error",onDismiss:l}=e,[i,o]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{s&&o(!1)},[s]),!s||i)return null;let c="string"==typeof s?s:a(s);return(0,r.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,r.jsx)("div",{className:"ml-3",children:(0,r.jsxs)("div",{className:"text-sm text-red-800",children:[(0,r.jsxs)("strong",{children:[t,":"]})," ",c]})})]}),(0,r.jsx)("button",{onClick:()=>{o(!0),l&&l()},className:"flex-shrink-0 ml-4 text-red-400 hover:text-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-red-50 rounded","aria-label":"Dismiss error",children:(0,r.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})})}},27669:function(e,s,t){t.r(s),t.d(s,{Users:function(){return B}});var r=t(85893),n=t(67294),a=t(45697),l=t.n(a),i=t(55739),o=t(41664),c=t.n(o),d=t(11163),u=t(30803),x=t(68764),m=t(53081),h=t(23266),p=t(68969),g=t(6378),f=t(36856),b=t(51214),j=t(94545),v=t(36989),y=t(60998);/**
|
|
12
|
-
* @license lucide-react v0.407.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/let w=(0,y.Z)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);var N=t(13626),k=t(81260);/**
|
|
17
|
-
* @license lucide-react v0.407.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/let C=(0,y.Z)("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]),_=(0,y.Z)("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var S=t(16826),R=t(70282),E=t(43767);/**
|
|
22
|
-
* @license lucide-react v0.407.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/let D=(0,y.Z)("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),I=(0,y.Z)("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);var Z=t(47603),L=t(27325);t(6135);var F=t(23001),U=t(37673),A=t(47145),M=t(50326),T=t(1812);let P=new Set(t(23015).statusGroups.active),z=(e,s)=>e&&e.includes("@")?e.split("@")[0]:e||"N/A",V=(e,s)=>e&&e.includes("@")?e:s||"-",q=b.nb.REFRESH_INTERVAL,O=e=>{let{message:s,onDismiss:t}=e;return s?(0,r.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-6",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}),(0,r.jsx)("div",{className:"ml-3",children:(0,r.jsx)("p",{className:"text-sm font-medium text-green-800",children:s})})]}),t&&(0,r.jsx)("div",{className:"ml-auto pl-3",children:(0,r.jsx)("div",{className:"-mx-1.5 -my-1.5",children:(0,r.jsxs)("button",{type:"button",onClick:t,className:"inline-flex rounded-md bg-green-50 p-1.5 text-green-500 hover:bg-green-100 focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2 focus:ring-offset-green-50",children:[(0,r.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,r.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})]})})})]})}):null};function B(){let e=(0,d.useRouter)(),[s,t]=(0,n.useState)(!1),a=(0,n.useRef)(null),l=(0,F.X)(),[o,c]=(0,n.useState)(!1),[x,f]=(0,n.useState)({username:"",password:"",role:"user"}),[b,j]=(0,n.useState)(!1),[v,y]=(0,n.useState)({open:!1,message:"",userName:""}),[R,E]=(0,n.useState)(null),[D,I]=(0,n.useState)(!1),[Z,L]=(0,n.useState)(!1),[U,P]=(0,n.useState)(!1),[z,V]=(0,n.useState)(null),[B,H]=(0,n.useState)(!1),[J,W]=(0,n.useState)(null),[Q,X]=(0,n.useState)("import"),[Y,G]=(0,n.useState)(!1),[ee,es]=(0,n.useState)(null),[et,er]=(0,n.useState)(""),[en,ea]=(0,n.useState)(!1),[el,ei]=(0,n.useState)(null),[eo,ec]=(0,n.useState)(!1),[ed,eu]=(0,n.useState)(null),[ex,em]=(0,n.useState)(null),[eh,ep]=(0,n.useState)(!1),[eg,ef]=(0,n.useState)(null),[eb,ej]=(0,n.useState)(null),[ev,ey]=(0,n.useState)(void 0),[ew,eN]=(0,n.useState)("users"),[ek,eC]=(0,n.useState)(!1),[e_,eS]=(0,n.useState)(!1),[eR,eE]=(0,n.useState)(null),[eD,eI]=(0,n.useState)(!1),[eZ,eL]=(0,n.useState)(""),[eF,eU]=(0,n.useState)("");(0,n.useEffect)(()=>{e.isReady&&("service-accounts"===e.query.tab?eN("service-accounts"):eN("users"))},[e.isReady,e.query.tab]),(0,n.useEffect)(()=>{(async function(){try{let e=await A.x.get("/api/health");if(e.ok){let s=await e.json();ey(!!s.basic_auth_enabled)}else ey(!1)}catch(e){ey(!1)}})()},[]);let eA=(0,n.useCallback)(async()=>{if(R&&Date.now()-R.timestamp<3e5)return R;I(!0);try{let e=await A.x.get("/users/role");if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to get user role")}let s=await e.json(),t={role:s.role,name:s.name,id:s.id,timestamp:Date.now()};return E(t),I(!1),t}catch(e){throw I(!1),e}},[R]);(0,n.useEffect)(()=>{eA().catch(()=>{console.error("Failed to get user role")})},[eA]);let eM=async(e,s)=>{try{let t=await eA();if("admin"!==t.role)return y({open:!0,message:e,userName:t.name.toLowerCase()}),!1;return s(),!0}catch(e){return console.error("Failed to check user role:",e),y({open:!0,message:"Error: ".concat(e.message),userName:""}),!1}},eT=()=>{g.default.invalidate(m.R),g.default.invalidate(h.getClusters),g.default.invalidate(p.getManagedJobs,[{allUsers:!0,skipFinished:!0,fields:["user_hash","status"]}]),a.current&&a.current()},eP=async()=>{if(!x.username||!x.password){ej(Error("Username and password are required.")),c(!1);return}j(!0),ej(null),ef(null);try{let e=await A.x.post("/users/create",x);if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to create user")}ef('User "'.concat(x.username,'" created successfully!')),c(!1),f({username:"",password:"",role:"user"}),eT()}catch(e){ej(e),c(!1),f({username:"",password:"",role:"user"})}finally{j(!1)}},ez=async e=>{let s=e.target.files[0];s&&(V(s),W(null))},eV=async()=>{if(!z){alert("Please select a CSV file first.");return}H(!0);try{let e=new FileReader;e.onload=async e=>{try{let s=e.target.result,t=await A.x.post("/users/import",{csv_content:s});if(!t.ok){let e=await t.json();throw Error(e.detail||"Failed to import users")}let r=await t.json(),n="Import completed. ".concat(r.success_count," users created successfully.");r.error_count>0&&(n+="\n".concat(r.error_count," failed."),r.creation_errors.length>0&&(n+="\nErrors: ".concat(r.creation_errors.slice(0,3).join(", ")),r.creation_errors.length>3&&(n+=" and ".concat(r.creation_errors.length-3," more...")))),W({message:n}),r.success_count>0&&eT()}catch(e){alert("Error importing users: ".concat(e.message))}finally{H(!1)}},e.readAsText(z)}catch(e){alert("Error reading file: ".concat(e.message)),H(!1)}},eq=async e=>{es(e),er(""),G(!0)},eO=async()=>{if(!et){ej(Error("Please enter a new password."));return}ea(!0),ei(null);try{let e=await A.x.post("/users/update",{user_id:ee.userId,password:et});if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to reset password")}ef('Password reset successfully for user "'.concat(ee.usernameDisplay,'"!')),G(!1),es(null),er("")}catch(e){G(!1),es(null),er(""),ei(null),ej(e)}finally{ea(!1)}},eB=async()=>{if(ed){ep(!0),em(null);try{let e=await A.x.post("/users/delete",{user_id:ed.userId});if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to delete user")}ef('User "'.concat(ed.usernameDisplay,'" deleted successfully!')),ec(!1),eu(null),eT()}catch(e){ec(!1),eu(null),em(null),ej(e)}finally{ep(!1)}}},eK=()=>{ec(!1),eu(null)},e$=()=>{G(!1),es(null),er("")};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{className:"text-base flex items-center",children:[(0,r.jsx)("button",{className:"leading-none mr-6 pb-2 px-2 border-b-2 ".concat("users"===ew?"text-sky-blue border-sky-500":"text-gray-500 hover:text-gray-700 border-transparent"),onClick:()=>{eN("users"),e.push("/users",void 0,{shallow:!0})},children:"Users"}),(0,r.jsx)("button",{className:"leading-none pb-2 px-2 border-b-2 ".concat("service-accounts"===ew?"text-sky-blue border-sky-500":"text-gray-500 hover:text-gray-700 border-transparent"),onClick:()=>{eN("service-accounts"),e.push("/users?tab=service-accounts",void 0,{shallow:!0})},children:"Service Accounts"})]}),(0,r.jsxs)("div",{className:"flex items-center",children:[s&&(0,r.jsxs)("div",{className:"flex items-center mr-2",children:[(0,r.jsx)(i.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),"users"===ew&&ev&&(null==R?void 0:R.role)==="admin"&&(0,r.jsx)("button",{onClick:async()=>{await eM("cannot create users",()=>{c(!0)})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center rounded px-2 py-1 mr-2",title:"Create New User",children:"+ New User"}),"users"===ew&&ev&&(null==R?void 0:R.role)==="admin"&&(0,r.jsxs)("button",{onClick:async()=>{await eM("cannot import users",()=>{P(!0)})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center rounded px-2 py-1 mr-2",title:"Import/Export Users",children:[(0,r.jsx)(w,{className:"h-4 w-4 mr-1"}),"Import/Export"]}),(0,r.jsxs)("button",{onClick:eT,disabled:s,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,r.jsx)(N.Z,{className:"h-4 w-4 mr-1.5"}),!l&&(0,r.jsx)("span",{children:"Refresh"})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"relative flex-1 max-w-md",children:[(0,r.jsx)("input",{type:"text",placeholder:"users"===ew?"Search users by name, email, or role":"Search by service account name, or created by",value:"users"===ew?eZ:eF,onChange:e=>{"users"===ew?eL(e.target.value):eU(e.target.value)},className:"h-8 w-full px-3 pr-8 text-sm border border-gray-300 rounded-md focus:ring-1 focus:ring-sky-500 focus:border-sky-500 outline-none"}),("users"===ew&&eZ||"service-accounts"===ew&&eF)&&(0,r.jsx)("button",{onClick:()=>{"users"===ew?eL(""):eU("")},className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear search",children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),"service-accounts"===ew&&(0,r.jsxs)("button",{onClick:()=>{eM("cannot create service account tokens",()=>{eC(!0)})},className:"ml-4 bg-sky-600 hover:bg-sky-700 text-white flex items-center rounded-md px-3 py-1 text-sm font-medium transition-colors duration-200",title:"Create Service Account",children:[(0,r.jsx)(k.Z,{className:"h-4 w-4 mr-2"}),"Create Service Account"]})]}),(0,r.jsxs)("div",{className:"fixed top-20 right-4 z-[9999] max-w-md",children:[(0,r.jsx)(O,{message:eg,onDismiss:()=>ef(null)}),(0,r.jsx)(T.X,{error:eb,title:"Error",onDismiss:()=>ej(null)})]}),"users"===ew?(0,r.jsx)(K,{refreshInterval:q,setLoading:t,refreshDataRef:a,checkPermissionAndAct:eM,roleLoading:D,onResetPassword:eq,onDeleteUser:e=>{eM("cannot delete users",()=>{eu(e),ec(!0)})},basicAuthEnabled:ev,currentUserRole:null==R?void 0:R.role,currentUserId:null==R?void 0:R.id,searchQuery:eZ,setSearchQuery:eL}):(0,r.jsx)($,{checkPermissionAndAct:eM,userRoleCache:R,setCreateSuccess:ef,setCreateError:ej,showCreateDialog:ek,setShowCreateDialog:eC,showRotateDialog:e_,setShowRotateDialog:eS,tokenToRotate:eR,setTokenToRotate:eE,rotating:eD,setRotating:eI,searchQuery:eF,setSearchQuery:eU}),(0,r.jsx)(M.Vq,{open:o,onOpenChange:e=>{c(e),e||ej(null)},children:(0,r.jsxs)(M.cZ,{className:"sm:max-w-md",children:[(0,r.jsx)(M.fK,{children:(0,r.jsx)(M.$N,{children:"Create User"})}),(0,r.jsxs)("div",{className:"flex flex-col gap-4 py-4",children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Username"}),(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full",placeholder:"Username",value:x.username,onChange:e=>f({...x,username:e.target.value})})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Password"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full pr-10",placeholder:"Password",type:Z?"text":"password",value:x.password,onChange:e=>f({...x,password:e.target.value})}),(0,r.jsx)("button",{type:"button",className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600",onClick:()=>L(!Z),children:Z?(0,r.jsx)(C,{className:"h-4 w-4"}):(0,r.jsx)(_,{className:"h-4 w-4"})})]})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Role"}),(0,r.jsxs)("select",{className:"border rounded px-3 py-2 w-full",value:x.role,onChange:e=>f({...x,role:e.target.value}),children:[(0,r.jsx)("option",{value:"user",children:"User"}),(0,r.jsx)("option",{value:"admin",children:"Admin"})]})]})]}),(0,r.jsxs)(M.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>c(!1),disabled:b,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:eP,disabled:b,children:b?"Creating...":"Create"})]})]})}),(0,r.jsx)(M.Vq,{open:v.open,onOpenChange:e=>{y(s=>({...s,open:e})),e||ej(null)},children:(0,r.jsxs)(M.cZ,{className:"sm:max-w-md transition-all duration-200 ease-in-out",children:[(0,r.jsxs)(M.fK,{children:[(0,r.jsx)(M.$N,{children:"Permission Denied"}),(0,r.jsx)(M.Be,{children:D?(0,r.jsxs)("div",{className:"flex items-center py-2",children:[(0,r.jsx)(i.Z,{size:16,className:"mr-2"}),(0,r.jsx)("span",{children:"Checking permissions..."})]}):(0,r.jsx)(r.Fragment,{children:v.userName?(0,r.jsxs)(r.Fragment,{children:[v.userName," is logged in as non-admin and ",v.message,"."]}):v.message})})]}),(0,r.jsx)(M.cN,{children:(0,r.jsx)(u.z,{variant:"outline",onClick:()=>y(e=>({...e,open:!1})),disabled:D,children:"OK"})})]})}),(0,r.jsx)(M.Vq,{open:U,onOpenChange:e=>{P(e),e||ej(null)},children:(0,r.jsxs)(M.cZ,{className:"sm:max-w-lg",children:[(0,r.jsx)(M.fK,{children:(0,r.jsx)(M.$N,{children:"Import/Export Users"})}),(0,r.jsxs)("div",{className:"flex border-b border-gray-200 mb-4",children:[(0,r.jsx)("button",{className:"px-4 py-2 text-sm font-medium ".concat("import"===Q?"border-b-2 border-sky-500 text-sky-600":"text-gray-500 hover:text-gray-700"),onClick:()=>X("import"),children:"Import"}),(0,r.jsx)("button",{className:"px-4 py-2 text-sm font-medium ".concat("export"===Q?"border-b-2 border-sky-500 text-sky-600":"text-gray-500 hover:text-gray-700"),onClick:()=>X("export"),children:"Export"})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:"import"===Q?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"CSV File"}),(0,r.jsx)("input",{type:"file",accept:".csv",onChange:ez,className:"border rounded px-3 py-2 w-full"}),(0,r.jsxs)("p",{className:"text-xs text-gray-500",children:["CSV should have columns: username, password, role",(0,r.jsx)("br",{}),"Supports both plain text passwords and exported password hashes."]})]}),J&&(0,r.jsx)("div",{className:"p-3 bg-green-50 border border-green-200 rounded text-green-700 text-sm",children:J.message})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Export Users to CSV"}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Download all users as a CSV file with password hashes."}),(0,r.jsxs)("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[(0,r.jsx)("p",{className:"text-sm text-amber-700",children:"⚠️ This will export all users with columns: username, password (hashed), role"}),(0,r.jsx)("p",{className:"text-xs text-amber-600 mt-1",children:"Password hashes can be imported directly for system backups."})]})]})})}),(0,r.jsxs)(M.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>P(!1),disabled:B,children:"Cancel"}),"import"===Q?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:eV,disabled:B||!z,children:B?"Importing...":"Import"}):(0,r.jsxs)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:async()=>{try{let e=await A.x.get("/users/export");if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to export users")}let s=await e.json(),t=s.csv_content,r=new Blob([t],{type:"text/csv;charset=utf-8;"}),n=URL.createObjectURL(r),a=document.createElement("a");a.href=n;let l=new Date,i=e=>String(e).padStart(2,"0"),o=l.getFullYear(),c=i(l.getMonth()+1),d=i(l.getDate()),u=i(l.getHours()),x=i(l.getMinutes()),m=i(l.getSeconds());a.download="users_export_".concat(o,"-").concat(c,"-").concat(d,"-").concat(u,"-").concat(x,"-").concat(m,".csv"),a.click(),URL.revokeObjectURL(n),alert("Successfully exported ".concat(s.user_count," users to CSV file."))}catch(e){alert("Error exporting users: ".concat(e.message))}},children:[(0,r.jsx)(S.Z,{className:"h-4 w-4 mr-1"}),"Export"]})]})]})}),(0,r.jsx)(M.Vq,{open:Y,onOpenChange:e=>{e||(e$(),ej(null))},children:(0,r.jsxs)(M.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(M.fK,{children:[(0,r.jsx)(M.$N,{children:"Reset Password"}),(0,r.jsxs)(M.Be,{children:["Enter a new password for"," ",(null==ee?void 0:ee.usernameDisplay)||"this user","."]})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"New Password"}),(0,r.jsx)("input",{type:"password",className:"border rounded px-3 py-2 w-full",placeholder:"Enter new password",value:et,onChange:e=>er(e.target.value),autoFocus:!0})]})}),(0,r.jsxs)(M.cN,{children:[(0,r.jsx)(u.z,{variant:"outline",onClick:e$,disabled:en,children:"Cancel"}),(0,r.jsx)(u.z,{variant:"default",onClick:eO,disabled:en||!et,className:"bg-sky-600 text-white hover:bg-sky-700",children:en?"Resetting...":"Reset Password"})]})]})}),(0,r.jsx)(M.Vq,{open:eo,onOpenChange:e=>{e||(eK(),ej(null))},children:(0,r.jsxs)(M.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(M.fK,{children:[(0,r.jsx)(M.$N,{children:"Delete User"}),(0,r.jsxs)(M.Be,{children:['Are you sure you want to delete user "',(null==ed?void 0:ed.usernameDisplay)||"this user",'"? This action cannot be undone.']})]}),(0,r.jsxs)(M.cN,{children:[(0,r.jsx)(u.z,{variant:"outline",onClick:eK,disabled:eh,children:"Cancel"}),(0,r.jsx)(u.z,{variant:"destructive",onClick:eB,disabled:eh,children:eh?"Deleting...":"Delete"})]})]})})]})}function K(e){let{refreshInterval:s,setLoading:t,refreshDataRef:a,checkPermissionAndAct:l,roleLoading:o,onResetPassword:d,onDeleteUser:u,basicAuthEnabled:b,currentUserRole:y,currentUserId:w,searchQuery:N,setSearchQuery:k}=e,[C,_]=(0,n.useState)([]),[S,L]=(0,n.useState)(!0),[F,M]=(0,n.useState)(!1),[T,q]=(0,n.useState)({key:"username",direction:"ascending"}),[O,B]=(0,n.useState)(null),[K,$]=(0,n.useState)(""),H=(0,n.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t&&e&&t(!0),e&&L(!0);try{let s=await g.default.get(m.R),r=(s||[]).map(e=>({...e,usernameDisplay:z(e.username,e.userId),fullEmailID:V(e.username,e.userId),clusterCount:-1,jobCount:-1}));_(r),M(!0),t&&e&&t(!1),e&&L(!1);let[n,a]=await Promise.all([g.default.get(h.getClusters),g.default.get(p.getManagedJobs,[{allUsers:!0,skipFinished:!0,fields:["user_hash","status"]}])]),l=a.jobs||[],i=(s||[]).map(e=>{let s=(n||[]).filter(s=>s.user_hash===e.userId),t=(l||[]).filter(s=>s.user_hash===e.userId&&P.has(s.status)).length;return{...e,usernameDisplay:z(e.username,e.userId),fullEmailID:V(e.username,e.userId),clusterCount:s.length,jobCount:t}});_(i)}catch(s){console.error("Failed to fetch or process user data:",s),_([]),M(!0),t&&e&&t(!1),e&&L(!1)}},[t]);(0,n.useEffect)(()=>{a&&(a.current=()=>H(!0))},[a,H]),(0,n.useEffect)(()=>{(async()=>{M(!1),L(!0),await f.ZP.preloadForPage("users"),H(!0)})();let e=setInterval(()=>{H(!1)},s);return()=>clearInterval(e)},[H,s]);let J=(0,n.useMemo)(()=>{let e=C;if(null==N?void 0:N.trim()){let s=N.toLowerCase();e=C.filter(e=>{var t,r,n;return(null===(t=e.usernameDisplay)||void 0===t?void 0:t.toLowerCase().includes(s))||(null===(r=e.fullEmailID)||void 0===r?void 0:r.toLowerCase().includes(s))||(null===(n=e.role)||void 0===n?void 0:n.toLowerCase().includes(s))})}return(0,j.R0)(e,T.key,T.direction)},[C,T,N]),W=e=>{let s="ascending";T.key===e&&"ascending"===T.direction&&(s="descending"),q({key:e,direction:s})},Q=e=>T.key===e?"ascending"===T.direction?" ↑":" ↓":"",X=async(e,s)=>{await l("cannot edit user role",()=>{B(e),$(s)})},Y=()=>{B(null),$("")},G=async e=>{if(!e||!K){console.error("User ID or role is missing."),alert("Error: User ID or role is missing.");return}L(!0);try{let s=await A.x.post("/users/update",{user_id:e,role:K});if(!s.ok){let e=await s.json();throw Error(e.detail||"Failed to update role")}g.default.invalidate(m.R),await H(!0),Y()}catch(e){console.error("Failed to update user role:",e),alert("Error updating role: ".concat(e.message))}finally{L(!1)}};return S&&0===C.length&&!F?(0,r.jsx)("div",{className:"flex justify-center items-center h-64",children:(0,r.jsx)(i.Z,{})}):F?J&&0!==J.length?(0,r.jsx)(U.Zb,{children:(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,r.jsxs)(x.iA,{className:"min-w-full",children:[(0,r.jsx)(x.xD,{children:(0,r.jsxs)(x.SC,{children:[(0,r.jsxs)(x.ss,{onClick:()=>W("usernameDisplay"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Name",Q("usernameDisplay")]}),(0,r.jsxs)(x.ss,{onClick:()=>W("fullEmailID"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["User ID",Q("fullEmailID")]}),(0,r.jsxs)(x.ss,{onClick:()=>W("role"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Role",Q("role")]}),(0,r.jsxs)(x.ss,{onClick:()=>W("created_at"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Joined",Q("created_at")]}),(0,r.jsxs)(x.ss,{onClick:()=>W("clusterCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Clusters",Q("clusterCount")]}),(0,r.jsxs)(x.ss,{onClick:()=>W("jobCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Jobs",Q("jobCount")]}),(b||"admin"===y)&&(0,r.jsx)(x.ss,{className:"whitespace-nowrap w-1/7",children:"Actions"})]})}),(0,r.jsx)(x.RM,{children:J.map(e=>(0,r.jsxs)(x.SC,{children:[(0,r.jsx)(x.pj,{className:"truncate",title:e.username,children:e.usernameDisplay}),(0,r.jsx)(x.pj,{className:"truncate",title:e.fullEmailID,children:e.fullEmailID}),(0,r.jsx)(x.pj,{className:"truncate",title:e.role,children:(0,r.jsx)("div",{className:"flex items-center gap-2",children:O===e.userId?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("select",{value:K,onChange:e=>$(e.target.value),className:"block w-auto p-1 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-sky-blue focus:border-sky-blue sm:text-sm",children:[(0,r.jsx)("option",{value:"admin",children:"Admin"}),(0,r.jsx)("option",{value:"user",children:"User"})]}),(0,r.jsx)("button",{onClick:()=>G(e.userId),className:"text-green-600 hover:text-green-800 p-1",title:"Save",children:(0,r.jsx)(R.Z,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:Y,className:"text-gray-500 hover:text-gray-700 p-1",title:"Cancel",children:(0,r.jsx)(E.Z,{className:"h-4 w-4"})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"capitalize",children:e.role}),"admin"===y&&(0,r.jsx)("button",{onClick:()=>X(e.userId,e.role),className:"text-blue-600 hover:text-blue-700 p-1",title:"Edit role",children:(0,r.jsx)(D,{className:"h-3 w-3"})})]})})}),(0,r.jsx)(x.pj,{className:"truncate",children:e.created_at?(0,r.jsx)(v.Zg,{date:new Date(1e3*e.created_at)}):"-"}),(0,r.jsx)(x.pj,{children:-1===e.clusterCount?(0,r.jsxs)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-400 rounded text-xs font-medium flex items-center",children:[(0,r.jsx)(i.Z,{size:10,className:"mr-1"}),"Loading..."]}):(0,r.jsx)(c(),{href:"/clusters?user=".concat(encodeURIComponent(e.userId)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.clusterCount>0?"bg-blue-100 text-blue-600 hover:bg-blue-200 hover:text-blue-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.clusterCount," cluster").concat(1!==e.clusterCount?"s":""," for ").concat(e.usernameDisplay),children:e.clusterCount})}),(0,r.jsx)(x.pj,{children:-1===e.jobCount?(0,r.jsxs)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-400 rounded text-xs font-medium flex items-center",children:[(0,r.jsx)(i.Z,{size:10,className:"mr-1"}),"Loading..."]}):(0,r.jsx)(c(),{href:"/jobs?user=".concat(encodeURIComponent(e.userId)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.jobCount>0?"bg-green-100 text-green-600 hover:bg-green-200 hover:text-green-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.jobCount," active job").concat(1!==e.jobCount?"s":""," for ").concat(e.usernameDisplay),children:e.jobCount})}),(b||"admin"===y)&&(0,r.jsx)(x.pj,{className:"relative",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[b&&(0,r.jsx)("button",{onClick:"admin"===y||e.userId===w?async()=>{d(e)}:void 0,className:"admin"===y||e.userId===w?"text-blue-600 hover:text-blue-700 p-1":"text-gray-300 cursor-not-allowed p-1",title:"admin"===y||e.userId===w?"Reset Password":"You can only reset your own password",disabled:"admin"!==y&&e.userId!==w,children:(0,r.jsx)(I,{className:"h-4 w-4"})}),"admin"===y&&(0,r.jsx)("button",{onClick:()=>u(e),className:"text-red-600 hover:text-red-700 p-1",title:"Delete User",children:(0,r.jsx)(Z.Z,{className:"h-4 w-4"})})]})})]},e.userId))})]})})}):(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)("p",{className:"text-lg font-semibold text-gray-500",children:(null==N?void 0:N.trim())?"No users match your search.":"No users found."}),(0,r.jsx)("p",{className:"text-sm text-gray-400 mt-1",children:(null==N?void 0:N.trim())?"Try adjusting your search terms.":"There are currently no users to display."})]}):(0,r.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,r.jsx)(i.Z,{}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading users..."})]})}function $(e){let{checkPermissionAndAct:s,userRoleCache:t,setCreateSuccess:a,setCreateError:l,showCreateDialog:o,setShowCreateDialog:d,showRotateDialog:u,setShowRotateDialog:m,tokenToRotate:f,setTokenToRotate:b,rotating:j,setRotating:y,searchQuery:w,setSearchQuery:k}=e,[C,_]=(0,n.useState)([]),[S,F]=(0,n.useState)(!0),[T,z]=(0,n.useState)(!1),[V,q]=(0,n.useState)(null),[O,B]=(0,n.useState)(null),[K,$]=(0,n.useState)({token_name:"",expires_in_days:30}),[H,J]=(0,n.useState)(""),[W,Q]=(0,n.useState)(!1),[X,Y]=(0,n.useState)(!1),[G,ee]=(0,n.useState)(""),[es,et]=(0,n.useState)(null),[er,en]=(0,n.useState)(null),[ea,el]=(0,n.useState)(null),[ei,eo]=(0,n.useState)(""),[ec,ed]=(0,n.useState)([]),eu=async()=>{try{F(!0);let e=await A.x.get("/users/service-account-tokens");if(!e.ok){console.error("Failed to fetch tokens"),_([]),ed([]);return}let s=await e.json();_(s||[]);let[t,r]=await Promise.all([g.default.get(h.getClusters),g.default.get(p.getManagedJobs,[{allUsers:!0,skipFinished:!0,fields:["user_hash","status"]}])]),n=t||[],a=(null==r?void 0:r.jobs)||[],l=(s||[]).map(e=>{let s=e.service_account_user_id,t=n.filter(e=>e.user_hash===s),r=a.filter(e=>e.user_hash===s&&P.has(e.status));return{...e,clusterCount:t.length,jobCount:r.length,primaryRole:e.service_account_roles&&e.service_account_roles.length>0?e.service_account_roles[0]:"user"}});ed(l)}catch(e){console.error("Error fetching tokens and counts:",e),_([]),ed([])}finally{F(!1)}};(0,n.useEffect)(()=>{eu()},[]);let ex=async(e,t)=>{await s("cannot edit service account role",()=>{el(e),eo(t)})},em=()=>{el(null),eo("")},eh=async e=>{if(!e||!ei){console.error("Token ID or role is missing."),l(Error("Token ID or role is missing."));return}F(!0);try{let s=await A.x.post("/users/service-account-tokens/update-role",{token_id:e,role:ei});if(!s.ok){let e=await s.json();throw Error(e.detail||"Failed to update role")}a("Service account role updated successfully!"),await eu(),em()}catch(e){console.error("Failed to update service account role:",e),l(e)}finally{F(!1)}},ep=async e=>{try{await navigator.clipboard.writeText(e),ee("Copied!"),setTimeout(()=>ee(""),2e3)}catch(e){console.error("Failed to copy:",e)}},eg=async()=>{if(!K.token_name.trim()){l(Error("Token name is required"));return}Q(!0);try{let e={token_name:K.token_name.trim(),expires_in_days:""===K.expires_in_days?null:K.expires_in_days},s=await A.x.post("/users/service-account-tokens",e);if(s.ok){let e=await s.json();et(e.token),$({token_name:"",expires_in_days:30}),await eu()}else{let e=await s.json();throw Error(e.detail||"Failed to create token")}}catch(e){l(e)}finally{Q(!1)}},ef=async()=>{if(V){Y(!0),B(null);try{let e=await A.x.post("/users/service-account-tokens/delete",{token_id:V.token_id});if(e.ok)a('Service account "'.concat(V.token_name,'" deleted successfully!')),z(!1),q(null),B(null),await eu();else{let s=await e.json();throw Error(s.detail||"Failed to delete service account")}}catch(e){z(!1),q(null),B(null),l(e)}finally{Y(!1)}}},eb=async()=>{if(f){y(!0);try{let e={token_id:f.token_id,expires_in_days:""===H?null:parseInt(H)},s=await A.x.post("/users/service-account-tokens/rotate",e);if(s.ok){let e=await s.json();en(e.token),await eu()}else{let e=await s.json();throw Error(e.detail||"Failed to rotate token")}}catch(e){l(e)}finally{y(!1)}}},ej=ec.filter(e=>{var s,t,r,n;if(!(null==w?void 0:w.trim()))return!0;let a=w.toLowerCase();return(null===(s=e.token_name)||void 0===s?void 0:s.toLowerCase().includes(a))||(null===(t=e.creator_name)||void 0===t?void 0:t.toLowerCase().includes(a))||(null===(r=e.service_account_name)||void 0===r?void 0:r.toLowerCase().includes(a))||(null===(n=e.primaryRole)||void 0===n?void 0:n.toLowerCase().includes(a))});return S&&0===ec.length?(0,r.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,r.jsx)(i.Z,{size:32}),(0,r.jsx)("span",{className:"ml-3",children:"Loading tokens..."})]}):(0,r.jsxs)(r.Fragment,{children:[0===ej.length?(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)(I,{className:"mx-auto h-12 w-12 text-gray-400"}),(0,r.jsx)("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:(null==w?void 0:w.trim())?"No tokens match your search":"No service accounts"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:(null==w?void 0:w.trim())?"Try adjusting your search terms.":"No service accounts have been created yet."})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(U.Zb,{children:(0,r.jsxs)(x.iA,{children:[(0,r.jsx)(x.xD,{children:(0,r.jsxs)(x.SC,{children:[(0,r.jsx)(x.ss,{children:"Name"}),(0,r.jsx)(x.ss,{children:"Created by"}),(0,r.jsx)(x.ss,{children:"Role"}),(0,r.jsx)(x.ss,{children:"Clusters"}),(0,r.jsx)(x.ss,{children:"Jobs"}),(0,r.jsx)(x.ss,{children:"Created"}),(0,r.jsx)(x.ss,{children:"Last used"}),(0,r.jsx)(x.ss,{children:"Expires"}),(0,r.jsx)(x.ss,{children:"Actions"})]})}),(0,r.jsx)(x.RM,{children:ej.map(e=>(0,r.jsxs)(x.SC,{children:[(0,r.jsx)(x.pj,{className:"truncate",title:e.token_name,children:e.token_name}),(0,r.jsx)(x.pj,{className:"truncate",children:(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("span",{children:e.creator_name||"Unknown"}),e.creator_user_hash!==(null==t?void 0:t.id)&&(0,r.jsx)("span",{className:"ml-2 px-1.5 py-0.5 text-xs bg-gray-100 text-gray-600 rounded",children:"Other"})]})}),(0,r.jsx)(x.pj,{className:"truncate",children:(0,r.jsx)("div",{className:"flex items-center gap-2",children:ea===e.token_id?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("select",{value:ei,onChange:e=>eo(e.target.value),className:"block w-auto p-1 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-sky-blue focus:border-sky-blue sm:text-sm",children:[(0,r.jsx)("option",{value:"admin",children:"Admin"}),(0,r.jsx)("option",{value:"user",children:"User"})]}),(0,r.jsx)("button",{onClick:()=>eh(e.token_id),className:"text-green-600 hover:text-green-800 p-1",title:"Save",children:(0,r.jsx)(R.Z,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:em,className:"text-gray-500 hover:text-gray-700 p-1",title:"Cancel",children:(0,r.jsx)(E.Z,{className:"h-4 w-4"})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"capitalize",children:e.primaryRole}),((null==t?void 0:t.role)==="admin"||e.creator_user_hash===(null==t?void 0:t.id))&&(0,r.jsx)("button",{onClick:()=>ex(e.token_id,e.primaryRole),className:"text-blue-600 hover:text-blue-700 p-1",title:"Edit role",children:(0,r.jsx)(D,{className:"h-3 w-3"})})]})})}),(0,r.jsx)(x.pj,{children:(0,r.jsx)(c(),{href:"/clusters?user=".concat(encodeURIComponent(e.service_account_user_id)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.clusterCount>0?"bg-blue-100 text-blue-600 hover:bg-blue-200 hover:text-blue-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.clusterCount," cluster").concat(1!==e.clusterCount?"s":""," for ").concat(e.token_name),children:e.clusterCount})}),(0,r.jsx)(x.pj,{children:(0,r.jsx)(c(),{href:"/jobs?user=".concat(encodeURIComponent(e.service_account_user_id)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.jobCount>0?"bg-green-100 text-green-600 hover:bg-green-200 hover:text-green-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.jobCount," active job").concat(1!==e.jobCount?"s":""," for ").concat(e.token_name),children:e.jobCount})}),(0,r.jsx)(x.pj,{className:"truncate",children:e.created_at?(0,r.jsx)(v.Zg,{date:new Date(1e3*e.created_at)}):"Never"}),(0,r.jsx)(x.pj,{className:"truncate",children:e.last_used_at?(0,r.jsx)(v.Zg,{date:new Date(1e3*e.last_used_at)}):"Never"}),(0,r.jsx)(x.pj,{className:"truncate",children:e.expires_at?new Date(1e3*e.expires_at)<new Date?(0,r.jsx)("span",{className:"text-red-600",children:"Expired"}):(0,r.jsx)(v.Zg,{date:new Date(1e3*e.expires_at)}):"Never"}),(0,r.jsx)(x.pj,{children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[((null==t?void 0:t.role)==="admin"||e.creator_user_hash===(null==t?void 0:t.id))&&(0,r.jsx)(v.WH,{content:"Rotate token",className:"capitalize text-sm text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{s("cannot rotate service account tokens",()=>{b(e),m(!0)})},className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:(0,r.jsx)(N.Z,{className:"h-4 w-4"})})}),((null==t?void 0:t.role)==="admin"||e.creator_user_hash===(null==t?void 0:t.id))&&(0,r.jsx)(v.WH,{content:"Delete ".concat(e.token_name),className:"capitalize text-sm text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{s("cannot delete service account tokens",()=>{q(e),z(!0)})},className:"text-red-600 hover:text-red-800 font-medium inline-flex items-center",children:(0,r.jsx)(Z.Z,{className:"h-4 w-4"})})})]})})]},e.token_id))})]})})}),(0,r.jsx)(M.Vq,{open:o,onOpenChange:e=>{d(e),e||(et(null),l(null))},children:(0,r.jsxs)(M.cZ,{className:"sm:max-w-2xl",children:[(0,r.jsxs)(M.fK,{children:[(0,r.jsx)(M.$N,{children:"Create Service Account"}),(0,r.jsx)(M.Be,{children:"Create a new service account with an API token for programmatic access to SkyPilot."})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:es?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center mb-3",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-green-900",children:"⚠️ Service account created successfully - save this token now!"}),(0,r.jsx)(v.WH,{content:G?"Copied!":"Copy token",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>ep(es),className:"flex items-center text-green-600 hover:text-green-800 transition-colors duration-200 p-1 ml-2",children:G?(0,r.jsx)(R.Z,{className:"w-4 h-4"}):(0,r.jsx)(L.Z,{className:"w-4 h-4"})})})]}),(0,r.jsx)("p",{className:"text-sm text-green-700 mb-3",children:"This service account token will not be shown again. Please copy and store it securely."}),(0,r.jsx)("div",{className:"bg-white border border-green-300 rounded-md p-3",children:(0,r.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all block",children:es})})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Service Account Name"}),(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full",placeholder:"e.g., ci-pipeline, monitoring-system",value:K.token_name,onChange:e=>$({...K,token_name:e.target.value})})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Expiration (days)"}),(0,r.jsx)("input",{type:"number",className:"border rounded px-3 py-2 w-full",placeholder:"e.g., 30",min:"0",max:"365",value:K.expires_in_days||"",onChange:e=>$({...K,expires_in_days:e.target.value?parseInt(e.target.value):null})}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Leave empty or enter 0 to never expire. Maximum 365 days."})]})]})}),(0,r.jsx)(M.cN,{children:es?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:()=>{d(!1),et(null)},children:"Close"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{d(!1),et(null)},disabled:W,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:eg,disabled:W||!K.token_name.trim(),children:W?"Creating...":"Create Token"})]})})]})}),(0,r.jsx)(M.Vq,{open:T,onOpenChange:e=>{z(e),e||(q(null),l(null))},children:(0,r.jsxs)(M.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(M.fK,{children:[(0,r.jsx)(M.$N,{children:"Delete Service Account Token"}),(0,r.jsxs)(M.Be,{children:['Are you sure you want to delete the service account "',null==V?void 0:V.token_name,'"',(null==V?void 0:V.creator_user_hash)!==(null==t?void 0:t.id)&&(null==t?void 0:t.role)==="admin"?" owned by ".concat(null==V?void 0:V.creator_name):"","? This action cannot be undone and will immediately revoke access for any systems using this token."]})]}),(0,r.jsxs)(M.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{z(!1),q(null)},disabled:X,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-red-600 text-white hover:bg-red-700 h-10 px-4 py-2",onClick:ef,disabled:X,children:X?"Deleting...":"Delete Token"})]})]})}),(0,r.jsx)(M.Vq,{open:u,onOpenChange:e=>{m(e),e||(b(null),J(""),en(null),l(null))},children:(0,r.jsxs)(M.cZ,{className:"sm:max-w-2xl",children:[(0,r.jsxs)(M.fK,{children:[(0,r.jsx)(M.$N,{children:"Rotate Service Account Token"}),(0,r.jsxs)(M.Be,{children:['Rotate the service account token "',null==f?void 0:f.token_name,'"',(null==f?void 0:f.creator_user_hash)!==(null==t?void 0:t.id)&&(null==t?void 0:t.role)==="admin"?" owned by ".concat(null==f?void 0:f.creator_name):"",". This will generate a new token value and invalidate the current one."]})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:er?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center mb-3",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-green-900",children:"\uD83D\uDD04 Service account token rotated successfully - save this new token now!"}),(0,r.jsx)(v.WH,{content:G?"Copied!":"Copy token",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>ep(er),className:"flex items-center text-green-600 hover:text-green-800 transition-colors duration-200 p-1 ml-2",children:G?(0,r.jsx)(R.Z,{className:"w-4 h-4"}):(0,r.jsx)(L.Z,{className:"w-4 h-4"})})})]}),(0,r.jsx)("p",{className:"text-sm text-green-700 mb-3",children:"This new token replaces the old one. Please copy and store it securely. The old token is now invalid."}),(0,r.jsx)("div",{className:"bg-white border border-green-300 rounded-md p-3",children:(0,r.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all block",children:er})})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"New Expiration (days)"}),(0,r.jsx)("input",{type:"number",className:"border rounded px-3 py-2 w-full",placeholder:"Leave empty to preserve current expiration",min:"0",max:"365",value:H,onChange:e=>J(e.target.value)}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Leave empty to preserve current expiration. Enter number of days for new expiration, or enter 0 to set to never expire. Maximum 365 days."})]}),(0,r.jsx)("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:(0,r.jsx)("p",{className:"text-sm text-amber-700",children:"⚠️ Any systems using the current token will need to be updated with the new token."})})]})}),(0,r.jsx)(M.cN,{children:er?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-green-600 text-white hover:bg-green-700 h-10 px-4 py-2",onClick:()=>{m(!1),b(null),J(""),en(null)},children:"Close"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{m(!1),b(null),J(""),en(null)},disabled:j,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:eb,disabled:j,children:j?"Rotating...":"Rotate Token"})]})})]})})]})}K.propTypes={refreshInterval:l().number.isRequired,setLoading:l().func.isRequired,refreshDataRef:l().shape({current:l().func}).isRequired,checkPermissionAndAct:l().func.isRequired,roleLoading:l().bool.isRequired,onResetPassword:l().func.isRequired,onDeleteUser:l().func.isRequired,basicAuthEnabled:l().bool,currentUserRole:l().string,currentUserId:l().string}},12003:function(e,s,t){t.d(s,{j:function(){return l}});var r=t(90512);let n=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,a=r.W,l=(e,s)=>t=>{var r;if((null==s?void 0:s.variants)==null)return a(e,null==t?void 0:t.class,null==t?void 0:t.className);let{variants:l,defaultVariants:i}=s,o=Object.keys(l).map(e=>{let s=null==t?void 0:t[e],r=null==i?void 0:i[e];if(null===s)return null;let a=n(s)||n(r);return l[e][a]}),c=t&&Object.entries(t).reduce((e,s)=>{let[t,r]=s;return void 0===r||(e[t]=r),e},{});return a(e,o,null==s?void 0:null===(r=s.compoundVariants)||void 0===r?void 0:r.reduce((e,s)=>{let{class:t,className:r,...n}=s;return Object.entries(n).every(e=>{let[s,t]=e;return Array.isArray(t)?t.includes({...i,...c}[s]):({...i,...c})[s]===t})?[...e,t,r]:e},[]),null==t?void 0:t.class,null==t?void 0:t.className)}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3015],{23015:function(e,s,t){t.r(s),t.d(s,{ClusterJobs:function(){return K},ManagedJobs:function(){return Z},ManagedJobsTable:function(){return B},Status2Actions:function(){return H},filterJobsByName:function(){return J},filterJobsByPool:function(){return O},filterJobsByUser:function(){return W},filterJobsByWorkspace:function(){return U},statusGroups:function(){return z}});var a=t(85893),r=t(67294),l=t(11163),n=t(41664),i=t.n(n),c=t(55739),o=t(30803),d=t(37673),u=t(68764),h=t(36989),x=t(51214),m=t(68969),p=t(6378);class j{_generateFilterKey(e){let{allUsers:s=!0,nameMatch:t,userMatch:a,workspaceMatch:r,poolMatch:l,statuses:n}=e;return["allUsers:".concat(s),t?"name:".concat(t):"",a?"user:".concat(a):"",r?"workspace:".concat(r):"",l?"pool:".concat(l):"",n&&n.length>0?"statuses:".concat(n.sort().join(",")):""].filter(Boolean).join("|")||"default"}_getCacheStatus(e){let s=this.fullDataCache.get(e),t=Date.now();if(!s)return{isCached:!1,isFresh:!1,age:0,maxAge:12e4,hasData:!1};let a=t-s.timestamp;return{isCached:!0,isFresh:a<12e4,age:a,maxAge:12e4,hasData:s.jobs&&Array.isArray(s.jobs),data:s}}async getPaginatedJobs(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{page:s=1,limit:t=10,...a}=e,r=this._generateFilterKey(a);try{let e=this._getCacheStatus(r);if(e.isCached&&e.hasData){let l=e.data;if(!l.jobs||Array.isArray(l.jobs)&&0===l.jobs.length){if(!this.prefetching.has(r)){let e=this._loadFullDataset(a,r).catch(()=>{}).finally(()=>this.prefetching.delete(r));this.prefetching.set(r,e)}}else{let n=(s-1)*t,i=l.jobs.slice(n,n+t);if(!this.prefetching.has(r)&&(!e.isFresh||e.age>e.maxAge/2)){let e=this._loadFullDataset(a,r).catch(()=>{}).finally(()=>this.prefetching.delete(r));this.prefetching.set(r,e)}return{jobs:i,total:l.total,totalNoFilter:l.totalNoFilter||l.total,controllerStopped:l.controllerStopped,statusCounts:l.statusCounts||{},fromCache:!0,cacheStatus:e.isFresh?"local_cache_hit":"local_cache_stale_hit"}}}let l=await p.default.get(m.getManagedJobs,[{...a,page:s,limit:t}]),n=(null==l?void 0:l.jobs)||[],i="number"==typeof(null==l?void 0:l.total)?l.total:n.length,c=!!(null==l?void 0:l.controllerStopped);if(!this.prefetching.has(r)){let e=this._loadFullDataset(a,r).catch(e=>{console.warn("Background prefetch of full jobs failed:",e)}).finally(()=>{this.prefetching.delete(r)});this.prefetching.set(r,e)}return{jobs:n,total:i,totalNoFilter:(null==l?void 0:l.totalNoFilter)||i,controllerStopped:c,statusCounts:(null==l?void 0:l.statusCounts)||{},fromCache:!1,cacheStatus:"server_page_fetch"}}catch(e){return console.error("Error in getPaginatedJobs:",e),{jobs:[],total:0,totalNoFilter:0,controllerStopped:!1,statusCounts:{},fromCache:!1,cacheStatus:"error"}}}async _loadFullDataset(e,s){let t=await p.default.get(m.getManagedJobs,[e]);if(t&&t.__skipCache||t.controllerStopped||!t.jobs)return t;let a={jobs:t.jobs,total:t.jobs.length,totalNoFilter:t.totalNoFilter||t.jobs.length,controllerStopped:!1,statusCounts:t.statusCounts||{},timestamp:Date.now()};return this.fullDataCache.set(s,a),a}isDataLoading(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=this._generateFilterKey(e);return this.isLoading.has(s)||this.prefetching.has(s)}isDataCached(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=this._generateFilterKey(e),t=this._getCacheStatus(s);return t.isCached&&t.isFresh&&t.hasData}getCacheStatus(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=this._generateFilterKey(e);return this._getCacheStatus(s)}invalidateCache(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(e){let s=this._generateFilterKey(e);this.fullDataCache.delete(s),this.isLoading.delete(s),this.prefetching.delete(s)}else this.fullDataCache.clear(),this.isLoading.clear(),this.prefetching.clear();p.default.invalidateFunction(m.getManagedJobs)}getCacheStats(){let e={cachedFilters:Array.from(this.fullDataCache.keys()),loadingFilters:Array.from(this.isLoading.keys()),prefetchingFilters:Array.from(this.prefetching.keys()),cacheSize:this.fullDataCache.size,loadingCount:this.isLoading.size,prefetchingCount:this.prefetching.size};for(let[s,t]of(e.detailedStatus={},this.fullDataCache.entries())){let a=this._getCacheStatus(s);e.detailedStatus[s]={age:a.age,isFresh:a.isFresh,hasData:a.hasData,jobCount:t.jobs?t.jobs.length:0}}return e}constructor(){this.fullDataCache=new Map,this.isLoading=new Map,this.prefetching=new Map}}let f=new j;var g=t(23266),b=t(17324),v=t(53081),y=t(13626),w=t(23293),N=t(6521),k=t(16826),C=t(92128),S=t(94545),_=t(99307),L=t(20546),E=t(23001),R=t(88950);let D=(e,s)=>{let t={...e.query},a=[],r=[],l=[];s.map((e,s)=>{var t;a.push(null!==(t=e.property.toLowerCase())&&void 0!==t?t:""),r.push(e.operator),l.push(e.value)}),t.property=a,t.operator=r,t.value=l,e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},M=(e,s)=>{let t={...e.query},a=t.property,r=t.operator,l=t.value;if(void 0===a)return[];let n=[],i=Array.isArray(a)?a.length:1;if(1===i)n.push({property:s.get(a),operator:r,value:l});else for(let e=0;e<i;e++)n.push({property:s.get(a[e]),operator:r[e],value:l[e]});return n},F=e=>{var s,t;let{propertyList:l=[],valueList:n,setFilters:i,updateURLParams:c,placeholder:o="Filter items"}=e,d=(0,r.useRef)(null),u=(0,r.useRef)(null),[h,x]=(0,r.useState)(!1),[m,p]=(0,r.useState)(""),[j,f]=(0,r.useState)((null===(s=l[0])||void 0===s?void 0:s.value)||"status"),[g,b]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&d.current&&!d.current.contains(e.target)&&x(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]),(0,r.useEffect)(()=>{let e=[];n&&"object"==typeof n&&(e=n[j]||[]),""!==m.trim()&&(e=e.filter(e=>e&&e.toString().toLowerCase().includes(m.toLowerCase()))),b(e)},[j,n,m]);let v=e=>{let s=l.find(s=>s.value===e);return s?s.label:e},y=e=>{i(s=>{let t=[...s,{property:v(j),operator:":",value:e}];return c(t),t}),x(!1),p(""),d.current.focus()};return(0,a.jsxs)("div",{className:"flex flex-row border border-gray-300 rounded-md overflow-visible",children:[(0,a.jsx)("div",{className:"border-r border-gray-300 flex-shrink-0",children:(0,a.jsxs)(R.Ph,{onValueChange:f,value:j,children:[(0,a.jsx)(R.i4,{"aria-label":"Filter Property",className:"focus:ring-0 focus:ring-offset-0 border-none rounded-l-md rounded-r-none w-20 sm:w-24 md:w-32 h-8 text-xs sm:text-sm",children:(0,a.jsx)(R.ki,{placeholder:(null===(t=l[0])||void 0===t?void 0:t.label)||"Status"})}),(0,a.jsx)(R.Bw,{children:l.map((e,s)=>(0,a.jsx)(R.Ql,{value:e.value,children:e.label},"property-item-".concat(s)))})]})}),(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)("input",{type:"text",ref:d,placeholder:o,value:m,onChange:e=>{p(e.target.value),h||x(!0)},onFocus:()=>{x(!0)},onKeyDown:e=>{"Enter"===e.key&&""!==m.trim()?(i(e=>{let s=[...e,{property:v(j),operator:":",value:m}];return c(s),s}),p(""),x(!1)):"Escape"===e.key&&(x(!1),d.current.blur())},className:"h-8 w-full sm:w-96 px-3 pr-8 text-sm border-none rounded-l-none rounded-r-md focus:ring-0 focus:outline-none",autoComplete:"off"}),m&&(0,a.jsx)("button",{onClick:()=>{p(""),x(!1)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear filter",tabIndex:-1,children:(0,a.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),h&&g.length>0&&(0,a.jsx)("div",{ref:u,className:"absolute z-50 mt-1 w-full bg-white border border-gray-200 rounded-md shadow-lg max-h-60 overflow-y-auto",style:{zIndex:9999},children:g.map((e,s)=>(0,a.jsx)("div",{className:"px-3 py-2 cursor-pointer hover:bg-gray-50 text-sm ".concat(s!==g.length-1?"border-b border-gray-100":""),onClick:()=>y(e),children:(0,a.jsx)("span",{className:"text-sm text-gray-700",children:e})},"".concat(e,"-").concat(s)))})]})]})},I=e=>{let{filters:s=[],setFilters:t,updateURLParams:r}=e,l=e=>{t(s=>{let t=s.filter((s,t)=>t!==e);return r(t),t})};return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"flex items-center gap-4 py-2 px-2",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-content gap-2",children:[s.map((e,s)=>(0,a.jsx)(A,{filter:e,onRemove:()=>l(s)},"filteritem-".concat(s))),s.length>0&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("button",{onClick:()=>{r([]),t([])},className:"rounded-full px-4 py-1 text-sm text-gray-700 bg-gray-200 hover:bg-gray-300",children:"Clear filters"})})]})})})},A=e=>{let{filter:s,onRemove:t}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"flex items-center text-blue-600 bg-blue-100 px-1 py-1 rounded-full text-sm",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 px-2",children:[(0,a.jsx)("span",{children:"".concat(s.property," ")}),(0,a.jsx)("span",{children:"".concat(s.operator," ")}),(0,a.jsx)("span",{children:" ".concat(s.value)})]}),(0,a.jsx)("button",{onClick:()=>t(),className:"p-0.5 ml-1 transform text-gray-400 hover:text-gray-600 bg-blue-500 hover:bg-blue-600 rounded-full flex flex-col items-center",title:"Clear filter",children:(0,a.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"white",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:5,d:"M6 18L18 6M6 6l12 12"})})})]})})},z={active:["PENDING","RUNNING","RECOVERING","SUBMITTED","STARTING","CANCELLING"],finished:["SUCCEEDED","FAILED","CANCELLED","FAILED_SETUP","FAILED_PRECHECKS","FAILED_NO_RESOURCE","FAILED_CONTROLLER"]},P=[{label:"Name",value:"name"},{label:"User",value:"user"},{label:"Workspace",value:"workspace"},{label:"Pool",value:"pool"}];function J(e,s){if(!s||""===s.trim())return e;let t=s.toLowerCase().trim();return e.filter(e=>(e.name||"").toLowerCase().includes(t))}function U(e,s){return s&&"ALL_WORKSPACES"!==s?e.filter(e=>(e.workspace||"default").toLowerCase()===s.toLowerCase()):e}function W(e,s){return s&&"ALL_USERS"!==s?e.filter(e=>(e.user_hash||e.user)===s):e}function O(e,s){if(!s||""===s.trim())return e;let t=s.toLowerCase().trim();return e.filter(e=>(e.pool||"").toLowerCase().includes(t))}let T=e=>{if(!e)return"-";let s=e instanceof Date?e:new Date(1e3*e);return(0,a.jsx)(h.Zg,{date:s})};function Z(){let e=(0,l.useRouter)(),[s,t]=(0,r.useState)(!1),[n,c]=(0,r.useState)(!0),[o,d]=(0,r.useState)(!0),u=r.useRef(null),x=r.useRef(null),[j,g]=(0,r.useState)([]),[y,w]=(0,r.useState)([]),N=r.useCallback(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t(!0),!e&&o&&c(!0);try{let[e]=await Promise.all([p.default.get(m.vs,[{}])]);g(e.pools||[])}catch(e){console.error("Error fetching data:",e)}finally{t(!1),!e&&o&&(c(!1),d(!1))}},[o]);(0,r.useEffect)(()=>{N()},[N]);let k=s=>{D(e,s)},C=r.useCallback(()=>{let s=new Map;s.set("",""),s.set("status","Status"),s.set("name","Name"),s.set("user","User"),s.set("workspace","Workspace"),s.set("pool","Pool"),w(M(e,s))},[e,w]);return(0,r.useEffect)(()=>{e.isReady&&C()},[e.isReady,e.query.tab,C]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[(0,a.jsx)("div",{className:"text-base",children:(0,a.jsx)(i(),{href:"/jobs",className:"text-sky-blue hover:underline leading-none",children:"Managed Jobs"})}),(0,a.jsx)("div",{className:"w-full sm:w-auto",children:(0,a.jsx)(F,{propertyList:P,valueList:{},setFilters:w,updateURLParams:k,placeholder:"Filter jobs"})})]}),(0,a.jsx)(I,{filters:y,setFilters:w,updateURLParams:k}),(0,a.jsx)(B,{refreshInterval:h.yc,setLoading:t,refreshDataRef:u,filters:y,onRefresh:()=>{f.invalidateCache(),p.default.invalidate(m.vs,[{}]),p.default.invalidate(b.getWorkspaces),p.default.invalidate(v.R),u.current&&u.current(),x.current&&x.current()},poolsData:j,poolsLoading:n}),(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsx)(V,{refreshInterval:h.yc,setLoading:t,refreshDataRef:x})})]})}function B(e){let{refreshInterval:s,setLoading:t,refreshDataRef:l,filters:n,onRefresh:j,poolsData:b,poolsLoading:v}=e,[N,k]=(0,r.useState)([]),[R,D]=(0,r.useState)(0),[M,F]=(0,r.useState)(0),[I,A]=(0,r.useState)({key:null,direction:"ascending"}),[P,J]=(0,r.useState)(!1),[U,W]=(0,r.useState)(!0),[O,Z]=(0,r.useState)(1),[B,K]=(0,r.useState)(10),[V,Y]=(0,r.useState)(null),Q=(0,r.useRef)(null),[X,$]=(0,r.useState)([]),[ee,es]=(0,r.useState)({}),[et,ea]=(0,r.useState)({}),[er,el]=(0,r.useState)(!1),[en,ei]=(0,r.useState)(!1),[ec,eo]=(0,r.useState)(!1),[ed,eu]=(0,r.useState)("all"),[eh,ex]=(0,r.useState)(!0),[em,ep]=(0,r.useState)({isOpen:!1,title:"",message:"",onConfirm:null}),ej=(0,E.X)(),ef=(0,r.useRef)(0),eg=r.useMemo(()=>{if(!N||0===N.length)return!1;let e=new Set(N.map(e=>e.workspace||"default"));return e.size>1||1===e.size&&!e.has("default")},[N]),eb=r.useMemo(()=>b&&b.length>0,[b]),ev=async()=>{ep({isOpen:!0,title:"Restart Controller",message:"Are you sure you want to restart the controller?",onConfirm:async()=>{try{eo(!0),J(!0),await (0,m.Ce)("restartcontroller"),await ey()}catch(e){console.error("Error restarting controller:",e)}finally{eo(!1),J(!1)}}})},ey=r.useCallback(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=!1!==e.includeStatus,a=ef.current+1;ef.current=a,J(!0),t(!0);try{let e,t;let r=e=>{let s=(n||[]).find(s=>(s.property||"").toLowerCase()===e);return s&&s.value?String(s.value):void 0};X.length>0?t=X:eh?"active"===ed?t=z.active:"finished"===ed&&(t=z.finished):t=[];let l={allUsers:!0,nameMatch:r("name"),userMatch:r("user"),workspaceMatch:r("workspace"),poolMatch:r("pool"),statuses:t,page:O,limit:B},i=null;if(f.isDataCached(l),f.isDataLoading(l),s){let[s,t]=await Promise.all([f.getPaginatedJobs(l),p.default.get(g.getClusters)]);e=s,i=t}else e=await f.getPaginatedJobs(l);let{jobs:c=[],total:o=0,totalNoFilter:d=0,controllerStopped:u=!1,cacheStatus:h="unknown",statusCounts:x={}}=e||{},m=!1,j=!1;if(s&&i){let e=null==i?void 0:i.find(e=>(0,S.Ym)(e.cluster)),s=e?e.status:"NOT_FOUND";"STOPPED"==s&&u&&(m=!0),"LAUNCHING"==s&&(j=!0)}a===ef.current&&(k(c),D(o||0),F(d||0),el(!!m),ei(!!j),ea(x),W(!1))}catch(e){console.error("Error fetching data:",e),a===ef.current&&(k([]),el(!1),W(!1))}finally{a===ef.current&&(J(!1),t(!1))}},[t,n,O,B,X,eh,ed]);r.useEffect(()=>{l&&(l.current=ey)},[l,ey]);let ew=r.useRef(ey);r.useEffect(()=>{ew.current=ey},[ey]);let eN=r.useRef(!0);r.useEffect(()=>{ey({includeStatus:!0}),eN.current=!1},[ey]),r.useEffect(()=>{eN.current||ey({includeStatus:!1})},[O,ey]),r.useEffect(()=>{eN.current||ey({includeStatus:!0})},[n,B,ey]),r.useEffect(()=>{eN.current||ey({includeStatus:!0})},[ed,X,eh,ey]),(0,r.useEffect)(()=>{let e=setInterval(()=>{ew.current&&ew.current({includeStatus:!0})},s);return()=>{clearInterval(e)}},[s]),(0,r.useEffect)(()=>{Z(1)},[ed]),(0,r.useEffect)(()=>{Z(1)},[n,B]),(0,r.useEffect)(()=>{$([]),ex(!0)},[ed]);let ek=e=>{let s="ascending";I.key===e&&"ascending"===I.direction&&(s="descending"),A({key:e,direction:s})},eC=e=>I.key===e?"ascending"===I.direction?" ↑":" ↓":"";r.useMemo(()=>{let e=N||[];return{active:e.filter(e=>z.active.includes(e.status)).length,finished:e.filter(e=>z.finished.includes(e.status)).length}},[N]);let eS=e=>X.length>0?X.includes(e):"all"===ed||z[ed].includes(e),e_=r.useMemo(()=>N,[N]),eL=r.useMemo(()=>I.key?[...e_].sort((e,s)=>e[I.key]<s[I.key]?"ascending"===I.direction?-1:1:e[I.key]>s[I.key]?"ascending"===I.direction?1:-1:0):e_,[e_,I]),eE=(O-1)*B,eR=R>0?Math.ceil(R/B):0,eD=R>0?Math.min(eE+eL.length,R):0,eM=e=>{if(X.includes(e)){let s=X.filter(s=>s!==e);0===s.length?(ex(!0),$([])):($(s),ex(!1))}else $([...X,e]),ex(!1);Z(1)};return(0,r.useEffect)(()=>{es(et)},[et]),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"flex flex-col space-y-1 mb-1",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between text-sm mb-1",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center",children:[(0,a.jsx)("span",{className:"mr-2 text-sm font-medium",children:"Statuses:"}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 items-center",children:[!P&&0===M&&!U&&(0,a.jsx)("span",{className:"text-gray-500 mr-2",children:"No jobs found"}),Object.entries(ee).map(e=>{let[s,t]=e;return(0,a.jsxs)("button",{onClick:()=>eM(s),className:"px-3 py-0.5 rounded-full flex items-center space-x-2 ".concat(eS(s)||X.includes(s)?(0,_.Cl)(s):"bg-gray-50 text-gray-600 hover:bg-gray-100"),children:[(0,a.jsx)("span",{children:s}),(0,a.jsx)("span",{className:"text-xs ".concat(eS(s)||X.includes(s)?"bg-white/50":"bg-gray-200"," px-1.5 py-0.5 rounded"),children:t})]},s)}),M>0&&(0,a.jsxs)("div",{className:"flex items-center ml-2 gap-2",children:[(0,a.jsx)("span",{className:"text-gray-500",children:"("}),(0,a.jsx)("button",{onClick:()=>{r.startTransition(()=>{eu("all"),$([]),ex(!0),Z(1)})},className:"text-sm font-medium ".concat("all"===ed&&eh?"text-purple-700 underline":"text-gray-600 hover:text-purple-700 hover:underline"),children:"show all jobs"}),(0,a.jsx)("span",{className:"text-gray-500 mx-1",children:"|"}),(0,a.jsx)("button",{onClick:()=>{r.startTransition(()=>{eu("active"),$([]),ex(!0),Z(1)})},className:"text-sm font-medium ".concat("active"===ed&&eh?"text-green-700 underline":"text-gray-600 hover:text-green-700 hover:underline"),children:"show all active jobs"}),(0,a.jsx)("span",{className:"text-gray-500 mx-1",children:"|"}),(0,a.jsx)("button",{onClick:()=>{r.startTransition(()=>{eu("finished"),$([]),ex(!0),Z(1)})},className:"text-sm font-medium ".concat("finished"===ed&&eh?"text-blue-700 underline":"text-gray-600 hover:text-blue-700 hover:underline"),children:"show all finished jobs"}),(0,a.jsx)("span",{className:"text-gray-500",children:")"})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[P&&(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(c.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"ml-2 text-gray-500 text-sm",children:"Loading..."})]}),(0,a.jsxs)("button",{onClick:()=>{j&&j()},disabled:P,className:"text-sky-blue hover:text-sky-blue-bright flex items-center text-sm",children:[(0,a.jsx)(y.Z,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:"Refresh"})]})]})]})}),ej&&er&&0===eL.length&&!P&&!U&&(0,a.jsx)("div",{className:"mb-4 p-4 bg-gray-50 rounded-lg border",children:(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-3",children:[(0,a.jsxs)("p",{className:"text-gray-700 text-center text-sm",children:["Job controller stopped.",(0,a.jsx)("br",{}),"Restart to check status."]}),(0,a.jsx)(o.z,{variant:"outline",size:"sm",onClick:ev,className:"text-sky-blue hover:text-sky-blue-bright",disabled:P||ec,children:ec?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.Z,{size:12,className:"mr-2"}),"Restarting..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(w.Z,{className:"h-4 w-4 mr-2"}),"Restart"]})})]})}),(0,a.jsx)(d.Zb,{children:(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,a.jsxs)(u.iA,{className:"min-w-full",children:[(0,a.jsx)(u.xD,{children:(0,a.jsxs)(u.SC,{children:[(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ek("id"),children:["ID",eC("id")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ek("name"),children:["Name",eC("name")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ek("user"),children:["User",eC("user")]}),eg&&(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ek("workspace"),children:["Workspace",eC("workspace")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ek("submitted_at"),children:["Submitted",eC("submitted_at")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ek("job_duration"),children:["Duration",eC("job_duration")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ek("status"),children:["Status",eC("status")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ek("infra"),children:["Infra",eC("infra")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ek("cluster"),children:["Resources",eC("cluster")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ek("recoveries"),children:["Recoveries",eC("recoveries")]}),eb&&(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ek("pool"),children:["Worker Pool",eC("pool")]}),(0,a.jsx)(u.ss,{children:"Details"}),(0,a.jsx)(u.ss,{children:"Logs"})]})}),(0,a.jsx)(u.RM,{children:P&&U?(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:11+(eg?1:0)+(eb?1:0),className:"text-center py-6 text-gray-500",children:(0,a.jsxs)("div",{className:"flex justify-center items-center",children:[(0,a.jsx)(c.Z,{size:20,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading..."})]})})}):eL.length>0?(0,a.jsx)(a.Fragment,{children:eL.map(e=>(0,a.jsxs)(r.Fragment,{children:[(0,a.jsxs)(u.SC,{children:[(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/jobs/".concat(e.id),className:"text-blue-600",children:e.id})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/jobs/".concat(e.id),className:"text-blue-600",children:e.name})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(L.H,{username:e.user,userHash:e.user_hash})}),eg&&(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/workspaces",className:"text-gray-700 hover:text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,a.jsx)(u.pj,{children:T(e.submitted_at)}),(0,a.jsx)(u.pj,{children:(0,h.LU)(e.job_duration)}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(_.OE,{status:e.status})}),(0,a.jsx)(u.pj,{children:e.infra&&"-"!==e.infra?(0,a.jsx)(h.Md,{content:e.full_infra||e.infra,className:"text-sm text-muted-foreground",children:(0,a.jsxs)("span",{children:[(0,a.jsx)(i(),{href:"/infra",className:"text-blue-600 hover:underline",children:e.cloud||e.infra.split("(")[0].trim()}),e.infra.includes("(")&&(0,a.jsx)("span",{children:" "+(()=>{let s=x.MO.NAME_TRUNCATE_LENGTH,t=e.infra.substring(e.infra.indexOf("(")),a=t.substring(1,t.length-1);if(a.length<=s)return t;let r="".concat(a.substring(0,Math.floor((s-3)/2)),"...").concat(a.substring(a.length-Math.ceil((s-3)/2)));return"(".concat(r,")")})()})]})}):(0,a.jsx)("span",{children:e.infra||"-"})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(h.Md,{content:e.resources_str_full||e.resources_str,className:"text-sm text-muted-foreground",children:(0,a.jsx)("span",{children:e.resources_str})})}),(0,a.jsx)(u.pj,{children:e.recoveries}),eb&&(0,a.jsx)(u.pj,{children:(0,a.jsx)("div",{className:v?"blur-sm transition-all duration-300":"",children:v?"-":(0,h.os)(e.pool,e.pool_hash,b)})}),(0,a.jsx)(u.pj,{children:e.details?(0,a.jsx)(G,{text:e.details,rowId:e.id,expandedRowId:V,setExpandedRowId:Y}):"-"}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(H,{jobParent:"/jobs",jobId:e.id,managed:!0,workspace:e.workspace})})]}),V===e.id&&(0,a.jsx)(q,{text:e.details,colSpan:11+(eg?1:0)+(eb?1:0),innerRef:Q})]},e.task_job_id))}):(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:11+(eg?1:0)+(eb?1:0),className:"text-center py-6",children:(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[en&&(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-2",children:[(0,a.jsx)("p",{className:"text-gray-700",children:"The managed job controller is launching. It will be ready shortly."}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(c.Z,{size:12,className:"mr-2"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Launching..."})]})]}),!er&&!en&&(0,a.jsx)("p",{className:"text-gray-500",children:"No active jobs"}),!ej&&er&&(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-3 px-4",children:[(0,a.jsx)("p",{className:"text-gray-700 text-center text-sm sm:text-base max-w-md",children:"The managed job controller has been stopped. Restart to check the latest job status."}),(0,a.jsx)(o.z,{variant:"outline",size:"sm",onClick:ev,className:"text-sky-blue hover:text-sky-blue-bright",disabled:P||ec,children:ec?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.Z,{size:12,className:"mr-2"}),"Restarting..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(w.Z,{className:"h-4 w-4 mr-2"}),"Restart Controller"]})})]})]})})})})]})})}),(0,a.jsx)("div",{className:"flex justify-end items-center py-2 px-4 text-sm text-gray-700",children:(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("span",{className:"mr-2",children:"Rows per page:"}),(0,a.jsxs)("div",{className:"relative inline-block",children:[(0,a.jsxs)("select",{value:B,onChange:e=>{K(parseInt(e.target.value,10)),Z(1)},className:"py-1 pl-2 pr-6 appearance-none outline-none cursor-pointer border-none bg-transparent",style:{minWidth:"40px"},children:[(0,a.jsx)("option",{value:10,children:"10"}),(0,a.jsx)("option",{value:30,children:"30"}),(0,a.jsx)("option",{value:50,children:"50"}),(0,a.jsx)("option",{value:100,children:"100"}),(0,a.jsx)("option",{value:200,children:"200"})]}),(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-500 absolute right-0 top-1/2 transform -translate-y-1/2 pointer-events-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),(0,a.jsx)("div",{children:R>0?"".concat(eE+1," – ").concat(eD," of ").concat(R):"0 – 0 of 0"}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{Z(e=>Math.max(e-1,1))},disabled:1===O||!eL||0===eL.length,className:"text-gray-500 h-8 w-8 p-0",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-left",children:(0,a.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,a.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{eR>0&&O<eR&&Z(e=>e+1)},disabled:0===eR||O>=eR||!eL||0===eL.length,className:"text-gray-500 h-8 w-8 p-0",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-right",children:(0,a.jsx)("path",{d:"M9 18l6-6-6-6"})})})]})]})}),(0,a.jsx)(C.cV,{isOpen:em.isOpen,onClose:()=>ep({...em,isOpen:!1}),onConfirm:em.onConfirm,title:em.title,message:em.message,confirmClassName:"bg-blue-600 hover:bg-blue-700 text-white"})]})}function H(e){let{withLabel:s=!1,jobParent:t,jobId:r,managed:n,workspace:i="default"}=e,c=(0,l.useRouter)(),o=(e,s)=>{e.preventDefault(),e.stopPropagation(),c.push({pathname:"".concat(t,"/").concat(r),query:{tab:s}})},d=function(e){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e.preventDefault(),e.stopPropagation(),n)(0,m.jh)({jobId:parseInt(r),controller:s});else{let e=t.match(/\/clusters\/(.+)/);if(e){let s=e[1];(0,g.GH)({clusterName:s,jobIds:[r],workspace:i})}}};return(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(h.WH,{content:"View Job Logs",className:"capitalize text-sm text-muted-foreground",children:(0,a.jsxs)("button",{onClick:e=>o(e,"logs"),className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center h-8",children:[(0,a.jsx)(N.Z,{className:"w-4 h-4"}),s&&(0,a.jsx)("span",{className:"ml-1.5",children:"Logs"})]})},"logs"),(0,a.jsx)(h.WH,{content:"Download Job Logs",className:"capitalize text-sm text-muted-foreground",children:(0,a.jsxs)("button",{onClick:e=>d(e,!1),className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center h-8",children:[(0,a.jsx)(k.Z,{className:"w-4 h-4"}),s&&(0,a.jsx)("span",{className:"ml-1.5",children:"Download"})]})},"downloadlogs")]})}function K(e){let{clusterName:s,clusterJobData:t,loading:l,refreshClusterJobsOnly:n,userFilter:x=null,nameFilter:m=null,workspace:p="default"}=e,[j,f]=(0,r.useState)(null),[g,b]=(0,r.useState)({key:null,direction:"ascending"}),[v,w]=(0,r.useState)(1),[N,k]=(0,r.useState)(10),C=(0,r.useRef)(null),[S,E]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=e=>{j&&C.current&&!C.current.contains(e.target)&&f(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[j]);let R=r.useMemo(()=>{let e=t||[];return x&&"ALL_USERS"!==x&&(e=W(e,x)),m&&(e=J(e,m)),e},[t,x,m]);(0,r.useEffect)(()=>{JSON.stringify(t)!==JSON.stringify(S)&&E(t)},[t,S]);let D=r.useMemo(()=>g.key?[...R].sort((e,s)=>e[g.key]<s[g.key]?"ascending"===g.direction?-1:1:e[g.key]>s[g.key]?"ascending"===g.direction?1:-1:0):R,[R,g]),M=e=>{let s="ascending";g.key===e&&"ascending"===g.direction&&(s="descending"),b({key:e,direction:s})},F=e=>g.key===e?"ascending"===g.direction?" ↑":" ↓":"",I=Math.ceil(D.length/N),A=(v-1)*N,z=A+N,P=D.slice(A,z);return(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)(d.Zb,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Cluster Jobs"}),(0,a.jsx)("div",{className:"flex items-center",children:n&&(0,a.jsxs)("button",{onClick:n,disabled:l,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center text-sm ml-2",children:[(0,a.jsx)(y.Z,{className:"w-4 h-4 mr-1"}),"Refresh Jobs"]})})]}),(0,a.jsxs)(u.iA,{children:[(0,a.jsx)(u.xD,{children:(0,a.jsxs)(u.SC,{children:[(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("id"),children:["ID",F("id")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("job"),children:["Name",F("job")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("user"),children:["User",F("user")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("submitted_at"),children:["Submitted",F("submitted_at")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("job_duration"),children:["Duration",F("job_duration")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("status"),children:["Status",F("status")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("resources"),children:["Resources",F("resources")]}),(0,a.jsx)(u.ss,{className:"whitespace-nowrap",children:"Logs"})]})}),(0,a.jsx)(u.RM,{children:l?(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:8,className:"text-center py-12 text-gray-500",children:(0,a.jsxs)("div",{className:"flex justify-center items-center",children:[(0,a.jsx)(c.Z,{size:24,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading cluster jobs..."})]})})}):P.length>0?P.map(e=>(0,a.jsxs)(r.Fragment,{children:[(0,a.jsxs)(u.SC,{className:j===e.id?"selected-row":"",children:[(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/clusters/".concat(s,"/").concat(e.id),className:"text-blue-600",children:e.id})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/clusters/".concat(s,"/").concat(e.id),className:"text-blue-600",children:(0,a.jsx)(G,{text:e.job||"Unnamed job",rowId:e.id,expandedRowId:j,setExpandedRowId:f})})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(L.H,{username:e.user,userHash:e.user_hash})}),(0,a.jsx)(u.pj,{children:T(e.submitted_at)}),(0,a.jsx)(u.pj,{children:(0,h.LU)(e.job_duration)}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(_.OE,{status:e.status})}),(0,a.jsx)(u.pj,{children:e.resources}),(0,a.jsx)(u.pj,{className:"flex content-center items-center",children:(0,a.jsx)(H,{jobParent:"/clusters/".concat(s),jobId:e.id,managed:!1,workspace:p})})]}),j===e.id&&(0,a.jsx)(q,{text:e.job||"Unnamed job",colSpan:8,innerRef:C})]},e.id)):(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:8,className:"text-center py-6 text-gray-500",children:"No jobs found"})})})]})]}),D&&D.length>0&&(0,a.jsx)("div",{className:"flex justify-end items-center py-2 px-4 text-sm text-gray-700",children:(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("span",{className:"mr-2",children:"Rows per page:"}),(0,a.jsxs)("div",{className:"relative inline-block",children:[(0,a.jsxs)("select",{value:N,onChange:e=>{k(parseInt(e.target.value,10)),w(1)},className:"py-1 pl-2 pr-6 appearance-none outline-none cursor-pointer border-none bg-transparent",style:{minWidth:"40px"},children:[(0,a.jsx)("option",{value:5,children:"5"}),(0,a.jsx)("option",{value:10,children:"10"}),(0,a.jsx)("option",{value:20,children:"20"}),(0,a.jsx)("option",{value:50,children:"50"})]}),(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-500 absolute right-0 top-1/2 transform -translate-y-1/2 pointer-events-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),(0,a.jsxs)("div",{children:[A+1," – ",Math.min(z,D.length)," of"," ",D.length]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{w(e=>Math.max(e-1,1))},disabled:1===v,className:"text-gray-500 h-8 w-8 p-0",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-left",children:(0,a.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,a.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{w(e=>Math.min(e+1,I))},disabled:v===I||0===I,className:"text-gray-500 h-8 w-8 p-0",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-right",children:(0,a.jsx)("path",{d:"M9 18l6-6-6-6"})})})]})]})})]})}function q(e){let{text:s,colSpan:t,innerRef:r}=e;return(0,a.jsx)(u.SC,{className:"expanded-details",children:(0,a.jsx)(u.pj,{colSpan:t,children:(0,a.jsx)("div",{className:"p-4 bg-gray-50 rounded-md border border-gray-200",ref:r,children:(0,a.jsx)("div",{className:"flex justify-between items-start",children:(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-gray-900",children:"Full Details"}),(0,a.jsx)("p",{className:"mt-1 text-sm text-gray-700",style:{whiteSpace:"pre-wrap"},children:s})]})})})})})}function G(e){let{text:s,rowId:t,expandedRowId:l,setExpandedRowId:n}=e,i=s||"",c=i.length>50,o=l===t,d=c?"".concat(i.substring(0,50)):i,u=(0,r.useRef)(null);return(0,a.jsxs)("div",{className:"truncated-details relative max-w-full flex items-center",children:[(0,a.jsx)("span",{className:"truncate",children:d}),c&&(0,a.jsx)("button",{ref:u,type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),n(o?null:t)},className:"text-blue-600 hover:text-blue-800 font-medium ml-1 flex-shrink-0","data-button-type":"show-more-less",children:o?"... show less":"... show more"})]})}function V(e){let{refreshInterval:s,setLoading:t,refreshDataRef:l}=e,[n,o]=(0,r.useState)([]),[x,j]=(0,r.useState)({key:null,direction:"ascending"}),[f,g]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!0),[y,w]=(0,r.useState)(1),[N,k]=(0,r.useState)(10),C=r.useCallback(async()=>{g(!0),t(!0);try{let{pools:e=[]}=await p.default.get(m.vs,[{}])||{};o(e),v(!1)}catch(e){console.error("Error fetching pools data:",e),o([]),v(!1)}finally{g(!1),t(!1)}},[t]);r.useEffect(()=>{l&&(l.current=C)},[l,C]),(0,r.useEffect)(()=>{o([]);let e=!0;C();let t=setInterval(()=>{e&&C()},s);return()=>{e=!1,clearInterval(t)}},[s,C]);let S=e=>{let s="ascending";x.key===e&&"ascending"===x.direction&&(s="descending"),j({key:e,direction:s})},L=e=>x.key===e?"ascending"===x.direction?" ↑":" ↓":"",E=r.useMemo(()=>x.key?[...n].sort((e,s)=>e[x.key]<s[x.key]?"ascending"===x.direction?-1:1:e[x.key]>s[x.key]?"ascending"===x.direction?1:-1:0):n,[n,x]),R=Math.ceil(E.length/N),D=(y-1)*N,M=D+N,F=E.slice(D,M),I=e=>{if(!e||!e.replica_info||0===e.replica_info.length)return"0 (target: 0)";let s=e.replica_info.filter(e=>"READY"===e.status).length,t=e.target_num_replicas||0;return"".concat(s," (target: ").concat(t,")")},A=e=>{let{jobCounts:s}=e;return(0,a.jsx)(h.x9,{jobCounts:s,getStatusStyle:_.Cl})},z=e=>{let{replicaInfo:s}=e;return(0,a.jsx)(h.Kl,{replicaInfo:s})};return(0,a.jsxs)(d.Zb,{children:[(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,a.jsxs)(u.iA,{className:"min-w-full table-fixed",children:[(0,a.jsx)(u.xD,{children:(0,a.jsxs)(u.SC,{children:[(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-32",onClick:()=>S("name"),children:["Pool",L("name")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-40",onClick:()=>S("job_counts"),children:["Jobs",L("job_counts")]}),(0,a.jsx)(u.ss,{className:"whitespace-nowrap w-20",children:"Workers"}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-36",onClick:()=>S("requested_resources_str"),children:["Worker Details",L("requested_resources_str")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-40",onClick:()=>S("requested_resources_str"),children:["Worker Resources",L("requested_resources_str")]})]})}),(0,a.jsx)(u.RM,{children:f&&b?(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:5,className:"text-center py-6 text-gray-500",children:(0,a.jsxs)("div",{className:"flex justify-center items-center",children:[(0,a.jsx)(c.Z,{size:20,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading..."})]})})}):F.length>0?F.map(e=>(0,a.jsxs)(u.SC,{children:[(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/jobs/pools/".concat(e.name),className:"text-blue-600 hover:text-blue-800",children:e.name})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(A,{jobCounts:e.jobCounts})}),(0,a.jsx)(u.pj,{children:I(e)}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(z,{replicaInfo:e.replica_info})}),(0,a.jsx)(u.pj,{children:e.requested_resources_str||"-"})]},e.name)):(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:5,className:"text-center py-6 text-gray-500",children:"No pools found"})})})]})}),F.length>0&&R>1&&(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-200",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{className:"text-sm text-gray-700",children:"Rows per page:"}),(0,a.jsxs)("select",{value:N,onChange:e=>{k(parseInt(e.target.value,10)),w(1)},className:"border border-gray-300 rounded px-2 py-1 text-sm",children:[(0,a.jsx)("option",{value:5,children:"5"}),(0,a.jsx)("option",{value:10,children:"10"}),(0,a.jsx)("option",{value:25,children:"25"}),(0,a.jsx)("option",{value:50,children:"50"})]})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsxs)("span",{className:"text-sm text-gray-700",children:[D+1,"-",Math.min(M,E.length)," of"," ",E.length]}),(0,a.jsx)("button",{onClick:()=>{w(e=>Math.max(e-1,1))},disabled:1===y,className:"px-2 py-1 text-sm border border-gray-300 rounded disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50",children:"Previous"}),(0,a.jsx)("button",{onClick:()=>{w(e=>Math.min(e+1,R))},disabled:y===R,className:"px-2 py-1 text-sm border border-gray-300 rounded disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50",children:"Next"})]})]})]})}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3294],{53294:function(e,s,t){t.r(s),t.d(s,{ContextDetails:function(){return D},GPUs:function(){return E},InfrastructureSection:function(){return I}});var a=t(85893),l=t(67294),r=t(55739);t(6135);var n=t(26409),o=t(98418),i=t(13626),c=t(23001),d=t(17853),m=t(32045),u=t(23266),x=t(68969),h=t(29326),g=t(50326),p=t(30803),f=t(42557),y=t(36185),j=t(69123);function b(e){let{isOpen:s,onClose:t,onSave:n,poolData:o=null,isLoading:i=!1}=e,[c,d]=(0,l.useState)(""),[m,u]=(0,l.useState)(""),[x,b]=(0,l.useState)("ubuntu"),[N,v]=(0,l.useState)(null),[w,S]=(0,l.useState)(""),[_,C]=(0,l.useState)({}),k=null!==o;(0,l.useEffect)(()=>{if(k&&o){var e,s,t;d(o.name||""),u(((null===(e=o.config)||void 0===e?void 0:e.hosts)||[]).join("\n")),b((null===(s=o.config)||void 0===s?void 0:s.user)||"ubuntu"),S((null===(t=o.config)||void 0===t?void 0:t.password)||"")}else d(""),u(""),b("ubuntu"),v(null),S("");C({})},[k,o]);let P=()=>{let e={};return c.trim()||(e.poolName="Pool name is required"),m.trim()||(e.hosts="At least one host is required"),x.trim()||(e.sshUser="SSH user is required"),N||w||(e.auth="Either SSH key file or password is required"),C(e),0===Object.keys(e).length},U=async()=>{if(!P())return;let e={hosts:m.split("\n").map(e=>e.trim()).filter(e=>e.length>0),user:x};try{if(N){let s=N.name;await (0,h.hY)(s,N),e.identity_file="~/.sky/ssh_keys/".concat(s)}w&&(e.password=w),n(c,e)}catch(e){console.error("Failed to upload SSH key:",e),C({..._,keyUpload:"Failed to upload SSH key"})}},I=()=>{i||t()};return(0,a.jsx)(g.Vq,{open:s,onOpenChange:I,children:(0,a.jsxs)(g.cZ,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,a.jsx)(g.fK,{children:(0,a.jsx)(g.$N,{children:k?"Edit SSH Node Pool: ".concat(null==o?void 0:o.name):"Add SSH Node Pool"})}),(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(y._,{htmlFor:"poolName",children:"Pool Name"}),(0,a.jsx)(f.I,{id:"poolName",placeholder:"my-ssh-cluster",value:c,onChange:e=>d(e.target.value),disabled:k,className:"placeholder:text-gray-500 ".concat(_.poolName?"border-red-500":"")}),_.poolName&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:_.poolName})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(y._,{htmlFor:"hosts",children:"Hosts (one per line)"}),(0,a.jsx)(j.g,{id:"hosts",placeholder:"192.168.1.10\n192.168.1.11\nhostname.example.com",value:m,onChange:e=>u(e.target.value),rows:6,className:"placeholder:text-gray-500 ".concat(_.hosts?"border-red-500":"")}),_.hosts&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:_.hosts})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(y._,{htmlFor:"sshUser",children:"SSH User"}),(0,a.jsx)(f.I,{id:"sshUser",placeholder:"ubuntu",value:x,onChange:e=>b(e.target.value),className:"placeholder:text-gray-500 ".concat(_.sshUser?"border-red-500":"")}),_.sshUser&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:_.sshUser})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(y._,{htmlFor:"keyFile",children:"SSH Private Key File"}),(0,a.jsx)(f.I,{id:"keyFile",type:"file",accept:".pem,.key,id_rsa,id_ed25519",onChange:e=>{var s;return v((null===(s=e.target.files)||void 0===s?void 0:s[0])||null)},className:"border-0 bg-transparent p-0 shadow-none focus:ring-0 file:mr-2 file:text-sm file:py-1 file:px-3 file:border file:border-gray-300 file:rounded file:bg-gray-50 hover:file:bg-gray-100 file:cursor-pointer"}),_.keyUpload&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:_.keyUpload})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(y._,{htmlFor:"password",children:"Password (optional, if sudo requires a password)"}),(0,a.jsx)(f.I,{id:"password",type:"password",placeholder:"Leave empty if using passwordless sudo",value:w,onChange:e=>S(e.target.value),className:"placeholder:text-gray-500"})]}),_.auth&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:_.auth})]}),(0,a.jsxs)(g.cN,{children:[(0,a.jsx)(p.z,{variant:"outline",onClick:I,disabled:i,children:"Cancel"}),(0,a.jsx)(p.z,{onClick:U,disabled:i,className:"bg-blue-600 hover:bg-blue-700 text-white disabled:bg-gray-300 disabled:text-gray-500",children:i?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Z,{size:16,className:"mr-2"}),"Saving..."]}):k?"Update Pool":"Create Pool"})]})]})})}var N=t(6378),v=t(36856),w=t(51214),S=t(11163),_=t(41664),C=t.n(_),k=t(36989);t(37673);let P=w.nb.REFRESH_INTERVAL,U=w.MO.NAME_TRUNCATE_LENGTH;function I(e){let{title:s,isLoading:t,isDataLoaded:l,contexts:n,gpus:o,groupedPerContextGPUs:i,groupedPerNodeGPUs:c,handleContextClick:d,contextStats:m={},jobsData:u={},isJobsDataLoading:x=!0,isSSH:h=!1,actionButton:g=null,contextWorkspaceMap:p={}}=e,f=n||[];return t&&0===f.length?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold mb-4",children:s}),(0,a.jsxs)("div",{className:"flex items-center justify-center py-6",children:[(0,a.jsx)(r.Z,{size:24,className:"mr-3"}),(0,a.jsxs)("span",{className:"text-gray-500",children:["Loading ",s,"..."]})]})]})}):l&&0===f.length?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:s}),g]}),(0,a.jsxs)("p",{className:"text-sm text-gray-500",children:["No ",s," found or ",s," is not configured."]})]})}):f.length>0?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:s}),(0,a.jsxs)("span",{className:"ml-2 px-2 py-0.5 bg-blue-100 text-blue-800 rounded-full text-xs font-medium",children:[f.length," ",1===f.length?h?"pool":"context":h?"pools":"contexts"]})]}),g]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm bg-white",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4",children:h?"Node Pool":"Context"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"Clusters"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"Jobs"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"Nodes"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4",children:"GPU Types"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"#GPUs"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200 ".concat(f.length>5?"max-h-[250px] overflow-y-auto block":""),children:f.map(e=>{var s,t;let n=i[e]||[],o=c[e]||[],g=n.reduce((e,s)=>e+(s.gpu_total||0),0),f=h?"ssh/".concat(e.replace(/^ssh-/,"")):"kubernetes/".concat(e),y=m[f]||{clusters:0,jobs:0},j=Object.keys(m).length>0&&m[f]||l,b=i&&Object.keys(i).length>0||l,N=c&&Object.keys(c).length>0||l,v=b?Object.keys(n.reduce((e,s)=>(e[s.gpu_name]=(e[s.gpu_name]||0)+(s.gpu_total||0),e),{})).join(", "):null,w=h?e.replace(/^ssh-/,""):e,S=p[e]||[],_=S.length>0?" (".concat(S.join(", "),")"):"";return(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"p-3",children:(0,a.jsx)(k.Md,{content:"".concat(w).concat(_),className:"text-sm text-muted-foreground",children:(0,a.jsxs)("span",{className:"text-blue-600 hover:underline cursor-pointer",onClick:()=>d(e),children:[w.length>U?"".concat(w.substring(0,Math.floor((U-3)/2)),"...").concat(w.substring(w.length-Math.ceil((U-3)/2))):w,_&&(0,a.jsx)("span",{className:"text-xs text-gray-500 ml-1",children:_})]})})}),(0,a.jsx)("td",{className:"p-3",children:j?y.clusters>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded text-xs font-medium",children:y.clusters}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"}):(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)(r.Z,{size:12})})}),(0,a.jsx)("td",{className:"p-3",children:x?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:(0,a.jsx)(r.Z,{size:12})}):(null===(s=u[f])||void 0===s?void 0:s.jobs)?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-green-100 text-green-800 rounded text-xs font-medium",children:null===(t=u[f])||void 0===t?void 0:t.jobs}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"})}),(0,a.jsx)("td",{className:"p-3",children:N?(0,a.jsx)("span",{className:0===o.length?"text-gray-400":"",title:0===o.length?"Context may be unavailable or timed out":"",children:0===o.length?"0*":o.length}):(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)(r.Z,{size:16})})}),(0,a.jsx)("td",{className:"p-3",children:b?v||"-":(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)(r.Z,{size:16})})}),(0,a.jsx)("td",{className:"p-3",children:b?(0,a.jsx)("span",{className:0===g&&0===o.length?"text-gray-400":"",title:0===g&&0===o.length?"Context may be unavailable or timed out":"",children:0===g&&0===o.length?"0*":g}):(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)(r.Z,{size:16})})})]},e)})})]})})}),o&&o.length>0&&(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm bg-white",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsxs)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4 whitespace-nowrap",children:["GPU",(0,a.jsxs)("span",{className:"ml-2 px-2 py-0.5 bg-green-100 text-green-800 rounded-full text-xs font-medium whitespace-nowrap",children:[o.reduce((e,s)=>e+s.gpu_free,0)," ","of"," ",o.reduce((e,s)=>e+s.gpu_total,0)," ","free"]})]}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4",children:"Requestable"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/2",children:(0,a.jsx)("div",{className:"flex items-center",children:(0,a.jsx)("span",{children:"Utilization"})})})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200 ".concat(o.length>5?"max-h-[250px] overflow-y-auto block":""),children:o.map(e=>{let s=e.gpu_total-e.gpu_free,t=e.gpu_total>0?e.gpu_free/e.gpu_total*100:0,l=e.gpu_total>0?s/e.gpu_total*100:0,r=i?Object.values(i).flat().filter(s=>s.gpu_name===e.gpu_name&&(h?s.context.startsWith("ssh-"):!s.context.startsWith("ssh-"))).map(e=>e.gpu_requestable_qty_per_node).filter((e,s,t)=>t.indexOf(e)===s).join(", "):"-";return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"p-3 font-medium w-24 whitespace-nowrap",children:e.gpu_name}),(0,a.jsxs)("td",{className:"p-3 text-xs text-gray-600",children:[r||"-"," / node"]}),(0,a.jsx)("td",{className:"p-3 w-2/3",children:(0,a.jsx)("div",{className:"flex items-center gap-3",children:(0,a.jsxs)("div",{className:"flex-1 bg-gray-100 rounded-md h-5 flex overflow-hidden shadow-sm min-w-[100px] w-full",children:[l>0&&(0,a.jsx)("div",{style:{width:"".concat(l,"%")},className:"bg-yellow-500 h-full flex items-center justify-center text-white text-xs font-medium",children:l>15&&"".concat(s," used")}),t>0&&(0,a.jsx)("div",{style:{width:"".concat(t,"%")},className:"bg-green-700 h-full flex items-center justify-center text-white text-xs font-medium",children:t>15&&"".concat(e.gpu_free," free")})]})})})]},e.gpu_name)})})]})})})]})]})}):null}function D(e){let{contextName:s,gpusInContext:t,nodesInContext:n}=e,o=s.startsWith("ssh-"),[i,c]=(0,l.useState)([]),[m,u]=(0,l.useState)("$__all"),[x,h]=(0,l.useState)({from:"now-1h",to:"now"}),[g,p]=(0,l.useState)(!1),[f,y]=(0,l.useState)(!1);(0,l.useEffect)(()=>{(async()=>{y(await (0,d.TO)())})()},[]);let j=(0,l.useCallback)(async()=>{if(f){p(!0);try{let e=(0,d.ki)(),t="in-cluster"===s?"^$":s,a="query="+encodeURIComponent('group by (node) (DCGM_FI_DEV_GPU_TEMP{cluster=~"'.concat(t,'"} or label_replace(amd_gpu_gfx_activity{cluster=~"').concat(t,'"}, "node", "$1", "hostname", "(.*)"))')),l="/api/datasources/proxy/1/api/v1/query?".concat(a);try{let s=await fetch("".concat(e).concat(l),{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(s.ok){let e=await s.json();if(e.data&&e.data.result&&e.data.result.length>0){let s=e.data.result.map(e=>e.metric.node).filter(Boolean).sort();c(s),console.log("Successfully fetched hosts for cluster ".concat(t||"in-cluster",":"),s)}else console.log("No nodes found for this cluster"),c([])}else console.log("HTTP ".concat(s.status," from ").concat(l,": ").concat(s.statusText)),c([])}catch(e){console.log("Failed to fetch from ".concat(l,":"),e),c([])}}catch(e){console.error("Error fetching available hosts:",e),c([])}finally{p(!1)}}},[f,s]);(0,l.useEffect)(()=>{f&&n&&n.length>0&&j()},[n,f,j]);let b=e=>{let t=(0,d.ki)(),a="in-cluster"===s?"^$":s;return"".concat(t,"/d-solo/skypilot-dcgm-cluster-dashboard/skypilot-dcgm-kubernetes-cluster-dashboard?orgId=1&timezone=browser&var-datasource=prometheus&var-host=").concat(encodeURIComponent(m),"&var-gpu=$__all&var-cluster=").concat(encodeURIComponent(a),"&refresh=5s&theme=light&from=").concat(encodeURIComponent(x.from),"&to=").concat(encodeURIComponent(x.to),"&panelId=").concat(e,"&__feature.dashboardSceneSolo")},N=e=>{h({"15m":{from:"now-15m",to:"now"},"1h":{from:"now-1h",to:"now"},"6h":{from:"now-6h",to:"now"},"24h":{from:"now-24h",to:"now"},"7d":{from:"now-7d",to:"now"}}[e])};return(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm h-full",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,a.jsx)("h4",{className:"text-lg font-semibold",children:"Available GPUs"})}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mb-6",children:t.map(e=>{let s=e.gpu_total-e.gpu_free,t=e.gpu_total>0?e.gpu_free/e.gpu_total*100:0,l=e.gpu_total>0?s/e.gpu_total*100:0;return(0,a.jsxs)("div",{className:"p-3 bg-gray-50 rounded-md border border-gray-200 shadow-sm",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-1.5 flex-wrap",children:[(0,a.jsxs)("div",{className:"font-medium text-gray-800 text-sm",children:[e.gpu_name,(0,a.jsxs)("span",{className:"text-xs text-gray-500 ml-2",children:["(Requestable: ",e.gpu_requestable_qty_per_node," / node)"]})]}),(0,a.jsxs)("span",{className:"text-xs font-medium",children:[e.gpu_free," free / ",e.gpu_total," total"]})]}),(0,a.jsxs)("div",{className:"w-full bg-gray-100 rounded-md h-4 flex overflow-hidden shadow-sm",children:[l>0&&(0,a.jsx)("div",{style:{width:"".concat(l,"%")},className:"bg-yellow-500 h-full flex items-center justify-center text-white text-xs",children:l>15&&"".concat(s," used")}),t>0&&(0,a.jsx)("div",{style:{width:"".concat(t,"%")},className:"bg-green-700 h-full flex items-center justify-center text-white text-xs",children:t>15&&"".concat(e.gpu_free," free")})]})]},e.gpu_name)})}),n&&n.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{className:"text-lg font-semibold mb-4",children:"Nodes"}),(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-100",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600",children:"Node"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600",children:"IP Address"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600",children:"GPU"}),(0,a.jsx)("th",{className:"p-3 text-right font-medium text-gray-600",children:"Availability"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:n.map((e,s)=>(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-gray-700",children:e.node_name}),(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-gray-700",children:e.ip_address||"-"}),(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-gray-700",children:e.gpu_name}),(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-right text-gray-700",children:"".concat(e.gpu_free," of ").concat(e.gpu_total," free")})]},"".concat(e.node_name,"-").concat(s)))})]})})]}),f&&t&&t.length>0&&!o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{className:"text-lg font-semibold mb-4 mt-6",children:"GPU Metrics"}),(0,a.jsxs)("div",{className:"mb-4 p-4 bg-gray-50 rounded-md border border-gray-200",children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center",children:[n&&n.length>0&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("label",{htmlFor:"host-select",className:"text-sm font-medium text-gray-700 whitespace-nowrap",children:"Node:"}),(0,a.jsxs)("select",{id:"host-select",value:m,onChange:e=>{u(e.target.value)},disabled:g,className:"px-3 py-1 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-sky-blue focus:border-transparent",children:[(0,a.jsx)("option",{value:"$__all",children:"All Nodes"}),i.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]}),g&&(0,a.jsx)("div",{className:"ml-2",children:(0,a.jsx)(r.Z,{size:16})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium text-gray-700 whitespace-nowrap",children:"Time Range:"}),(0,a.jsx)("div",{className:"flex gap-1",children:[{label:"15m",value:"15m"},{label:"1h",value:"1h"},{label:"6h",value:"6h"},{label:"24h",value:"24h"},{label:"7d",value:"7d"}].map(e=>(0,a.jsx)("button",{onClick:()=>N(e.value),className:"px-2 py-1 text-xs font-medium rounded border transition-colors ".concat(x.from==="now-".concat(e.value)&&"now"===x.to?"bg-sky-blue text-white border-sky-blue":"bg-white text-gray-600 border-gray-300 hover:bg-gray-50"),children:e.label},e.value))})]})]}),(0,a.jsx)("div",{className:"mt-2 text-xs text-gray-500",children:n&&n.length>0?(0,a.jsxs)(a.Fragment,{children:["Showing:"," ","$__all"===m?"All nodes":m," ","• Time: ",x.from," to ",x.to,i.length>0&&(0,a.jsxs)("span",{children:[" ","• ",i.length," nodes available"]})]}):(0,a.jsxs)(a.Fragment,{children:["Cluster:"," ",o?s.replace(/^ssh-/,""):s," ","• Time: ",x.from," to ",x.to," • Showing metrics for all nodes in cluster"]})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:b("6"),width:"100%",height:"400",frameBorder:"0",title:"GPU Utilization",className:"rounded"},"gpu-util-".concat(m,"-").concat(x.from,"-").concat(x.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:b("18"),width:"100%",height:"400",frameBorder:"0",title:"GPU Memory",className:"rounded"},"gpu-memory-".concat(m,"-").concat(x.from,"-").concat(x.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:b("10"),width:"100%",height:"400",frameBorder:"0",title:"GPU Power Consumption",className:"rounded"},"gpu-power-".concat(m,"-").concat(x.from,"-").concat(x.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:b("12"),width:"100%",height:"400",frameBorder:"0",title:"GPU Temperature",className:"rounded"},"gpu-temp-".concat(m,"-").concat(x.from,"-").concat(x.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:b("22"),width:"100%",height:"400",frameBorder:"0",title:"CPU Utilization",className:"rounded"},"cpu-util-".concat(m,"-").concat(x.from,"-").concat(x.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:b("21"),width:"100%",height:"400",frameBorder:"0",title:"Memory Utilization",className:"rounded"},"memory-util-".concat(m,"-").concat(x.from,"-").concat(x.to))})})]})]})]})})})}function F(e){var s;let{poolName:t,gpusInContext:i,nodesInContext:c,handleDeploySSHPool:d,handleEditSSHPool:m,handleDeleteSSHPool:u,poolConfig:x}=e,[f,y]=(0,l.useState)(null),[j,b]=(0,l.useState)(!0),[N,v]=(0,l.useState)({isOpen:!1,action:null,loading:!1}),[w,S]=(0,l.useState)({isOpen:!1,logs:"",isStreaming:!1,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});(0,l.useEffect)(()=>{(async()=>{try{b(!0);let e=await (0,h.IS)(t);y(e)}catch(e){console.error("Failed to fetch SSH Node Pool status:",e),y({pool_name:t,status:"Error",reason:"Failed to fetch status"})}finally{b(!1)}})()},[t]);let{deployDisabled:_}=(()=>{if(!f)return{deployDisabled:!0};let e=f.status;return"Ready"===e?{deployDisabled:!0}:"Error"===e?{deployDisabled:!0}:{deployDisabled:!1}})(),C=async()=>{v({...N,loading:!0});try{if("deploy"===N.action){v({isOpen:!1,action:null,loading:!1}),S({isOpen:!0,logs:"",isStreaming:!0,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});try{let e=(await d(t)).request_id;S(s=>({...s,requestId:e}));let s=new AbortController;await (0,h.wJ)({requestId:e,signal:s.signal,onNewLog:e=>{S(s=>({...s,logs:s.logs+e}))}}),S(e=>({...e,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!0})),setTimeout(async()=>{(async()=>{try{let e=await (0,h.IS)(t);y(e)}catch(e){console.error("Failed to fetch SSH Node Pool status after deployment:",e)}})()},1e3)}catch(e){console.error("Deployment failed:",e),S(s=>({...s,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!1,logs:s.logs+"\nDeployment failed: ".concat(e.message)}))}}else if("delete"===N.action){v({isOpen:!1,action:null,loading:!1}),S({isOpen:!0,logs:"",isStreaming:!0,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});try{let e=(await (0,h.ez)(t)).request_id;S(s=>({...s,requestId:e})),e&&await (0,h.mF)({requestId:e,signal:null,onNewLog:e=>{S(s=>({...s,logs:s.logs+e}))},operationType:"down"}),await u(t),S(e=>({...e,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!0,logs:e.logs+"\nSSH Node Pool teardown completed successfully."}))}catch(e){console.error("Down operation failed:",e),S(s=>({...s,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!1,logs:s.logs+"\nTeardown failed: ".concat(e.message)}))}}}catch(e){console.error("Action failed:",e),v({...N,loading:!1})}},k=()=>{v({isOpen:!1,action:null,loading:!1})},P=()=>{S({isOpen:!1,logs:"",isStreaming:!1,deploymentComplete:!1,deploymentSuccess:!1,requestId:null}),w.deploymentComplete&&setTimeout(()=>{(async()=>{try{let e=await (0,h.IS)(t);y(e)}catch(e){console.error("Failed to refresh status:",e)}})()},1e3)},U="deploy"===N.action?{title:"Deploy SSH Node Pool",description:'Are you sure you want to deploy SSH Node Pool "'.concat(t,'"?'),details:["• Set up SkyPilot runtime on the configured SSH hosts","• Install required components and dependencies","• Make the node pool available for workloads","","This process may take a few minutes to complete."]}:{title:"Delete SSH Node Pool",description:'Are you sure you want to delete SSH Node Pool "'.concat(t,'"?'),details:["• Clean up any deployed resources","• Remove the SSH Node Pool configuration"]};return(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-6",children:(0,a.jsxs)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 pt-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"SSH Node Pool Details"}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsxs)("button",{className:"px-3 py-1 text-sm border rounded flex items-center ".concat(_?"border-gray-300 bg-gray-100 text-gray-400 cursor-not-allowed":"border-green-300 bg-green-50 text-green-700 hover:bg-green-100"),onClick:_?void 0:()=>{v({isOpen:!0,action:"deploy",loading:!1})},disabled:_,children:[(0,a.jsx)(n.Z,{className:"w-4 h-4 mr-2"}),"Deploy"]}),(0,a.jsxs)("button",{className:"px-3 py-1 text-sm border border-gray-300 rounded hover:bg-gray-50 flex items-center text-red-600 hover:text-red-700",onClick:()=>{v({isOpen:!0,action:"delete",loading:!1})},children:[(0,a.jsx)(o.Z,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]}),(0,a.jsx)("div",{className:"p-4",children:(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Pool Name"}),(0,a.jsx)("div",{className:"text-base mt-1",children:t})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Nodes"}),(0,a.jsx)("div",{className:"text-base mt-1",children:c?c.length:0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Status"}),(0,a.jsx)("div",{className:"text-base mt-1",children:j?(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(r.Z,{size:16,className:"mr-2"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading..."})]}):f?(0,a.jsx)(e=>{let{status:s,reason:t}=e,l="Ready"===s,r="Not Ready"===s?"Click Deploy to set up this node pool":t;return(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium ".concat(l?"bg-green-100":"bg-red-100"," ").concat(l?"text-green-800":"text-red-800"),children:s}),!l&&r&&(0,a.jsxs)("span",{className:"text-sm text-gray-600",children:["(",r,")"]})]})},{status:f.status,reason:f.reason}):(0,a.jsx)("span",{className:"text-gray-500",children:"Unknown"})})]})]})})]})}),(0,a.jsx)(D,{contextName:"ssh-".concat(t),gpusInContext:i,nodesInContext:c}),(0,a.jsx)(g.Vq,{open:N.isOpen,onOpenChange:k,children:(0,a.jsxs)(g.cZ,{className:"sm:max-w-md",children:[(0,a.jsxs)(g.fK,{className:"",children:[(0,a.jsx)(g.$N,{className:"",children:U.title}),(0,a.jsx)(g.Be,{className:"",children:U.description})]}),(0,a.jsx)("div",{className:"py-4",children:(0,a.jsxs)("div",{className:"text-sm text-gray-600 space-y-1",children:[(0,a.jsx)("p",{className:"font-medium mb-2",children:"This will:"}),U.details.map((e,s)=>(0,a.jsx)("p",{className:""===e?"pt-2":"",children:e},s))]})}),(0,a.jsxs)(g.cN,{className:"",children:[(0,a.jsx)(p.z,{variant:"outline",onClick:k,disabled:N.loading,className:"",children:"Cancel"}),(0,a.jsx)(p.z,{onClick:C,disabled:N.loading,className:"deploy"===N.action?"bg-green-600 hover:bg-green-700 text-white":"bg-red-600 hover:bg-red-700 text-white",children:N.loading?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Z,{size:16,className:"mr-2"}),"deploy"===N.action?"Deploying...":"Deleting..."]}):"deploy"===N.action?"Deploy":"Delete"})]})]})}),(0,a.jsx)(g.Vq,{open:w.isOpen,onOpenChange:w.isStreaming?void 0:P,children:(0,a.jsxs)(g.cZ,{className:"sm:max-w-4xl max-h-[80vh]",children:[(0,a.jsxs)(g.fK,{className:"",children:[(0,a.jsxs)(g.$N,{className:"",children:["Deploying SSH Node Pool: ",t]}),(0,a.jsx)(g.Be,{className:"",children:w.isStreaming?"Deployment in progress. Do not close this dialog.":w.deploymentSuccess?"Deployment completed successfully!":"Deployment completed with errors."})]}),(0,a.jsx)("div",{className:"py-4",children:(0,a.jsxs)("div",{className:"bg-black text-green-400 p-4 rounded-md font-mono text-sm max-h-96 overflow-y-auto",children:[(0,a.jsx)("pre",{className:"whitespace-pre-wrap",children:(s=w.logs)?s.split("\n").map(e=>(e=e.replace(/\x1b\[[0-9;]*m/g,"")).match(/^D \d{2}-\d{2} \d{2}:\d{2}:\d{2}/)?null:e=(e=e.replace(/├──/g,"├─")).replace(/└──/g,"└─")).filter(e=>null!==e&&""!==e.trim()).join("\n"):""}),w.isStreaming&&(0,a.jsxs)("div",{className:"flex items-center mt-2",children:[(0,a.jsx)(r.Z,{size:16,className:"mr-2 text-green-400"}),(0,a.jsx)("span",{className:"text-green-400",children:"Streaming logs..."})]})]})}),(0,a.jsx)(g.cN,{className:"",children:(0,a.jsx)(p.z,{onClick:P,disabled:w.isStreaming,className:w.deploymentSuccess?"bg-green-600 hover:bg-green-700 text-white":w.deploymentComplete&&!w.deploymentSuccess?"bg-red-600 hover:bg-red-700 text-white":"bg-gray-600 hover:bg-gray-700 text-white",children:w.isStreaming?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Z,{size:16,className:"mr-2"}),"Deploying..."]}):"Close"})})]})})]})}function E(){let[e,s]=(0,l.useState)(!0),[t,n]=(0,l.useState)(!0),[o,d]=(0,l.useState)(!0),g=l.useRef(null),p=(0,c.X)(),[f,y]=(0,l.useState)(!1),[j,w]=(0,l.useState)(!1),_=(0,S.useRouter)(),[k,U]=(0,l.useState)([]),[E,H]=(0,l.useState)([]),[A,z]=(0,l.useState)([]),[R,q]=(0,l.useState)([]),[O,M]=(0,l.useState)([]),[Z,G]=(0,l.useState)(0),[L,T]=(0,l.useState)(0),[W,B]=(0,l.useState)({}),[K,$]=(0,l.useState)({}),[J,V]=(0,l.useState)({}),[X,Y]=(0,l.useState)("all"),[Q,ee]=(0,l.useState)([]),[es,et]=(0,l.useState)({}),[ea,el]=(0,l.useState)(!1),[er,en]=(0,l.useState)(null),[eo,ei]=(0,l.useState)(!1),[ec,ed]=(0,l.useState)(!0),[em,eu]=(0,l.useState)({}),[ex,eh]=(0,l.useState)(null),eg=l.useCallback(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{showLoadingIndicators:!0},{showLoadingIndicators:t=!0,forceRefresh:a=!1}=e;t&&(s(!0),n(!0),ei(!0),ed(!0));try{async function l(e){await ep(e),await ej(e)}await Promise.all([l(a),ey(a),ef(a)])}catch(e){console.error("Error in fetchData:",e),V({}),U([]),H([]),z([]),q([]),B({}),$({}),ee([]),y(!0),s(!1),M([]),G(0),T(0),w(!0),et({}),ei(!1),eu({}),ed(!1)}finally{t&&(s(!1),n(!1),ei(!1),ed(!1)),o&&t&&d(!1)}},[o]),ep=async e=>{try{let t=e?await (0,m.Xg)():await N.default.get(m.Xg);if(t){let{workspaces:e,allContextNames:a,allGPUs:l,perContextGPUs:r,perNodeGPUs:n,contextStats:o,contextWorkspaceMap:i}=t;V(e||{}),U(a||[]),H(l||[]),z(r||[]),q(n||[]),B(o||{}),$(i||{});let c=Object.keys(e||{});ee(c.sort()),y(!0),s(!1)}else null===t&&(V({}),U([]),H([]),z([]),q([]),B({}),$({}),ee([]),y(!0),s(!1))}catch(e){console.error("Error in fetchKubernetesData:",e),V({}),U([]),H([]),z([]),q([]),B({}),$({}),ee([]),y(!0),s(!1)}},ef=async e=>{try{let s=e?await (0,x.getManagedJobs)({allUsers:!0,skipFinished:!0,fields:["cloud","region"]}):await N.default.get(x.getManagedJobs,[{allUsers:!0,skipFinished:!0,fields:["cloud","region"]}]),t=(null==s?void 0:s.jobs)||[];eu(await (0,m.R8)(t)),ed(!1)}catch(e){console.error("Error in fetchManagedJobsData:",e),eu({}),ed(!1)}},ey=async e=>{try{let s=e?await (0,m.ef)():await N.default.get(m.ef,[e]);s?(M(s.clouds||[]),G(s.totalClouds||0),T(s.enabledClouds||0),w(!0)):null===s&&(M([]),G(0),T(0),w(!0))}catch(e){console.error("Error in fetchCloudData:",e),M([]),G(0),T(0),w(!0)}},ej=async e=>{try{let s=e?await (0,h.It)():await N.default.get(h.It);et(s),ei(!1)}catch(e){console.error("Failed to fetch SSH Node Pools:",e),et({}),ei(!1)}},eb=(e,s)=>{en({name:e,config:s}),el(!0)},eN=async e=>{try{await (0,h.MV)(e),await ej(),eh(null),_.push("/infra")}catch(e){throw console.error("Failed to delete SSH Node Pool:",e),e}},ev=async e=>{try{await (0,h._x)(e)}catch(e){throw console.error("Failed to deploy SSH Node Pool:",e),e}},ew=async(e,s)=>{ei(!0);try{let t={...es};t[e]=s,await (0,h.Ri)(t),await ej(),el(!1)}catch(e){console.error("Failed to save SSH Node Pool:",e),alert("Failed to save SSH Node Pool. Please try again.")}finally{ei(!1)}};(0,l.useEffect)(()=>{g.current=eg},[eg]),(0,l.useEffect)(()=>{(async()=>{await v.ZP.preloadForPage("infra"),eg({showLoadingIndicators:!0})})()},[]),(0,l.useEffect)(()=>{let e=!0,s=setInterval(()=>{e&&g.current&&g.current({showLoadingIndicators:!1})},P);return()=>{e=!1,clearInterval(s)}},[]),(0,l.useEffect)(()=>()=>{y(!1),w(!1),ei(!1),d(!0),ed(!1)},[]);let eS=()=>{N.default.invalidate(u.getClusters),N.default.invalidate(x.getManagedJobs,[{allUsers:!0,skipFinished:!0,fields:["cloud","region"]}]),N.default.invalidate(m.Xg),N.default.invalidate(m.ef,[!1]),N.default.invalidate(h.It),g.current&&g.current({showLoadingIndicators:!0,forceRefresh:!0})};(0,l.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"r"===e.key&&(e.preventDefault(),eS())};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[]),(E||[]).length,(E||[]).reduce((e,s)=>e+s.gpu_total,0),(E||[]).reduce((e,s)=>e+s.gpu_free,0);let e_=l.useMemo(()=>A?A.reduce((e,s)=>{let{context:t}=s;return e[t]||(e[t]=[]),e[t].push(s),e},{}):{},[A]),eC=l.useCallback(e=>"all"===X?e:e.filter(e=>(K[e]||[]).includes(X)),[X,K]),ek=l.useMemo(()=>k&&Array.isArray(k)?eC(k.filter(e=>e.startsWith("ssh-"))):[],[k,eC]),eP=l.useMemo(()=>k&&Array.isArray(k)?eC(k.filter(e=>!e.startsWith("ssh-"))):[],[k,eC]),eU=l.useMemo(()=>{if(!A||!E)return[];let e=new Set;return A.forEach(s=>{s.context.startsWith("ssh-")&&e.add(s.gpu_name)}),E.filter(s=>e.has(s.gpu_name))},[E,A]),eI=l.useMemo(()=>{if(!A||!E)return[];let e=new Set;return A.forEach(s=>{s.context.startsWith("ssh-")||e.add(s.gpu_name)}),E.filter(s=>e.has(s.gpu_name))},[E,A]),eD=l.useMemo(()=>R?R.reduce((e,s)=>{let{context:t}=s;return e[t]||(e[t]=[]),e[t].push(s),e},{}):{},[R]);(0,l.useEffect)(()=>{_.isReady&&_.query.context&&eh(decodeURIComponent(Array.isArray(_.query.context)?_.query.context[0]:_.query.context))},[_.isReady,_.query.context]);let eF=e=>{eh(e),_.push("/infra/".concat(encodeURIComponent(e)))},eE=s=>{let t=e_[s]||[],l=eD[s]||[];if(e&&!f)return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-64",children:[(0,a.jsx)(r.Z,{size:32,className:"mb-4"}),(0,a.jsx)("span",{className:"text-gray-500 text-lg",children:"Loading Context..."})]});if(s.startsWith("ssh-")){let e=s.replace(/^ssh-/,"");return(0,a.jsx)(F,{poolName:e,gpusInContext:t,nodesInContext:l,handleDeploySSHPool:ev,handleEditSSHPool:eb,handleDeleteSSHPool:eN,poolConfig:es[e]})}return(0,a.jsx)(D,{contextName:s,gpusInContext:t,nodesInContext:l})},eH=()=>t&&(!O||0===O.length)?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold mb-4",children:"Cloud"}),(0,a.jsxs)("div",{className:"flex items-center justify-center py-6",children:[(0,a.jsx)(r.Z,{size:24,className:"mr-3"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading Cloud..."})]})]})}):(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Cloud"}),(0,a.jsxs)("span",{className:"ml-2 px-2 py-0.5 bg-blue-100 text-blue-800 rounded-full text-xs font-medium",children:[L," of ",Z," enabled"]})]}),O&&0!==O.length?(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm bg-white",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-32",children:"Cloud"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-24",children:"Clusters"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-24",children:"Jobs"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:O.map(e=>{let s=j&&void 0!==e.clusters&&void 0!==e.jobs;return(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"p-3 font-medium text-gray-700",children:e.name}),(0,a.jsx)("td",{className:"p-3",children:s?e.clusters>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded text-xs font-medium",children:e.clusters}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"}):(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)(r.Z,{size:16})})}),(0,a.jsx)("td",{className:"p-3",children:s?e.jobs>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-green-100 text-green-800 rounded text-xs font-medium",children:e.jobs}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"}):(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)(r.Z,{size:16})})})]},e.name)})})]})}):(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"No enabled clouds available."})]})}),eA=()=>(0,a.jsx)(I,{title:"SSH Node Pool",isLoading:e,isDataLoaded:f,contexts:ek,gpus:eU,groupedPerContextGPUs:e_,groupedPerNodeGPUs:eD,handleContextClick:eF,contextStats:W,jobsData:em,isJobsDataLoading:ec,isSSH:!0,contextWorkspaceMap:K,actionButton:null}),ez=()=>(0,a.jsx)(I,{title:"Kubernetes",isLoading:e,isDataLoaded:f,contexts:eP,gpus:eI,groupedPerContextGPUs:e_,groupedPerNodeGPUs:eD,handleContextClick:eF,contextStats:W,jobsData:em,isJobsDataLoading:ec,isSSH:!1,contextWorkspaceMap:K}),eR=e||t;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,a.jsxs)("div",{className:"text-base flex items-center",children:[(0,a.jsx)(C(),{href:"/infra",className:"text-sky-blue hover:underline ".concat(ex?"":"cursor-default"),children:"Infrastructure"}),ex&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),ex.startsWith("ssh-")?(0,a.jsx)(C(),{href:"/infra",className:"text-sky-blue hover:underline cursor-pointer",children:"SSH Node Pool"}):(0,a.jsx)(C(),{href:"/infra",className:"text-sky-blue hover:underline cursor-pointer",children:"Kubernetes"}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsx)("span",{className:"text-sky-blue",children:ex.startsWith("ssh-")?ex.replace(/^ssh-/,""):ex})]})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[Q.length>0&&(0,a.jsxs)("div",{className:"flex items-center mr-4",children:[(0,a.jsx)("label",{htmlFor:"workspace-selector",className:"text-sm font-medium text-gray-700 mr-2",children:"Workspace:"}),(0,a.jsxs)("select",{id:"workspace-selector",value:X,onChange:e=>Y(e.target.value),className:"px-3 py-1 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-sky-blue focus:border-transparent",children:[(0,a.jsx)("option",{value:"all",children:"All Workspaces"}),Q.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]})]}),eR&&(0,a.jsxs)("div",{className:"flex items-center mr-2",children:[(0,a.jsx)(r.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),(0,a.jsxs)("button",{onClick:eS,disabled:eR,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,a.jsx)(i.Z,{className:"h-4 w-4 mr-1.5"}),!p&&"Refresh"]})]})]}),(()=>{if(ex)return e&&!f?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-64",children:[(0,a.jsx)(r.Z,{size:32,className:"mb-4"}),(0,a.jsx)("span",{className:"text-gray-500 text-lg",children:"Loading Context..."})]}):eE(ex);let s=[];s.push({name:"Kubernetes",render:ez,hasActivity:eP.length>0,priority:1}),s.push({name:"Cloud",render:eH,hasActivity:L>0,priority:2}),s.push({name:"SSH Node Pool",render:eA,hasActivity:ek.length>0&&function(e){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.some(e=>{let t=W[s?"ssh/".concat(e.replace(/^ssh-/,"")):"kubernetes/".concat(e)]||{clusters:0,jobs:0};return t.clusters>0||t.jobs>0})}(ek,!0),priority:3});let t=s.sort((e,s)=>e.hasActivity!==s.hasActivity?e.hasActivity?-1:1:e.priority-s.priority);return(0,a.jsx)(a.Fragment,{children:t.map((e,s)=>(0,a.jsx)(l.Fragment,{children:e.render()},s))})})(),(0,a.jsx)(b,{isOpen:ea,onClose:()=>el(!1),onSave:ew,poolData:er,isLoading:eo})]})}},42557:function(e,s,t){t.d(s,{I:function(){return n}});var a=t(85893),l=t(67294),r=t(32350);let n=l.forwardRef((e,s)=>{let{className:t,type:l,...n}=e;return(0,a.jsx)("input",{type:l,className:(0,r.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...n})});n.displayName="Input"},36185:function(e,s,t){t.d(s,{_:function(){return c}});var a=t(85893),l=t(67294),r=t(49102),n=t(12003),o=t(32350);let i=(0,n.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)(r.f,{ref:s,className:(0,o.cn)(i(),t),...l})});c.displayName=r.f.displayName},69123:function(e,s,t){t.d(s,{g:function(){return n}});var a=t(85893),l=t(67294),r=t(32350);let n=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)("textarea",{className:(0,r.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...l})});n.displayName="Textarea"},17853:function(e,s,t){t.d(s,{TO:function(){return r},ki:function(){return n}});let a=null,l=null,r=async()=>null!==a?a:l||(l=(async()=>{try{let e="".concat(window.location.origin,"/grafana"),s=await fetch("".concat(e,"/api/health"),{method:"GET",credentials:"include",headers:{Accept:"application/json"},signal:AbortSignal.timeout(5e3)});return 200==s.status}catch(e){return console.debug("Grafana availability check failed:",e),a=!1,!1}finally{l=null}})()),n=()=>"".concat(window.location.origin,"/grafana")}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6135],{6135:function(e,t,s){s.r(t),s.d(t,{Layout:function(){return L}});var r=s(85893),a=s(67294),n=s(25675),l=s.n(n),o=s(11163),i=s(41664),c=s.n(i),d=s(53850),x=s(40355),m=s(6021),h=s(93225),u=s(36989),f=s(23001);let p=(0,a.createContext)(null);function b(e){let{children:t}=e,[s,n]=(0,a.useState)(!0),[l,o]=(0,a.useState)(!1),[i,c]=(0,a.useState)(null),[d,x]=(0,a.useState)(null),m=window.location.origin,u="".concat(m).concat(h.f4);return(0,a.useEffect)(()=>{fetch("".concat(u,"/api/health")).then(e=>e.json()).then(e=>{e.user&&e.user.name&&(c(e.user.name),(async()=>{try{let e=await fetch("".concat(u,"/users/role"));if(e.ok){let t=await e.json();t.role&&x(t.role)}}catch(e){console.log("Could not fetch user role:",e)}})())}).catch(e=>{console.error("Error fetching user data:",e)})},[u]),(0,r.jsx)(p.Provider,{value:{isSidebarOpen:s,toggleSidebar:()=>{n(e=>!e)},isMobileSidebarOpen:l,toggleMobileSidebar:()=>{o(e=>!e)},userEmail:i,userRole:d},children:t})}function g(){let e,t;let s=(0,o.useRouter)(),n=(0,f.X)(),{userEmail:i,userRole:b,isMobileSidebarOpen:g,toggleMobileSidebar:j}=function(){let e=(0,a.useContext)(p);if(!e)throw Error("useSidebar must be used within a SidebarProvider");return e}(),[y,N]=(0,a.useState)(!1),v=(0,a.useRef)(null),w=(0,a.useRef)(null);(0,a.useEffect)(()=>{function e(e){v.current&&!v.current.contains(e.target)&&N(!1),w.current&&!w.current.contains(e.target)&&!e.target.closest(".mobile-menu-button")&&g&&j()}return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[v,g,j]);let k=e=>"/workspaces"===e?s.pathname.startsWith("/workspaces")||s.pathname.startsWith("/workspace"):s.pathname.startsWith(e),C=e=>{let t=k(e);return"inline-flex items-center border-b-2 ".concat(t?"border-transparent text-blue-600":"border-transparent hover:text-blue-600"," ").concat(n?"px-2 py-1":"px-1 pt-1 space-x-2")};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed top-0 left-0 right-0 bg-white z-30 h-14 px-4 border-b border-gray-200 shadow-sm",children:(0,r.jsxs)("div",{className:"flex items-center justify-between h-full",children:[(0,r.jsxs)("div",{className:"flex items-center space-x-4 mr-4 md:mr-6",children:[n&&(0,r.jsx)("button",{onClick:j,className:"mobile-menu-button p-2 rounded-md text-gray-600 hover:text-blue-600 hover:bg-gray-100 transition-colors","aria-label":"Toggle mobile menu",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:g?"M6 18L18 6M6 6l12 12":"M4 6h16M4 12h16M4 18h16"})})}),(0,r.jsx)(c(),{href:"/",className:"flex items-center px-1 pt-1 h-full",prefetch:!1,children:(0,r.jsx)("div",{className:"h-20 w-20 flex items-center justify-center",children:(0,r.jsx)(l(),{src:"".concat(h.GW,"/skypilot.svg"),alt:"SkyPilot Logo",width:80,height:80,priority:!0,className:"w-full h-full object-contain"})})})]}),!n&&(0,r.jsxs)("div",{className:"flex items-center space-x-2 md:space-x-4 mr-6",children:[(0,r.jsxs)(c(),{href:"/clusters",className:C("/clusters"),prefetch:!1,children:[(0,r.jsx)(d.QT,{className:"w-4 h-4"}),(0,r.jsx)("span",{children:"Clusters"})]}),(0,r.jsxs)(c(),{href:"/jobs",className:C("/jobs"),prefetch:!1,children:[(0,r.jsx)(d.Vp,{className:"w-4 h-4"}),(0,r.jsx)("span",{children:"Jobs"})]}),(0,r.jsxs)(c(),{href:"/volumes",className:C("/volumes"),prefetch:!1,children:[(0,r.jsx)(d.eU,{className:"w-4 h-4"}),(0,r.jsx)("span",{children:"Volumes"})]}),(0,r.jsx)("div",{className:"border-l border-gray-200 h-6 mx-1"}),(0,r.jsxs)(c(),{href:"/infra",className:C("/infra"),prefetch:!1,children:[(0,r.jsx)(d.PC,{className:"w-4 h-4"}),(0,r.jsx)("span",{children:"Infra"})]}),(0,r.jsxs)(c(),{href:"/workspaces",className:C("/workspaces"),prefetch:!1,children:[(0,r.jsx)(d.E9,{className:"w-4 h-4"}),(0,r.jsx)("span",{children:"Workspaces"})]}),(0,r.jsxs)(c(),{href:"/users",className:C("/users"),prefetch:!1,children:[(0,r.jsx)(d.oy,{className:"w-4 h-4"}),(0,r.jsx)("span",{children:"Users"})]})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-1 ml-auto",children:[!n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.WH,{content:"Documentation",className:"text-sm text-muted-foreground",children:(0,r.jsxs)("a",{href:"https://skypilot.readthedocs.io/en/latest/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center px-2 py-1 text-gray-600 hover:text-blue-600 transition-colors duration-150 cursor-pointer",title:"Docs",children:[(0,r.jsx)("span",{className:"mr-1",children:"Docs"}),(0,r.jsx)(d.h0,{className:"w-3.5 h-3.5"})]})}),(0,r.jsx)(u.WH,{content:"GitHub Repository",className:"text-sm text-muted-foreground",children:(0,r.jsx)("a",{href:"https://github.com/skypilot-org/skypilot",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center p-2 rounded-full text-gray-600 hover:bg-gray-100 transition-colors duration-150 cursor-pointer",title:"GitHub",children:(0,r.jsx)(d.fy,{className:"w-5 h-5"})})}),(0,r.jsx)(u.WH,{content:"Join Slack",className:"text-sm text-muted-foreground",children:(0,r.jsx)("a",{href:"https://slack.skypilot.co/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center p-2 rounded-full text-gray-600 hover:bg-gray-100 transition-colors duration-150 cursor-pointer",title:"Slack",children:(0,r.jsx)(d.mU,{className:"w-5 h-5"})})}),(0,r.jsx)(u.WH,{content:"Leave Feedback",className:"text-sm text-muted-foreground",children:(0,r.jsx)("a",{href:"https://github.com/skypilot-org/skypilot/issues/new",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center p-2 rounded-full text-gray-600 hover:bg-gray-100 transition-colors duration-150 cursor-pointer",title:"Leave Feedback",children:(0,r.jsx)(d.aD,{className:"w-5 h-5"})})}),(0,r.jsx)("div",{className:"border-l border-gray-200 h-6"}),(0,r.jsx)(u.WH,{content:"Configuration",className:"text-sm text-muted-foreground",children:(0,r.jsx)(c(),{href:"/config",className:"inline-flex items-center justify-center p-2 rounded-full transition-colors duration-150 cursor-pointer ".concat(k("/config")?"text-blue-600 hover:bg-gray-100":"text-gray-600 hover:bg-gray-100"),title:"Configuration",prefetch:!1,children:(0,r.jsx)(x.Z,{className:"w-5 h-5"})})})]}),i&&(0,r.jsxs)("div",{className:"relative",ref:v,children:[(0,r.jsx)("button",{onClick:()=>N(!y),className:"inline-flex items-center justify-center rounded-full transition-colors duration-150 cursor-pointer hover:ring-2 hover:ring-blue-200",title:"User Profile",children:(0,r.jsx)("div",{className:"".concat(n?"w-6 h-6 text-xs":"w-7 h-7 text-sm"," bg-blue-600 text-white rounded-full flex items-center justify-center font-medium hover:bg-blue-700 transition-colors"),children:i?i.includes("@")?i.split("@")[0].charAt(0).toUpperCase():i.charAt(0).toUpperCase():"?"})}),y&&(0,r.jsxs)("div",{className:"absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg z-50 border border-gray-200",children:[(e=i,t=null,i&&i.includes("@")&&(e=i.split("@")[0],t=i),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"px-4 pt-2 pb-1 text-sm font-medium text-gray-900",children:e}),t&&(0,r.jsx)("div",{className:"px-4 pt-0 pb-1 text-xs text-gray-500",children:t}),b&&(0,r.jsx)("div",{className:"px-4 pt-0 pb-2 text-xs",children:"admin"===b?(0,r.jsxs)("span",{className:"inline-flex items-center text-blue-600",children:[(0,r.jsx)(d.r7,{className:"w-3 h-3 mr-1"}),"Admin"]}):(0,r.jsxs)("span",{className:"inline-flex items-center text-gray-600",children:[(0,r.jsx)(m.Z,{className:"w-3 h-3 mr-1"}),"User"]})})]})),(0,r.jsx)("div",{className:"border-t border-gray-200 mx-1 my-1"}),(0,r.jsx)(c(),{href:"/users",className:"block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-blue-600",onClick:()=>N(!1),prefetch:!1,children:"See all users"})]})]})]})]})}),n&&(0,r.jsxs)(r.Fragment,{children:[g&&(0,r.jsx)("div",{className:"fixed top-14 left-0 right-0 bottom-0 bg-black bg-opacity-50 z-40",onClick:j}),(0,r.jsx)("div",{ref:w,className:"fixed top-14 left-0 h-[calc(100vh-56px)] w-64 bg-white border-r border-gray-200 shadow-lg z-50 transform transition-transform duration-300 ease-in-out ".concat(g?"translate-x-0":"-translate-x-full"),children:(0,r.jsx)("nav",{className:"flex-1 overflow-y-auto py-6",children:(0,r.jsxs)("div",{className:"px-4 space-y-1",children:[(0,r.jsxs)(c(),{href:"/clusters",className:"flex items-center px-4 py-3 text-sm font-medium rounded-md transition-colors ".concat(k("/clusters")?"bg-blue-50 text-blue-600":"text-gray-700 hover:bg-gray-100 hover:text-blue-600"),onClick:j,prefetch:!1,children:[(0,r.jsx)(d.QT,{className:"w-5 h-5 mr-3"}),"Clusters"]}),(0,r.jsxs)(c(),{href:"/jobs",className:"flex items-center px-4 py-3 text-sm font-medium rounded-md transition-colors ".concat(k("/jobs")?"bg-blue-50 text-blue-600":"text-gray-700 hover:bg-gray-100 hover:text-blue-600"),onClick:j,prefetch:!1,children:[(0,r.jsx)(d.Vp,{className:"w-5 h-5 mr-3"}),"Jobs"]}),(0,r.jsxs)(c(),{href:"/volumes",className:"flex items-center px-4 py-3 text-sm font-medium rounded-md transition-colors ".concat(k("/volumes")?"bg-blue-50 text-blue-600":"text-gray-700 hover:bg-gray-100 hover:text-blue-600"),onClick:j,prefetch:!1,children:[(0,r.jsx)(d.eU,{className:"w-5 h-5 mr-3"}),"Volumes"]}),(0,r.jsx)("div",{className:"border-t border-gray-200 my-4"}),(0,r.jsxs)(c(),{href:"/infra",className:"flex items-center px-4 py-3 text-sm font-medium rounded-md transition-colors ".concat(k("/infra")?"bg-blue-50 text-blue-600":"text-gray-700 hover:bg-gray-100 hover:text-blue-600"),onClick:j,prefetch:!1,children:[(0,r.jsx)(d.PC,{className:"w-5 h-5 mr-3"}),"Infra"]}),(0,r.jsxs)(c(),{href:"/workspaces",className:"flex items-center px-4 py-3 text-sm font-medium rounded-md transition-colors ".concat(k("/workspaces")?"bg-blue-50 text-blue-600":"text-gray-700 hover:bg-gray-100 hover:text-blue-600"),onClick:j,prefetch:!1,children:[(0,r.jsx)(d.E9,{className:"w-5 h-5 mr-3"}),"Workspaces"]}),(0,r.jsxs)(c(),{href:"/users",className:"flex items-center px-4 py-3 text-sm font-medium rounded-md transition-colors ".concat(k("/users")?"bg-blue-50 text-blue-600":"text-gray-700 hover:bg-gray-100 hover:text-blue-600"),onClick:j,prefetch:!1,children:[(0,r.jsx)(d.oy,{className:"w-5 h-5 mr-3"}),"Users"]}),(0,r.jsx)("div",{className:"border-t border-gray-200 my-4"}),(0,r.jsxs)("a",{href:"https://skypilot.readthedocs.io/en/latest/",target:"_blank",rel:"noopener noreferrer",className:"flex items-center px-4 py-3 text-sm font-medium text-gray-700 hover:bg-gray-100 hover:text-blue-600 rounded-md transition-colors",onClick:j,children:[(0,r.jsx)(d.h0,{className:"w-5 h-5 mr-3"}),"Documentation"]}),(0,r.jsxs)("a",{href:"https://github.com/skypilot-org/skypilot",target:"_blank",rel:"noopener noreferrer",className:"flex items-center px-4 py-3 text-sm font-medium text-gray-700 hover:bg-gray-100 hover:text-blue-600 rounded-md transition-colors",onClick:j,children:[(0,r.jsx)(d.fy,{className:"w-5 h-5 mr-3"}),"GitHub"]}),(0,r.jsxs)("a",{href:"https://slack.skypilot.co/",target:"_blank",rel:"noopener noreferrer",className:"flex items-center px-4 py-3 text-sm font-medium text-gray-700 hover:bg-gray-100 hover:text-blue-600 rounded-md transition-colors",onClick:j,children:[(0,r.jsx)(d.mU,{className:"w-5 h-5 mr-3"}),"Slack"]}),(0,r.jsxs)(c(),{href:"/config",className:"flex items-center px-4 py-3 text-sm font-medium rounded-md transition-colors ".concat(k("/config")?"bg-blue-50 text-blue-600":"text-gray-700 hover:bg-gray-100 hover:text-blue-600"),onClick:j,prefetch:!1,children:[(0,r.jsx)(x.Z,{className:"w-5 h-5 mr-3"}),"Configuration"]})]})})})]})]})}var j=s(43767),y=s(33067),N=s(26409),v=s(94849),w=s(6556);function k(){let{startTour:e}=(0,v.r)(),{shouldShowTourPrompt:t,markTourCompleted:s}=(0,w.n)(),[n,l]=(0,a.useState)(!1),[o,i]=(0,a.useState)(!1);(0,a.useEffect)(()=>{if(i(!0),t){let e=setTimeout(()=>{l(!0)},2e3);return()=>clearTimeout(e)}},[t]);let c=()=>{l(!1),s()};return o&&t&&n?(0,r.jsx)("div",{className:"fixed top-20 right-6 z-50 max-w-sm",children:(0,r.jsxs)("div",{className:"bg-white rounded-md shadow-lg border border-gray-200 p-4 transform transition-all duration-300 ease-out",children:[(0,r.jsx)("button",{onClick:c,className:"absolute top-3 right-3 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full p-1 transition-all duration-150","aria-label":"Dismiss notification",children:(0,r.jsx)(j.Z,{className:"w-3 h-3"})}),(0,r.jsxs)("div",{className:"pr-6",children:[(0,r.jsxs)("div",{className:"flex items-start mb-3",children:[(0,r.jsx)("div",{className:"flex items-center justify-center w-7 h-7 bg-blue-50 rounded-full mr-3 mt-0.5",children:(0,r.jsx)(y.Z,{className:"w-3.5 h-3.5 text-blue-600"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-900 mb-1",children:"Welcome to SkyPilot!"}),(0,r.jsx)("p",{className:"text-sm text-gray-600 leading-relaxed",children:"New to the dashboard? Take a quick guided tour to discover all the features."})]})]}),(0,r.jsxs)("div",{className:"flex space-x-2 ml-10",children:[(0,r.jsxs)("button",{onClick:()=>{l(!1),e()},className:"flex items-center px-3 py-1.5 bg-blue-600 text-white text-sm font-medium rounded hover:bg-blue-700 transition-colors duration-150",children:[(0,r.jsx)(N.Z,{className:"w-3 h-3 mr-1.5"}),"Start Tour"]}),(0,r.jsx)("button",{onClick:c,className:"px-3 py-1.5 text-sm font-medium text-gray-600 hover:text-gray-800 hover:bg-gray-100 rounded transition-colors duration-150",children:"Maybe Later"})]})]})]})}):null}var C=s(19185);function S(e){let{children:t,text:s}=e,[n,l]=(0,a.useState)(!1);return(0,r.jsxs)("div",{className:"relative",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t,n&&(0,r.jsx)("div",{className:"absolute top-0 right-0 transform -translate-y-full -translate-x-2 mb-2 px-2 py-1 bg-gray-700 text-white text-xs rounded-md shadow-lg whitespace-nowrap z-50",children:s})]})}function E(){let{startTour:e}=(0,v.r)();return(0,r.jsx)(S,{text:"Start a tour",children:(0,r.jsx)("button",{onClick:e,className:"fixed bottom-4 right-4 bg-transparent text-gray-400 p-2 rounded-full hover:text-gray-500 focus:outline-none","aria-label":"Start Tour",children:(0,r.jsx)(C.Z,{className:"h-5 w-5"})})})}function W(e){let{children:t,highlighted:s}=e;return(0,f.X)(),(0,r.jsxs)("div",{className:"min-h-screen bg-gray-50",children:[(0,r.jsx)("div",{className:"fixed top-0 left-0 right-0 z-50 shadow-sm",children:(0,r.jsx)(g,{})}),(0,r.jsx)("div",{className:"transition-all duration-200 ease-in-out min-h-screen",style:{paddingTop:"56px"},children:(0,r.jsx)("main",{className:"p-6",children:t})}),(0,r.jsx)(k,{}),(0,r.jsx)(E,{})]})}function L(e){return(0,r.jsx)(b,{children:(0,r.jsx)(W,{...e})})}},23001:function(e,t,s){s.d(t,{X:function(){return a}});var r=s(67294);function a(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:768,[t,s]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let t=()=>{s(window.innerWidth<e)};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[e]),t}}}]);
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9360,8640],{88507:function(e,s,t){t.d(s,{Z:function(){return r}});/**
|
|
2
|
-
* @license lucide-react v0.407.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/let r=(0,t(60998).Z)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},81260:function(e,s,t){t.d(s,{Z:function(){return r}});/**
|
|
7
|
-
* @license lucide-react v0.407.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/let r=(0,t(60998).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},47603:function(e,s,t){t.d(s,{Z:function(){return r}});/**
|
|
12
|
-
* @license lucide-react v0.407.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/let r=(0,t(60998).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},28586:function(e,s,t){t.d(s,{Z:function(){return r}});/**
|
|
17
|
-
* @license lucide-react v0.407.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/let r=(0,t(60998).Z)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},43767:function(e,s,t){t.d(s,{Z:function(){return r}});/**
|
|
22
|
-
* @license lucide-react v0.407.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/let r=(0,t(60998).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},1812:function(e,s,t){t.d(s,{X:function(){return l}});var r=t(85893),a=t(67294);let n=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let s=e.message;return s.includes("failed:")&&(s=s.split("failed:")[1].trim()),s},l=e=>{let{error:s,title:t="Error",onDismiss:l}=e,[o,i]=(0,a.useState)(!1);if((0,a.useEffect)(()=>{s&&i(!1)},[s]),!s||o)return null;let c="string"==typeof s?s:n(s);return(0,r.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,r.jsx)("div",{className:"ml-3",children:(0,r.jsxs)("div",{className:"text-sm text-red-800",children:[(0,r.jsxs)("strong",{children:[t,":"]})," ",c]})})]}),(0,r.jsx)("button",{onClick:()=>{i(!0),l&&l()},className:"flex-shrink-0 ml-4 text-red-400 hover:text-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-red-50 rounded","aria-label":"Dismiss error",children:(0,r.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})})}},82077:function(e,s,t){t.r(s),t.d(s,{Workspaces:function(){return z},getWorkspaceClusters:function(){return S},getWorkspaceManagedJobs:function(){return L}});var r=t(85893),a=t(67294),n=t(11163),l=t(17324),o=t(37673),i=t(68764),c=t(30803),d=t(55739),u=t(1272),m=t(50326);t(53850);var h=t(1812),x=t(13626),p=t(81260);/**
|
|
27
|
-
* @license lucide-react v0.407.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/let f=(0,t(60998).Z)("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);var g=t(47603),j=t(23001),v=t(23015),k=t(6378),w=t(51214),b=t(36856),y=t(47145),N=t(94545),C=t(93225),E=t(41664),_=t.n(E);async function S(e){try{return(await y.x.fetch("/status",{cluster_names:null,all_users:!0,include_credentials:!1,override_skypilot_config:{active_workspace:e}})).map(e=>({status:"UP"===e.status?"RUNNING":"STOPPED"===e.status?"STOPPED":"INIT"===e.status?"LAUNCHING":"TERMINATED",cluster:e.name,user:e.user_name,user_hash:e.user_hash,cluster_hash:e.cluster_hash,cloud:e.cloud,region:e.region,zone:e.zone,launched_at:e.launched_at,handle:e.handle,last_use:e.last_use,autostop:e.autostop,to_down:e.to_down,metadata:e.metadata,resources_str:e.resources_str,workspace:e.workspace||"default"})).filter(s=>s.workspace===e)}catch(s){return console.error("Error fetching clusters for workspace ".concat(e,":"),s),[]}}async function L(e){try{let s=(await y.x.post("/jobs/queue/v2",{all_users:!0,verbose:!0,skip_finished:!0,workspace_match:e,fields:["workspace","status"],override_skypilot_config:{active_workspace:e}})).headers.get("X-Skypilot-Request-ID"),t=await y.x.get("/api/get?request_id=".concat(s)),r=await t.json(),a=r.return_value?JSON.parse(r.return_value):{jobs:[]};return a.jobs&&(a.jobs=a.jobs.map(e=>({...e,workspace:e.workspace||"default"})),a.jobs=a.jobs.filter(s=>s.workspace===e)),a}catch(s){return console.error("Error fetching managed jobs for workspace ".concat(e,":"),s),{jobs:[]}}}let Z=e=>{let{isPrivate:s}=e;return s?(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-700 border border-gray-300",children:"Private"}):(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-700 border border-green-300",children:"Public"})};function z(){let[e,s]=(0,a.useState)([]),[t,E]=(0,a.useState)({runningClusters:0,totalClusters:0,managedJobs:0}),[z,M]=(0,a.useState)(!0),[R,D]=(0,a.useState)(null),[O,T]=(0,a.useState)({key:"name",direction:"asc"}),[W,P]=(0,a.useState)(""),[F,A]=(0,a.useState)(!1),[J,I]=(0,a.useState)({confirmOpen:!1,workspaceToDelete:null,deleting:!1,error:null}),[q,V]=(0,a.useState)({open:!1,message:"",userName:""}),[B,H]=(0,a.useState)(null),[X,U]=(0,a.useState)(!1),[G,K]=(0,a.useState)(null),[$,Q]=(0,a.useState)(null),Y=(0,n.useRouter)(),ee=(0,j.X)(),es=async()=>{if(B&&Date.now()-B.timestamp<3e5)return B;U(!0);try{let e=await y.x.get("/users/role");if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to get user role")}let s=await e.json(),t={role:s.role,name:s.name,timestamp:Date.now()};return H(t),U(!1),t}catch(e){throw U(!1),e}},et=async(e,s)=>{try{let t=await es();if("admin"!==t.role)return V({open:!0,message:e,userName:t.name.toLowerCase()}),!1;return s(),!0}catch(e){return console.error("Failed to check user role:",e),V({open:!0,message:"Error: ".concat(e.message),userName:""}),!1}},er=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e&&M(!0);try{let e=await k.default.get(l.getWorkspaces);D(e);let t=Object.keys(e),r=t.map(async e=>{let[s,t,r]=await Promise.all([k.default.get(l.getEnabledClouds,[e]),k.default.get(S,[e]),k.default.get(L,[e])]);return{workspaceName:e,enabledClouds:s,clusters:t||[],managedJobs:r||{jobs:[]}}}),a=await Promise.all(r),n=[],o=[],i={};a.forEach(e=>{let{workspaceName:s,enabledClouds:t,clusters:r,managedJobs:a}=e;r.forEach(e=>{n.push(e)}),a.jobs.forEach(e=>{o.push(e)}),i[s]=t}),Object.fromEntries(n.map(e=>[e.cluster,e.workspace||"default"]));let c={};t.forEach(e=>{c[e]={name:e,totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:new Set}});let d=0;n.forEach(e=>{let s=e.workspace||"default";c[s]||(c[s]={name:s,totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:new Set}),c[s].totalClusterCount++,("RUNNING"===e.status||"LAUNCHING"===e.status)&&(c[s].runningClusterCount++,d++),e.cloud&&c[s].clouds.add(e.cloud)});let u=new Set(v.statusGroups.active),m=0;(o||[]).forEach(e=>{let s=e.workspace||"default";c[s]&&u.has(e.status)&&c[s].managedJobsCount++,u.has(e.status)&&m++});let h=Object.values(c).filter(e=>t.includes(e.name)).map(e=>{let s=Array.isArray(i[e.name])?i[e.name]:[];return{...e,clouds:s}}).sort((e,s)=>e.name.localeCompare(s.name));s(h),E({runningClusters:d,totalClusters:n.length,managedJobs:m})}catch(e){console.error("Error fetching workspace data:",e),s([]),E({runningClusters:0,totalClusters:0,managedJobs:0})}e&&M(!1)};(0,a.useEffect)(()=>{(async()=>{await b.ZP.preloadForPage("workspaces"),er(!0)})();let e=setInterval(()=>{er(!1)},w.nb.REFRESH_INTERVAL);return()=>clearInterval(e)},[]);let ea=e=>{let s="asc";O.key===e&&"asc"===O.direction&&(s="desc"),T({key:e,direction:s})},en=e=>O.key===e?"asc"===O.direction?" ↑":" ↓":"",el=a.useMemo(()=>{if(!e)return[];let s=e;if(W&&""!==W.trim()){let t=W.toLowerCase().trim();s=e.filter(e=>!!(e.name.toLowerCase().includes(t)||e.clouds.some(e=>{let s=C.Z2[e.toLowerCase()]||e;return e.toLowerCase().includes(t)||s.toLowerCase().includes(t)}))||!!(!0===((null==R?void 0:R[e.name])||{}).private?"private":"public").includes(t))}return(0,N.R0)(s,O.key,O.direction)},[e,O,W,R]),eo=e=>{et("cannot delete workspace",()=>{I({confirmOpen:!0,workspaceToDelete:e,deleting:!1,error:null})})},ei=async()=>{if(J.workspaceToDelete){I(e=>({...e,deleting:!0,error:null}));try{await (0,l.zl)(J.workspaceToDelete),Q('Workspace "'.concat(J.workspaceToDelete,'" deleted successfully!')),I({confirmOpen:!1,workspaceToDelete:null,deleting:!1,error:null}),k.default.invalidate(l.getWorkspaces),k.default.invalidateFunction(S),k.default.invalidateFunction(L),await er(!0)}catch(e){console.error("Error deleting workspace:",e),I(e=>({...e,deleting:!1,error:null})),K(e)}}},ec=()=>{I({confirmOpen:!1,workspaceToDelete:null,deleting:!1,error:null})},ed=e=>{et("cannot edit workspace",()=>{Y.push("/workspaces/".concat(e))})};return z&&0===e.length?(0,r.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,r.jsx)(d.Z,{}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading workspaces..."})]}):(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"fixed top-20 right-4 z-[9999] max-w-md",children:[$&&(0,r.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-4",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}),(0,r.jsx)("div",{className:"ml-3",children:(0,r.jsx)("p",{className:"text-sm font-medium text-green-800",children:$})})]}),(0,r.jsx)("div",{className:"ml-auto pl-3",children:(0,r.jsxs)("button",{type:"button",onClick:()=>Q(null),className:"inline-flex rounded-md bg-green-50 p-1.5 text-green-500 hover:bg-green-100",children:[(0,r.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,r.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})]})})]})}),(0,r.jsx)(h.X,{error:G,title:"Error",onDismiss:()=>K(null)})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2 h-5",children:[(0,r.jsx)("div",{className:"text-base flex items-center",children:(0,r.jsx)("span",{className:"text-sky-blue leading-none",children:"Workspaces"})}),(0,r.jsxs)("div",{className:"flex items-center",children:[z&&(0,r.jsxs)("div",{className:"flex items-center mr-2",children:[(0,r.jsx)(d.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500 text-xs",children:"Refreshing..."})]}),(0,r.jsxs)("button",{onClick:()=>{k.default.invalidate(l.getWorkspaces),k.default.invalidateFunction(l.getEnabledClouds),k.default.invalidateFunction(S),k.default.invalidateFunction(L),er(!0)},disabled:z,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,r.jsx)(x.Z,{className:"h-4 w-4 mr-1.5"}),!ee&&(0,r.jsx)("span",{children:"Refresh"})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"relative flex-1 max-w-md",children:[(0,r.jsx)("input",{type:"text",placeholder:"Filter workspaces",value:W,onChange:e=>P(e.target.value),className:"h-8 w-full px-3 pr-8 text-sm border border-gray-300 rounded-md focus:ring-1 focus:ring-sky-500 focus:border-sky-500 outline-none"}),W&&(0,r.jsx)("button",{onClick:()=>P(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear search",children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("button",{onClick:()=>{et("cannot create workspace",()=>{Y.push("/workspace/new")})},disabled:X,className:"ml-4 bg-sky-600 hover:bg-sky-700 text-white flex items-center rounded-md px-3 py-1 text-sm font-medium transition-colors duration-200",title:"Create Workspace",children:X?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.Z,{size:12,className:"mr-2"}),(0,r.jsx)("span",{children:"Create Workspace"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p.Z,{className:"h-4 w-4 mr-2"}),"Create Workspace"]})})]}),0!==e.length||z?(0,r.jsx)(o.Zb,{children:(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,r.jsxs)(i.iA,{className:"min-w-full",children:[(0,r.jsx)(i.xD,{children:(0,r.jsxs)(i.SC,{children:[(0,r.jsxs)(i.ss,{className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50",onClick:()=>ea("name"),children:["Workspace",en("name")]}),(0,r.jsxs)(i.ss,{className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50",onClick:()=>ea("totalClusterCount"),children:["Clusters ",en("totalClusterCount")]}),(0,r.jsxs)(i.ss,{className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50",onClick:()=>ea("managedJobsCount"),children:["Jobs",en("managedJobsCount")]}),(0,r.jsx)(i.ss,{className:"whitespace-nowrap",children:"Enabled infra"}),(0,r.jsx)(i.ss,{className:"whitespace-nowrap",children:"Actions"})]})}),(0,r.jsx)(i.RM,{children:z&&0===el.length?(0,r.jsx)(i.SC,{children:(0,r.jsx)(i.pj,{colSpan:5,className:"text-center py-6 text-gray-500",children:(0,r.jsxs)("div",{className:"flex justify-center items-center",children:[(0,r.jsx)(d.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading..."})]})})}):el.length>0?el.map(e=>{let s=!0===((null==R?void 0:R[e.name])||{}).private;return(0,r.jsxs)(i.SC,{className:"hover:bg-gray-50",children:[(0,r.jsxs)(i.pj,{className:"",children:[(0,r.jsx)("button",{onClick:()=>ed(e.name),disabled:X,className:"text-blue-600 hover:text-blue-600 hover:underline text-left",children:e.name}),(0,r.jsx)("span",{className:"ml-2",children:(0,r.jsx)(Z,{isPrivate:s})})]}),(0,r.jsx)(i.pj,{children:(0,r.jsxs)("button",{onClick:()=>{Y.push({pathname:"/clusters",query:{workspace:e.name}})},className:"text-gray-700 hover:text-blue-600 hover:underline",children:[e.runningClusterCount," running,"," ",e.totalClusterCount," total"]})}),(0,r.jsx)(i.pj,{children:(0,r.jsx)("button",{onClick:()=>{Y.push({pathname:"/jobs",query:{workspace:e.name}})},className:"text-gray-700 hover:text-blue-600 hover:underline",children:e.managedJobsCount})}),(0,r.jsx)(i.pj,{children:e.clouds.length>0?[...e.clouds].sort().map((s,t)=>{let a=C.Z2[s.toLowerCase()]||s;return(0,r.jsxs)("span",{children:[(0,r.jsx)(_(),{href:"/infra",className:"inline-flex items-center px-2 py-1 rounded text-sm bg-sky-100 text-sky-800 hover:bg-sky-200 hover:text-sky-900 transition-colors duration-200",children:a}),t<e.clouds.length-1&&" "]},s)}):(0,r.jsx)("span",{className:"text-gray-500 text-sm",children:"-"})}),(0,r.jsxs)(i.pj,{children:[(0,r.jsx)(c.z,{variant:"ghost",size:"sm",onClick:()=>ed(e.name),disabled:X,className:"text-gray-600 hover:text-gray-800 mr-1",children:(0,r.jsx)(f,{className:"w-4 h-4"})}),(0,r.jsx)(c.z,{variant:"ghost",size:"sm",onClick:()=>eo(e.name),disabled:"default"===e.name||X,title:"default"===e.name?"Cannot delete default workspace":"Delete workspace",className:"text-red-600 hover:text-red-700 hover:bg-red-50",children:(0,r.jsx)(g.Z,{className:"w-4 h-4"})})]})]},e.name)}):(0,r.jsx)(i.SC,{children:(0,r.jsx)(i.pj,{colSpan:5,className:"text-center py-6 text-gray-500",children:"No workspaces found"})})})]})})}):(0,r.jsxs)("div",{className:"text-center py-10",children:[(0,r.jsx)("p",{className:"text-lg text-gray-600",children:"No workspaces found."}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-2",children:"Create a cluster to see its workspace here."})]}),R&&(0,r.jsx)(m.Vq,{open:F,onOpenChange:A,children:(0,r.jsxs)(m.cZ,{className:"sm:max-w-md md:max-w-lg lg:max-w-xl xl:max-w-2xl w-full max-h-[90vh] flex flex-col",children:[(0,r.jsx)(m.fK,{children:(0,r.jsx)(m.$N,{className:"pr-10",children:"All Workspaces Configuration"})}),(0,r.jsx)("div",{className:"flex-grow overflow-y-auto py-4",children:(0,r.jsx)("pre",{style:{backgroundColor:"#f5f5f5",padding:"16px",borderRadius:"8px",overflowX:"auto",whiteSpace:"pre",wordBreak:"normal"},children:u.ZP.dump(R,{indent:2})})})]})}),(0,r.jsx)(m.Vq,{open:q.open,onOpenChange:e=>{V(s=>({...s,open:e})),e||K(null)},children:(0,r.jsxs)(m.cZ,{className:"sm:max-w-md transition-all duration-200 ease-in-out",children:[(0,r.jsxs)(m.fK,{children:[(0,r.jsx)(m.$N,{children:"Permission Denied"}),(0,r.jsx)(m.Be,{children:X?(0,r.jsxs)("div",{className:"flex items-center py-2",children:[(0,r.jsx)(d.Z,{size:16,className:"mr-2"}),(0,r.jsx)("span",{children:"Checking permissions..."})]}):(0,r.jsx)(r.Fragment,{children:q.userName?(0,r.jsxs)(r.Fragment,{children:[q.userName," is logged in as non-admin and ",q.message,"."]}):q.message})})]}),(0,r.jsx)(m.cN,{children:(0,r.jsx)(c.z,{variant:"outline",onClick:()=>V(e=>({...e,open:!1})),disabled:X,children:"OK"})})]})}),(0,r.jsx)(m.Vq,{open:J.confirmOpen,onOpenChange:e=>{e||(ec(),K(null))},children:(0,r.jsxs)(m.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(m.fK,{children:[(0,r.jsx)(m.$N,{children:"Delete Workspace"}),(0,r.jsxs)(m.Be,{children:['Are you sure you want to delete workspace "',J.workspaceToDelete,'"? This action cannot be undone.']})]}),(0,r.jsxs)(m.cN,{children:[(0,r.jsx)(c.z,{variant:"outline",onClick:ec,disabled:J.deleting,children:"Cancel"}),(0,r.jsx)(c.z,{variant:"destructive",onClick:ei,disabled:J.deleting,children:J.deleting?"Deleting...":"Delete"})]})]})})]})}w.nb.REFRESH_INTERVAL},23001:function(e,s,t){t.d(s,{X:function(){return a}});var r=t(67294);function a(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:768,[s,t]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let s=()=>{t(window.innerWidth<e)};return s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}},[e]),s}},12003:function(e,s,t){t.d(s,{j:function(){return l}});var r=t(90512);let a=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,n=r.W,l=(e,s)=>t=>{var r;if((null==s?void 0:s.variants)==null)return n(e,null==t?void 0:t.class,null==t?void 0:t.className);let{variants:l,defaultVariants:o}=s,i=Object.keys(l).map(e=>{let s=null==t?void 0:t[e],r=null==o?void 0:o[e];if(null===s)return null;let n=a(s)||a(r);return l[e][n]}),c=t&&Object.entries(t).reduce((e,s)=>{let[t,r]=s;return void 0===r||(e[t]=r),e},{});return n(e,i,null==s?void 0:null===(r=s.compoundVariants)||void 0===r?void 0:r.reduce((e,s)=>{let{class:t,className:r,...a}=s;return Object.entries(a).every(e=>{let[s,t]=e;return Array.isArray(t)?t.includes({...o,...c}[s]):({...o,...c})[s]===t})?[...e,t,r]:e},[]),null==t?void 0:t.class,null==t?void 0:t.className)}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[722],{58706:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/clusters/[cluster]",function(){return s(56996)}])},1125:function(e,t,s){"use strict";s.d(t,{C:function(){return c}});var a=s(85893),r=s(67294),l=s(34209),n=s(84283);let i=e=>{if(!e||"string"!=typeof e)return e;let t=e.split("\n"),s=[];for(let e=0;e<t.length;e++){let a=t[e];if(""===a.trim()){let r=!1,l=0;for(let s=e-1;s>=0;s--){let e=t[s],a=e.trim();if(a&&e.match(/:\s*[|>]\s*$/)){r=!0;for(let e=s+1;e<t.length;e++){let s=t[e];if(s.trim()){l=s.search(/\S/);break}}break}if(a&&0===e.search(/\S/))break}if(r)for(let r=e+1;r<t.length;r++){let e=t[r];if(e.trim()){e.search(/\S/)>=l?s.push(" #YAML_BLANK_LINE_MARKER#"):s.push(a);break}}else s.push(a)}else s.push(a)}return s.join("\n")};function c(e){let{children:t,className:s=""}=e,c=(0,r.useRef)(null),o=i(t);(0,r.useEffect)(()=>{if(c.current){let e=c.current;setTimeout(()=>{let t;let s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);for(;t=s.nextNode();)t.textContent&&t.textContent.includes("#YAML_BLANK_LINE_MARKER#")&&(t.textContent=t.textContent.replace(/#YAML_BLANK_LINE_MARKER#/g,""))},0)}},[o]);let d={...n.mQ,'code[class*="language-"]':{...n.mQ['code[class*="language-"]'],whiteSpace:"pre !important"},'pre[class*="language-"]':{...n.mQ['pre[class*="language-"]'],whiteSpace:"pre !important"}};return(0,a.jsx)("div",{ref:c,className:s,children:(0,a.jsx)(l.Z,{language:"yaml",style:d,customStyle:{margin:0,padding:0,background:"transparent",fontSize:"0.875rem",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace'},wrapLines:!0,wrapLongLines:!0,showLineNumbers:!1,useInlineStyles:!0,children:o})})}},84303:function(e,t,s){"use strict";s.d(t,{_q:function(){return l},pJ:function(){return c}});var a=s(1272);let r={lineWidth:-1,quotingType:"'",forceQuotes:!1,noRefs:!0,sortKeys:!1,condenseFlow:!1,indent:2},l=e=>{if(!e)return"No YAML available";try{let t=a.ZP.load(e),s=a.ZP.dump(t,r).split("\n"),l=[],n=-1;for(let e=0;e<s.length;e++){let t=s[e],a=t.search(/\S/);0===a&&n>=0&&e>0&&l.push(""),l.push(t),n=a}return l.join("\n").trim()}catch(t){return console.error("YAML formatting error:",t),e}},n=e=>"string"==typeof e?e.substring(0,50)+"...":e&&e.name?"name: ".concat(e.name):e&&e.resources?"Task configuration":"YAML document",i=(e,t)=>{try{let s=a.ZP.load(e),l=a.ZP.dump(s,r).split("\n"),i=[],c=-1;for(let e=0;e<l.length;e++){let t=l[e],s=t.search(/\S/);0===s&&c>=0&&e>0&&i.push(""),i.push(t),c=s}return{index:t,content:i.join("\n").trim(),preview:n(s)}}catch(s){return console.error("YAML formatting error for document ".concat(t,":"),s),{index:t,content:e,preview:"Invalid YAML"}}},c=e=>{if(!e)return[];try{let t=[],s=e.split(/^---$/m);for(let e=0;e<s.length;e++){let a=s[e].trim();a&&""!==a&&t.push(a)}return(t.length>1?t.slice(1):t).map((e,t)=>i(e,t))}catch(t){return console.error("YAML formatting error:",t),[{index:0,content:e,preview:"Invalid YAML"}]}}},56996:function(e,t,s){"use strict";s.r(t);var a=s(85893),r=s(67294),l=s(55739),n=s(23015),i=s(11163);s(6135);var c=s(41664),o=s.n(c),d=s(39037),u=s(99307);s(37673);var m=s(23266),x=s(6378),h=s(13626),f=s(70282),g=s(27325),v=s(45895),j=s(6639);s(1272);var b=s(36989),p=s(17853),N=s(92128),y=s(23001),_=s(9008),w=s.n(_),S=s(84303),C=s(20546),k=s(1125);let M=(e,t)=>{let s="",a="";return e>=0&&(s=e+"m",a=" "),t&&(s+="".concat(a,"(down)")),""===s&&(s="-"),s};function L(e){var t,s,l,i;let{clusterData:c,clusterJobData:d,clusterJobsLoading:m,refreshClusterJobsOnly:x,isVSCodeModalOpen:h,setIsVSCodeModalOpen:p,timeRange:N,handleTimeRangePreset:y,buildGrafanaMetricsUrl:_,matchedClusterName:w,isLoadingClusterMatch:L,isGrafanaAvailable:A,isHistoricalCluster:E=!1}=e,[R,T]=(0,r.useState)(!1),[O,P]=(0,r.useState)(!1),[I,Z]=(0,r.useState)(!1),U=async()=>{try{let e=c.task_yaml||c.last_creation_yaml,t=(0,S._q)(e);await navigator.clipboard.writeText(t),P(!0),setTimeout(()=>P(!1),2e3)}catch(e){console.error("Failed to copy YAML to clipboard:",e)}},Y=async()=>{try{let e=c.command||c.last_creation_command;await navigator.clipboard.writeText(e),Z(!0),setTimeout(()=>Z(!1),2e3)}catch(e){console.error("Failed to copy command to clipboard:",e)}},D=(null==c?void 0:c.last_creation_command)||(null==c?void 0:c.last_creation_yaml)||(null==c?void 0:c.command)||(null==c?void 0:c.task_yaml);return(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-6",children:(0,a.jsxs)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm",children:[(0,a.jsx)("div",{className:"flex items-center justify-between px-4 pt-4",children:(0,a.jsx)("h3",{className:"text-lg font-semibold",children:E?"Historical Cluster Details":"Details"})}),(0,a.jsx)("div",{className:"p-4",children:(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Status"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(0,a.jsx)(u.OE,{status:c.status})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Cluster"}),(0,a.jsx)("div",{className:"text-base mt-1",children:c.cluster_name_on_cloud?(0,a.jsx)(b.Md,{content:"Name on ".concat(c.cloud||(null===(s=c.infra)||void 0===s?void 0:null===(t=s.split("(")[0])||void 0===t?void 0:t.trim())||"cloud",": ").concat(c.cluster_name_on_cloud),className:"text-sm text-muted-foreground",children:(0,a.jsx)("span",{className:"border-b border-dotted border-gray-400 cursor-help",children:c.cluster||c.name})}):c.cluster||c.name})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"User"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(0,a.jsx)(C.H,{username:c.user,userHash:c.user_hash})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:E?"Cloud":"Infra"}),(0,a.jsx)("div",{className:"text-base mt-1",children:E?c.cloud||"N/A":c.infra?(0,a.jsx)(b.Md,{content:c.full_infra||c.infra,className:"text-sm text-muted-foreground",children:(0,a.jsxs)("span",{children:[(0,a.jsx)(o(),{href:"/infra",className:"text-blue-600 hover:underline",children:c.cloud||c.infra.split("(")[0].trim()}),c.infra.includes("(")&&(0,a.jsx)("span",{children:" "+c.infra.substring(c.infra.indexOf("("))})]})}):"N/A"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Resources"}),(0,a.jsx)("div",{className:"text-base mt-1",children:c.resources_str_full||c.resources_str||"N/A"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Started"}),(0,a.jsx)("div",{className:"text-base mt-1",children:c.time?(0,b.xn)(new Date(c.time)):"N/A"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Last Event"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(0,a.jsx)(b.Md,{content:c.last_event||"-",className:"text-sm text-muted-foreground",children:(0,a.jsx)("span",{children:c.last_event||"-"})})})]}),E?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Duration"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(e=>{if(!e||0===e)return"-";let t=e=Math.floor(e),s="",a=0;for(let e of[{value:31536e3,label:"y"},{value:2592e3,label:"mo"},{value:86400,label:"d"},{value:3600,label:"h"},{value:60,label:"m"},{value:1,label:"s"}])if(t>=e.value&&a<2){let r=Math.floor(t/e.value);s+="".concat(r).concat(e.label," "),t%=e.value,a++}return s.trim()||"0s"})(c.duration)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Cost"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(e=>{if(null==e||0===e)return"-";let t=Number(e);return isNaN(t)?"-":"$".concat(t.toFixed(2))})(c.total_cost)})]})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Autostop"}),(0,a.jsx)("div",{className:"text-base mt-1",children:M(c.autostop,c.to_down)})]}),D&&(0,a.jsxs)("div",{className:"col-span-2",children:[(c.command||c.last_creation_command)&&(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Entrypoint"}),c.command&&(0,a.jsx)(b.WH,{content:I?"Copied!":"Copy command",className:"text-muted-foreground",children:(0,a.jsx)("button",{onClick:Y,className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",children:I?(0,a.jsx)(f.Z,{className:"w-4 h-4 text-green-600"}):(0,a.jsx)(g.Z,{className:"w-4 h-4"})})})]}),(0,a.jsxs)("div",{className:"space-y-4 mt-3",children:[(c.command||c.last_creation_command)&&(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-3",children:(0,a.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all",children:c.command||c.last_creation_command})})}),(c.task_yaml||c.last_creation_yaml)&&"{}"!==c.task_yaml&&"{}"!==c.last_creation_yaml&&!(null===(l=c.cluster||c.name)||void 0===l?void 0:l.startsWith("sky-jobs-controller-"))&&!(null===(i=c.cluster||c.name)||void 0===i?void 0:i.startsWith("sky-serve-controller-"))&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center mb-2",children:[(0,a.jsxs)("button",{onClick:()=>{T(!R)},className:"flex items-center text-left focus:outline-none text-gray-700 hover:text-gray-900 transition-colors duration-200",children:[R?(0,a.jsx)(v.Z,{className:"w-4 h-4 mr-1"}):(0,a.jsx)(j.Z,{className:"w-4 h-4 mr-1"}),(0,a.jsx)("span",{className:"text-base",children:"Show SkyPilot YAML"})]}),(0,a.jsx)(b.WH,{content:O?"Copied!":"Copy YAML",className:"text-muted-foreground",children:(0,a.jsx)("button",{onClick:U,className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",children:O?(0,a.jsx)(f.Z,{className:"w-4 h-4 text-green-600"}):(0,a.jsx)(g.Z,{className:"w-4 h-4"})})})]}),R&&(0,a.jsx)("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-3 max-h-96 overflow-y-auto",children:(0,a.jsx)(k.C,{className:"whitespace-pre-wrap",children:(0,S._q)(c.task_yaml||c.last_creation_yaml)})})]})]})]})]})})]})}),c&&c.full_infra&&c.full_infra.includes("Kubernetes")&&!c.full_infra.includes("SSH")&&!c.full_infra.includes("ssh")&&A&&(0,a.jsx)("div",{className:"mb-6",children:(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"GPU Metrics"})}),(0,a.jsxs)("div",{className:"mb-4 p-4 bg-gray-50 rounded-md border border-gray-200",children:[(0,a.jsx)("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium text-gray-700 whitespace-nowrap",children:"Time Range:"}),(0,a.jsx)("div",{className:"flex gap-1",children:[{label:"15m",value:"15m"},{label:"1h",value:"1h"},{label:"6h",value:"6h"},{label:"24h",value:"24h"},{label:"7d",value:"7d"}].map(e=>(0,a.jsx)("button",{onClick:()=>y(e.value),className:"px-2 py-1 text-xs font-medium rounded border transition-colors ".concat(N.from==="now-".concat(e.value)&&"now"===N.to?"bg-sky-blue text-white border-sky-blue":"bg-white text-gray-600 border-gray-300 hover:bg-gray-50"),children:e.label},e.value))})]})}),(0,a.jsxs)("div",{className:"mt-2 text-xs text-gray-500",children:["Showing: ",null==c?void 0:c.cluster," • Time: ",N.from," to"," ",N.to,L&&(0,a.jsx)("span",{children:" • Finding cluster data..."})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:_("1"),width:"100%",height:"400",frameBorder:"0",title:"GPU Utilization",className:"rounded"},"gpu-util-".concat(null==c?void 0:c.cluster,"-").concat(N.from,"-").concat(N.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:_("2"),width:"100%",height:"400",frameBorder:"0",title:"GPU Memory Utilization",className:"rounded"},"gpu-memory-".concat(null==c?void 0:c.cluster,"-").concat(N.from,"-").concat(N.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:_("4"),width:"100%",height:"400",frameBorder:"0",title:"GPU Power Usage",className:"rounded"},"gpu-power-".concat(null==c?void 0:c.cluster,"-").concat(N.from,"-").concat(N.to))})})]})]})})}),!E&&(0,a.jsx)("div",{className:"mb-8",children:(0,a.jsx)(n.ClusterJobs,{clusterName:c.cluster,clusterJobData:d,loading:m,refreshClusterJobsOnly:x,workspace:c.workspace})})]})}t.default=function(){let e=(0,i.useRouter)(),{cluster:t}=e.query,[s,n]=(0,r.useState)(!1),[c,u]=(0,r.useState)(!0),[f,g]=(0,r.useState)(!1),[v,j]=(0,r.useState)(!1),[_,S]=(0,r.useState)(null),[C,k]=(0,r.useState)(!1),[M,A]=(0,r.useState)(!1),E=(0,y.X)(),[R,T]=(0,r.useState)({from:"now-1h",to:"now"}),{clusterData:O,clusterJobData:P,loading:I,clusterDetailsLoading:Z,clusterJobsLoading:U,refreshData:Y,refreshClusterJobsOnly:D}=(0,m.QL)({cluster:t}),[F,G]=(0,r.useState)(null),[H,J]=(0,r.useState)(!1),[W,K]=(0,r.useState)(!1);(0,r.useEffect)(()=>{(async()=>{K(await (0,p.TO)())})()},[]);let z=(0,r.useCallback)(async()=>{if(W&&(null==O?void 0:O.cluster)){J(!0);try{let e=(0,p.ki)(),t=await fetch("".concat(e).concat("/api/datasources/proxy/1/api/v1/label/label_skypilot_cluster/values"),{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(t.ok){let e=await t.json();if(e.data&&e.data.length>0){let t=e.data.find(e=>e.startsWith(O.cluster));t&&G(t)}}}catch(e){console.error("Error fetching matching cluster:",e)}finally{J(!1)}}},[null==O?void 0:O.cluster,W]);(0,r.useEffect)(()=>{W&&(null==O?void 0:O.cluster)&&z()},[null==O?void 0:O.cluster,z,W]);let B=e=>{let t=(0,p.ki)(),s=F||(null==O?void 0:O.cluster)||"$__all";return"".concat(t,"/d-solo/skypilot-dcgm-gpu/skypilot-dcgm-gpu-metrics?orgId=1&from=").concat(encodeURIComponent(R.from),"&to=").concat(encodeURIComponent(R.to),"&timezone=browser&var-cluster=").concat(encodeURIComponent(s),"&var-node=$__all&var-gpu=$__all&theme=light&panelId=").concat(e,"&__feature.dashboardSceneSolo")};r.useEffect(()=>{!Z&&c&&u(!1)},[Z,c]),r.useEffect(()=>{let e=async()=>{if(t&&!Z&&!O){A(!0);try{let e=(await x.default.get(m.uR,[t])).find(e=>e.cluster_hash===t||e.cluster===t);e&&(S(e),k(!0))}catch(e){console.error("Error fetching cluster history:",e)}finally{A(!1)}}};Z||O||e()},[t,Z,O]);let $=async()=>{n(!0),await Y(),n(!1)},q=e=>{T({from:"now-".concat(e),to:"now"})};if(!e.isReady)return(0,a.jsx)("div",{children:"Loading..."});let Q=t?"Cluster: ".concat(t," | SkyPilot Dashboard"):"Cluster Details | SkyPilot Dashboard";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(w(),{children:(0,a.jsx)("title",{children:Q})}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,a.jsxs)("div",{className:"text-base flex items-center",children:[(0,a.jsx)(o(),{href:"/clusters",className:"text-sky-blue hover:underline",children:"Sky Clusters"}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsx)(o(),{href:"/clusters/".concat(t),className:"text-sky-blue hover:underline",children:t})]}),(0,a.jsx)("div",{className:"text-sm flex items-center",children:(0,a.jsxs)("div",{className:"text-sm flex items-center",children:[(Z||s)&&(0,a.jsxs)("div",{className:"flex items-center mr-4",children:[(0,a.jsx)(l.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),O&&(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,a.jsx)(b.WH,{content:"Refresh",className:"text-sm text-muted-foreground",children:(0,a.jsxs)("button",{onClick:$,disabled:Z||s,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:[(0,a.jsx)(h.Z,{className:"w-4 h-4 mr-1.5"}),!E&&(0,a.jsx)("span",{children:"Refresh"})]})}),(0,a.jsx)(d.Status2Actions,{withLabel:!0,cluster:O.cluster,status:O.status,onOpenSSHModal:()=>{g(!0)},onOpenVSCodeModal:()=>{j(!0)}})]})]})})]}),Z&&c||M?(0,a.jsxs)("div",{className:"flex justify-center items-center py-12",children:[(0,a.jsx)(l.Z,{size:24,className:"mr-2"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading cluster details..."})]}):O?(0,a.jsx)(L,{clusterData:O,clusterJobData:P,clusterJobsLoading:U,refreshClusterJobsOnly:D,isVSCodeModalOpen:v,setIsVSCodeModalOpen:j,timeRange:R,handleTimeRangePreset:q,buildGrafanaMetricsUrl:B,matchedClusterName:F,isLoadingClusterMatch:H,isGrafanaAvailable:W,isHistoricalCluster:!1}):C&&_?(0,a.jsx)(L,{clusterData:_,clusterJobData:[],clusterJobsLoading:!1,refreshClusterJobsOnly:()=>{},isVSCodeModalOpen:!1,setIsVSCodeModalOpen:()=>{},timeRange:R,handleTimeRangePreset:q,buildGrafanaMetricsUrl:B,matchedClusterName:null,isLoadingClusterMatch:!1,isGrafanaAvailable:!1,isHistoricalCluster:!0}):(0,a.jsx)("div",{className:"flex justify-center items-center py-12",children:(0,a.jsx)("span",{className:"text-gray-500",children:"Cluster not found in active clusters or history."})}),(0,a.jsx)(N.Oh,{isOpen:f,onClose:()=>g(!1),cluster:t}),(0,a.jsx)(N._R,{isOpen:v,onClose:()=>j(!1),cluster:t})]})]})}},17853:function(e,t,s){"use strict";s.d(t,{TO:function(){return l},ki:function(){return n}});let a=null,r=null,l=async()=>null!==a?a:r||(r=(async()=>{try{let e="".concat(window.location.origin,"/grafana"),t=await fetch("".concat(e,"/api/health"),{method:"GET",credentials:"include",headers:{Accept:"application/json"},signal:AbortSignal.timeout(5e3)});return 200==t.status}catch(e){return console.debug("Grafana availability check failed:",e),a=!1,!1}finally{r=null}})()),n=()=>"".concat(window.location.origin,"/grafana")}},function(e){e.O(0,[616,6130,5739,7411,1272,7359,6212,6989,3850,8969,6990,6135,4282,6601,3015,6856,1871,2888,9774,179],function(){return e(e.s=58706)}),_N_E=e.O()}]);
|