Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jobs widget to jbrowse-web #3951

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,28 @@ exports[`renders with the available plugins 1`] = `
GFF3Plugin
</p>
</li>
<li
class="MuiListItem-root MuiListItem-dense MuiListItem-gutters MuiListItem-padding css-ypie1g-MuiListItem-root"
>
<svg
aria-hidden="true"
aria-label="This plugin was installed by an administrator, you cannot remove it."
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-1a34d00-MuiSvgIcon-root-lockedPluginTooltip"
data-mui-internal-clone-element="true"
data-testid="LockIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"
/>
</svg>
<p
class="MuiTypography-root MuiTypography-body1 css-k0xfey-MuiTypography-root"
>
JobsManagementPlugin
</p>
</li>
<li
class="MuiListItem-root MuiListItem-dense MuiListItem-gutters MuiListItem-padding css-ypie1g-MuiListItem-root"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const CurrentJobCard = observer(function CurrentJobCard({
color="inherit"
disabled={clicked || job.progressPct === 0}
onClick={() => {
job.setStatusMessage('Aborted via cancel button')
job.cancelCallback && job.cancelCallback()
setClicked(true)
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ const JobCard = observer(function JobCard({ job }: { job: NewJob }) {
<strong>{'Name: '}</strong>
{job.name}
</Typography>
{job.statusMessage ? (
<Typography variant="body1">
<strong>{'Message: '}</strong>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: don't have to use the curly for the plain-old-string on the strong line of the jsx

{job.statusMessage}
</Typography>
) : null}
</CardContent>
</Card>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ const useStyles = makeStyles()(theme => ({

const JobsListWidget = observer(function ({ model }: { model: JobsListModel }) {
const { classes } = useStyles()
const { jobs, finished, queued } = model
const { jobs, finished, queued, aborted } = model
return (
<div className={classes.root}>
<Accordion defaultExpanded>
<AccordionSummary
expandIcon={<ExpandMoreIcon className={classes.expandIcon} />}
>
<Typography variant="h5">Jobs</Typography>
<Typography variant="h5">Running jobs</Typography>
</AccordionSummary>
{jobs.length ? (
jobs.map((job: NewJob, index: number) => (
Expand All @@ -43,7 +43,7 @@ const JobsListWidget = observer(function ({ model }: { model: JobsListModel }) {
) : (
<Card variant="outlined">
<CardContent>
<Typography variant="body1">No jobs</Typography>
<Typography variant="body1">No running jobs</Typography>
</CardContent>
</Card>
)}
Expand All @@ -70,7 +70,7 @@ const JobsListWidget = observer(function ({ model }: { model: JobsListModel }) {
<AccordionSummary
expandIcon={<ExpandMoreIcon className={classes.expandIcon} />}
>
<Typography variant="h5">Jobs completed</Typography>
<Typography variant="h5">Completed jobs</Typography>
</AccordionSummary>
{finished.length ? (
finished.map((job: NewJob, index: number) => (
Expand All @@ -79,7 +79,25 @@ const JobsListWidget = observer(function ({ model }: { model: JobsListModel }) {
) : (
<Card variant="outlined">
<CardContent>
<Typography variant="body1">No jobs completed</Typography>
<Typography variant="body1">No completed jobs</Typography>
</CardContent>
</Card>
)}
</Accordion>
<Accordion defaultExpanded>
<AccordionSummary
expandIcon={<ExpandMoreIcon className={classes.expandIcon} />}
>
<Typography variant="h5">Aborted jobs</Typography>
</AccordionSummary>
{aborted.length ? (
aborted.map((job: NewJob, index: number) => (
<JobCard key={`${JSON.stringify(job)}-${index}`} job={job} />
))
) : (
<Card variant="outlined">
<CardContent>
<Typography variant="body1">No aborted jobs</Typography>
</CardContent>
</Card>
)}
Expand Down
6 changes: 6 additions & 0 deletions plugins/jobs-management/src/JobsListWidget/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const Job = types

export interface NewJob extends SnapshotIn<typeof Job> {
cancelCallback(): void
setStatusMessage(msg?: string): void
}

export default function f(_pluginManager: PluginManager) {
Expand All @@ -35,6 +36,7 @@ export default function f(_pluginManager: PluginManager) {
jobs: types.array(Job),
finished: types.array(Job),
queued: types.array(Job),
aborted: types.array(Job),
})
.actions(self => ({
addJob(job: NewJob) {
Expand All @@ -58,6 +60,10 @@ export default function f(_pluginManager: PluginManager) {
self.queued.push(job)
return self.finished
},
addAbortedJob(job: NewJob) {
self.aborted.push(job)
return self.aborted
},
removeQueuedJob(jobName: string) {
const indx = self.queued.findIndex(job => job.name === jobName)
const removed = self.queued[indx]
Expand Down
3 changes: 2 additions & 1 deletion plugins/jobs-management/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class extends Plugin {
pluginManager.addWidgetType(() => {
return new WidgetType({
name: 'JobsListWidget',
heading: 'Running jobs',
heading: 'Jobs list',
configSchema: JobsListConfigSchema,
stateModel: JobsListStateModelFactory(pluginManager),
ReactComponent: lazy(
Expand All @@ -40,6 +40,7 @@ export default class extends Plugin {
let jobStatusWidget = widgets.get('JobsList')
if (!jobStatusWidget) {
jobStatusWidget = session.addWidget('JobsListWidget', 'JobsList')
session.showWidget(jobStatusWidget)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: showWidget is on both sides of the if/else, can probably move outside of if/else

} else {
session.showWidget(jobStatusWidget)
}
Expand Down
2 changes: 2 additions & 0 deletions products/jbrowse-web/src/corePlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import DataManagement from '@jbrowse/plugin-data-management'
import DotplotView from '@jbrowse/plugin-dotplot-view'
import GtfPlugin from '@jbrowse/plugin-gtf'
import Gff3 from '@jbrowse/plugin-gff3'
import JobsManagementPlugin from '@jbrowse/plugin-jobs-management'
import LegacyJBrowse from '@jbrowse/plugin-legacy-jbrowse'
import LinearGenomeView from '@jbrowse/plugin-linear-genome-view'
import LinearComparativeView from '@jbrowse/plugin-linear-comparative-view'
Expand Down Expand Up @@ -39,6 +40,7 @@ const corePlugins = [
DotplotView,
GtfPlugin,
Gff3,
JobsManagementPlugin,
LegacyJBrowse,
LinearComparativeView,
Lollipop,
Expand Down