open-nomad/ui/app/utils/generate-exec-url.js
Buck Doyle 674da96a59
UI: add exec terminal (#6697)
This connects Xterm.js to a Nomad exec websocket so people
can interact on clients via live sessions. There are buttons on
job, allocation, task group, and task detail pages that open a
popup that lets them edit their shell command and start a
session.

More is to come, as recorded in issues.
2020-03-24 18:22:16 -05:00

19 lines
605 B
JavaScript

export default function generateExecUrl(router, { job, taskGroup, task, allocation }) {
const queryParams = router.currentRoute.queryParams;
if (task) {
return router.urlFor('exec.task-group.task', job, taskGroup, task, {
queryParams: {
allocation,
...queryParams,
},
});
} else if (taskGroup) {
return router.urlFor('exec.task-group', job, taskGroup, { queryParams });
} else if (allocation) {
return router.urlFor('exec', job, { queryParams: { allocation, ...queryParams } });
} else {
return router.urlFor('exec', job, { queryParams });
}
}