import{d as z,aa as L,o as T,A as i,J as e,B as c,C as r,j as t,aw as C,_ as f,P as l,t as o,as as x,i as h,O as J,r as g,c as q,g as d,ax as j,H as D,an as w,a6 as v,a7 as _,az as A,e as M,b as H}from"./index-DOFLUERq.js";import{I as k}from"./iconify-p99pbjf9.js";import{a as R,t as B}from"./scheduledJobs-joQMtCXM.js";import{_ as O}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./common-DEIQtiPI.js";const P={class:"job-detail-page"},G={class:"page-header"},K={class:"page-title"},Q={key:0,class:"loading"},W={key:1,class:"job-content"},X={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"},ve={class:"cron-code"},_e={class:"cron-description"},me={class:"execution-section"},ye={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"},Ce={key:2,class:"text-muted"},Je={key:2,class:"error"},je=`*  *  *  *  *
┬  ┬  ┬  ┬  ┬
│  │  │  │  │
│  │  │  │  └ 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=z({__name:"ScheduledJobDetail",setup(we){const N=H(),V=M(),p=L(),s=g(null),m=g(!1),y=q(()=>N.params.id),b=g(null),U=async()=>{if(y.value){m.value=!0;try{const n=await R(y.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{m.value=!1}}},F=async n=>{if(s.value)try{const a=await B(y.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}},E=async()=>{if(s.value)try{const n=await B(y.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)=>(d(),i("div",P,[e("div",G,[c(t(C),{justify:"space-between",align:"center"},{default:r(()=>[e("div",null,[e("h1",K,l(s.value?.method||t(o)("Scheduled Job Detail")),1)]),c(t(C),{size:8},{default:r(()=>[s.value?(d(),h(t(w),{key:0,type:"default",size:"medium",disabled:m.value,onClick:E,class:D(["toolbar-btn",s.value.stopped?"execute-btn":"stop-btn"])},{icon:r(()=>[c(t(j),null,{default:r(()=>[s.value.stopped?(d(),h(t(k),{key:0,icon:"tabler:play"})):(d(),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(w),{type:"default",size:"medium",onClick:I},{icon:r(()=>[c(t(j),null,{default:r(()=>[c(t(k),{icon:"tabler:arrow-left"})]),_:1})]),default:r(()=>[f(" "+l(t(o)("Back")),1)]),_:1})]),_:1})]),_:1})]),m.value?(d(),i("div",Q,[a[7]||(a[7]=e("i",{class:"fa fa-spinner fa-spin"},null,-1)),f(" "+l(t(o)("Loading...")),1)])):s.value?(d(),i("div",W,[c(t(x),{title:t(o)("Basic Information")},{default:r(()=>[e("div",X,[e("div",Y,[e("div",Z,[e("label",null,l(t(o)("Method")),1),v(e("input",{type:"text","onUpdate:modelValue":a[0]||(a[0]=u=>s.value.method=u),readonly:""},null,512),[[_,s.value.method]])]),e("div",$,[e("label",null,l(t(o)("Frequency")),1),v(e("input",{type:"text","onUpdate:modelValue":a[1]||(a[1]=u=>s.value.frequency=u),readonly:""},null,512),[[_,s.value.frequency]])]),e("div",ee,[e("label",null,l(t(o)("Status")),1),e("div",te,[c(t(A),{checked:s.value.stopped,"onUpdate:checked":[a[2]||(a[2]=u=>s.value.stopped=u),F]},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?(d(),i("span",ae,l(t(o)("Enabled")),1)):(d(),i("span",le,l(t(o)("Disabled")),1))])])]),e("div",ne,[e("div",de,[e("label",null,l(t(o)("Server Script")),1),v(e("input",{type:"text","onUpdate:modelValue":a[3]||(a[3]=u=>s.value.server_script=u),readonly:""},null,512),[[_,s.value.server_script]])]),e("div",ue,[e("label",null,l(t(o)("Scheduler Event")),1),v(e("input",{type:"text","onUpdate:modelValue":a[4]||(a[4]=u=>s.value.scheduler_event=u),readonly:""},null,512),[[_,s.value.scheduler_event]])]),e("div",ie,[e("label",null,l(t(o)("Created At")),1),v(e("input",{type:"text","onUpdate:modelValue":a[5]||(a[5]=u=>s.value.creation=u),readonly:""},null,512),[[_,s.value.creation]])]),e("div",re,[e("label",null,l(t(o)("Updated At")),1),v(e("input",{type:"text","onUpdate:modelValue":a[6]||(a[6]=u=>s.value.modified=u),readonly:""},null,512),[[_,s.value.modified]])])])])]),_:1},8,["title"]),s.value.frequency==="Cron"&&s.value.cron_format?(d(),h(t(x),{key:0,title:t(o)("Cron Format")},{default:r(()=>[e("div",ce,[e("div",pe,[e("code",ve,l(s.value.cron_format),1)]),e("div",_e,[e("h4",null,l(t(o)("Cron Format Description")),1),e("pre",{class:"cron-help"},l(je))])])]),_:1},8,["title"])):J("",!0),c(t(x),{title:t(o)("Execution History")},{default:r(()=>[e("div",me,[e("div",ye,[e("label",null,l(t(o)("Last Execution")),1),e("div",be,[s.value.last_execution?(d(),i("span",fe,l(S(s.value.last_execution)),1)):(d(),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?(d(),i("span",ke,l(S(b.value)),1)):s.value.stopped?(d(),i("span",Se,l(t(o)("Job is stopped")),1)):(d(),i("span",Ce,l(t(o)("Unable to calculate")),1))])])])]),_:1},8,["title"])])):(d(),i("div",Je,[a[8]||(a[8]=e("i",{class:"fa fa-exclamation-triangle"},null,-1)),f(" "+l(t(o)("Job not found")),1)]))]))}}),Ee=O(De,[["__scopeId","data-v-9cef9d64"]]);export{Ee as default};
