Skip to content

Commit

Permalink
migrating client to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
erikengervall committed Jan 21, 2020
1 parent 0505950 commit 98dd39f
Show file tree
Hide file tree
Showing 17 changed files with 640 additions and 492 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ module.exports = {
'prettier',
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
'plugin:react/recommended',
],
plugins: ['@typescript-eslint', 'no-only-tests'],
plugins: ['@typescript-eslint', 'no-only-tests', 'react'],
parserOptions: {
ecmaVersion: 2019, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
"@types/express": "^4.17.2",
"@types/jest": "^24.9.0",
"@types/node": "^13.1.8",
"@types/pretty-bytes": "^5.2.0",
"@types/react": "^16.9.18",
"@types/react-dom": "^16.9.5",
"@types/react-highlight": "^0.12.2",
"@typescript-eslint/eslint-plugin": "^2.17.0",
"@typescript-eslint/parser": "^2.17.0",
"@typescript-eslint/typescript-estree": "^2.17.0",
Expand All @@ -63,8 +67,10 @@
"prettier": "^1.19.1",
"prettier-eslint": "^9.0.1",
"react-dev-utils": "^8.0.0",
"source-map-loader": "^0.2.4",
"style-loader": "^0.23.1",
"ts-jest": "^24.3.0",
"ts-loader": "^6.2.1",
"ts-node": "^8.6.2",
"typescript": "^3.7.5",
"webpack": "^4.41.5",
Expand Down
9 changes: 3 additions & 6 deletions src/routes/queues.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { parse as parseRedisInfo } from 'redis-info'
import { RequestHandler, Request } from 'express'
import { Job } from 'bull'
import {
Job as JobMq,
// Queue as QueueMq
} from 'bullmq'
import { Job as JobMq } from 'bullmq'

import { BullBoardQueues, BullBoardQueue } from '../@types'

Expand Down Expand Up @@ -86,7 +83,7 @@ const getDataForQueues = async (
}
}

const counts = await Promise.all(
const queues = await Promise.all(
pairs.map(async ([name, { queue }]) => {
const counts = await queue.getJobCounts(...statuses)

Expand All @@ -105,7 +102,7 @@ const getDataForQueues = async (

return {
stats,
queues: counts,
queues,
}
}

Expand Down
30 changes: 22 additions & 8 deletions src/ui/components/App.js → src/ui/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import React from 'react'
import Queue from './Queue'
import RedisStats from './RedisStats'
import Header from './Header'
import useStore from './hooks/useStore'

export default function App({ basePath }) {
import { Queue as QueueElement } from './Queue'
import { RedisStats } from './RedisStats'
import { Header } from './Header'
import { useStore } from './hooks/useStore'
import { Job, JobCounts } from 'bull'
import { Job as JobMq } from 'bullmq'

interface Queueue {
name: string
counts: JobCounts
jobs: (Job | JobMq)[]
}

export const App = ({ basePath }: { basePath: string }) => {
const {
state,
selectedStatuses,
Expand All @@ -23,9 +32,14 @@ export default function App({ basePath }) {
'Loading...'
) : (
<>
<RedisStats stats={state.data.stats} />
{state.data.queues.map(queue => (
<Queue
{state.data && state.data.stats ? (
<RedisStats stats={state.data.stats} />
) : (
<>No stats to display </>
)}

{state.data.queues.map((queue: Queueue) => (
<QueueElement
queue={queue}
key={queue.name}
selectedStatus={selectedStatuses[queue.name]}
Expand Down
5 changes: 3 additions & 2 deletions src/ui/components/Header.js → src/ui/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import useScrolled from './hooks/useScrolled'

export default function Header() {
import { useScrolled } from './hooks/useScrolled'

export const Header = () => {
const scrolled = useScrolled()

return (
Expand Down
Loading

0 comments on commit 98dd39f

Please sign in to comment.