PageSourceSearch

https://a-cukrun-next.vercel.app/_next/static/chunks/pages/admin/cron-settings-43910bdc83db8ecf.js

js a-cukrun-next.vercel.app collected 2026-10-03 06:04:15 UTC 10,658 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8912],{77194:function(e,n,o){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/cron-settings",function(){return o(45647)}])},45647:function(e,n,o){"use strict";o.r(n),o.d(n,{default:function(){return b}});var t=o(85893),r=o(36465),s=o.n(r),a=o(67294),c=o(11163),i=o(47146),d=o(88368),l=o(15373),u=o(71765),h=o(28774),p=o(36383),m=o(71042),j=o(35599),f=o(60074),g=o(22627);function b(){var e,n;let o=(0,c.useRouter)(),{user:r,loading:b}=(0,g.aC)(),[x,y]=(0,a.useState)(!1),[S,Z]=(0,a.useState)(!0),C=(0,i.Z)(),w=(e,n)=>C.push((0,t.jsx)(d.Z,{type:e,closable:!0,children:n}),{placement:"topCenter",duration:5e3}),[v,k]=(0,a.useState)({enabled:!0,reportHourLondon:23,reportMinuteLondon:45,allowedDriftMinutes:3,sesSource:'"跑动英伦" <[email protected]>',recipientsCsv:"[email protected]",bccCsv:"",schedulerSchedule:"",schedulerTimeZone:"Europe/London"}),[N,L]=(0,a.useState)(""),[T,E]=(0,a.useState)(!0),[O,z]=(0,a.useState)(""),[R,_]=(0,a.useState)(null),[I,A]=(0,a.useState)(""),[P,B]=(0,a.useState)(null),G=!!r&&"[email protected]"===r.email;async function H(){if(!r){z("Sign in to load settings");return}y(!0),z(""),_(null);try{let e=await r.getIdToken(!0),n=await fetch("/api/cron/settings",{headers:{Authorization:"Bearer ".concat(e)}}),o=await n.json();if(!o.ok)throw Error(o.error||"Failed to fetch");k(e=>({...e,...o.settings})),z("Settings loaded"),_("success"),w("success","Settings loaded")}catch(e){z("Load failed: ".concat(e.message)),_("error"),w("error","Load failed: ".concat(e.message))}finally{y(!1)}}async function M(e){if(e&&e.preventDefault&&e.preventDefault(),!r){z("Sign in before saving and updating"),_("error");return}if(!G){z("Access denied: admin only"),_("error"),w("error","Access denied: admin only");return}y(!0),z(""),_(null);try{let e=await r.getIdToken(!0),n=await fetch("/api/cron/settings",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify(v)}),o=await n.json();if(!o.ok)throw Error(o.error||"Update failed");k(e=>({...e,...o.settings}));let t={};v.schedulerSchedule&&(t.schedule=v.schedulerSchedule),v.schedulerTimeZone&&(t.timeZone=v.schedulerTimeZone),N&&(t.jobName=N);let s=await fetch("/api/cron/scheduler-update",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify(t)}),a=await s.json();if(!a.ok)throw Error(a.message||a.error||"Scheduler update failed");k(e=>({...e,schedulerSchedule:a.job.schedule||e.schedulerSchedule,schedulerTimeZone:a.job.timeZone||e.schedulerTimeZone})),z("Saved settings and updated scheduler: ".concat(a.job.schedule," (").concat(a.job.timeZone,")")),_("success"),A("Scheduler updated: ".concat(a.job.schedule," (").concat(a.job.timeZone,")")),B("success"),w("success","Saved settings and updated scheduler: ".concat(a.job.schedule," (").concat(a.job.timeZone,")")),v.enabled?await F():await U()}catch(e){z("Save & Update failed: ".concat(e.message)),_("error"),w("error","Save & Update failed: ".concat(e.message))}finally{y(!1)}}async function D(){if(r)try{let e=await r.getIdToken(!0),n=N?"?jobName=".concat(encodeURIComponent(N)):"",o=await fetch("/api/cron/scheduler-job".concat(n),{headers:{Authorization:"Bearer ".concat(e)}}),t=await o.json();if(!t.ok)throw Error(t.message||t.error||"Failed to load job");k(e=>({...e,schedulerSchedule:t.job.schedule||"",schedulerTimeZone:t.job.timeZone||e.schedulerTimeZone||""})),A("Scheduler loaded: ".concat(t.job.schedule||"no schedule"," (").concat(t.job.timeZone||"no time zone",")")),B("success"),w("success","Scheduler loaded: ".concat(t.job.schedule||"no schedule"," (").concat(t.job.timeZone||"no time zone",")"))}catch(e){A("Cloud Scheduler read failed: ".concat(e.message)),B("error"),w("error","Cloud Scheduler read failed: ".concat(e.message))}}async function U(){try{let e=await r.getIdToken(!0),n=await fetch("/api/cron/scheduler-pause",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({jobName:N||void 0})}),o=await n.json();if(!o.ok)throw Error(o.message||o.error||"Pause failed");A("Scheduler paused: ".concat(o.job.schedule||""," (").concat(o.job.timeZone||"",")")),B("success"),w("success","Cloud Scheduler job paused")}catch(e){A("Pause failed: ".concat(e.message)),B("error"),w("error","Pause failed: ".concat(e.message))}}async function F(){try{let e=await r.getIdToken(!0),n=await fetch("/api/cron/scheduler-resume",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},body:JSON.stringify({jobName:N||void 0})}),o=await n.json();if(!o.ok)throw Error(o.message||o.error||"Resume failed");A("Scheduler resumed: ".concat(o.job.schedule||""," (").concat(o.job.timeZone||"",")")),B("success"),w("success","Cloud Scheduler job resumed")}catch(e){A("Resume failed: ".concat(e.message)),B("error"),w("error","Resume failed: ".concat(e.message))}}function J(e,n){k(o=>({...o,[e]:n}))}return(0,a.useEffect)(()=>{let e=async()=>
1{if(!b){if(G){Z(!0);try{await Promise.all([H(),D()])}catch(e){}finally{Z(!1)}}else Z(!1)}};e()},[b,G]),(0,a.useEffect)(()=>{b||G||(w("error","Access denied: admin only"),o.replace("/"))},[b,G]),(0,a.useEffect)(()=>{if(!o.isReady)return;let{cron:e,timeZone:n,job:t}=o.query||{};if("string"==typeof e&&e.trim()){let n=e.trim().split(/\s+/);if(n.length>=2){let o=String(n[0]||""),t=String(n[1]||""),r=o.split(",")[0],s=t.split(",")[0],a=parseInt(r,10),c=parseInt(s,10);!Number.isNaN(a)&&a>=0&&a<=59&&J("reportMinuteLondon",a),!Number.isNaN(c)&&c>=0&&c<=23&&J("reportHourLondon",c),k(n=>({...n,schedulerSchedule:e}))}}"string"==typeof n&&n.trim()&&J("schedulerTimeZone",n),"string"==typeof t&&t.trim()&&L(t)},[o.isReady]),(0,a.useEffect)(()=>{if(T)return;let e="".concat(v.reportMinuteLondon," ").concat(v.reportHourLondon," * * *");v.schedulerSchedule!==e&&k(n=>({...n,schedulerSchedule:e}))},[v.reportHourLondon,v.reportMinuteLondon,T]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"jsx-a9228d8c56490853 checkout-container",children:[(0,t.jsxs)(l.Z,{bordered:!0,style:{backgroundColor:"white",minHeight:"80vh"},children:[(0,t.jsx)("h2",{style:{marginBottom:8},className:"jsx-a9228d8c56490853",children:"Daily Report Scheduler Settings"}),S?(0,t.jsx)("div",{style:{display:"flex",justifyContent:"center",padding:24},className:"jsx-a9228d8c56490853",children:(0,t.jsx)(u.Z,{size:"md",center:!0,content:"Loading settings..."})}):G?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(h.Z,{fluid:!0,onSubmit:e=>{e&&e.preventDefault&&e.preventDefault()},children:[(0,t.jsx)(h.Z.Group,{children:(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%"},className:"jsx-a9228d8c56490853",children:[(0,t.jsx)(h.Z.ControlLabel,{style:{margin:0},children:"Enabled"}),(0,t.jsx)(p.Z,{checked:v.enabled,onChange:async e=>{J("enabled",!!e);try{e?await F():await U()}catch(e){}},checkedChildren:"On",unCheckedChildren:"Off"})]})}),(0,t.jsxs)(h.Z.Group,{children:[(0,t.jsx)(h.Z.ControlLabel,{children:"Report hour (Europe/London)"}),(0,t.jsx)(m.Z,{min:0,max:23,value:v.reportHourLondon,onChange:e=>
1J("reportHourLondon",Number(e)||0),style:{width:"100%"}})]}),(0,t.jsxs)(h.Z.Group,{children:[(0,t.jsx)(h.Z.ControlLabel,{children:"Report minute"}),(0,t.jsx)(m.Z,{min:0,max:59,value:v.reportMinuteLondon,onChange:e=>J("reportMinuteLondon",Number(e)||0),style:{width:"100%"}})]}),(0,t.jsxs)(h.Z.Group,{children:[(0,t.jsx)(h.Z.ControlLabel,{children:"SES source"}),(0,t.jsx)(j.Z,{value:v.sesSource,onChange:e=>J("sesSource",e)})]}),(0,t.jsxs)(h.Z.Group,{children:[(0,t.jsx)(h.Z.ControlLabel,{children:"Recipients (comma-separated)"}),(0,t.jsx)(j.Z,{value:v.recipientsCsv,onChange:e=>J("recipientsCsv",e)})]}),(0,t.jsxs)(h.Z.Group,{children:[(0,t.jsx)(h.Z.ControlLabel,{children:"BCC (comma-separated)"}),(0,t.jsx)(j.Z,{value:v.bccCsv,onChange:e=>J("bccCsv",e)})]})]}),(0,t.jsxs)(h.Z,{fluid:!0,onSubmit:M,children:[(0,t.jsx)(h.Z.Group,{children:(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%"},className:"jsx-a9228d8c56490853",children:[(0,t.jsx)(h.Z.ControlLabel,{style:{margin:0},children:"Advanced cron editor"}),(0,t.jsx)(p.Z,{checked:T,onChange:e=>E(!!e),checkedChildren:"On",unCheckedChildren:"Off"})]})}),(0,t.jsxs)(h.Z.Group,{children:[(0,t.jsx)(h.Z.ControlLabel,{children:"Cron expression"}),T?(0,t.jsx)(j.Z,{placeholder:"e.g. 5 8,18 * * *",value:null!==(e=v.schedulerSchedule)&&void 0!==e?e:"",onChange:e=>J("schedulerSchedule",null!=e?e:""),style:{width:"100%"}}):(0,t.jsx)(j.Z,{placeholder:"e.g. 30 10 * * *",value:"".concat(v.reportMinuteLondon," ").concat(v.reportHourLondon," * * *"),disabled:!0}),(0,t.jsxs)("div",{style:{marginTop:6,fontSize:12,color:"#666"},className:"jsx-a9228d8c56490853",children:["Need help? Try ",(0,t.jsx)("a",{href:"https://crontab.guru/",target:"_blank",rel:"noreferrer",className:"jsx-a9228d8c56490853",children:"crontab.guru"})]})]}),(0,t.jsxs)(h.Z.Group,{children:[(0,t.jsx)(h.Z.ControlLabel,{children:"Time zone"}),(0,t.jsx)(j.Z,{placeholder:"Europe/London",value:null!==(n=v.schedulerTimeZone)&&void 0!==n?n:"",onChange:e=>J("schedulerTimeZone",null!=e?e:""),disabled:!0})]})]})]}):(0,t.jsx)(d.Z,{type:"error",children:"Access denied: admin only"})]}),G&&!S&&(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:16},className:"jsx-a9228d8c56490853",children:[(0,t.jsxs)("div",{className:"jsx-a9228d8c56490853",children:[(0,t.jsx)(f.Z,{appearance:"link",type:"button",onClick:H,disabled:x,children:"Load current settings"}),(0,t.jsx)(f.Z,{appearance:"link",type:"button",onClick:H,disabled:x,style:{marginLeft:8},children:"Reload"})]}),(0,t.jsx)("div",{className:"jsx-a9228d8c56490853",children:(0,t.jsx)(f.Z,{appearance:"primary",type:"button",onClick:M,loading:x,children:"Save settings"})})]})]}),(0,t.jsx)(s(),{id:"a9228d8c56490853",children:'.checkout-container.jsx-a9228d8c56490853{max-width:800px;margin:0 auto;background-color:whitesmoke;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;min-height:100vh;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:16px}'})]})}}},function(e){e.O(0,[2138,9467,4467,5243,2476,9713,9496,5064,148,6281,3141,7722,1955,9100,731,848,209,8469,467,5153,3291,5323,747,541,6395,4588,5723,9226,862,4978,1147,653,2156,5702,8922,8510,8424,553,715,2600,2716,3971,930,4288,340,4159,4412,1332,7870,7429,9356,3063,5341,8212,2888,179],function(){return e(e.s=77194)}),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.