Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into chat_update
Browse files Browse the repository at this point in the history
  • Loading branch information
xinaesthete committed Feb 14, 2025
2 parents 0b07853 + 3006193 commit 8743def
Show file tree
Hide file tree
Showing 8 changed files with 1,320 additions and 983 deletions.
3 changes: 2 additions & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ f93a09e0378b55a47faebf5690cb036aab4e99a2
7f4bd896704515f9ee9516db6c6863506c31be7e
1ca81b4f4197e05c343effcd6ca4023b16c4cec3
0fc6b2764b5e88cdc1c7059d9495503f842c1836
a845e698b8ab953d09d7564df18430bb1e96ceec
a845e698b8ab953d09d7564df18430bb1e96ceec
1f325bae9d511441722c83d4cffafee907557489
90 changes: 55 additions & 35 deletions src/charts/ChartManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ import { toPng } from "html-to-image";
import popoutChart from "@/utilities/Popout";
import { makeObservable, observable, action } from "mobx";
import { AddChartDialog } from "./dialogs/AddChartDialog";
import ErrorComponentReactWrapper from "@/react/components/ErrorComponentReactWrapper";
import { createMdvPortal } from "@/react/react_utils";

//order of column data in an array buffer
//doubles and integers (both represented by float32) and int32 need to be first
Expand Down Expand Up @@ -174,7 +176,7 @@ export class ChartManager {
* menuBar the dom menu associated with this element
* contentDiv the div that the charts associated with the datastore will be added
* @typedef {import("@/charts/charts/DataSource")} DataSource
* @type {DataSource[]}
* @type {DataSource[]}
*/
this.dataSources = [];
/** @type {{[k: string]: DataSource | undefined}} */
Expand Down Expand Up @@ -235,7 +237,6 @@ export class ChartManager {

createEl("span", { classes: ["mdv-divider"] }, this.menuBar);


/** @type {HTMLSpanElement} */
const homeButton = createMenuIcon(
"fas fa-home",
Expand All @@ -247,7 +248,9 @@ export class ChartManager {
func: () => {
// const state = this.getState();
// this._callListeners("state_saved", state);
window.location.href = import.meta.env.DEV ? `${window.location.origin}/catalog_dev` : `${window.location.origin}/../`;
window.location.href = import.meta.env.DEV
? `${window.location.origin}/catalog_dev`
: `${window.location.origin}/../`;
},
},
this.menuBar,
Expand Down Expand Up @@ -1082,7 +1085,10 @@ export class ChartManager {
// (also probably refactor this dialog into react)
// considered returning a string to set a tooltip or something, parked that idea for now pending more thought/refactoring
// validate: (v) => this.viewSelect.childNodes.values().some(e => e.value === v) ? "Name already exists" : null,
validate: (v) => !this.viewSelect.childNodes.values().some(e => e.value === v),
validate: (v) =>
!this.viewSelect.childNodes
.values()
.some((e) => e.value === v),
},
];
if (this.dataSources.length > 1) {
Expand Down Expand Up @@ -1454,8 +1460,8 @@ export class ChartManager {
const view = JSON.parse(JSON.stringify(this.viewData));
view.initialCharts = initialCharts;
const all_views = this.viewSelect
// @ts-ignore do we know that we actually have elements with 'value'?
? Array.from(this.viewSelect.children, (x) => x.value)
? // @ts-ignore do we know that we actually have elements with 'value'?
Array.from(this.viewSelect.children, (x) => x.value)
: null;

return {
Expand Down Expand Up @@ -1552,14 +1558,16 @@ export class ChartManager {

updateInfoAlert(id, msg, config = {}) {
const al = this.infoAlerts[id];
if (config.type && al.type !== config.type) {
al.div.classList.remove(`ciview-alert-${al.type}`);
al.div.classList.add(`ciview-alert-${config.type}`);
al.type = config.type;
}
al.text.textContent = msg;
if (config.duration) {
this.removeInfoAlert(id, config.duration);
if (al) {
if (config.type && al.type !== config.type) {
al.div.classList.remove(`ciview-alert-${al.type}`);
al.div.classList.add(`ciview-alert-${config.type}`);
al.type = config.type;
}
al.text.textContent = msg;
if (config.duration) {
this.removeInfoAlert(id, config.duration);
}
}
}

Expand Down Expand Up @@ -1591,7 +1599,7 @@ export class ChartManager {
* @param {string[]} columns An array of column fields/ids
* @param {string} dataSource The name of the dataSource
* @param {function} callback A function which will be run once all the
* columns are loaded, with any failed columns as an argument (although it's not clear that the underlying code actually does this,
* columns are loaded, with any failed columns as an argument (although it's not clear that the underlying code actually does this,
* or that any code that calls this function actually uses the argument)
* @param {number} [split=10] the number of columns to send with each request
* @param {number} [threads=2] the number of concurrent requests
Expand Down Expand Up @@ -1676,11 +1684,16 @@ export class ChartManager {
for (const col of col_list) {
delete this.columnsLoading[dataSource][col];
}
all_loaded = all_loaded > trans.totalColumns
? trans.totalColumns
: all_loaded;
all_loaded =
all_loaded > trans.totalColumns
? trans.totalColumns
: all_loaded;
if (trans.failedColumns.length > 0) {
this.updateInfoAlert(trans.alertID, `Failed to load ${trans.failedColumns.length} columns`, { type: 'danger' });
this.updateInfoAlert(
trans.alertID,
`Failed to load ${trans.failedColumns.length} columns`,
{ type: "danger" },
);
// return;
} else {
this.updateInfoAlert(
Expand Down Expand Up @@ -1963,7 +1976,7 @@ export class ChartManager {
},
ds.contentDiv,
);
createEl(
const spinner = createEl(
"i",
{
classes: ["fas", "fa-circle-notch", "fa-spin"],
Expand All @@ -1975,7 +1988,7 @@ export class ChartManager {
},
div,
);
createEl(
const ellipsis = createEl(
"div",
{
styles: {
Expand All @@ -2000,28 +2013,32 @@ export class ChartManager {
this._addChart(dataSource, config, div, notify);
} catch (error) {
this.clearInfoAlerts();
const id = this.createInfoAlert(
`Error creating chart with columns [${neededCols.join(", ")}]: '${error}'`,
{
type: "warning",
},
);
console.error(error);
const idiv = this.infoAlerts[id].div;
idiv.onclick = () => idiv.remove();
// div.remove();
spinner.remove();
ellipsis.remove();
// const id = this.createInfoAlert(
// `Error creating chart with columns [${neededCols.join(", ")}]: '${error}'`,
// {
// type: "warning",
// },
// );
// const idiv = this.infoAlerts[id].div;
// idiv.onclick = () => idiv.remove();
const debugNode = createEl(
"div",
{
styles: {
position: "absolute",
width: "100%",
height: "100%",
display: "flex",
justifyContent: "center",
alignItems: "center",
backdropFilter: "blur(10px)",
},
},
div.lastElementChild,
div,
);
debugNode.innerHTML = `<div><h2>Error creating chart</h2><pre>${error.stack}</pre></div>`;
debugNode.onclick = () => debugNode.remove();
createMdvPortal(ErrorComponentReactWrapper({error, height, width, extraMetaData: {config}}), debugNode);
//not rethrowing doesn't help recovering from missing data in other charts.
//throw new Error(error); //probably not a great way to handle this
}
Expand Down Expand Up @@ -2152,7 +2169,10 @@ export class ChartManager {
else {
this.loadColumnSet(reqCols, dataSource, (failedColumns) => {
if (failedColumns.length) {
console.warn('got columns with some failures', failedColumns);
console.warn(
"got columns with some failures",
failedColumns,
);
}
this._haveColumnsLoaded(columns, dataSource, func);
});
Expand Down
Loading

0 comments on commit 8743def

Please sign in to comment.