Skip to content

Commit

Permalink
Cb 4270 row counter add cancel button for big tables (#2545)
Browse files Browse the repository at this point in the history
* CB-4270 adds cancel option for load total count of rows in table

* CB-4270 adds ui for load total count of rows in table

* CB-4270 fix: task cancels in a true way

* CB-4270 cleanup

* CB-4270 cancel load total count on close table tab

* CB-4270 cancel load total count on close sql editor tab

* CB-4270 fix: cancel close only task if it is not already cancelled

* CB-4270 chore: tasks -> cancelLoadTotalCountTasks

* CB-4270 stops counting rows when tab closes

* CB-4270 reverts incorrect calls of cancelLoadTotalCount

* CB-4270 reverts ToolsActions unneeded props

* CB-4270 pr fixes

* СB-4270 cancel load total count for refresh action

* CB-4270 fix: place cancelLoadTotalCount to DatabaseDataSource

* CB-4270 fix: cancel load rows in refresh data in data source

* CB-4270 cancels load on close result set tab

* CB-4270 refactor: move cancelLoadTotalCount to resultsetdatasource

* CB-4270 cancel load total count execute only for resultsetdatasource

* CB-4270 adds constraint for TableFooterRowCount

* CB-4270 fix: do not load new value if cancelled rows loading

* CB-4270 cleanup

* Revert "CB-4270 cleanup"

This reverts commit f8bffa2.

* CB-4270 pr fixes

* CB-4270 pr fixes

* CB-4270 deletes cross icon icon

* CB-4270 DataSources has correct tree of calls for cancel and dispose functions

* CB-4270 cleanup

* chore: add experimental cancellable promise implementation

* CB-4270 pr fixes: remove unneeded disposes + close results in close result tab flow

* CB-4270 removes closeResults abstraction leak in ResultSetDataSource extended classes

* CB-4270 removes unused context in data sources

* CB-4270 adds loader for CancelTotalCountAction on cancel task action

* CB-4270 cancel row count job fix

* CB-4270 cancel row counter with notification

* CB-4270 pr fixes

* CB-4270 pr fixes

---------

Co-authored-by: Aleksei Potsetsuev <[email protected]>
Co-authored-by: Daria Marutkina <[email protected]>
Co-authored-by: Ainur <[email protected]>
  • Loading branch information
4 people authored Apr 23, 2024
1 parent acde2c5 commit 51ef899
Show file tree
Hide file tree
Showing 26 changed files with 746 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public void run(DBRProgressMonitor monitor) throws InvocationTargetException, In
try {
monitor.beginTask("Get row data count", 1);
WebSQLResultsInfo results = contextInfo.getResults(resultsId);
long rowCount = DBUtils.readRowCount(webSession.getProgressMonitor(), contextInfo.getProcessor().getExecutionContext(), results.getDataContainer(), null, this);
long rowCount = DBUtils.readRowCount(monitor, contextInfo.getProcessor().getExecutionContext(), results.getDataContainer(), null, this);
this.result = "Row data count completed";
this.extendedResults = rowCount;
} catch (Throwable e) {
Expand Down
7 changes: 7 additions & 0 deletions webapp/packages/core-blocks/src/Containers/GroupClose.m.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
.groupClose {
width: 18px;
height: 18px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
const { merge } = require('webpack-merge');
const { resolve } = require('path');
const webpack = require('webpack');
Expand Down
15 changes: 15 additions & 0 deletions webapp/packages/core-executor/src/TaskScheduler/CancelError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/

export class CancelError extends Error {
constructor(message?: string, options?: ErrorOptions) {
super(message, options);

this.name = 'Cancel Error';
}
}
43 changes: 43 additions & 0 deletions webapp/packages/core-executor/src/TaskScheduler/ITaskNew.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/

export interface ITaskConstructor {
readonly prototype: ITask<any>;
new <T>(executor: TaskExecutor<T>): ITask<T>;

reject<T = never>(reason?: any): ITask<T>;
cancel<T = never>(reason?: any): ITask<T>;
resolve(): ITask<void>;
resolve<T>(value: T): ITask<Awaited<T>>;
resolve<T>(value: T | PromiseLike<T>): ITask<Awaited<T>>;
fromPromise<T>(promise: Promise<T>): ITask<T>;
all<T extends readonly unknown[] | []>(values: T): ITask<{ -readonly [P in keyof T]: Awaited<T[P]> }>;
allSettled<T extends readonly unknown[] | []>(
values: T,
): ITask<{ -readonly [P in keyof T]: { status: 'fulfilled'; value: Awaited<T[P]> } | { status: 'rejected' | 'cancelled'; reason: any } }>;
}

declare const ITask: ITaskConstructor;

export interface ITask<TValue> extends Promise<TValue>, PromiseLike<TValue> {
readonly then: <TResult1 = TValue, TResult2 = never, TResult3 = never>(
onFulfilled?: ((value: TValue) => TResult1 | PromiseLike<TResult1>) | null,
onRejected?: ((reason: any, cancelled: boolean) => TResult2 | PromiseLike<TResult2>) | null,
) => ITask<TResult1 | TResult2 | TResult3>;
readonly catch: <TResult = never>(
onRejected?: ((reason: any, cancelled: boolean) => TResult | PromiseLike<TResult>) | null,
) => ITask<TValue | TResult>;
readonly finally: (onfinally?: (() => void) | null) => ITask<TValue>;
readonly cancel: (reason?: any) => ITask<void>;
}

export type TaskResolveFn<T> = (reason: T | PromiseLike<T>) => void;
export type TaskRejectFn = (reason?: any, cancelled?: boolean) => void;
export type TaskCancelFn = (reason?: any) => ITask<void> | void;

export type TaskExecutor<T> = (resolve: TaskResolveFn<T>, reject: TaskRejectFn, registerCancel: (cancel: TaskCancelFn) => void) => void;
Loading

0 comments on commit 51ef899

Please sign in to comment.