"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[38919],{36041:function(e,t,n){n.r(t),n.d(t,{Component:function(){return H}});var r=n(62540),a=n(63696),i=n(65242),o=n(5898),l=n(92779),s=n(70140);function c(e,t){return e?e.filter((function(e){return e.Category==t})).sort((function(e,t){var n;return e.Name&&t.Name?null===(n=e.Name)||void 0===n?void 0:n.localeCompare(t.Name):0})):[]}var u=n(84849),d=n(28335),f=n(89348),y=n(35117),x=n(69018),h=n(98634),A=n(73828),m=n(60434),v=n(13478),p=n(41906),b=n(34401),j=n(80096),g=n(52457),k=function(e){var t,n,i=e.task,l=(0,p.Y)().dateFnsLocale,s=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,i=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)o.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(a)throw a.error}}return o}((0,a.useMemo)((function(){var e,t;if((null===(e=i.LastExecutionResult)||void 0===e?void 0:e.StartTimeUtc)&&(null===(t=i.LastExecutionResult)||void 0===t?void 0:t.EndTimeUtc)){var n=(0,b.A)(i.LastExecutionResult.EndTimeUtc),r=(0,b.A)(i.LastExecutionResult.StartTimeUtc);return[(0,j.A)(n,{locale:l,addSuffix:!0}),(0,g.A)(r,n,{locale:l})]}return[]}),[i,l]),2),c=s[0],u=s[1];if("Idle"!=i.State)return(0,r.jsx)(f.A,{sx:{color:"text.secondary"},children:o.Ay.translate("LabelStopping")});if((null===(t=i.LastExecutionResult)||void 0===t?void 0:t.StartTimeUtc)&&(null===(n=i.LastExecutionResult)||void 0===n?void 0:n.EndTimeUtc)){var d=i.LastExecutionResult.Status;return(0,r.jsxs)(f.A,{sx:{lineHeight:"1.2rem",color:"text.secondary"},variant:"body1",children:[o.Ay.translate("LabelScheduledTaskLastRan",c,u),"Failed"==d&&(0,r.jsx)(f.A,{display:"inline",color:"error",children:" (".concat(o.Ay.translate("LabelFailed"),")")}),"Cancelled"==d&&(0,r.jsx)(f.A,{display:"inline",color:"blue",children:" (".concat(o.Ay.translate("LabelCancelled"),")")}),"Aborted"==d&&(0,r.jsx)(f.A,{display:"inline",color:"error",children:" (".concat(o.Ay.translate("LabelAbortedByServerShutdown"),")")})]})}},S=n(75487),C=n(2066),L=n(7729),T=n(22204),E=n(53875),R=n(38596),I=n(69410),N=n(31297),w=n(71607),U=n(95858),P=function(e){var t,n=e.task,i=(0,T.V)(),o=(t=(0,I.gf)().api,(0,R.n)({mutationFn:function(e){return(0,E.g)(t).stopTask(e)},onSuccess:function(){N.q.invalidateQueries({queryKey:[w.t]})}})),l=(0,a.useCallback)((function(){n.Id&&i.mutate({taskId:n.Id})}),[n,i]),s=(0,a.useCallback)((function(){n.Id&&o.mutate({taskId:n.Id})}),[n,o]);return(0,r.jsx)(y.Ay,{disablePadding:!0,secondaryAction:(0,r.jsx)(S.A,{onClick:"Running"==n.State?s:l,children:"Running"==n.State?(0,r.jsx)(L.A,{}):(0,r.jsx)(C.A,{})}),children:(0,r.jsxs)(U.A,{to:"/dashboard/tasks/".concat(n.Id),children:[(0,r.jsx)(A.A,{children:(0,r.jsx)(x.A,{sx:{bgcolor:"primary.main"},children:(0,r.jsx)(h.A,{sx:{color:"#fff"}})})}),(0,r.jsx)(m.A,{primary:(0,r.jsx)(f.A,{variant:"h3",children:n.Name}),secondary:"Running"==n.State?(0,r.jsx)(v.A,{task:n}):(0,r.jsx)(k,{task:n}),disableTypography:!0})]})})},F=function(e){var t=e.category,n=e.tasks;return(0,r.jsxs)(s.A,{spacing:2,children:[(0,r.jsx)(f.A,{variant:"h2",children:t}),(0,r.jsx)(d.A,{sx:{bgcolor:"background.paper"},children:n.map((function(e){return(0,r.jsx)(P,{task:e},e.Id)}))})]})},q=n(54861),H=function(){var e=(0,q.A)({isHidden:!1}),t=e.data;if(e.isPending||!t)return(0,r.jsx)(u.A,{});var n=function(e){var t,n;if(!e)return[];var r=[];try{for(var a=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),i=a.next();!i.done;i=a.next()){var o=i.value;o.Category&&!r.includes(o.Category)&&r.push(o.Category)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return r.sort((function(e,t){return e.localeCompare(t)}))}(t);return(0,r.jsx)(i.A,{id:"scheduledTasksPage",title:o.Ay.translate("TabScheduledTasks"),className:"mainAnimatedPage type-interior",children:(0,r.jsx)(l.A,{className:"content-primary",children:(0,r.jsx)(l.A,{className:"readOnlyContent",children:(0,r.jsx)(s.A,{spacing:3,mt:2,children:n.map((function(e){return(0,r.jsx)(F,{category:e,tasks:c(t,e)},e)}))})})})})};H.displayName="TasksPage"}}]);