@jbrowse/plugin-grid-bookmark 3.7.0 → 4.0.1
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/esm/GridBookmarkWidget/components/AssemblySelector.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/AssemblySelector.js +1 -1
- package/esm/GridBookmarkWidget/components/BookmarkGrid.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/BookmarkGrid.js +3 -3
- package/esm/GridBookmarkWidget/components/GridBookmarkWidget.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/GridBookmarkWidget.js +9 -9
- package/esm/GridBookmarkWidget/components/Highlight/Highlight.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/Highlight/Highlight.js +3 -4
- package/esm/GridBookmarkWidget/components/Highlight/OverviewHighlight.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/Highlight/OverviewHighlight.js +5 -5
- package/esm/GridBookmarkWidget/components/Highlight/index.js +2 -2
- package/esm/GridBookmarkWidget/components/dialogs/DeleteBookmarksDialog.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/dialogs/DeleteBookmarksDialog.js +1 -1
- package/esm/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.js +2 -3
- package/esm/GridBookmarkWidget/components/dialogs/ExportBookmarksDialog.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/dialogs/ExportBookmarksDialog.js +5 -5
- package/esm/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.js +1 -1
- package/esm/GridBookmarkWidget/components/dialogs/ImportBookmarksDialog.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/dialogs/ImportBookmarksDialog.js +5 -5
- package/esm/GridBookmarkWidget/components/dialogs/ShareBookmarksDialog.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/dialogs/ShareBookmarksDialog.js +5 -5
- package/esm/GridBookmarkWidget/index.js +3 -3
- package/esm/GridBookmarkWidget/model.d.ts +94 -94
- package/esm/GridBookmarkWidget/model.js +10 -15
- package/esm/GridBookmarkWidget/sessionSharing.js +1 -1
- package/esm/GridBookmarkWidget/utils.d.ts +2 -2
- package/esm/GridBookmarkWidget/utils.js +11 -15
- package/esm/index.js +17 -6
- package/package.json +32 -36
- package/dist/GridBookmarkWidget/components/AssemblySelector.d.ts +0 -5
- package/dist/GridBookmarkWidget/components/AssemblySelector.js +0 -22
- package/dist/GridBookmarkWidget/components/BookmarkGrid.d.ts +0 -5
- package/dist/GridBookmarkWidget/components/BookmarkGrid.js +0 -97
- package/dist/GridBookmarkWidget/components/GridBookmarkWidget.d.ts +0 -5
- package/dist/GridBookmarkWidget/components/GridBookmarkWidget.js +0 -131
- package/dist/GridBookmarkWidget/components/Highlight/Highlight.d.ts +0 -6
- package/dist/GridBookmarkWidget/components/Highlight/Highlight.js +0 -89
- package/dist/GridBookmarkWidget/components/Highlight/OverviewHighlight.d.ts +0 -8
- package/dist/GridBookmarkWidget/components/Highlight/OverviewHighlight.js +0 -60
- package/dist/GridBookmarkWidget/components/Highlight/index.d.ts +0 -2
- package/dist/GridBookmarkWidget/components/Highlight/index.js +0 -23
- package/dist/GridBookmarkWidget/components/dialogs/DeleteBookmarksDialog.d.ts +0 -6
- package/dist/GridBookmarkWidget/components/dialogs/DeleteBookmarksDialog.js +0 -20
- package/dist/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.d.ts +0 -6
- package/dist/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.js +0 -23
- package/dist/GridBookmarkWidget/components/dialogs/ExportBookmarksDialog.d.ts +0 -6
- package/dist/GridBookmarkWidget/components/dialogs/ExportBookmarksDialog.js +0 -40
- package/dist/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.d.ts +0 -6
- package/dist/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.js +0 -16
- package/dist/GridBookmarkWidget/components/dialogs/ImportBookmarksDialog.d.ts +0 -6
- package/dist/GridBookmarkWidget/components/dialogs/ImportBookmarksDialog.js +0 -115
- package/dist/GridBookmarkWidget/components/dialogs/ShareBookmarksDialog.d.ts +0 -6
- package/dist/GridBookmarkWidget/components/dialogs/ShareBookmarksDialog.js +0 -77
- package/dist/GridBookmarkWidget/index.d.ts +0 -2
- package/dist/GridBookmarkWidget/index.js +0 -57
- package/dist/GridBookmarkWidget/model.d.ts +0 -228
- package/dist/GridBookmarkWidget/model.js +0 -169
- package/dist/GridBookmarkWidget/sessionSharing.d.ts +0 -6
- package/dist/GridBookmarkWidget/sessionSharing.js +0 -99
- package/dist/GridBookmarkWidget/types.d.ts +0 -4
- package/dist/GridBookmarkWidget/types.js +0 -2
- package/dist/GridBookmarkWidget/utils.d.ts +0 -7
- package/dist/GridBookmarkWidget/utils.js +0 -144
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -185
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const ui_1 = require("@jbrowse/core/ui");
|
|
9
|
-
const util_1 = require("@jbrowse/core/util");
|
|
10
|
-
const io_1 = require("@jbrowse/core/util/io");
|
|
11
|
-
const types_1 = require("@jbrowse/core/util/types");
|
|
12
|
-
const ExpandMore_1 = __importDefault(require("@mui/icons-material/ExpandMore"));
|
|
13
|
-
const Publish_1 = __importDefault(require("@mui/icons-material/Publish"));
|
|
14
|
-
const material_1 = require("@mui/material");
|
|
15
|
-
const mobx_react_1 = require("mobx-react");
|
|
16
|
-
const mui_1 = require("tss-react/mui");
|
|
17
|
-
const sessionSharing_1 = require("../../sessionSharing");
|
|
18
|
-
const utils_1 = require("../../utils");
|
|
19
|
-
const useStyles = (0, mui_1.makeStyles)()(theme => ({
|
|
20
|
-
expandIcon: {
|
|
21
|
-
color: theme.palette.tertiary.contrastText || '#fff',
|
|
22
|
-
},
|
|
23
|
-
minWidth: {
|
|
24
|
-
minWidth: 500,
|
|
25
|
-
},
|
|
26
|
-
}));
|
|
27
|
-
async function getBookmarksFromShareLink(shareLink, shareURL) {
|
|
28
|
-
const defaultURL = 'https://share.jbrowse.org/api/v1/';
|
|
29
|
-
const urlParams = new URL(shareLink);
|
|
30
|
-
const sessionQueryParam = urlParams.searchParams.get('bookmarks');
|
|
31
|
-
const password = urlParams.searchParams.get('password');
|
|
32
|
-
const decryptedSession = await (0, sessionSharing_1.readSessionFromDynamo)(`${shareURL !== null && shareURL !== void 0 ? shareURL : defaultURL}load`, sessionQueryParam || '', password || '');
|
|
33
|
-
const sharedSession = JSON.parse(await (0, utils_1.fromUrlSafeB64)(decryptedSession));
|
|
34
|
-
return sharedSession.sharedBookmarks;
|
|
35
|
-
}
|
|
36
|
-
function guessFileType(header) {
|
|
37
|
-
return header.startsWith('chrom') && header.includes('assembly_name')
|
|
38
|
-
? 'TSV'
|
|
39
|
-
: 'BED';
|
|
40
|
-
}
|
|
41
|
-
async function getBookmarksFromTSVFile(lines) {
|
|
42
|
-
if (lines[0].startsWith('chrom')) {
|
|
43
|
-
lines = lines.slice(1);
|
|
44
|
-
}
|
|
45
|
-
return lines
|
|
46
|
-
.filter(f => !f.startsWith('#'))
|
|
47
|
-
.map(line => {
|
|
48
|
-
const [refName, start, end, label, assemblyName] = line.split('\t');
|
|
49
|
-
return {
|
|
50
|
-
assemblyName: assemblyName,
|
|
51
|
-
refName: refName,
|
|
52
|
-
start: +start,
|
|
53
|
-
end: +end,
|
|
54
|
-
label: label === '.' ? undefined : label,
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
async function getBookmarksFromBEDFile(lines, selectedAsm) {
|
|
59
|
-
return lines
|
|
60
|
-
.filter(f => !f.startsWith('#'))
|
|
61
|
-
.map(line => {
|
|
62
|
-
const [refName, start, end, label] = line.split('\t');
|
|
63
|
-
return {
|
|
64
|
-
assemblyName: selectedAsm,
|
|
65
|
-
refName: refName,
|
|
66
|
-
start: +start,
|
|
67
|
-
end: +end,
|
|
68
|
-
label: label === '.' ? undefined : label,
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
const ImportBookmarksDialog = (0, mobx_react_1.observer)(function ({ onClose, model, }) {
|
|
73
|
-
const { classes } = useStyles();
|
|
74
|
-
const [location, setLocation] = (0, react_1.useState)();
|
|
75
|
-
const [error, setError] = (0, react_1.useState)();
|
|
76
|
-
const [shareLink, setShareLink] = (0, react_1.useState)('');
|
|
77
|
-
const session = (0, util_1.getSession)(model);
|
|
78
|
-
const { assemblyNames } = session;
|
|
79
|
-
const [selectedAsm, setSelectedAsm] = (0, react_1.useState)(assemblyNames[0]);
|
|
80
|
-
const [expanded, setExpanded] = (0, react_1.useState)('shareLinkAccordion');
|
|
81
|
-
return ((0, jsx_runtime_1.jsxs)(ui_1.Dialog, { open: true, onClose: onClose, maxWidth: "xl", title: "Import bookmarks", children: [(0, jsx_runtime_1.jsxs)(material_1.DialogContent, { className: classes.minWidth, children: [(0, jsx_runtime_1.jsxs)(material_1.Accordion, { expanded: expanded === 'shareLinkAccordion', onChange: () => {
|
|
82
|
-
setExpanded('shareLinkAccordion');
|
|
83
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.AccordionSummary, { expandIcon: (0, jsx_runtime_1.jsx)(ExpandMore_1.default, { className: classes.expandIcon }), children: (0, jsx_runtime_1.jsx)(material_1.Typography, { style: { display: 'flex', alignItems: 'center', gap: '5px' }, children: "Import from share link" }) }), (0, jsx_runtime_1.jsxs)(material_1.AccordionDetails, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: "Paste a bookmark share link generated by the 'Share' button from the bookmarks widget" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Enter Share URL", variant: "outlined", fullWidth: true, value: shareLink, onChange: e => {
|
|
84
|
-
setShareLink(e.target.value);
|
|
85
|
-
} })] })] }), (0, jsx_runtime_1.jsxs)(material_1.Accordion, { expanded: expanded === 'fileAccordion', onChange: () => {
|
|
86
|
-
setExpanded('fileAccordion');
|
|
87
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.AccordionSummary, { expandIcon: (0, jsx_runtime_1.jsx)(ExpandMore_1.default, { className: classes.expandIcon }), children: (0, jsx_runtime_1.jsx)(material_1.Typography, { children: "Import from file" }) }), (0, jsx_runtime_1.jsxs)(material_1.AccordionDetails, { children: [(0, jsx_runtime_1.jsx)(ui_1.FileSelector, { location: location, setLocation: setLocation, name: "File", description: `Choose a BED or TSV format file to import. Required TSV column headers are "chrom, start, end, label, assembly_name".` }), (0, jsx_runtime_1.jsx)(ui_1.AssemblySelector, { onChange: val => {
|
|
88
|
-
setSelectedAsm(val);
|
|
89
|
-
}, helperText: 'Select the assembly for BED file.', session: session, selected: selectedAsm })] })] }), error ? (0, jsx_runtime_1.jsx)(ui_1.ErrorMessage, { error: error }) : null] }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "secondary", onClick: onClose, children: "Cancel" }), (0, jsx_runtime_1.jsx)(material_1.Button, { "data-testid": "dialogImport", variant: "contained", color: "primary", disabled: !location && !shareLink, startIcon: (0, jsx_runtime_1.jsx)(Publish_1.default, {}), onClick: async () => {
|
|
90
|
-
try {
|
|
91
|
-
if (expanded === 'fileAccordion' && location) {
|
|
92
|
-
const data = await (0, io_1.openLocation)(location).readFile('utf8');
|
|
93
|
-
const lines = data.split(/\n|\r\n|\r/).filter(f => !!f.trim());
|
|
94
|
-
const fileType = guessFileType(lines[0]);
|
|
95
|
-
if (fileType === 'BED') {
|
|
96
|
-
model.importBookmarks(await getBookmarksFromBEDFile(lines, selectedAsm));
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
model.importBookmarks(await getBookmarksFromTSVFile(lines));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
else if (expanded === 'shareLinkAccordion' &&
|
|
103
|
-
shareLink &&
|
|
104
|
-
(0, types_1.isSessionWithShareURL)(session)) {
|
|
105
|
-
model.importBookmarks(await getBookmarksFromShareLink(shareLink, session.shareURL));
|
|
106
|
-
}
|
|
107
|
-
onClose();
|
|
108
|
-
}
|
|
109
|
-
catch (e) {
|
|
110
|
-
console.error(e);
|
|
111
|
-
setError(e);
|
|
112
|
-
}
|
|
113
|
-
}, children: "Import" })] })] }));
|
|
114
|
-
});
|
|
115
|
-
exports.default = ImportBookmarksDialog;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const ui_1 = require("@jbrowse/core/ui");
|
|
9
|
-
const util_1 = require("@jbrowse/core/util");
|
|
10
|
-
const ContentCopy_1 = __importDefault(require("@mui/icons-material/ContentCopy"));
|
|
11
|
-
const material_1 = require("@mui/material");
|
|
12
|
-
const copy_to_clipboard_1 = __importDefault(require("copy-to-clipboard"));
|
|
13
|
-
const mobx_react_1 = require("mobx-react");
|
|
14
|
-
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
15
|
-
const mui_1 = require("tss-react/mui");
|
|
16
|
-
const sessionSharing_1 = require("../../sessionSharing");
|
|
17
|
-
const useStyles = (0, mui_1.makeStyles)()(() => ({
|
|
18
|
-
flexItem: {
|
|
19
|
-
margin: 5,
|
|
20
|
-
},
|
|
21
|
-
content: {
|
|
22
|
-
display: 'flex',
|
|
23
|
-
flexFlow: 'column',
|
|
24
|
-
gap: '5px',
|
|
25
|
-
},
|
|
26
|
-
}));
|
|
27
|
-
const ShareBookmarksDialog = (0, mobx_react_1.observer)(function ({ onClose, model, }) {
|
|
28
|
-
const { classes } = useStyles();
|
|
29
|
-
const [url, setUrl] = (0, react_1.useState)('');
|
|
30
|
-
const [error, setError] = (0, react_1.useState)();
|
|
31
|
-
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
32
|
-
const session = (0, util_1.getSession)(model);
|
|
33
|
-
const { selectedBookmarks } = model;
|
|
34
|
-
const shareAll = selectedBookmarks.length === 0;
|
|
35
|
-
const bookmarksToShare = selectedBookmarks.length === 0
|
|
36
|
-
? model.allBookmarksModel
|
|
37
|
-
: model.sharedBookmarksModel;
|
|
38
|
-
(0, react_1.useEffect)(() => {
|
|
39
|
-
;
|
|
40
|
-
(async () => {
|
|
41
|
-
try {
|
|
42
|
-
if (!(0, util_1.isSessionWithShareURL)(session)) {
|
|
43
|
-
throw new Error('No shareURL configured');
|
|
44
|
-
}
|
|
45
|
-
setLoading(true);
|
|
46
|
-
const snap = (0, mobx_state_tree_1.getSnapshot)(bookmarksToShare);
|
|
47
|
-
const locationUrl = new URL(window.location.href);
|
|
48
|
-
const result = await (0, sessionSharing_1.shareSessionToDynamo)(snap, session.shareURL, locationUrl.href);
|
|
49
|
-
const params = new URLSearchParams(locationUrl.search);
|
|
50
|
-
params.set('bookmarks', `share-${result.json.sessionId}`);
|
|
51
|
-
params.set('password', result.password);
|
|
52
|
-
locationUrl.search = params.toString();
|
|
53
|
-
setUrl(locationUrl.href);
|
|
54
|
-
setLoading(false);
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
setError(e);
|
|
58
|
-
}
|
|
59
|
-
finally {
|
|
60
|
-
setLoading(false);
|
|
61
|
-
}
|
|
62
|
-
})();
|
|
63
|
-
}, [bookmarksToShare, session]);
|
|
64
|
-
return ((0, jsx_runtime_1.jsxs)(ui_1.Dialog, { open: true, onClose: onClose, title: "Share bookmarks", children: [(0, jsx_runtime_1.jsxs)(material_1.DialogContent, { className: classes.content, children: [(0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "info", children: shareAll ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { children: "All bookmarks will be shared." }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("span", { children: "Use the checkboxes to select individual bookmarks to share." })] })) : ('Only selected bookmarks will be shared.') }), (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: "Copy the URL below to share your bookmarks." }), error ? ((0, jsx_runtime_1.jsx)(ui_1.ErrorMessage, { error: error })) : loading ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { children: "Generating short URL..." })) : ((0, jsx_runtime_1.jsx)(material_1.TextField, { label: "URL", value: url, slotProps: {
|
|
65
|
-
input: {
|
|
66
|
-
readOnly: true,
|
|
67
|
-
},
|
|
68
|
-
}, variant: "filled", fullWidth: true, onClick: event => {
|
|
69
|
-
const target = event.target;
|
|
70
|
-
target.select();
|
|
71
|
-
} })), (0, jsx_runtime_1.jsx)(material_1.DialogContentText, { children: "The URL should be pasted into the \"Import from share link\" field in the \"Import\" form found in the \"Bookmarked regions\" drawer." })] }), (0, jsx_runtime_1.jsx)(material_1.DialogActions, { children: (0, jsx_runtime_1.jsx)(material_1.Button, { className: classes.flexItem, "data-testid": "dialogShare", variant: "contained", color: "primary", disabled: loading, startIcon: (0, jsx_runtime_1.jsx)(ContentCopy_1.default, {}), onClick: async () => {
|
|
72
|
-
(0, copy_to_clipboard_1.default)(url);
|
|
73
|
-
session.notify('Copied to clipboard', 'success');
|
|
74
|
-
onClose();
|
|
75
|
-
}, children: "Copy share link" }) })] }));
|
|
76
|
-
});
|
|
77
|
-
exports.default = ShareBookmarksDialog;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.default = GridBookmarkWidgetF;
|
|
40
|
-
const react_1 = require("react");
|
|
41
|
-
const configuration_1 = require("@jbrowse/core/configuration");
|
|
42
|
-
const pluggableElementTypes_1 = require("@jbrowse/core/pluggableElementTypes");
|
|
43
|
-
const Highlight_1 = __importDefault(require("./components/Highlight"));
|
|
44
|
-
const model_1 = __importDefault(require("./model"));
|
|
45
|
-
const configSchema = (0, configuration_1.ConfigurationSchema)('GridBookmarkWidget', {});
|
|
46
|
-
function GridBookmarkWidgetF(pluginManager) {
|
|
47
|
-
pluginManager.addWidgetType(() => {
|
|
48
|
-
return new pluggableElementTypes_1.WidgetType({
|
|
49
|
-
name: 'GridBookmarkWidget',
|
|
50
|
-
heading: 'Bookmarked regions',
|
|
51
|
-
configSchema,
|
|
52
|
-
stateModel: (0, model_1.default)(pluginManager),
|
|
53
|
-
ReactComponent: (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./components/GridBookmarkWidget')))),
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
(0, Highlight_1.default)(pluginManager);
|
|
57
|
-
}
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
2
|
-
import type { Region } from '@jbrowse/core/util/types';
|
|
3
|
-
import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
|
|
4
|
-
import type { IMSTArray, Instance, SnapshotIn } from 'mobx-state-tree';
|
|
5
|
-
declare const LabeledRegionModel: import("mobx-state-tree").IModelType<{
|
|
6
|
-
refName: import("mobx-state-tree").ISimpleType<string>;
|
|
7
|
-
start: import("mobx-state-tree").ISimpleType<number>;
|
|
8
|
-
end: import("mobx-state-tree").ISimpleType<number>;
|
|
9
|
-
reversed: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
|
|
10
|
-
} & {
|
|
11
|
-
assemblyName: import("mobx-state-tree").ISimpleType<string>;
|
|
12
|
-
} & {
|
|
13
|
-
label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
14
|
-
highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
15
|
-
}, {
|
|
16
|
-
setRefName(newRefName: string): void;
|
|
17
|
-
} & {
|
|
18
|
-
setLabel(label: string): void;
|
|
19
|
-
setHighlight(color: string): void;
|
|
20
|
-
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
21
|
-
export interface IExtendedLGV extends LinearGenomeViewModel {
|
|
22
|
-
bookmarkHighlightsVisible: boolean;
|
|
23
|
-
bookmarkLabelsVisible: boolean;
|
|
24
|
-
setBookmarkHighlightsVisible: (arg: boolean) => void;
|
|
25
|
-
setBookmarkLabelsVisible: (arg: boolean) => void;
|
|
26
|
-
}
|
|
27
|
-
export interface ILabeledRegionModel extends SnapshotIn<typeof LabeledRegionModel> {
|
|
28
|
-
refName: string;
|
|
29
|
-
start: number;
|
|
30
|
-
end: number;
|
|
31
|
-
reversed: boolean;
|
|
32
|
-
highlight: string;
|
|
33
|
-
assemblyName: string;
|
|
34
|
-
label: string;
|
|
35
|
-
setRefName: (newRefName: string) => void;
|
|
36
|
-
setLabel: (label: string) => void;
|
|
37
|
-
setHighlight: (color: string) => void;
|
|
38
|
-
}
|
|
39
|
-
export interface IExtendedLabeledRegionModel extends ILabeledRegionModel {
|
|
40
|
-
id: number;
|
|
41
|
-
correspondingObj: ILabeledRegionModel;
|
|
42
|
-
}
|
|
43
|
-
export default function f(_pluginManager: PluginManager): import("mobx-state-tree").IModelType<{
|
|
44
|
-
id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
45
|
-
type: import("mobx-state-tree").ISimpleType<"GridBookmarkWidget">;
|
|
46
|
-
bookmarks: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
|
|
47
|
-
refName: import("mobx-state-tree").ISimpleType<string>;
|
|
48
|
-
start: import("mobx-state-tree").ISimpleType<number>;
|
|
49
|
-
end: import("mobx-state-tree").ISimpleType<number>;
|
|
50
|
-
reversed: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
|
|
51
|
-
} & {
|
|
52
|
-
assemblyName: import("mobx-state-tree").ISimpleType<string>;
|
|
53
|
-
} & {
|
|
54
|
-
label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
55
|
-
highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
56
|
-
}, {
|
|
57
|
-
setRefName(newRefName: string): void;
|
|
58
|
-
} & {
|
|
59
|
-
setLabel(label: string): void;
|
|
60
|
-
setHighlight(color: string): void;
|
|
61
|
-
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>, [undefined]>;
|
|
62
|
-
}, {
|
|
63
|
-
selectedBookmarks: IExtendedLabeledRegionModel[];
|
|
64
|
-
selectedAssembliesPre: string[] | undefined;
|
|
65
|
-
} & {
|
|
66
|
-
readonly bookmarkAssemblies: string[];
|
|
67
|
-
readonly validAssemblies: Set<string>;
|
|
68
|
-
readonly areBookmarksHighlightedOnAllOpenViews: boolean;
|
|
69
|
-
readonly areBookmarksHighlightLabelsOnAllOpenViews: boolean;
|
|
70
|
-
} & {
|
|
71
|
-
readonly bookmarksWithValidAssemblies: ({
|
|
72
|
-
refName: string;
|
|
73
|
-
start: number;
|
|
74
|
-
end: number;
|
|
75
|
-
reversed: boolean;
|
|
76
|
-
assemblyName: string;
|
|
77
|
-
label: string;
|
|
78
|
-
highlight: string;
|
|
79
|
-
} & import("mobx-state-tree/dist/internal").NonEmptyObject & {
|
|
80
|
-
setRefName(newRefName: string): void;
|
|
81
|
-
} & {
|
|
82
|
-
setLabel(label: string): void;
|
|
83
|
-
setHighlight(color: string): void;
|
|
84
|
-
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
85
|
-
refName: import("mobx-state-tree").ISimpleType<string>;
|
|
86
|
-
start: import("mobx-state-tree").ISimpleType<number>;
|
|
87
|
-
end: import("mobx-state-tree").ISimpleType<number>;
|
|
88
|
-
reversed: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
|
|
89
|
-
} & {
|
|
90
|
-
assemblyName: import("mobx-state-tree").ISimpleType<string>;
|
|
91
|
-
} & {
|
|
92
|
-
label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
93
|
-
highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
94
|
-
}, {
|
|
95
|
-
setRefName(newRefName: string): void;
|
|
96
|
-
} & {
|
|
97
|
-
setLabel(label: string): void;
|
|
98
|
-
setHighlight(color: string): void;
|
|
99
|
-
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>)[];
|
|
100
|
-
} & {
|
|
101
|
-
readonly sharedBookmarksModel: {
|
|
102
|
-
sharedBookmarks: (IMSTArray<import("mobx-state-tree").IModelType<{
|
|
103
|
-
refName: import("mobx-state-tree").ISimpleType<string>;
|
|
104
|
-
start: import("mobx-state-tree").ISimpleType<number>;
|
|
105
|
-
end: import("mobx-state-tree").ISimpleType<number>;
|
|
106
|
-
reversed: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
|
|
107
|
-
} & {
|
|
108
|
-
assemblyName: import("mobx-state-tree").ISimpleType<string>;
|
|
109
|
-
} & {
|
|
110
|
-
label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
111
|
-
highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
112
|
-
}, {
|
|
113
|
-
setRefName(newRefName: string): void;
|
|
114
|
-
} & {
|
|
115
|
-
setLabel(label: string): void;
|
|
116
|
-
setHighlight(color: string): void;
|
|
117
|
-
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>> & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IMaybe<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
|
|
118
|
-
refName: import("mobx-state-tree").ISimpleType<string>;
|
|
119
|
-
start: import("mobx-state-tree").ISimpleType<number>;
|
|
120
|
-
end: import("mobx-state-tree").ISimpleType<number>;
|
|
121
|
-
reversed: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
|
|
122
|
-
} & {
|
|
123
|
-
assemblyName: import("mobx-state-tree").ISimpleType<string>;
|
|
124
|
-
} & {
|
|
125
|
-
label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
126
|
-
highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
127
|
-
}, {
|
|
128
|
-
setRefName(newRefName: string): void;
|
|
129
|
-
} & {
|
|
130
|
-
setLabel(label: string): void;
|
|
131
|
-
setHighlight(color: string): void;
|
|
132
|
-
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>>>) | undefined;
|
|
133
|
-
} & import("mobx-state-tree/dist/internal").NonEmptyObject & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
134
|
-
sharedBookmarks: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
|
|
135
|
-
refName: import("mobx-state-tree").ISimpleType<string>;
|
|
136
|
-
start: import("mobx-state-tree").ISimpleType<number>;
|
|
137
|
-
end: import("mobx-state-tree").ISimpleType<number>;
|
|
138
|
-
reversed: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
|
|
139
|
-
} & {
|
|
140
|
-
assemblyName: import("mobx-state-tree").ISimpleType<string>;
|
|
141
|
-
} & {
|
|
142
|
-
label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
143
|
-
highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
144
|
-
}, {
|
|
145
|
-
setRefName(newRefName: string): void;
|
|
146
|
-
} & {
|
|
147
|
-
setLabel(label: string): void;
|
|
148
|
-
setHighlight(color: string): void;
|
|
149
|
-
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>>;
|
|
150
|
-
}, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
|
|
151
|
-
readonly allBookmarksModel: {
|
|
152
|
-
sharedBookmarks: (IMSTArray<import("mobx-state-tree").IModelType<{
|
|
153
|
-
refName: import("mobx-state-tree").ISimpleType<string>;
|
|
154
|
-
start: import("mobx-state-tree").ISimpleType<number>;
|
|
155
|
-
end: import("mobx-state-tree").ISimpleType<number>;
|
|
156
|
-
reversed: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
|
|
157
|
-
} & {
|
|
158
|
-
assemblyName: import("mobx-state-tree").ISimpleType<string>;
|
|
159
|
-
} & {
|
|
160
|
-
label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
161
|
-
highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
162
|
-
}, {
|
|
163
|
-
setRefName(newRefName: string): void;
|
|
164
|
-
} & {
|
|
165
|
-
setLabel(label: string): void;
|
|
166
|
-
setHighlight(color: string): void;
|
|
167
|
-
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>> & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IMaybe<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
|
|
168
|
-
refName: import("mobx-state-tree").ISimpleType<string>;
|
|
169
|
-
start: import("mobx-state-tree").ISimpleType<number>;
|
|
170
|
-
end: import("mobx-state-tree").ISimpleType<number>;
|
|
171
|
-
reversed: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
|
|
172
|
-
} & {
|
|
173
|
-
assemblyName: import("mobx-state-tree").ISimpleType<string>;
|
|
174
|
-
} & {
|
|
175
|
-
label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
176
|
-
highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
177
|
-
}, {
|
|
178
|
-
setRefName(newRefName: string): void;
|
|
179
|
-
} & {
|
|
180
|
-
setLabel(label: string): void;
|
|
181
|
-
setHighlight(color: string): void;
|
|
182
|
-
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>>>) | undefined;
|
|
183
|
-
} & import("mobx-state-tree/dist/internal").NonEmptyObject & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
184
|
-
sharedBookmarks: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
|
|
185
|
-
refName: import("mobx-state-tree").ISimpleType<string>;
|
|
186
|
-
start: import("mobx-state-tree").ISimpleType<number>;
|
|
187
|
-
end: import("mobx-state-tree").ISimpleType<number>;
|
|
188
|
-
reversed: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
|
|
189
|
-
} & {
|
|
190
|
-
assemblyName: import("mobx-state-tree").ISimpleType<string>;
|
|
191
|
-
} & {
|
|
192
|
-
label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
193
|
-
highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
194
|
-
}, {
|
|
195
|
-
setRefName(newRefName: string): void;
|
|
196
|
-
} & {
|
|
197
|
-
setLabel(label: string): void;
|
|
198
|
-
setHighlight(color: string): void;
|
|
199
|
-
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>>;
|
|
200
|
-
}, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
|
|
201
|
-
} & {
|
|
202
|
-
setSelectedAssemblies(assemblies?: string[]): void;
|
|
203
|
-
} & {
|
|
204
|
-
readonly selectedAssemblies: string[];
|
|
205
|
-
} & {
|
|
206
|
-
importBookmarks(regions: Region[]): void;
|
|
207
|
-
addBookmark(region: Region): void;
|
|
208
|
-
removeBookmark(index: number): void;
|
|
209
|
-
updateBookmarkLabel(bookmark: IExtendedLabeledRegionModel, label: string): void;
|
|
210
|
-
updateBookmarkHighlight(bookmark: IExtendedLabeledRegionModel, color: string): void;
|
|
211
|
-
updateBulkBookmarkHighlights(color: string): void;
|
|
212
|
-
setSelectedBookmarks(bookmarks: IExtendedLabeledRegionModel[]): void;
|
|
213
|
-
setBookmarkedRegions(regions: IMSTArray<typeof LabeledRegionModel>): void;
|
|
214
|
-
setBookmarkHighlightsVisible(arg: boolean): void;
|
|
215
|
-
setBookmarkLabelsVisible(arg: boolean): void;
|
|
216
|
-
} & {
|
|
217
|
-
clearAllBookmarks(): void;
|
|
218
|
-
clearSelectedBookmarks(): void;
|
|
219
|
-
removeBookmarkObject(arg: Instance<typeof LabeledRegionModel>): void;
|
|
220
|
-
} & {
|
|
221
|
-
afterAttach(): void;
|
|
222
|
-
}, import("mobx-state-tree")._NotCustomized, {
|
|
223
|
-
type: "GridBookmarkWidget";
|
|
224
|
-
id: string;
|
|
225
|
-
}>;
|
|
226
|
-
export type GridBookmarkStateModel = ReturnType<typeof f>;
|
|
227
|
-
export type GridBookmarkModel = Instance<GridBookmarkStateModel>;
|
|
228
|
-
export {};
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = f;
|
|
4
|
-
const util_1 = require("@jbrowse/core/util");
|
|
5
|
-
const mst_1 = require("@jbrowse/core/util/types/mst");
|
|
6
|
-
const mobx_1 = require("mobx");
|
|
7
|
-
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
8
|
-
const LabeledRegionModel = mobx_state_tree_1.types
|
|
9
|
-
.compose(mst_1.Region, mobx_state_tree_1.types.model('Label', {
|
|
10
|
-
label: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.string, ''),
|
|
11
|
-
highlight: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.string, 'rgba(247, 129, 192, 0.35)'),
|
|
12
|
-
}))
|
|
13
|
-
.actions(self => ({
|
|
14
|
-
setLabel(label) {
|
|
15
|
-
self.label = label;
|
|
16
|
-
},
|
|
17
|
-
setHighlight(color) {
|
|
18
|
-
self.highlight = color;
|
|
19
|
-
},
|
|
20
|
-
}));
|
|
21
|
-
const SharedBookmarksModel = mobx_state_tree_1.types.model('SharedBookmarksModel', {
|
|
22
|
-
sharedBookmarks: mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.array(LabeledRegionModel)),
|
|
23
|
-
});
|
|
24
|
-
const localStorageKeyF = () => typeof window !== 'undefined'
|
|
25
|
-
? `bookmarks-${[window.location.host + window.location.pathname].join('-')}`
|
|
26
|
-
: 'empty';
|
|
27
|
-
function f(_pluginManager) {
|
|
28
|
-
return mobx_state_tree_1.types
|
|
29
|
-
.model('GridBookmarkModel', {
|
|
30
|
-
id: mst_1.ElementId,
|
|
31
|
-
type: mobx_state_tree_1.types.literal('GridBookmarkWidget'),
|
|
32
|
-
bookmarks: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.array(LabeledRegionModel), () => JSON.parse((0, util_1.localStorageGetItem)(localStorageKeyF()) || '[]')),
|
|
33
|
-
})
|
|
34
|
-
.volatile(() => ({
|
|
35
|
-
selectedBookmarks: [],
|
|
36
|
-
selectedAssembliesPre: undefined,
|
|
37
|
-
}))
|
|
38
|
-
.views(self => ({
|
|
39
|
-
get bookmarkAssemblies() {
|
|
40
|
-
return [...new Set(self.bookmarks.map(r => r.assemblyName))];
|
|
41
|
-
},
|
|
42
|
-
get validAssemblies() {
|
|
43
|
-
const { assemblyManager } = (0, util_1.getSession)(self);
|
|
44
|
-
return new Set(this.bookmarkAssemblies.filter(a => assemblyManager.get(a)));
|
|
45
|
-
},
|
|
46
|
-
get areBookmarksHighlightedOnAllOpenViews() {
|
|
47
|
-
const { views } = (0, util_1.getSession)(self);
|
|
48
|
-
return views.every(v => 'bookmarkHighlightsVisible' in v ? v.bookmarkHighlightsVisible : true);
|
|
49
|
-
},
|
|
50
|
-
get areBookmarksHighlightLabelsOnAllOpenViews() {
|
|
51
|
-
const { views } = (0, util_1.getSession)(self);
|
|
52
|
-
return views.every(v => 'bookmarkLabelsVisible' in v ? v.bookmarkLabelsVisible : true);
|
|
53
|
-
},
|
|
54
|
-
}))
|
|
55
|
-
.views(self => ({
|
|
56
|
-
get bookmarksWithValidAssemblies() {
|
|
57
|
-
return self.bookmarks.filter(e => self.validAssemblies.has(e.assemblyName));
|
|
58
|
-
},
|
|
59
|
-
}))
|
|
60
|
-
.views(self => ({
|
|
61
|
-
get sharedBookmarksModel() {
|
|
62
|
-
return SharedBookmarksModel.create({
|
|
63
|
-
sharedBookmarks: JSON.parse(JSON.stringify(self.selectedBookmarks)),
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
get allBookmarksModel() {
|
|
67
|
-
return SharedBookmarksModel.create({
|
|
68
|
-
sharedBookmarks: JSON.parse(JSON.stringify(self.bookmarksWithValidAssemblies)),
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
}))
|
|
72
|
-
.actions(self => ({
|
|
73
|
-
setSelectedAssemblies(assemblies) {
|
|
74
|
-
self.selectedAssembliesPre = assemblies;
|
|
75
|
-
},
|
|
76
|
-
}))
|
|
77
|
-
.views(self => ({
|
|
78
|
-
get selectedAssemblies() {
|
|
79
|
-
var _a, _b;
|
|
80
|
-
return ((_b = (_a = self.selectedAssembliesPre) === null || _a === void 0 ? void 0 : _a.filter(f => self.validAssemblies.has(f))) !== null && _b !== void 0 ? _b : [...self.validAssemblies]);
|
|
81
|
-
},
|
|
82
|
-
}))
|
|
83
|
-
.actions(self => ({
|
|
84
|
-
importBookmarks(regions) {
|
|
85
|
-
self.bookmarks = (0, mobx_state_tree_1.cast)([...self.bookmarks, ...regions]);
|
|
86
|
-
},
|
|
87
|
-
addBookmark(region) {
|
|
88
|
-
self.bookmarks.push(region);
|
|
89
|
-
},
|
|
90
|
-
removeBookmark(index) {
|
|
91
|
-
self.bookmarks.splice(index, 1);
|
|
92
|
-
},
|
|
93
|
-
updateBookmarkLabel(bookmark, label) {
|
|
94
|
-
bookmark.correspondingObj.setLabel(label);
|
|
95
|
-
},
|
|
96
|
-
updateBookmarkHighlight(bookmark, color) {
|
|
97
|
-
bookmark.correspondingObj.setHighlight(color);
|
|
98
|
-
},
|
|
99
|
-
updateBulkBookmarkHighlights(color) {
|
|
100
|
-
for (const bookmark of self.selectedBookmarks) {
|
|
101
|
-
this.updateBookmarkHighlight(bookmark, color);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
setSelectedBookmarks(bookmarks) {
|
|
105
|
-
self.selectedBookmarks = bookmarks;
|
|
106
|
-
},
|
|
107
|
-
setBookmarkedRegions(regions) {
|
|
108
|
-
self.bookmarks = (0, mobx_state_tree_1.cast)(regions);
|
|
109
|
-
},
|
|
110
|
-
setBookmarkHighlightsVisible(arg) {
|
|
111
|
-
var _a, _b;
|
|
112
|
-
const { views } = (0, util_1.getSession)(self);
|
|
113
|
-
for (const view of views) {
|
|
114
|
-
(_a = view.setBookmarkHighlightsVisible) === null || _a === void 0 ? void 0 : _a.call(view, arg);
|
|
115
|
-
(_b = view.views) === null || _b === void 0 ? void 0 : _b.map(view => {
|
|
116
|
-
var _a;
|
|
117
|
-
(_a = view.setBookmarkHighlightsVisible) === null || _a === void 0 ? void 0 : _a.call(view, arg);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
setBookmarkLabelsVisible(arg) {
|
|
122
|
-
var _a, _b;
|
|
123
|
-
const { views } = (0, util_1.getSession)(self);
|
|
124
|
-
for (const view of views) {
|
|
125
|
-
(_a = view.setBookmarkLabelsVisible) === null || _a === void 0 ? void 0 : _a.call(view, arg);
|
|
126
|
-
(_b = view.views) === null || _b === void 0 ? void 0 : _b.map(view => {
|
|
127
|
-
var _a;
|
|
128
|
-
(_a = view.setBookmarkHighlightsVisible) === null || _a === void 0 ? void 0 : _a.call(view, arg);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
}))
|
|
133
|
-
.actions(self => ({
|
|
134
|
-
clearAllBookmarks() {
|
|
135
|
-
self.setBookmarkedRegions(self.bookmarks.filter(bookmark => !self.validAssemblies.has(bookmark.assemblyName)));
|
|
136
|
-
},
|
|
137
|
-
clearSelectedBookmarks() {
|
|
138
|
-
for (const bookmark of self.selectedBookmarks) {
|
|
139
|
-
self.bookmarks.remove(bookmark.correspondingObj);
|
|
140
|
-
}
|
|
141
|
-
self.selectedBookmarks = [];
|
|
142
|
-
},
|
|
143
|
-
removeBookmarkObject(arg) {
|
|
144
|
-
self.bookmarks.remove(arg);
|
|
145
|
-
},
|
|
146
|
-
}))
|
|
147
|
-
.actions(self => ({
|
|
148
|
-
afterAttach() {
|
|
149
|
-
const key = localStorageKeyF();
|
|
150
|
-
function handler(e) {
|
|
151
|
-
if (e.key === key) {
|
|
152
|
-
const localStorage = JSON.parse((0, util_1.localStorageGetItem)(key) || '[]');
|
|
153
|
-
self.setBookmarkedRegions(localStorage);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
window.addEventListener('storage', handler);
|
|
157
|
-
(0, mobx_state_tree_1.addDisposer)(self, () => {
|
|
158
|
-
window.removeEventListener('storage', handler);
|
|
159
|
-
});
|
|
160
|
-
(0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.autorun)(() => {
|
|
161
|
-
(0, util_1.localStorageSetItem)(key, JSON.stringify(self.bookmarks));
|
|
162
|
-
}));
|
|
163
|
-
},
|
|
164
|
-
}))
|
|
165
|
-
.postProcessSnapshot(snap => {
|
|
166
|
-
const { bookmarks: _, ...rest } = snap;
|
|
167
|
-
return rest;
|
|
168
|
-
});
|
|
169
|
-
}
|