Skip to content

Commit

Permalink
feat(tree-view): use perma links on nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Jun 11, 2021
1 parent 56f2748 commit 07b6f3d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
8 changes: 4 additions & 4 deletions example/bullmq_with_flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function main() {
name: queueName,

// User-readable display name for the host. Required.
hostId: 'Queue Server 1',
hostId: 'Server 1',

// Queue type (Bull or Bullmq or Bee - default Bull).
type: 'bullmq',
Expand All @@ -95,7 +95,7 @@ async function main() {
name: parentQueueName,

// User-readable display name for the host. Required.
hostId: 'Queue Server 1',
hostId: 'Server 1',

// Queue type (Bull or Bullmq or Bee - default Bull).
type: 'bullmq',
Expand All @@ -110,7 +110,7 @@ async function main() {
flows: [
{
// User-readable display name for the host. Required.
hostId: 'Flow server 1',
hostId: 'Server 1',

// Required for each flow definition.
name: 'Connection name 1',
Expand All @@ -125,7 +125,7 @@ async function main() {
},
{
// User-readable display name for the host. Required.
hostId: 'Flow server 2',
hostId: 'Server 1',

// Required for each flow definition.
name: 'Connection name 2',
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"bee-queue": "^1.4.0",
"bull": "^3.22.6",
"bullmq": "^1.33.1",
"bullmq": "^1.34.0",
"express": "^4.17.1",
"redis-server": "^1.2.2"
}
Expand Down
17 changes: 14 additions & 3 deletions public/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ $(document).ready(() => {
return string.charAt(0).toUpperCase() + string.slice(1);
}

function formatToTreeView(flow) {
function encodeURI(url) {
if (typeof url !== 'string') {
return '';
}
return encodeURIComponent(url);
}

function formatToTreeView(flow, basePath, flowHost) {
const {job, children} = flow;
const text = `${job.name} <span class="label label-default">${job.id}</span>`;
const text = `${job.name} <a href="${basePath}/${encodeURI(
flowHost
)}/${encodeURI(job.queueName)}/${
job.id
}"><span class="label label-default">${job.id}</span></a>`;

if (children && children.length > 0) {
return {
Expand Down Expand Up @@ -282,7 +293,7 @@ $(document).ready(() => {
contentType: 'application/json',
})
.done((res) => {
const flowTree = formatToTreeView(res);
const flowTree = formatToTreeView(res, basePath, flowHost);
alert('Flow successfully added!');
localStorage.removeItem('arena:savedFlow');
$('#tree').treeview({data: [flowTree]});
Expand Down

0 comments on commit 07b6f3d

Please sign in to comment.