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

feat: sort rows in EDA #1183

Merged
merged 40 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8a36f5c
feat: clean up state and separate it
SmiteDeluxe May 14, 2024
54ef0a3
Merge branch '1169-improve-eda-state' into 1171-hide-column-feature-i…
SmiteDeluxe May 14, 2024
4d8bf10
feat: hidden columns messaging logic for vis vs. manip
SmiteDeluxe May 14, 2024
79f0aa0
feat: hide columns functionality
SmiteDeluxe May 14, 2024
e98549c
feat: making other tabs outdated on relevant changes in history
SmiteDeluxe May 14, 2024
f79923a
fix: improv oudated logic & display
SmiteDeluxe May 14, 2024
2254cf1
fix: better hidden col handling for not 'none' col count tabs
SmiteDeluxe May 15, 2024
6c8cbea
fix: slightly smaller active tab font
SmiteDeluxe May 15, 2024
6c4de29
Merge remote-tracking branch 'origin/main' into 1171-hide-column-feat…
SmiteDeluxe May 26, 2024
0df827f
fix: only numerical columns in plots other than histogram
SmiteDeluxe May 26, 2024
4ff5cc0
fix: order and fix up col right clicks
SmiteDeluxe May 26, 2024
573aee7
fix: buildATab NonNumerical based changes
SmiteDeluxe May 26, 2024
2d2810b
feat: footer basics for col count
SmiteDeluxe May 27, 2024
fb1dcba
fix: hidden cols excl. in profiling errors
SmiteDeluxe May 27, 2024
f66aa3b
fix: profiling error store
SmiteDeluxe May 27, 2024
3b5c772
feat: right click on profiling possible
SmiteDeluxe May 27, 2024
cec02ab
feat: hidden col menu to show
SmiteDeluxe May 27, 2024
5049fd7
refactor: rename color vars
SmiteDeluxe May 27, 2024
03bdd3e
fix: z-index of col show menu & fix: reactivity sidebar width changes
SmiteDeluxe May 27, 2024
c2d96d3
fix: only right click interaction allowed on hidden col & styling fixes
SmiteDeluxe May 27, 2024
01679cc
fix: hiddenCol reorder drag over & resize min width
SmiteDeluxe May 27, 2024
67d65de
refactor
SmiteDeluxe May 27, 2024
73844a7
fix: bug
SmiteDeluxe May 27, 2024
4b448f7
style: apply automated linter fixes
megalinter-bot May 27, 2024
a78ebc6
Merge branch '1171-hide-column-feature-in-eda' into 1151-sort-rows-in…
SmiteDeluxe May 28, 2024
46aaf2c
feat: sort hover effect
SmiteDeluxe May 28, 2024
2b88eab
Merge remote-tracking branch 'origin/main' into 1171-hide-column-feat…
SmiteDeluxe May 28, 2024
aa791bf
Merge remote-tracking branch 'origin/main' into 1151-sort-rows-in-eda…
SmiteDeluxe May 28, 2024
4eca383
feat: sort columns & fixed pastEntry execution
SmiteDeluxe May 28, 2024
7921990
feat: overrideIds for history entries
SmiteDeluxe May 29, 2024
6631da1
feat: voidSortByColumn
SmiteDeluxe May 29, 2024
699bd5d
feat: loading screen on table
SmiteDeluxe May 29, 2024
5b80ae8
Update packages/safe-ds-eda/src/apis/historyApi.ts
SmiteDeluxe May 29, 2024
61602a9
style: apply automated linter fixes
megalinter-bot May 29, 2024
cdf7ad6
Update packages/safe-ds-eda/src/components/ColumnCounts.svelte
SmiteDeluxe May 29, 2024
8457385
refactor: columnNames to ColumnOptions as more contents
SmiteDeluxe May 29, 2024
8e2a61b
refactor & fix: empty col names list case in sds code gen
SmiteDeluxe May 29, 2024
8ccd6e8
Merge branch '1171-hide-column-feature-in-eda' into 1151-sort-rows-in…
SmiteDeluxe May 29, 2024
6006e40
Merge remote-tracking branch 'origin/main' into 1151-sort-rows-in-eda…
SmiteDeluxe May 29, 2024
54a1bf9
Merge branch 'main' into 1151-sort-rows-in-eda-tool
lars-reimann May 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
105 changes: 93 additions & 12 deletions packages/safe-ds-eda/src/apis/historyApi.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { get } from 'svelte/store';
import type { FromExtensionMessage, RunnerExecutionResultMessage } from '../../types/messaging';
import type {
CategoricalFilter,
EmptyTab,
ExternalHistoryEntry,
HistoryEntry,
InteralEmptyTabHistoryEntry,
InternalHistoryEntry,
NumericalFilter,
RealTab,
Tab,
TabHistoryEntry,
} from '../../types/state';
import { cancelTabIdsWaiting, tabs, history, currentTabIndex, table } from '../webviewState';
import { cancelTabIdsWaiting, tabs, history, currentTabIndex, table, tableLoading } from '../webviewState';
import { executeRunner } from './extensionApi';

// Wait for results to return from the server
Expand All @@ -22,6 +24,34 @@ export const getAndIncrementEntryId = function (): number {
return entryIdCounter++;
};

const generateOverrideId = function (entry: ExternalHistoryEntry | InternalHistoryEntry): string {
switch (entry.action) {
case 'hideColumn':
case 'showColumn':
case 'resizeColumn':
case 'reorderColumns':
case 'highlightColumn':
return entry.columnName + '.' + entry.action;
case 'sortByColumn':
return entry.action; // Thus enforcing override sort
case 'voidSortByColumn':
return 'sortByColumn'; // This overriding previous sorts
case 'filterColumn':
return entry.columnName + entry.filter.type + '.' + entry.action;
case 'linePlot':
case 'scatterPlot':
case 'histogram':
case 'boxPlot':
case 'infoPanel':
case 'heatmap':
case 'emptyTab':
const tabId = entry.newTabId ?? entry.existingTabId;
return entry.type + '.' + tabId;
default:
throw new Error('Unknown action type to generateOverrideId');
}
};

window.addEventListener('message', (event) => {
const message = event.data as FromExtensionMessage;

Expand All @@ -40,6 +70,11 @@ window.addEventListener('message', (event) => {

deployResult(message, asyncQueue[0]);
asyncQueue.shift();

if (asyncQueue.length === 0) {
tableLoading.set(false);
}

evaluateMessagesWaitingForTurn();
} else if (message.command === 'cancelRunnerExecution') {
cancelExecuteExternalHistoryEntry(message.value);
Expand All @@ -51,6 +86,7 @@ export const addInternalToHistory = function (entry: InternalHistoryEntry): void
const entryWithId: HistoryEntry = {
...entry,
id: getAndIncrementEntryId(),
overrideId: generateOverrideId(entry),
};
const newHistory = [...state, entryWithId];
return newHistory;
Expand All @@ -60,10 +96,18 @@ export const addInternalToHistory = function (entry: InternalHistoryEntry): void
};

export const executeExternalHistoryEntry = function (entry: ExternalHistoryEntry): void {
// Set table to loading if loading takes longer than 500ms
setTimeout(() => {
if (asyncQueue.length > 0) {
tableLoading.set(true);
}
}, 500);

history.update((state) => {
const entryWithId: HistoryEntry = {
...entry,
id: getAndIncrementEntryId(),
overrideId: generateOverrideId(entry),
};
const newHistory = [...state, entryWithId];

Expand Down Expand Up @@ -91,7 +135,7 @@ export const addAndDeployTabHistoryEntry = function (entry: TabHistoryEntry & {
}

history.update((state) => {
return [...state, entry];
return [...state, { ...entry, overrideId: generateOverrideId(entry) }];
});
tabs.update((state) => {
const newTabs = (state ?? []).concat(tab);
Expand All @@ -101,20 +145,22 @@ export const addAndDeployTabHistoryEntry = function (entry: TabHistoryEntry & {
};

export const addEmptyTabHistoryEntry = function (): void {
const tabId = crypto.randomUUID();
const entry: InteralEmptyTabHistoryEntry & { id: number } = {
action: 'emptyTab',
type: 'internal',
alias: 'New empty tab',
id: getAndIncrementEntryId(),
newTabId: tabId,
};
const tab: EmptyTab = {
type: 'empty',
id: crypto.randomUUID(),
id: tabId,
isInGeneration: true,
};

history.update((state) => {
return [...state, entry];
return [...state, { ...entry, overrideId: generateOverrideId(entry) }];
});
tabs.update((state) => {
const newTabs = (state ?? []).concat(tab);
Expand All @@ -136,6 +182,10 @@ export const cancelExecuteExternalHistoryEntry = function (entry: HistoryEntry):
unsetTabAsGenerating(tab);
}
}

if (asyncQueue.length === 0) {
tableLoading.set(false);
}
} else {
throw new Error('Entry already fully executed');
}
Expand Down Expand Up @@ -181,13 +231,14 @@ export const unsetTabAsGenerating = function (tab: RealTab): void {
const deployResult = function (result: RunnerExecutionResultMessage, historyEntry: ExternalHistoryEntry) {
const resultContent = result.value;
if (resultContent.type === 'tab') {
if (resultContent.content.id) {
const existingTab = get(tabs).find((et) => et.id === resultContent.content.id);
if (historyEntry.type !== 'external-visualizing') throw new Error('Deploying tab from non-visualizing entry');
if (historyEntry.existingTabId) {
const existingTab = get(tabs).find((et) => et.id === historyEntry.existingTabId);
if (existingTab) {
const tabIndex = get(tabs).indexOf(existingTab);
tabs.update((state) =>
state.map((t) => {
if (t.id === resultContent.content.id) {
if (t.id === historyEntry.existingTabId) {
return resultContent.content;
} else {
return t;
Expand All @@ -197,14 +248,44 @@ const deployResult = function (result: RunnerExecutionResultMessage, historyEntr
currentTabIndex.set(tabIndex);
return;
}
} else {
const tab = resultContent.content;
tab.id = historyEntry.newTabId!; // Must exist if not existingTabId, not sure why ts does not pick up on it itself here
tabs.update((state) => state.concat(tab));
currentTabIndex.set(get(tabs).indexOf(tab));
}
const tab = resultContent.content;
tab.id = crypto.randomUUID();
tabs.update((state) => state.concat(tab));
currentTabIndex.set(get(tabs).indexOf(tab));
} else if (resultContent.type === 'table') {
table.update((state) => {
for (const column of resultContent.content.columns) {
const existingColumn = state?.columns.find((c) => c.name === column.name);
if (!existingColumn) throw new Error('New Column not found in current table!');

column.profiling = existingColumn.profiling; // Preserve profiling, after this if it was a type that invalidated profiling, it will be invalidated
column.hidden = existingColumn.hidden;
column.highlighted = existingColumn.highlighted;
if (historyEntry.action === 'sortByColumn' && column.name === historyEntry.columnName) {
column.appliedSort = historyEntry.sort; // Set sorted column to sorted if it was a sort action, otherwise if also not a void sort preserve
} else if (historyEntry.action !== 'sortByColumn' && historyEntry.action !== 'voidSortByColumn') {
column.appliedSort = existingColumn.appliedSort;
}
if (historyEntry.action === 'filterColumn' && column.name === historyEntry.columnName) {
if (existingColumn.type === 'numerical') {
column.appliedFilters = existingColumn.appliedFilters.concat([
historyEntry.filter as NumericalFilter,
]); // Set filtered column to filtered if it was a filter action, otherwise preserve
} else if (existingColumn.type === 'categorical') {
column.appliedFilters = existingColumn.appliedFilters.concat([
historyEntry.filter as CategoricalFilter,
]); // Set filtered column to filtered if it was a filter action, otherwise preserve
}
} else if (historyEntry.action !== 'filterColumn') {
column.appliedFilters = existingColumn.appliedFilters;
}
}
return resultContent.content;
});

updateTabOutdated(historyEntry);
throw new Error('Not implemented');
}
};

Expand Down
Loading