Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ScottLogic/finos-vuu into V…
Browse files Browse the repository at this point in the history
…UU-27-remote-layout-management
  • Loading branch information
vferraro-scottlogic committed Oct 20, 2023
2 parents 847f7c1 + e2bc781 commit 63ea32e
Show file tree
Hide file tree
Showing 143 changed files with 3,439 additions and 1,361 deletions.
36 changes: 36 additions & 0 deletions vuu-ui/package-lock.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export class ArrayDataSource
return this.#config;
}

set config(config: DataSourceConfig | undefined) {
set config(config: DataSourceConfig) {
if (configChanged(this.#config, config)) {
if (config) {
const originalConfig = this.#config;
Expand Down
18 changes: 18 additions & 0 deletions vuu-ui/packages/vuu-data/src/connection-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ const pendingRequests = new Map();

type WorkerOptions = {
protocol: WebSocketProtocol;
retryLimitDisconnect?: number;
retryLimitStartup?: number;
url: string;
token?: string;
username: string | undefined;
Expand All @@ -89,6 +91,8 @@ type WorkerOptions = {
const getWorker = async ({
handleConnectionStatusChange,
protocol,
retryLimitDisconnect,
retryLimitStartup,
token = "",
username,
url,
Expand Down Expand Up @@ -120,6 +124,8 @@ const getWorker = async ({
window.clearTimeout(timer);
worker.postMessage({
protocol,
retryLimitDisconnect,
retryLimitStartup,
token,
type: "connect",
url,
Expand Down Expand Up @@ -274,6 +280,10 @@ export type ConnectOptions = {
authToken?: string;
username?: string;
protocol?: WebSocketProtocol;
/** Max number of reconnect attempts in the event of unsuccessful websocket connection at startup */
retryLimitStartup?: number;
/** Max number of reconnect attempts in the event of a disconnected websocket connection */
retryLimitDisconnect?: number;
};

class _ConnectionManager extends EventEmitter<ConnectionEvents> {
Expand All @@ -284,6 +294,8 @@ class _ConnectionManager extends EventEmitter<ConnectionEvents> {
authToken,
username,
protocol,
retryLimitDisconnect,
retryLimitStartup,
}: ConnectOptions): Promise<ServerAPI> {
// By passing handleMessageFromWorker here, we can get connection status
//messages while we wait for worker to resolve.
Expand All @@ -292,6 +304,8 @@ class _ConnectionManager extends EventEmitter<ConnectionEvents> {
url,
token: authToken,
username,
retryLimitDisconnect,
retryLimitStartup,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
handleConnectionStatusChange: handleMessageFromWorker,
Expand Down Expand Up @@ -321,13 +335,17 @@ export const connectToServer = async ({
protocol = undefined,
authToken,
username,
retryLimitDisconnect,
retryLimitStartup,
}: ConnectOptions) => {
try {
const serverAPI = await ConnectionManager.connect({
protocol,
url,
authToken,
username,
retryLimitDisconnect,
retryLimitStartup,
});
resolveServer(serverAPI);
} catch (err: unknown) {
Expand Down
2 changes: 1 addition & 1 deletion vuu-ui/packages/vuu-data/src/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export interface DataSource extends EventEmitter<DataSourceEvents> {
applyEdit: DataSourceEditHandler;
closeTreeNode: (key: string, cascade?: boolean) => void;
columns: string[];
config: DataSourceConfig | undefined;
config: DataSourceConfig;
suspend?: () => void;
resume?: () => void;
enable?: () => void;
Expand Down
33 changes: 19 additions & 14 deletions vuu-ui/packages/vuu-data/src/json-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import type {
DataSourceEvents,
SubscribeCallback,
SubscribeProps,
WithFullConfig,
} from "./data-source";
import { vanillaConfig } from "./data-source";
import {
MenuRpcResponse,
VuuUIMessageInRPCEditReject,
Expand Down Expand Up @@ -59,7 +61,7 @@ export class JsonDataSource
private visibleRows: DataSourceRow[] = [];

#aggregations: VuuAggregation[] = [];
#columns: string[] = [];
#config: WithFullConfig = vanillaConfig;
#data: DataSourceRow[];
#filter: DataSourceFilter = { filter: "" };
#groupBy: VuuGroupBy = [];
Expand Down Expand Up @@ -100,7 +102,10 @@ export class JsonDataSource
this.#aggregations = aggregations;
}
if (this.columnDescriptors) {
this.#columns = this.columnDescriptors.map((c) => c.name);
this.#config = {
...this.#config,
columns: this.columnDescriptors.map((c) => c.name),
};
}
if (filter) {
this.#filter = filter;
Expand Down Expand Up @@ -134,7 +139,10 @@ export class JsonDataSource
this.#aggregations = aggregations;
}
if (columns) {
this.#columns = columns;
this.#config = {
...this.#config,
columns,
};
}
if (filter) {
this.#filter = filter;
Expand Down Expand Up @@ -162,7 +170,7 @@ export class JsonDataSource
aggregations: this.#aggregations,
type: "subscribed",
clientViewportId: this.viewport,
columns: this.#columns,
columns: this.#config.columns,
filter: this.#filter,
groupBy: this.#groupBy,
range: this.#range,
Expand Down Expand Up @@ -240,8 +248,6 @@ export class JsonDataSource
size: this.visibleRows.length,
type: "viewport-update",
});

console.log(this.expandedRows);
}

closeTreeNode(key: string, cascade = false) {
Expand All @@ -258,7 +264,7 @@ export class JsonDataSource
}

get config() {
return undefined;
return this.#config;
}

get selectedRowsCount() {
Expand Down Expand Up @@ -295,12 +301,15 @@ export class JsonDataSource
}

get columns() {
return this.#columns;
return this.#config.columns;
}

set columns(columns: string[]) {
this.#columns = columns;
console.log(`ArrayDataSource setColumns ${columns.join(",")}`);
// TODO use setter
this.#config = {
...this.#config,
columns,
};
}

get aggregations() {
Expand All @@ -327,7 +336,6 @@ export class JsonDataSource
set filter(filter: DataSourceFilter) {
// TODO should we wait until server ACK before we assign #sort ?
this.#filter = filter;
console.log(`RemoteDataSource ${JSON.stringify(filter)}`);
}

get groupBy() {
Expand Down Expand Up @@ -402,9 +410,6 @@ export class JsonDataSource
);
}

const sections = rowKey.split("|").slice(1);
console.log({ sections, parentRow });

return [];
}

Expand Down
2 changes: 1 addition & 1 deletion vuu-ui/packages/vuu-data/src/remote-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ export class RemoteDataSource
return this.#config;
}

set config(config: DataSourceConfig | undefined) {
set config(config: DataSourceConfig) {
if (configChanged(this.#config, config)) {
if (config) {
const newConfig: DataSourceConfig =
Expand Down
2 changes: 2 additions & 0 deletions vuu-ui/packages/vuu-data/src/vuuUIMessageTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ export interface VuuUIMessageOutConnect {
token: string;
url: string;
username?: string;
retryLimitDisconnect?: number;
retryLimitStartup?: number;
}

export interface VuuUIMessageOutSubscribe extends ServerProxySubscribeMessage {
Expand Down
Loading

0 comments on commit 63ea32e

Please sign in to comment.