@airporting/tech-app 0.0.103 → 0.0.105

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.
@@ -1 +1 @@
1
- "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["7825"],{2268:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{g:()=>useFinanceJobsStock});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useFinanceJobsStock(){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","finance-jobs","stock"],queryFn:async()=>(await api.financeJobs.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}},1486:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>FinanceJobs});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var QueueDashboard=__webpack_require__(5351);var index_mjs_=__webpack_require__(207);var tabler_icons_react_mjs_=__webpack_require__(9632);var financeJobsStockQuery=__webpack_require__(2268);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useFinanceJobsTasks(filters){const api=(0,useApi.h)();const query={...filters.job_name&&{job_name:filters.job_name},...filters.owner&&{owner:filters.owner},...filters.company_slug&&{company_slug:filters.company_slug},...filters.state&&{state:filters.state},...filters.beta&&{beta:filters.beta},...filters.period&&{period:filters.period},...void 0!==filters.take&&{take:String(filters.take)},...void 0!==filters.skip&&{skip:String(filters.skip)}};return(0,modern_index_js_.useQuery)({queryKey:["tech","finance-jobs","tasks",filters],queryFn:async()=>(await api.financeJobs.listTasksV1(query)).data,refetchOnWindowFocus:false})}function useInvalidate(){const queryClient=(0,modern_index_js_.useQueryClient)();return()=>queryClient.invalidateQueries({queryKey:["tech","finance-jobs"]})}function useUnstickFinanceTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.unstickV1({id:String(id)})).data,onSuccess:invalidate})}function useRetryFinanceTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.retryV1({id:String(id)})).data,onSuccess:invalidate})}function useDiscardFinanceTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.discardV1({id:String(id)})).data,onSuccess:invalidate})}function useSetFinanceTaskOwner(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async({id,owner})=>(await api.financeJobs.setOwnerV1({id:String(id)},{owner})).data,onSuccess:invalidate})}function useDeleteFinanceRedisLock(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.deleteRedisLockV1({id:String(id)})).data,onSuccess:invalidate})}var jobLogsContext=__webpack_require__(4302);var esm_index_mjs_=__webpack_require__(1455);function notify(title,message,color){esm_index_mjs_.notifications.show({title,message,color})}function RowActions({taskId,jobName,companyLabel,currentOwner,githubJob,onShowLogs}){const[confirm,setConfirm]=(0,index_js_.useState)(null);const[ownerModalOpen,setOwnerModalOpen]=(0,index_js_.useState)(false);const[ownerInput,setOwnerInput]=(0,index_js_.useState)(currentOwner??"");const unstick=useUnstickFinanceTask();const retry=useRetryFinanceTask();const discard=useDiscardFinanceTask();const setOwner=useSetFinanceTaskOwner();const deleteLock=useDeleteFinanceRedisLock();const runUnstick=()=>unstick.mutate(taskId,{onSuccess:()=>notify("Unstuck",`Task #${taskId} reset`,"green"),onError:e=>notify("Failed",e?.message??"Unstick failed","red")});const runRetry=()=>{setConfirm(null);retry.mutate(taskId,{onSuccess:()=>notify("Retry queued",`Task #${taskId} will rerun`,"green"),onError:e=>notify("Failed",e?.message??"Retry failed","red")})};const runDiscard=()=>{setConfirm(null);discard.mutate(taskId,{onSuccess:()=>notify("Discarded",`Task #${taskId} marked done`,"green"),onError:e=>notify("Failed",e?.message??"Discard failed","red")})};const runSetOwner=()=>{setOwnerModalOpen(false);setOwner.mutate({id:taskId,owner:ownerInput},{onSuccess:()=>notify("Owner updated",`Task #${taskId} \u{2192} ${ownerInput}`,"green"),onError:e=>notify("Failed",e?.message??"Set owner failed","red")})};const runDeleteLock=()=>{setConfirm(null);deleteLock.mutate(taskId,{onSuccess:data=>notify("Redis lock",data.existed?`Deleted ${data.key}`:`No lock found (${data.key})`,"green"),onError:e=>notify("Failed",e?.message??"Redis delete failed","red")})};return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[githubJob&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"Voir les logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",onClick:()=>onShowLogs(githubJob),"aria-label":"Voir les logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTerminal,{size:16})})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu,{position:"bottom-end",withArrow:true,shadow:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Target,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default","aria-label":"Actions",children:"⋮"})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu.Dropdown,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:runUnstick,children:"Unstick"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>setConfirm("retry"),children:"Retry"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>{setOwnerInput(currentOwner??"");setOwnerModalOpen(true)},children:"Set owner…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>setConfirm("redis"),children:"Delete Redis lock"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{color:"red",onClick:()=>setConfirm("discard"),children:"Discard"})]})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"retry"===confirm,onClose:()=>setConfirm(null),title:"Retry task",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Reset task #",taskId," (",jobName," — ",companyLabel,") so the runner picks it up again. This clears ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"finished"}),","," ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"startedAt"}),", ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"error"})," and the Redis lock."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:runRetry,loading:retry.isPending,children:"Retry"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"discard"===confirm,onClose:()=>setConfirm(null),title:"Discard task",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Mark task #",taskId," (",jobName," — ",companyLabel,") as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"finished"})," ","with error=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". The runner will skip it."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",onClick:runDiscard,loading:discard.isPending,children:"Discard"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"redis"===confirm,onClose:()=>setConfirm(null),title:"Delete Redis lock",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Delete ",/*#__PURE__*/(0,jsx_runtime.jsxs)("code",{children:["fm-task-node-",taskId]}),". The runner will be able to pick this task up again on the next iteration."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"orange",onClick:runDeleteLock,loading:deleteLock.isPending,children:"Delete lock"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:ownerModalOpen,onClose:()=>setOwnerModalOpen(false),title:`Set owner for task #${taskId}`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Owner email",value:ownerInput,onChange:e=>setOwnerInput(e.currentTarget.value),placeholder:"bob@airporting.com"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setOwnerModalOpen(false),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:runSetOwner,loading:setOwner.isPending,disabled:!ownerInput.trim(),children:"Save"})]})]})})]})}function useFinanceRunners(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","finance-jobs","runners"],queryFn:async()=>(await api.financeJobs.getRunnersV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}function RunnerBadge(){const runners=useFinanceRunners();if(runners.isError)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"gray",variant:"light",children:"runners —"});if(!runners.data)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"gray",variant:"light",children:"runners …"});const inProgress=runners.data.inProgress??0;const queued=runners.data.queued??0;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:`${inProgress} run(s) en cours \xb7 ${queued} en file`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Badge,{color:inProgress>0?"green":"gray",variant:inProgress>0?"filled":"light",children:["▶ ",inProgress," en cours",queued>0?` \xb7 ${queued} en file`:""]})})}function useRunRecipe(){const api=(0,useApi.h)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async count=>(await api.financeJobs.runRecipeV1({count})).data,onSuccess:data=>{esm_index_mjs_.notifications.show({title:"Run recipe",message:data?.message??`${data?.dispatched??0} run(s) lanc\xe9(s)`,color:"green"});queryClient.invalidateQueries({queryKey:["tech","finance-jobs","runners"]})},onError:err=>{esm_index_mjs_.notifications.show({title:"Run recipe",message:err?.error?.error??err?.message??"\xc9chec du dispatch",color:"red"})}})}function RunRecipeButton(){const[count,setCount]=(0,index_js_.useState)(1);const run=useRunRecipe();return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{size:"sm",w:70,min:1,max:3,value:count,onChange:v=>setCount("number"==typeof v?v:1),clampBehavior:"strict"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"sm",color:"green",loading:run.isPending,onClick:()=>run.mutate(count),children:"▶ Ajouter des runners"})]})}const STATE_COLORS={pending:"gray",running:"blue",stuck:"orange",errored:"red",done:"green"};const STATE_LABELS={pending:"En attente",running:"En cours",stuck:"Bloqu\xe9e",errored:"En erreur",done:"Termin\xe9e"};function fmt(d){return d?new Date(d).toLocaleString("fr-FR"):"—"}function fmtDuration(ms){if(null==ms)return"—";if(ms<1e3)return`${ms}ms`;const s=Math.floor(ms/1e3);if(s<60)return`${s}s`;const m=Math.floor(s/60);return`${m}m${s%60}s`}function config_companyLabel(item){return item.company_display_name??item.company_slug??`#${item.company_id}`}function stateBadge(item){if("stuck"===item.state){const n=Math.min(item.reboot_count+1,3);const color=n>=3?"red":2===n?"orange":"yellow";return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:color,children:`stuck \xd7${n}`})}return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[item.state],children:STATE_LABELS[item.state]})}function MobileInfo({label,value}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:1,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"10px",c:"dimmed",tt:"uppercase",fw:700,children:label}),"string"==typeof value?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",lineClamp:1,children:value}):value]})}function FinanceMobileCard({item,id,selected,onToggle,actions}){const label=config_companyLabel(item);const trigger="manual"===item.trigger_source?item.owner||"Manuel":"Planifi\xe9";return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Card,{withBorder:true,padding:"sm",radius:"md",style:{borderColor:selected?"var(--mantine-color-teal-5)":void 0,background:selected?"rgba(32, 201, 151, 0.08)":void 0},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",align:"flex-start",wrap:"nowrap",style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{mt:3,checked:selected,onChange:onToggle,"aria-label":`Select task ${id}`}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:2,style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:item.job_name_fr??item.job_name}),item.beta&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"violet",variant:"light",children:"beta"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:label})]})]}),stateBadge(item)]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:2,spacing:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(MobileInfo,{label:"Type",value:trigger}),/*#__PURE__*/(0,jsx_runtime.jsx)(MobileInfo,{label:"Cr\xe9\xe9e",value:fmt(item.created)}),/*#__PURE__*/(0,jsx_runtime.jsx)(MobileInfo,{label:"Dur\xe9e",value:fmtDuration(item.runDuration)}),/*#__PURE__*/(0,jsx_runtime.jsx)(MobileInfo,{label:"Relances",value:item.reboot_count>0?`${item.reboot_count}`:"—"})]}),item.error?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Code,{c:"red",style:{display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:item.error}):null!=item.trace_count?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",c:"dimmed",children:[item.trace_count," ",item.trace_label??""]}):null,/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",c:"dimmed",children:["#",id]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{gap:"xs",children:actions})]})]})})}function FinanceRowActions({item}){const openLogs=(0,jobLogsContext.j)();return/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:item.id,jobName:item.job_name,companyLabel:config_companyLabel(item),currentOwner:item.owner,githubJob:item.github_job,onShowLogs:openLogs})}async function runBulk(ids,fn){const results=await Promise.allSettled(ids.map(fn));const ok=results.filter(r=>"fulfilled"===r.status).length;return{ok,failed:results.length-ok}}function useFinanceJobsConfig(){const unstick=useUnstickFinanceTask();const retry=useRetryFinanceTask();const discard=useDiscardFinanceTask();const setOwner=useSetFinanceTaskOwner();const deleteLock=useDeleteFinanceRedisLock();return(0,index_js_.useMemo)(()=>({title:"Finance jobs",source:{useStock:financeJobsStockQuery.g,useTasks:({job_name,owner,company_slug,state,beta,period},pagination)=>useFinanceJobsTasks({job_name:job_name??void 0,owner:owner??void 0,company_slug:company_slug??void 0,state,beta,period,skip:pagination.skip,take:pagination.take})},initialFilters:{job_name:null,owner:null,company_slug:null,state:"pending",beta:"false",period:"all",search:""},kpis:[{key:"pending",label:"\xc0 traiter",value:s=>s?.pending??0,filter:{state:"pending",beta:"all",period:"all"}},{key:"running",label:"En cours",value:s=>s?.running??0,filter:{state:"running",beta:"all",period:"all"}},{key:"stuck",label:"Bloqu\xe9s",value:s=>s?.stuck??0,tone:s=>(s?.stuck??0)>0?"warn":"neutral",filter:{state:"stuck",beta:"all",period:"all"}},{key:"errored_today",label:"Erreurs du jour",value:s=>s?.errored_today??0,tone:s=>(s?.errored_today??0)>0?"bad":"neutral",filter:{state:"errored",beta:"all",period:"today"}},{key:"done_today",label:"Termin\xe9s du jour",value:s=>s?.done_today??0,filter:{state:"done",beta:"all",period:"today"}},{key:"oldest",label:"Plus ancien",value:s=>s?.oldest?`${s.oldest.ageHours}h`:"—"}],filters:[{kind:"select",key:"job_name",label:"T\xe2che",options:s=>(s?.byJobName??[]).map(e=>e.key),width:240},{kind:"select",key:"owner",label:"Propri\xe9taire",options:s=>(s?.byOwner??[]).map(e=>e.key),width:240},{kind:"select",key:"company_slug",label:"Entreprise",options:s=>(s?.byCompany??[]).map(e=>e.key),width:220},{kind:"select",key:"state",label:"\xc9tat",options:()=>["pending","running","stuck","errored","done","all"],clearable:false,width:140},{kind:"select",key:"beta",label:"Beta",options:()=>[{value:"false",label:"Prod"},{value:"true",label:"Beta"},{value:"all",label:"Tout"}],clearable:false,width:120},{kind:"select",key:"period",label:"P\xe9riode",options:()=>[{value:"all",label:"Tout"},{value:"today",label:"Aujourd'hui"}],clearable:false,width:140},{kind:"search",key:"search",label:"Recherche",placeholder:"id, owner, company, erreur…",width:240}],columns:[{key:"job",label:"T\xe2che",render:t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.job_name}),t.beta&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"violet",variant:"light",children:"beta"})]})},{key:"company",label:"Entreprise",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.company_display_name??t.company_slug??`#${t.company_id}`})},{key:"type",label:"Type",render:t=>"manual"===t.trigger_source?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconUser,{size:18,stroke:1.5}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.owner})]}):/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconRobot,{size:18,stroke:1.5}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"Planifi\xe9"})]})},{key:"state",label:"\xc9tat",render:stateBadge},{key:"created",label:"Cr\xe9\xe9e",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.created)})},{key:"startedAt",label:"D\xe9marr\xe9e",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.startedAt)})},{key:"finishedAt",label:"Termin\xe9e",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.finishedAt)})},{key:"duration",label:"Dur\xe9e",render:t=>fmtDuration(t.runDuration)},{key:"error",label:"R\xe9sultat / Erreur",render:t=>t.error?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:t.error,multiline:true,w:420,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Code,{c:"red",style:{display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:320},children:t.error})}):null!=t.trace_count?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:[t.trace_count," ",t.trace_label??""]}):"—"}],rowActions:[{key:"actions",render:item=>/*#__PURE__*/(0,jsx_runtime.jsx)(FinanceRowActions,{item:item})}],mobile:{title:"Action requise",emptyLabel:"Aucune t\xe2che Finance Jobs pour ces filtres.",renderItem:(item,context)=>/*#__PURE__*/(0,jsx_runtime.jsx)(FinanceMobileCard,{item:item,...context})},bulkActions:[{key:"unstick",label:"D\xe9bloquer",run:ids=>runBulk(ids,id=>unstick.mutateAsync(id))},{key:"retry",label:"Relancer",confirm:{title:"Relancer {count} t\xe2che(s)",body:"R\xe9initialise les t\xe2ches pour que le runner les reprenne."},run:ids=>runBulk(ids,id=>retry.mutateAsync(id))},{key:"set-owner",label:"Changer le propri\xe9taire…",prompt:{label:"E-mail du propri\xe9taire",placeholder:"bob@airporting.com"},run:(ids,owner)=>{if(!owner)return Promise.resolve({ok:0,failed:ids.length});return runBulk(ids,id=>setOwner.mutateAsync({id,owner}))}},{key:"delete-lock",label:"Supprimer le verrou Redis",color:"orange",confirm:{title:"Supprimer le verrou Redis pour {count} t\xe2che(s)",body:"Suppression du verrou Redis fm-task-node-<id>."},run:ids=>runBulk(ids,id=>deleteLock.mutateAsync(id))},{key:"discard",label:"Abandonner",color:"red",confirm:{title:"Abandonner {count} t\xe2che(s)",body:"Les t\xe2ches seront marqu\xe9es termin\xe9es avec error=discarded."},run:ids=>runBulk(ids,id=>discard.mutateAsync(id))}],topErrors:{extract:t=>t.error},headerBadge:/*#__PURE__*/(0,jsx_runtime.jsx)(RunnerBadge,{}),headerActions:/*#__PURE__*/(0,jsx_runtime.jsx)(RunRecipeButton,{}),getRowId:t=>t.id,searchMatches:(t,q)=>String(t.id).includes(q)||(t.owner??"").toLowerCase().includes(q)||(t.company_slug??"").toLowerCase().includes(q)||(t.company_display_name??"").toLowerCase().includes(q)||(t.job_name??"").toLowerCase().includes(q)||(t.error??"").toLowerCase().includes(q)}),[unstick,retry,discard,setOwner,deleteLock])}function FinanceJobsApp(){const config=useFinanceJobsConfig();return/*#__PURE__*/(0,jsx_runtime.jsx)(QueueDashboard.r,{config:config})}function FinanceJobs(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(FinanceJobsApp,{})})})}}}]);
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["7825"],{2268:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{g:()=>useFinanceJobsStock});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useFinanceJobsStock(filters={}){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();const query={...filters.period&&{period:filters.period}};return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","finance-jobs","stock",filters],queryFn:async()=>(await api.financeJobs.getStockV1({query})).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}},1486:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>FinanceJobs});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var QueueDashboard=__webpack_require__(5351);var index_mjs_=__webpack_require__(207);var tabler_icons_react_mjs_=__webpack_require__(9632);var financeJobsStockQuery=__webpack_require__(2268);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useFinanceJobsTasks(filters){const api=(0,useApi.h)();const query={...filters.job_name&&{job_name:filters.job_name},...filters.owner&&{owner:filters.owner},...filters.company_slug&&{company_slug:filters.company_slug},...filters.state&&{state:filters.state},...filters.beta&&{beta:filters.beta},...filters.period&&{period:filters.period},...void 0!==filters.take&&{take:String(filters.take)},...void 0!==filters.skip&&{skip:String(filters.skip)}};return(0,modern_index_js_.useQuery)({queryKey:["tech","finance-jobs","tasks",filters],queryFn:async()=>(await api.financeJobs.listTasksV1(query)).data,refetchOnWindowFocus:false})}function useInvalidate(){const queryClient=(0,modern_index_js_.useQueryClient)();return()=>queryClient.invalidateQueries({queryKey:["tech","finance-jobs"]})}function useUnstickFinanceTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.unstickV1({id:String(id)})).data,onSuccess:invalidate})}function useRetryFinanceTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.retryV1({id:String(id)})).data,onSuccess:invalidate})}function useDiscardFinanceTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.discardV1({id:String(id)})).data,onSuccess:invalidate})}function useSetFinanceTaskOwner(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async({id,owner})=>(await api.financeJobs.setOwnerV1({id:String(id)},{owner})).data,onSuccess:invalidate})}function useDeleteFinanceRedisLock(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.deleteRedisLockV1({id:String(id)})).data,onSuccess:invalidate})}var jobLogsContext=__webpack_require__(4302);var esm_index_mjs_=__webpack_require__(1455);function notify(title,message,color){esm_index_mjs_.notifications.show({title,message,color})}function RowActions({taskId,jobName,companyLabel,currentOwner,githubJob,onShowLogs}){const[confirm,setConfirm]=(0,index_js_.useState)(null);const[ownerModalOpen,setOwnerModalOpen]=(0,index_js_.useState)(false);const[ownerInput,setOwnerInput]=(0,index_js_.useState)(currentOwner??"");const unstick=useUnstickFinanceTask();const retry=useRetryFinanceTask();const discard=useDiscardFinanceTask();const setOwner=useSetFinanceTaskOwner();const deleteLock=useDeleteFinanceRedisLock();const runUnstick=()=>unstick.mutate(taskId,{onSuccess:()=>notify("Unstuck",`Task #${taskId} reset`,"green"),onError:e=>notify("Failed",e?.message??"Unstick failed","red")});const runRetry=()=>{setConfirm(null);retry.mutate(taskId,{onSuccess:()=>notify("Retry queued",`Task #${taskId} will rerun`,"green"),onError:e=>notify("Failed",e?.message??"Retry failed","red")})};const runDiscard=()=>{setConfirm(null);discard.mutate(taskId,{onSuccess:()=>notify("Discarded",`Task #${taskId} marked done`,"green"),onError:e=>notify("Failed",e?.message??"Discard failed","red")})};const runSetOwner=()=>{setOwnerModalOpen(false);setOwner.mutate({id:taskId,owner:ownerInput},{onSuccess:()=>notify("Owner updated",`Task #${taskId} \u{2192} ${ownerInput}`,"green"),onError:e=>notify("Failed",e?.message??"Set owner failed","red")})};const runDeleteLock=()=>{setConfirm(null);deleteLock.mutate(taskId,{onSuccess:data=>notify("Redis lock",data.existed?`Deleted ${data.key}`:`No lock found (${data.key})`,"green"),onError:e=>notify("Failed",e?.message??"Redis delete failed","red")})};return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[githubJob&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"Voir les logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",onClick:()=>onShowLogs(githubJob),"aria-label":"Voir les logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTerminal,{size:16})})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu,{position:"bottom-end",withArrow:true,shadow:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Target,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default","aria-label":"Actions",children:"⋮"})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu.Dropdown,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:runUnstick,children:"Unstick"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>setConfirm("retry"),children:"Retry"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>{setOwnerInput(currentOwner??"");setOwnerModalOpen(true)},children:"Set owner…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>setConfirm("redis"),children:"Delete Redis lock"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{color:"red",onClick:()=>setConfirm("discard"),children:"Discard"})]})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"retry"===confirm,onClose:()=>setConfirm(null),title:"Retry task",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Reset task #",taskId," (",jobName," — ",companyLabel,") so the runner picks it up again. This clears ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"finished"}),","," ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"startedAt"}),", ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"error"})," and the Redis lock."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:runRetry,loading:retry.isPending,children:"Retry"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"discard"===confirm,onClose:()=>setConfirm(null),title:"Discard task",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Mark task #",taskId," (",jobName," — ",companyLabel,") as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"finished"})," ","with error=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". The runner will skip it."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",onClick:runDiscard,loading:discard.isPending,children:"Discard"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"redis"===confirm,onClose:()=>setConfirm(null),title:"Delete Redis lock",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Delete ",/*#__PURE__*/(0,jsx_runtime.jsxs)("code",{children:["fm-task-node-",taskId]}),". The runner will be able to pick this task up again on the next iteration."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"orange",onClick:runDeleteLock,loading:deleteLock.isPending,children:"Delete lock"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:ownerModalOpen,onClose:()=>setOwnerModalOpen(false),title:`Set owner for task #${taskId}`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Owner email",value:ownerInput,onChange:e=>setOwnerInput(e.currentTarget.value),placeholder:"bob@airporting.com"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setOwnerModalOpen(false),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:runSetOwner,loading:setOwner.isPending,disabled:!ownerInput.trim(),children:"Save"})]})]})})]})}function useFinanceRunners(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","finance-jobs","runners"],queryFn:async()=>(await api.financeJobs.getRunnersV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}function RunnerBadge(){const runners=useFinanceRunners();if(runners.isError)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"gray",variant:"light",children:"runners —"});if(!runners.data)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"gray",variant:"light",children:"runners …"});const inProgress=runners.data.inProgress??0;const queued=runners.data.queued??0;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:`${inProgress} run(s) en cours \xb7 ${queued} en file`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Badge,{color:inProgress>0?"green":"gray",variant:inProgress>0?"filled":"light",children:["▶ ",inProgress," en cours",queued>0?` \xb7 ${queued} en file`:""]})})}function useRunRecipe(){const api=(0,useApi.h)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async count=>(await api.financeJobs.runRecipeV1({count})).data,onSuccess:data=>{esm_index_mjs_.notifications.show({title:"Run recipe",message:data?.message??`${data?.dispatched??0} run(s) lanc\xe9(s)`,color:"green"});queryClient.invalidateQueries({queryKey:["tech","finance-jobs","runners"]})},onError:err=>{esm_index_mjs_.notifications.show({title:"Run recipe",message:err?.error?.error??err?.message??"\xc9chec du dispatch",color:"red"})}})}function RunRecipeButton(){const[count,setCount]=(0,index_js_.useState)(1);const run=useRunRecipe();return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{size:"sm",w:70,min:1,max:3,value:count,onChange:v=>setCount("number"==typeof v?v:1),clampBehavior:"strict"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"sm",color:"green",loading:run.isPending,onClick:()=>run.mutate(count),children:"▶ Ajouter des runners"})]})}const STATE_COLORS={pending:"gray",running:"blue",stuck:"orange",errored:"red",done:"green"};const STATE_LABELS={pending:"En attente",running:"En cours",stuck:"Bloqu\xe9e",errored:"En erreur",done:"Termin\xe9e"};function fmt(d){return d?new Date(d).toLocaleString("fr-FR"):"—"}function fmtDuration(ms){if(null==ms)return"—";if(ms<1e3)return`${ms}ms`;const s=Math.floor(ms/1e3);if(s<60)return`${s}s`;const m=Math.floor(s/60);return`${m}m${s%60}s`}function config_companyLabel(item){return item.company_display_name??item.company_slug??`#${item.company_id}`}function stateBadge(item){if("stuck"===item.state){const n=Math.min(item.reboot_count+1,3);const color=n>=3?"red":2===n?"orange":"yellow";return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:color,children:`stuck \xd7${n}`})}return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[item.state],children:STATE_LABELS[item.state]})}function MobileInfo({label,value}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:1,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"10px",c:"dimmed",tt:"uppercase",fw:700,children:label}),"string"==typeof value?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",lineClamp:1,children:value}):value]})}function FinanceMobileCard({item,id,selected,onToggle,actions}){const label=config_companyLabel(item);const trigger="manual"===item.trigger_source?item.owner||"Manuel":"Planifi\xe9";return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Card,{withBorder:true,padding:"sm",radius:"md",style:{borderColor:selected?"var(--mantine-color-teal-5)":void 0,background:selected?"rgba(32, 201, 151, 0.08)":void 0},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",align:"flex-start",wrap:"nowrap",style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{mt:3,checked:selected,onChange:onToggle,"aria-label":`Select task ${id}`}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:2,style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:item.job_name_fr??item.job_name}),item.beta&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"violet",variant:"light",children:"beta"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:label})]})]}),stateBadge(item)]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:2,spacing:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(MobileInfo,{label:"Type",value:trigger}),/*#__PURE__*/(0,jsx_runtime.jsx)(MobileInfo,{label:"Cr\xe9\xe9e",value:fmt(item.created)}),/*#__PURE__*/(0,jsx_runtime.jsx)(MobileInfo,{label:"Dur\xe9e",value:fmtDuration(item.runDuration)}),/*#__PURE__*/(0,jsx_runtime.jsx)(MobileInfo,{label:"Relances",value:item.reboot_count>0?`${item.reboot_count}`:"—"})]}),item.error?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Code,{c:"red",style:{display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:item.error}):null!=item.trace_count?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",c:"dimmed",children:[item.trace_count," ",item.trace_label??""]}):null,/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",c:"dimmed",children:["#",id]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{gap:"xs",children:actions})]})]})})}function FinanceRowActions({item}){const openLogs=(0,jobLogsContext.j)();return/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:item.id,jobName:item.job_name,companyLabel:config_companyLabel(item),currentOwner:item.owner,githubJob:item.github_job,onShowLogs:openLogs})}async function runBulk(ids,fn){const results=await Promise.allSettled(ids.map(fn));const ok=results.filter(r=>"fulfilled"===r.status).length;return{ok,failed:results.length-ok}}function useFinanceJobsConfig(){const unstick=useUnstickFinanceTask();const retry=useRetryFinanceTask();const discard=useDiscardFinanceTask();const setOwner=useSetFinanceTaskOwner();const deleteLock=useDeleteFinanceRedisLock();return(0,index_js_.useMemo)(()=>({title:"Finance jobs",source:{useStock:({period})=>(0,financeJobsStockQuery.g)({period:period??void 0}),useTasks:({job_name,owner,company_slug,state,beta,period},pagination)=>useFinanceJobsTasks({job_name:job_name??void 0,owner:owner??void 0,company_slug:company_slug??void 0,state,beta,period,skip:pagination.skip,take:pagination.take})},initialFilters:{job_name:null,owner:null,company_slug:null,state:"pending",beta:"false",period:"today",search:""},kpis:[{key:"pending",label:"\xc0 traiter",value:s=>s?.pending??0,filter:{state:"pending",beta:"all"}},{key:"running",label:"En cours",value:s=>s?.running??0,filter:{state:"running",beta:"all"}},{key:"stuck",label:"Bloqu\xe9s",value:s=>s?.stuck??0,tone:s=>(s?.stuck??0)>0?"warn":"neutral",filter:{state:"stuck",beta:"all"}},{key:"errored",label:"En erreur",value:s=>s?.errored??0,tone:s=>(s?.errored??0)>0?"bad":"neutral",filter:{state:"errored",beta:"all"}},{key:"done_today",label:"Termin\xe9s",value:s=>s?.done_today??0,filter:{state:"done",beta:"all"}},{key:"oldest",label:"Plus ancien",value:s=>s?.oldest?`${s.oldest.ageHours}h`:"—"}],filters:[{kind:"select",key:"job_name",label:"T\xe2che",options:s=>(s?.byJobName??[]).map(e=>e.key),width:240},{kind:"select",key:"owner",label:"Propri\xe9taire",options:s=>(s?.byOwner??[]).map(e=>e.key),width:240},{kind:"select",key:"company_slug",label:"Entreprise",options:s=>(s?.byCompany??[]).map(e=>e.key),width:220},{kind:"select",key:"state",label:"\xc9tat",options:()=>["pending","running","stuck","errored","done","all"],clearable:false,width:140},{kind:"select",key:"beta",label:"Beta",options:()=>[{value:"false",label:"Prod"},{value:"true",label:"Beta"},{value:"all",label:"Tout"}],clearable:false,width:120},{kind:"select",key:"period",label:"P\xe9riode",options:()=>[{value:"today",label:"Aujourd'hui"},{value:"7d",label:"7 jours"},{value:"30d",label:"30 jours"},{value:"all",label:"Tout"}],clearable:false,width:140},{kind:"search",key:"search",label:"Recherche",placeholder:"id, owner, company, erreur…",width:240}],columns:[{key:"job",label:"T\xe2che",render:t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.job_name}),t.beta&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"violet",variant:"light",children:"beta"})]})},{key:"company",label:"Entreprise",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.company_display_name??t.company_slug??`#${t.company_id}`})},{key:"type",label:"Type",render:t=>"manual"===t.trigger_source?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconUser,{size:18,stroke:1.5}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.owner})]}):/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconRobot,{size:18,stroke:1.5}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"Planifi\xe9"})]})},{key:"state",label:"\xc9tat",render:stateBadge},{key:"created",label:"Cr\xe9\xe9e",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.created)})},{key:"startedAt",label:"D\xe9marr\xe9e",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.startedAt)})},{key:"finishedAt",label:"Termin\xe9e",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.finishedAt)})},{key:"duration",label:"Dur\xe9e",render:t=>fmtDuration(t.runDuration)},{key:"error",label:"R\xe9sultat / Erreur",render:t=>t.error?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:t.error,multiline:true,w:420,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Code,{c:"red",style:{display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:320},children:t.error})}):null!=t.trace_count?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:[t.trace_count," ",t.trace_label??""]}):"—"}],rowActions:[{key:"actions",render:item=>/*#__PURE__*/(0,jsx_runtime.jsx)(FinanceRowActions,{item:item})}],mobile:{title:"Action requise",emptyLabel:"Aucune t\xe2che Finance Jobs pour ces filtres.",renderItem:(item,context)=>/*#__PURE__*/(0,jsx_runtime.jsx)(FinanceMobileCard,{item:item,...context})},bulkActions:[{key:"unstick",label:"D\xe9bloquer",run:ids=>runBulk(ids,id=>unstick.mutateAsync(id))},{key:"retry",label:"Relancer",confirm:{title:"Relancer {count} t\xe2che(s)",body:"R\xe9initialise les t\xe2ches pour que le runner les reprenne."},run:ids=>runBulk(ids,id=>retry.mutateAsync(id))},{key:"set-owner",label:"Changer le propri\xe9taire…",prompt:{label:"E-mail du propri\xe9taire",placeholder:"bob@airporting.com"},run:(ids,owner)=>{if(!owner)return Promise.resolve({ok:0,failed:ids.length});return runBulk(ids,id=>setOwner.mutateAsync({id,owner}))}},{key:"delete-lock",label:"Supprimer le verrou Redis",color:"orange",confirm:{title:"Supprimer le verrou Redis pour {count} t\xe2che(s)",body:"Suppression du verrou Redis fm-task-node-<id>."},run:ids=>runBulk(ids,id=>deleteLock.mutateAsync(id))},{key:"discard",label:"Abandonner",color:"red",confirm:{title:"Abandonner {count} t\xe2che(s)",body:"Les t\xe2ches seront marqu\xe9es termin\xe9es avec error=discarded."},run:ids=>runBulk(ids,id=>discard.mutateAsync(id))}],topErrors:{extract:t=>t.error},headerBadge:/*#__PURE__*/(0,jsx_runtime.jsx)(RunnerBadge,{}),headerActions:/*#__PURE__*/(0,jsx_runtime.jsx)(RunRecipeButton,{}),getRowId:t=>t.id,searchMatches:(t,q)=>String(t.id).includes(q)||(t.owner??"").toLowerCase().includes(q)||(t.company_slug??"").toLowerCase().includes(q)||(t.company_display_name??"").toLowerCase().includes(q)||(t.job_name??"").toLowerCase().includes(q)||(t.error??"").toLowerCase().includes(q)}),[unstick,retry,discard,setOwner,deleteLock])}function FinanceJobsApp(){const config=useFinanceJobsConfig();return/*#__PURE__*/(0,jsx_runtime.jsx)(QueueDashboard.r,{config:config})}function FinanceJobs(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(FinanceJobsApp,{})})})}}}]);
@@ -1 +1 @@
1
- "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["509"],{466:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{U:()=>useGsheetStock});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useGsheetStock(filters={}){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();const query={...filters.period&&{period:filters.period}};return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","gsheet","stock",filters],queryFn:async()=>(await api.gsheet.getStockV1(query)).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}},3897:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{O:()=>BrandLogo});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(243);function BrandLogo({domain,alt,size=24}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Image,{src:(0,_src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__.j)(domain),alt:alt,title:alt,w:size,h:size,fit:"contain",radius:"sm",style:{aspectRatio:1}})}},243:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{j:()=>logoDevUrl});const LOGO_DEV_TOKEN="pk_BVN4OQv0Qs-bnqjdIgTppg";function logoDevUrl(domain){return`https://img.logo.dev/${domain}?token=${LOGO_DEV_TOKEN}`}},5080:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Spreadsheet});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var QueueDashboard=__webpack_require__(5351);var index_mjs_=__webpack_require__(207);var tabler_icons_react_mjs_=__webpack_require__(9632);var gsheetStockQuery=__webpack_require__(466);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useGsheetTasks(filters){const api=(0,useApi.h)();const service=filters.service?.toLowerCase()==="all"?void 0:filters.service;const owner=filters.owner?.toLowerCase()==="all"?void 0:filters.owner;const query={...service&&{service},...owner&&{owner},...filters.state&&{state:filters.state},...filters.period&&{period:filters.period},...void 0!==filters.take&&{take:String(filters.take)},...void 0!==filters.skip&&{skip:String(filters.skip)}};return(0,modern_index_js_.useQuery)({queryKey:["tech","gsheet","tasks",filters],queryFn:async()=>(await api.gsheet.listTasksV1(query)).data,refetchOnWindowFocus:false})}function useInvalidate(){const queryClient=(0,modern_index_js_.useQueryClient)();return()=>queryClient.invalidateQueries({queryKey:["tech","gsheet"]})}function useUnstickTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.gsheet.unstickV1({id:String(id)})).data,onSuccess:invalidate})}function useDiscardTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.gsheet.discardV1({id:String(id)})).data,onSuccess:invalidate})}function useSetTaskOwner(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async({id,owner})=>(await api.gsheet.setOwnerV1({id:String(id)},{owner})).data,onSuccess:invalidate})}function useDeleteRedisLock(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.gsheet.deleteRedisLockV1({id:String(id)})).data,onSuccess:invalidate})}var jobLogsContext=__webpack_require__(4302);var esm_index_mjs_=__webpack_require__(1455);function grafanaUrl(traceId){return`https://airporting.grafana.net/d/beegyy3vsp8n4c/recipes?var-trace=${encodeURIComponent(traceId)}&orgId=1&from=now-7d&to=now&timezone=browser&showCategory=Logs&refresh=7d`}function notify(title,message,color){esm_index_mjs_.notifications.show({title,message,color})}function RowActions({taskId,currentOwner,service,spreadsheet,worksheet,githubJob,traceId,onShowLogs}){const[confirm,setConfirm]=(0,index_js_.useState)(null);const[ownerModalOpen,setOwnerModalOpen]=(0,index_js_.useState)(false);const[ownerInput,setOwnerInput]=(0,index_js_.useState)(currentOwner??"");const unstick=useUnstickTask();const discard=useDiscardTask();const setOwner=useSetTaskOwner();const deleteLock=useDeleteRedisLock();const runUnstick=()=>unstick.mutate(taskId,{onSuccess:()=>notify("Unstuck",`Task #${taskId} reset`,"green"),onError:e=>notify("Failed",e?.message??"Unstick failed","red")});const runDiscard=()=>{setConfirm(null);discard.mutate(taskId,{onSuccess:()=>notify("Discarded",`Task #${taskId} marked done`,"green"),onError:e=>notify("Failed",e?.message??"Discard failed","red")})};const runSetOwner=()=>{setOwnerModalOpen(false);setOwner.mutate({id:taskId,owner:ownerInput},{onSuccess:()=>notify("Owner updated",`Task #${taskId} \u{2192} ${ownerInput}`,"green"),onError:e=>notify("Failed",e?.message??"Set owner failed","red")})};const runDeleteLock=()=>{setConfirm(null);deleteLock.mutate(taskId,{onSuccess:data=>notify("Redis lock",data.existed?`Deleted ${data.key}`:`No lock found (${data.key})`,"green"),onError:e=>notify("Failed",e?.message??"Redis delete failed","red")})};const getWorksheetUrl=()=>{if(!spreadsheet)return null;return"excel"===service?`https://airporting.sharepoint.com/:x:/g/personal/airporting_com/ER${spreadsheet}`:`https://docs.google.com/spreadsheets/d/${spreadsheet}/edit`};const worksheetUrl=getWorksheetUrl();return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[worksheetUrl&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"Ouvrir le tableur",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{component:"a",href:worksheetUrl,target:"_blank",rel:"noopener noreferrer",variant:"subtle","aria-label":"Ouvrir le tableur",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconFileSpreadsheet,{size:16})})}),githubJob&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"GitHub Actions logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",onClick:()=>onShowLogs(githubJob),"aria-label":"GitHub Actions logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTerminal,{size:16})})}),traceId&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"Grafana Loki logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{component:"a",href:grafanaUrl(traceId),target:"_blank",rel:"noopener noreferrer",variant:"subtle","aria-label":"Grafana Loki logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconFileText,{size:16})})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu,{position:"bottom-end",withArrow:true,shadow:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Target,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default","aria-label":"Actions",children:"⋮"})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu.Dropdown,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:runUnstick,children:"Unstick"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>{setOwnerInput(currentOwner??"");setOwnerModalOpen(true)},children:"Set owner…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>setConfirm("redis"),children:"Delete Redis lock"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{color:"red",onClick:()=>setConfirm("discard"),children:"Discard"})]})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"discard"===confirm,onClose:()=>setConfirm(null),title:"Discard task",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Mark task #",taskId," (",spreadsheet,worksheet?`:${worksheet}`:"",") as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"done"})," with step=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". The task will not be processed by the runner."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",onClick:runDiscard,loading:discard.isPending,children:"Discard"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"redis"===confirm,onClose:()=>setConfirm(null),title:"Delete Redis lock",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Delete the Redis running-lock for ",spreadsheet,worksheet?`:${worksheet}`:"",". The runner will be able to pick up the worksheet again on the next iteration."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"orange",onClick:runDeleteLock,loading:deleteLock.isPending,children:"Delete lock"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:ownerModalOpen,onClose:()=>setOwnerModalOpen(false),title:`Set owner for task #${taskId}`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Owner email",value:ownerInput,onChange:e=>setOwnerInput(e.currentTarget.value),placeholder:"bob@airporting.com"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setOwnerModalOpen(false),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:runSetOwner,loading:setOwner.isPending,disabled:!ownerInput.trim(),children:"Save"})]})]})})]})}var BrandLogo=__webpack_require__(3897);const SERVICE_DOMAIN={gsheet:"google.com",excel:"microsoft.com"};const SERVICE_LABEL={gsheet:"Google Sheets",excel:"Excel"};function ServiceLogo({service,size=18}){const domain=SERVICE_DOMAIN[service];const label=SERVICE_LABEL[service]??service;if(!domain)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",variant:"light",color:"gray",title:service,children:service.slice(0,2).toUpperCase()});return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.O,{domain:domain,alt:label,size:size}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:label})]})}const STATE_COLORS={pending:"gray",running:"blue",stuck:"orange",errored:"red",done:"green"};const STATE_LABELS={pending:"En attente",running:"En cours",stuck:"Bloqu\xe9e",errored:"En erreur",done:"Termin\xe9e"};function fmt(d){return d?new Date(d).toLocaleString("fr-FR"):"—"}function GsheetRowActions({item}){const openLogs=(0,jobLogsContext.j)();return/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:item.id,currentOwner:item.owner,service:item.service,spreadsheet:item.spreadsheet,worksheet:item.worksheet,githubJob:item.github_job,traceId:item.trace_id,onShowLogs:openLogs})}async function runBulk(ids,fn){const results=await Promise.allSettled(ids.map(fn));const ok=results.filter(r=>"fulfilled"===r.status).length;return{ok,failed:results.length-ok}}function useGsheetConfig(){const unstick=useUnstickTask();const discard=useDiscardTask();const setOwner=useSetTaskOwner();const deleteLock=useDeleteRedisLock();return(0,index_js_.useMemo)(()=>({title:"Worksheets : \xe9tat des lieux des copies sur tableurs",source:{useStock:({period})=>(0,gsheetStockQuery.U)({period:period??void 0}),useTasks:({service,owner,state,period},pagination)=>useGsheetTasks({service:service??void 0,owner:owner??void 0,state,period:period??void 0,skip:pagination.skip,take:pagination.take})},initialFilters:{service:null,owner:null,state:"pending",period:"today",search:""},kpis:[{key:"pending",label:"En attente",value:s=>s?.pending??0,filter:{state:"pending"}},{key:"running",label:"En cours",value:s=>s?.running??0,filter:{state:"running"}},{key:"stuck",label:"Bloqu\xe9es",value:s=>s?.stuck??0,tone:s=>(s?.stuck??0)>0?"warn":"neutral",filter:{state:"stuck"}},{key:"errored",label:"En erreur",value:s=>s?.errored??0,tone:s=>(s?.errored??0)>0?"bad":"neutral",filter:{state:"errored"}},{key:"done_today",label:"Termin\xe9es",value:s=>s?.done_today??0,filter:{state:"done"}},{key:"oldest",label:"Plus ancienne en attente",value:s=>s?.oldest?`${s.oldest.ageHours}h`:"—"}],filters:[{kind:"select",key:"service",label:"Service",options:()=>["all","gsheet","excel"],width:240},{kind:"select",key:"owner",label:"Propri\xe9taire",options:s=>["all",...(s?.byOwner??[]).map(e=>e.key)],width:240},{kind:"select",key:"state",label:"\xc9tat",options:()=>["pending","running","stuck","errored","done","all"],clearable:false,width:140},{kind:"select",key:"period",label:"P\xe9riode",options:()=>["today","7d","30d","all"],clearable:false,width:130},{kind:"search",key:"search",label:"Recherche",placeholder:"id, owner, spreadsheet…",width:240}],columns:[{key:"service",label:"Service",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(ServiceLogo,{service:t.service})},{key:"spreadsheet",label:"ID tableur",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:t.spreadsheet})},{key:"worksheet",label:"Onglet",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:t.worksheet??"—"})},{key:"company_display_name",label:"Entreprise",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.company_display_name??"—"})},{key:"trigger_source",label:"Type",render:t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ThemeIcon,{variant:"transparent",color:"gray",size:"sm",children:"manual"===t.trigger_source?/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconUser,{size:16,stroke:1.5}):/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconRobot,{size:16,stroke:1.5})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"manual"===t.trigger_source?t.owner??"Manuel":"Planifi\xe9"})]})},{key:"state",label:"\xc9tat",render:t=>{const badge=/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[t.state],children:STATE_LABELS[t.state]});return t.error?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:t.error,multiline:true,maw:420,withArrow:true,children:badge}):badge}},{key:"created",label:"Cr\xe9\xe9e",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.created)})},{key:"started",label:"D\xe9marr\xe9e",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.started)})},{key:"finished_at",label:"Termin\xe9e",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.finished_at)})}],rowActions:[{key:"actions",render:item=>/*#__PURE__*/(0,jsx_runtime.jsx)(GsheetRowActions,{item:item})}],bulkActions:[{key:"unstick",label:"D\xe9bloquer",run:ids=>runBulk(ids,id=>unstick.mutateAsync(id))},{key:"set-owner",label:"Changer le propri\xe9taire…",prompt:{label:"E-mail du propri\xe9taire",placeholder:"bob@airporting.com"},run:(ids,owner)=>{if(!owner)return Promise.resolve({ok:0,failed:ids.length});return runBulk(ids,id=>setOwner.mutateAsync({id,owner}))}},{key:"delete-lock",label:"Supprimer le verrou Redis",color:"orange",confirm:{title:"Supprimer le verrou Redis pour {count} t\xe2che(s)",body:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"fm-task-node-<id>",disabled:true,children:/*#__PURE__*/(0,jsx_runtime.jsxs)("span",{children:["Suppression du verrou Redis pour ","{count}"," t\xe2che(s)."]})})},run:ids=>runBulk(ids,id=>deleteLock.mutateAsync(id))},{key:"discard",label:"Abandonner",color:"red",confirm:{title:"Abandonner {count} t\xe2che(s)",body:"Les t\xe2ches seront marqu\xe9es comme termin\xe9es/abandonn\xe9es."},run:ids=>runBulk(ids,id=>discard.mutateAsync(id))}],getRowId:t=>t.id,searchMatches:(t,q)=>String(t.id).includes(q)||(t.owner??"").toLowerCase().includes(q)||(t.spreadsheet??"").toLowerCase().includes(q)||(t.worksheet??"").toLowerCase().includes(q)||(t.service??"").toLowerCase().includes(q)||(t.company_display_name??"").toLowerCase().includes(q)}),[unstick,discard,setOwner,deleteLock])}function SpreadsheetApp(){const config=useGsheetConfig();return/*#__PURE__*/(0,jsx_runtime.jsx)(QueueDashboard.r,{config:config})}function Spreadsheet(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(SpreadsheetApp,{})})})}}}]);
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["509"],{466:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{U:()=>useGsheetStock});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useGsheetStock(filters={}){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();const query={...filters.period&&{period:filters.period}};return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","gsheet","stock",filters],queryFn:async()=>(await api.gsheet.getStockV1({query})).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}},3897:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{O:()=>BrandLogo});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(243);function BrandLogo({domain,alt,size=24}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Image,{src:(0,_src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__.j)(domain),alt:alt,title:alt,w:size,h:size,fit:"contain",radius:"sm",style:{aspectRatio:1}})}},243:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{j:()=>logoDevUrl});const LOGO_DEV_TOKEN="pk_BVN4OQv0Qs-bnqjdIgTppg";function logoDevUrl(domain){return`https://img.logo.dev/${domain}?token=${LOGO_DEV_TOKEN}`}},5080:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Spreadsheet});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var QueueDashboard=__webpack_require__(5351);var index_mjs_=__webpack_require__(207);var tabler_icons_react_mjs_=__webpack_require__(9632);var gsheetStockQuery=__webpack_require__(466);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useGsheetTasks(filters){const api=(0,useApi.h)();const service=filters.service?.toLowerCase()==="all"?void 0:filters.service;const owner=filters.owner?.toLowerCase()==="all"?void 0:filters.owner;const query={...service&&{service},...owner&&{owner},...filters.state&&{state:filters.state},...filters.period&&{period:filters.period},...void 0!==filters.take&&{take:String(filters.take)},...void 0!==filters.skip&&{skip:String(filters.skip)}};return(0,modern_index_js_.useQuery)({queryKey:["tech","gsheet","tasks",filters],queryFn:async()=>(await api.gsheet.listTasksV1(query)).data,refetchOnWindowFocus:false})}function useInvalidate(){const queryClient=(0,modern_index_js_.useQueryClient)();return()=>queryClient.invalidateQueries({queryKey:["tech","gsheet"]})}function useUnstickTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.gsheet.unstickV1({id:String(id)})).data,onSuccess:invalidate})}function useDiscardTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.gsheet.discardV1({id:String(id)})).data,onSuccess:invalidate})}function useSetTaskOwner(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async({id,owner})=>(await api.gsheet.setOwnerV1({id:String(id)},{owner})).data,onSuccess:invalidate})}function useDeleteRedisLock(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.gsheet.deleteRedisLockV1({id:String(id)})).data,onSuccess:invalidate})}var jobLogsContext=__webpack_require__(4302);var esm_index_mjs_=__webpack_require__(1455);function grafanaUrl(traceId){return`https://airporting.grafana.net/d/beegyy3vsp8n4c/recipes?var-trace=${encodeURIComponent(traceId)}&orgId=1&from=now-7d&to=now&timezone=browser&showCategory=Logs&refresh=7d`}function notify(title,message,color){esm_index_mjs_.notifications.show({title,message,color})}function RowActions({taskId,currentOwner,service,spreadsheet,worksheet,githubJob,traceId,onShowLogs}){const[confirm,setConfirm]=(0,index_js_.useState)(null);const[ownerModalOpen,setOwnerModalOpen]=(0,index_js_.useState)(false);const[ownerInput,setOwnerInput]=(0,index_js_.useState)(currentOwner??"");const unstick=useUnstickTask();const discard=useDiscardTask();const setOwner=useSetTaskOwner();const deleteLock=useDeleteRedisLock();const runUnstick=()=>unstick.mutate(taskId,{onSuccess:()=>notify("Unstuck",`Task #${taskId} reset`,"green"),onError:e=>notify("Failed",e?.message??"Unstick failed","red")});const runDiscard=()=>{setConfirm(null);discard.mutate(taskId,{onSuccess:()=>notify("Discarded",`Task #${taskId} marked done`,"green"),onError:e=>notify("Failed",e?.message??"Discard failed","red")})};const runSetOwner=()=>{setOwnerModalOpen(false);setOwner.mutate({id:taskId,owner:ownerInput},{onSuccess:()=>notify("Owner updated",`Task #${taskId} \u{2192} ${ownerInput}`,"green"),onError:e=>notify("Failed",e?.message??"Set owner failed","red")})};const runDeleteLock=()=>{setConfirm(null);deleteLock.mutate(taskId,{onSuccess:data=>notify("Redis lock",data.existed?`Deleted ${data.key}`:`No lock found (${data.key})`,"green"),onError:e=>notify("Failed",e?.message??"Redis delete failed","red")})};const getWorksheetUrl=()=>{if(!spreadsheet)return null;return"excel"===service?`https://airporting.sharepoint.com/:x:/g/personal/airporting_com/ER${spreadsheet}`:`https://docs.google.com/spreadsheets/d/${spreadsheet}/edit`};const worksheetUrl=getWorksheetUrl();return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[worksheetUrl&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"Ouvrir le tableur",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{component:"a",href:worksheetUrl,target:"_blank",rel:"noopener noreferrer",variant:"subtle","aria-label":"Ouvrir le tableur",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconFileSpreadsheet,{size:16})})}),githubJob&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"GitHub Actions logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",onClick:()=>onShowLogs(githubJob),"aria-label":"GitHub Actions logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTerminal,{size:16})})}),traceId&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"Grafana Loki logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{component:"a",href:grafanaUrl(traceId),target:"_blank",rel:"noopener noreferrer",variant:"subtle","aria-label":"Grafana Loki logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconFileText,{size:16})})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu,{position:"bottom-end",withArrow:true,shadow:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Target,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default","aria-label":"Actions",children:"⋮"})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu.Dropdown,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:runUnstick,children:"Unstick"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>{setOwnerInput(currentOwner??"");setOwnerModalOpen(true)},children:"Set owner…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>setConfirm("redis"),children:"Delete Redis lock"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{color:"red",onClick:()=>setConfirm("discard"),children:"Discard"})]})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"discard"===confirm,onClose:()=>setConfirm(null),title:"Discard task",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Mark task #",taskId," (",spreadsheet,worksheet?`:${worksheet}`:"",") as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"done"})," with step=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". The task will not be processed by the runner."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",onClick:runDiscard,loading:discard.isPending,children:"Discard"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"redis"===confirm,onClose:()=>setConfirm(null),title:"Delete Redis lock",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Delete the Redis running-lock for ",spreadsheet,worksheet?`:${worksheet}`:"",". The runner will be able to pick up the worksheet again on the next iteration."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"orange",onClick:runDeleteLock,loading:deleteLock.isPending,children:"Delete lock"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:ownerModalOpen,onClose:()=>setOwnerModalOpen(false),title:`Set owner for task #${taskId}`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Owner email",value:ownerInput,onChange:e=>setOwnerInput(e.currentTarget.value),placeholder:"bob@airporting.com"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setOwnerModalOpen(false),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:runSetOwner,loading:setOwner.isPending,disabled:!ownerInput.trim(),children:"Save"})]})]})})]})}var BrandLogo=__webpack_require__(3897);const SERVICE_DOMAIN={gsheet:"google.com",excel:"microsoft.com"};const SERVICE_LABEL={gsheet:"Google Sheets",excel:"Excel"};function ServiceLogo({service,size=18}){const domain=SERVICE_DOMAIN[service];const label=SERVICE_LABEL[service]??service;if(!domain)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",variant:"light",color:"gray",title:service,children:service.slice(0,2).toUpperCase()});return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.O,{domain:domain,alt:label,size:size}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:label})]})}const STATE_COLORS={pending:"gray",running:"blue",stuck:"orange",errored:"red",done:"green"};const STATE_LABELS={pending:"En attente",running:"En cours",stuck:"Bloqu\xe9e",errored:"En erreur",done:"Termin\xe9e"};function fmt(d){return d?new Date(d).toLocaleString("fr-FR"):"—"}function GsheetRowActions({item}){const openLogs=(0,jobLogsContext.j)();return/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:item.id,currentOwner:item.owner,service:item.service,spreadsheet:item.spreadsheet,worksheet:item.worksheet,githubJob:item.github_job,traceId:item.trace_id,onShowLogs:openLogs})}async function runBulk(ids,fn){const results=await Promise.allSettled(ids.map(fn));const ok=results.filter(r=>"fulfilled"===r.status).length;return{ok,failed:results.length-ok}}function useGsheetConfig(){const unstick=useUnstickTask();const discard=useDiscardTask();const setOwner=useSetTaskOwner();const deleteLock=useDeleteRedisLock();return(0,index_js_.useMemo)(()=>({title:"Worksheets : \xe9tat des lieux des copies sur tableurs",source:{useStock:({period})=>(0,gsheetStockQuery.U)({period:period??void 0}),useTasks:({service,owner,state,period},pagination)=>useGsheetTasks({service:service??void 0,owner:owner??void 0,state,period:period??void 0,skip:pagination.skip,take:pagination.take})},initialFilters:{service:null,owner:null,state:"pending",period:"today",search:""},kpis:[{key:"pending",label:"En attente",value:s=>s?.pending??0,filter:{state:"pending"}},{key:"running",label:"En cours",value:s=>s?.running??0,filter:{state:"running"}},{key:"stuck",label:"Bloqu\xe9es",value:s=>s?.stuck??0,tone:s=>(s?.stuck??0)>0?"warn":"neutral",filter:{state:"stuck"}},{key:"errored",label:"En erreur",value:s=>s?.errored??0,tone:s=>(s?.errored??0)>0?"bad":"neutral",filter:{state:"errored"}},{key:"done_today",label:"Termin\xe9es",value:s=>s?.done_today??0,filter:{state:"done"}},{key:"oldest",label:"Plus ancienne en attente",value:s=>s?.oldest?`${s.oldest.ageHours}h`:"—"}],filters:[{kind:"select",key:"service",label:"Service",options:()=>["all","gsheet","excel"],width:240},{kind:"select",key:"owner",label:"Propri\xe9taire",options:s=>["all",...(s?.byOwner??[]).map(e=>e.key)],width:240},{kind:"select",key:"state",label:"\xc9tat",options:()=>["pending","running","stuck","errored","done","all"],clearable:false,width:140},{kind:"select",key:"period",label:"P\xe9riode",options:()=>[{value:"today",label:"Aujourd'hui"},{value:"7d",label:"7 jours"},{value:"30d",label:"30 jours"},{value:"all",label:"Tout"}],clearable:false,width:130},{kind:"search",key:"search",label:"Recherche",placeholder:"id, owner, spreadsheet…",width:240}],columns:[{key:"service",label:"Service",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(ServiceLogo,{service:t.service})},{key:"spreadsheet",label:"ID tableur",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:t.spreadsheet})},{key:"worksheet",label:"Onglet",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:t.worksheet??"—"})},{key:"company_display_name",label:"Entreprise",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.company_display_name??"—"})},{key:"trigger_source",label:"Type",render:t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ThemeIcon,{variant:"transparent",color:"gray",size:"sm",children:"manual"===t.trigger_source?/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconUser,{size:16,stroke:1.5}):/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconRobot,{size:16,stroke:1.5})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"manual"===t.trigger_source?t.owner??"Manuel":"Planifi\xe9"})]})},{key:"state",label:"\xc9tat",render:t=>{const badge=/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[t.state],children:STATE_LABELS[t.state]});return t.error?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:t.error,multiline:true,maw:420,withArrow:true,children:badge}):badge}},{key:"created",label:"Cr\xe9\xe9e",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.created)})},{key:"started",label:"D\xe9marr\xe9e",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.started)})},{key:"finished_at",label:"Termin\xe9e",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.finished_at)})}],rowActions:[{key:"actions",render:item=>/*#__PURE__*/(0,jsx_runtime.jsx)(GsheetRowActions,{item:item})}],bulkActions:[{key:"unstick",label:"D\xe9bloquer",run:ids=>runBulk(ids,id=>unstick.mutateAsync(id))},{key:"set-owner",label:"Changer le propri\xe9taire…",prompt:{label:"E-mail du propri\xe9taire",placeholder:"bob@airporting.com"},run:(ids,owner)=>{if(!owner)return Promise.resolve({ok:0,failed:ids.length});return runBulk(ids,id=>setOwner.mutateAsync({id,owner}))}},{key:"delete-lock",label:"Supprimer le verrou Redis",color:"orange",confirm:{title:"Supprimer le verrou Redis pour {count} t\xe2che(s)",body:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"fm-task-node-<id>",disabled:true,children:/*#__PURE__*/(0,jsx_runtime.jsxs)("span",{children:["Suppression du verrou Redis pour ","{count}"," t\xe2che(s)."]})})},run:ids=>runBulk(ids,id=>deleteLock.mutateAsync(id))},{key:"discard",label:"Abandonner",color:"red",confirm:{title:"Abandonner {count} t\xe2che(s)",body:"Les t\xe2ches seront marqu\xe9es comme termin\xe9es/abandonn\xe9es."},run:ids=>runBulk(ids,id=>discard.mutateAsync(id))}],getRowId:t=>t.id,searchMatches:(t,q)=>String(t.id).includes(q)||(t.owner??"").toLowerCase().includes(q)||(t.spreadsheet??"").toLowerCase().includes(q)||(t.worksheet??"").toLowerCase().includes(q)||(t.service??"").toLowerCase().includes(q)||(t.company_display_name??"").toLowerCase().includes(q)}),[unstick,discard,setOwner,deleteLock])}function SpreadsheetApp(){const config=useGsheetConfig();return/*#__PURE__*/(0,jsx_runtime.jsx)(QueueDashboard.r,{config:config})}function Spreadsheet(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(SpreadsheetApp,{})})})}}}]);