UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

71 lines (70 loc) 3.22 kB
import { jsxs as n, jsx as o } from "react/jsx-runtime"; import { useState as p } from "react"; import { o as m, m as b, P as f, c as h, B as g, t as y, u } from "./JBrowsePanel-uJIA-L6s.js"; const w = b()((t) => ({ paper: { margin: t.spacing(), padding: t.spacing() }, submit: { marginTop: 25, marginBottom: 100, display: "block" } })); function k(t) { const { webUtils: s } = window.require("electron"); return u.isElectron ? { localPath: s.getPathForFile(t), locationType: "LocalPathLocation" } : y.storeBlobLocation({ blob: t }); } function x({ trackName: t, val: s, model: a }) { var l; const i = u.getSession(a); try { const r = [ `${t.toLowerCase().replaceAll(" ", "_")}-${Date.now()}`, i.adminMode ? "" : "-sessionTrack" ].join(""); let e; try { e = JSON.parse(s); } catch { e = s.split(/\n|\r\n|\r/).map((d) => d.trim()).filter((d) => !!d); } const c = typeof e[0] == "string" ? { bigWigs: e } : { subadapters: e }; u.isSessionWithAddTracks(i) && (i.addTrackConf({ trackId: r, type: "MultiQuantitativeTrack", name: t, assemblyNames: [a.assembly], adapter: { type: "MultiWiggleAdapter", ...c } }), (l = a.view) === null || l === void 0 || l.showTrack(r)), a.clearData(), u.isSessionModelWithWidgets(i) && i.hideWidget(a); } catch (r) { console.error(r), i.notifyError(`${r}`, r); } } const L = m(function({ model: t }) { const { classes: s } = w(), [a, l] = p(""), [i, r] = p(`MultiWiggle${+Date.now()}`); return n(f, { className: s.paper, children: [n("ul", { children: [o("li", { children: "Enter list of URLs for bigwig files in the textbox" }), o("li", { children: "Or, use the button below the text box to select files from your computer" })] }), o(h, { multiline: !0, fullWidth: !0, rows: 10, value: a, placeholder: "Paste list of URLs here, or use file selector below", variant: "outlined", onChange: (e) => { l(e.target.value); } }), n(g, { variant: "outlined", component: "label", children: ["Choose Files from your computer", o("input", { type: "file", hidden: !0, multiple: !0, onChange: ({ target: e }) => { l(JSON.stringify([...e.files || []].map((c) => ({ type: "BigWigAdapter", bigWigLocation: k(c), source: c.name })), null, 2)); } })] }), o(h, { value: i, helperText: "Track name", onChange: (e) => { r(e.target.value); } }), o(g, { variant: "contained", className: s.submit, onClick: () => { x({ trackName: i, val: a, model: t }); }, children: "Submit" }), o("p", { children: "Additional notes: " }), n("ul", { children: [n("li", { children: ["The list of bigwig files in the text box can be a list of URLs, or a list of elements like", " ", o("code", { children: '[{"type":"BigWigAdapter","bigWigLocation":{"uri":"http://host/file.bw"}, "color":"green","source":"name for subtrack"}]' }), " ", "to apply e.g. the color attribute to the view"] }), o("li", { children: 'Adding local files will update the textbox with JSON contents that are ready to submit with the "Submit" button' })] })] }); }); export { L as default }; //# sourceMappingURL=AddTrackWorkflow-BHFThDq6.js.map