Skip to content

Commit 96d6749

Browse files
authored
feat(queue-list): use accordions by hostId (#691)
1 parent 7cd07f5 commit 96d6749

9 files changed

Lines changed: 62 additions & 38 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ Arena({
5454

5555
// Optionally include your own script
5656
customJsPath: 'https://example.com/custom-arena-js.js',
57+
58+
// Optionally expand a single host on the queues overview page by its `hostId`.
59+
// All other hosts start collapsed. When omitted, every host starts collapsed.
60+
activeHostId: 'Queue Server 1',
5761
});
5862
```
5963

@@ -169,6 +173,7 @@ router.use('/', arena);
169173
- `basePath` - specify custom path to mount server on (default: '/')
170174
- `disableListen` - don't let the server listen (useful when mounting Arena as a sub-app of another Express app) (default: false)
171175
- `useCdn` - set false to use the bundled js and css files (default: true)
176+
- `activeHostId` - `hostId` of the host to show expanded on the queues overview page; all other hosts start collapsed. Can also be set in `config`. (default: none, every host starts collapsed)
172177
- `customCssPath` - an URL to an external stylesheet (default: null)
173178

174179
##### Example config (for bull)

example/bullmq.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ async function main() {
122122
],
123123
},
124124
{
125+
activeHostId: 'Queue Server 1',
125126
port: HTTP_SERVER_PORT,
126127
}
127128
);

example/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ version: '3.2'
22
services:
33
redis:
44
image: redis:7-alpine
5-
container_name: cache
5+
container_name: cache-arena
66
ports:
77
- 6379:6379

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@fastify/express": "^2.3.0",
2121
"bee-queue": "^1.4.0",
2222
"bull": "^4.12.4",
23-
"bullmq": "^5.63.0",
23+
"bullmq": "^5.64.1",
2424
"express": "^4.17.1",
2525
"fastify": "^4.13.0"
2626
}

example/yarn.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
dependencies:
4646
fast-deep-equal "^3.1.3"
4747

48-
"@ioredis/commands@^1.1.1":
49-
version "1.2.0"
50-
resolved "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz"
51-
integrity sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==
48+
"@ioredis/commands@1.4.0":
49+
version "1.4.0"
50+
resolved "https://registry.npmjs.org/@ioredis/commands/-/commands-1.4.0.tgz"
51+
integrity sha512-aFT2yemJJo+TZCmieA7qnYGQooOS7QfNmYrzGtsYd3g9j5iDP8AimYYAesf79ohjbLG12XxC4nG5DyEnC88AsQ==
5252

5353
"@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.3":
5454
version "3.0.3"
@@ -208,13 +208,13 @@ bull@^4.12.4:
208208
semver "^7.5.2"
209209
uuid "^8.3.0"
210210

211-
bullmq@^5.63.0:
212-
version "5.63.0"
213-
resolved "https://registry.npmjs.org/bullmq/-/bullmq-5.63.0.tgz"
214-
integrity sha512-HT1iM3Jt4bZeg3Ru/MxrOy2iIItxcl1Pz5Ync1Vrot70jBpVguMxFEiSaDU57BwYwR4iwnObDnzct2lirKkX5A==
211+
bullmq@^5.64.1:
212+
version "5.64.1"
213+
resolved "https://registry.npmjs.org/bullmq/-/bullmq-5.64.1.tgz"
214+
integrity sha512-Tg4ORit8bQ1xLwcQrEfcDpG50pS30Onuz1ZA4rPLbL9QEsOaBbvFQMSEvXSgMnvRZRqDggJoSBGz9tck+1PixQ==
215215
dependencies:
216216
cron-parser "^4.9.0"
217-
ioredis "^5.4.1"
217+
ioredis "^5.8.2"
218218
msgpackr "^1.11.2"
219219
node-abort-controller "^3.1.1"
220220
semver "^7.5.4"
@@ -800,12 +800,12 @@ internal-slot@^1.1.0:
800800
hasown "^2.0.2"
801801
side-channel "^1.1.0"
802802

803-
ioredis@^5.3.2, ioredis@^5.4.1:
804-
version "5.6.1"
805-
resolved "https://registry.npmjs.org/ioredis/-/ioredis-5.6.1.tgz"
806-
integrity sha512-UxC0Yv1Y4WRJiGQxQkP0hfdL0/5/6YvdfOOClRgJ0qppSarkhneSa6UvkMkms0AkdGimSH3Ikqm+6mkMmX7vGA==
803+
ioredis@^5.3.2, ioredis@^5.8.2:
804+
version "5.8.2"
805+
resolved "https://registry.npmjs.org/ioredis/-/ioredis-5.8.2.tgz"
806+
integrity sha512-C6uC+kleiIMmjViJINWk80sOQw5lEzse1ZmvD+S/s8p8CWapftSaC+kocGTx6xrbrJ4WmYQGC08ffHLr6ToR6Q==
807807
dependencies:
808-
"@ioredis/commands" "^1.1.1"
808+
"@ioredis/commands" "1.4.0"
809809
cluster-key-slot "^1.1.0"
810810
debug "^4.3.4"
811811
denque "^2.1.0"

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ function run(config, listenOpts = {}) {
99
Queues.useCdn =
1010
typeof listenOpts.useCdn !== 'undefined' ? listenOpts.useCdn : true;
1111

12+
// Host whose queue list should stay expanded on the overview page; all other
13+
// hosts collapse by default. Undefined -> every host collapses.
14+
app.locals.activeHostId =
15+
typeof listenOpts.activeHostId !== 'undefined'
16+
? listenOpts.activeHostId
17+
: config.activeHostId;
18+
1219
if (listenOpts.disableListen) {
1320
app.locals.appBasePath =
1421
listenOpts.basePath == '/' ? app.locals.appBasePath : listenOpts.basePath;

src/server/views/dashboard/queueDetails.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const {rest} = require('lodash');
21
const QueueHelpers = require('../helpers/queueHelpers');
32

43
async function handler(req, res) {

src/server/views/dashboard/queueList.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
const _ = require('lodash');
2+
13
function handler(req, res) {
2-
const {Queues, Flows} = req.app.locals;
4+
const {Queues, Flows, activeHostId} = req.app.locals;
35
const queues = Queues.list();
46
const basePath = req.baseUrl;
57

8+
const hosts = _.map(_.groupBy(queues, 'hostId'), (queues, hostId) => ({
9+
hostId,
10+
queues,
11+
active: activeHostId === hostId,
12+
}));
13+
614
return res.render('dashboard/templates/queueList', {
715
basePath,
8-
queues,
16+
hosts,
917
hasFlows: Flows.hasFlows(),
1018
});
1119
}
Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
<h2>Queues</h2>
22
<h3>Overview</h3>
33

4-
<div class="no-padding">
5-
<table id="queueList" class="table">
6-
<thead>
7-
<th>Host</th>
8-
<th>Name</th>
9-
</thead>
10-
<tbody>
11-
{{#each queues}}
12-
<tr>
13-
<td>{{ this.hostId }}</td>
14-
<td><a href="{{ ../basePath }}/{{ encodeURI this.hostId }}/{{ encodeURI this.name }}">{{ this.name }}</a></td>
15-
</tr>
16-
{{/each}}
17-
</tbody>
18-
</table>
4+
<div class="panel-group" id="queueList" role="tablist" aria-multiselectable="true">
5+
{{#each hosts}}
6+
<div class="panel panel-default">
7+
<div class="panel-heading" role="tab" id="host-heading-{{ @index }}">
8+
<h4 class="panel-title">
9+
<a role="button" data-toggle="collapse" href="#host-collapse-{{ @index }}" aria-expanded="true"
10+
aria-controls="host-collapse-{{ @index }}">
11+
{{ this.hostId }} <span class="badge">{{ this.queues.length }}</span>
12+
</a>
13+
</h4>
14+
</div>
15+
<div id="host-collapse-{{ @index }}" class="panel-collapse collapse{{#if this.active}} in{{/if}}" role="tabpanel"
16+
aria-labelledby="host-heading-{{ @index }}">
17+
<ul class="list-group">
18+
{{#each this.queues}}
19+
<li class="list-group-item">
20+
<a href="{{ ../../basePath }}/{{ encodeURI this.hostId }}/{{ encodeURI this.name }}">{{ this.name }}</a>
21+
</li>
22+
{{/each}}
23+
</ul>
24+
</div>
25+
</div>
26+
{{/each}}
1927
</div>
2028

2129
{{#contentFor 'sidebar'}}
2230
<li class="active"><a href="#">Queues Overview</a></li>
2331
{{#if hasFlows}}
2432
<li><a href="{{ basePath }}/flows">Flows Overview</a></li>
2533
{{/if}}
26-
{{/contentFor}}
27-
28-
{{#contentFor 'script'}}
29-
new Tablesort(document.getElementById('queueList'));
3034
{{/contentFor}}

0 commit comments

Comments
 (0)