skypilot-nightly 1.0.0.dev20251009__py3-none-any.whl → 1.0.0.dev20251107__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 +6 -2
- sky/adaptors/aws.py +25 -7
- sky/adaptors/coreweave.py +278 -0
- sky/adaptors/kubernetes.py +64 -0
- sky/adaptors/shadeform.py +89 -0
- sky/admin_policy.py +20 -0
- sky/authentication.py +59 -149
- sky/backends/backend_utils.py +104 -63
- sky/backends/cloud_vm_ray_backend.py +84 -39
- sky/catalog/data_fetchers/fetch_runpod.py +698 -0
- sky/catalog/data_fetchers/fetch_shadeform.py +142 -0
- sky/catalog/kubernetes_catalog.py +24 -28
- sky/catalog/runpod_catalog.py +5 -1
- sky/catalog/shadeform_catalog.py +165 -0
- sky/check.py +25 -13
- sky/client/cli/command.py +335 -86
- sky/client/cli/flags.py +4 -2
- sky/client/cli/table_utils.py +17 -9
- sky/client/sdk.py +59 -12
- sky/cloud_stores.py +73 -0
- sky/clouds/__init__.py +2 -0
- sky/clouds/aws.py +71 -16
- sky/clouds/azure.py +12 -5
- sky/clouds/cloud.py +19 -9
- sky/clouds/cudo.py +12 -5
- sky/clouds/do.py +4 -1
- sky/clouds/fluidstack.py +12 -5
- sky/clouds/gcp.py +12 -5
- sky/clouds/hyperbolic.py +12 -5
- sky/clouds/ibm.py +12 -5
- sky/clouds/kubernetes.py +62 -25
- sky/clouds/lambda_cloud.py +12 -5
- sky/clouds/nebius.py +12 -5
- sky/clouds/oci.py +12 -5
- sky/clouds/paperspace.py +4 -1
- sky/clouds/primeintellect.py +4 -1
- sky/clouds/runpod.py +12 -5
- sky/clouds/scp.py +12 -5
- sky/clouds/seeweb.py +4 -1
- sky/clouds/shadeform.py +400 -0
- sky/clouds/ssh.py +4 -2
- sky/clouds/vast.py +12 -5
- sky/clouds/vsphere.py +4 -1
- sky/core.py +12 -11
- sky/dashboard/out/404.html +1 -1
- sky/dashboard/out/_next/static/chunks/1141-e6aa9ab418717c59.js +11 -0
- sky/dashboard/out/_next/static/chunks/{1871-49141c317f3a9020.js → 1871-74503c8e80fd253b.js} +1 -1
- sky/dashboard/out/_next/static/chunks/2260-7703229c33c5ebd5.js +1 -0
- sky/dashboard/out/_next/static/chunks/2755.fff53c4a3fcae910.js +26 -0
- sky/dashboard/out/_next/static/chunks/3294.72362fa129305b19.js +1 -0
- sky/dashboard/out/_next/static/chunks/{3785.a19328ba41517b8b.js → 3785.ad6adaa2a0fa9768.js} +1 -1
- sky/dashboard/out/_next/static/chunks/{4725.10f7a9a5d3ea8208.js → 4725.a830b5c9e7867c92.js} +1 -1
- sky/dashboard/out/_next/static/chunks/6856-ef8ba11f96d8c4a3.js +1 -0
- sky/dashboard/out/_next/static/chunks/6990-32b6e2d3822301fa.js +1 -0
- sky/dashboard/out/_next/static/chunks/7615-3301e838e5f25772.js +1 -0
- sky/dashboard/out/_next/static/chunks/8969-1e4613c651bf4051.js +1 -0
- sky/dashboard/out/_next/static/chunks/9025.fa408f3242e9028d.js +6 -0
- sky/dashboard/out/_next/static/chunks/9353-cff34f7e773b2e2b.js +1 -0
- sky/dashboard/out/_next/static/chunks/9360.7310982cf5a0dc79.js +31 -0
- sky/dashboard/out/_next/static/chunks/pages/{_app-ce361c6959bc2001.js → _app-bde01e4a2beec258.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-c736ead69c2d86ec.js +16 -0
- sky/dashboard/out/_next/static/chunks/pages/clusters/{[cluster]-477555ab7c0b13d8.js → [cluster]-a37d2063af475a1c.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/{clusters-2f61f65487f6d8ff.js → clusters-d44859594e6f8064.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/infra/{[context]-553b8b5cb65e100b.js → [context]-c0b5935149902e6f.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/{infra-910a22500c50596f.js → infra-aed0ea19df7cf961.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-5796e8d6aea291a0.js +16 -0
- sky/dashboard/out/_next/static/chunks/pages/jobs/pools/{[pool]-bc979970c247d8f3.js → [pool]-6edeb7d06032adfc.js} +2 -2
- sky/dashboard/out/_next/static/chunks/pages/{jobs-a35a9dc3c5ccd657.js → jobs-479dde13399cf270.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/{users-98d2ed979084162a.js → users-5ab3b907622cf0fe.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/{volumes-835d14ba94808f79.js → volumes-b84b948ff357c43e.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/workspaces/{[name]-e8688c35c06f0ac5.js → [name]-c5a3eeee1c218af1.js} +1 -1
- sky/dashboard/out/_next/static/chunks/pages/{workspaces-69c80d677d3c2949.js → workspaces-22b23febb3e89ce1.js} +1 -1
- sky/dashboard/out/_next/static/chunks/webpack-2679be77fc08a2f8.js +1 -0
- sky/dashboard/out/_next/static/css/0748ce22df867032.css +3 -0
- sky/dashboard/out/_next/static/zB0ed6ge_W1MDszVHhijS/_buildManifest.js +1 -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/data/data_utils.py +92 -1
- sky/data/mounting_utils.py +143 -19
- sky/data/storage.py +168 -11
- sky/exceptions.py +13 -1
- sky/execution.py +13 -0
- sky/global_user_state.py +189 -113
- sky/jobs/client/sdk.py +32 -10
- sky/jobs/client/sdk_async.py +9 -3
- sky/jobs/constants.py +3 -1
- sky/jobs/controller.py +164 -192
- sky/jobs/file_content_utils.py +80 -0
- sky/jobs/log_gc.py +201 -0
- sky/jobs/recovery_strategy.py +59 -82
- sky/jobs/scheduler.py +20 -9
- sky/jobs/server/core.py +105 -23
- sky/jobs/server/server.py +40 -28
- sky/jobs/server/utils.py +32 -11
- sky/jobs/state.py +588 -110
- sky/jobs/utils.py +442 -209
- sky/logs/agent.py +1 -1
- sky/metrics/utils.py +45 -6
- sky/optimizer.py +1 -1
- sky/provision/__init__.py +7 -0
- sky/provision/aws/instance.py +2 -1
- sky/provision/azure/instance.py +2 -1
- sky/provision/common.py +2 -0
- sky/provision/cudo/instance.py +2 -1
- sky/provision/do/instance.py +2 -1
- sky/provision/fluidstack/instance.py +4 -3
- sky/provision/gcp/instance.py +2 -1
- sky/provision/hyperbolic/instance.py +2 -1
- sky/provision/instance_setup.py +10 -2
- sky/provision/kubernetes/constants.py +0 -1
- sky/provision/kubernetes/instance.py +222 -89
- sky/provision/kubernetes/network.py +12 -8
- sky/provision/kubernetes/utils.py +114 -53
- sky/provision/kubernetes/volume.py +5 -4
- sky/provision/lambda_cloud/instance.py +2 -1
- sky/provision/nebius/instance.py +2 -1
- sky/provision/oci/instance.py +2 -1
- sky/provision/paperspace/instance.py +2 -1
- sky/provision/provisioner.py +11 -2
- sky/provision/runpod/instance.py +2 -1
- sky/provision/scp/instance.py +2 -1
- sky/provision/seeweb/instance.py +3 -3
- sky/provision/shadeform/__init__.py +11 -0
- sky/provision/shadeform/config.py +12 -0
- sky/provision/shadeform/instance.py +351 -0
- sky/provision/shadeform/shadeform_utils.py +83 -0
- sky/provision/vast/instance.py +2 -1
- sky/provision/vsphere/instance.py +2 -1
- sky/resources.py +1 -1
- sky/schemas/api/responses.py +9 -5
- sky/schemas/db/skypilot_config/001_initial_schema.py +30 -0
- sky/schemas/db/spot_jobs/004_job_file_contents.py +42 -0
- sky/schemas/db/spot_jobs/005_logs_gc.py +38 -0
- sky/schemas/generated/jobsv1_pb2.py +52 -52
- sky/schemas/generated/jobsv1_pb2.pyi +4 -2
- sky/schemas/generated/managed_jobsv1_pb2.py +39 -35
- sky/schemas/generated/managed_jobsv1_pb2.pyi +21 -5
- sky/serve/client/impl.py +11 -3
- sky/serve/replica_managers.py +5 -2
- sky/serve/serve_utils.py +9 -2
- sky/serve/server/impl.py +7 -2
- sky/serve/server/server.py +18 -15
- sky/serve/service.py +2 -2
- sky/server/auth/oauth2_proxy.py +2 -5
- sky/server/common.py +31 -28
- sky/server/constants.py +5 -1
- sky/server/daemons.py +27 -19
- sky/server/requests/executor.py +138 -74
- sky/server/requests/payloads.py +9 -1
- sky/server/requests/preconditions.py +13 -10
- sky/server/requests/request_names.py +120 -0
- sky/server/requests/requests.py +485 -153
- sky/server/requests/serializers/decoders.py +26 -13
- sky/server/requests/serializers/encoders.py +56 -11
- sky/server/requests/threads.py +106 -0
- sky/server/rest.py +70 -18
- sky/server/server.py +283 -104
- sky/server/stream_utils.py +233 -59
- sky/server/uvicorn.py +18 -17
- sky/setup_files/alembic.ini +4 -0
- sky/setup_files/dependencies.py +32 -13
- sky/sky_logging.py +0 -2
- sky/skylet/constants.py +30 -7
- sky/skylet/events.py +7 -0
- sky/skylet/log_lib.py +8 -2
- sky/skylet/log_lib.pyi +1 -1
- sky/skylet/services.py +26 -13
- sky/skylet/subprocess_daemon.py +103 -29
- sky/skypilot_config.py +87 -75
- sky/ssh_node_pools/server.py +9 -8
- sky/task.py +67 -54
- sky/templates/kubernetes-ray.yml.j2 +8 -1
- sky/templates/nebius-ray.yml.j2 +1 -0
- sky/templates/shadeform-ray.yml.j2 +72 -0
- sky/templates/websocket_proxy.py +142 -12
- sky/users/permission.py +8 -1
- sky/utils/admin_policy_utils.py +16 -3
- sky/utils/asyncio_utils.py +78 -0
- sky/utils/auth_utils.py +153 -0
- sky/utils/cli_utils/status_utils.py +8 -2
- sky/utils/command_runner.py +11 -0
- sky/utils/common.py +3 -1
- sky/utils/common_utils.py +7 -4
- sky/utils/context.py +57 -51
- sky/utils/context_utils.py +30 -12
- sky/utils/controller_utils.py +35 -8
- sky/utils/db/db_utils.py +37 -10
- sky/utils/db/migration_utils.py +8 -4
- sky/utils/locks.py +24 -6
- sky/utils/resource_checker.py +4 -1
- sky/utils/resources_utils.py +53 -29
- sky/utils/schemas.py +23 -4
- sky/utils/subprocess_utils.py +17 -4
- sky/volumes/server/server.py +7 -6
- sky/workspaces/server.py +13 -12
- {skypilot_nightly-1.0.0.dev20251009.dist-info → skypilot_nightly-1.0.0.dev20251107.dist-info}/METADATA +306 -55
- {skypilot_nightly-1.0.0.dev20251009.dist-info → skypilot_nightly-1.0.0.dev20251107.dist-info}/RECORD +215 -195
- sky/dashboard/out/_next/static/chunks/1121-d0782b9251f0fcd3.js +0 -1
- sky/dashboard/out/_next/static/chunks/1141-3b40c39626f99c89.js +0 -11
- sky/dashboard/out/_next/static/chunks/2755.97300e1362fe7c98.js +0 -26
- sky/dashboard/out/_next/static/chunks/3015-8d748834fcc60b46.js +0 -1
- sky/dashboard/out/_next/static/chunks/3294.1fafbf42b3bcebff.js +0 -1
- sky/dashboard/out/_next/static/chunks/6135-4b4d5e824b7f9d3c.js +0 -1
- sky/dashboard/out/_next/static/chunks/6856-5fdc9b851a18acdb.js +0 -1
- sky/dashboard/out/_next/static/chunks/6990-f6818c84ed8f1c86.js +0 -1
- sky/dashboard/out/_next/static/chunks/8969-66237729cdf9749e.js +0 -1
- sky/dashboard/out/_next/static/chunks/9025.c12318fb6a1a9093.js +0 -6
- sky/dashboard/out/_next/static/chunks/9360.71e83b2ddc844ec2.js +0 -31
- sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-8f058b0346db2aff.js +0 -16
- sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-4f7079dcab6ed653.js +0 -16
- sky/dashboard/out/_next/static/chunks/webpack-6a5ddd0184bfa22c.js +0 -1
- sky/dashboard/out/_next/static/css/4614e06482d7309e.css +0 -3
- sky/dashboard/out/_next/static/hIViZcQBkn0HE8SpaSsUU/_buildManifest.js +0 -1
- /sky/dashboard/out/_next/static/{hIViZcQBkn0HE8SpaSsUU → zB0ed6ge_W1MDszVHhijS}/_ssgManifest.js +0 -0
- {skypilot_nightly-1.0.0.dev20251009.dist-info → skypilot_nightly-1.0.0.dev20251107.dist-info}/WHEEL +0 -0
- {skypilot_nightly-1.0.0.dev20251009.dist-info → skypilot_nightly-1.0.0.dev20251107.dist-info}/entry_points.txt +0 -0
- {skypilot_nightly-1.0.0.dev20251009.dist-info → skypilot_nightly-1.0.0.dev20251107.dist-info}/licenses/LICENSE +0 -0
- {skypilot_nightly-1.0.0.dev20251009.dist-info → skypilot_nightly-1.0.0.dev20251107.dist-info}/top_level.txt +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1121],{50326:function(e,t,a){a.d(t,{$N:function(){return m},Be:function(){return h},Vq:function(){return c},cN:function(){return _},cZ:function(){return d},fK:function(){return f}});var r=a(85893),s=a(67294),o=a(6327),n=a(32350),l=a(43767);let c=o.fC;o.xz;let u=o.h_;o.x8;let i=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(o.aV,{ref:t,className:(0,n.cn)("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...s})});i.displayName=o.aV.displayName;let d=s.forwardRef((e,t)=>{let{className:a,children:s,...c}=e;return(0,r.jsxs)(u,{children:[(0,r.jsx)(i,{}),(0,r.jsxs)(o.VY,{ref:t,className:(0,n.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200 bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...c,children:[s,(0,r.jsxs)(o.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100 data-[state=open]:text-gray-500",children:[(0,r.jsx)(l.Z,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});d.displayName=o.VY.displayName;let f=e=>{let{className:t,...a}=e;return(0,r.jsx)("div",{className:(0,n.cn)("flex flex-col space-y-1.5 text-center sm:text-left",t),...a})};f.displayName="DialogHeader";let _=e=>{let{className:t,...a}=e;return(0,r.jsx)("div",{className:(0,n.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a})};_.displayName="DialogFooter";let m=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(o.Dx,{ref:t,className:(0,n.cn)("text-lg font-semibold leading-none tracking-tight",a),...s})});m.displayName=o.Dx.displayName;let h=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(o.dk,{ref:t,className:(0,n.cn)("text-sm text-gray-500",a),...s})});h.displayName=o.dk.displayName},23266:function(e,t,a){a.d(t,{GH:function(){return f},QL:function(){return m},Sl:function(){return d},getClusters:function(){return u},uR:function(){return i}});var r=a(67294),s=a(15821),o=a(47145),n=a(93225),l=a(6378);let c={UP:"RUNNING",STOPPED:"STOPPED",INIT:"LAUNCHING",null:"TERMINATED"};async function u(){let{clusterNames:e=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return(await o.x.fetch("/status",{cluster_names:e,all_users:!0,include_credentials:!1,summary_response:null==e})).map(e=>{let t="",a=t=e.zone?e.zone:e.region;return t&&t.length>25&&(t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15;if(!e||e.length<=t)return e;if(t<=3)return"...";let a=Math.floor((t-3)/2),r=a+(t-3)%2;return 0===a?e.substring(0,r)+"...":e.substring(0,r)+"..."+e.substring(e.length-a)}(t,25)),{status:c[e.status],cluster:e.name,user:e.user_name,user_hash:e.user_hash,cluster_hash:e.cluster_hash,cloud:e.cloud,region:e.region,infra:t?e.cloud+" ("+t+")":e.cloud,full_infra:a?"".concat(e.cloud," (").concat(a,")"):e.cloud,cpus:e.cpus,mem:e.memory,gpus:e.accelerators,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:new Date(1e3*e.launched_at),num_nodes:e.nodes,workspace:e.workspace,autostop:e.autostop,last_event:e.last_event,to_down:e.to_down,cluster_name_on_cloud:e.cluster_name_on_cloud,jobs:[],command:e.last_creation_command||e.last_use,task_yaml:e.last_creation_yaml||"{}",events:[{time:new Date(1e3*e.launched_at),event:"Cluster created."}]}})}catch(e){return console.error("Error fetching clusters:",e),[]}}async function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30;try{let a={days:t,dashboard_summary_response:!0};e&&(a.cluster_hashes=[e]);let r=await o.x.fetch("/cost_report",a);console.log("Raw cluster history data:",r);let s=r.map(e=>{let t="Unknown";e.cloud?t=e.cloud:e.resources&&e.resources.cloud&&(t=e.resources.cloud);let a=e.user_name||"-";return{status:e.status?c[e.status]:"TERMINATED",cluster:e.name,user:a,user_hash:e.user_hash,cluster_hash:e.cluster_hash,cloud:t,region:"",infra:t,full_infra:t,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:e.launched_at?new Date(1e3*e.launched_at):null,num_nodes:e.num_nodes||1,duration:e.duration,total_cost:e.total_cost,workspace:e.workspace||"default",autostop:-1,last_event:e.last_event,to_down:!1,cluster_name_on_cloud:null,usage_intervals:e.usage_intervals,command:e.last_creation_command||"",task_yaml:e.last_creation_yaml||"{}",events:[{time:e.launched_at?new Date(1e3*e.launched_at):new Date,event:"Cluster created."}]}});return console.log("Processed cluster history data:",s),s}catch(e){return console.error("Error fetching cluster history:",e),[]}}async function d(e){let{clusterName:t,jobId:a,onNewLog:r,workspace:n}=e;try{await o.x.stream("/logs",{follow:!1,cluster_name:t,job_id:a,tail:1e4,override_skypilot_config:{active_workspace:n||"default"}},r)}catch(e){console.error("Error in streamClusterJobLogs:",e),(0,s.C)("Error in streamClusterJobLogs: ".concat(e.message),"error")}}async function f(e){let{clusterName:t,jobIds:a=null,workspace:r}=e;try{let e=await o.x.fetch("/download_logs",{cluster_name:t,job_ids:a?a.map(String):null,override_skypilot_config:{active_workspace:r||"default"}}),l=Object.values(e||{});if(!l.length){(0,s.C)("No logs found to download.","warning");return}let c=window.location.origin,u="".concat(c).concat(n.f4,"/download"),i=await fetch("".concat(u,"?relative=items"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder_paths:l})});if(!i.ok){let e=await i.text();throw Error("Download failed: ".concat(i.status," ").concat(e))}let d=await i.blob(),f=window.URL.createObjectURL(d),_=document.createElement("a"),m=new Date().toISOString().replace(/[:.]/g,"-"),h=a&&1===a.length?"job-".concat(a[0]):"jobs";_.href=f,_.download="".concat(t,"-").concat(h,"-logs-").concat(m,".zip"),document.body.appendChild(_),_.click(),_.remove(),window.URL.revokeObjectURL(f)}catch(e){console.error("Error downloading logs:",e),(0,s.C)("Error downloading logs: ".concat(e.message),"error")}}async function _(e){let{clusterName:t,workspace:a}=e;try{return(await o.x.fetch("/queue",{cluster_name:t,all_users:!0,override_skypilot_config:{active_workspace:a}})).map(e=>{var r;let s=e.end_at?e.end_at:Date.now()/1e3,o=0,n=0;return e.submitted_at&&(o=s-e.submitted_at),e.start_at&&(n=s-e.start_at),{id:e.job_id,status:e.status,job:e.job_name,user:e.username,user_hash:e.user_hash,gpus:e.accelerators||{},submitted_at:e.submitted_at?new Date(1e3*e.submitted_at):null,resources:e.resources,cluster:t,total_duration:o,job_duration:n,infra:"",logs:"",workspace:a||"default",git_commit:(null===(r=e.metadata)||void 0===r?void 0:r.git_commit)||"-"}})}catch(e){return console.error("Error fetching cluster jobs:",e),[]}}function m(e){let{cluster:t,job:a=null}=e,[s,o]=(0,r.useState)(null),[n,c]=(0,r.useState)(null),[i,d]=(0,r.useState)(!0),[f,m]=(0,r.useState)(!0),h=(0,r.useCallback)(async()=>{if(t)try{d(!0);let e=await l.default.get(u,[{clusterNames:[t]}]);return o(e[0]),e[0]}catch(e){console.error("Error fetching cluster data:",e)}finally{d(!1)}return null},[t]),g=(0,r.useCallback)(async e=>{if(t)try{m(!0);let a=await l.default.get(_,[{clusterName:t,workspace:e||"default"}]);c(a)}catch(e){console.error("Error fetching cluster job data:",e)}finally{m(!1)}},[t]),p=(0,r.useCallback)(async()=>{l.default.invalidate(u,[{clusterNames:[t]}]);let e=await h();e&&(l.default.invalidate(_,[{clusterName:t,workspace:e.workspace||"default"}]),await g(e.workspace))},[h,g,t]),w=(0,r.useCallback)(async()=>{s&&(l.default.invalidate(_,[{clusterName:t,workspace:s.workspace||"default"}]),await g(s.workspace))},[g,s,t]);return(0,r.useEffect)(()=>{(async()=>{let e=await h();e&&g(e.workspace)})()},[t,a,h,g]),{clusterData:s,clusterJobData:n,loading:i,clusterDetailsLoading:i,clusterJobsLoading:f,refreshData:p,refreshClusterJobsOnly:w}}},53081:function(e,t,a){a.d(t,{R:function(){return s}}),a(23266),a(68969);var r=a(47145);async function s(){try{let e=await r.x.get("/users");if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));return(await e.json()).map(e=>({userId:e.id,username:e.name,role:e.role,created_at:e.created_at}))||[]}catch(e){return console.error("Failed to fetch users:",e),[]}}}}]);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1141],{99333:function(e,s,r){r.d(s,{Z:function(){return t}});/**
|
|
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 t=(0,r(60998).Z)("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},98418:function(e,s,r){r.d(s,{Z:function(){return t}});/**
|
|
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 t=(0,r(60998).Z)("Trash",[["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"}]])},1812:function(e,s,r){r.d(s,{X:function(){return n}});var t=r(85893),a=r(67294);let l=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},n=e=>{let{error:s,title:r="Error",onDismiss:n}=e,[c,i]=(0,a.useState)(!1);if((0,a.useEffect)(()=>{s&&i(!1)},[s]),!s||c)return null;let o="string"==typeof s?s:l(s);return(0,t.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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,t.jsx)("div",{className:"ml-3",children:(0,t.jsxs)("div",{className:"text-sm text-red-800",children:[(0,t.jsxs)("strong",{children:[r,":"]})," ",o]})})]}),(0,t.jsx)("button",{onClick:()=>{i(!0),n&&n()},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,t.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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"})})})]})})}},69123:function(e,s,r){r.d(s,{g:function(){return n}});var t=r(85893),a=r(67294),l=r(32350);let n=a.forwardRef((e,s)=>{let{className:r,...a}=e;return(0,t.jsx)("textarea",{className:(0,l.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",r),ref:s,...a})});n.displayName="Textarea"},11141:function(e,s,r){r.r(s),r.d(s,{WorkspaceEditor:function(){return R}});var t=r(85893),a=r(67294),l=r(11163),n=r(17324),c=r(23266),i=r(68969);r(6135);var o=r(41664),d=r.n(o),u=r(9008),x=r.n(u),m=r(37673),h=r(30803),f=r(69123),g=r(55739),p=r(70282),b=r(6021),j=r(13626),y=r(98418),N=r(99333),v=r(50326);let k=e=>{let{className:s="",variant:r="default",children:a,...l}=e;return(0,t.jsx)("div",{role:"alert",className:"".concat("relative w-full rounded-lg border p-4 flex items-start space-x-2"," ").concat({default:"bg-blue-50 border-blue-200 text-blue-800",destructive:"bg-red-50 border-red-200 text-red-800"}[r]," ").concat(s),...l,children:a})},w=e=>{let{className:s="",children:r,...a}=e;return(0,t.jsx)("div",{className:"text-sm leading-relaxed ".concat(s),...a,children:r})};var C=r(53850),L=r(1812),E=r(23015),S=r(1272),W=r(93225),A=r(53081);let Z=e=>{let{message:s}=e;return s?(0,t.jsxs)(k,{className:"border-green-200 bg-green-50",children:[(0,t.jsx)(p.Z,{className:"h-4 w-4 text-green-600"}),(0,t.jsx)(w,{className:"text-green-800",children:s})]}):null},D=e=>{let{workspaceName:s,config:r,enabledClouds:a=[]}=e;if(!r)return null;let l="default"===s,n=0===Object.keys(r).length;if(l&&n)return(0,t.jsx)("div",{className:"text-sm text-gray-500 mb-3 italic p-3 bg-sky-50 rounded border border-sky-200",children:"Workspace 'default' can use all accessible infrastructure."});let c=[],i=[],o=[],d=new Set(a.map(e=>e.toLowerCase()));Object.entries(r).forEach(e=>{let[s,r]=e;if("private"===s||"allowed_users"===s)return;let a=W.Z2[s.toLowerCase()]||s.toUpperCase(),l=null==a?void 0:a.toLowerCase(),n=d.has(l)||Array.from(d).some(e=>e.startsWith(l+"/")),u=()=>"kubernetes"===s.toLowerCase()?Array.from(d).filter(e=>e.startsWith(l+"/")).map(e=>e.split("/")[1]):[];if((null==r?void 0:r.disabled)===!0)i.push(a);else if(r&&Object.keys(r).length>0){let e="";if("gcp"===s.toLowerCase()&&r.project_id)e=" (Project ID: ".concat(r.project_id,")");else if("aws"===s.toLowerCase()&&r.region)e=" (Region: ".concat(r.region,")");else if("kubernetes"===s.toLowerCase()){let s=u();s.length>0&&(e=" (Contexts: ".concat(s.join(", "),")"))}n?c.push((0,t.jsxs)("span",{className:"block",children:[a,e," is enabled."]},"".concat(s,"-enabled"))):o.push((0,t.jsxs)("span",{className:"block text-amber-700",children:[a,e," is configured but not currently available."]},"".concat(s,"-configured-not-enabled")))}else if(n){let e="";if("kubernetes"===s.toLowerCase()){let s=u();s.length>0&&(e=" (Contexts: ".concat(s.join(", "),")"))}c.push((0,t.jsxs)("span",{className:"block",children:[a,e," is enabled (using default settings)."]},"".concat(s,"-default-enabled")))}else o.push((0,t.jsxs)("span",{className:"block text-amber-700",children:[a," is configured but not currently available."]},"".concat(s,"-default-not-enabled")))});let u=[];if(i.length>0){let e=i.join(" and ");u.push((0,t.jsxs)("span",{className:"block",children:[e," ",1===i.length?"is":"are"," explicitly disabled."]},"disabled-clouds"))}return(u.push(...c),u.push(...o),u.length>0)?(0,t.jsx)("div",{className:"text-sm text-gray-700 mb-3 p-3 bg-sky-50 rounded border border-sky-200",children:u}):!l&&n?(0,t.jsx)("div",{className:"text-sm text-gray-500 mb-3 italic p-3 bg-sky-50 rounded border border-sky-200",children:"This workspace has no specific cloud resource configurations and can use all accessible infrastructure."}):null},M=e=>{let{isPrivate:s}=e;return s?(0,t.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,t.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"})},P=e=>{let{workspaceConfig:s,allUsers:r}=e;if(!s.private)return null;let a=s.allowed_users||[],l=(r||[]).filter(e=>"admin"===e.role).map(e=>e.username),n=[...new Set([...a,...l])];return 0===n.length?(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Allowed Users (0)"}),(0,t.jsx)("div",{className:"text-amber-600 text-xs italic p-2 bg-amber-50 rounded border border-amber-200",children:"No users configured (workspace may be inaccessible)"})]}):(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsxs)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:["Allowed Users (",n.length,")"]}),(0,t.jsx)("div",{className:"space-y-1 max-h-48 overflow-y-auto border border-gray-200 rounded",children:n.map(e=>{let s=l.includes(e);return(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs p-2 bg-gray-50 hover:bg-gray-100 border-b border-gray-100 last:border-b-0",children:[(0,t.jsx)("span",{className:"font-medium text-gray-700",children:e}),s?(0,t.jsxs)("span",{className:"inline-flex items-center text-blue-600",children:[(0,t.jsx)(C.r7,{className:"w-3 h-3 mr-1"}),"Admin"]}):(0,t.jsxs)("span",{className:"inline-flex items-center text-gray-600",children:[(0,t.jsx)(b.Z,{className:"w-3 h-3 mr-1"}),"User"]})]},e)})})]})};function R(e){let{workspaceName:s,isNewWorkspace:r=!1}=e,o=(0,l.useRouter)(),[u,p]=(0,a.useState)({}),[b,k]=(0,a.useState)({}),[w,W]=(0,a.useState)(""),[R,_]=(0,a.useState)(!0),[z,O]=(0,a.useState)(!1),[U,T]=(0,a.useState)(!1),[Y,J]=(0,a.useState)(null),[I,V]=(0,a.useState)(null),[F,H]=(0,a.useState)(null),[B,X]=(0,a.useState)([]),[G,q]=(0,a.useState)({showDialog:!1,deleting:!1,error:null}),[K,Q]=(0,a.useState)({totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:[]}),[$,ee]=(0,a.useState)(!1),es=(0,a.useCallback)(async()=>{_(!0),J(null);try{let e;let[r,t]=await Promise.all([(0,n.getWorkspaces)(),(0,A.R)()]),a=r[s]||{};p(a),k(a),X(t||[]),e=0===Object.keys(a).length?"".concat(s,":\n # Empty workspace configuration - uses all accessible infrastructure\n"):S.ZP.dump({[s]:a},{indent:2,lineWidth:-1,noRefs:!0,skipInvalid:!0,flowLevel:-1}),W(e)}catch(e){console.error("Error fetching workspace config:",e),J(e)}finally{_(!1)}},[s]),er=(0,a.useCallback)(async()=>{if(!r){ee(!0);try{let[e,r,t]=await Promise.all([(0,c.getClusters)(),(0,i.getManagedJobs)({allUsers:!0}),(0,n.getEnabledClouds)(s,!0)]),a=e.filter(e=>(e.workspace||"default")===s),l=a.filter(e=>"RUNNING"===e.status||"LAUNCHING"===e.status),o={};e.forEach(e=>{o[e.cluster]=e.workspace||"default"});let d=r.jobs||[],u=new Set(E.statusGroups.active),x=0;d.forEach(e=>{let r=e.cluster_name||e.resources&&e.resources.cluster_name;r&&o[r]===s&&u.has(e.status)&&x++}),Q({totalClusterCount:a.length,runningClusterCount:l.length,managedJobsCount:x,clouds:Array.isArray(t)?t:[]})}catch(e){console.error("Failed to fetch workspace stats:",e)}finally{ee(!1)}}},[s,r]);(0,a.useEffect)(()=>{r?(_(!1),W("".concat(s,":\n # New workspace configuration\n # Leave empty to use all accessible infrastructure\n"))):(es(),er())},[s,r,es,er]),(0,a.useEffect)(()=>{T(JSON.stringify(u)!==JSON.stringify(b))},[u,b]);let et=e=>{W(e),H(null);try{let r=S.ZP.load(e)||{},t=Object.keys(r);if(0===t.length)p({});else if(1===t.length){let e=t[0];if(e!==s){H('Workspace name cannot be changed. Expected "'.concat(s,'" but found "').concat(e,'".'));return}let a=r[s]||{};p(a)}else H("Configuration must contain only one workspace. Found: ".concat(t.join(", ")))}catch(e){H("Invalid YAML: ".concat(e.message))}},ea=async()=>{O(!0),J(null),V(null);try{if(F)throw Error("Please fix YAML errors before saving");let e=S.ZP.load(w)||{},t=Object.keys(e);if(t.length>0&&t[0]!==s)throw Error('Workspace name cannot be changed. Expected "'.concat(s,'".'));r?(await (0,n.MB)(s,u),V("Workspace created successfully!"),setTimeout(()=>{o.push("/workspaces/".concat(s))},1500)):(await (0,n.eA)(s,u),V("Workspace updated successfully!"),k(u),er())}catch(e){console.error("Error saving workspace:",e),J(e)}finally{O(!1)}},el=async()=>{q(e=>({...e,deleting:!0,error:null}));try{await (0,n.zl)(s),V("Workspace deleted successfully!"),setTimeout(()=>{o.push("/workspaces")},1500)}catch(e){console.error("Error deleting workspace:",e),q(s=>({...s,deleting:!1,error:e}))}},en=()=>{q({showDialog:!1,deleting:!1,error:null})},ec=async()=>{await Promise.all([es(),er()])};if(!o.isReady)return(0,t.jsx)("div",{children:"Loading..."});let ei=r?"Create New Workspace | SkyPilot Dashboard":"Workspace: ".concat(s," | SkyPilot Dashboard");return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(x(),{children:(0,t.jsx)("title",{children:ei})}),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,t.jsxs)("div",{className:"text-base flex items-center",children:[(0,t.jsx)(d(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,t.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,t.jsx)(d(),{href:r?"/workspace/new":"/workspaces/".concat(s),className:"text-sky-blue hover:underline",children:r?"New Workspace":s}),U&&(0,t.jsx)("span",{className:"ml-3 px-2 py-1 bg-yellow-100 text-yellow-800 text-xs rounded",children:"Unsaved changes"})]}),(0,t.jsxs)("div",{className:"text-sm flex items-center",children:[(R||z||$)&&(0,t.jsxs)("div",{className:"flex items-center mr-4",children:[(0,t.jsx)(g.Z,{size:15,className:"mt-0"}),(0,t.jsx)("span",{className:"ml-2 text-gray-500",children:z?"Saving...":"Loading..."})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-4",children:[!r&&(0,t.jsxs)("button",{onClick:ec,disabled:R||z||$,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:[(0,t.jsx)(j.Z,{className:"w-4 h-4 mr-1.5"}),"Refresh"]}),!r&&"default"!==s&&(0,t.jsxs)("button",{onClick:()=>q({...G,showDialog:!0}),disabled:G.deleting||z,className:"text-red-600 hover:text-red-700 font-medium inline-flex items-center",children:[(0,t.jsx)(y.Z,{className:"w-4 h-4 mr-1.5"}),"Delete"]})]})]})]}),R?(0,t.jsxs)("div",{className:"flex justify-center items-center py-12",children:[(0,t.jsx)(g.Z,{size:24,className:"mr-2"}),(0,t.jsx)("span",{className:"text-gray-500",children:"Loading workspace configuration..."})]}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)(L.X,{error:Y,title:"Error",onDismiss:()=>J(null)}),(0,t.jsx)(Z,{message:I}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[!r&&(0,t.jsx)("div",{className:"lg:col-span-1",children:(0,t.jsxs)(m.Zb,{className:"h-full",children:[(0,t.jsx)(m.Ol,{children:(0,t.jsx)(m.ll,{className:"text-base font-normal",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-semibold",children:"Workspace:"})," ",s]}),(0,t.jsx)(M,{isPrivate:!0===b.private})]})})}),(0,t.jsxs)(m.aY,{className:"text-sm pb-2 flex-1",children:[(0,t.jsxs)("div",{className:"py-2 flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,t.jsx)(C.QT,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,t.jsx)("span",{children:"Clusters (Running / Total)"})]}),(0,t.jsx)("span",{className:"font-normal text-gray-800",children:$?"...":"".concat(K.runningClusterCount," / ").concat(K.totalClusterCount)})]}),(0,t.jsxs)("div",{className:"py-2 flex items-center justify-between border-t border-gray-100",children:[(0,t.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,t.jsx)(C.Vp,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,t.jsx)("span",{children:"Managed Jobs"})]}),(0,t.jsx)("span",{className:"font-normal text-gray-800",children:$?"...":K.managedJobsCount})]})]}),(0,t.jsxs)("div",{className:"px-6 pb-6 text-sm pt-3",children:[(0,t.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Enabled Infra"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:$?(0,t.jsx)("span",{className:"text-gray-500",children:"Loading..."}):K.clouds.length>0?K.clouds.map(e=>(0,t.jsxs)("div",{className:"flex items-center text-gray-700",children:[(0,t.jsx)(C.Ye,{className:"w-3.5 h-3.5 mr-1.5 text-green-500"}),(0,t.jsx)("span",{children:e})]},e)):(0,t.jsx)("span",{className:"text-gray-500 italic",children:"No enabled infrastructure"})}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(D,{workspaceName:s,config:b,enabledClouds:K.clouds})}),(0,t.jsx)(P,{workspaceConfig:b,allUsers:B})]})]})}),(0,t.jsx)("div",{className:r?"lg:col-span-3":"lg:col-span-2",children:(0,t.jsxs)(m.Zb,{className:"h-full flex flex-col",children:[(0,t.jsx)(m.Ol,{children:(0,t.jsx)(m.ll,{className:"text-base font-normal",children:r?"New Workspace YAML":"Edit Workspace YAML"})}),(0,t.jsx)(m.aY,{className:"flex-1 flex flex-col",children:(0,t.jsxs)("div",{className:"space-y-4 flex-1 flex flex-col",children:[F&&(0,t.jsx)(L.X,{error:F,onDismiss:()=>H(null)}),(0,t.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,t.jsxs)("p",{className:"text-sm text-gray-600 mb-3",children:["Configure infra-specific settings for this workspace. Leave empty to use all accessible infrastructure. Refer to"," ",(0,t.jsx)("a",{href:"https://docs.skypilot.co/en/latest/admin/workspaces.html#configuration",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600",children:"SkyPilot Docs"})," ","for more details."]}),(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Example configuration:"}),(0,t.jsx)("div",{className:"p-3 bg-gray-50 border rounded-lg",children:(0,t.jsx)("pre",{className:"text-xs font-mono text-gray-600 whitespace-pre-wrap",children:"".concat(s||"my-workspace",":\n private: true\n allowed_users:\n - user1@mydomain.com\n - user2@mydomain.com\n gcp:\n project_id: xxx\n disabled: false\n kubernetes:\n allowed_contexts:\n - context-1")})})]}),(0,t.jsx)(f.g,{value:w,onChange:e=>et(e.target.value),className:"font-mono text-sm flex-1 resize-none",style:{minHeight:"350px"},spellCheck:!1,placeholder:"# Enter workspace configuration in YAML format"}),(0,t.jsx)("div",{className:"flex justify-end space-x-3 pt-3 border-gray-200",children:(0,t.jsxs)(h.z,{onClick:ea,disabled:z||F||R,className:"inline-flex items-center bg-sky-600 hover:bg-sky-700 text-white",children:[(0,t.jsx)(N.Z,{className:"w-4 h-4 mr-1.5"}),z?"Applying...":"Apply"]})})]})]})})]})})]})]}),(0,t.jsx)(v.Vq,{open:G.showDialog,onOpenChange:en,children:(0,t.jsxs)(v.cZ,{className:"sm:max-w-md",children:[(0,t.jsxs)(v.fK,{className:"",children:[(0,t.jsx)(v.$N,{children:"Delete Workspace"}),(0,t.jsxs)(v.Be,{children:['Are you sure you want to delete workspace "',s,'"? This action cannot be undone.']})]}),G.error&&(0,t.jsx)(L.X,{error:G.error,title:"Deletion Failed",onDismiss:()=>q(e=>({...e,error:null}))}),(0,t.jsxs)(v.cN,{className:"",children:[(0,t.jsx)(h.z,{variant:"outline",onClick:en,disabled:G.deleting,children:"Cancel"}),(0,t.jsx)(h.z,{variant:"destructive",onClick:el,disabled:G.deleting,children:G.deleting?"Deleting...":"Delete"})]})]})})]})]})}}}]);
|
|
@@ -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),b=t(36856),f=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=f.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,b]=(0,n.useState)({username:"",password:"",role:"user"}),[f,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,eb]=(0,n.useState)(null),[ef,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}]),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),eb(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")}eb('User "'.concat(x.username,'" created successfully!')),c(!1),b({username:"",password:"",role:"user"}),eT()}catch(e){ej(e),c(!1),b({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")}eb('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")}eb('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:()=>eb(null)}),(0,r.jsx)(T.X,{error:ef,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:eb,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=>b({...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=>b({...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=>b({...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:f,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:f,children:f?"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:f,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}])]),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 b.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")]}),(f||"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})}),(f||"admin"===y)&&(0,r.jsx)(x.pj,{className:"relative",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[f&&(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:b,setTokenToRotate:f,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}])]),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)}},eb=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)}}},ef=async()=>{if(b){y(!0);try{let e={token_id:b.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",()=>{f(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:eb,disabled:X,children:X?"Deleting...":"Delete Token"})]})]})}),(0,r.jsx)(M.Vq,{open:u,onOpenChange:e=>{m(e),e||(f(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==b?void 0:b.token_name,'"',(null==b?void 0:b.creator_user_hash)!==(null==t?void 0:t.id)&&(null==t?void 0:t.role)==="admin"?" owned by ".concat(null==b?void 0:b.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),f(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),f(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:ef,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 H},ManagedJobs:function(){return Z},ManagedJobsTable:function(){return B},Status2Actions:function(){return q},filterJobsByName:function(){return J},filterJobsByPool:function(){return O},filterJobsByUser:function(){return W},filterJobsByWorkspace:function(){return U},statusGroups:function(){return z}});var r=t(85893),a=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:r,workspaceMatch:a,poolMatch:l,statuses:n}=e;return["allUsers:".concat(s),t?"name:".concat(t):"",r?"user:".concat(r):"",a?"workspace:".concat(a):"",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 r=t-s.timestamp;return{isCached:!0,isFresh:r<12e4,age:r,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,...r}=e,a=this._generateFilterKey(r);try{let e=this._getCacheStatus(a);if(e.isCached&&e.hasData){let l=e.data;if(!l.jobs||Array.isArray(l.jobs)&&0===l.jobs.length){if(!this.prefetching.has(a)){let e=this._loadFullDataset(r,a).catch(()=>{}).finally(()=>this.prefetching.delete(a));this.prefetching.set(a,e)}}else{let n=(s-1)*t,i=l.jobs.slice(n,n+t);if(!this.prefetching.has(a)&&(!e.isFresh||e.age>e.maxAge/2)){let e=this._loadFullDataset(r,a).catch(()=>{}).finally(()=>this.prefetching.delete(a));this.prefetching.set(a,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,[{...r,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(a)){let e=this._loadFullDataset(r,a).catch(e=>{console.warn("Background prefetch of full jobs failed:",e)}).finally(()=>{this.prefetching.delete(a)});this.prefetching.set(a,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.controllerStopped||!t.jobs)return t;let r={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,r),r}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 r=this._getCacheStatus(s);e.detailedStatus[s]={age:r.age,isFresh:r.isFresh,hasData:r.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),w=t(13626),y=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},r=[],a=[],l=[];s.map((e,s)=>{var t;r.push(null!==(t=e.property.toLowerCase())&&void 0!==t?t:""),a.push(e.operator),l.push(e.value)}),t.property=r,t.operator=a,t.value=l,e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},F=(e,s)=>{let t={...e.query},r=t.property,a=t.operator,l=t.value;if(void 0===r)return[];let n=[],i=Array.isArray(r)?r.length:1;if(1===i)n.push({property:s.get(r),operator:a,value:l});else for(let e=0;e<i;e++)n.push({property:s.get(r[e]),operator:a[e],value:l[e]});return n},M=e=>{var s,t;let{propertyList:l=[],valueList:n,setFilters:i,updateURLParams:c,placeholder:o="Filter items"}=e,d=(0,a.useRef)(null),u=(0,a.useRef)(null),[h,x]=(0,a.useState)(!1),[m,p]=(0,a.useState)(""),[j,f]=(0,a.useState)((null===(s=l[0])||void 0===s?void 0:s.value)||"status"),[g,b]=(0,a.useState)([]);(0,a.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,a.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},w=e=>{i(s=>{let t=[...s,{property:v(j),operator:":",value:e}];return c(t),t}),x(!1),p(""),d.current.focus()};return(0,r.jsxs)("div",{className:"flex flex-row border border-gray-300 rounded-md overflow-visible",children:[(0,r.jsx)("div",{className:"border-r border-gray-300 flex-shrink-0",children:(0,r.jsxs)(R.Ph,{onValueChange:f,value:j,children:[(0,r.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,r.jsx)(R.ki,{placeholder:(null===(t=l[0])||void 0===t?void 0:t.label)||"Status"})}),(0,r.jsx)(R.Bw,{children:l.map((e,s)=>(0,r.jsx)(R.Ql,{value:e.value,children:e.label},"property-item-".concat(s)))})]})}),(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.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,r.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,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"})})}),h&&g.length>0&&(0,r.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,r.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:()=>w(e),children:(0,r.jsx)("span",{className:"text-sm text-gray-700",children:e})},"".concat(e,"-").concat(s)))})]})]})},I=e=>{let{filters:s=[],setFilters:t,updateURLParams:a}=e,l=e=>{t(s=>{let t=s.filter((s,t)=>t!==e);return a(t),t})};return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{className:"flex items-center gap-4 py-2 px-2",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-content gap-2",children:[s.map((e,s)=>(0,r.jsx)(A,{filter:e,onRemove:()=>l(s)},"filteritem-".concat(s))),s.length>0&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("button",{onClick:()=>{a([]),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,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex items-center text-blue-600 bg-blue-100 px-1 py-1 rounded-full text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2",children:[(0,r.jsx)("span",{children:"".concat(s.property," ")}),(0,r.jsx)("span",{children:"".concat(s.operator," ")}),(0,r.jsx)("span",{children:" ".concat(s.value)})]}),(0,r.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,r.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"white",viewBox:"0 0 24 24",children:(0,r.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,r.jsx)(h.Zg,{date:s})};function Z(){let e=(0,l.useRouter)(),[s,t]=(0,a.useState)(!1),[n,c]=(0,a.useState)(!0),[o,d]=(0,a.useState)(!0),u=a.useRef(null),x=a.useRef(null),[j,g]=(0,a.useState)([]),[w,y]=(0,a.useState)([]),N=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))}};(0,a.useEffect)(()=>{N()},[]);let k=s=>{D(e,s)},C=a.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"),y(F(e,s))},[e,y]);return(0,a.useEffect)(()=>{e.isReady&&C()},[e.isReady,e.query.tab,C]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[(0,r.jsx)("div",{className:"text-base",children:(0,r.jsx)(i(),{href:"/jobs",className:"text-sky-blue hover:underline leading-none",children:"Managed Jobs"})}),(0,r.jsx)("div",{className:"w-full sm:w-auto",children:(0,r.jsx)(M,{propertyList:P,valueList:{},setFilters:y,updateURLParams:k,placeholder:"Filter jobs"})})]}),(0,r.jsx)(I,{filters:w,setFilters:y,updateURLParams:k}),(0,r.jsx)(B,{refreshInterval:h.yc,setLoading:t,refreshDataRef:u,filters:w,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,r.jsx)("div",{className:"mb-4",children:(0,r.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,a.useState)([]),[R,D]=(0,a.useState)(0),[F,M]=(0,a.useState)(0),[I,A]=(0,a.useState)({key:null,direction:"ascending"}),[P,J]=(0,a.useState)(!1),[U,W]=(0,a.useState)(!0),[O,Z]=(0,a.useState)(1),[B,H]=(0,a.useState)(10),[V,Y]=(0,a.useState)(null),Q=(0,a.useRef)(null),[X,$]=(0,a.useState)([]),[ee,es]=(0,a.useState)({}),[et,er]=(0,a.useState)({}),[ea,el]=(0,a.useState)(!1),[en,ei]=(0,a.useState)(!1),[ec,eo]=(0,a.useState)(!1),[ed,eu]=(0,a.useState)("all"),[eh,ex]=(0,a.useState)(!0),[em,ep]=(0,a.useState)({isOpen:!1,title:"",message:"",onConfirm:null}),ej=(0,E.X)(),ef=(0,a.useRef)(0),eg=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 eb()}catch(e){console.error("Error restarting controller:",e)}finally{eo(!1),J(!1)}}})},eb=a.useCallback(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=!1!==e.includeStatus,r=ef.current+1;ef.current=r,J(!0),t(!0);try{let e,t;let a=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:a("name"),userMatch:a("user"),workspaceMatch:a("workspace"),poolMatch:a("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)}r===ef.current&&(k(c),D(o||0),M(d||0),el(!!m),ei(!!j),er(x),W(!1))}catch(e){console.error("Error fetching data:",e),r===ef.current&&(k([]),el(!1),W(!1))}finally{r===ef.current&&(J(!1),t(!1))}},[t,n,O,B,X,eh,ed]);a.useEffect(()=>{l&&(l.current=eb)},[l,eb]);let ev=a.useRef(eb);a.useEffect(()=>{ev.current=eb},[eb]);let ew=a.useRef(!0);a.useEffect(()=>{eb({includeStatus:!0}),ew.current=!1},[]),a.useEffect(()=>{ew.current||eb({includeStatus:!1})},[O]),a.useEffect(()=>{ew.current||eb({includeStatus:!0})},[n,B]),a.useEffect(()=>{ew.current||eb({includeStatus:!0})},[ed,X,eh]),(0,a.useEffect)(()=>{let e=setInterval(()=>{ev.current&&ev.current({includeStatus:!0})},s);return()=>{clearInterval(e)}},[s]),(0,a.useEffect)(()=>{Z(1)},[ed]),(0,a.useEffect)(()=>{Z(1)},[n,B]),(0,a.useEffect)(()=>{$([]),ex(!0)},[ed]);let ey=e=>{let s="ascending";I.key===e&&"ascending"===I.direction&&(s="descending"),A({key:e,direction:s})},eN=e=>I.key===e?"ascending"===I.direction?" ↑":" ↓":"";a.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 ek=e=>X.length>0?X.includes(e):"all"===ed||z[ed].includes(e),eC=a.useMemo(()=>N,[N]),eS=a.useMemo(()=>I.key?[...eC].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):eC,[eC,I]),e_=(O-1)*B,eL=R>0?Math.ceil(R/B):0,eE=R>0?Math.min(e_+eS.length,R):0,eR=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,a.useEffect)(()=>{es(et)},[et]),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{className:"flex flex-col space-y-1 mb-1",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between text-sm mb-1",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center",children:[(0,r.jsx)("span",{className:"mr-2 text-sm font-medium",children:"Statuses:"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 items-center",children:[!P&&0===F&&!U&&(0,r.jsx)("span",{className:"text-gray-500 mr-2",children:"No jobs found"}),Object.entries(ee).map(e=>{let[s,t]=e;return(0,r.jsxs)("button",{onClick:()=>eR(s),className:"px-3 py-0.5 rounded-full flex items-center space-x-2 ".concat(ek(s)||X.includes(s)?(0,_.Cl)(s):"bg-gray-50 text-gray-600 hover:bg-gray-100"),children:[(0,r.jsx)("span",{children:s}),(0,r.jsx)("span",{className:"text-xs ".concat(ek(s)||X.includes(s)?"bg-white/50":"bg-gray-200"," px-1.5 py-0.5 rounded"),children:t})]},s)}),F>0&&(0,r.jsxs)("div",{className:"flex items-center ml-2 gap-2",children:[(0,r.jsx)("span",{className:"text-gray-500",children:"("}),(0,r.jsx)("button",{onClick:()=>{a.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,r.jsx)("span",{className:"text-gray-500 mx-1",children:"|"}),(0,r.jsx)("button",{onClick:()=>{a.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,r.jsx)("span",{className:"text-gray-500 mx-1",children:"|"}),(0,r.jsx)("button",{onClick:()=>{a.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,r.jsx)("span",{className:"text-gray-500",children:")"})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[P&&(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(c.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500 text-sm",children:"Loading..."})]}),(0,r.jsxs)("button",{onClick:()=>{j&&j()},disabled:P,className:"text-sky-blue hover:text-sky-blue-bright flex items-center text-sm",children:[(0,r.jsx)(w.Z,{className:"h-4 w-4 mr-1.5"}),(0,r.jsx)("span",{children:"Refresh"})]})]})]})}),ej&&ea&&0===eS.length&&!P&&!U&&(0,r.jsx)("div",{className:"mb-4 p-4 bg-gray-50 rounded-lg border",children:(0,r.jsxs)("div",{className:"flex flex-col items-center space-y-3",children:[(0,r.jsxs)("p",{className:"text-gray-700 text-center text-sm",children:["Job controller stopped.",(0,r.jsx)("br",{}),"Restart to check status."]}),(0,r.jsx)(o.z,{variant:"outline",size:"sm",onClick:eg,className:"text-sky-blue hover:text-sky-blue-bright",disabled:P||ec,children:ec?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c.Z,{size:12,className:"mr-2"}),"Restarting..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(y.Z,{className:"h-4 w-4 mr-2"}),"Restart"]})})]})}),(0,r.jsx)(d.Zb,{children:(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,r.jsxs)(u.iA,{className:"min-w-full",children:[(0,r.jsx)(u.xD,{children:(0,r.jsxs)(u.SC,{children:[(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ey("id"),children:["ID",eN("id")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ey("name"),children:["Name",eN("name")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ey("user"),children:["User",eN("user")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ey("workspace"),children:["Workspace",eN("workspace")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ey("submitted_at"),children:["Submitted",eN("submitted_at")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ey("job_duration"),children:["Duration",eN("job_duration")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ey("status"),children:["Status",eN("status")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ey("resources_str"),children:["Requested",eN("resources_str")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ey("infra"),children:["Infra",eN("infra")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ey("cluster"),children:["Resources",eN("cluster")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ey("recoveries"),children:["Recoveries",eN("recoveries")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ey("pool"),children:["Worker Pool",eN("pool")]}),(0,r.jsx)(u.ss,{children:"Details"}),(0,r.jsx)(u.ss,{children:"Logs"})]})}),(0,r.jsx)(u.RM,{children:P&&U?(0,r.jsx)(u.SC,{children:(0,r.jsx)(u.pj,{colSpan:12,className:"text-center py-6 text-gray-500",children:(0,r.jsxs)("div",{className:"flex justify-center items-center",children:[(0,r.jsx)(c.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading..."})]})})}):eS.length>0?(0,r.jsx)(r.Fragment,{children:eS.map(e=>(0,r.jsxs)(a.Fragment,{children:[(0,r.jsxs)(u.SC,{children:[(0,r.jsx)(u.pj,{children:(0,r.jsx)(i(),{href:"/jobs/".concat(e.id),className:"text-blue-600",children:e.id})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(i(),{href:"/jobs/".concat(e.id),className:"text-blue-600",children:e.name})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(L.H,{username:e.user,userHash:e.user_hash})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(i(),{href:"/workspaces",className:"text-gray-700 hover:text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,r.jsx)(u.pj,{children:T(e.submitted_at)}),(0,r.jsx)(u.pj,{children:(0,h.LU)(e.job_duration)}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(_.OE,{status:e.status})}),(0,r.jsx)(u.pj,{children:e.requested_resources}),(0,r.jsx)(u.pj,{children:e.infra&&"-"!==e.infra?(0,r.jsx)(h.Md,{content:e.full_infra||e.infra,className:"text-sm text-muted-foreground",children:(0,r.jsxs)("span",{children:[(0,r.jsx)(i(),{href:"/infra",className:"text-blue-600 hover:underline",children:e.cloud||e.infra.split("(")[0].trim()}),e.infra.includes("(")&&(0,r.jsx)("span",{children:" "+(()=>{let s=x.MO.NAME_TRUNCATE_LENGTH,t=e.infra.substring(e.infra.indexOf("(")),r=t.substring(1,t.length-1);if(r.length<=s)return t;let a="".concat(r.substring(0,Math.floor((s-3)/2)),"...").concat(r.substring(r.length-Math.ceil((s-3)/2)));return"(".concat(a,")")})()})]})}):(0,r.jsx)("span",{children:e.infra||"-"})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(h.Md,{content:e.resources_str_full||e.resources_str,className:"text-sm text-muted-foreground",children:(0,r.jsx)("span",{children:e.resources_str})})}),(0,r.jsx)(u.pj,{children:e.recoveries}),(0,r.jsx)(u.pj,{children:(0,r.jsx)("div",{className:v?"blur-sm transition-all duration-300":"",children:v?"-":(0,h.os)(e.pool,e.pool_hash,b)})}),(0,r.jsx)(u.pj,{children:e.details?(0,r.jsx)(G,{text:e.details,rowId:e.id,expandedRowId:V,setExpandedRowId:Y}):"-"}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(q,{jobParent:"/jobs",jobId:e.id,managed:!0,workspace:e.workspace})})]}),V===e.id&&(0,r.jsx)(K,{text:e.details,colSpan:13,innerRef:Q})]},e.task_job_id))}):(0,r.jsx)(u.SC,{children:(0,r.jsx)(u.pj,{colSpan:13,className:"text-center py-6",children:(0,r.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[en&&(0,r.jsxs)("div",{className:"flex flex-col items-center space-y-2",children:[(0,r.jsx)("p",{className:"text-gray-700",children:"The managed job controller is launching. It will be ready shortly."}),(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(c.Z,{size:12,className:"mr-2"}),(0,r.jsx)("span",{className:"text-gray-500",children:"Launching..."})]})]}),!ea&&!en&&(0,r.jsx)("p",{className:"text-gray-500",children:"No active jobs"}),!ej&&ea&&(0,r.jsxs)("div",{className:"flex flex-col items-center space-y-3 px-4",children:[(0,r.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,r.jsx)(o.z,{variant:"outline",size:"sm",onClick:eg,className:"text-sky-blue hover:text-sky-blue-bright",disabled:P||ec,children:ec?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c.Z,{size:12,className:"mr-2"}),"Restarting..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(y.Z,{className:"h-4 w-4 mr-2"}),"Restart Controller"]})})]})]})})})})]})})}),(0,r.jsx)("div",{className:"flex justify-end items-center py-2 px-4 text-sm text-gray-700",children:(0,r.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("span",{className:"mr-2",children:"Rows per page:"}),(0,r.jsxs)("div",{className:"relative inline-block",children:[(0,r.jsxs)("select",{value:B,onChange:e=>{H(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,r.jsx)("option",{value:10,children:"10"}),(0,r.jsx)("option",{value:30,children:"30"}),(0,r.jsx)("option",{value:50,children:"50"}),(0,r.jsx)("option",{value:100,children:"100"}),(0,r.jsx)("option",{value:200,children:"200"})]}),(0,r.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,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),(0,r.jsx)("div",{children:R>0?"".concat(e_+1," – ").concat(eE," of ").concat(R):"0 – 0 of 0"}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{Z(e=>Math.max(e-1,1))},disabled:1===O||!eS||0===eS.length,className:"text-gray-500 h-8 w-8 p-0",children:(0,r.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,r.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,r.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{eL>0&&O<eL&&Z(e=>e+1)},disabled:0===eL||O>=eL||!eS||0===eS.length,className:"text-gray-500 h-8 w-8 p-0",children:(0,r.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,r.jsx)("path",{d:"M9 18l6-6-6-6"})})})]})]})}),(0,r.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 q(e){let{withLabel:s=!1,jobParent:t,jobId:a,managed:n,workspace:i="default"}=e,c=(0,l.useRouter)(),o=(e,s)=>{e.preventDefault(),e.stopPropagation(),c.push({pathname:"".concat(t,"/").concat(a),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(a),controller:s});else{let e=t.match(/\/clusters\/(.+)/);if(e){let s=e[1];(0,g.GH)({clusterName:s,jobIds:[a],workspace:i})}}};return(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(h.WH,{content:"View Job Logs",className:"capitalize text-sm text-muted-foreground",children:(0,r.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,r.jsx)(N.Z,{className:"w-4 h-4"}),s&&(0,r.jsx)("span",{className:"ml-1.5",children:"Logs"})]})},"logs"),(0,r.jsx)(h.WH,{content:"Download Job Logs",className:"capitalize text-sm text-muted-foreground",children:(0,r.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,r.jsx)(k.Z,{className:"w-4 h-4"}),s&&(0,r.jsx)("span",{className:"ml-1.5",children:"Download"})]})},"downloadlogs")]})}function H(e){let{clusterName:s,clusterJobData:t,loading:l,refreshClusterJobsOnly:n,userFilter:x=null,nameFilter:m=null,workspace:p="default"}=e,[j,f]=(0,a.useState)(null),[g,b]=(0,a.useState)({key:null,direction:"ascending"}),[v,y]=(0,a.useState)(1),[N,k]=(0,a.useState)(10),C=(0,a.useRef)(null),[S,E]=(0,a.useState)(null);(0,a.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=a.useMemo(()=>{let e=t||[];return x&&"ALL_USERS"!==x&&(e=W(e,x)),m&&(e=J(e,m)),e},[t,x,m]);(0,a.useEffect)(()=>{JSON.stringify(t)!==JSON.stringify(S)&&E(t)},[t,S]);let D=a.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]),F=e=>{let s="ascending";g.key===e&&"ascending"===g.direction&&(s="descending"),b({key:e,direction:s})},M=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,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)(d.Zb,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Cluster Jobs"}),(0,r.jsx)("div",{className:"flex items-center",children:n&&(0,r.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,r.jsx)(w.Z,{className:"w-4 h-4 mr-1"}),"Refresh Jobs"]})})]}),(0,r.jsxs)(u.iA,{children:[(0,r.jsx)(u.xD,{children:(0,r.jsxs)(u.SC,{children:[(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("id"),children:["ID",M("id")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("job"),children:["Name",M("job")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("user"),children:["User",M("user")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("workspace"),children:["Workspace",M("workspace")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("submitted_at"),children:["Submitted",M("submitted_at")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("job_duration"),children:["Duration",M("job_duration")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("status"),children:["Status",M("status")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("resources"),children:["Resources",M("resources")]}),(0,r.jsx)(u.ss,{className:"whitespace-nowrap",children:"Logs"})]})}),(0,r.jsx)(u.RM,{children:l?(0,r.jsx)(u.SC,{children:(0,r.jsx)(u.pj,{colSpan:9,className:"text-center py-12 text-gray-500",children:(0,r.jsxs)("div",{className:"flex justify-center items-center",children:[(0,r.jsx)(c.Z,{size:24,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading cluster jobs..."})]})})}):P.length>0?P.map(e=>(0,r.jsxs)(a.Fragment,{children:[(0,r.jsxs)(u.SC,{className:j===e.id?"selected-row":"",children:[(0,r.jsx)(u.pj,{children:(0,r.jsx)(i(),{href:"/clusters/".concat(s,"/").concat(e.id),className:"text-blue-600",children:e.id})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(i(),{href:"/clusters/".concat(s,"/").concat(e.id),className:"text-blue-600",children:(0,r.jsx)(G,{text:e.job||"Unnamed job",rowId:e.id,expandedRowId:j,setExpandedRowId:f})})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(L.H,{username:e.user,userHash:e.user_hash})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(i(),{href:"/workspaces",className:"text-gray-700 hover:text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,r.jsx)(u.pj,{children:T(e.submitted_at)}),(0,r.jsx)(u.pj,{children:(0,h.LU)(e.job_duration)}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(_.OE,{status:e.status})}),(0,r.jsx)(u.pj,{children:e.resources}),(0,r.jsx)(u.pj,{className:"flex content-center items-center",children:(0,r.jsx)(q,{jobParent:"/clusters/".concat(s),jobId:e.id,managed:!1,workspace:p})})]}),j===e.id&&(0,r.jsx)(K,{text:e.job||"Unnamed job",colSpan:9,innerRef:C})]},e.id)):(0,r.jsx)(u.SC,{children:(0,r.jsx)(u.pj,{colSpan:8,className:"text-center py-6 text-gray-500",children:"No jobs found"})})})]})]}),D&&D.length>0&&(0,r.jsx)("div",{className:"flex justify-end items-center py-2 px-4 text-sm text-gray-700",children:(0,r.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("span",{className:"mr-2",children:"Rows per page:"}),(0,r.jsxs)("div",{className:"relative inline-block",children:[(0,r.jsxs)("select",{value:N,onChange:e=>{k(parseInt(e.target.value,10)),y(1)},className:"py-1 pl-2 pr-6 appearance-none outline-none cursor-pointer border-none bg-transparent",style:{minWidth:"40px"},children:[(0,r.jsx)("option",{value:5,children:"5"}),(0,r.jsx)("option",{value:10,children:"10"}),(0,r.jsx)("option",{value:20,children:"20"}),(0,r.jsx)("option",{value:50,children:"50"})]}),(0,r.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,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),(0,r.jsxs)("div",{children:[A+1," – ",Math.min(z,D.length)," of"," ",D.length]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{y(e=>Math.max(e-1,1))},disabled:1===v,className:"text-gray-500 h-8 w-8 p-0",children:(0,r.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,r.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,r.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{y(e=>Math.min(e+1,I))},disabled:v===I||0===I,className:"text-gray-500 h-8 w-8 p-0",children:(0,r.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,r.jsx)("path",{d:"M9 18l6-6-6-6"})})})]})]})})]})}function K(e){let{text:s,colSpan:t,innerRef:a}=e;return(0,r.jsx)(u.SC,{className:"expanded-details",children:(0,r.jsx)(u.pj,{colSpan:t,children:(0,r.jsx)("div",{className:"p-4 bg-gray-50 rounded-md border border-gray-200",ref:a,children:(0,r.jsx)("div",{className:"flex justify-between items-start",children:(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-gray-900",children:"Full Details"}),(0,r.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,a.useRef)(null);return(0,r.jsxs)("div",{className:"truncated-details relative max-w-full flex items-center",children:[(0,r.jsx)("span",{className:"truncate",children:d}),c&&(0,r.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,a.useState)([]),[x,j]=(0,a.useState)({key:null,direction:"ascending"}),[f,g]=(0,a.useState)(!1),[b,v]=(0,a.useState)(!0),[w,y]=(0,a.useState)(1),[N,k]=(0,a.useState)(10),C=a.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]);a.useEffect(()=>{l&&(l.current=C)},[l,C]),(0,a.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=a.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=(w-1)*N,F=D+N,M=E.slice(D,F),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,r.jsx)(h.x9,{jobCounts:s,getStatusStyle:_.Cl})},z=e=>{let{replicaInfo:s}=e;return(0,r.jsx)(h.Kl,{replicaInfo:s})};return(0,r.jsxs)(d.Zb,{children:[(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,r.jsxs)(u.iA,{className:"min-w-full table-fixed",children:[(0,r.jsx)(u.xD,{children:(0,r.jsxs)(u.SC,{children:[(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-32",onClick:()=>S("name"),children:["Pool",L("name")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-40",onClick:()=>S("job_counts"),children:["Jobs",L("job_counts")]}),(0,r.jsx)(u.ss,{className:"whitespace-nowrap w-20",children:"Workers"}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-36",onClick:()=>S("requested_resources_str"),children:["Worker Details",L("requested_resources_str")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-40",onClick:()=>S("requested_resources_str"),children:["Worker Resources",L("requested_resources_str")]})]})}),(0,r.jsx)(u.RM,{children:f&&b?(0,r.jsx)(u.SC,{children:(0,r.jsx)(u.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)(c.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading..."})]})})}):M.length>0?M.map(e=>(0,r.jsxs)(u.SC,{children:[(0,r.jsx)(u.pj,{children:(0,r.jsx)(i(),{href:"/jobs/pools/".concat(e.name),className:"text-blue-600 hover:text-blue-800",children:e.name})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(A,{jobCounts:e.jobCounts})}),(0,r.jsx)(u.pj,{children:I(e)}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(z,{replicaInfo:e.replica_info})}),(0,r.jsx)(u.pj,{children:e.requested_resources_str||"-"})]},e.name)):(0,r.jsx)(u.SC,{children:(0,r.jsx)(u.pj,{colSpan:5,className:"text-center py-6 text-gray-500",children:"No pools found"})})})]})}),M.length>0&&R>1&&(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-200",children:[(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("span",{className:"text-sm text-gray-700",children:"Rows per page:"}),(0,r.jsxs)("select",{value:N,onChange:e=>{k(parseInt(e.target.value,10)),y(1)},className:"border border-gray-300 rounded px-2 py-1 text-sm",children:[(0,r.jsx)("option",{value:5,children:"5"}),(0,r.jsx)("option",{value:10,children:"10"}),(0,r.jsx)("option",{value:25,children:"25"}),(0,r.jsx)("option",{value:50,children:"50"})]})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsxs)("span",{className:"text-sm text-gray-700",children:[D+1,"-",Math.min(F,E.length)," of"," ",E.length]}),(0,r.jsx)("button",{onClick:()=>{y(e=>Math.max(e-1,1))},disabled:1===w,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,r.jsx)("button",{onClick:()=>{y(e=>Math.min(e+1,R))},disabled:w===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}):await N.default.get(x.getManagedJobs,[{allUsers:!0}]),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}]),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 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6856],{32045:function(e,t,o){o.d(t,{R8:function(){return i},Xg:function(){return s},ef:function(){return n}});var r=o(93225),a=o(47145);async function n(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=(await Promise.resolve().then(o.bind(o,6378))).default,{getClusters:n}=await Promise.resolve().then(o.bind(o,23266)),{getManagedJobs:s}=await Promise.resolve().then(o.bind(o,68969));try{let o=await t.get(s,[{allUsers:!0}]),c=(null==o?void 0:o.jobs)||[],l=await t.get(n),i=[];try{if(e){console.log("Force refreshing clouds by running sky check...");try{let e=await a.x.post("/check",{}),t=e.headers.get("X-Skypilot-Request-ID")||e.headers.get("X-Request-ID"),o=await a.x.get("/api/get?request_id=".concat(t)),r=await o.json();console.log("Sky check completed:",r)}catch(e){console.error("Error running sky check:",e)}}let t=await a.x.get("/enabled_clouds"),o=t.headers.get("X-Skypilot-Request-ID")||t.headers.get("X-Request-ID"),r=await a.x.get("/api/get?request_id=".concat(o)),n=await r.json();i=n.return_value?JSON.parse(n.return_value):[],console.log("Enabled clouds:",i)}catch(e){console.error("Error fetching enabled clouds:",e),i=[]}let u={};r.$m.forEach(e=>{let t=i.includes(e.toLowerCase());u[e]={name:e,clusters:0,jobs:0,enabled:t}}),(l||[]).forEach(e=>{if(e.cloud){let t=e.cloud;u[t]&&(u[t].clusters+=1,u[t].enabled=!0)}}),c.forEach(e=>{if(e.cloud){let t=e.cloud;u[t]&&(u[t].jobs+=1,u[t].enabled=!0)}});let d=r.$m.length,g=Object.values(u).filter(e=>e.enabled).length;return{clouds:Object.values(u).filter(e=>e.enabled).sort((e,t)=>e.name.localeCompare(t.name)),totalClouds:d,enabledClouds:g}}catch(e){return console.error("Error fetching cloud infrastructure:",e),{clouds:[],totalClouds:r.$m.length,enabledClouds:0}}}async function s(){try{console.log("[DEBUG] Starting workspace-aware infrastructure fetch");let{getWorkspaces:e}=await Promise.resolve().then(o.bind(o,17324));console.log("[DEBUG] About to call getWorkspaces()");let t=await e();if(console.log("[DEBUG] Workspaces data received:",t),console.log("[DEBUG] Number of accessible workspaces:",Object.keys(t||{}).length),console.log("[DEBUG] Workspace names:",Object.keys(t||{})),!t||0===Object.keys(t).length)return console.log("[DEBUG] No accessible workspaces found - returning empty result"),{workspaces:{},allContextNames:[],allGPUs:[],perContextGPUs:[],perNodeGPUs:[],contextStats:{},contextWorkspaceMap:{}};let{getEnabledClouds:r}=await Promise.resolve().then(o.bind(o,17324)),a={},n=[],s={};await Promise.allSettled(Object.entries(t).map(async e=>{let[t,o]=e;console.log("Fetching infrastructure for workspace: ".concat(t));try{console.log("[DEBUG] Fetching enabled clouds for workspace: ".concat(t));let e=await r(t,!0);console.log("[DEBUG] Expanded clouds for ".concat(t,":"),e),a[t]={config:o,clouds:e,contexts:[]},console.log("[DEBUG] Processing expandedClouds for ".concat(t,":"),e),e&&Array.isArray(e)?e.forEach(e=>{if(console.log("[DEBUG] Processing infraItem: ".concat(e)),e.toLowerCase().startsWith("kubernetes/")){let o=e.replace(/^kubernetes\//i,"");console.log("[DEBUG] Extracted kubernetes context: ".concat(o)),n.push(o),s[o]||(s[o]=[]),s[o].includes(t)||s[o].push(t),a[t].contexts.push(o)}else if(e.toLowerCase().startsWith("ssh/")){let o=e.replace(/^ssh\//i,""),r="ssh-".concat(o);console.log("[DEBUG] Extracted SSH context: ".concat(r)),n.push(r),s[r]||(s[r]=[]),s[r].includes(t)||s[r].push(t),a[t].contexts.push(r)}}):console.log("[DEBUG] No expanded clouds or not an array for ".concat(t))}catch(e){console.error("Failed to fetch infrastructure for workspace ".concat(t,":"),e),a[t]={config:o,clouds:[],contexts:[],error:e.message}}}));let{getClusters:l}=await Promise.resolve().then(o.bind(o,23266)),i=(await Promise.resolve().then(o.bind(o,6378))).default,d=await i.get(l),g=await u(d||[]),f=[...new Set(n)].filter(e=>e&&"string"==typeof e),p=await c(f),h={workspaces:a,allContextNames:[...new Set(n)].sort(),allGPUs:p.allGPUs||[],perContextGPUs:p.perContextGPUs||[],perNodeGPUs:p.perNodeGPUs||[],contextStats:g,contextWorkspaceMap:s};return console.log("[DEBUG] Final result:",h),console.log("[DEBUG] All contexts found:",n),console.log("[DEBUG] Context workspace map:",s),h}catch(e){return console.error("[DEBUG] Failed to fetch workspace infrastructure:",e),console.error("[DEBUG] Error stack:",e.stack),{workspaces:{},allContextNames:[],allGPUs:[],perContextGPUs:[],perNodeGPUs:[],contextStats:{},contextWorkspaceMap:{},error:e.message}}}async function c(e){try{var t,o,r,a,n,s;if(!e||0===e.length)return{allGPUs:[],perContextGPUs:[],perNodeGPUs:[]};let c={},i={},u={},d=await Promise.all(e.map(e=>l(e))),g={};for(let t=0;t<e.length;t++)g[e[t]]=d[t];for(let r of e){let e=g[r]||{};if(e&&Object.keys(e).length>0){let a={};for(let n in e){let s=e[n];if(!s){console.warn("No node data for node ".concat(n," in context ").concat(r));continue}let c=s.accelerator_type,l=(null===(t=s.total)||void 0===t?void 0:t.accelerator_count)||0,i=(null===(o=s.free)||void 0===o?void 0:o.accelerators_available)||0;l>0&&(a[c]||(a[c]={gpu_name:c,gpu_requestable_qty_per_node:0,gpu_total:0,gpu_free:0,context:r}),a[c].gpu_total+=l,a[c].gpu_free+=i,a[c].gpu_requestable_qty_per_node=l)}for(let e in i[r]=Object.values(a),a)e in c?(c[e].gpu_total+=a[e].gpu_total,c[e].gpu_free+=a[e].gpu_free):c[e]={gpu_total:a[e].gpu_total,gpu_free:a[e].gpu_free,gpu_name:e}}else i[r]=[]}for(let t of e){let e=g[t];if(e&&Object.keys(e).length>0)for(let o in e){let l=e[o];if(!l){console.warn("No node data for node ".concat(o," in context ").concat(t));continue}let d=l.accelerator_type||"-",g=null!==(n=null===(r=l.total)||void 0===r?void 0:r.accelerator_count)&&void 0!==n?n:0,f=null!==(s=null===(a=l.free)||void 0===a?void 0:a.accelerators_available)&&void 0!==s?s:0;u["".concat(t,"/").concat(o)]={node_name:l.name||o,gpu_name:d,gpu_total:g,gpu_free:f,ip_address:l.ip_address||null,context:t},"-"===d||!i[t]||i[t].some(e=>e.gpu_name===d)||(d in c||(c[d]={gpu_total:0,gpu_free:0,gpu_name:d}),i[t].find(e=>e.gpu_name===d)||i[t].push({gpu_name:d,gpu_requestable_qty_per_node:"-",gpu_total:0,gpu_free:0,context:t}))}}return{allGPUs:Object.values(c).sort((e,t)=>e.gpu_name.localeCompare(t.gpu_name)),perContextGPUs:Object.values(i).flat().sort((e,t)=>e.context.localeCompare(t.context)||e.gpu_name.localeCompare(t.gpu_name)),perNodeGPUs:Object.values(u).sort((e,t)=>e.context.localeCompare(t.context)||e.node_name.localeCompare(t.node_name)||e.gpu_name.localeCompare(t.gpu_name))}}catch(e){return console.error("[infra.jsx] Error in getKubernetesGPUsFromContexts:",e),{allGPUs:[],perContextGPUs:[],perNodeGPUs:[]}}}async function l(e){try{let t=await a.x.post("/kubernetes_node_info",{context:e}),o=t.headers.get("X-Skypilot-Request-ID")||t.headers.get("x-request-id"),r=await a.x.get("/api/get?request_id=".concat(o));if(500===r.status){try{let t=await r.json();if(t.detail&&t.detail.error)try{let o=JSON.parse(t.detail.error);console.warn("[infra.jsx] Context ".concat(e," unavailable:"),o.message)}catch(e){console.error("Error parsing JSON:",e)}}catch(e){console.error("Error parsing JSON:",e)}return{}}let n=await r.json();return(n.return_value?JSON.parse(n.return_value):{}).node_info_dict||{}}catch(t){return console.warn("[infra.jsx] Context ".concat(e," unavailable or timed out:"),t.message),{}}}async function i(e){try{let t={};return e.forEach(e=>{let o=null;if("Kubernetes"===e.cloud)(o=e.region)&&(o="kubernetes/".concat(o));else if("SSH"===e.cloud&&(o=e.region)){let e=o.startsWith("ssh-")?o.substring(4):o;o="ssh/".concat(e)}o&&(t[o]||(t[o]={clusters:0,jobs:0}),t[o].jobs+=1)}),t}catch(e){return console.error("=== Error in getContextJobs ===",e),{}}}async function u(e){try{let t={};return e.forEach(e=>{let o=null;if("Kubernetes"===e.cloud)(o=e.region)&&(o="kubernetes/".concat(o));else if("SSH"===e.cloud&&(o=e.region)){let e=o.startsWith("ssh-")?o.substring(4):o;o="ssh/".concat(e)}o&&(t[o]||(t[o]={clusters:0,jobs:0}),t[o].clusters+=1)}),t}catch(e){return console.error("=== Error in getContextClusters ===",e),{}}}},29326:function(e,t,o){o.d(t,{IS:function(){return d},It:function(){return n},MV:function(){return c},Ri:function(){return s},_x:function(){return i},ez:function(){return u},hY:function(){return l},mF:function(){return f},wJ:function(){return g}});var r=o(93225),a=o(15821);async function n(){try{let e=await fetch("".concat(r.f4,"/ssh_node_pools"),{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));return await e.json()}catch(e){return console.error("Error fetching SSH Node Pools:",e),{}}}async function s(e){try{let t=await fetch("".concat(r.f4,"/ssh_node_pools"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error updating SSH Node Pools:",e),e}}async function c(e){try{let t=await fetch("".concat(r.f4,"/ssh_node_pools/").concat(e),{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error deleting SSH Node Pool:",e),e}}async function l(e,t){try{let o=new FormData;o.append("key_name",e),o.append("key_file",t);let a=await fetch("".concat(r.f4,"/ssh_node_pools/keys"),{method:"POST",body:o});if(!a.ok)throw Error("HTTP error! status: ".concat(a.status));return await a.json()}catch(e){throw console.error("Error uploading SSH key:",e),e}}async function i(e){try{let t=await fetch("".concat(r.f4,"/ssh_node_pools/").concat(e,"/deploy"),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error deploying SSH Node Pool:",e),e}}async function u(e){try{let t=await fetch("".concat(r.f4,"/ssh_node_pools/").concat(e,"/down"),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error tearing down SSH Node Pool:",e),e}}async function d(e){try{let t=await fetch("".concat(r.f4,"/ssh_node_pools/").concat(e,"/status"),{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error fetching SSH Node Pool status:",e),e}}async function g(e){let t,{requestId:o,signal:n,onNewLog:s}=e,c=Date.now(),l=new Promise(e=>{let o=()=>{let r=Date.now()-c;r>=3e5?e({timeout:!0}):t=setTimeout(o,3e5-r)};t=setTimeout(o,3e5)}),i=(async()=>{try{let e=await fetch("".concat(r.f4,"/api/stream?request_id=").concat(o,"&format=plain&tail=").concat(1e3,"&follow=true"),{method:"GET",headers:{"Content-Type":"application/json"},...n?{signal:n}:{}});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));let a=e.body.getReader();try{for(;;){let{done:e,value:t}=await a.read();if(e)break;c=Date.now();let o=new TextDecoder().decode(t);s(o)}}finally{a.cancel(),t&&clearTimeout(t)}return{timeout:!1}}catch(e){if(t&&clearTimeout(t),"AbortError"===e.name)return{timeout:!1};throw e}})(),u=await Promise.race([i,l]);if(t&&clearTimeout(t),u.timeout){(0,a.C)("SSH deployment log stream timed out after ".concat(300,"s of inactivity"),"warning");return}}async function f(e){let t,{requestId:o,signal:n,onNewLog:s,operationType:c="operation"}=e,l=Date.now(),i=new Promise(e=>{let o=()=>{let r=Date.now()-l;r>=3e5?e({timeout:!0}):t=setTimeout(o,3e5-r)};t=setTimeout(o,3e5)}),u=(async()=>{try{let e=await fetch("".concat(r.f4,"/api/stream?request_id=").concat(o,"&format=plain&tail=").concat(1e3,"&follow=true"),{method:"GET",headers:{"Content-Type":"application/json"},...n?{signal:n}:{}});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));let a=e.body.getReader();try{for(;;){let{done:e,value:t}=await a.read();if(e)break;l=Date.now();let o=new TextDecoder().decode(t);s(o)}}finally{a.cancel(),t&&clearTimeout(t)}return{timeout:!1}}catch(e){if(t&&clearTimeout(t),"AbortError"===e.name)return{timeout:!1};throw e}})(),d=await Promise.race([u,i]);if(t&&clearTimeout(t),d.timeout){(0,a.C)("SSH ".concat(c," log stream timed out after ").concat(300,"s of inactivity"),"warning");return}}},19238:function(e,t,o){o.d(t,{C:function(){return a},w:function(){return n}});var r=o(47145);async function a(){try{return(await r.x.fetch("/volumes",{},"GET")).map(e=>{var t,o,r;let a=e.cloud||"";return e.region&&(a+="/".concat(e.region)),e.zone&&(a+="/".concat(e.zone)),{name:e.name,launched_at:e.launched_at,user_hash:e.user_hash,user_name:e.user_name||"-",workspace:e.workspace||"-",last_attached_at:e.last_attached_at,status:e.status,type:e.type,cloud:e.cloud,region:e.region,zone:e.zone,infra:a,size:"".concat(e.size,"Gi"),config:e.config,storage_class:(null===(t=e.config)||void 0===t?void 0:t.storage_class_name)||"-",access_mode:(null===(o=e.config)||void 0===o?void 0:o.access_mode)||"-",namespace:(null===(r=e.config)||void 0===r?void 0:r.namespace)||"-",name_on_cloud:e.name_on_cloud,usedby_pods:e.usedby_pods,usedby_clusters:e.usedby_clusters}})||[]}catch(e){return console.error("Failed to fetch volumes:",e),[]}}async function n(e){let t="";try{let o=await r.x.post("/volumes/delete",{names:[e]}),a=o.headers.get("X-SkyPilot-Request-ID")||o.headers.get("X-Request-ID"),n=await r.x.get("/api/get?request_id=".concat(a));if(500===n.status){try{let e=await n.json();if(e.detail&&e.detail.error)try{t=JSON.parse(e.detail.error).message}catch(e){console.error("Error parsing JSON:",e)}}catch(e){console.error("Error parsing JSON:",e)}return{success:!1,msg:t}}return{success:!0}}catch(e){return console.error("Failed to delete volume:",e),{success:!1,msg:e.message}}}},36856:function(e,t,o){var r=o(6378),a=o(23266),n=o(68969),s=o(17324),c=o(53081),l=o(19238),i=o(32045),u=o(29326);let d={base:{getClusters:{fn:a.getClusters,args:[]},getManagedJobs:{fn:n.aT,args:[{allUsers:!0}]},getWorkspaces:{fn:s.getWorkspaces,args:[]},getUsers:{fn:c.R,args:[]},getCloudInfrastructure:{fn:i.ef,args:[!1]},getSSHNodePools:{fn:u.It,args:[]},getVolumes:{fn:l.C,args:[]}},dynamic:{getEnabledClouds:{fn:s.getEnabledClouds,requiresWorkspaces:!0}},pages:{clusters:["getClusters","getWorkspaces"],jobs:["getManagedJobs","getClusters","getWorkspaces","getUsers"],infra:["getClusters","getManagedJobs","getCloudInfrastructure","getSSHNodePools"],workspaces:["getWorkspaces","getClusters","getManagedJobs","getEnabledClouds"],users:["getUsers","getClusters","getManagedJobs"],volumes:["getVolumes"]}};class g{async preloadForPage(e,t){let{backgroundPreload:o=!0,force:r=!1}=t||{};if(!d.pages[e]){console.warn("Unknown page: ".concat(e));return}console.log("[CachePreloader] Preloading cache for page: ".concat(e));try{await this._loadPageData(e,r),o&&this._backgroundPreloadOtherPages(e)}catch(t){console.error("[CachePreloader] Error preloading for page ".concat(e,":"),t)}}async _loadPageData(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=d.pages[e],a=[];for(let e of o)if(d.base[e]){let{fn:o,args:n}=d.base[e];t&&r.default.invalidate(o,n),a.push(r.default.get(o,n).then(e=>(this._markAsPreloaded(o,n),e)))}else"getEnabledClouds"===e&&a.push(this._loadEnabledCloudsForAllWorkspaces(t));await Promise.allSettled(a),console.log("[CachePreloader] Loaded data for page: ".concat(e))}async _loadEnabledCloudsForAllWorkspaces(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{e&&r.default.invalidate(s.getWorkspaces);let t=await r.default.get(s.getWorkspaces),o=Object.keys(t||{}).map(t=>(e&&r.default.invalidate(s.getEnabledClouds,[t]),r.default.get(s.getEnabledClouds,[t])));await Promise.allSettled(o)}catch(e){console.error("[CachePreloader] Error loading enabled clouds:",e)}}_backgroundPreloadOtherPages(e){if(this.isPreloading)return;this.isPreloading=!0;let t=new Set(d.pages[e]),o=new Set;Object.keys(d.pages).filter(t=>t!==e).forEach(e=>{d.pages[e].forEach(e=>{t.has(e)||o.add(e)})}),console.log("[CachePreloader] Background preloading ".concat(o.size," unique functions: ").concat(Array.from(o).join(", "))),Promise.allSettled(Array.from(o).map(async e=>{try{if(d.base[e]){let{fn:t,args:o}=d.base[e];await r.default.get(t,o),this._markAsPreloaded(t,o)}else"getEnabledClouds"===e&&await this._loadEnabledCloudsForAllWorkspaces(!1);console.log("[CachePreloader] Background loaded function: ".concat(e))}catch(t){console.error("[CachePreloader] Background load failed for function ".concat(e,":"),t)}})).then(()=>{this.isPreloading=!1,console.log("[CachePreloader] Background preloading complete")})}async preloadBaseFunctions(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];console.log("[CachePreloader] Preloading all base functions");let t=Object.entries(d.base).map(t=>{let[o,{fn:a,args:n}]=t;return e&&r.default.invalidate(a,n),r.default.get(a,n).catch(e=>{console.error("[CachePreloader] Failed to preload ".concat(o,":"),e)})});await Promise.allSettled(t),console.log("[CachePreloader] Base functions preloaded")}getCacheStats(){return{...r.default.getStats(),isPreloading:this.isPreloading}}wasRecentlyPreloaded(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=this._generateKey(e,t),r=this.recentlyPreloaded.get(o);if(!r)return!1;let a=Date.now()-r<this.PRELOAD_GRACE_PERIOD;return a||this.recentlyPreloaded.delete(o),a}_markAsPreloaded(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=this._generateKey(e,t);this.recentlyPreloaded.set(o,Date.now())}_generateKey(e,t){let o=e.toString(),r=this._simpleHash(o),a=t.length>0?JSON.stringify(t):"";return"".concat(r,"_").concat(a)}_simpleHash(e){let t=5381;for(let o=0;o<e.length;o++)t=(t<<5)+t+e.charCodeAt(o);return t>>>0}clearCache(){r.default.clear(),this.isPreloading=!1,this.preloadPromises.clear(),this.recentlyPreloaded.clear(),console.log("[CachePreloader] Cache cleared")}constructor(){this.isPreloading=!1,this.preloadPromises=new Map,this.recentlyPreloaded=new Map,this.PRELOAD_GRACE_PERIOD=5e3}}let f=new g;r.default.setPreloader(f),t.ZP=f}}]);
|