import{d as q,u as L,r as x,c as M,o as T,e as i,f as e,h as c,w as r,j as t,s as f,g as l,J as h,k as J,X as z,l as A,t as o,n as u,M as j,a6 as C,B as D,q as N,D as _,E as v,a8 as R,a0 as g}from"./index-a0da86f0.js";import{I as k}from"./iconify-56cbf3ff.js";import{a as H,t as w}from"./scheduledJobs-9f6b0395.js";import{_ as X}from"./_plugin-vue_export-helper-c27b6911.js";import"./common-fa44b7a0.js";const G={class:"job-detail-page"},K={class:"page-header"},O={class:"page-title"},P={key:0,class:"loading"},Q={key:1,class:"job-content"},W={class:"properties-grid"},Y={class:"property-group"},Z={class:"property-item"},$={class:"property-item"},ee={class:"property-item"},te={class:"status-display"},se={class:"property-item"},oe={class:"status-display"},ae={key:0,class:"status-badge enabled"},le={key:1,class:"status-badge disabled"},ne={class:"property-group"},de={class:"property-item"},ue={class:"property-item"},ie={class:"property-item"},re={class:"property-item"},ce={class:"cron-section"},pe={class:"cron-display"},_e={class:"cron-code"},ve={class:"cron-description"},ye={class:"execution-section"},me={class:"execution-item"},be={class:"execution-value"},fe={key:0,class:"datetime-text"},he={key:1,class:"text-muted"},xe={class:"execution-item"},ge={class:"execution-value"},ke={key:0,class:"datetime-text next-execution"},Se={key:1,class:"text-muted"},Je={key:2,class:"text-muted"},je={key:2,class:"error"},Ce=`*  *  *  *  *
┬  ┬  ┬  ┬  ┬
│  │  │  │  │
│  │  │  │  └ day of week (0 - 6) (0 is Sunday)
│  │  │  └───── month (1 - 12)
│  │  └────────── day of month (1 - 31)
│  └─────────────── hour (0 - 23)
└──────────────────── minute (0 - 59)

---

* - Any value
/ - Step values`,De=q({__name:"ScheduledJobDetail",setup(Ne){const B=z(),V=A(),p=L(),s=x(null),y=x(!1),m=M(()=>B.params.id),b=x(null),U=async()=>{if(m.value){y.value=!0;try{const n=await H(m.value);n.stopped=!!n.stopped,s.value=n,!n.stopped&&n.next_execution?b.value=n.next_execution:b.value=null}catch(n){console.error("获取任务详情失败:",n),p.error(o("Failed to load job detail")),s.value=null}finally{y.value=!1}}},E=async n=>{if(s.value)try{const a=await w(m.value);a.success?p.success(a.message||o("Job status updated successfully")):(p.error(a.message||o("Failed to update job status")),s.value.stopped=!n)}catch(a){console.error("Toggle job status error:",a),p.error(o("Failed to update job status")),s.value.stopped=!n}},F=async()=>{if(s.value)try{const n=await w(m.value);n.success?(p.success(n.message||o("Job status updated successfully")),s.value.stopped=!s.value.stopped):p.error(n.message||o("Failed to update job status"))}catch(n){console.error("Toggle job status error:",n),p.error(o("Failed to update job status"))}},I=()=>{V.push({name:"ScheduledJobList"})},S=n=>{if(!n)return"—";try{return new Date(n).toLocaleString()}catch{return n}};return T(()=>{U()}),(n,a)=>(u(),i("div",G,[e("div",K,[c(t(j),{justify:"space-between",align:"center"},{default:r(()=>{var d;return[e("div",null,[e("h1",O,l(((d=s.value)==null?void 0:d.method)||t(o)("Scheduled Job Detail")),1)]),c(t(j),{size:8},{default:r(()=>[s.value?(u(),h(t(N),{key:0,type:"default",size:"medium",disabled:y.value,onClick:F,class:D(["toolbar-btn",s.value.stopped?"execute-btn":"stop-btn"])},{icon:r(()=>[c(t(C),null,{default:r(()=>[s.value.stopped?(u(),h(t(k),{key:0,icon:"tabler:play"})):(u(),h(t(k),{key:1,icon:"tabler:pause"}))]),_:1})]),default:r(()=>[f(" "+l(s.value.stopped?t(o)("Start Job"):t(o)("Stop Job")),1)]),_:1},8,["disabled","class"])):J("",!0),c(t(N),{type:"default",size:"medium",onClick:I},{icon:r(()=>[c(t(C),null,{default:r(()=>[c(t(k),{icon:"tabler:arrow-left"})]),_:1})]),default:r(()=>[f(" "+l(t(o)("Back")),1)]),_:1})]),_:1})]}),_:1})]),y.value?(u(),i("div",P,[a[7]||(a[7]=e("i",{class:"fa fa-spinner fa-spin"},null,-1)),f(" "+l(t(o)("Loading...")),1)])):s.value?(u(),i("div",Q,[c(t(g),{title:t(o)("Basic Information")},{default:r(()=>[e("div",W,[e("div",Y,[e("div",Z,[e("label",null,l(t(o)("Method")),1),_(e("input",{type:"text","onUpdate:modelValue":a[0]||(a[0]=d=>s.value.method=d),readonly:""},null,512),[[v,s.value.method]])]),e("div",$,[e("label",null,l(t(o)("Frequency")),1),_(e("input",{type:"text","onUpdate:modelValue":a[1]||(a[1]=d=>s.value.frequency=d),readonly:""},null,512),[[v,s.value.frequency]])]),e("div",ee,[e("label",null,l(t(o)("Status")),1),e("div",te,[c(t(R),{checked:s.value.stopped,"onUpdate:checked":[a[2]||(a[2]=d=>s.value.stopped=d),E]},null,8,["checked"]),e("span",{class:D(["status-badge",s.value.stopped?"stopped":"running"])},l(s.value.stopped?t(o)("Stopped"):t(o)("Running")),3)])]),e("div",se,[e("label",null,l(t(o)("Create Log")),1),e("div",oe,[s.value.create_log?(u(),i("span",ae,l(t(o)("Enabled")),1)):(u(),i("span",le,l(t(o)("Disabled")),1))])])]),e("div",ne,[e("div",de,[e("label",null,l(t(o)("Server Script")),1),_(e("input",{type:"text","onUpdate:modelValue":a[3]||(a[3]=d=>s.value.server_script=d),readonly:""},null,512),[[v,s.value.server_script]])]),e("div",ue,[e("label",null,l(t(o)("Scheduler Event")),1),_(e("input",{type:"text","onUpdate:modelValue":a[4]||(a[4]=d=>s.value.scheduler_event=d),readonly:""},null,512),[[v,s.value.scheduler_event]])]),e("div",ie,[e("label",null,l(t(o)("Created At")),1),_(e("input",{type:"text","onUpdate:modelValue":a[5]||(a[5]=d=>s.value.creation=d),readonly:""},null,512),[[v,s.value.creation]])]),e("div",re,[e("label",null,l(t(o)("Updated At")),1),_(e("input",{type:"text","onUpdate:modelValue":a[6]||(a[6]=d=>s.value.modified=d),readonly:""},null,512),[[v,s.value.modified]])])])])]),_:1},8,["title"]),s.value.frequency==="Cron"&&s.value.cron_format?(u(),h(t(g),{key:0,title:t(o)("Cron Format")},{default:r(()=>[e("div",ce,[e("div",pe,[e("code",_e,l(s.value.cron_format),1)]),e("div",ve,[e("h4",null,l(t(o)("Cron Format Description")),1),e("pre",{class:"cron-help"},l(Ce))])])]),_:1},8,["title"])):J("",!0),c(t(g),{title:t(o)("Execution History")},{default:r(()=>[e("div",ye,[e("div",me,[e("label",null,l(t(o)("Last Execution")),1),e("div",be,[s.value.last_execution?(u(),i("span",fe,l(S(s.value.last_execution)),1)):(u(),i("span",he,l(t(o)("Never executed")),1))])]),e("div",xe,[e("label",null,l(t(o)("Next Execution")),1),e("div",ge,[b.value?(u(),i("span",ke,l(S(b.value)),1)):s.value.stopped?(u(),i("span",Se,l(t(o)("Job is stopped")),1)):(u(),i("span",Je,l(t(o)("Unable to calculate")),1))])])])]),_:1},8,["title"])])):(u(),i("div",je,[a[8]||(a[8]=e("i",{class:"fa fa-exclamation-triangle"},null,-1)),f(" "+l(t(o)("Job not found")),1)]))]))}});const Fe=X(De,[["__scopeId","data-v-9cef9d64"]]);export{Fe as default};
