taxonium-component
Version:
React component for exploring large phylogenetic trees in the browser
70 lines (69 loc) • 3.2 kB
JavaScript
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-BNE3gNW1.js";
const w = b()((t) => ({
paper: {
margin: t.spacing(),
padding: t.spacing()
},
submit: {
marginTop: 25,
marginBottom: 100,
display: "block"
}
}));
function k(t) {
return u.isElectron ? {
localPath: window.require("electron").webUtils.getPathForFile(t),
locationType: "LocalPathLocation"
} : y.storeBlobLocation({ blob: t });
}
function x({ trackName: t, val: l, model: a }) {
var s;
const i = u.getSession(a);
try {
const r = [
`${t.toLowerCase().replaceAll(" ", "_")}-${Date.now()}`,
i.adminMode ? "" : "-sessionTrack"
].join("");
let e;
try {
e = JSON.parse(l);
} catch {
e = l.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
}
}), (s = a.view) === null || s === void 0 || s.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: l } = w(), [a, s] = p(""), [i, r] = p(`MultiWiggle${+Date.now()}`);
return n(f, { className: l.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) => {
s(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 }) => {
s(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: l.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-BJkSDUPq.js.map