Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove xlsx export from CLI's interactive tables #6439

Merged
merged 10 commits into from
May 21, 2024
2 changes: 1 addition & 1 deletion frontend-components/plotly/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite",
"build": "vite build",
"build_tsc": "tsc && vite build",
"deploy": "npm run build && mv dist/index.html ../../cli/openbb_cli/assets/interactive/plotly.html",
"deploy": "npm run build && mv dist/index.html ../../openbb_platform/obbject_extensions/charting/openbb_charting/core/plotly.html",
"preview": "vite preview"
},
"dependencies": {
Expand Down
47 changes: 0 additions & 47 deletions frontend-components/tables/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OpenBB Interactive Tables</title>
<script>
if (window.json_data && JSON.parse(window.json_data)?.posthog?.collect_logs) {
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init("phc_vhssDAMod5qIplznQ75Kdgz4aB1qPFmeVmfEOZ4hkRw", {
api_host: "https://app.posthog.com",
autocapture: {
css_selector_allowlist: [".ph-capture"],
},
capture_pageview: false,
loaded: function (posthog) {
if (window.json_data) {
const data = JSON.parse(window.json_data);

const log_id = data?.log_id || "";
if (log_id != "" && log_id != "REPLACE_ME") {
posthog.identify(log_id);
}

posthog.capture("table", {
INFO: {
command: data.command_location,
title: data.title,
python_version: data.python_version,
pywry_version: data.pywry_version,
terminal_version: data.terminal_version,
},
});
}
posthog.onFeatureFlags(function () {
if (
!posthog.isFeatureEnabled("record-pywry", { send_event: false })
) {
posthog.stopSessionRecording();
}
if (
!posthog.isFeatureEnabled("collect-logs-pywry", {
send_event: false,
})
) {
posthog.opt_out_capturing();
} else if (posthog.has_opted_out_capturing()) {
posthog.opt_in_capturing();
}
});
},
});
}

if (
// check if user had saved dark as their
// theme when accessing page before
Expand Down
95 changes: 0 additions & 95 deletions frontend-components/tables/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions frontend-components/tables/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "vite",
"build": "vite build",
"build_tsc": "tsc && vite build",
"deploy": "npm run build && mv dist/index.html ../../cli/openbb_cli/assets/interactive/table.html",
"deploy": "npm run build && mv dist/index.html ../../openbb_platform/obbject_extensions/charting/openbb_charting/core/table.html",
"preview": "vite preview"
},
"dependencies": {
Expand All @@ -30,7 +30,6 @@
"react-plotly.js": "^2.6.0",
"react-table": "^7.8.0",
"react-virtual": "^2.10.4",
"xlsx": "^0.18.5",
"xss": "^1.0.14"
},
"devDependencies": {
Expand Down
3 changes: 0 additions & 3 deletions frontend-components/tables/src/components/Table/Export.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ export default function Export({
case "csv":
downloadData("csv", columns, data, downloadFinished);
break;
case "xlsx":
downloadData("xlsx", columns, data, downloadFinished);
break;
case "png":
downloadImage("table", downloadFinished);
break;
Expand Down
2 changes: 1 addition & 1 deletion frontend-components/tables/src/components/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function getCellWidth(row, column) {
}
}

export const EXPORT_TYPES = ["csv", "xlsx", "png"];
export const EXPORT_TYPES = ["csv", "png"];
export default function Table({
data,
columns,
Expand Down
24 changes: 14 additions & 10 deletions frontend-components/tables/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,33 @@ body {
font-family: "Fira Code", monospace;
}

/*table tbody {
display: block;
max-height: 300px;
overflow-y: scroll;
}*/
table {
width: 100%;
table-layout: auto;
}

table thead,
table tfoot,
table tbody tr {
display: table;
width: 100%;
table-layout: fixed;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

th, td {
word-wrap: break-word;
overflow: hidden;
text-overflow: ellipsis;
}

.resizer {
cursor: col-resize;
user-select: none;
touch-action: none;
}

tr {
width: fit-content;
transition: opacity 0.2s ease-in-out;
}

.resizer.isResizing {
Expand Down Expand Up @@ -162,7 +167,6 @@ table thead th {
opacity: 1;
}


@keyframes spin {
0% {
transform: rotate(0deg);
Expand Down
17 changes: 2 additions & 15 deletions frontend-components/tables/src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { rankItem } from "@tanstack/match-sorter-utils";
import domtoimage from "dom-to-image";
import { utils, writeFile } from "xlsx";


export function formatNumberNoMagnitude(value: number | string) {
if (typeof value === "string") {
Expand Down Expand Up @@ -224,7 +224,7 @@ export const saveToFile = (
};

export async function downloadData(
type: "csv" | "xlsx",
type: "csv",
columns: any,
data: any,
downloadFinished: (changed: boolean) => void,
Expand Down Expand Up @@ -270,19 +270,6 @@ export async function downloadData(

return;
}

const wb = utils.book_new();
const ws = utils.aoa_to_sheet(csvData);
utils.book_append_sheet(wb, ws, "Sheet1");
await loadingOverlay("Saving XLSX");
non_blocking(async function () {
// @ts-ignore
// timeout to allow loading overlay to show
await new Promise((resolve) => setTimeout(resolve, 1500));
writeFile(wb, `${window.title}.xlsx`);
await loadingOverlay("", true);
downloadFinished?.(true);
}, 2)();
}

export async function downloadImage(
Expand Down
Loading
Loading