@jbrowse/plugin-circular-view 2.6.1 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseChordDisplay/components/BaseChordDisplay.js +0 -1
- package/dist/BaseChordDisplay/components/DisplayError.js +0 -1
- package/dist/BaseChordDisplay/components/Loading.js +0 -1
- package/dist/BaseChordDisplay/index.js +0 -1
- package/dist/BaseChordDisplay/models/configSchema.js +0 -1
- package/dist/BaseChordDisplay/models/model.js +0 -1
- package/dist/BaseChordDisplay/models/renderReaction.js +0 -1
- package/dist/CircularView/components/CircularView.js +0 -1
- package/dist/CircularView/components/Controls.js +0 -1
- package/dist/CircularView/components/ExportSvgDialog.js +0 -1
- package/dist/CircularView/components/ImportForm.js +0 -1
- package/dist/CircularView/components/Ruler.js +0 -1
- package/dist/CircularView/index.js +0 -1
- package/dist/CircularView/models/CircularView.js +0 -1
- package/dist/CircularView/models/slices.js +0 -1
- package/dist/CircularView/models/viewportVisibleRegion.js +0 -1
- package/dist/CircularView/svgcomponents/SVGBackground.js +2 -2
- package/dist/CircularView/svgcomponents/SVGCircularView.js +0 -1
- package/dist/LaunchCircularView/index.js +0 -1
- package/dist/index.js +0 -1
- package/esm/BaseChordDisplay/components/BaseChordDisplay.js +0 -1
- package/esm/BaseChordDisplay/components/DisplayError.js +0 -1
- package/esm/BaseChordDisplay/components/Loading.js +0 -1
- package/esm/BaseChordDisplay/index.js +0 -1
- package/esm/BaseChordDisplay/models/configSchema.js +0 -1
- package/esm/BaseChordDisplay/models/model.js +0 -1
- package/esm/BaseChordDisplay/models/renderReaction.js +0 -1
- package/esm/CircularView/components/CircularView.js +0 -1
- package/esm/CircularView/components/Controls.js +0 -1
- package/esm/CircularView/components/ExportSvgDialog.js +0 -1
- package/esm/CircularView/components/ImportForm.js +0 -1
- package/esm/CircularView/components/Ruler.js +0 -1
- package/esm/CircularView/index.js +0 -1
- package/esm/CircularView/models/CircularView.js +0 -1
- package/esm/CircularView/models/slices.js +0 -1
- package/esm/CircularView/models/viewportVisibleRegion.js +0 -1
- package/esm/CircularView/svgcomponents/SVGBackground.js +2 -2
- package/esm/CircularView/svgcomponents/SVGCircularView.js +0 -1
- package/esm/LaunchCircularView/index.js +0 -1
- package/esm/index.js +0 -1
- package/package.json +4 -4
- package/dist/BaseChordDisplay/components/BaseChordDisplay.js.map +0 -1
- package/dist/BaseChordDisplay/components/DisplayError.js.map +0 -1
- package/dist/BaseChordDisplay/components/Loading.js.map +0 -1
- package/dist/BaseChordDisplay/index.js.map +0 -1
- package/dist/BaseChordDisplay/models/configSchema.js.map +0 -1
- package/dist/BaseChordDisplay/models/model.js.map +0 -1
- package/dist/BaseChordDisplay/models/renderReaction.js.map +0 -1
- package/dist/CircularView/components/CircularView.js.map +0 -1
- package/dist/CircularView/components/Controls.js.map +0 -1
- package/dist/CircularView/components/ExportSvgDialog.js.map +0 -1
- package/dist/CircularView/components/ImportForm.js.map +0 -1
- package/dist/CircularView/components/Ruler.js.map +0 -1
- package/dist/CircularView/index.js.map +0 -1
- package/dist/CircularView/models/CircularView.js.map +0 -1
- package/dist/CircularView/models/slices.js.map +0 -1
- package/dist/CircularView/models/viewportVisibleRegion.js.map +0 -1
- package/dist/CircularView/svgcomponents/SVGBackground.js.map +0 -1
- package/dist/CircularView/svgcomponents/SVGCircularView.js.map +0 -1
- package/dist/LaunchCircularView/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/esm/BaseChordDisplay/components/BaseChordDisplay.js.map +0 -1
- package/esm/BaseChordDisplay/components/DisplayError.js.map +0 -1
- package/esm/BaseChordDisplay/components/Loading.js.map +0 -1
- package/esm/BaseChordDisplay/index.js.map +0 -1
- package/esm/BaseChordDisplay/models/configSchema.js.map +0 -1
- package/esm/BaseChordDisplay/models/model.js.map +0 -1
- package/esm/BaseChordDisplay/models/renderReaction.js.map +0 -1
- package/esm/CircularView/components/CircularView.js.map +0 -1
- package/esm/CircularView/components/Controls.js.map +0 -1
- package/esm/CircularView/components/ExportSvgDialog.js.map +0 -1
- package/esm/CircularView/components/ImportForm.js.map +0 -1
- package/esm/CircularView/components/Ruler.js.map +0 -1
- package/esm/CircularView/index.js.map +0 -1
- package/esm/CircularView/models/CircularView.js.map +0 -1
- package/esm/CircularView/models/slices.js.map +0 -1
- package/esm/CircularView/models/viewportVisibleRegion.js.map +0 -1
- package/esm/CircularView/svgcomponents/SVGBackground.js.map +0 -1
- package/esm/CircularView/svgcomponents/SVGCircularView.js.map +0 -1
- package/esm/LaunchCircularView/index.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/src/BaseChordDisplay/components/BaseChordDisplay.tsx +0 -26
- package/src/BaseChordDisplay/components/DisplayError.tsx +0 -47
- package/src/BaseChordDisplay/components/Loading.tsx +0 -111
- package/src/BaseChordDisplay/index.ts +0 -3
- package/src/BaseChordDisplay/models/configSchema.ts +0 -30
- package/src/BaseChordDisplay/models/model.tsx +0 -314
- package/src/BaseChordDisplay/models/renderReaction.ts +0 -75
- package/src/CircularView/components/CircularView.tsx +0 -128
- package/src/CircularView/components/Controls.tsx +0 -119
- package/src/CircularView/components/ExportSvgDialog.tsx +0 -132
- package/src/CircularView/components/ImportForm.tsx +0 -68
- package/src/CircularView/components/Ruler.tsx +0 -265
- package/src/CircularView/index.ts +0 -16
- package/src/CircularView/models/CircularView.ts +0 -621
- package/src/CircularView/models/__snapshots__/slices.test.js.snap +0 -91
- package/src/CircularView/models/slices.test.js +0 -70
- package/src/CircularView/models/slices.ts +0 -101
- package/src/CircularView/models/viewportVisibleRegion.test.js +0 -168
- package/src/CircularView/models/viewportVisibleRegion.ts +0 -272
- package/src/CircularView/svgcomponents/SVGBackground.tsx +0 -21
- package/src/CircularView/svgcomponents/SVGCircularView.tsx +0 -58
- package/src/LaunchCircularView/index.ts +0 -48
- package/src/index.ts +0 -43
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import clone from 'clone'
|
|
2
|
-
import { getRpcSessionId } from '@jbrowse/core/util/tracks'
|
|
3
|
-
import { getSession, getContainingView } from '@jbrowse/core/util'
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
-
export function renderReactionData(self: any) {
|
|
7
|
-
const view = getContainingView(self)
|
|
8
|
-
const { rendererType } = self
|
|
9
|
-
const { rpcManager } = getSession(view)
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
rendererType,
|
|
13
|
-
rpcManager,
|
|
14
|
-
renderProps: self.renderProps(),
|
|
15
|
-
renderArgs: {
|
|
16
|
-
assemblyName: view.displayedRegions[0]?.assemblyName,
|
|
17
|
-
adapterConfig: clone(self.adapterConfig),
|
|
18
|
-
rendererType: rendererType.name,
|
|
19
|
-
regions: clone(view.displayedRegions),
|
|
20
|
-
blockDefinitions: self.blockDefinitions,
|
|
21
|
-
sessionId: getRpcSessionId(self),
|
|
22
|
-
timeout: 1000000,
|
|
23
|
-
},
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export async function renderReactionEffect(
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
props: any,
|
|
30
|
-
signal: AbortSignal | undefined,
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
-
self: any,
|
|
33
|
-
) {
|
|
34
|
-
if (!props) {
|
|
35
|
-
throw new Error('cannot render with no props')
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const {
|
|
39
|
-
rendererType,
|
|
40
|
-
rpcManager,
|
|
41
|
-
cannotBeRenderedReason,
|
|
42
|
-
renderArgs,
|
|
43
|
-
renderProps,
|
|
44
|
-
exportSVG,
|
|
45
|
-
} = props
|
|
46
|
-
|
|
47
|
-
if (cannotBeRenderedReason) {
|
|
48
|
-
return { message: cannotBeRenderedReason }
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// don't try to render 0 or NaN radius or no regions
|
|
52
|
-
if (!renderProps.radius || !renderArgs.regions?.length) {
|
|
53
|
-
return { message: 'Skipping render' }
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// check renderertype compatibility
|
|
57
|
-
if (!self.isCompatibleWithRenderer(rendererType)) {
|
|
58
|
-
throw new Error(
|
|
59
|
-
`renderer ${rendererType.name} is not compatible with this display type`,
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const { html, ...data } = await rendererType.renderInClient(rpcManager, {
|
|
64
|
-
...renderArgs,
|
|
65
|
-
...renderProps,
|
|
66
|
-
exportSVG,
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
html,
|
|
71
|
-
data,
|
|
72
|
-
reactElement: data.reactElement,
|
|
73
|
-
renderingComponent: rendererType.ReactComponent,
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { observer } from 'mobx-react'
|
|
3
|
-
import { ResizeHandle } from '@jbrowse/core/ui'
|
|
4
|
-
import { assembleLocString } from '@jbrowse/core/util'
|
|
5
|
-
import { makeStyles } from 'tss-react/mui'
|
|
6
|
-
|
|
7
|
-
// locals
|
|
8
|
-
import Ruler from './Ruler'
|
|
9
|
-
import Controls from './Controls'
|
|
10
|
-
import ImportForm from './ImportForm'
|
|
11
|
-
import { CircularViewModel } from '../models/CircularView'
|
|
12
|
-
|
|
13
|
-
const dragHandleHeight = 3
|
|
14
|
-
|
|
15
|
-
const useStyles = makeStyles()(theme => ({
|
|
16
|
-
root: {
|
|
17
|
-
position: 'relative',
|
|
18
|
-
marginBottom: theme.spacing(1),
|
|
19
|
-
overflow: 'hidden',
|
|
20
|
-
},
|
|
21
|
-
scroller: {
|
|
22
|
-
overflow: 'auto',
|
|
23
|
-
},
|
|
24
|
-
}))
|
|
25
|
-
|
|
26
|
-
const Slices = observer(({ model }: { model: CircularViewModel }) => {
|
|
27
|
-
return (
|
|
28
|
-
<>
|
|
29
|
-
{model.staticSlices.map(slice => (
|
|
30
|
-
<Ruler
|
|
31
|
-
key={assembleLocString(
|
|
32
|
-
slice.region.elided ? slice.region.regions[0] : slice.region,
|
|
33
|
-
)}
|
|
34
|
-
model={model}
|
|
35
|
-
slice={slice}
|
|
36
|
-
/>
|
|
37
|
-
))}
|
|
38
|
-
{model.tracks.map(track => {
|
|
39
|
-
const display = track.displays[0]
|
|
40
|
-
return (
|
|
41
|
-
<display.RenderingComponent
|
|
42
|
-
key={display.id}
|
|
43
|
-
display={display}
|
|
44
|
-
view={model}
|
|
45
|
-
/>
|
|
46
|
-
)
|
|
47
|
-
})}
|
|
48
|
-
</>
|
|
49
|
-
)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
const CircularView = observer(({ model }: { model: CircularViewModel }) => {
|
|
53
|
-
const initialized =
|
|
54
|
-
!!model.displayedRegions.length &&
|
|
55
|
-
!!model.figureWidth &&
|
|
56
|
-
!!model.figureHeight &&
|
|
57
|
-
model.initialized
|
|
58
|
-
|
|
59
|
-
const showImportForm = !initialized && !model.disableImportForm
|
|
60
|
-
const showFigure = initialized && !showImportForm
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<>
|
|
64
|
-
{showImportForm || model.error ? (
|
|
65
|
-
<ImportForm model={model} />
|
|
66
|
-
) : showFigure ? (
|
|
67
|
-
<CircularViewLoaded model={model} />
|
|
68
|
-
) : null}
|
|
69
|
-
</>
|
|
70
|
-
)
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
const CircularViewLoaded = observer(function ({
|
|
74
|
-
model,
|
|
75
|
-
}: {
|
|
76
|
-
model: CircularViewModel
|
|
77
|
-
}) {
|
|
78
|
-
const {
|
|
79
|
-
width,
|
|
80
|
-
height,
|
|
81
|
-
id,
|
|
82
|
-
offsetRadians,
|
|
83
|
-
centerXY,
|
|
84
|
-
figureWidth,
|
|
85
|
-
figureHeight,
|
|
86
|
-
hideVerticalResizeHandle,
|
|
87
|
-
} = model
|
|
88
|
-
const { classes } = useStyles()
|
|
89
|
-
return (
|
|
90
|
-
<div className={classes.root} style={{ width, height }} data-testid={id}>
|
|
91
|
-
<div className={classes.scroller} style={{ width, height }}>
|
|
92
|
-
<svg
|
|
93
|
-
style={{
|
|
94
|
-
transform: `rotate(${offsetRadians}rad)`,
|
|
95
|
-
transition: 'transform 0.5s',
|
|
96
|
-
transformOrigin: centerXY.map(x => `${x}px`).join(' '),
|
|
97
|
-
position: 'absolute',
|
|
98
|
-
left: 0,
|
|
99
|
-
top: 0,
|
|
100
|
-
}}
|
|
101
|
-
width={figureWidth}
|
|
102
|
-
height={figureHeight}
|
|
103
|
-
>
|
|
104
|
-
<g transform={`translate(${centerXY})`}>
|
|
105
|
-
<Slices model={model} />
|
|
106
|
-
</g>
|
|
107
|
-
</svg>
|
|
108
|
-
</div>
|
|
109
|
-
<Controls model={model} />
|
|
110
|
-
{hideVerticalResizeHandle ? null : (
|
|
111
|
-
<ResizeHandle
|
|
112
|
-
onDrag={model.resizeHeight}
|
|
113
|
-
style={{
|
|
114
|
-
height: dragHandleHeight,
|
|
115
|
-
position: 'absolute',
|
|
116
|
-
bottom: 0,
|
|
117
|
-
left: 0,
|
|
118
|
-
background: '#ccc',
|
|
119
|
-
boxSizing: 'border-box',
|
|
120
|
-
borderTop: '1px solid #fafafa',
|
|
121
|
-
}}
|
|
122
|
-
/>
|
|
123
|
-
)}
|
|
124
|
-
</div>
|
|
125
|
-
)
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
export default CircularView
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import { observer } from 'mobx-react'
|
|
3
|
-
import { IconButton } from '@mui/material'
|
|
4
|
-
import { makeStyles } from 'tss-react/mui'
|
|
5
|
-
import JBrowseMenu from '@jbrowse/core/ui/Menu'
|
|
6
|
-
|
|
7
|
-
// icons
|
|
8
|
-
import ZoomOutIcon from '@mui/icons-material/ZoomOut'
|
|
9
|
-
import ZoomInIcon from '@mui/icons-material/ZoomIn'
|
|
10
|
-
import RotateLeftIcon from '@mui/icons-material/RotateLeft'
|
|
11
|
-
import RotateRightIcon from '@mui/icons-material/RotateRight'
|
|
12
|
-
import LockOpenIcon from '@mui/icons-material/LockOpen'
|
|
13
|
-
import LockIcon from '@mui/icons-material/Lock'
|
|
14
|
-
import PhotoCamera from '@mui/icons-material/PhotoCamera'
|
|
15
|
-
import MoreVert from '@mui/icons-material/MoreVert'
|
|
16
|
-
import { TrackSelector as TrackSelectorIcon } from '@jbrowse/core/ui/Icons'
|
|
17
|
-
|
|
18
|
-
// locals
|
|
19
|
-
import { CircularViewModel } from '../models/CircularView'
|
|
20
|
-
import { getSession } from '@jbrowse/core/util'
|
|
21
|
-
import ExportSvgDlg from './ExportSvgDialog'
|
|
22
|
-
|
|
23
|
-
const useStyles = makeStyles()(theme => ({
|
|
24
|
-
controls: {
|
|
25
|
-
position: 'absolute',
|
|
26
|
-
borderRight: `1px solid ${theme.palette.divider}`,
|
|
27
|
-
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
28
|
-
left: 0,
|
|
29
|
-
top: 0,
|
|
30
|
-
},
|
|
31
|
-
}))
|
|
32
|
-
|
|
33
|
-
export default observer(function ({ model }: { model: CircularViewModel }) {
|
|
34
|
-
const { classes } = useStyles()
|
|
35
|
-
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)
|
|
36
|
-
return (
|
|
37
|
-
<div className={classes.controls}>
|
|
38
|
-
<IconButton
|
|
39
|
-
onClick={model.zoomOutButton}
|
|
40
|
-
title={model.lockedFitToWindow ? 'unlock to zoom out' : 'zoom out'}
|
|
41
|
-
disabled={model.atMaxBpPerPx || model.lockedFitToWindow}
|
|
42
|
-
>
|
|
43
|
-
<ZoomOutIcon />
|
|
44
|
-
</IconButton>
|
|
45
|
-
|
|
46
|
-
<IconButton
|
|
47
|
-
onClick={model.zoomInButton}
|
|
48
|
-
disabled={model.atMinBpPerPx}
|
|
49
|
-
title="zoom in"
|
|
50
|
-
>
|
|
51
|
-
<ZoomInIcon />
|
|
52
|
-
</IconButton>
|
|
53
|
-
|
|
54
|
-
<IconButton
|
|
55
|
-
onClick={model.rotateCounterClockwiseButton}
|
|
56
|
-
title="rotate counter-clockwise"
|
|
57
|
-
>
|
|
58
|
-
<RotateLeftIcon />
|
|
59
|
-
</IconButton>
|
|
60
|
-
|
|
61
|
-
<IconButton
|
|
62
|
-
onClick={model.rotateClockwiseButton}
|
|
63
|
-
title="rotate clockwise"
|
|
64
|
-
>
|
|
65
|
-
<RotateRightIcon />
|
|
66
|
-
</IconButton>
|
|
67
|
-
|
|
68
|
-
<IconButton
|
|
69
|
-
onClick={model.toggleFitToWindowLock}
|
|
70
|
-
title={
|
|
71
|
-
model.lockedFitToWindow
|
|
72
|
-
? 'locked model to window size'
|
|
73
|
-
: 'unlocked model to zoom further'
|
|
74
|
-
}
|
|
75
|
-
disabled={model.tooSmallToLock}
|
|
76
|
-
>
|
|
77
|
-
{model.lockedFitToWindow ? <LockIcon /> : <LockOpenIcon />}
|
|
78
|
-
</IconButton>
|
|
79
|
-
|
|
80
|
-
<IconButton onClick={event => setAnchorEl(event.currentTarget)}>
|
|
81
|
-
<MoreVert />
|
|
82
|
-
</IconButton>
|
|
83
|
-
|
|
84
|
-
{model.hideTrackSelectorButton ? null : (
|
|
85
|
-
<IconButton
|
|
86
|
-
onClick={model.activateTrackSelector}
|
|
87
|
-
title="Open track selector"
|
|
88
|
-
data-testid="circular_track_select"
|
|
89
|
-
>
|
|
90
|
-
<TrackSelectorIcon />
|
|
91
|
-
</IconButton>
|
|
92
|
-
)}
|
|
93
|
-
|
|
94
|
-
{anchorEl ? (
|
|
95
|
-
<JBrowseMenu
|
|
96
|
-
anchorEl={anchorEl}
|
|
97
|
-
menuItems={[
|
|
98
|
-
{
|
|
99
|
-
label: 'Export SVG',
|
|
100
|
-
icon: PhotoCamera,
|
|
101
|
-
onClick: () => {
|
|
102
|
-
getSession(model).queueDialog(handleClose => [
|
|
103
|
-
ExportSvgDlg,
|
|
104
|
-
{ model, handleClose },
|
|
105
|
-
])
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
]}
|
|
109
|
-
onMenuItemClick={(_event, callback) => {
|
|
110
|
-
callback()
|
|
111
|
-
setAnchorEl(null)
|
|
112
|
-
}}
|
|
113
|
-
open={Boolean(anchorEl)}
|
|
114
|
-
onClose={() => setAnchorEl(null)}
|
|
115
|
-
/>
|
|
116
|
-
) : null}
|
|
117
|
-
</div>
|
|
118
|
-
)
|
|
119
|
-
})
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
Button,
|
|
4
|
-
Checkbox,
|
|
5
|
-
CircularProgress,
|
|
6
|
-
DialogActions,
|
|
7
|
-
DialogContent,
|
|
8
|
-
FormControlLabel,
|
|
9
|
-
MenuItem,
|
|
10
|
-
TextField,
|
|
11
|
-
Typography,
|
|
12
|
-
} from '@mui/material'
|
|
13
|
-
import { Dialog, ErrorMessage } from '@jbrowse/core/ui'
|
|
14
|
-
|
|
15
|
-
// locals
|
|
16
|
-
import { ExportSvgOptions } from '../models/CircularView'
|
|
17
|
-
import { getSession, useLocalStorage } from '@jbrowse/core/util'
|
|
18
|
-
|
|
19
|
-
function LoadingMessage() {
|
|
20
|
-
return (
|
|
21
|
-
<div>
|
|
22
|
-
<CircularProgress size={20} style={{ marginRight: 20 }} />
|
|
23
|
-
<Typography display="inline">Creating SVG</Typography>
|
|
24
|
-
</div>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function useSvgLocal<T>(key: string, val: T) {
|
|
29
|
-
return useLocalStorage('svg-' + key, val)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export default function ExportSvgDlg({
|
|
33
|
-
model,
|
|
34
|
-
handleClose,
|
|
35
|
-
}: {
|
|
36
|
-
model: { exportSvg(opts: ExportSvgOptions): Promise<void> }
|
|
37
|
-
handleClose: () => void
|
|
38
|
-
}) {
|
|
39
|
-
const session = getSession(model)
|
|
40
|
-
const offscreenCanvas = typeof OffscreenCanvas !== 'undefined'
|
|
41
|
-
const [rasterizeLayers, setRasterizeLayers] = useState(offscreenCanvas)
|
|
42
|
-
const [loading, setLoading] = useState(false)
|
|
43
|
-
const [error, setError] = useState<unknown>()
|
|
44
|
-
const [filename, setFilename] = useSvgLocal('file', 'jbrowse.svg')
|
|
45
|
-
const [themeName, setThemeName] = useSvgLocal(
|
|
46
|
-
'theme',
|
|
47
|
-
session.themeName || 'default',
|
|
48
|
-
)
|
|
49
|
-
return (
|
|
50
|
-
<Dialog open onClose={handleClose} title="Export SVG">
|
|
51
|
-
<DialogContent>
|
|
52
|
-
{error ? (
|
|
53
|
-
<ErrorMessage error={error} />
|
|
54
|
-
) : loading ? (
|
|
55
|
-
<LoadingMessage />
|
|
56
|
-
) : null}
|
|
57
|
-
<TextField
|
|
58
|
-
helperText="filename"
|
|
59
|
-
value={filename}
|
|
60
|
-
onChange={event => setFilename(event.target.value)}
|
|
61
|
-
/>
|
|
62
|
-
<br />
|
|
63
|
-
|
|
64
|
-
{session.allThemes ? (
|
|
65
|
-
<TextField
|
|
66
|
-
select
|
|
67
|
-
label="Theme"
|
|
68
|
-
value={themeName}
|
|
69
|
-
onChange={event => setThemeName(event.target.value)}
|
|
70
|
-
>
|
|
71
|
-
{Object.entries(session.allThemes()).map(([key, val]) => (
|
|
72
|
-
<MenuItem key={key} value={key}>
|
|
73
|
-
{
|
|
74
|
-
// @ts-expect-error
|
|
75
|
-
val.name || '(Unknown name)'
|
|
76
|
-
}
|
|
77
|
-
</MenuItem>
|
|
78
|
-
))}
|
|
79
|
-
</TextField>
|
|
80
|
-
) : null}
|
|
81
|
-
{offscreenCanvas ? (
|
|
82
|
-
<FormControlLabel
|
|
83
|
-
control={
|
|
84
|
-
<Checkbox
|
|
85
|
-
checked={rasterizeLayers}
|
|
86
|
-
onChange={() => setRasterizeLayers(val => !val)}
|
|
87
|
-
/>
|
|
88
|
-
}
|
|
89
|
-
label="Rasterize canvas based tracks? File may be much larger if this is turned off"
|
|
90
|
-
/>
|
|
91
|
-
) : (
|
|
92
|
-
<Typography>
|
|
93
|
-
Note: rasterizing layers not yet supported in this browser, so SVG
|
|
94
|
-
size may be large
|
|
95
|
-
</Typography>
|
|
96
|
-
)}
|
|
97
|
-
</DialogContent>
|
|
98
|
-
<DialogActions>
|
|
99
|
-
<Button
|
|
100
|
-
variant="contained"
|
|
101
|
-
color="secondary"
|
|
102
|
-
onClick={() => handleClose()}
|
|
103
|
-
>
|
|
104
|
-
Cancel
|
|
105
|
-
</Button>
|
|
106
|
-
<Button
|
|
107
|
-
variant="contained"
|
|
108
|
-
color="primary"
|
|
109
|
-
type="submit"
|
|
110
|
-
onClick={async () => {
|
|
111
|
-
setLoading(true)
|
|
112
|
-
setError(undefined)
|
|
113
|
-
try {
|
|
114
|
-
await model.exportSvg({
|
|
115
|
-
rasterizeLayers,
|
|
116
|
-
filename,
|
|
117
|
-
themeName,
|
|
118
|
-
})
|
|
119
|
-
handleClose()
|
|
120
|
-
} catch (e) {
|
|
121
|
-
console.error(e)
|
|
122
|
-
setError(e)
|
|
123
|
-
setLoading(false)
|
|
124
|
-
}
|
|
125
|
-
}}
|
|
126
|
-
>
|
|
127
|
-
Submit
|
|
128
|
-
</Button>
|
|
129
|
-
</DialogActions>
|
|
130
|
-
</Dialog>
|
|
131
|
-
)
|
|
132
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import { Button, Container, Grid } from '@mui/material'
|
|
3
|
-
import { makeStyles } from 'tss-react/mui'
|
|
4
|
-
import { observer } from 'mobx-react'
|
|
5
|
-
import { getSession } from '@jbrowse/core/util'
|
|
6
|
-
import { ErrorMessage, AssemblySelector } from '@jbrowse/core/ui'
|
|
7
|
-
|
|
8
|
-
const useStyles = makeStyles()(theme => ({
|
|
9
|
-
importFormContainer: {
|
|
10
|
-
padding: theme.spacing(6),
|
|
11
|
-
},
|
|
12
|
-
}))
|
|
13
|
-
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
const ImportForm = observer(({ model }: { model: any }) => {
|
|
16
|
-
const { classes } = useStyles()
|
|
17
|
-
const session = getSession(model)
|
|
18
|
-
const { error } = model
|
|
19
|
-
const { assemblyNames, assemblyManager } = session
|
|
20
|
-
const [selectedAsm, setSelectedAsm] = useState(assemblyNames[0])
|
|
21
|
-
const assembly = assemblyManager.get(selectedAsm)
|
|
22
|
-
const assemblyError = assemblyNames.length
|
|
23
|
-
? assembly?.error
|
|
24
|
-
: 'No configured assemblies'
|
|
25
|
-
const regions = assembly?.regions || []
|
|
26
|
-
const err = assemblyError || error
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<Container className={classes.importFormContainer}>
|
|
30
|
-
{err ? (
|
|
31
|
-
<Grid container spacing={1} justifyContent="center" alignItems="center">
|
|
32
|
-
<Grid item>
|
|
33
|
-
<ErrorMessage error={err} />
|
|
34
|
-
</Grid>
|
|
35
|
-
</Grid>
|
|
36
|
-
) : null}
|
|
37
|
-
<Grid container spacing={1} justifyContent="center" alignItems="center">
|
|
38
|
-
<Grid item>
|
|
39
|
-
<AssemblySelector
|
|
40
|
-
onChange={val => {
|
|
41
|
-
model.setError(undefined)
|
|
42
|
-
setSelectedAsm(val)
|
|
43
|
-
}}
|
|
44
|
-
session={session}
|
|
45
|
-
selected={selectedAsm}
|
|
46
|
-
/>
|
|
47
|
-
</Grid>
|
|
48
|
-
|
|
49
|
-
<Grid item>
|
|
50
|
-
<Button
|
|
51
|
-
disabled={!regions?.length}
|
|
52
|
-
onClick={() => {
|
|
53
|
-
model.setError(undefined)
|
|
54
|
-
model.setDisplayedRegions(regions)
|
|
55
|
-
}}
|
|
56
|
-
variant="contained"
|
|
57
|
-
color="primary"
|
|
58
|
-
>
|
|
59
|
-
{/* if there's an error, it's not actively loading so just display open */}
|
|
60
|
-
{regions.length || err ? 'Open' : 'Loading...'}
|
|
61
|
-
</Button>
|
|
62
|
-
</Grid>
|
|
63
|
-
</Grid>
|
|
64
|
-
</Container>
|
|
65
|
-
)
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
export default ImportForm
|