From 6a4b2cecb299c70ccdcb2e25c4db299397dc4078 Mon Sep 17 00:00:00 2001 From: Felix Mosheev <9304194+felixmosh@users.noreply.github.com> Date: Tue, 17 Oct 2023 12:39:42 +0300 Subject: [PATCH] feat: add new statuses to overview page --- example.ts | 4 ++ .../ui/src/components/JobCard/JobCard.tsx | 2 +- .../QueueStats/QueueStats.module.css | 12 ++++ .../QueueCard/QueueStats/QueueStats.tsx | 8 +-- .../StatusLegend/StatusLegend.module.css | 12 ++++ .../components/StatusLegend/StatusLegend.tsx | 5 +- .../StatusMenu/StatusMenu.module.css | 71 ++++++++++--------- .../ui/src/constants/queue-stats-status.ts | 5 +- packages/ui/src/index.css | 11 +-- packages/ui/src/pages/QueuePage/QueuePage.tsx | 2 +- packages/ui/src/utils/toCamelCase.ts | 6 ++ 11 files changed, 90 insertions(+), 48 deletions(-) create mode 100644 packages/ui/src/utils/toCamelCase.ts diff --git a/example.ts b/example.ts index eb4ff5f1..093dc1b5 100644 --- a/example.ts +++ b/example.ts @@ -65,6 +65,10 @@ const run = async () => { opts.delay = +opts.delay * 1000; // delay must be a number } + if (opts.priority) { + opts.priority = +opts.priority; + } + exampleBull.add({ title: req.query.title }, opts); exampleBullMq.add('Add', { title: req.query.title }, opts); diff --git a/packages/ui/src/components/JobCard/JobCard.tsx b/packages/ui/src/components/JobCard/JobCard.tsx index 440f80b3..cb60de67 100644 --- a/packages/ui/src/components/JobCard/JobCard.tsx +++ b/packages/ui/src/components/JobCard/JobCard.tsx @@ -1,4 +1,4 @@ -import { STATUSES } from '@bull-board/api/dist/src/constants/statuses'; +import { STATUSES } from '@bull-board/api/src/constants/statuses'; import { AppJob, Status } from '@bull-board/api/typings/app'; import React from 'react'; import { Link } from 'react-router-dom'; diff --git a/packages/ui/src/components/QueueCard/QueueStats/QueueStats.module.css b/packages/ui/src/components/QueueCard/QueueStats/QueueStats.module.css index bc80b71e..670f662d 100644 --- a/packages/ui/src/components/QueueCard/QueueStats/QueueStats.module.css +++ b/packages/ui/src/components/QueueCard/QueueStats/QueueStats.module.css @@ -31,6 +31,14 @@ background-color: var(--waiting); } +.waitingChildren { + background-color: var(--waitingChildren); +} + +.prioritized { + background-color: var(--prioritized); +} + .completed { background-color: var(--completed); } @@ -46,3 +54,7 @@ .delayed { background-color: var(--delayed); } + +.paused { + background-color: var(--paused); +} diff --git a/packages/ui/src/components/QueueCard/QueueStats/QueueStats.tsx b/packages/ui/src/components/QueueCard/QueueStats/QueueStats.tsx index 65d93118..5058132d 100644 --- a/packages/ui/src/components/QueueCard/QueueStats/QueueStats.tsx +++ b/packages/ui/src/components/QueueCard/QueueStats/QueueStats.tsx @@ -1,6 +1,6 @@ import { AppQueue } from '@bull-board/api/typings/app'; import React from 'react'; -import { queueStatsStatusList } from '../../../constants/queue-stats-status'; +import { toCamelCase } from '../../../utils/toCamelCase'; import s from './QueueStats.module.css'; interface IQueueStatsProps { @@ -8,12 +8,12 @@ interface IQueueStatsProps { } export const QueueStats = ({ queue }: IQueueStatsProps) => { - const total = queueStatsStatusList.reduce((result, status) => result + queue.counts[status], 0); + const total = queue.statuses.reduce((result, status) => result + (queue.counts[status] || 0), 0); return (
- {queueStatsStatusList + {queue.statuses .filter((status) => queue.counts[status] > 0) .map((status) => { const value = queue.counts[status]; @@ -26,7 +26,7 @@ export const QueueStats = ({ queue }: IQueueStatsProps) => { aria-valuenow={value} aria-valuemin={0} aria-valuemax={total} - className={s[status]} + className={s[toCamelCase(status)]} > {value}
diff --git a/packages/ui/src/components/StatusLegend/StatusLegend.module.css b/packages/ui/src/components/StatusLegend/StatusLegend.module.css index 99ef57d0..b87af3bd 100644 --- a/packages/ui/src/components/StatusLegend/StatusLegend.module.css +++ b/packages/ui/src/components/StatusLegend/StatusLegend.module.css @@ -24,6 +24,14 @@ --item-bg: var(--waiting); } +.waitingChildren { + --item-bg: var(--waitingChildren); +} + +.prioritized { + --item-bg: var(--prioritized); +} + .active { --item-bg: var(--active); } @@ -39,3 +47,7 @@ .delayed { --item-bg: var(--delayed); } + +.paused { + --item-bg: var(--paused); +} diff --git a/packages/ui/src/components/StatusLegend/StatusLegend.tsx b/packages/ui/src/components/StatusLegend/StatusLegend.tsx index 464528ee..b77caca8 100644 --- a/packages/ui/src/components/StatusLegend/StatusLegend.tsx +++ b/packages/ui/src/components/StatusLegend/StatusLegend.tsx @@ -1,11 +1,12 @@ -import { queueStatsStatusList } from '../../constants/queue-stats-status'; import React from 'react'; +import { queueStatsStatusList } from '../../constants/queue-stats-status'; +import { toCamelCase } from '../../utils/toCamelCase'; import s from './StatusLegend.module.css'; export const StatusLegend = () => (