@airporting/tech-app 0.0.120 → 0.0.121
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.
- package/dist/mf/{5429.eecc07ae26.js → 5429.bdf021fc55.js} +1 -1
- package/dist/mf/{8853.a8b3155879.js → 8853.20c1b87755.js} +5 -5
- package/dist/mf/{8853.a8b3155879.js.LICENSE.txt → 8853.20c1b87755.js.LICENSE.txt} +1 -1
- package/dist/mf/{9698.78f690ae77.css → 9698.35e6238b72.css} +73 -73
- package/dist/mf/@mf-types.zip +0 -0
- package/dist/mf/{__federation_expose_synchro.a358d53b47.js → __federation_expose_synchro.090ad23824.js} +2 -2
- package/dist/mf/{__federation_expose_usage.61e16f490e.js → __federation_expose_usage.be52f862ad.js} +2 -2
- package/dist/mf/{index.973c391254.js → index.490830ae60.js} +3 -3
- package/dist/mf/mf-manifest.json +40 -40
- package/dist/mf/mf-stats.json +47 -47
- package/dist/mf/{tech_app.970d9761d3.js → tech_app.d95348e0d8.js} +3 -3
- package/package.json +3 -3
- /package/dist/mf/{__federation_expose_synchro.a358d53b47.js.LICENSE.txt → __federation_expose_synchro.090ad23824.js.LICENSE.txt} +0 -0
- /package/dist/mf/{__federation_expose_usage.61e16f490e.js.LICENSE.txt → __federation_expose_usage.be52f862ad.js.LICENSE.txt} +0 -0
package/dist/mf/{__federation_expose_usage.61e16f490e.js → __federation_expose_usage.be52f862ad.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! LICENSE: __federation_expose_usage.
|
|
1
|
+
/*! LICENSE: __federation_expose_usage.be52f862ad.js.LICENSE.txt */
|
|
2
2
|
"use strict";(globalThis["chunk_tech_app "]||=[]).push([[3270],{9698(__unused_rspack_module,exports){/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
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},4848(module,__unused_rspack_exports,__webpack_require__){module.exports=__webpack_require__(9698)},7483(__unused_rspack_module,__webpack_exports__,__webpack_require__){var react_jsx_runtime__rspack_import_0=__webpack_require__(4848);var _mantine_core__rspack_import_1=__webpack_require__(4618);var _tabler_icons_react__rspack_import_2=__webpack_require__(2638);var react__rspack_import_3=__webpack_require__(814);function formatRelative(now,then){const seconds=Math.max(0,Math.floor((now-then)/1e3));if(seconds<5)return"à l’instant";if(seconds<60)return`il y a ${seconds}s`;const minutes=Math.floor(seconds/60);if(minutes<60)return`il y a ${minutes} min`;const hours=Math.floor(minutes/60);return`il y a ${hours} h`}function PageHeader({title,leading,badge,updatedAt,isFetching,isError,onRefresh,actions}){const[now,setNow]=(0,react__rspack_import_3.useState)(()=>Date.now());(0,react__rspack_import_3.useEffect)(()=>{if(!updatedAt)return;const id=window.setInterval(()=>setNow(Date.now()),1e3);return()=>window.clearInterval(id)},[updatedAt]);const relative=updatedAt?formatRelative(now,updatedAt):null;const color=isError?"orange":isFetching?"teal":"dimmed";return/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsxs)(_mantine_core__rspack_import_1.Group,{justify:"space-between",align:"center",mih:48,mb:"md",children:[/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsxs)(_mantine_core__rspack_import_1.Group,{gap:"sm",align:"center",children:[leading,/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsx)(_mantine_core__rspack_import_1.Title,{order:2,children:title}),badge]}),/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsxs)(_mantine_core__rspack_import_1.Group,{gap:"sm",align:"center",children:[relative&&/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsx)(_mantine_core__rspack_import_1.Text,{size:"xs",c:color,fw:isFetching?600:400,"data-testid":"page-header-freshness",children:isError?"échec maj":isFetching?"maj…":relative}),onRefresh&&/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsx)(_mantine_core__rspack_import_1.Tooltip,{label:"Rafraîchir",children:/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsx)(_mantine_core__rspack_import_1.ActionIcon,{variant:"default",size:"md",onClick:onRefresh,loading:isFetching,"aria-label":"Refresh",children:/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsx)(_tabler_icons_react__rspack_import_2.IconRefresh,{size:16})})}),actions]})]})}__webpack_require__.d(__webpack_exports__,{z:()=>PageHeader})},6066(__unused_rspack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Usage});var jsx_runtime=__webpack_require__(4848);var index_js_=__webpack_require__(814);var providers=__webpack_require__(9528);var index_mjs_=__webpack_require__(4618);var tabler_icons_react_mjs_=__webpack_require__(2638);var modern_index_js_=__webpack_require__(3411);var useApi=__webpack_require__(4691);const STALE_MS=6e4;const DAY_REFETCH_MS=3e5;function chargeKey(view,trigger,at){return["tech","usage","charge",view,trigger,at??null]}function chargeParams(view,trigger,at){return{view,..."all"===trigger?{}:{trigger},...at?{at}:{}}}function useUsageCharge(view,trigger,at){const api=(0,useApi.g)();return(0,modern_index_js_.useQuery)({queryKey:chargeKey(view,trigger,at),queryFn:async()=>{const response=await api.http.request({path:"/v1/usage/charge",method:"GET",query:chargeParams(view,trigger,at),format:"json"});return response.data},placeholderData:modern_index_js_.keepPreviousData,staleTime:STALE_MS,refetchInterval:"day"===view?DAY_REFETCH_MS:false,refetchOnWindowFocus:false})}function useUsageChargePrefetch(){const api=(0,useApi.g)();const queryClient=(0,modern_index_js_.useQueryClient)();return(view,trigger,at)=>{queryClient.prefetchQuery({queryKey:chargeKey(view,trigger,at),queryFn:async()=>{const response=await api.http.request({path:"/v1/usage/charge",method:"GET",query:chargeParams(view,trigger,at),format:"json"});return response.data},staleTime:STALE_MS})}}var PageHeader=__webpack_require__(7483);const OPTIONS=[{value:"all",label:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"Tout"})},{value:"auto",label:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconRobot,{size:16,stroke:1.5}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"Robots"})]})},{value:"human",label:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconUser,{size:16,stroke:1.5}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"Humains"})]})}];const HINT="Robots = planificateur et crons dédiés. Humains = run lancé depuis l’app ; c’est un plancher, les runs passés par l’ancienne API sont comptés comme planifiés.";function TriggerFilter(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:HINT,multiline:true,w:320,withArrow:true,position:"bottom",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:props.value,onChange:next=>props.onChange(next),data:OPTIONS,size:"xs"})})}const USAGE_COLORS={productive:"#3987e5",errored:"#d03b3b",noop:"#fab219"};const AXIS_INK="#898781";function formatHours(hours){if(hours>=100)return`${Math.round(hours)} h`;return`${hours.toFixed(1).replace(".",",")} h`}function formatCount(value){return new Intl.NumberFormat("fr-FR").format(value)}function formatCompactCount(value){return new Intl.NumberFormat("fr-FR",{notation:"compact",maximumFractionDigits:1}).format(value)}function servicePercent(under,measured){if(measured<=0)return 0;return Math.round(under/measured*100)}function wastePercent(kpis){if(kpis.computeHours<=0)return 0;return Math.round((kpis.erroredHours+kpis.noopHours)/kpis.computeHours*100)}function UsageKpiRow(props){const{kpis}=props;const tiles=[{key:"compute",label:"Compute",value:formatHours(kpis.computeHours),hint:`${formatCount(kpis.tasks)} t\xe2ches, dont ${formatCount(kpis.worksheetTasks)} worksheets`},{key:"companies",label:"Entreprises actives",value:formatCount(kpis.companies),hint:`${formatCount(kpis.distinctJobs)} connecteurs distincts`},{key:"waste",label:"Compute non productif",value:`${formatHours(kpis.erroredHours+kpis.noopHours)} \xb7 ${wastePercent(kpis)} %`,hint:`${formatHours(kpis.erroredHours)} en erreur (${formatCount(kpis.erroredTasks)} t\xe2ches), ${formatHours(kpis.noopHours)} sans r\xe9sultat`,accent:USAGE_COLORS.errored},{key:"concurrency",label:"Concurrence max",value:null===kpis.maxConcurrent?"—":`${formatCount(kpis.maxConcurrent)} t\xe2ches`,hint:null===kpis.maxConcurrent?"Non calculé sur 12 mois : trop coûteux à recouvrir":"Pic de tâches simultanées, durée bornée à 110 min"},{key:"service",label:"Démarrage < 15 min",value:kpis.waitMeasured>0?`${servicePercent(kpis.waitLe15,kpis.waitMeasured)} %`:"—",hint:kpis.waitMeasured>0?`${servicePercent(kpis.waitLe30,kpis.waitMeasured)} % sous 30 min, ${servicePercent(kpis.waitLe60,kpis.waitMeasured)} % sous 1 h, ${servicePercent(kpis.waitLe240,kpis.waitMeasured)} % sous 4 h — sur ${formatCount(kpis.waitMeasured)} t\xe2ches r\xe9ellement ex\xe9cut\xe9es`:"Aucune tâche exécutée sur la période"},{key:"abandoned",label:"Synchros perdues",value:formatCount(kpis.abandonedTasks),hint:0===kpis.abandonedTasks?"Aucune synchro abandonnée sur la période":`Abandonn\xe9es apr\xe8s 3 d\xe9blocages, sans jamais avoir tourn\xe9. ${formatHours(kpis.abandonedFabricatedHours)} de dur\xe9e fictive exclues du compute.`,accent:kpis.abandonedTasks>0?USAGE_COLORS.errored:void 0},{key:"rows",label:"Lignes synchronisées",value:formatCompactCount(kpis.rowsSynced),hint:"Somme des compteurs renvoyés par les jobs — proxy de tendance"}];return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:{base:1,sm:2,md:3,lg:4,xl:7},spacing:"md",children:tiles.map(tile=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,align:"center",mb:6,children:[tile.accent?/*#__PURE__*/(0,jsx_runtime.jsx)("span",{"aria-hidden":true,style:{width:8,height:8,borderRadius:2,background:tile.accent,display:"inline-block"}}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",tt:"uppercase",fw:700,children:tile.label})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:tile.hint,withArrow:true,multiline:true,w:260,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fz:26,fw:600,lh:1.1,children:tile.value})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",mt:6,lineClamp:2,children:tile.hint})]},tile.key))})}var esm_index_mjs_=__webpack_require__(7194);const PARIS_TZ="Europe/Paris";const minuteFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:PARIS_TZ,hour:"2-digit",minute:"2-digit"});const weekDayFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:PARIS_TZ,weekday:"short",day:"numeric"});const monthFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:PARIS_TZ,month:"short",year:"2-digit"});const fullDayFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:PARIS_TZ,weekday:"long",day:"numeric",month:"long"});function bucketDate(t){if(7===t.length)return new Date(`${t}-15T12:00:00Z`);return new Date(`${t}T12:00:00Z`)}function formatMinuteTick(iso){return minuteFormatter.format(new Date(iso))}function formatBucketTick(t,view){if("year"===view)return monthFormatter.format(bucketDate(t));if("month"===view)return String(bucketDate(t).getUTCDate());return weekDayFormatter.format(bucketDate(t))}function formatBucketLong(t,view){if("year"===view)return monthFormatter.format(bucketDate(t));return fullDayFormatter.format(bucketDate(t))}function formatWindow(from,to,view){if("day"===view)return fullDayFormatter.format(new Date(from));if("year"===view){const start=monthFormatter.format(new Date(from));const end=monthFormatter.format(new Date(new Date(to).getTime()-1));return`${start} → ${end}`}const start=fullDayFormatter.format(new Date(from));const end=fullDayFormatter.format(new Date(new Date(to).getTime()-1));return`${start} → ${end}`}function ConcurrencyTooltip({payload}){const point=payload?.[0]?.payload;if(!point)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{px:"md",py:"sm",withBorder:true,shadow:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,mb:4,children:formatMinuteTick(point.t)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:[point.concurrent," tâche",point.concurrent>1?"s":""," en cours"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:[point.started," démarrage",point.started>1?"s":""]}),point.errored>0?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:USAGE_COLORS.errored,children:[point.errored," en erreur"]}):null]})}function ConcurrencyChart(props){const{data}=props;if(0===data.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Aucune tâche sur la journée."});return/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.AreaChart,{h:260,data:data,dataKey:"t",withDots:false,strokeWidth:2,curveType:"linear",gridAxis:"y",tickLine:"none",series:[{name:"concurrent",label:"Tâches en cours",color:USAGE_COLORS.productive}],xAxisProps:{tickFormatter:formatMinuteTick,minTickGap:48,stroke:AXIS_INK},yAxisProps:{allowDecimals:false,stroke:AXIS_INK,width:32},tooltipProps:{content:ConcurrencyTooltip},tooltipAnimationDuration:0})}const SURFACE="var(--mantine-color-body)";const SERIES=[{name:"productiveHours",label:"Productif",color:USAGE_COLORS.productive},{name:"noopHours",label:"Sans résultat",color:USAGE_COLORS.noop},{name:"erroredHours",label:"En erreur",color:USAGE_COLORS.errored}];const TOP_SERIES=SERIES[SERIES.length-1].name;function makeTooltip(view){return function({payload}){const bucket=payload?.[0]?.payload;if(!bucket)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{px:"md",py:"sm",withBorder:true,shadow:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,mb:4,children:formatBucketLong(bucket.t,view)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:[formatHours(bucket.computeHours)," de compute"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:USAGE_COLORS.errored,children:["dont ",formatHours(bucket.erroredHours)," en erreur (",formatCount(bucket.erroredTasks)," tâches)"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:["dont ",formatHours(bucket.noopHours)," sans résultat"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",mt:4,children:[formatCount(bucket.tasks)," tâches ·"," ",formatCount(bucket.worksheetTasks)," worksheets"]}),bucket.waitMaxMinutes?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:["attente max ",Math.round(bucket.waitMaxMinutes)," min"]}):null]})}}function ChargeStack(props){const{buckets,view}=props;if(0===buckets.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Aucune tâche sur la période."});return/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.BarChart,{h:300,data:buckets,dataKey:"t",type:"stacked",withLegend:true,legendProps:{verticalAlign:"top",height:32},gridAxis:"y",tickLine:"none",unit:" h",series:SERIES,barProps:item=>({stroke:SURFACE,strokeWidth:1.5,strokeOpacity:1,radius:item.name===TOP_SERIES?[4,4,0,0]:0}),xAxisProps:{tickFormatter:t=>formatBucketTick(t,view),stroke:AXIS_INK,minTickGap:4},yAxisProps:{stroke:AXIS_INK,width:44},tooltipProps:{content:makeTooltip(view)},tooltipAnimationDuration:0})}function AbandonedChart_makeTooltip(view){return function({payload}){const bucket=payload?.[0]?.payload;if(!bucket)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{px:"md",py:"sm",withBorder:true,shadow:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,mb:4,children:formatBucketLong(bucket.t,view)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:USAGE_COLORS.errored,children:[formatCount(bucket.abandonedTasks)," synchro",bucket.abandonedTasks>1?"s":""," perdue",bucket.abandonedTasks>1?"s":""]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:["sur ",formatCount(bucket.tasks)," tâches créées"]})]})}}function AbandonedChart(props){const{buckets,view}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.BarChart,{h:180,data:buckets,dataKey:"t",gridAxis:"y",tickLine:"none",series:[{name:"abandonedTasks",label:"Synchros perdues",color:USAGE_COLORS.errored}],barProps:{radius:[4,4,0,0]},xAxisProps:{tickFormatter:t=>formatBucketTick(t,view),stroke:AXIS_INK,minTickGap:4},yAxisProps:{stroke:AXIS_INK,width:44,allowDecimals:false},tooltipProps:{content:AbandonedChart_makeTooltip(view)},tooltipAnimationDuration:0})}function toPoints(buckets){return buckets.map(b=>({t:b.t,service:servicePercent(b.waitLe15,b.waitMeasured),under30:servicePercent(b.waitLe30,b.waitMeasured),under60:servicePercent(b.waitLe60,b.waitMeasured),measured:b.waitMeasured}))}function ServiceLevelChart_makeTooltip(view){return function({payload}){const point=payload?.[0]?.payload;if(!point)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{px:"md",py:"sm",withBorder:true,shadow:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,mb:4,children:formatBucketLong(point.t,view)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:USAGE_COLORS.productive,children:[point.service," % démarrées sous ",15," min"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:[point.under30," % sous 30 min · ",point.under60," % sous 1 h"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",mt:4,children:["sur ",formatCount(point.measured)," tâches exécutées"]})]})}}function ServiceLevelChart(props){const{buckets,view}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.LineChart,{h:180,data:toPoints(buckets),dataKey:"t",gridAxis:"y",tickLine:"none",unit:" %",withDots:buckets.length<=40,series:[{name:"service",label:"Démarrées sous 15 min",color:USAGE_COLORS.productive}],xAxisProps:{tickFormatter:t=>formatBucketTick(t,view),stroke:AXIS_INK,minTickGap:4},yAxisProps:{stroke:AXIS_INK,width:48,domain:[0,100],allowDecimals:false},tooltipProps:{content:ServiceLevelChart_makeTooltip(view)},tooltipAnimationDuration:0})}const TRACTION_SERIES=[{name:"companies",label:"Entreprises actives",color:"#3987e5"},{name:"distinctJobs",label:"Connecteurs distincts",color:"#d95926"}];function TractionTooltip({payload}){const bucket=payload?.[0]?.payload;if(!bucket)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{px:"md",py:"sm",withBorder:true,shadow:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,mb:4,children:formatBucketLong(bucket.t,"year")}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:[bucket.companies??0," entreprises actives"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:[bucket.distinctJobs??0," connecteurs distincts"]})]})}function TractionChart(props){const{buckets}=props;if(0===buckets.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Pas d'historique sur la période."});return/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.LineChart,{h:240,data:buckets,dataKey:"t",withLegend:true,legendProps:{verticalAlign:"top",height:32},strokeWidth:2,dotProps:{r:4},activeDotProps:{r:6},gridAxis:"y",tickLine:"none",series:TRACTION_SERIES,xAxisProps:{tickFormatter:t=>formatBucketTick(t,"year"),stroke:AXIS_INK},yAxisProps:{allowDecimals:false,stroke:AXIS_INK,width:40},tooltipProps:{content:TractionTooltip},tooltipAnimationDuration:0})}function ShareBar(props){const{hours,erroredHours,max}=props;if(max<=0)return null;const total=hours/max*100;const errored=Math.min(erroredHours,hours)/max*100;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Progress.Root,{size:"md",w:140,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Progress.Section,{value:Math.max(total-errored,0),color:USAGE_COLORS.productive}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Progress.Section,{value:errored,color:USAGE_COLORS.errored})]})}function LostCell(props){if(0===props.count)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",children:"—"});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",style:{fontVariantNumeric:"tabular-nums",color:USAGE_COLORS.errored,fontWeight:600},children:formatCount(props.count)})}function TopCompaniesTable(props){const{rows,totalHours}=props;const max=rows.length>0?rows[0].computeHours:0;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{highlightOnHover:true,striped:false,verticalSpacing:"xs",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:32,children:"#"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Entreprise"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:150,children:"Part"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:90,ta:"right",children:"Compute"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:70,ta:"right",children:"% total"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:100,ta:"right",children:"Tâches"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:80,ta:"right",children:"Perdues"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:rows.map((row,index)=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{c:"dimmed",children:index+1}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Td,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:500,children:row.displayName??row.slug??`#${row.companyId}`}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:row.slug??`company ${row.companyId}`})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{withArrow:true,label:`${formatHours(row.erroredHours)} en erreur sur ${formatHours(row.computeHours)}`,children:/*#__PURE__*/(0,jsx_runtime.jsx)("div",{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ShareBar,{hours:row.computeHours,erroredHours:row.erroredHours,max:max})})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",style:{fontVariantNumeric:"tabular-nums"},children:formatHours(row.computeHours)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",style:{fontVariantNumeric:"tabular-nums"},children:totalHours>0?`${Math.round(row.computeHours/totalHours*100)} %`:"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",style:{fontVariantNumeric:"tabular-nums"},children:formatCount(row.tasks)}),/*#__PURE__*/(0,jsx_runtime.jsx)(LostCell,{count:row.abandonedTasks})]},row.companyId))})]})}function TopJobsTable(props){const{rows,totalHours}=props;const max=rows.length>0?rows[0].computeHours:0;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{highlightOnHover:true,verticalSpacing:"xs",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:32,children:"#"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Connecteur"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:150,children:"Part"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:90,ta:"right",children:"Compute"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:70,ta:"right",children:"% total"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:110,ta:"right",children:"h / entreprise"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:80,ta:"right",children:"Perdues"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:rows.map((row,index)=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{c:"dimmed",children:index+1}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Td,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:500,children:row.jobName}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",c:"dimmed",children:[formatCount(row.companies)," entreprise",row.companies>1?"s":""," · ",formatCount(row.tasks)," tâches"]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{withArrow:true,label:`${formatHours(row.erroredHours)} en erreur sur ${formatHours(row.computeHours)}`,children:/*#__PURE__*/(0,jsx_runtime.jsx)("div",{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ShareBar,{hours:row.computeHours,erroredHours:row.erroredHours,max:max})})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",style:{fontVariantNumeric:"tabular-nums"},children:formatHours(row.computeHours)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",style:{fontVariantNumeric:"tabular-nums"},children:totalHours>0?`${Math.round(row.computeHours/totalHours*100)} %`:"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",style:{fontVariantNumeric:"tabular-nums"},children:row.companies>0?formatHours(row.computeHours/row.companies):"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(LostCell,{count:row.abandonedTasks})]},row.jobName))})]})}var date_fns_index_js_=__webpack_require__(1917);function shiftPeriod(view,at,direction){if("week"===view)return(0,date_fns_index_js_.addWeeks)(at,direction);if("month"===view)return(0,date_fns_index_js_.addMonths)(at,direction);if("year"===view)return(0,date_fns_index_js_.addMonths)(at,12*direction);return(0,date_fns_index_js_.addDays)(at,direction)}function canGoForward(view,at,now){return shiftPeriod(view,at,1).getTime()<=now.getTime()}const RESET_LABEL={day:"Aujourd'hui",week:"Cette semaine",month:"Ce mois",year:"12 derniers mois"};const VIEW_OPTIONS=[{value:"day",label:"Jour"},{value:"week",label:"Semaine"},{value:"month",label:"Mois"},{value:"year",label:"12 mois"}];const CHART_TITLES={day:"Tâches simultanées, minute par minute",week:"Compute par jour (lundi → dimanche)",month:"Compute par jour du mois",year:"Compute par mois"};function SectionTitle(props){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"baseline",mb:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:600,children:props.children}),props.hint?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:props.hint}):null]})}function UsageApp(){const[view,setView]=(0,index_js_.useState)("day");const[at,setAt]=(0,index_js_.useState)(null);const[trigger,setTrigger]=(0,index_js_.useState)("all");const charge=useUsageCharge(view,trigger,at?at.toISOString():void 0);const prefetch=useUsageChargePrefetch();const data=charge.data;const reference=at??new Date;const forwardDisabled=null===at||!canGoForward(view,reference,new Date);(0,index_js_.useEffect)(()=>{if(charge.isFetching)return;const previous=shiftPeriod(view,at??new Date,-1);prefetch(view,trigger,previous.toISOString())},[view,at,trigger,charge.isFetching]);const goto=direction=>{const next=shiftPeriod(view,reference,direction);setAt(next)};const changeView=next=>{setView(next);setAt(null)};return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Container,{fluid:true,my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"lg",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(PageHeader.z,{title:"Usage & charge",updatedAt:charge.dataUpdatedAt,isFetching:charge.isFetching,isError:charge.isError,onRefresh:()=>charge.refetch()}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"center",wrap:"wrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"md",align:"center",wrap:"wrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:view,onChange:value=>changeView(value),data:VIEW_OPTIONS}),/*#__PURE__*/(0,jsx_runtime.jsx)(TriggerFilter,{value:trigger,onChange:setTrigger})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",align:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default",size:"lg","aria-label":"Période précédente",onClick:()=>goto(-1),children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronLeft,{size:18})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",ta:"center",miw:280,children:data?`${formatWindow(data.from,data.to,data.view)} \xb7 heure de Paris`:"…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default",size:"lg","aria-label":"Période suivante",disabled:forwardDisabled,onClick:()=>goto(1),children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronRight,{size:18})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",color:"gray",size:"xs",disabled:null===at,onClick:()=>setAt(null),children:RESET_LABEL[view]})]})]}),charge.isError?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Alert,{color:"red",title:"Impossible de charger la charge",children:String(charge.error)}):null,data?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"lg",style:{opacity:charge.isPlaceholderData?.45:1,transition:"opacity 150ms ease",pointerEvents:charge.isPlaceholderData?"none":void 0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(UsageKpiRow,{kpis:data.kpis}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"day"===view?"durée bornée à 110 min — au-delà, une tâche est perdue, pas en cours":"heures de compute, décomposées par issue",children:CHART_TITLES[view]}),"day"===view?/*#__PURE__*/(0,jsx_runtime.jsx)(ConcurrencyChart,{data:data.concurrency}):/*#__PURE__*/(0,jsx_runtime.jsx)(ChargeStack,{buckets:data.buckets,view:data.view})]}),"year"===view?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"deux dénombrements, un seul axe",children:"Traction — entreprises actives et connecteurs"}),/*#__PURE__*/(0,jsx_runtime.jsx)(TractionChart,{buckets:data.buckets})]}):null,"day"===view&&data.buckets.length>0?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"décomposition du compute de la journée",children:"Compute de la journée"}),/*#__PURE__*/(0,jsx_runtime.jsx)(ChargeStack,{buckets:data.buckets,view:data.view})]}):null,data.buckets.length>1?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"création → exécution, sur les tâches réellement exécutées",children:"Délai de mise en route"}),/*#__PURE__*/(0,jsx_runtime.jsx)(ServiceLevelChart,{buckets:data.buckets,view:data.view})]}):null,data.kpis.abandonedTasks>0?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"abandonnées après 3 déblocages, sans jamais avoir tourné",children:"Synchros perdues"}),/*#__PURE__*/(0,jsx_runtime.jsx)(AbandonedChart,{buckets:data.buckets,view:data.view})]}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Grid,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:12,lg:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",h:"100%",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"classement, pas de moyenne",children:"Top consommateurs"}),/*#__PURE__*/(0,jsx_runtime.jsx)(TopCompaniesTable,{rows:data.topCompanies,totalHours:data.kpis.computeHours})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:12,lg:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",h:"100%",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"brique de tarification du free",children:"Coût par connecteur"}),/*#__PURE__*/(0,jsx_runtime.jsx)(TopJobsTable,{rows:data.topJobs,totalHours:data.kpis.computeHours})]})})]})]}):/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:96}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:300})]})]})})}function Usage(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.b,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(UsageApp,{})})})}}}]);
|
|
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},4848(module,__unused_rspack_exports,__webpack_require__){module.exports=__webpack_require__(9698)},7483(__unused_rspack_module,__webpack_exports__,__webpack_require__){var react_jsx_runtime__rspack_import_0=__webpack_require__(4848);var _mantine_core__rspack_import_1=__webpack_require__(4618);var _tabler_icons_react__rspack_import_2=__webpack_require__(2638);var react__rspack_import_3=__webpack_require__(814);function formatRelative(now,then){const seconds=Math.max(0,Math.floor((now-then)/1e3));if(seconds<5)return"à l’instant";if(seconds<60)return`il y a ${seconds}s`;const minutes=Math.floor(seconds/60);if(minutes<60)return`il y a ${minutes} min`;const hours=Math.floor(minutes/60);return`il y a ${hours} h`}function PageHeader({title,leading,badge,updatedAt,isFetching,isError,onRefresh,actions}){const[now,setNow]=(0,react__rspack_import_3.useState)(()=>Date.now());(0,react__rspack_import_3.useEffect)(()=>{if(!updatedAt)return;const id=window.setInterval(()=>setNow(Date.now()),1e3);return()=>window.clearInterval(id)},[updatedAt]);const relative=updatedAt?formatRelative(now,updatedAt):null;const color=isError?"orange":isFetching?"teal":"dimmed";return/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsxs)(_mantine_core__rspack_import_1.Group,{justify:"space-between",align:"center",mih:48,mb:"md",children:[/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsxs)(_mantine_core__rspack_import_1.Group,{gap:"sm",align:"center",children:[leading,/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsx)(_mantine_core__rspack_import_1.Title,{order:2,children:title}),badge]}),/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsxs)(_mantine_core__rspack_import_1.Group,{gap:"sm",align:"center",children:[relative&&/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsx)(_mantine_core__rspack_import_1.Text,{size:"xs",c:color,fw:isFetching?600:400,"data-testid":"page-header-freshness",children:isError?"échec maj":isFetching?"maj…":relative}),onRefresh&&/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsx)(_mantine_core__rspack_import_1.Tooltip,{label:"Rafraîchir",children:/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsx)(_mantine_core__rspack_import_1.ActionIcon,{variant:"default",size:"md",onClick:onRefresh,loading:isFetching,"aria-label":"Refresh",children:/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsx)(_tabler_icons_react__rspack_import_2.IconRefresh,{size:16})})}),actions]})]})}__webpack_require__.d(__webpack_exports__,{z:()=>PageHeader})},6066(__unused_rspack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Usage});var jsx_runtime=__webpack_require__(4848);var index_js_=__webpack_require__(814);var providers=__webpack_require__(9528);var index_mjs_=__webpack_require__(4618);var tabler_icons_react_mjs_=__webpack_require__(2638);var modern_index_js_=__webpack_require__(3411);var useApi=__webpack_require__(4691);const STALE_MS=6e4;const DAY_REFETCH_MS=3e5;function chargeKey(view,trigger,at){return["tech","usage","charge",view,trigger,at??null]}function chargeParams(view,trigger,at){return{view,..."all"===trigger?{}:{trigger},...at?{at}:{}}}function useUsageCharge(view,trigger,at){const api=(0,useApi.g)();return(0,modern_index_js_.useQuery)({queryKey:chargeKey(view,trigger,at),queryFn:async()=>{const response=await api.http.request({path:"/v1/usage/charge",method:"GET",query:chargeParams(view,trigger,at),format:"json"});return response.data},placeholderData:modern_index_js_.keepPreviousData,staleTime:STALE_MS,refetchInterval:"day"===view?DAY_REFETCH_MS:false,refetchOnWindowFocus:false})}function useUsageChargePrefetch(){const api=(0,useApi.g)();const queryClient=(0,modern_index_js_.useQueryClient)();return(view,trigger,at)=>{queryClient.prefetchQuery({queryKey:chargeKey(view,trigger,at),queryFn:async()=>{const response=await api.http.request({path:"/v1/usage/charge",method:"GET",query:chargeParams(view,trigger,at),format:"json"});return response.data},staleTime:STALE_MS})}}var PageHeader=__webpack_require__(7483);const OPTIONS=[{value:"all",label:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"Tout"})},{value:"auto",label:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconRobot,{size:16,stroke:1.5}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"Robots"})]})},{value:"human",label:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconUser,{size:16,stroke:1.5}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:"Humains"})]})}];const HINT="Robots = planificateur et crons dédiés. Humains = run lancé depuis l’app ; c’est un plancher, les runs passés par l’ancienne API sont comptés comme planifiés.";function TriggerFilter(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:HINT,multiline:true,w:320,withArrow:true,position:"bottom",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:props.value,onChange:next=>props.onChange(next),data:OPTIONS,size:"xs"})})}const USAGE_COLORS={productive:"#3987e5",errored:"#d03b3b",noop:"#fab219"};const AXIS_INK="#898781";function formatHours(hours){if(hours>=100)return`${Math.round(hours)} h`;return`${hours.toFixed(1).replace(".",",")} h`}function formatCount(value){return new Intl.NumberFormat("fr-FR").format(value)}function formatCompactCount(value){return new Intl.NumberFormat("fr-FR",{notation:"compact",maximumFractionDigits:1}).format(value)}function servicePercent(under,measured){if(measured<=0)return 0;return Math.round(under/measured*100)}function wastePercent(kpis){if(kpis.computeHours<=0)return 0;return Math.round((kpis.erroredHours+kpis.noopHours)/kpis.computeHours*100)}function UsageKpiRow(props){const{kpis}=props;const tiles=[{key:"compute",label:"Compute",value:formatHours(kpis.computeHours),hint:`${formatCount(kpis.tasks)} t\xe2ches, dont ${formatCount(kpis.worksheetTasks)} worksheets`},{key:"companies",label:"Entreprises actives",value:formatCount(kpis.companies),hint:`${formatCount(kpis.distinctJobs)} connecteurs distincts`},{key:"waste",label:"Compute non productif",value:`${formatHours(kpis.erroredHours+kpis.noopHours)} \xb7 ${wastePercent(kpis)} %`,hint:`${formatHours(kpis.erroredHours)} en erreur (${formatCount(kpis.erroredTasks)} t\xe2ches), ${formatHours(kpis.noopHours)} sans r\xe9sultat`,accent:USAGE_COLORS.errored},{key:"concurrency",label:"Concurrence max",value:null===kpis.maxConcurrent?"—":`${formatCount(kpis.maxConcurrent)} t\xe2ches`,hint:null===kpis.maxConcurrent?"Non calculé sur 12 mois : trop coûteux à recouvrir":"Pic de tâches simultanées, durée bornée à 110 min"},{key:"service",label:"Démarrage < 15 min",value:kpis.waitMeasured>0?`${servicePercent(kpis.waitLe15,kpis.waitMeasured)} %`:"—",hint:kpis.waitMeasured>0?`${servicePercent(kpis.waitLe30,kpis.waitMeasured)} % sous 30 min, ${servicePercent(kpis.waitLe60,kpis.waitMeasured)} % sous 1 h, ${servicePercent(kpis.waitLe240,kpis.waitMeasured)} % sous 4 h — sur ${formatCount(kpis.waitMeasured)} t\xe2ches r\xe9ellement ex\xe9cut\xe9es`:"Aucune tâche exécutée sur la période"},{key:"abandoned",label:"Synchros perdues",value:formatCount(kpis.abandonedTasks),hint:0===kpis.abandonedTasks?"Aucune synchro abandonnée sur la période":`Abandonn\xe9es apr\xe8s 3 d\xe9blocages, sans jamais avoir tourn\xe9. ${formatHours(kpis.abandonedFabricatedHours)} de dur\xe9e fictive exclues du compute.`,accent:kpis.abandonedTasks>0?USAGE_COLORS.errored:void 0},{key:"rows",label:"Lignes synchronisées",value:formatCompactCount(kpis.rowsSynced),hint:"Somme des compteurs renvoyés par les jobs — proxy de tendance"}];return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:{base:1,sm:2,md:3,lg:4,xl:7},spacing:"md",children:tiles.map(tile=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,align:"center",mb:6,children:[tile.accent?/*#__PURE__*/(0,jsx_runtime.jsx)("span",{"aria-hidden":true,style:{width:8,height:8,borderRadius:2,background:tile.accent,display:"inline-block"}}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",tt:"uppercase",fw:700,children:tile.label})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:tile.hint,withArrow:true,multiline:true,w:260,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fz:26,fw:600,lh:1.1,children:tile.value})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",mt:6,lineClamp:2,children:tile.hint})]},tile.key))})}var esm_index_mjs_=__webpack_require__(7194);const PARIS_TZ="Europe/Paris";const minuteFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:PARIS_TZ,hour:"2-digit",minute:"2-digit"});const weekDayFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:PARIS_TZ,weekday:"short",day:"numeric"});const monthFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:PARIS_TZ,month:"short",year:"2-digit"});const fullDayFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:PARIS_TZ,weekday:"long",day:"numeric",month:"long"});function bucketDate(t){if(7===t.length)return new Date(`${t}-15T12:00:00Z`);return new Date(`${t}T12:00:00Z`)}function formatMinuteTick(iso){return minuteFormatter.format(new Date(iso))}function formatBucketTick(t,view){if("year"===view)return monthFormatter.format(bucketDate(t));if("month"===view)return String(bucketDate(t).getUTCDate());return weekDayFormatter.format(bucketDate(t))}function formatBucketLong(t,view){if("year"===view)return monthFormatter.format(bucketDate(t));return fullDayFormatter.format(bucketDate(t))}function formatWindow(from,to,view){if("day"===view)return fullDayFormatter.format(new Date(from));if("year"===view){const start=monthFormatter.format(new Date(from));const end=monthFormatter.format(new Date(new Date(to).getTime()-1));return`${start} → ${end}`}const start=fullDayFormatter.format(new Date(from));const end=fullDayFormatter.format(new Date(new Date(to).getTime()-1));return`${start} → ${end}`}function ConcurrencyTooltip({payload}){const point=payload?.[0]?.payload;if(!point)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{px:"md",py:"sm",withBorder:true,shadow:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,mb:4,children:formatMinuteTick(point.t)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:[point.concurrent," tâche",point.concurrent>1?"s":""," en cours"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:[point.started," démarrage",point.started>1?"s":""]}),point.errored>0?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:USAGE_COLORS.errored,children:[point.errored," en erreur"]}):null]})}function ConcurrencyChart(props){const{data}=props;if(0===data.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Aucune tâche sur la journée."});return/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.AreaChart,{h:260,data:data,dataKey:"t",withDots:false,strokeWidth:2,curveType:"linear",gridAxis:"y",tickLine:"none",series:[{name:"concurrent",label:"Tâches en cours",color:USAGE_COLORS.productive}],xAxisProps:{tickFormatter:formatMinuteTick,minTickGap:48,stroke:AXIS_INK},yAxisProps:{allowDecimals:false,stroke:AXIS_INK,width:32},tooltipProps:{content:ConcurrencyTooltip},tooltipAnimationDuration:0})}const SURFACE="var(--mantine-color-body)";const SERIES=[{name:"productiveHours",label:"Productif",color:USAGE_COLORS.productive},{name:"noopHours",label:"Sans résultat",color:USAGE_COLORS.noop},{name:"erroredHours",label:"En erreur",color:USAGE_COLORS.errored}];const TOP_SERIES=SERIES[SERIES.length-1].name;function makeTooltip(view){return function({payload}){const bucket=payload?.[0]?.payload;if(!bucket)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{px:"md",py:"sm",withBorder:true,shadow:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,mb:4,children:formatBucketLong(bucket.t,view)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:[formatHours(bucket.computeHours)," de compute"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:USAGE_COLORS.errored,children:["dont ",formatHours(bucket.erroredHours)," en erreur (",formatCount(bucket.erroredTasks)," tâches)"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:["dont ",formatHours(bucket.noopHours)," sans résultat"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",mt:4,children:[formatCount(bucket.tasks)," tâches ·"," ",formatCount(bucket.worksheetTasks)," worksheets"]}),bucket.waitMaxMinutes?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:["attente max ",Math.round(bucket.waitMaxMinutes)," min"]}):null]})}}function ChargeStack(props){const{buckets,view}=props;if(0===buckets.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Aucune tâche sur la période."});return/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.BarChart,{h:300,data:buckets,dataKey:"t",type:"stacked",withLegend:true,legendProps:{verticalAlign:"top",height:32},gridAxis:"y",tickLine:"none",unit:" h",series:SERIES,barProps:item=>({stroke:SURFACE,strokeWidth:1.5,strokeOpacity:1,radius:item.name===TOP_SERIES?[4,4,0,0]:0}),xAxisProps:{tickFormatter:t=>formatBucketTick(t,view),stroke:AXIS_INK,minTickGap:4},yAxisProps:{stroke:AXIS_INK,width:44},tooltipProps:{content:makeTooltip(view)},tooltipAnimationDuration:0})}function AbandonedChart_makeTooltip(view){return function({payload}){const bucket=payload?.[0]?.payload;if(!bucket)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{px:"md",py:"sm",withBorder:true,shadow:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,mb:4,children:formatBucketLong(bucket.t,view)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:USAGE_COLORS.errored,children:[formatCount(bucket.abandonedTasks)," synchro",bucket.abandonedTasks>1?"s":""," perdue",bucket.abandonedTasks>1?"s":""]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:["sur ",formatCount(bucket.tasks)," tâches créées"]})]})}}function AbandonedChart(props){const{buckets,view}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.BarChart,{h:180,data:buckets,dataKey:"t",gridAxis:"y",tickLine:"none",series:[{name:"abandonedTasks",label:"Synchros perdues",color:USAGE_COLORS.errored}],barProps:{radius:[4,4,0,0]},xAxisProps:{tickFormatter:t=>formatBucketTick(t,view),stroke:AXIS_INK,minTickGap:4},yAxisProps:{stroke:AXIS_INK,width:44,allowDecimals:false},tooltipProps:{content:AbandonedChart_makeTooltip(view)},tooltipAnimationDuration:0})}function toPoints(buckets){return buckets.map(b=>({t:b.t,service:servicePercent(b.waitLe15,b.waitMeasured),under30:servicePercent(b.waitLe30,b.waitMeasured),under60:servicePercent(b.waitLe60,b.waitMeasured),measured:b.waitMeasured}))}function ServiceLevelChart_makeTooltip(view){return function({payload}){const point=payload?.[0]?.payload;if(!point)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{px:"md",py:"sm",withBorder:true,shadow:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,mb:4,children:formatBucketLong(point.t,view)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:USAGE_COLORS.productive,children:[point.service," % démarrées sous ",15," min"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:[point.under30," % sous 30 min · ",point.under60," % sous 1 h"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",mt:4,children:["sur ",formatCount(point.measured)," tâches exécutées"]})]})}}function ServiceLevelChart(props){const{buckets,view}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.LineChart,{h:180,data:toPoints(buckets),dataKey:"t",gridAxis:"y",tickLine:"none",unit:" %",withDots:buckets.length<=40,series:[{name:"service",label:"Démarrées sous 15 min",color:USAGE_COLORS.productive}],xAxisProps:{tickFormatter:t=>formatBucketTick(t,view),stroke:AXIS_INK,minTickGap:4},yAxisProps:{stroke:AXIS_INK,width:48,domain:[0,100],allowDecimals:false},tooltipProps:{content:ServiceLevelChart_makeTooltip(view)},tooltipAnimationDuration:0})}const TRACTION_SERIES=[{name:"companies",label:"Entreprises actives",color:"#3987e5"},{name:"distinctJobs",label:"Connecteurs distincts",color:"#d95926"}];function TractionTooltip({payload}){const bucket=payload?.[0]?.payload;if(!bucket)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{px:"md",py:"sm",withBorder:true,shadow:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,mb:4,children:formatBucketLong(bucket.t,"year")}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:[bucket.companies??0," entreprises actives"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:[bucket.distinctJobs??0," connecteurs distincts"]})]})}function TractionChart(props){const{buckets}=props;if(0===buckets.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Pas d'historique sur la période."});return/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.LineChart,{h:240,data:buckets,dataKey:"t",withLegend:true,legendProps:{verticalAlign:"top",height:32},strokeWidth:2,dotProps:{r:4},activeDotProps:{r:6},gridAxis:"y",tickLine:"none",series:TRACTION_SERIES,xAxisProps:{tickFormatter:t=>formatBucketTick(t,"year"),stroke:AXIS_INK},yAxisProps:{allowDecimals:false,stroke:AXIS_INK,width:40},tooltipProps:{content:TractionTooltip},tooltipAnimationDuration:0})}function ShareBar(props){const{hours,erroredHours,max}=props;if(max<=0)return null;const total=hours/max*100;const errored=Math.min(erroredHours,hours)/max*100;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Progress.Root,{size:"md",w:140,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Progress.Section,{value:Math.max(total-errored,0),color:USAGE_COLORS.productive}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Progress.Section,{value:errored,color:USAGE_COLORS.errored})]})}function LostCell(props){if(0===props.count)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",children:"—"});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",style:{fontVariantNumeric:"tabular-nums",color:USAGE_COLORS.errored,fontWeight:600},children:formatCount(props.count)})}function TopCompaniesTable(props){const{rows,totalHours}=props;const max=rows.length>0?rows[0].computeHours:0;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{highlightOnHover:true,striped:false,verticalSpacing:"xs",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:32,children:"#"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Entreprise"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:150,children:"Part"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:90,ta:"right",children:"Compute"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:70,ta:"right",children:"% total"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:100,ta:"right",children:"Tâches"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:80,ta:"right",children:"Perdues"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:rows.map((row,index)=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{c:"dimmed",children:index+1}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Td,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:500,children:row.displayName??row.slug??`#${row.companyId}`}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:row.slug??`company ${row.companyId}`})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{withArrow:true,label:`${formatHours(row.erroredHours)} en erreur sur ${formatHours(row.computeHours)}`,children:/*#__PURE__*/(0,jsx_runtime.jsx)("div",{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ShareBar,{hours:row.computeHours,erroredHours:row.erroredHours,max:max})})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",style:{fontVariantNumeric:"tabular-nums"},children:formatHours(row.computeHours)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",style:{fontVariantNumeric:"tabular-nums"},children:totalHours>0?`${Math.round(row.computeHours/totalHours*100)} %`:"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",style:{fontVariantNumeric:"tabular-nums"},children:formatCount(row.tasks)}),/*#__PURE__*/(0,jsx_runtime.jsx)(LostCell,{count:row.abandonedTasks})]},row.companyId))})]})}function TopJobsTable(props){const{rows,totalHours}=props;const max=rows.length>0?rows[0].computeHours:0;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{highlightOnHover:true,verticalSpacing:"xs",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:32,children:"#"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Connecteur"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:150,children:"Part"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:90,ta:"right",children:"Compute"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:70,ta:"right",children:"% total"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:110,ta:"right",children:"h / entreprise"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:80,ta:"right",children:"Perdues"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:rows.map((row,index)=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{c:"dimmed",children:index+1}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Td,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:500,children:row.jobName}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",c:"dimmed",children:[formatCount(row.companies)," entreprise",row.companies>1?"s":""," · ",formatCount(row.tasks)," tâches"]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{withArrow:true,label:`${formatHours(row.erroredHours)} en erreur sur ${formatHours(row.computeHours)}`,children:/*#__PURE__*/(0,jsx_runtime.jsx)("div",{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ShareBar,{hours:row.computeHours,erroredHours:row.erroredHours,max:max})})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",style:{fontVariantNumeric:"tabular-nums"},children:formatHours(row.computeHours)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",style:{fontVariantNumeric:"tabular-nums"},children:totalHours>0?`${Math.round(row.computeHours/totalHours*100)} %`:"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",style:{fontVariantNumeric:"tabular-nums"},children:row.companies>0?formatHours(row.computeHours/row.companies):"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(LostCell,{count:row.abandonedTasks})]},row.jobName))})]})}var date_fns_index_js_=__webpack_require__(8680);function shiftPeriod(view,at,direction){if("week"===view)return(0,date_fns_index_js_.addWeeks)(at,direction);if("month"===view)return(0,date_fns_index_js_.addMonths)(at,direction);if("year"===view)return(0,date_fns_index_js_.addMonths)(at,12*direction);return(0,date_fns_index_js_.addDays)(at,direction)}function canGoForward(view,at,now){return shiftPeriod(view,at,1).getTime()<=now.getTime()}const RESET_LABEL={day:"Aujourd'hui",week:"Cette semaine",month:"Ce mois",year:"12 derniers mois"};const VIEW_OPTIONS=[{value:"day",label:"Jour"},{value:"week",label:"Semaine"},{value:"month",label:"Mois"},{value:"year",label:"12 mois"}];const CHART_TITLES={day:"Tâches simultanées, minute par minute",week:"Compute par jour (lundi → dimanche)",month:"Compute par jour du mois",year:"Compute par mois"};function SectionTitle(props){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"baseline",mb:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:600,children:props.children}),props.hint?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:props.hint}):null]})}function UsageApp(){const[view,setView]=(0,index_js_.useState)("day");const[at,setAt]=(0,index_js_.useState)(null);const[trigger,setTrigger]=(0,index_js_.useState)("all");const charge=useUsageCharge(view,trigger,at?at.toISOString():void 0);const prefetch=useUsageChargePrefetch();const data=charge.data;const reference=at??new Date;const forwardDisabled=null===at||!canGoForward(view,reference,new Date);(0,index_js_.useEffect)(()=>{if(charge.isFetching)return;const previous=shiftPeriod(view,at??new Date,-1);prefetch(view,trigger,previous.toISOString())},[view,at,trigger,charge.isFetching]);const goto=direction=>{const next=shiftPeriod(view,reference,direction);setAt(next)};const changeView=next=>{setView(next);setAt(null)};return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Container,{fluid:true,my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"lg",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(PageHeader.z,{title:"Usage & charge",updatedAt:charge.dataUpdatedAt,isFetching:charge.isFetching,isError:charge.isError,onRefresh:()=>charge.refetch()}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"center",wrap:"wrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"md",align:"center",wrap:"wrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:view,onChange:value=>changeView(value),data:VIEW_OPTIONS}),/*#__PURE__*/(0,jsx_runtime.jsx)(TriggerFilter,{value:trigger,onChange:setTrigger})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",align:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default",size:"lg","aria-label":"Période précédente",onClick:()=>goto(-1),children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronLeft,{size:18})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",ta:"center",miw:280,children:data?`${formatWindow(data.from,data.to,data.view)} \xb7 heure de Paris`:"…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default",size:"lg","aria-label":"Période suivante",disabled:forwardDisabled,onClick:()=>goto(1),children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronRight,{size:18})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",color:"gray",size:"xs",disabled:null===at,onClick:()=>setAt(null),children:RESET_LABEL[view]})]})]}),charge.isError?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Alert,{color:"red",title:"Impossible de charger la charge",children:String(charge.error)}):null,data?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"lg",style:{opacity:charge.isPlaceholderData?.45:1,transition:"opacity 150ms ease",pointerEvents:charge.isPlaceholderData?"none":void 0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(UsageKpiRow,{kpis:data.kpis}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"day"===view?"durée bornée à 110 min — au-delà, une tâche est perdue, pas en cours":"heures de compute, décomposées par issue",children:CHART_TITLES[view]}),"day"===view?/*#__PURE__*/(0,jsx_runtime.jsx)(ConcurrencyChart,{data:data.concurrency}):/*#__PURE__*/(0,jsx_runtime.jsx)(ChargeStack,{buckets:data.buckets,view:data.view})]}),"year"===view?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"deux dénombrements, un seul axe",children:"Traction — entreprises actives et connecteurs"}),/*#__PURE__*/(0,jsx_runtime.jsx)(TractionChart,{buckets:data.buckets})]}):null,"day"===view&&data.buckets.length>0?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"décomposition du compute de la journée",children:"Compute de la journée"}),/*#__PURE__*/(0,jsx_runtime.jsx)(ChargeStack,{buckets:data.buckets,view:data.view})]}):null,data.buckets.length>1?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"création → exécution, sur les tâches réellement exécutées",children:"Délai de mise en route"}),/*#__PURE__*/(0,jsx_runtime.jsx)(ServiceLevelChart,{buckets:data.buckets,view:data.view})]}):null,data.kpis.abandonedTasks>0?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"abandonnées après 3 déblocages, sans jamais avoir tourné",children:"Synchros perdues"}),/*#__PURE__*/(0,jsx_runtime.jsx)(AbandonedChart,{buckets:data.buckets,view:data.view})]}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Grid,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:12,lg:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",h:"100%",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"classement, pas de moyenne",children:"Top consommateurs"}),/*#__PURE__*/(0,jsx_runtime.jsx)(TopCompaniesTable,{rows:data.topCompanies,totalHours:data.kpis.computeHours})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:12,lg:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",h:"100%",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"brique de tarification du free",children:"Coût par connecteur"}),/*#__PURE__*/(0,jsx_runtime.jsx)(TopJobsTable,{rows:data.topJobs,totalHours:data.kpis.computeHours})]})})]})]}):/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:96}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:300})]})]})})}function Usage(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.b,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(UsageApp,{})})})}}}]);
|