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

Preview v2 #3320

Closed
wants to merge 124 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
c14e8da
feat: add dummy components for preview renewal
MarcoKorinth Sep 27, 2023
337128b
fix: remove typo in preview actions
MarcoKorinth Sep 28, 2023
c8a51c1
add rc-table WIP
fabian-bizfactory Oct 24, 2023
8079f39
api call for charts
fabian-bizfactory Oct 27, 2023
a78a054
add charts container
fabian-bizfactory Oct 27, 2023
6eb5077
string diagrams are shown
fabian-bizfactory Oct 30, 2023
9651095
Normal Distributions are working
fabian-bizfactory Oct 30, 2023
44a9ca2
fix diagram tooltip
fabian-bizfactory Oct 30, 2023
5551037
scroll charts
fabian-bizfactory Oct 31, 2023
8c7db04
raw 2x2
fabian-bizfactory Oct 31, 2023
009af15
feat: fetch preview backend data
MarcoKorinth Nov 1, 2023
df14074
Merge branch 'feat/add-table' into feat/preview-v2
MarcoKorinth Nov 1, 2023
976c9d3
add modal, improve left and right
fabian-bizfactory Nov 6, 2023
f4844da
Improve diagram styling
fabian-bizfactory Nov 6, 2023
d8f022e
responsive charts
fabian-bizfactory Nov 7, 2023
c9a38a7
loading error translation
fabian-bizfactory Nov 7, 2023
51cf7ba
Diagramm Loading spinner
fabian-bizfactory Nov 7, 2023
d4fa9ba
feat: add rc-table
MarcoKorinth Nov 9, 2023
1619e66
add Headline Stats
fabian-bizfactory Nov 10, 2023
c5fc416
Merge branch 'initial-preview-merge' into feat/preview-v2
fabian-bizfactory Nov 13, 2023
7816897
Merge pull request #1 from BIZFactoryGmbH/feat/preview-v2
fabian-bizfactory Nov 13, 2023
05f4601
Cleanup and fixes
fabian-bizfactory Nov 13, 2023
e8226da
work on Select box
fabian-bizfactory Nov 13, 2023
e34fe9a
update Date in Header
fabian-bizfactory Nov 13, 2023
1155959
feat: refactor preview code
MarcoKorinth Nov 17, 2023
e7c696d
working selection box
fabian-bizfactory Nov 20, 2023
6c363f2
aproximate pdf from samples for number statistics
fabian-bizfactory Nov 20, 2023
de53e43
begin with number formatting
fabian-bizfactory Nov 20, 2023
a73ad42
feat: adjust scroll behavior on preview page and add scroll to top bu…
MarcoKorinth Nov 20, 2023
d3991db
Select Box is now jumping
fabian-bizfactory Nov 21, 2023
b393a3c
feat: save statistics data in preview redux
MarcoKorinth Nov 24, 2023
1b987c4
use queryId - backend working with stats - only missing arrow
fabian-bizfactory Nov 27, 2023
d3db239
small payload change
fabian-bizfactory Nov 27, 2023
5bfbfda
cleanup and bugfix
fabian-bizfactory Nov 27, 2023
7ff3401
Merge branch 'feat/previewMain' into feat/add-charts
fabian-bizfactory Nov 27, 2023
29197c4
add arrow file
fabian-bizfactory Nov 27, 2023
0cf866d
fix merge
fabian-bizfactory Nov 27, 2023
8f134d1
WIP datechart
fabian-bizfactory Nov 27, 2023
fc8f174
Merge pull request #2 from BIZFactoryGmbH/feat/add-charts
fabian-bizfactory Nov 28, 2023
e093c8d
Merge branch 'feat/previewMain' into feat/add-date-chart
fabian-bizfactory Nov 28, 2023
7c0c691
Merge pull request #3 from BIZFactoryGmbH/feat/add-date-chart
fabian-bizfactory Nov 28, 2023
b73936c
fix more small build errors
fabian-bizfactory Nov 28, 2023
dd1b518
fix: typescript ignores
MarcoKorinth Nov 30, 2023
2dd1820
fix table scroll
fabian-bizfactory Dec 4, 2023
d6cdf31
feat: preview loading optimization
MarcoKorinth Dec 1, 2023
b81fae6
Cleanup and increase readability
fabian-bizfactory Dec 4, 2023
2685571
remove console.log
fabian-bizfactory Dec 7, 2023
fd580e9
fix: prettier errors
MarcoKorinth Dec 1, 2023
0450742
cleanup
fabian-bizfactory Dec 7, 2023
d55d504
Merge pull request #4 from BIZFactoryGmbH/bugfix/table-scroll
fabian-bizfactory Dec 7, 2023
95b27e6
Use Headline based on TooltipEntries
fabian-bizfactory Dec 11, 2023
a4c1513
Fix date diagram bug& only render every 3rd Date
fabian-bizfactory Dec 8, 2023
120601a
Merge pull request #5 from BIZFactoryGmbH/fix/improve-readability-of-…
fabian-bizfactory Dec 7, 2023
e51aa59
forward all html props
fabian-bizfactory Dec 14, 2023
4f7e3ff
move Auth token, so the refreshed value is used
fabian-bizfactory Dec 14, 2023
9995582
improve number format
fabian-bizfactory Dec 11, 2023
d1006c1
Fix arrow authorization
fabian-bizfactory Dec 11, 2023
f2af8f1
Monatsnahme in den Titel
fabian-bizfactory Dec 12, 2023
559cd9f
Merge pull request #7 from BIZFactoryGmbH/feat/change-headline
fabian-bizfactory Dec 14, 2023
1d55b77
Diagram Improvements
fabian-bizfactory Dec 11, 2023
e7ebe46
Fix Number Stats for some unhandled cases of chart type
fabian-bizfactory Dec 11, 2023
d500e36
Merge branch 'feat/previewMain' into fix/fix-date-diagram-bug
fabian-bizfactory Dec 14, 2023
32af107
feat: add custom render for types in preview table
MarcoKorinth Dec 13, 2023
fd5767b
fix useGetResult
fabian-bizfactory Dec 14, 2023
e0e3dec
Merge pull request #6 from BIZFactoryGmbH/fix/fix-date-diagram-bug
fabian-bizfactory Dec 14, 2023
a58d564
Merge branch 'feat/previewMain' into feat/table-customrender-types
MarcoKorinth Dec 15, 2023
776cb02
improve Tooltip and Rounding
fabian-bizfactory Dec 11, 2023
0f91059
Merge pull request #9 from BIZFactoryGmbH/feat/table-customrender-types
MarcoKorinth Dec 15, 2023
b5f53d9
Merge branch 'feat/previewMain' into feat/improve-tooltips-and-rounding
fabian-bizfactory Dec 11, 2023
ed20cc5
use chart types
fabian-bizfactory Dec 14, 2023
a52a4d7
Merge branch 'feat/previewMain' into feat/improve-tooltips-and-rounding
fabian-bizfactory Dec 14, 2023
d9ea2d6
refresh auth token
fabian-bizfactory Dec 14, 2023
fbde729
Fix Dates
fabian-bizfactory Dec 14, 2023
dff5e8d
useTheme
fabian-bizfactory Dec 15, 2023
b12d217
align headline stats right
fabian-bizfactory Dec 18, 2023
05503b9
Merge branch 'feat/previewMain' into feat/improve-tooltips-and-rounding
fabian-bizfactory Dec 18, 2023
c79c4ee
small fix
fabian-bizfactory Dec 18, 2023
8805e18
Merge pull request #8 from BIZFactoryGmbH/feat/improve-tooltips-and-r…
fabian-bizfactory Dec 18, 2023
595b4cc
Change to new Datastructure
fabian-bizfactory Dec 19, 2023
e64336b
Formatting, remove declaration for pdfast
fabian-bizfactory Dec 19, 2023
0098b8e
fix lint errors
fabian-bizfactory Dec 19, 2023
42d55b3
format
fabian-bizfactory Dec 19, 2023
7eaaa39
Merge pull request #10 from BIZFactoryGmbH/feat/update-diagrams-to-ne…
MarcoKorinth Dec 19, 2023
90cd33c
remove debug preview button and use previewv2 by default
MarcoKorinth Dec 22, 2023
f25e73c
render list types and daterange in preview table
MarcoKorinth Dec 22, 2023
4d3eb6e
Reimplement changes from feat/minor-ui-changes
fabian-bizfactory Jan 5, 2024
ce0ad64
fix format
fabian-bizfactory Jan 5, 2024
335653c
fix format
MarcoKorinth Dec 22, 2023
f5c56c4
Merge pull request #12 from BIZFactoryGmbH/feat/hide-draghandles-mino…
fabian-bizfactory Jan 8, 2024
6561c23
add titleColor to LineChart
fabian-bizfactory Jan 8, 2024
e2848cb
remove suggested min und max
fabian-bizfactory Jan 9, 2024
4ed365e
feat: display true/false instead of 0/1 in preview table
MarcoKorinth Jan 27, 2024
2712739
fix: number formatting in preview
MarcoKorinth Jan 27, 2024
15f3065
feat: add border between table columns in preview
MarcoKorinth Jan 27, 2024
0874a44
fix: hardcoded locales
MarcoKorinth Jan 27, 2024
4b0b639
feat: limit string length in preview table
MarcoKorinth Jan 27, 2024
59bd0e4
fix: date rendering in preview table
MarcoKorinth Jan 27, 2024
b35efac
fix: number types
MarcoKorinth Jan 30, 2024
c3b3ede
fix: null errors and money conversion from cents
MarcoKorinth Jan 30, 2024
19f7df2
feat: reduce max date tablecell width
MarcoKorinth Jan 30, 2024
0e9dd45
feat: change color of previewtable cell borders
MarcoKorinth Jan 30, 2024
28df7bd
fix: show date values with leading zero in preview table
MarcoKorinth Jan 31, 2024
4d3332a
fix: formatting
MarcoKorinth Jan 31, 2024
2eaffc3
feat: show loading spinner while preview is loading
MarcoKorinth Feb 1, 2024
8ce9b15
fix: date format in preview chart
MarcoKorinth Feb 1, 2024
9564be7
chore: refactor Diagram component
MarcoKorinth Feb 1, 2024
ab8fbd1
feat: add caching to preview table
MarcoKorinth Feb 7, 2024
9005089
fix: too many preview table rerenders
MarcoKorinth Feb 13, 2024
d30eae2
wip fix: load arrow file dynamically
MarcoKorinth Feb 20, 2024
692f070
fix: force fractions for money values in preview table
MarcoKorinth Feb 21, 2024
c7864f9
fix: draghandles shown in preview
MarcoKorinth Feb 21, 2024
19fcc40
feat: adjust x axis of date diagrams in preview
MarcoKorinth Feb 21, 2024
df84612
feat: add scrollbar to preview table
MarcoKorinth Feb 22, 2024
e9afffc
fix: scroll up button in preview
MarcoKorinth Feb 22, 2024
7204db2
feat: adjust preview data loading
MarcoKorinth Feb 22, 2024
5d60499
Merge branch 'develop' into preview-v2-mergetest
MarcoKorinth Feb 28, 2024
0767b33
fix: formatting
MarcoKorinth Feb 28, 2024
08cba5a
fix: remove yarn lock
MarcoKorinth Feb 28, 2024
2930a27
fix: remove preview info
MarcoKorinth Feb 28, 2024
1f17f37
chore: remove code comments
MarcoKorinth Feb 28, 2024
907d412
chore: remove empty export
MarcoKorinth Feb 28, 2024
a8d158c
chore: solve open todos
MarcoKorinth Feb 28, 2024
55e613a
chore: remove preview v1
MarcoKorinth Feb 29, 2024
2b21be0
feat: add limit param to arrow stream
MarcoKorinth Feb 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
339 changes: 339 additions & 0 deletions frontend/package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"@vitejs/plugin-react": "^4.1.1",
"apache-arrow": "^13.0.0",
"axios": "^1.6.0",
"chance": "^1.1.11",
"chart.js": "^4.4.0",
Expand All @@ -57,6 +58,7 @@
"mustache": "^4.2.0",
"nodemon": "^3.0.1",
"prettier-plugin-organize-imports": "^3.2.3",
"rc-table": "^7.35.2",
"react": "^18.2.0",
"react-chartjs-2": "^5.2.0",
"react-datepicker": "^4.21.0",
Expand Down Expand Up @@ -99,6 +101,7 @@
"@testing-library/react": "^14.0.0",
"@types/axios": "^0.14.0",
"@types/chance": "^1.1.5",
"@types/chart.js": "^2.9.41",
"@types/compression": "^1.7.4",
"@types/cors": "^2.8.15",
"@types/express": "^4.17.20",
Expand Down
43 changes: 42 additions & 1 deletion frontend/src/js/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback } from "react";
import { useCallback, useContext, useEffect, useRef } from "react";

import { EditorV2Query } from "../editor-v2/types";
import { EntityId } from "../entity-history/reducer";
Expand All @@ -11,6 +11,7 @@ import type { QueryToUploadT } from "../previous-queries/upload/CSVColumnPicker"
import { StandardQueryStateT } from "../standard-query-editor/queryReducer";
import { ValidatedTimebasedQueryStateT } from "../timebased-query-editor/reducer";

import { AuthTokenContext } from "../authorization/AuthTokenProvider";
import { transformQueryToApi } from "./apiHelper";
import type {
ConceptIdT,
Expand All @@ -34,6 +35,7 @@ import type {
PostLoginResponseT,
PostQueriesResponseT,
PostResolveEntitiesResponse,
PreviewStatisticsResponse,
QueryIdT,
UploadQueryResponseT,
} from "./types";
Expand Down Expand Up @@ -405,3 +407,42 @@ export const usePostResolveEntities = () => {
[api],
);
};

export const useGetResult = () => {
const { authToken } = useContext(AuthTokenContext);
const authTokenRef = useRef<string>(authToken);
useEffect(
function updateRef() {
authTokenRef.current = authToken;
},
[authToken],
);
return useCallback(
(queryId: string, limit = 1000) => {
const url =
`/result/arrow/${queryId}.arrs` +
new URLSearchParams({ limit: limit.toString() });
const res = fetch(getProtectedUrl(url), {
headers: {
Authorization: `Bearer ${authTokenRef.current}`,
},
});
return res;
},
[authTokenRef],
);
};

export const usePreviewStatistics = () => {
const api = useApi<PreviewStatisticsResponse>();

return useCallback(
(queryId: string) =>
api({
url: getProtectedUrl(`/queries/${queryId}/statistics`),
method: "GET",
data: queryId,
}),
[api],
);
};
34 changes: 34 additions & 0 deletions frontend/src/js/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,3 +583,37 @@ export type GetEntityHistoryResponse = {
export type PostResolveEntitiesResponse = {
[idKind: string]: string; // idKind is the key, the value is the resolved ID
}[];

export type BaseStatistics = {
label: string;
description?: string;
count: number;
nullValues: number;
};

export type BarStatistics = BaseStatistics & {
chart: "HISTO";
type: "INTEGER" | "DECIMAL" | "MONEY" | "STRING" | "REAL";
entries: { label: string; value: number }[];
extras: { [key: string]: string };
};

export type DateStatistics = BaseStatistics & {
chart: "DATES";
type: "DATE_RANGE" | "DATE";
quarterCounts: Record<string, number>;
monthCounts: Record<string, number>;
span: {
min: string; // format "yyyy-MM-dd"
max: string;
};
};

export type PreviewStatistics = BarStatistics | DateStatistics;

export type PreviewStatisticsResponse = {
entities: number;
total: number; // Number of rows
statistics: PreviewStatistics[];
dateRange: DateRangeT;
};
10 changes: 7 additions & 3 deletions frontend/src/js/app/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import styled from "@emotion/styled";
import { useSelector } from "react-redux";

import { History } from "../entity-history/History";
import Preview from "../preview/Preview";
import ActivateTooltip from "../tooltip/ActivateTooltip";
import Tooltip from "../tooltip/Tooltip";

import { useMemo } from "react";
import { Panel, PanelGroup } from "react-resizable-panels";
import { ResizeHandle } from "../common/ResizeHandle";
import Preview from "../preview/Preview";
import DndProvider from "./DndProvider";
import LeftPane from "./LeftPane";
import RightPane from "./RightPane";
Expand All @@ -33,6 +33,10 @@ const Content = () => {
(state) => state.entityHistory.isOpen,
);

const disableDragHandles = useSelector<StateT, boolean>(
(state) => state.panes.disableDragHandles,
);

const collapsedStyles = useMemo(() => {
if (displayTooltip) return {};

Expand All @@ -58,11 +62,11 @@ const Content = () => {
>
{displayTooltip ? <Tooltip /> : <ActivateTooltip />}
</Panel>
<ResizeHandle disabled={!displayTooltip} />
{!disableDragHandles && <ResizeHandle />}
<Panel minSize={350} defaultSize={600}>
<LeftPane />
</Panel>
<ResizeHandle />
{!disableDragHandles && <ResizeHandle />}
<Panel minSize={250}>
<RightPane />
</Panel>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/js/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { DatasetActions } from "../dataset/actions";
import type { EntityHistoryActions } from "../entity-history/actions";
import type { ExternalFormActions } from "../external-forms/actions";
import type { PaneActions } from "../pane/actions";
import type { PreviewActions } from "../preview/actions";
import { PreviewActions } from "../preview/actions";
import type { ProjectItemsFilterActions } from "../previous-queries/filter/actions";
import type { FolderFilterActions } from "../previous-queries/folder-filter/actions";
import type { PreviousQueryListActions } from "../previous-queries/list/actions";
Expand Down
49 changes: 31 additions & 18 deletions frontend/src/js/button/PreviewButton.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,52 @@
import styled from "@emotion/styled";
import { useTranslation } from "react-i18next";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";

import type { ColumnDescription } from "../api/types";
import { useGetAuthorizedUrl } from "../authorization/useAuthorizedUrl";
import {
faMagnifyingGlass,
faSpinner,
} from "@fortawesome/free-solid-svg-icons";
import { useMemo, useState } from "react";
import { StateT } from "../app/reducers";
import { openPreview, useLoadPreviewData } from "../preview/actions";
import IconButton, { IconButtonPropsT } from "./IconButton";

import { TransparentButton } from "./TransparentButton";

const Button = styled(TransparentButton)`
const Button = styled(IconButton)`
white-space: nowrap;
height: 35px;
padding: 5px 12px;
`;

const PreviewButton = ({
url,
columns,
...restProps
}: {
columns: ColumnDescription[];
url: string;
}) => {
const PreviewButton = (buttonProps: Partial<IconButtonPropsT>) => {
const { t } = useTranslation();
const dispatch = useDispatch();

const loadPreviewData = useLoadPreviewData();
const getAuthorizedUrl = useGetAuthorizedUrl();
const queryId = useSelector<StateT, string | null>(
(state) => state.preview.lastQuery,
);

const [isLoading, setLoading] = useState(false);
const icon = useMemo(
() => (isLoading ? faSpinner : faMagnifyingGlass),
[isLoading],
);

return (
<Button
frame
icon={icon}
onClick={async () => {
await loadPreviewData(getAuthorizedUrl(url), columns);
dispatch(openPreview());
if (queryId) {
setLoading(true);
setTimeout(async () => {
await loadPreviewData(queryId);
setLoading(false);
dispatch(openPreview());
});
}
}}
{...restProps}
{...buttonProps}
>
{t("preview.preview")}
</Button>
Expand Down
9 changes: 2 additions & 7 deletions frontend/src/js/button/QueryResultHistoryButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { faListUl, faSpinner } from "@fortawesome/free-solid-svg-icons";
import { useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";

import type { ColumnDescription } from "../api/types";
import type { StateT } from "../app/reducers";
import { useGetAuthorizedUrl } from "../authorization/useAuthorizedUrl";
import { openHistory, useNewHistorySession } from "../entity-history/actions";

import IconButton from "./IconButton";
Expand All @@ -16,27 +14,24 @@ const SxIconButton = styled(IconButton)`
`;

interface PropsT {
columns: ColumnDescription[];
label: string;
url: string;
}

export const QueryResultHistoryButton = ({ url, label, columns }: PropsT) => {
export const QueryResultHistoryButton = ({ label }: PropsT) => {
const { t } = useTranslation();
const dispatch = useDispatch();
const isLoading = useSelector<StateT, boolean>(
(state) => state.entityHistory.isLoading,
);

const getAuthorizedUrl = useGetAuthorizedUrl();
const newHistorySession = useNewHistorySession();

return (
<SxIconButton
icon={isLoading ? faSpinner : faListUl}
frame
onClick={async () => {
await newHistorySession(getAuthorizedUrl(url), columns, label);
await newHistorySession(label);
dispatch(openHistory());
}}
>
Expand Down
19 changes: 16 additions & 3 deletions frontend/src/js/entity-history/TimeStratifiedChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {
CategoryScale,
Chart as ChartJS,
ChartOptions,
LineElement,
LinearScale,
PointElement,
Title,
Tooltip,
} from "chart.js";
import { useMemo } from "react";
Expand All @@ -18,7 +21,17 @@ import { formatCurrency } from "./timeline/util";

const TRUNCATE_X_AXIS_LABELS_LEN = 18;

ChartJS.register(CategoryScale, LinearScale, BarElement, Tooltip);
ChartJS.register(
CategoryScale,
LinearScale,
BarElement,
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
);

const ChartContainer = styled("div")`
height: 190px;
Expand All @@ -27,7 +40,7 @@ const ChartContainer = styled("div")`
justify-content: flex-end;
`;

function hexToRgbA(hex: string) {
export function hexToRgbA(hex: string) {
let c: string | string[];
if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)) {
c = hex.substring(1).split("");
Expand All @@ -41,7 +54,7 @@ function hexToRgbA(hex: string) {
throw new Error("Bad Hex");
}

function interpolateDecreasingOpacity(index: number) {
export function interpolateDecreasingOpacity(index: number) {
return Math.min(1, 1 / (index + 0.3));
}

Expand Down
Loading
Loading