Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion src/api/tesseract/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export function queryParamsToRequest(params: QueryParams): TesseractDataRequest
item.active ? filterSerialize(item) : null
).join(","),
limit: `${params.pagiLimit || 0},${params.pagiOffset || 0}`,
sort: params.sortKey ? `${params.sortKey}.${params.sortDir}` : undefined
sort: params.sortKey ? `${params.sortKey}.${params.sortDir}` : undefined,
time: params.timeComplete ? `${params.timeComplete}.complete` : undefined
// sparse: params.sparse,
// ranking:
// typeof params.ranking === "boolean"
Expand Down Expand Up @@ -108,6 +109,8 @@ export function requestToQueryParams(cube: TesseractCube, search: URLSearchParam
const [limit = "0", offset = "0"] = (search.get("limit") || "0").split(",");
const [sortKey, sortDir] = (search.get("sort") || "").split(".");

const timeComplete = search.get("time")?.split(".")[0] || undefined;

return {
cube: cube.name,
locale: search.get("locale") || undefined,
Expand All @@ -120,6 +123,7 @@ export function requestToQueryParams(cube: TesseractCube, search: URLSearchParam
sortDir: sortDir === "asc" ? "asc" : "desc",
sortKey: sortKey || undefined,
isPreview: false,
timeComplete: timeComplete || undefined,
booleans: {
// parents: search.get("parents") || undefined,
}
Expand Down
8 changes: 3 additions & 5 deletions src/components/CubeSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import {Anchor, Text, TextProps} from "@mantine/core";
import React from "react";
import {useSelector} from "react-redux";
import {useTranslation} from "../hooks/translation";
import {selectOlapCube} from "../state/selectors";
import {getAnnotation} from "../utils/string";
import {selectCurrentQueryItem, selectLocale} from "../state/queries";
import {selectLocale} from "../state/queries";
import type {Annotated} from "../utils/types";
import {useSelectedItem, useServerSchema} from "../hooks/useQueryApi";
import {useSelectedItem} from "../hooks/useQueryApi";

export function CubeAnnotation(
props: TextProps & {
Expand Down Expand Up @@ -42,14 +41,13 @@ export function CubeSourceAnchor(
return (
<Text component="p" {...textProps}>
{`${t("params.label_source")}: `}
{srcLink ? <Anchor href={srcLink}>{srcName}</Anchor> : <Text span>{srcName}</Text>}
{srcLink ? <Anchor href={srcLink} target="_blank">{srcName}</Anchor> : <Text span>{srcName}</Text>}
</Text>
);
}

export default function CubeSource() {
const selectedItem = useSelectedItem();
// TODO: agregar locale
const {code: locale} = useSelector(selectLocale);
return (
selectedItem && (
Expand Down
47 changes: 44 additions & 3 deletions src/components/DrawerMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ function LevelItem({
const paddingLeft = `${5 * depth + 5}px`;

const properties = currentDrilldown.properties.length ? currentDrilldown.properties : null;

const dimensionIsTimeComplete = dimension.annotations.de_time_complete === "true";
return (
currentDrilldown && (
<>
Expand All @@ -336,10 +338,49 @@ function LevelItem({
onChange={() => {
actions.updateDrilldown({
...currentDrilldown,
active: !currentDrilldown.active,
active: !currentDrilldown.active
});
if (cut && cut.members.length > 0)
actions.updateCut({...cut, active: !cut.active});
if (cut && cut.members.length > 0) actions.updateCut({...cut, active: !cut.active});

// if current dimension has time complete annotation
if (dimensionIsTimeComplete) {
const hierarchyLevels =
dimension.hierarchies.find(h => h.name === hierarchy.name)?.levels || [];

// select all levels that are either active or match the current drilldown level to be added
const availableLevels = hierarchyLevels.filter(
l =>
l.name &&
activeItems.some(item =>
!currentDrilldown.active
? item.level === l.name || l.name === currentDrilldown.level
: item.level === l.name && item.level !== currentDrilldown.level
)
);

// take the higher order level
const timeCompleteLevel = availableLevels.find(
l => l.depth === Math.min(...availableLevels.map(level => level.depth))
);
const deepestLevel = hierarchyLevels.find(
l => l.depth === Math.max(...hierarchyLevels.map(level => level.depth))
);

const deepestLevelAvailable = availableLevels.find(
l => l.depth === deepestLevel?.depth
);

if (
timeCompleteLevel &&
deepestLevel &&
timeCompleteLevel.depth < deepestLevel.depth &&
!deepestLevelAvailable
) {
actions.updateTimeComplete(timeCompleteLevel.name);
} else {
actions.removeTimeComplete();
}
}
}}
checked={checked}
label={label}
Expand Down
8 changes: 4 additions & 4 deletions src/components/TableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function isColumnSorted(column: string, key: string) {

const removeColumn = (
queryItem: QueryItem,
entity: TesseractMeasure | TesseractProperty | TesseractLevel,
entity: TesseractMeasure | TesseractProperty | TesseractLevel
) => {
const newQuery = buildQuery(cloneDeep(queryItem));
const params = newQuery.params;
Expand All @@ -122,15 +122,15 @@ const removeColumn = (
const mapPropertyToDrilldown = Object.fromEntries(
Object.values(params.drilldowns)
.filter(drilldown => drilldown.active)
.flatMap(drilldown => drilldown.properties.map(prop => [prop.name, drilldown])),
.flatMap(drilldown => drilldown.properties.map(prop => [prop.name, drilldown]))
);
const drilldown = mapPropertyToDrilldown[entity.name];
if (drilldown) {
params.drilldowns[drilldown.key] = {
...drilldown,
properties: drilldown.properties.map(prop =>
prop.name === entity.name ? {...prop, active: false} : prop,
),
prop.name === entity.name ? {...prop, active: false} : prop
)
};
return newQuery;
}
Expand Down
6 changes: 4 additions & 2 deletions src/context/query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ export function QueryProvider({children, defaultCube}: QueryProviderProps) {
};

function setDefaultValues(cube: TesseractCube) {
const drilldowns = pickDefaultDrilldowns(cube.dimensions, cube).map(level =>
const {levels, timeComplete} = pickDefaultDrilldowns(cube.dimensions, cube);
const drilldowns = levels.map(level =>
buildDrilldown({
...level,
key: level.name,
Expand Down Expand Up @@ -213,7 +214,8 @@ export function QueryProvider({children, defaultCube}: QueryProviderProps) {
cube: cube.name,
measures: keyBy(measures, item => item.key),
drilldowns: keyBy(drilldowns, item => item.key),
locale
locale,
timeComplete
},
panel: panel ?? "table"
});
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/permalink.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useCallback, useEffect} from "react";
import {useCallback} from "react";
import type {TesseractCube} from "../api";
import {queryParamsToRequest, requestToQueryParams} from "../api/tesseract/parse";
import {selectCurrentQueryItem} from "../state/queries";
Expand Down
Loading