Skip to content

Commit

Permalink
Merge pull request #1818 from Inist-CNRS/fix/precomputed-timer
Browse files Browse the repository at this point in the history
fix(precomputed): Add direct timer on precomputed progress display
  • Loading branch information
arimet authored Dec 4, 2023
2 parents eb62c7c + 58c63eb commit 0da82a7
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions src/app/js/admin/precomputed/PrecomputedForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,7 @@ export const renderStatus = (status, polyglot, startedAt = null) => {
);
}
if (status === IN_PROGRESS) {
return (
<Chip
component="span"
label={`${polyglot.t(
'precomputed_status_running',
)} (${getDisplayTimeStartedAt(startedAt)})`}
color="info"
/>
);
return <ProgressChip polyglot={polyglot} startedAt={startedAt} />;
}

if (status === PAUSED) {
Expand Down Expand Up @@ -171,6 +163,30 @@ export const renderStatus = (status, polyglot, startedAt = null) => {
);
};

export const ProgressChip = ({ polyglot, startedAt }) => {
const [spentTime, setSpentTime] = useState(
getDisplayTimeStartedAt(startedAt),
);
useEffect(() => {
const interval = setInterval(() => {
setSpentTime(getDisplayTimeStartedAt(startedAt));
}, 59000);
return () => clearInterval(interval);
}, []);
return (
<Chip
component="span"
label={`${polyglot.t('precomputed_status_running')} (${spentTime})`}
color="info"
/>
);
};

ProgressChip.propTypes = {
polyglot: polyglotPropTypes.isRequired,
startedAt: PropTypes.string,
};

export const renderRunButton = (
handleLaunchPrecomputed,
precomputedStatus,
Expand Down

0 comments on commit 0da82a7

Please sign in to comment.