@airporting/tech-app 0.0.40 → 0.0.41

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"],{1226: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 index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useFinanceJobsStock(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","finance-jobs","stock"],queryFn:async()=>(await api.financeJobs.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}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},...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})}var JobLogsDrawer=__webpack_require__(620);function Tile({label,value,color}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{padding:"md",radius:"md",withBorder:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:label}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,c:color,children:value})]})}function KpiCards({stock,isLoading,isError}){if(isLoading)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:6,children:[0,1,2,3,4,5].map(i=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:88},i))});if(isError||!stock)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"red",children:"Failed to load stock"})});return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:6,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Pending",value:stock.pending}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Running",value:stock.running,color:"blue"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Stuck",value:stock.stuck,color:"orange"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Errored",value:stock.errored,color:"red"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Done today",value:stock.done_today,color:"green"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Oldest pending",value:stock.oldest?`${stock.oldest.ageHours}h`:"—"})]})}var esm_index_mjs_=__webpack_require__(7183);function Panel({title,data,limit=12}){const sliced=data.slice(0,limit);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{padding:"md",radius:"md",withBorder:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mb:"sm",children:title}),0===sliced.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No data"}):/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.BarChart,{h:220,data:sliced.map(d=>({name:d.key,count:d.count})),dataKey:"name",series:[{name:"count",color:"teal.6"}],withTooltip:true})]})}function Breakdowns({byJobName,byOwner,byCompany}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:3,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By job",data:byJobName??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By owner",data:byOwner??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By company",data:byCompany??[]})]})}const STATES=["pending","running","stuck","errored","done","all"];const BETA_OPTIONS=[{value:"false",label:"Prod"},{value:"true",label:"Beta"},{value:"all",label:"All"}];function TasksFilters({jobName,owner,company,state,beta,jobNames,owners,companies,onJobName,onOwner,onCompany,onState,onBeta,onRefresh}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Job",placeholder:"All",data:jobNames,value:jobName,onChange:onJobName,searchable:true,clearable:true,w:240}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Owner",placeholder:"All",data:owners,value:owner,onChange:onOwner,searchable:true,clearable:true,w:240}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Company",placeholder:"All",data:companies,value:company,onChange:onCompany,searchable:true,clearable:true,w:220}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"State",data:STATES.map(s=>({value:s,label:s})),value:state,onChange:v=>onState(v??"pending"),w:140}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Beta",data:BETA_OPTIONS,value:beta,onChange:v=>onBeta(v??"false"),w:120}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default",onClick:onRefresh,"aria-label":"Refresh",mt:22,children:"↻"})]})}const STATE_COLORS={pending:"gray",running:"blue",stuck:"orange",errored:"red",done:"green"};const STATE_LABELS={pending:"Pending",running:"Running",stuck:"Stuck",errored:"Errored",done:"Done"};var tabler_icons_react_mjs_=__webpack_require__(9632);var notifications_esm_index_mjs_=__webpack_require__(1455);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})}function notify(title,message,color){notifications_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 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);const rem=s%60;return`${m}m${rem}s`}function TasksTable({items,total,isLoading,onShowLogs,selectedIds,onToggleId,onToggleAll}){if(isLoading)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:300});if(!items||0===items.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No tasks for current filters."});const visibleIds=items.map(i=>i.id);const allSelected=visibleIds.every(id=>selectedIds.has(id));const someSelected=!allSelected&&visibleIds.some(id=>selectedIds.has(id));return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.ScrollArea,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",c:"dimmed",mb:"xs",children:[total," task(s)"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{miw:1300,verticalSpacing:"xs",highlightOnHover:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:40,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{checked:allSelected,indeterminate:someSelected,onChange:e=>onToggleAll(visibleIds,e.currentTarget.checked),"aria-label":"Select all"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"#"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Job"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Company"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Owner"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"State"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Created"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Started"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Duration"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Result / Error"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Actions"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:items.map(t=>{const companyLabel=t.company_display_name??t.company_slug??`#${t.company_id}`;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{bg:selectedIds.has(t.id)?"var(--mantine-color-dark-6)":void 0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{checked:selectedIds.has(t.id),onChange:()=>onToggleId(t.id),"aria-label":`Select task ${t.id}`})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:t.id}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__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"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:companyLabel})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.owner})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[t.state],children:STATE_LABELS[t.state]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmt(t.created)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmt(t.startedAt)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmtDuration(t.runDuration)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{style:{maxWidth:320},children: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"},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??""]}):"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:t.id,jobName:t.job_name,companyLabel:companyLabel,currentOwner:t.owner,githubJob:t.github_job,onShowLogs:onShowLogs})})]},t.id)})})]})]})}function BulkActionBar_notify(title,message,color){notifications_esm_index_mjs_.notifications.show({title,message,color})}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 BulkActionBar({selectedIds,onClear}){const count=selectedIds.length;const[confirm,setConfirm]=(0,index_js_.useState)(null);const[ownerOpen,setOwnerOpen]=(0,index_js_.useState)(false);const[ownerInput,setOwnerInput]=(0,index_js_.useState)("");const[pending,setPending]=(0,index_js_.useState)(false);const unstick=useUnstickFinanceTask();const retry=useRetryFinanceTask();const discard=useDiscardFinanceTask();const setOwner=useSetFinanceTaskOwner();const deleteLock=useDeleteFinanceRedisLock();const finalize=(label,res)=>{setPending(false);onClear();BulkActionBar_notify(label,`${res.ok} succeeded${res.failed?`, ${res.failed} failed`:""}`,res.failed?"red":"green")};const runUnstick=async()=>{setPending(true);const res=await runBulk(selectedIds,id=>unstick.mutateAsync(id));finalize("Bulk unstick",res)};const runRetry=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>retry.mutateAsync(id));finalize("Bulk retry",res)};const runDiscard=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>discard.mutateAsync(id));finalize("Bulk discard",res)};const runDeleteLock=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>deleteLock.mutateAsync(id));finalize("Bulk Redis lock delete",res)};const runSetOwner=async()=>{setOwnerOpen(false);const owner=ownerInput.trim();if(!owner)return;setPending(true);const res=await runBulk(selectedIds,id=>setOwner.mutateAsync({id,owner}));finalize(`Bulk set owner \u{2192} ${owner}`,res)};if(0===count)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{p:"sm",radius:"md",withBorder:true,style:{position:"sticky",bottom:16,zIndex:5,backgroundColor:"var(--mantine-color-dark-7)"},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",fw:600,children:[count," selected"]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"subtle",onClick:onClear,children:"Clear"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:runUnstick,children:"Unstick"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:()=>setConfirm("retry"),children:"Retry"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:()=>{setOwnerInput("");setOwnerOpen(true)},children:"Set owner…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",color:"orange",loading:pending,onClick:()=>setConfirm("redis"),children:"Delete Redis lock"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",color:"red",loading:pending,onClick:()=>setConfirm("discard"),children:"Discard"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"retry"===confirm,onClose:()=>setConfirm(null),title:`Retry ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Reset ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," task(s) so the runner picks them up again."]}),/*#__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.jsxs)(index_mjs_.Button,{onClick:runRetry,children:["Retry ",count]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"discard"===confirm,onClose:()=>setConfirm(null),title:`Discard ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Mark ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," task(s) as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"finished"})," with error=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". They will not be processed."]}),/*#__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.jsxs)(index_mjs_.Button,{color:"red",onClick:runDiscard,children:["Discard ",count]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"redis"===confirm,onClose:()=>setConfirm(null),title:`Delete Redis lock for ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Delete ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"fm-task-node-<id>"})," for ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," ","task(s)."]}),/*#__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.jsxs)(index_mjs_.Button,{color:"orange",onClick:runDeleteLock,children:["Delete ",count," lock(s)"]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:ownerOpen,onClose:()=>setOwnerOpen(false),title:`Set owner for ${count} task(s)`,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:()=>setOwnerOpen(false),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Button,{onClick:runSetOwner,disabled:!ownerInput.trim(),children:["Apply to ",count]})]})]})})]})}function FinanceJobsApp(){const stock=useFinanceJobsStock();const[jobName,setJobName]=(0,index_js_.useState)(null);const[owner,setOwner]=(0,index_js_.useState)(null);const[company,setCompany]=(0,index_js_.useState)(null);const[state,setState]=(0,index_js_.useState)("pending");const[beta,setBeta]=(0,index_js_.useState)("false");const tasks=useFinanceJobsTasks({job_name:jobName??void 0,owner:owner??void 0,company_slug:company??void 0,state,beta,take:50});const[openJob,setOpenJob]=(0,index_js_.useState)(null);const[selectedIds,setSelectedIds]=(0,index_js_.useState)(new Set);const toggleId=(0,index_js_.useCallback)(id=>{setSelectedIds(prev=>{const next=new Set(prev);if(next.has(id))next.delete(id);else next.add(id);return next})},[]);const toggleAll=(0,index_js_.useCallback)((ids,select)=>{setSelectedIds(prev=>{const next=new Set(prev);for(const id of ids)if(select)next.add(id);else next.delete(id);return next})},[]);const clearSelection=(0,index_js_.useCallback)(()=>setSelectedIds(new Set),[]);const jobNames=(0,index_js_.useMemo)(()=>(stock.data?.byJobName??[]).map(e=>e.key),[stock.data]);const owners=(0,index_js_.useMemo)(()=>(stock.data?.byOwner??[]).map(e=>e.key),[stock.data]);const companies=(0,index_js_.useMemo)(()=>(stock.data?.byCompany??[]).map(e=>e.key),[stock.data]);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Container,{fluid:true,my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,children:"Finance Jobs Tasks"}),stock.dataUpdatedAt&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{c:"dimmed",size:"xs",children:["Updated"," ",new Date(stock.dataUpdatedAt).toLocaleTimeString("fr-FR")]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",size:"sm",loading:stock.isFetching||tasks.isFetching,onClick:()=>{stock.refetch();tasks.refetch()},children:"↻ Refresh"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(KpiCards,{stock:stock.data,isLoading:stock.isLoading,isError:stock.isError}),/*#__PURE__*/(0,jsx_runtime.jsx)(Breakdowns,{byJobName:stock.data?.byJobName,byOwner:stock.data?.byOwner,byCompany:stock.data?.byCompany}),/*#__PURE__*/(0,jsx_runtime.jsx)(TasksFilters,{jobName:jobName,owner:owner,company:company,state:state,beta:beta,jobNames:jobNames,owners:owners,companies:companies,onJobName:setJobName,onOwner:setOwner,onCompany:setCompany,onState:setState,onBeta:setBeta,onRefresh:()=>tasks.refetch()}),/*#__PURE__*/(0,jsx_runtime.jsx)(TasksTable,{items:tasks.data?.items,total:tasks.data?.total??0,isLoading:tasks.isLoading,onShowLogs:setOpenJob,selectedIds:selectedIds,onToggleId:toggleId,onToggleAll:toggleAll}),/*#__PURE__*/(0,jsx_runtime.jsx)(BulkActionBar,{selectedIds:[...selectedIds],onClear:clearSelection}),/*#__PURE__*/(0,jsx_runtime.jsx)(JobLogsDrawer.o,{githubJob:openJob,opened:!!openJob,onClose:()=>setOpenJob(null)})]})})}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"],{620:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{o:()=>JobLogsDrawer});var jsx_runtime=__webpack_require__(5893);var index_mjs_=__webpack_require__(207);var index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useJobLogs(githubJob){const api=(0,useApi.h)();return(0,index_js_.useQuery)({queryKey:["tech","github","job-logs",githubJob],queryFn:async()=>(await api.github.getJobLogsV1({githubJob:githubJob})).data,enabled:!!githubJob,refetchOnWindowFocus:false,retry:false})}function fallbackUrl(githubJob){const parts=githubJob.split("/");if(parts.length<3)return null;const runId=parts[parts.length-1];const repo=parts[parts.length-2];const owner=parts.slice(0,-2).join("/");return`https://github.com/${owner}/${repo}/actions/runs/${runId}`}function JobLogsDrawer({githubJob,opened,onClose}){const query=useJobLogs(opened?githubJob:null);const ghLink=githubJob?fallbackUrl(githubJob):null;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Drawer,{opened:opened,onClose:onClose,position:"right",size:"60%",title:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,children:"Workflow logs"}),query.data?.conclusion&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"success"===query.data.conclusion?"green":"red",children:query.data.conclusion})]}),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[ghLink&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{component:"a",href:ghLink,target:"_blank",variant:"default",size:"xs",children:"Open in GitHub"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",onClick:()=>query.refetch(),children:"Refresh logs"})]}),query.isLoading&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:400}),query.isError&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Alert,{color:"red",title:"Failed to load logs",children:query.error?.message??"Unknown error"}),query.data?.jobs.map((j,i)=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,children:j.name}),j.conclusion&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"success"===j.conclusion?"green":"red",children:j.conclusion})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Code,{block:true,style:{maxHeight:400,overflow:"auto",whiteSpace:"pre"},children:j.logs||"(empty)"})]},i)),query.data&&0===query.data.jobs.length&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No jobs found."})]})})}},1226: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 index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useFinanceJobsStock(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","finance-jobs","stock"],queryFn:async()=>(await api.financeJobs.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}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},...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})}var JobLogsDrawer=__webpack_require__(620);function Tile({label,value,color}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{padding:"md",radius:"md",withBorder:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:label}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,c:color,children:value})]})}function KpiCards({stock,isLoading,isError}){if(isLoading)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:6,children:[0,1,2,3,4,5].map(i=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:88},i))});if(isError||!stock)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"red",children:"Failed to load stock"})});return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:6,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Pending",value:stock.pending}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Running",value:stock.running,color:"blue"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Stuck",value:stock.stuck,color:"orange"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Errored",value:stock.errored,color:"red"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Done today",value:stock.done_today,color:"green"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Oldest pending",value:stock.oldest?`${stock.oldest.ageHours}h`:"—"})]})}var esm_index_mjs_=__webpack_require__(7183);function Panel({title,data,limit=12}){const sliced=data.slice(0,limit);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{padding:"md",radius:"md",withBorder:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mb:"sm",children:title}),0===sliced.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No data"}):/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.BarChart,{h:220,data:sliced.map(d=>({name:d.key,count:d.count})),dataKey:"name",series:[{name:"count",color:"teal.6"}],withTooltip:true})]})}function Breakdowns({byJobName,byOwner,byCompany}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:3,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By job",data:byJobName??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By owner",data:byOwner??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By company",data:byCompany??[]})]})}const STATES=["pending","running","stuck","errored","done","all"];const BETA_OPTIONS=[{value:"false",label:"Prod"},{value:"true",label:"Beta"},{value:"all",label:"All"}];function TasksFilters({jobName,owner,company,state,beta,jobNames,owners,companies,onJobName,onOwner,onCompany,onState,onBeta,onRefresh}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Job",placeholder:"All",data:jobNames,value:jobName,onChange:onJobName,searchable:true,clearable:true,w:240}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Owner",placeholder:"All",data:owners,value:owner,onChange:onOwner,searchable:true,clearable:true,w:240}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Company",placeholder:"All",data:companies,value:company,onChange:onCompany,searchable:true,clearable:true,w:220}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"State",data:STATES.map(s=>({value:s,label:s})),value:state,onChange:v=>onState(v??"pending"),w:140}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Beta",data:BETA_OPTIONS,value:beta,onChange:v=>onBeta(v??"false"),w:120}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default",onClick:onRefresh,"aria-label":"Refresh",mt:22,children:"↻"})]})}const STATE_COLORS={pending:"gray",running:"blue",stuck:"orange",errored:"red",done:"green"};const STATE_LABELS={pending:"Pending",running:"Running",stuck:"Stuck",errored:"Errored",done:"Done"};var tabler_icons_react_mjs_=__webpack_require__(9632);var notifications_esm_index_mjs_=__webpack_require__(1455);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})}function notify(title,message,color){notifications_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 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);const rem=s%60;return`${m}m${rem}s`}function TasksTable({items,total,isLoading,onShowLogs,selectedIds,onToggleId,onToggleAll}){if(isLoading)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:300});if(!items||0===items.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No tasks for current filters."});const visibleIds=items.map(i=>i.id);const allSelected=visibleIds.every(id=>selectedIds.has(id));const someSelected=!allSelected&&visibleIds.some(id=>selectedIds.has(id));return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.ScrollArea,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",c:"dimmed",mb:"xs",children:[total," task(s)"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{miw:1300,verticalSpacing:"xs",highlightOnHover:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:40,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{checked:allSelected,indeterminate:someSelected,onChange:e=>onToggleAll(visibleIds,e.currentTarget.checked),"aria-label":"Select all"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"#"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Job"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Company"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Owner"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"State"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Created"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Started"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Duration"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Result / Error"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Actions"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:items.map(t=>{const companyLabel=t.company_display_name??t.company_slug??`#${t.company_id}`;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{bg:selectedIds.has(t.id)?"var(--mantine-color-dark-6)":void 0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{checked:selectedIds.has(t.id),onChange:()=>onToggleId(t.id),"aria-label":`Select task ${t.id}`})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:t.id}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__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"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:companyLabel})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.owner})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[t.state],children:STATE_LABELS[t.state]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmt(t.created)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmt(t.startedAt)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmtDuration(t.runDuration)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{style:{maxWidth:320},children: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"},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??""]}):"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:t.id,jobName:t.job_name,companyLabel:companyLabel,currentOwner:t.owner,githubJob:t.github_job,onShowLogs:onShowLogs})})]},t.id)})})]})]})}function BulkActionBar_notify(title,message,color){notifications_esm_index_mjs_.notifications.show({title,message,color})}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 BulkActionBar({selectedIds,onClear}){const count=selectedIds.length;const[confirm,setConfirm]=(0,index_js_.useState)(null);const[ownerOpen,setOwnerOpen]=(0,index_js_.useState)(false);const[ownerInput,setOwnerInput]=(0,index_js_.useState)("");const[pending,setPending]=(0,index_js_.useState)(false);const unstick=useUnstickFinanceTask();const retry=useRetryFinanceTask();const discard=useDiscardFinanceTask();const setOwner=useSetFinanceTaskOwner();const deleteLock=useDeleteFinanceRedisLock();const finalize=(label,res)=>{setPending(false);onClear();BulkActionBar_notify(label,`${res.ok} succeeded${res.failed?`, ${res.failed} failed`:""}`,res.failed?"red":"green")};const runUnstick=async()=>{setPending(true);const res=await runBulk(selectedIds,id=>unstick.mutateAsync(id));finalize("Bulk unstick",res)};const runRetry=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>retry.mutateAsync(id));finalize("Bulk retry",res)};const runDiscard=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>discard.mutateAsync(id));finalize("Bulk discard",res)};const runDeleteLock=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>deleteLock.mutateAsync(id));finalize("Bulk Redis lock delete",res)};const runSetOwner=async()=>{setOwnerOpen(false);const owner=ownerInput.trim();if(!owner)return;setPending(true);const res=await runBulk(selectedIds,id=>setOwner.mutateAsync({id,owner}));finalize(`Bulk set owner \u{2192} ${owner}`,res)};if(0===count)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{p:"sm",radius:"md",withBorder:true,style:{position:"sticky",bottom:16,zIndex:5,backgroundColor:"var(--mantine-color-dark-7)"},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",fw:600,children:[count," selected"]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"subtle",onClick:onClear,children:"Clear"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:runUnstick,children:"Unstick"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:()=>setConfirm("retry"),children:"Retry"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:()=>{setOwnerInput("");setOwnerOpen(true)},children:"Set owner…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",color:"orange",loading:pending,onClick:()=>setConfirm("redis"),children:"Delete Redis lock"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",color:"red",loading:pending,onClick:()=>setConfirm("discard"),children:"Discard"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"retry"===confirm,onClose:()=>setConfirm(null),title:`Retry ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Reset ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," task(s) so the runner picks them up again."]}),/*#__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.jsxs)(index_mjs_.Button,{onClick:runRetry,children:["Retry ",count]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"discard"===confirm,onClose:()=>setConfirm(null),title:`Discard ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Mark ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," task(s) as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"finished"})," with error=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". They will not be processed."]}),/*#__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.jsxs)(index_mjs_.Button,{color:"red",onClick:runDiscard,children:["Discard ",count]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"redis"===confirm,onClose:()=>setConfirm(null),title:`Delete Redis lock for ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Delete ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"fm-task-node-<id>"})," for ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," ","task(s)."]}),/*#__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.jsxs)(index_mjs_.Button,{color:"orange",onClick:runDeleteLock,children:["Delete ",count," lock(s)"]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:ownerOpen,onClose:()=>setOwnerOpen(false),title:`Set owner for ${count} task(s)`,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:()=>setOwnerOpen(false),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Button,{onClick:runSetOwner,disabled:!ownerInput.trim(),children:["Apply to ",count]})]})]})})]})}function FinanceJobsApp(){const stock=useFinanceJobsStock();const[jobName,setJobName]=(0,index_js_.useState)(null);const[owner,setOwner]=(0,index_js_.useState)(null);const[company,setCompany]=(0,index_js_.useState)(null);const[state,setState]=(0,index_js_.useState)("pending");const[beta,setBeta]=(0,index_js_.useState)("false");const tasks=useFinanceJobsTasks({job_name:jobName??void 0,owner:owner??void 0,company_slug:company??void 0,state,beta,take:50});const[openJob,setOpenJob]=(0,index_js_.useState)(null);const[selectedIds,setSelectedIds]=(0,index_js_.useState)(new Set);const toggleId=(0,index_js_.useCallback)(id=>{setSelectedIds(prev=>{const next=new Set(prev);if(next.has(id))next.delete(id);else next.add(id);return next})},[]);const toggleAll=(0,index_js_.useCallback)((ids,select)=>{setSelectedIds(prev=>{const next=new Set(prev);for(const id of ids)if(select)next.add(id);else next.delete(id);return next})},[]);const clearSelection=(0,index_js_.useCallback)(()=>setSelectedIds(new Set),[]);const jobNames=(0,index_js_.useMemo)(()=>(stock.data?.byJobName??[]).map(e=>e.key),[stock.data]);const owners=(0,index_js_.useMemo)(()=>(stock.data?.byOwner??[]).map(e=>e.key),[stock.data]);const companies=(0,index_js_.useMemo)(()=>(stock.data?.byCompany??[]).map(e=>e.key),[stock.data]);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Container,{fluid:true,my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,children:"Finance Jobs Tasks"}),stock.dataUpdatedAt&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{c:"dimmed",size:"xs",children:["Updated"," ",new Date(stock.dataUpdatedAt).toLocaleTimeString("fr-FR")]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",size:"sm",loading:stock.isFetching||tasks.isFetching,onClick:()=>{stock.refetch();tasks.refetch()},children:"↻ Refresh"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(KpiCards,{stock:stock.data,isLoading:stock.isLoading,isError:stock.isError}),/*#__PURE__*/(0,jsx_runtime.jsx)(Breakdowns,{byJobName:stock.data?.byJobName,byOwner:stock.data?.byOwner,byCompany:stock.data?.byCompany}),/*#__PURE__*/(0,jsx_runtime.jsx)(TasksFilters,{jobName:jobName,owner:owner,company:company,state:state,beta:beta,jobNames:jobNames,owners:owners,companies:companies,onJobName:setJobName,onOwner:setOwner,onCompany:setCompany,onState:setState,onBeta:setBeta,onRefresh:()=>tasks.refetch()}),/*#__PURE__*/(0,jsx_runtime.jsx)(TasksTable,{items:tasks.data?.items,total:tasks.data?.total??0,isLoading:tasks.isLoading,onShowLogs:setOpenJob,selectedIds:selectedIds,onToggleId:toggleId,onToggleAll:toggleAll}),/*#__PURE__*/(0,jsx_runtime.jsx)(BulkActionBar,{selectedIds:[...selectedIds],onClear:clearSelection}),/*#__PURE__*/(0,jsx_runtime.jsx)(JobLogsDrawer.o,{githubJob:openJob,opened:!!openJob,onClose:()=>setOpenJob(null)})]})})}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([["8692"],{9031:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Github});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useGithubQuery(){const api=(0,useApi.h)();const query=(0,modern_index_js_.useQuery)({queryKey:["tech","github"],queryFn:async()=>await api.github.getJobsRunnersV1().then(x=>x.data),refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true});return query}var formatDate=__webpack_require__(2086);var IconGithub=__webpack_require__(5068);var dist_index_js_=__webpack_require__(1380);function GithubApp(){const dashboardResult=useGithubQuery();const dashboard=dashboardResult.data;if(!dashboard)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Container,{my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,my:"md",children:"Chargement..."})});return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fw:"lighter",fz:"sm",my:"md",span:true,c:"dimmed",children:["Derni\xe8re mise \xe0 jour :"," ",(0,formatDate.p)(dashboardResult?.dataUpdatedAt??Date.now())]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,my:"md",children:"Runners par repo"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ScrollArea,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{miw:800,verticalSpacing:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Repository"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Tag"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Self-hosted"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Runners"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:dashboard.list.map((line,i)=>{const{repo,selfhost,runner_tag,runners}=line;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(dist_index_js_.AirButton,{variant:"subtle",color:"gray",href:`https://github.com/airporting/${repo}`,children:[repo,"\xa0",/*#__PURE__*/(0,jsx_runtime.jsx)(IconGithub.U,{size:20})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:runner_tag}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:selfhost?/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.IconCheck,{size:30,color:"green"}):/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.IconCross,{size:30,color:"red"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:runners.map((runnerItem,j)=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"blue",m:5,children:runnerItem},j))})]},i)})})]})})]})}var providers=__webpack_require__(7034);function Github(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)(GithubApp,{})})})}}}]);
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["8692"],{5068:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{U:()=>IconGithub});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);function IconGithub({color="currentColor",size=20,marker,...props}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("svg",{width:size,height:size,viewBox:"0 0 24 24",fill:color,xmlns:"http://www.w3.org/2000/svg",...props,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("path",{d:"M12 0.297C5.373 0.297 0 5.67 0 12.297c0 5.292 3.438 9.787 8.205 11.387.6.111.82-.261.82-.58 0-.287-.011-1.244-.016-2.255-3.338.726-4.042-1.609-4.042-1.609-.546-1.389-1.333-1.759-1.333-1.759-1.089-.745.083-.73.083-.73 1.205.085 1.84 1.236 1.84 1.236 1.07 1.834 2.807 1.304 3.492.997.107-.775.419-1.305.762-1.605-2.665-.304-5.466-1.332-5.466-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.536-1.524.116-3.176 0 0 1.008-.322 3.301 1.23a11.51 11.51 0 0 1 3.004-.404 c1.019.005 2.047.138 3.004.404 2.291-1.552 3.297-1.23 3.297-1.23.655 1.652.243 2.873.119 3.176.77.84 1.235 1.91 1.235 3.221 0 4.61-2.805 5.624-5.476 5.921.43.372.823 1.104.823 2.223 0 1.606-.015 2.896-.015 3.293 0 .321.216.697.825.578C20.565 22.08 24 17.585 24 12.297 24 5.67 18.627.297 12 .297z"})})}},2086:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{p:()=>formatDate});const formatDate=ts=>new Date(ts).toLocaleString("fr-FR",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:false})},9031:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Github});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useGithubQuery(){const api=(0,useApi.h)();const query=(0,modern_index_js_.useQuery)({queryKey:["tech","github"],queryFn:async()=>await api.github.getJobsRunnersV1().then(x=>x.data),refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true});return query}var formatDate=__webpack_require__(2086);var IconGithub=__webpack_require__(5068);var dist_index_js_=__webpack_require__(1380);function GithubApp(){const dashboardResult=useGithubQuery();const dashboard=dashboardResult.data;if(!dashboard)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Container,{my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,my:"md",children:"Chargement..."})});return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fw:"lighter",fz:"sm",my:"md",span:true,c:"dimmed",children:["Derni\xe8re mise \xe0 jour :"," ",(0,formatDate.p)(dashboardResult?.dataUpdatedAt??Date.now())]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,my:"md",children:"Runners par repo"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ScrollArea,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{miw:800,verticalSpacing:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Repository"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Tag"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Self-hosted"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Runners"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:dashboard.list.map((line,i)=>{const{repo,selfhost,runner_tag,runners}=line;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(dist_index_js_.AirButton,{variant:"subtle",color:"gray",href:`https://github.com/airporting/${repo}`,children:[repo,"\xa0",/*#__PURE__*/(0,jsx_runtime.jsx)(IconGithub.U,{size:20})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:runner_tag}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:selfhost?/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.IconCheck,{size:30,color:"green"}):/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.IconCross,{size:30,color:"red"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:runners.map((runnerItem,j)=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"blue",m:5,children:runnerItem},j))})]},i)})})]})})]})}var providers=__webpack_require__(7034);function Github(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)(GithubApp,{})})})}}}]);
@@ -1,10 +1 @@
1
- /*! For license information please see __federation_expose_sobank.js.LICENSE.txt */
2
- "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["1744"],{631:function(__unused_webpack_module,exports){/**
3
- * @license React
4
- * react-jsx-runtime.production.js
5
- *
6
- * Copyright (c) Meta Platforms, Inc. and affiliates.
7
- *
8
- * This source code is licensed under the MIT license found in the
9
- * LICENSE file in the root directory of this source tree.
10
- */var REACT_ELEMENT_TYPE=Symbol.for("react.transitional.element"),REACT_FRAGMENT_TYPE=Symbol.for("react.fragment");function jsxProd(type,config,maybeKey){var key=null;void 0!==maybeKey&&(key=""+maybeKey);void 0!==config.key&&(key=""+config.key);if("key"in config){maybeKey={};for(var propName in config)"key"!==propName&&(maybeKey[propName]=config[propName])}else maybeKey=config;config=maybeKey.ref;return{$$typeof:REACT_ELEMENT_TYPE,type:type,key:key,ref:void 0!==config?config:null,props:maybeKey}}exports.Fragment=REACT_FRAGMENT_TYPE;exports.jsx=jsxProd;exports.jsxs=jsxProd},5893:function(module,__unused_webpack_exports,__webpack_require__){module.exports=__webpack_require__(631)},4148:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{h:()=>useApi});var _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(9056);var _src_hooks_useAppConfig_ts__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(7936);function useApi(){const config=(0,_src_hooks_useAppConfig_ts__WEBPACK_IMPORTED_MODULE_0__.M)();const client=new _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__.eN({baseUrl:config.api.replace(/\/$/,""),baseApiParams:{headers:{Authorization:config.token?`Bearer ${config.token}`:"",From:config.owner}}});return new _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__.eT(client)}},9056:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{eN:()=>HttpClient,eT:()=>TechApi});class HttpClient{baseUrl="";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...fetchParams)=>fetch(...fetchParams);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(apiConfig={}){Object.assign(this,apiConfig)}setSecurityData=data=>{this.securityData=data};encodeQueryParam(key,value){const encodedKey=encodeURIComponent(key);return`${encodedKey}=${encodeURIComponent("number"==typeof value?value:`${value}`)}`}addQueryParam(query,key){return this.encodeQueryParam(key,query[key])}addArrayQueryParam(query,key){const value=query[key];return value.map(v=>this.encodeQueryParam(key,v)).join("&")}toQueryString(rawQuery){const query=rawQuery||{};const keys=Object.keys(query).filter(key=>void 0!==query[key]);return keys.map(key=>Array.isArray(query[key])?this.addArrayQueryParam(query,key):this.addQueryParam(query,key)).join("&")}addQueryParams(rawQuery){const queryString=this.toQueryString(rawQuery);return queryString?`?${queryString}`:""}contentFormatters={["application/json"]:input=>null!==input&&("object"==typeof input||"string"==typeof input)?JSON.stringify(input):input,["application/vnd.api+json"]:input=>null!==input&&("object"==typeof input||"string"==typeof input)?JSON.stringify(input):input,["text/plain"]:input=>null!==input&&"string"!=typeof input?JSON.stringify(input):input,["multipart/form-data"]:input=>{if(input instanceof FormData)return input;return Object.keys(input||{}).reduce((formData,key)=>{const property=input[key];formData.append(key,property instanceof Blob?property:"object"==typeof property&&null!==property?JSON.stringify(property):`${property}`);return formData},new FormData)},["application/x-www-form-urlencoded"]:input=>this.toQueryString(input)};mergeRequestParams(params1,params2){return{...this.baseApiParams,...params1,...params2||{},headers:{...this.baseApiParams.headers||{},...params1.headers||{},...params2&&params2.headers||{}}}}createAbortSignal=cancelToken=>{if(this.abortControllers.has(cancelToken)){const abortController=this.abortControllers.get(cancelToken);if(abortController)return abortController.signal;return}const abortController=new AbortController;this.abortControllers.set(cancelToken,abortController);return abortController.signal};abortRequest=cancelToken=>{const abortController=this.abortControllers.get(cancelToken);if(abortController){abortController.abort();this.abortControllers.delete(cancelToken)}};request=async({body,secure,path,type,query,format,baseUrl,cancelToken,...params})=>{const secureParams=("boolean"==typeof secure?secure:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{};const requestParams=this.mergeRequestParams(params,secureParams);const queryString=query&&this.toQueryString(query);const payloadFormatter=this.contentFormatters[type||"application/json"];const responseFormat=format||requestParams.format;return this.customFetch(`${baseUrl||this.baseUrl||""}${path}${queryString?`?${queryString}`:""}`,{...requestParams,headers:{...requestParams.headers||{},...type&&"multipart/form-data"!==type?{"Content-Type":type}:{}},signal:(cancelToken?this.createAbortSignal(cancelToken):requestParams.signal)||null,body:null==body?null:payloadFormatter(body)}).then(async response=>{const r=response;r.data=null;r.error=null;const responseToParse=responseFormat?response.clone():response;const data=responseFormat?await responseToParse[responseFormat]().then(data=>{if(r.ok)r.data=data;else r.error=data;return r}).catch(e=>{r.error=e;return r}):r;if(cancelToken)this.abortControllers.delete(cancelToken);if(!response.ok)throw data;return data})}}class TechApi{http;constructor(http){this.http=http}status=(params={})=>this.http.request({path:"/status",method:"GET",...params});getDashboard=(params={})=>this.http.request({path:"/dashboard",method:"GET",format:"json",...params});getCompanies=(params={})=>this.http.request({path:"/companies",method:"GET",format:"json",...params});webhook={postSmsWebhook:(query,params={})=>this.http.request({path:"/sms/webhook",method:"POST",query:query,...params})};amex={getTransactionsV1:(query,params={})=>this.http.request({path:"/v1/amex/transactions",method:"GET",query:query,...params})};github={getJobsRunnersV1:(params={})=>this.http.request({path:"/v1/github/jobs/runners",method:"GET",format:"json",...params}),getLabelsV1:({host,...query},params={})=>this.http.request({path:`/v1/github/labels/${host}`,method:"GET",format:"json",...params}),getJobLogsV1:(query,params={})=>this.http.request({path:"/v1/github/job-logs",method:"GET",query:query,format:"json",...params})};gsheet={getStockV1:(params={})=>this.http.request({path:"/v1/gsheet/stock",method:"GET",format:"json",...params}),listTasksV1:(query,params={})=>this.http.request({path:"/v1/gsheet/tasks",method:"GET",query:query,format:"json",...params}),unstickV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/unstick`,method:"POST",format:"json",...params}),discardV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/discard`,method:"POST",format:"json",...params}),setOwnerV1:({id,...query},data,params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/owner`,method:"PUT",body:data,type:"application/json",format:"json",...params}),deleteRedisLockV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/redis-lock`,method:"DELETE",format:"json",...params})};notion={getKikouV1:(params={})=>this.http.request({path:"/v1/notion/kikou",method:"GET",format:"json",...params})};payfit={getChartV1:(query,params={})=>this.http.request({path:"/v1/payfit/chart",method:"GET",query:query,...params})};sobank={getExportsV1:(query,params={})=>this.http.request({path:"/v1/sobank/exports",method:"GET",query:query,format:"json",...params})};synchro={getRunStatsV1:(params={})=>this.http.request({path:"/v1/synchro/run/stats",method:"GET",format:"json",...params}),getTasksV1:(query,params={})=>this.http.request({path:"/v1/synchro/tasks",method:"GET",query:query,format:"json",...params}),getJobsDefaultsV1:(params={})=>this.http.request({path:"/v1/synchro/jobs/defaults",method:"GET",format:"json",...params}),putStopTaskV1:({id,...query},params={})=>this.http.request({path:`/v1/synchro/tasks/stop/${id}`,method:"PUT",...params}),resetOwnerStatsV1:({owner,value,...query},params={})=>this.http.request({path:`/v1/synchro/run/stats/${owner}/${value}`,method:"PUT",...params})}}},7936:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{$:()=>AppConfigProvider,M:()=>useAppConfig});var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(3106);const AppConfigCtx=(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(null);const AppConfigProvider=AppConfigCtx.Provider;function useAppConfig(){const config=(0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(AppConfigCtx);if(!config)throw new Error("Called `useAppConfig` outside a `<AppConfigProvider />`");return config}},7034:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{C:()=>Providers});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _airporting_app_front__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1380);var _mantine_core__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(207);var _mantine_modals__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(4142);var _mantine_notifications__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(1455);var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(6197);var radash__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(9877);var _hooks_useAppConfig__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(7936);const theme=(0,_mantine_core__WEBPACK_IMPORTED_MODULE_2__.createTheme)((0,radash__WEBPACK_IMPORTED_MODULE_6__.assign)(_airporting_app_front__WEBPACK_IMPORTED_MODULE_1__.theme,{components:{}}));const cssVarResolver=x=>(0,radash__WEBPACK_IMPORTED_MODULE_6__.assign)(_airporting_app_front__WEBPACK_IMPORTED_MODULE_1__.cssVarResolver(x),{dark:{},light:{},variables:{}});function Providers(props){const{children,config,mantine,tanstack}=props;return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_hooks_useAppConfig__WEBPACK_IMPORTED_MODULE_7__.$,{value:config,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.QueryClientProvider,{client:tanstack?.queryClient??new _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.QueryClient,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_2__.MantineProvider,{theme:theme,cssVariablesResolver:cssVarResolver,defaultColorScheme:mantine?.defaultColorScheme,forceColorScheme:mantine?.forceColorScheme,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_modals__WEBPACK_IMPORTED_MODULE_3__.ModalsProvider,{children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_notifications__WEBPACK_IMPORTED_MODULE_4__.Notifications,{}),children]})})})})}},316:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Sobank});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var esm_index_mjs_=__webpack_require__(9038);var tabler_icons_react_mjs_=__webpack_require__(9632);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useSobankExports(params){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","sobank","exports",params],queryFn:async()=>await api.sobank.getExportsV1(params).then(x=>x.data),refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true})}var date_fns_index_js_=__webpack_require__(4365);function SobankApp(){const[dateRange,setDateRange]=(0,index_js_.useState)([null,null]);const[bank,setBank]=(0,index_js_.useState)("");const[currency,setCurrency]=(0,index_js_.useState)("");const[iban,setIban]=(0,index_js_.useState)("");const exportsResult=useSobankExports({...dateRange[0]&&{balanceDateAfter:new Date(dateRange[0]).toISOString()},...dateRange[1]&&{balanceDateBefore:new Date(dateRange[1]).toISOString()},...bank&&{bank},...currency&&{currency},...iban&&{iban}});const rows=exportsResult.data?.exports??[];return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,my:"md",children:"Sobank — Exports"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Stack,{gap:"sm",my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{align:"flex-end",wrap:"wrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.DatePickerInput,{leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconCalendar,{size:18}),type:"range",label:"P\xe9riode de solde",placeholder:"S\xe9lectionner une plage",value:dateRange,onChange:setDateRange,clearable:true,allowSingleDateInRange:true,w:260}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Banque",placeholder:"Filtrer par banque",value:bank,onChange:e=>setBank(e.currentTarget.value),w:160}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Devise",placeholder:"EUR, USD...",value:currency,onChange:e=>setCurrency(e.currentTarget.value),w:120}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"IBAN",placeholder:"Filtrer par IBAN",value:iban,onChange:e=>setIban(e.currentTarget.value),w:240})]})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{stickyHeader:true,striped:true,highlightOnHover:true,withTableBorder:true,withColumnBorders:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"ID"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"IBAN"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Banque"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Compte"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Devise"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Solde"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Date solde"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Solde pr\xe9c\xe9dent"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Date pr\xe9c\xe9dente"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Cr\xe9\xe9 le"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:rows.map(row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:row.id}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:row.iban??"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:row.bank}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:row.account}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:row.currency}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:String(row.balance)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:(0,date_fns_index_js_.format)(row.balance_date,"dd/MM/yyyy HH:mm")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:String(row.previous_balance)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:(0,date_fns_index_js_.format)(row.previous_date,"dd/MM/yyyy HH:mm")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:(0,date_fns_index_js_.format)(row.created,"dd/MM/yyyy HH:mm")})]},row.id))})]})]})}function Sobank(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)(SobankApp,{})})})}}}]);
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["1744"],{316:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Sobank});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var esm_index_mjs_=__webpack_require__(9038);var tabler_icons_react_mjs_=__webpack_require__(9632);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useSobankExports(params){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","sobank","exports",params],queryFn:async()=>await api.sobank.getExportsV1(params).then(x=>x.data),refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true})}var date_fns_index_js_=__webpack_require__(4365);function SobankApp(){const[dateRange,setDateRange]=(0,index_js_.useState)([null,null]);const[bank,setBank]=(0,index_js_.useState)("");const[currency,setCurrency]=(0,index_js_.useState)("");const[iban,setIban]=(0,index_js_.useState)("");const exportsResult=useSobankExports({...dateRange[0]&&{balanceDateAfter:new Date(dateRange[0]).toISOString()},...dateRange[1]&&{balanceDateBefore:new Date(dateRange[1]).toISOString()},...bank&&{bank},...currency&&{currency},...iban&&{iban}});const rows=exportsResult.data?.exports??[];return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,my:"md",children:"Sobank — Exports"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Stack,{gap:"sm",my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{align:"flex-end",wrap:"wrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.DatePickerInput,{leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconCalendar,{size:18}),type:"range",label:"P\xe9riode de solde",placeholder:"S\xe9lectionner une plage",value:dateRange,onChange:setDateRange,clearable:true,allowSingleDateInRange:true,w:260}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Banque",placeholder:"Filtrer par banque",value:bank,onChange:e=>setBank(e.currentTarget.value),w:160}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Devise",placeholder:"EUR, USD...",value:currency,onChange:e=>setCurrency(e.currentTarget.value),w:120}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"IBAN",placeholder:"Filtrer par IBAN",value:iban,onChange:e=>setIban(e.currentTarget.value),w:240})]})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{stickyHeader:true,striped:true,highlightOnHover:true,withTableBorder:true,withColumnBorders:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"ID"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"IBAN"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Banque"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Compte"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Devise"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Solde"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Date solde"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Solde pr\xe9c\xe9dent"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Date pr\xe9c\xe9dente"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Cr\xe9\xe9 le"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:rows.map(row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:row.id}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:row.iban??"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:row.bank}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:row.account}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:row.currency}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:String(row.balance)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:(0,date_fns_index_js_.format)(row.balance_date,"dd/MM/yyyy HH:mm")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:String(row.previous_balance)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:(0,date_fns_index_js_.format)(row.previous_date,"dd/MM/yyyy HH:mm")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:(0,date_fns_index_js_.format)(row.created,"dd/MM/yyyy HH:mm")})]},row.id))})]})]})}function Sobank(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)(SobankApp,{})})})}}}]);
@@ -1 +1 @@
1
- "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["509"],{5774: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 index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useGsheetStock(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","gsheet","stock"],queryFn:async()=>(await api.gsheet.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}function useGsheetTasks(filters){const api=(0,useApi.h)();const query={...filters.service&&{service:filters.service},...filters.owner&&{owner:filters.owner},...filters.state&&{state:filters.state},...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 Tile({label,value,color}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{padding:"md",radius:"md",withBorder:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:label}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,c:color,children:value})]})}function KpiCards({stock,isLoading,isError}){if(isLoading)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:5,children:[0,1,2,3,4].map(i=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:88},i))});if(isError||!stock)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"red",children:"Failed to load stock"})});return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:5,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Pending",value:stock.pending}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Running",value:stock.running,color:"blue"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Stuck",value:stock.stuck,color:"orange"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Errored",value:stock.errored,color:"red"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Oldest",value:stock.oldest?`${stock.oldest.ageHours}h`:"—"})]})}var esm_index_mjs_=__webpack_require__(7183);function Panel({title,data}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{padding:"md",radius:"md",withBorder:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mb:"sm",children:title}),0===data.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No data"}):/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.BarChart,{h:220,data:data.map(d=>({name:d.key,count:d.count})),dataKey:"name",series:[{name:"count",color:"teal.6"}],withTooltip:true})]})}function Breakdowns({byService,byOwner}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By service",data:byService??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By owner",data:byOwner??[]})]})}const STATES=["pending","running","stuck","errored","done","all"];function TasksFilters({service,owner,state,services,owners,onService,onOwner,onState,onRefresh}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Service",placeholder:"All",data:services,value:service,onChange:onService,clearable:true,w:180}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Owner",placeholder:"All",data:owners,value:owner,onChange:onOwner,clearable:true,w:260}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"State",data:STATES.map(s=>({value:s,label:s})),value:state,onChange:v=>onState(v??"pending"),w:140}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default",onClick:onRefresh,"aria-label":"Refresh",mt:22,children:"↻"})]})}const STATE_COLORS={pending:"gray",running:"blue",stuck:"orange",errored:"red",done:"green"};const STATE_LABELS={pending:"Pending",running:"Running",stuck:"Stuck",errored:"Errored",done:"Done"};var tabler_icons_react_mjs_=__webpack_require__(9632);var notifications_esm_index_mjs_=__webpack_require__(1455);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})}function notify(title,message,color){notifications_esm_index_mjs_.notifications.show({title,message,color})}function RowActions({taskId,currentOwner,spreadsheet,worksheet,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=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")})};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:()=>{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"})]})]})})]})}function fmt(d){return d?new Date(d).toLocaleString("fr-FR"):"—"}function TasksTable({items,total,isLoading,onShowLogs,selectedIds,onToggleId,onToggleAll}){if(isLoading)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:300});if(!items||0===items.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No tasks for current filters."});const visibleIds=items.map(i=>i.id);const allSelected=visibleIds.every(id=>selectedIds.has(id));const someSelected=!allSelected&&visibleIds.some(id=>selectedIds.has(id));return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.ScrollArea,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",c:"dimmed",mb:"xs",children:[total," task(s)"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{miw:1100,verticalSpacing:"xs",highlightOnHover:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:40,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{checked:allSelected,indeterminate:someSelected,onChange:e=>onToggleAll(visibleIds,e.currentTarget.checked),"aria-label":"Select all"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"#"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Service"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Spreadsheet:Worksheet"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Owner"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"State"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Created"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Started"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Actions"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:items.map(t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{bg:selectedIds.has(t.id)?"var(--mantine-color-dark-6)":void 0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{checked:selectedIds.has(t.id),onChange:()=>onToggleId(t.id),"aria-label":`Select task ${t.id}`})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:t.id}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:t.service}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:[t.spreadsheet,t.worksheet?`:${t.worksheet}`:""]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:t.owner??"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[t.state],children:STATE_LABELS[t.state]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmt(t.created)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmt(t.started)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:t.id,currentOwner:t.owner,spreadsheet:t.spreadsheet,worksheet:t.worksheet,githubJob:t.github_job,onShowLogs:onShowLogs})})]},t.id))})]})]})}var JobLogsDrawer=__webpack_require__(620);function BulkActionBar_notify(title,message,color){notifications_esm_index_mjs_.notifications.show({title,message,color})}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 BulkActionBar({selectedIds,onClear}){const count=selectedIds.length;const[confirm,setConfirm]=(0,index_js_.useState)(null);const[ownerOpen,setOwnerOpen]=(0,index_js_.useState)(false);const[ownerInput,setOwnerInput]=(0,index_js_.useState)("");const[pending,setPending]=(0,index_js_.useState)(false);const unstick=useUnstickTask();const discard=useDiscardTask();const setOwner=useSetTaskOwner();const deleteLock=useDeleteRedisLock();const finalize=(label,res)=>{setPending(false);onClear();BulkActionBar_notify(label,`${res.ok} succeeded${res.failed?`, ${res.failed} failed`:""}`,res.failed?"red":"green")};const runUnstick=async()=>{setPending(true);const res=await runBulk(selectedIds,id=>unstick.mutateAsync(id));finalize("Bulk unstick",res)};const runDiscard=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>discard.mutateAsync(id));finalize("Bulk discard",res)};const runDeleteLock=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>deleteLock.mutateAsync(id));finalize("Bulk Redis lock delete",res)};const runSetOwner=async()=>{setOwnerOpen(false);const owner=ownerInput.trim();if(!owner)return;setPending(true);const res=await runBulk(selectedIds,id=>setOwner.mutateAsync({id,owner}));finalize(`Bulk set owner \u{2192} ${owner}`,res)};if(0===count)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{p:"sm",radius:"md",withBorder:true,style:{position:"sticky",bottom:16,zIndex:5,backgroundColor:"var(--mantine-color-dark-7)"},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",fw:600,children:[count," selected"]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"subtle",onClick:onClear,children:"Clear"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:runUnstick,children:"Unstick"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:()=>{setOwnerInput("");setOwnerOpen(true)},children:"Set owner…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",color:"orange",loading:pending,onClick:()=>setConfirm("redis"),children:"Delete Redis lock"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",color:"red",loading:pending,onClick:()=>setConfirm("discard"),children:"Discard"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"discard"===confirm,onClose:()=>setConfirm(null),title:`Discard ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Mark ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," task(s) as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"done"})," with step=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". They 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.jsxs)(index_mjs_.Button,{color:"red",onClick:runDiscard,children:["Discard ",count]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"redis"===confirm,onClose:()=>setConfirm(null),title:`Delete Redis lock for ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Delete the Redis running-lock for ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," task(s). The runner will be able to pick them 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.jsxs)(index_mjs_.Button,{color:"orange",onClick:runDeleteLock,children:["Delete ",count," lock(s)"]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:ownerOpen,onClose:()=>setOwnerOpen(false),title:`Set owner for ${count} task(s)`,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:()=>setOwnerOpen(false),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Button,{onClick:runSetOwner,disabled:!ownerInput.trim(),children:["Apply to ",count]})]})]})})]})}function SpreadsheetApp(){const stock=useGsheetStock();const[service,setService]=(0,index_js_.useState)(null);const[owner,setOwner]=(0,index_js_.useState)(null);const[state,setState]=(0,index_js_.useState)("pending");const tasks=useGsheetTasks({service:service??void 0,owner:owner??void 0,state,take:50});const[openJob,setOpenJob]=(0,index_js_.useState)(null);const[selectedIds,setSelectedIds]=(0,index_js_.useState)(new Set);const toggleId=(0,index_js_.useCallback)(id=>{setSelectedIds(prev=>{const next=new Set(prev);if(next.has(id))next.delete(id);else next.add(id);return next})},[]);const toggleAll=(0,index_js_.useCallback)((ids,select)=>{setSelectedIds(prev=>{const next=new Set(prev);for(const id of ids)if(select)next.add(id);else next.delete(id);return next})},[]);const clearSelection=(0,index_js_.useCallback)(()=>setSelectedIds(new Set),[]);const services=(0,index_js_.useMemo)(()=>(stock.data?.byService??[]).map(e=>e.key),[stock.data]);const owners=(0,index_js_.useMemo)(()=>(stock.data?.byOwner??[]).map(e=>e.key),[stock.data]);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Container,{fluid:true,my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,children:"Gsheet task stock"}),stock.dataUpdatedAt&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{c:"dimmed",size:"xs",children:["Updated"," ",new Date(stock.dataUpdatedAt).toLocaleTimeString("fr-FR")]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",size:"sm",loading:stock.isFetching||tasks.isFetching,onClick:()=>{stock.refetch();tasks.refetch()},children:"↻ Refresh"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(KpiCards,{stock:stock.data,isLoading:stock.isLoading,isError:stock.isError}),/*#__PURE__*/(0,jsx_runtime.jsx)(Breakdowns,{byService:stock.data?.byService,byOwner:stock.data?.byOwner}),/*#__PURE__*/(0,jsx_runtime.jsx)(TasksFilters,{service:service,owner:owner,state:state,services:services,owners:owners,onService:setService,onOwner:setOwner,onState:setState,onRefresh:()=>tasks.refetch()}),/*#__PURE__*/(0,jsx_runtime.jsx)(TasksTable,{items:tasks.data?.items,total:tasks.data?.total??0,isLoading:tasks.isLoading,onShowLogs:setOpenJob,selectedIds:selectedIds,onToggleId:toggleId,onToggleAll:toggleAll}),/*#__PURE__*/(0,jsx_runtime.jsx)(BulkActionBar,{selectedIds:[...selectedIds],onClear:clearSelection}),/*#__PURE__*/(0,jsx_runtime.jsx)(JobLogsDrawer.o,{githubJob:openJob,opened:!!openJob,onClose:()=>setOpenJob(null)})]})})}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"],{620:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{o:()=>JobLogsDrawer});var jsx_runtime=__webpack_require__(5893);var index_mjs_=__webpack_require__(207);var index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useJobLogs(githubJob){const api=(0,useApi.h)();return(0,index_js_.useQuery)({queryKey:["tech","github","job-logs",githubJob],queryFn:async()=>(await api.github.getJobLogsV1({githubJob:githubJob})).data,enabled:!!githubJob,refetchOnWindowFocus:false,retry:false})}function fallbackUrl(githubJob){const parts=githubJob.split("/");if(parts.length<3)return null;const runId=parts[parts.length-1];const repo=parts[parts.length-2];const owner=parts.slice(0,-2).join("/");return`https://github.com/${owner}/${repo}/actions/runs/${runId}`}function JobLogsDrawer({githubJob,opened,onClose}){const query=useJobLogs(opened?githubJob:null);const ghLink=githubJob?fallbackUrl(githubJob):null;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Drawer,{opened:opened,onClose:onClose,position:"right",size:"60%",title:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,children:"Workflow logs"}),query.data?.conclusion&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"success"===query.data.conclusion?"green":"red",children:query.data.conclusion})]}),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[ghLink&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{component:"a",href:ghLink,target:"_blank",variant:"default",size:"xs",children:"Open in GitHub"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",onClick:()=>query.refetch(),children:"Refresh logs"})]}),query.isLoading&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:400}),query.isError&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Alert,{color:"red",title:"Failed to load logs",children:query.error?.message??"Unknown error"}),query.data?.jobs.map((j,i)=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,children:j.name}),j.conclusion&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"success"===j.conclusion?"green":"red",children:j.conclusion})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Code,{block:true,style:{maxHeight:400,overflow:"auto",whiteSpace:"pre"},children:j.logs||"(empty)"})]},i)),query.data&&0===query.data.jobs.length&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No jobs found."})]})})}},5774: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 index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useGsheetStock(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","gsheet","stock"],queryFn:async()=>(await api.gsheet.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}function useGsheetTasks(filters){const api=(0,useApi.h)();const query={...filters.service&&{service:filters.service},...filters.owner&&{owner:filters.owner},...filters.state&&{state:filters.state},...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 Tile({label,value,color}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{padding:"md",radius:"md",withBorder:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:label}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,c:color,children:value})]})}function KpiCards({stock,isLoading,isError}){if(isLoading)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:5,children:[0,1,2,3,4].map(i=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:88},i))});if(isError||!stock)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"red",children:"Failed to load stock"})});return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:5,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Pending",value:stock.pending}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Running",value:stock.running,color:"blue"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Stuck",value:stock.stuck,color:"orange"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Errored",value:stock.errored,color:"red"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Oldest",value:stock.oldest?`${stock.oldest.ageHours}h`:"—"})]})}var esm_index_mjs_=__webpack_require__(7183);function Panel({title,data}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{padding:"md",radius:"md",withBorder:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mb:"sm",children:title}),0===data.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No data"}):/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.BarChart,{h:220,data:data.map(d=>({name:d.key,count:d.count})),dataKey:"name",series:[{name:"count",color:"teal.6"}],withTooltip:true})]})}function Breakdowns({byService,byOwner}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By service",data:byService??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By owner",data:byOwner??[]})]})}const STATES=["pending","running","stuck","errored","done","all"];function TasksFilters({service,owner,state,services,owners,onService,onOwner,onState,onRefresh}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Service",placeholder:"All",data:services,value:service,onChange:onService,clearable:true,w:180}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Owner",placeholder:"All",data:owners,value:owner,onChange:onOwner,clearable:true,w:260}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"State",data:STATES.map(s=>({value:s,label:s})),value:state,onChange:v=>onState(v??"pending"),w:140}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default",onClick:onRefresh,"aria-label":"Refresh",mt:22,children:"↻"})]})}const STATE_COLORS={pending:"gray",running:"blue",stuck:"orange",errored:"red",done:"green"};const STATE_LABELS={pending:"Pending",running:"Running",stuck:"Stuck",errored:"Errored",done:"Done"};var tabler_icons_react_mjs_=__webpack_require__(9632);var notifications_esm_index_mjs_=__webpack_require__(1455);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})}function notify(title,message,color){notifications_esm_index_mjs_.notifications.show({title,message,color})}function RowActions({taskId,currentOwner,spreadsheet,worksheet,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=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")})};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:()=>{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"})]})]})})]})}function fmt(d){return d?new Date(d).toLocaleString("fr-FR"):"—"}function TasksTable({items,total,isLoading,onShowLogs,selectedIds,onToggleId,onToggleAll}){if(isLoading)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:300});if(!items||0===items.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No tasks for current filters."});const visibleIds=items.map(i=>i.id);const allSelected=visibleIds.every(id=>selectedIds.has(id));const someSelected=!allSelected&&visibleIds.some(id=>selectedIds.has(id));return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.ScrollArea,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",c:"dimmed",mb:"xs",children:[total," task(s)"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{miw:1100,verticalSpacing:"xs",highlightOnHover:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:40,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{checked:allSelected,indeterminate:someSelected,onChange:e=>onToggleAll(visibleIds,e.currentTarget.checked),"aria-label":"Select all"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"#"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Service"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Spreadsheet:Worksheet"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Owner"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"State"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Created"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Started"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Actions"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:items.map(t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{bg:selectedIds.has(t.id)?"var(--mantine-color-dark-6)":void 0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{checked:selectedIds.has(t.id),onChange:()=>onToggleId(t.id),"aria-label":`Select task ${t.id}`})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:t.id}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:t.service}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:[t.spreadsheet,t.worksheet?`:${t.worksheet}`:""]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:t.owner??"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[t.state],children:STATE_LABELS[t.state]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmt(t.created)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmt(t.started)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:t.id,currentOwner:t.owner,spreadsheet:t.spreadsheet,worksheet:t.worksheet,githubJob:t.github_job,onShowLogs:onShowLogs})})]},t.id))})]})]})}var JobLogsDrawer=__webpack_require__(620);function BulkActionBar_notify(title,message,color){notifications_esm_index_mjs_.notifications.show({title,message,color})}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 BulkActionBar({selectedIds,onClear}){const count=selectedIds.length;const[confirm,setConfirm]=(0,index_js_.useState)(null);const[ownerOpen,setOwnerOpen]=(0,index_js_.useState)(false);const[ownerInput,setOwnerInput]=(0,index_js_.useState)("");const[pending,setPending]=(0,index_js_.useState)(false);const unstick=useUnstickTask();const discard=useDiscardTask();const setOwner=useSetTaskOwner();const deleteLock=useDeleteRedisLock();const finalize=(label,res)=>{setPending(false);onClear();BulkActionBar_notify(label,`${res.ok} succeeded${res.failed?`, ${res.failed} failed`:""}`,res.failed?"red":"green")};const runUnstick=async()=>{setPending(true);const res=await runBulk(selectedIds,id=>unstick.mutateAsync(id));finalize("Bulk unstick",res)};const runDiscard=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>discard.mutateAsync(id));finalize("Bulk discard",res)};const runDeleteLock=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>deleteLock.mutateAsync(id));finalize("Bulk Redis lock delete",res)};const runSetOwner=async()=>{setOwnerOpen(false);const owner=ownerInput.trim();if(!owner)return;setPending(true);const res=await runBulk(selectedIds,id=>setOwner.mutateAsync({id,owner}));finalize(`Bulk set owner \u{2192} ${owner}`,res)};if(0===count)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{p:"sm",radius:"md",withBorder:true,style:{position:"sticky",bottom:16,zIndex:5,backgroundColor:"var(--mantine-color-dark-7)"},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",fw:600,children:[count," selected"]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"subtle",onClick:onClear,children:"Clear"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:runUnstick,children:"Unstick"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:()=>{setOwnerInput("");setOwnerOpen(true)},children:"Set owner…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",color:"orange",loading:pending,onClick:()=>setConfirm("redis"),children:"Delete Redis lock"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",color:"red",loading:pending,onClick:()=>setConfirm("discard"),children:"Discard"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"discard"===confirm,onClose:()=>setConfirm(null),title:`Discard ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Mark ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," task(s) as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"done"})," with step=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". They 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.jsxs)(index_mjs_.Button,{color:"red",onClick:runDiscard,children:["Discard ",count]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"redis"===confirm,onClose:()=>setConfirm(null),title:`Delete Redis lock for ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Delete the Redis running-lock for ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," task(s). The runner will be able to pick them 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.jsxs)(index_mjs_.Button,{color:"orange",onClick:runDeleteLock,children:["Delete ",count," lock(s)"]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:ownerOpen,onClose:()=>setOwnerOpen(false),title:`Set owner for ${count} task(s)`,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:()=>setOwnerOpen(false),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Button,{onClick:runSetOwner,disabled:!ownerInput.trim(),children:["Apply to ",count]})]})]})})]})}function SpreadsheetApp(){const stock=useGsheetStock();const[service,setService]=(0,index_js_.useState)(null);const[owner,setOwner]=(0,index_js_.useState)(null);const[state,setState]=(0,index_js_.useState)("pending");const tasks=useGsheetTasks({service:service??void 0,owner:owner??void 0,state,take:50});const[openJob,setOpenJob]=(0,index_js_.useState)(null);const[selectedIds,setSelectedIds]=(0,index_js_.useState)(new Set);const toggleId=(0,index_js_.useCallback)(id=>{setSelectedIds(prev=>{const next=new Set(prev);if(next.has(id))next.delete(id);else next.add(id);return next})},[]);const toggleAll=(0,index_js_.useCallback)((ids,select)=>{setSelectedIds(prev=>{const next=new Set(prev);for(const id of ids)if(select)next.add(id);else next.delete(id);return next})},[]);const clearSelection=(0,index_js_.useCallback)(()=>setSelectedIds(new Set),[]);const services=(0,index_js_.useMemo)(()=>(stock.data?.byService??[]).map(e=>e.key),[stock.data]);const owners=(0,index_js_.useMemo)(()=>(stock.data?.byOwner??[]).map(e=>e.key),[stock.data]);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Container,{fluid:true,my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,children:"Gsheet task stock"}),stock.dataUpdatedAt&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{c:"dimmed",size:"xs",children:["Updated"," ",new Date(stock.dataUpdatedAt).toLocaleTimeString("fr-FR")]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",size:"sm",loading:stock.isFetching||tasks.isFetching,onClick:()=>{stock.refetch();tasks.refetch()},children:"↻ Refresh"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(KpiCards,{stock:stock.data,isLoading:stock.isLoading,isError:stock.isError}),/*#__PURE__*/(0,jsx_runtime.jsx)(Breakdowns,{byService:stock.data?.byService,byOwner:stock.data?.byOwner}),/*#__PURE__*/(0,jsx_runtime.jsx)(TasksFilters,{service:service,owner:owner,state:state,services:services,owners:owners,onService:setService,onOwner:setOwner,onState:setState,onRefresh:()=>tasks.refetch()}),/*#__PURE__*/(0,jsx_runtime.jsx)(TasksTable,{items:tasks.data?.items,total:tasks.data?.total??0,isLoading:tasks.isLoading,onShowLogs:setOpenJob,selectedIds:selectedIds,onToggleId:toggleId,onToggleAll:toggleAll}),/*#__PURE__*/(0,jsx_runtime.jsx)(BulkActionBar,{selectedIds:[...selectedIds],onClear:clearSelection}),/*#__PURE__*/(0,jsx_runtime.jsx)(JobLogsDrawer.o,{githubJob:openJob,opened:!!openJob,onClose:()=>setOpenJob(null)})]})})}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,10 +1 @@
1
- /*! For license information please see __federation_expose_synchro.js.LICENSE.txt */
2
- "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["2124"],{631:function(__unused_webpack_module,exports){/**
3
- * @license React
4
- * react-jsx-runtime.production.js
5
- *
6
- * Copyright (c) Meta Platforms, Inc. and affiliates.
7
- *
8
- * This source code is licensed under the MIT license found in the
9
- * LICENSE file in the root directory of this source tree.
10
- */var REACT_ELEMENT_TYPE=Symbol.for("react.transitional.element"),REACT_FRAGMENT_TYPE=Symbol.for("react.fragment");function jsxProd(type,config,maybeKey){var key=null;void 0!==maybeKey&&(key=""+maybeKey);void 0!==config.key&&(key=""+config.key);if("key"in config){maybeKey={};for(var propName in config)"key"!==propName&&(maybeKey[propName]=config[propName])}else maybeKey=config;config=maybeKey.ref;return{$$typeof:REACT_ELEMENT_TYPE,type:type,key:key,ref:void 0!==config?config:null,props:maybeKey}}exports.Fragment=REACT_FRAGMENT_TYPE;exports.jsx=jsxProd;exports.jsxs=jsxProd},5893:function(module,__unused_webpack_exports,__webpack_require__){module.exports=__webpack_require__(631)},4148:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{h:()=>useApi});var _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(9056);var _src_hooks_useAppConfig_ts__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(7936);function useApi(){const config=(0,_src_hooks_useAppConfig_ts__WEBPACK_IMPORTED_MODULE_0__.M)();const client=new _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__.eN({baseUrl:config.api.replace(/\/$/,""),baseApiParams:{headers:{Authorization:config.token?`Bearer ${config.token}`:"",From:config.owner}}});return new _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__.eT(client)}},5068:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{U:()=>IconGithub});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);function IconGithub({color="currentColor",size=20,marker,...props}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("svg",{width:size,height:size,viewBox:"0 0 24 24",fill:color,xmlns:"http://www.w3.org/2000/svg",...props,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("path",{d:"M12 0.297C5.373 0.297 0 5.67 0 12.297c0 5.292 3.438 9.787 8.205 11.387.6.111.82-.261.82-.58 0-.287-.011-1.244-.016-2.255-3.338.726-4.042-1.609-4.042-1.609-.546-1.389-1.333-1.759-1.333-1.759-1.089-.745.083-.73.083-.73 1.205.085 1.84 1.236 1.84 1.236 1.07 1.834 2.807 1.304 3.492.997.107-.775.419-1.305.762-1.605-2.665-.304-5.466-1.332-5.466-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.536-1.524.116-3.176 0 0 1.008-.322 3.301 1.23a11.51 11.51 0 0 1 3.004-.404 c1.019.005 2.047.138 3.004.404 2.291-1.552 3.297-1.23 3.297-1.23.655 1.652.243 2.873.119 3.176.77.84 1.235 1.91 1.235 3.221 0 4.61-2.805 5.624-5.476 5.921.43.372.823 1.104.823 2.223 0 1.606-.015 2.896-.015 3.293 0 .321.216.697.825.578C20.565 22.08 24 17.585 24 12.297 24 5.67 18.627.297 12 .297z"})})}},9056:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{eN:()=>HttpClient,eT:()=>TechApi});class HttpClient{baseUrl="";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...fetchParams)=>fetch(...fetchParams);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(apiConfig={}){Object.assign(this,apiConfig)}setSecurityData=data=>{this.securityData=data};encodeQueryParam(key,value){const encodedKey=encodeURIComponent(key);return`${encodedKey}=${encodeURIComponent("number"==typeof value?value:`${value}`)}`}addQueryParam(query,key){return this.encodeQueryParam(key,query[key])}addArrayQueryParam(query,key){const value=query[key];return value.map(v=>this.encodeQueryParam(key,v)).join("&")}toQueryString(rawQuery){const query=rawQuery||{};const keys=Object.keys(query).filter(key=>void 0!==query[key]);return keys.map(key=>Array.isArray(query[key])?this.addArrayQueryParam(query,key):this.addQueryParam(query,key)).join("&")}addQueryParams(rawQuery){const queryString=this.toQueryString(rawQuery);return queryString?`?${queryString}`:""}contentFormatters={["application/json"]:input=>null!==input&&("object"==typeof input||"string"==typeof input)?JSON.stringify(input):input,["application/vnd.api+json"]:input=>null!==input&&("object"==typeof input||"string"==typeof input)?JSON.stringify(input):input,["text/plain"]:input=>null!==input&&"string"!=typeof input?JSON.stringify(input):input,["multipart/form-data"]:input=>{if(input instanceof FormData)return input;return Object.keys(input||{}).reduce((formData,key)=>{const property=input[key];formData.append(key,property instanceof Blob?property:"object"==typeof property&&null!==property?JSON.stringify(property):`${property}`);return formData},new FormData)},["application/x-www-form-urlencoded"]:input=>this.toQueryString(input)};mergeRequestParams(params1,params2){return{...this.baseApiParams,...params1,...params2||{},headers:{...this.baseApiParams.headers||{},...params1.headers||{},...params2&&params2.headers||{}}}}createAbortSignal=cancelToken=>{if(this.abortControllers.has(cancelToken)){const abortController=this.abortControllers.get(cancelToken);if(abortController)return abortController.signal;return}const abortController=new AbortController;this.abortControllers.set(cancelToken,abortController);return abortController.signal};abortRequest=cancelToken=>{const abortController=this.abortControllers.get(cancelToken);if(abortController){abortController.abort();this.abortControllers.delete(cancelToken)}};request=async({body,secure,path,type,query,format,baseUrl,cancelToken,...params})=>{const secureParams=("boolean"==typeof secure?secure:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{};const requestParams=this.mergeRequestParams(params,secureParams);const queryString=query&&this.toQueryString(query);const payloadFormatter=this.contentFormatters[type||"application/json"];const responseFormat=format||requestParams.format;return this.customFetch(`${baseUrl||this.baseUrl||""}${path}${queryString?`?${queryString}`:""}`,{...requestParams,headers:{...requestParams.headers||{},...type&&"multipart/form-data"!==type?{"Content-Type":type}:{}},signal:(cancelToken?this.createAbortSignal(cancelToken):requestParams.signal)||null,body:null==body?null:payloadFormatter(body)}).then(async response=>{const r=response;r.data=null;r.error=null;const responseToParse=responseFormat?response.clone():response;const data=responseFormat?await responseToParse[responseFormat]().then(data=>{if(r.ok)r.data=data;else r.error=data;return r}).catch(e=>{r.error=e;return r}):r;if(cancelToken)this.abortControllers.delete(cancelToken);if(!response.ok)throw data;return data})}}class TechApi{http;constructor(http){this.http=http}status=(params={})=>this.http.request({path:"/status",method:"GET",...params});getDashboard=(params={})=>this.http.request({path:"/dashboard",method:"GET",format:"json",...params});getCompanies=(params={})=>this.http.request({path:"/companies",method:"GET",format:"json",...params});webhook={postSmsWebhook:(query,params={})=>this.http.request({path:"/sms/webhook",method:"POST",query:query,...params})};amex={getTransactionsV1:(query,params={})=>this.http.request({path:"/v1/amex/transactions",method:"GET",query:query,...params})};github={getJobsRunnersV1:(params={})=>this.http.request({path:"/v1/github/jobs/runners",method:"GET",format:"json",...params}),getLabelsV1:({host,...query},params={})=>this.http.request({path:`/v1/github/labels/${host}`,method:"GET",format:"json",...params}),getJobLogsV1:(query,params={})=>this.http.request({path:"/v1/github/job-logs",method:"GET",query:query,format:"json",...params})};gsheet={getStockV1:(params={})=>this.http.request({path:"/v1/gsheet/stock",method:"GET",format:"json",...params}),listTasksV1:(query,params={})=>this.http.request({path:"/v1/gsheet/tasks",method:"GET",query:query,format:"json",...params}),unstickV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/unstick`,method:"POST",format:"json",...params}),discardV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/discard`,method:"POST",format:"json",...params}),setOwnerV1:({id,...query},data,params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/owner`,method:"PUT",body:data,type:"application/json",format:"json",...params}),deleteRedisLockV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/redis-lock`,method:"DELETE",format:"json",...params})};notion={getKikouV1:(params={})=>this.http.request({path:"/v1/notion/kikou",method:"GET",format:"json",...params})};payfit={getChartV1:(query,params={})=>this.http.request({path:"/v1/payfit/chart",method:"GET",query:query,...params})};sobank={getExportsV1:(query,params={})=>this.http.request({path:"/v1/sobank/exports",method:"GET",query:query,format:"json",...params})};synchro={getRunStatsV1:(params={})=>this.http.request({path:"/v1/synchro/run/stats",method:"GET",format:"json",...params}),getTasksV1:(query,params={})=>this.http.request({path:"/v1/synchro/tasks",method:"GET",query:query,format:"json",...params}),getJobsDefaultsV1:(params={})=>this.http.request({path:"/v1/synchro/jobs/defaults",method:"GET",format:"json",...params}),putStopTaskV1:({id,...query},params={})=>this.http.request({path:`/v1/synchro/tasks/stop/${id}`,method:"PUT",...params}),resetOwnerStatsV1:({owner,value,...query},params={})=>this.http.request({path:`/v1/synchro/run/stats/${owner}/${value}`,method:"PUT",...params})}}},7936:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{$:()=>AppConfigProvider,M:()=>useAppConfig});var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(3106);const AppConfigCtx=(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(null);const AppConfigProvider=AppConfigCtx.Provider;function useAppConfig(){const config=(0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(AppConfigCtx);if(!config)throw new Error("Called `useAppConfig` outside a `<AppConfigProvider />`");return config}},7034:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{C:()=>Providers});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _airporting_app_front__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1380);var _mantine_core__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(207);var _mantine_modals__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(4142);var _mantine_notifications__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(1455);var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(6197);var radash__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(9877);var _hooks_useAppConfig__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(7936);const theme=(0,_mantine_core__WEBPACK_IMPORTED_MODULE_2__.createTheme)((0,radash__WEBPACK_IMPORTED_MODULE_6__.assign)(_airporting_app_front__WEBPACK_IMPORTED_MODULE_1__.theme,{components:{}}));const cssVarResolver=x=>(0,radash__WEBPACK_IMPORTED_MODULE_6__.assign)(_airporting_app_front__WEBPACK_IMPORTED_MODULE_1__.cssVarResolver(x),{dark:{},light:{},variables:{}});function Providers(props){const{children,config,mantine,tanstack}=props;return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_hooks_useAppConfig__WEBPACK_IMPORTED_MODULE_7__.$,{value:config,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.QueryClientProvider,{client:tanstack?.queryClient??new _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.QueryClient,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_2__.MantineProvider,{theme:theme,cssVariablesResolver:cssVarResolver,defaultColorScheme:mantine?.defaultColorScheme,forceColorScheme:mantine?.forceColorScheme,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_modals__WEBPACK_IMPORTED_MODULE_3__.ModalsProvider,{children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_notifications__WEBPACK_IMPORTED_MODULE_4__.Notifications,{}),children]})})})})}},9098:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Synchro});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var esm_index_mjs_=__webpack_require__(9038);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useSynchroStatsQuery(){const api=(0,useApi.h)();const query=(0,modern_index_js_.useQuery)({queryKey:["tech","synchro","stats"],queryFn:async()=>await api.synchro.getRunStatsV1().then(x=>x.data),refetchInterval:6e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true});return query}var tabler_icons_react_mjs_=__webpack_require__(9632);var notifications_esm_index_mjs_=__webpack_require__(1455);function useResetStatsMutation(){const api=(0,useApi.h)();const query=(0,modern_index_js_.useMutation)({mutationFn:async values=>await api.synchro.resetOwnerStatsV1(values).then(x=>x.data),onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Cible remise \xe0 niveau",message:"C'est reparti comme en 40"})},onError:(error,variables,context)=>{console.error(error,variables,context);notifications_esm_index_mjs_.notifications.show({color:"red",title:"Erreur !",message:"Nous rencontrons un soucis technique. Veuillez r\xe9essayer plus tard."})}});return query}function useSynchroTasks({gas,dateRange,companies,jobs}){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","synchro","tasks","list",{gas,dateRange,companies,jobs}],queryFn:async()=>await api.synchro.getTasksV1({...gas&&{gas},...dateRange&&{dateStart:dateRange[0]??void 0,dateEnd:dateRange[1]??void 0,companyIds:companies?.map(x=>+x),jobNames:jobs}}).then(x=>x.data),refetchInterval:6e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true})}var IconGithub=__webpack_require__(5068);var dist_index_js_=__webpack_require__(1380);var date_fns_index_js_=__webpack_require__(4365);function useCompaniesQuery(){const api=(0,useApi.h)();const query=(0,modern_index_js_.useQuery)({queryKey:["tech","companies"],queryFn:async()=>await api.getCompanies().then(x=>x.data)});return query}function useJobsDefaultQuery(){const api=(0,useApi.h)();const query=(0,modern_index_js_.useQuery)({queryKey:["tech","jobs","defaults"],queryFn:async()=>await api.synchro.getJobsDefaultsV1().then(x=>x.data)});return query}function SynchroApp(){const[gasOnly,setGasOnly]=(0,index_js_.useState)("nodejs");const[dateRange,setDateRange]=(0,index_js_.useState)([(0,date_fns_index_js_.formatISO)((0,date_fns_index_js_.startOfDay)(new Date)),(0,date_fns_index_js_.formatISO)((0,date_fns_index_js_.endOfDay)(new Date))]);const[companies,setCompanies]=(0,index_js_.useState)([]);const[jobs,setJobs]=(0,index_js_.useState)([]);const companiesResult=useCompaniesQuery();const companiesList=(companiesResult.data?.list??[]).map(company=>({value:company.id.toString(),label:company.display_name??company.id.toString()}));const jobsDefaultResult=useJobsDefaultQuery();const jobsDefaultList=(jobsDefaultResult.data?.list??[]).map(jobDefault=>jobDefault.task);const statsResult=useSynchroStatsQuery();const stats=statsResult.data;const tasksListResult=useSynchroTasks({gas:gasOnly,dateRange,companies,jobs});const tasksList=tasksListResult.data;const resetFn=useResetStatsMutation();function resolveStatus(element){if(!element.ready)return"en attente";if(element.need_gas)return element.gas_started?"GAS en cours":"GAS en attente";return element.finished?"fini":"en cours"}const rows=(tasksList?.tasks??[]).map(element=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:element.id}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Td,{children:[element.need_gas?/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconOld,{title:"papi GAS"}):/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconBolt,{title:"fougueux nodejs"})," ",element.job_name,/*#__PURE__*/(0,jsx_runtime.jsx)("br",{}),/*#__PURE__*/(0,jsx_runtime.jsx)("small",{children:element.job_name_fr})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:(0,date_fns_index_js_.format)(element.created,"dd/MM/yyyy HH:mm:ss")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:element.startedAt?(0,date_fns_index_js_.format)(element.startedAt,"dd/MM/yyyy HH:mm:ss"):""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:resolveStatus(element)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:element.owner}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:element.main_company?.display_name}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Th,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.AirButton,{variant:"subtle",color:"gray",href:element.github_job,title:"Github runner",children:/*#__PURE__*/(0,jsx_runtime.jsx)(IconGithub.U,{size:20})}),/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.AirButton,{variant:"subtle",color:"gray",href:`https://airporting.grafana.net/d/beegyy3vsp8n4c/recipes?var-trace=${element.recipe_uuid}-${element.id}&orgId=1&from=now-7d&to=now&timezone=browser&showCategory=Logs&refresh=7d`,children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconFileText,{title:"Logs",size:20})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",color:"gray",size:"compact-sm",onClick:()=>console.log(`coucou ${element.id}`),children:"log"}),element.finished?/*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{}):/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.AirButton,{variant:"subtle",color:"gray",onClick:async()=>{console.log("stop",element.id)},children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconHandStop,{title:"Stop",size:20})})]})]},element.id));return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,my:"md",children:"Synchro"}),/*#__PURE__*/(0,jsx_runtime.jsx)("ul",{children:stats&&Object.entries(stats.currentJobsCounters).map(([key,value])=>/*#__PURE__*/(0,jsx_runtime.jsxs)("li",{children:[key,": ",value.db," db, ",value.redis," redis",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",color:value.db!=value.redis?"red":"green",onClick:async()=>{await resetFn.mutateAsync({owner:key,value:(value.db??0).toString()});await statsResult.refetch()},children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconRefreshDot,{size:20})})]},key))}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Stack,{gap:"sm",my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{align:"flex-end",wrap:"wrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"GAS et/ou nodejs",data:[{value:"all",label:"Toutes"},{value:"nodejs",label:"nodejs seulement"},{value:"gas",label:"GAS seulement"}],value:gasOnly,onChange:v=>setGasOnly(v??"nodejs"),w:140}),/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.DatePickerInput,{leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconCalendar,{size:18}),type:"range",label:"Date de cr\xe9ation",placeholder:"S\xe9lectionner une plage",value:dateRange,onChange:setDateRange,clearable:true,allowSingleDateInRange:true,w:260}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MultiSelect,{label:"Client",placeholder:"S\xe9lectionner un ou plusieurs clients",data:companiesList,onChange:setCompanies,searchable:true,clearable:true}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MultiSelect,{label:"Fonction",placeholder:"S\xe9lectionner une ou plusieurs fonctions",data:jobsDefaultList,onChange:setJobs,searchable:true,clearable:true})]})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{stickyHeader:true,striped:true,highlightOnHover:true,withTableBorder:true,withColumnBorders:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"ID"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Fonction"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Demand\xe9e"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"D\xe9mar\xe9e"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Statut"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Owner"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Client"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Liens"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:rows})]})]})}function Synchro(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)(SynchroApp,{})})})}}}]);
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["2124"],{5068:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{U:()=>IconGithub});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);function IconGithub({color="currentColor",size=20,marker,...props}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("svg",{width:size,height:size,viewBox:"0 0 24 24",fill:color,xmlns:"http://www.w3.org/2000/svg",...props,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("path",{d:"M12 0.297C5.373 0.297 0 5.67 0 12.297c0 5.292 3.438 9.787 8.205 11.387.6.111.82-.261.82-.58 0-.287-.011-1.244-.016-2.255-3.338.726-4.042-1.609-4.042-1.609-.546-1.389-1.333-1.759-1.333-1.759-1.089-.745.083-.73.083-.73 1.205.085 1.84 1.236 1.84 1.236 1.07 1.834 2.807 1.304 3.492.997.107-.775.419-1.305.762-1.605-2.665-.304-5.466-1.332-5.466-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.536-1.524.116-3.176 0 0 1.008-.322 3.301 1.23a11.51 11.51 0 0 1 3.004-.404 c1.019.005 2.047.138 3.004.404 2.291-1.552 3.297-1.23 3.297-1.23.655 1.652.243 2.873.119 3.176.77.84 1.235 1.91 1.235 3.221 0 4.61-2.805 5.624-5.476 5.921.43.372.823 1.104.823 2.223 0 1.606-.015 2.896-.015 3.293 0 .321.216.697.825.578C20.565 22.08 24 17.585 24 12.297 24 5.67 18.627.297 12 .297z"})})}},9098:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Synchro});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var esm_index_mjs_=__webpack_require__(9038);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useSynchroStatsQuery(){const api=(0,useApi.h)();const query=(0,modern_index_js_.useQuery)({queryKey:["tech","synchro","stats"],queryFn:async()=>await api.synchro.getRunStatsV1().then(x=>x.data),refetchInterval:6e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true});return query}var tabler_icons_react_mjs_=__webpack_require__(9632);var notifications_esm_index_mjs_=__webpack_require__(1455);function useResetStatsMutation(){const api=(0,useApi.h)();const query=(0,modern_index_js_.useMutation)({mutationFn:async values=>await api.synchro.resetOwnerStatsV1(values).then(x=>x.data),onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Cible remise \xe0 niveau",message:"C'est reparti comme en 40"})},onError:(error,variables,context)=>{console.error(error,variables,context);notifications_esm_index_mjs_.notifications.show({color:"red",title:"Erreur !",message:"Nous rencontrons un soucis technique. Veuillez r\xe9essayer plus tard."})}});return query}function useSynchroTasks({gas,dateRange,companies,jobs}){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","synchro","tasks","list",{gas,dateRange,companies,jobs}],queryFn:async()=>await api.synchro.getTasksV1({...gas&&{gas},...dateRange&&{dateStart:dateRange[0]??void 0,dateEnd:dateRange[1]??void 0,companyIds:companies?.map(x=>+x),jobNames:jobs}}).then(x=>x.data),refetchInterval:6e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true})}var IconGithub=__webpack_require__(5068);var dist_index_js_=__webpack_require__(1380);var date_fns_index_js_=__webpack_require__(4365);function useCompaniesQuery(){const api=(0,useApi.h)();const query=(0,modern_index_js_.useQuery)({queryKey:["tech","companies"],queryFn:async()=>await api.getCompanies().then(x=>x.data)});return query}function useJobsDefaultQuery(){const api=(0,useApi.h)();const query=(0,modern_index_js_.useQuery)({queryKey:["tech","jobs","defaults"],queryFn:async()=>await api.synchro.getJobsDefaultsV1().then(x=>x.data)});return query}function SynchroApp(){const[gasOnly,setGasOnly]=(0,index_js_.useState)("nodejs");const[dateRange,setDateRange]=(0,index_js_.useState)([(0,date_fns_index_js_.formatISO)((0,date_fns_index_js_.startOfDay)(new Date)),(0,date_fns_index_js_.formatISO)((0,date_fns_index_js_.endOfDay)(new Date))]);const[companies,setCompanies]=(0,index_js_.useState)([]);const[jobs,setJobs]=(0,index_js_.useState)([]);const companiesResult=useCompaniesQuery();const companiesList=(companiesResult.data?.list??[]).map(company=>({value:company.id.toString(),label:company.display_name??company.id.toString()}));const jobsDefaultResult=useJobsDefaultQuery();const jobsDefaultList=(jobsDefaultResult.data?.list??[]).map(jobDefault=>jobDefault.task);const statsResult=useSynchroStatsQuery();const stats=statsResult.data;const tasksListResult=useSynchroTasks({gas:gasOnly,dateRange,companies,jobs});const tasksList=tasksListResult.data;const resetFn=useResetStatsMutation();function resolveStatus(element){if(!element.ready)return"en attente";if(element.need_gas)return element.gas_started?"GAS en cours":"GAS en attente";return element.finished?"fini":"en cours"}const rows=(tasksList?.tasks??[]).map(element=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:element.id}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Td,{children:[element.need_gas?/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconOld,{title:"papi GAS"}):/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconBolt,{title:"fougueux nodejs"})," ",element.job_name,/*#__PURE__*/(0,jsx_runtime.jsx)("br",{}),/*#__PURE__*/(0,jsx_runtime.jsx)("small",{children:element.job_name_fr})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:(0,date_fns_index_js_.format)(element.created,"dd/MM/yyyy HH:mm:ss")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:element.startedAt?(0,date_fns_index_js_.format)(element.startedAt,"dd/MM/yyyy HH:mm:ss"):""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:resolveStatus(element)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:element.owner}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:element.main_company?.display_name}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Th,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.AirButton,{variant:"subtle",color:"gray",href:element.github_job,title:"Github runner",children:/*#__PURE__*/(0,jsx_runtime.jsx)(IconGithub.U,{size:20})}),/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.AirButton,{variant:"subtle",color:"gray",href:`https://airporting.grafana.net/d/beegyy3vsp8n4c/recipes?var-trace=${element.recipe_uuid}-${element.id}&orgId=1&from=now-7d&to=now&timezone=browser&showCategory=Logs&refresh=7d`,children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconFileText,{title:"Logs",size:20})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",color:"gray",size:"compact-sm",onClick:()=>console.log(`coucou ${element.id}`),children:"log"}),element.finished?/*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{}):/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.AirButton,{variant:"subtle",color:"gray",onClick:async()=>{console.log("stop",element.id)},children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconHandStop,{title:"Stop",size:20})})]})]},element.id));return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,my:"md",children:"Synchro"}),/*#__PURE__*/(0,jsx_runtime.jsx)("ul",{children:stats&&Object.entries(stats.currentJobsCounters).map(([key,value])=>/*#__PURE__*/(0,jsx_runtime.jsxs)("li",{children:[key,": ",value.db," db, ",value.redis," redis",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",color:value.db!=value.redis?"red":"green",onClick:async()=>{await resetFn.mutateAsync({owner:key,value:(value.db??0).toString()});await statsResult.refetch()},children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconRefreshDot,{size:20})})]},key))}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Stack,{gap:"sm",my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{align:"flex-end",wrap:"wrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"GAS et/ou nodejs",data:[{value:"all",label:"Toutes"},{value:"nodejs",label:"nodejs seulement"},{value:"gas",label:"GAS seulement"}],value:gasOnly,onChange:v=>setGasOnly(v??"nodejs"),w:140}),/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.DatePickerInput,{leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconCalendar,{size:18}),type:"range",label:"Date de cr\xe9ation",placeholder:"S\xe9lectionner une plage",value:dateRange,onChange:setDateRange,clearable:true,allowSingleDateInRange:true,w:260}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MultiSelect,{label:"Client",placeholder:"S\xe9lectionner un ou plusieurs clients",data:companiesList,onChange:setCompanies,searchable:true,clearable:true}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MultiSelect,{label:"Fonction",placeholder:"S\xe9lectionner une ou plusieurs fonctions",data:jobsDefaultList,onChange:setJobs,searchable:true,clearable:true})]})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{stickyHeader:true,striped:true,highlightOnHover:true,withTableBorder:true,withColumnBorders:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"ID"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Fonction"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Demand\xe9e"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"D\xe9mar\xe9e"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Statut"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Owner"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Client"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Liens"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:rows})]})]})}function Synchro(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)(SynchroApp,{})})})}}}]);