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

populate Instrument Picker from basket constituents #1011

Merged
merged 2 commits into from
Nov 24, 2023
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
8 changes: 6 additions & 2 deletions vuu-ui/packages/vuu-data/src/remote-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Selection } from "@finos/vuu-datagrid-types";
import {
ClientToServerEditRpc,
ClientToServerMenuRPC,
ClientToServerViewportRpcCall,
LinkDescriptorWithLabel,
VuuAggregation,
VuuDataRowDto,
Expand Down Expand Up @@ -35,6 +36,7 @@ import {
DataSourceStatus,
isDataSourceConfigMessage,
OptimizeStrategy,
RpcResponse,
SubscribeCallback,
SubscribeProps,
vanillaConfig,
Expand Down Expand Up @@ -646,9 +648,11 @@ export class RemoteDataSource
}
}

async rpcCall(rpcRequest: Omit<ClientToServerViewportRpcCall, "vpId">) {
async rpcCall<T extends RpcResponse = RpcResponse>(
rpcRequest: Omit<ClientToServerViewportRpcCall, "vpId">
) {
if (this.viewport) {
return this.server?.rpcCall<MenuRpcResponse>({
return this.server?.rpcCall<T>({
vpId: this.viewport,
...rpcRequest,
} as ClientToServerViewportRpcCall);
Expand Down
2 changes: 1 addition & 1 deletion vuu-ui/packages/vuu-shell/src/feature/Loader.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// TODO
export const Loader = () => <div className="hwLoader">loading</div>;
export const Loader = () => <div className="hwLoader"></div>;
4 changes: 2 additions & 2 deletions vuu-ui/sample-apps/feature-basket-trading/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
"table": "basketTradingConstituentJoin"
},
{
"module": "SIMUL",
"table": "instruments"
"module": "BASKET",
"table": "basketConstituent"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export interface BasketTradingFeatureProps {
basketSchema: TableSchema;
basketTradingSchema: TableSchema;
basketTradingConstituentJoinSchema: TableSchema;
instrumentsSchema: TableSchema;
basketConstituentSchema: TableSchema;
}

const VuuBasketTradingFeature = (props: BasketTradingFeatureProps) => {
const {
basketSchema,
basketTradingSchema,
basketTradingConstituentJoinSchema,
instrumentsSchema,
basketConstituentSchema,
} = props;

const {
Expand All @@ -46,7 +46,7 @@ const VuuBasketTradingFeature = (props: BasketTradingFeatureProps) => {
basketSchema,
basketTradingSchema,
basketTradingConstituentJoinSchema,
instrumentsSchema,
basketConstituentSchema,
});

if (basketCount === -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { DataSource } from "@finos/vuu-data";
import { useMemo } from "react";

export const useBasketContextMenus = ({
dataSourceInstruments,
dataSourceBasketConstituent,
}: {
dataSourceInstruments: DataSource;
dataSourceBasketConstituent: DataSource;
}) => {
const dispatchLayoutAction = useLayoutProviderDispatch();

Expand Down Expand Up @@ -47,7 +47,7 @@ export const useBasketContextMenus = ({
allowDragDrop: "drag-copy",
id: "basket-instruments",
},
dataSource: dataSourceInstruments,
dataSource: dataSourceBasketConstituent,
},
},
title: "Add Ticker",
Expand All @@ -57,5 +57,5 @@ export const useBasketContextMenus = ({
return false;
},
];
}, [dataSourceInstruments, dispatchLayoutAction]);
}, [dataSourceBasketConstituent, dispatchLayoutAction]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export type BasketTradingHookProps = Pick<
| "basketSchema"
| "basketTradingSchema"
| "basketTradingConstituentJoinSchema"
| "instrumentsSchema"
| "basketConstituentSchema"
>;

const toDataDto = (dataSourceRow: VuuDataRow, columnMap: ColumnMap) => {
Expand All @@ -67,7 +67,7 @@ export const useBasketTrading = ({
basketSchema,
basketTradingSchema,
basketTradingConstituentJoinSchema,
instrumentsSchema,
basketConstituentSchema,
}: BasketTradingHookProps) => {
const { load, save } = useViewContext();

Expand All @@ -81,15 +81,15 @@ export const useBasketTrading = ({
dataSourceBasketTradingControl,
dataSourceBasketTradingSearch,
dataSourceBasketTradingConstituentJoin,
dataSourceInstruments,
dataSourceBasketConstituent,
onSendToMarket,
onTakeOffMarket,
} = useBasketTradingDataSources({
basketInstanceId,
basketSchema,
basketTradingSchema,
basketTradingConstituentJoinSchema,
instrumentsSchema,
basketConstituentSchema,
});

const [basket, setBasket] = useState<Basket | undefined>();
Expand Down Expand Up @@ -121,9 +121,6 @@ export const useBasketTrading = ({
);

useMemo(() => {
console.log(
`subscribe to BT Control ${dataSourceBasketTradingControl.status}`
);
dataSourceBasketTradingControl.subscribe(
{
range: { from: 0, to: 1 },
Expand Down Expand Up @@ -215,7 +212,7 @@ export const useBasketTrading = ({
);

const [menuBuilder, menuActionHandler] = useBasketContextMenus({
dataSourceInstruments,
dataSourceBasketConstituent,
});

const handleRpcResponse = useCallback((response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type basketDataSourceKey =
| "data-source-basket-trading-control"
| "data-source-basket-trading-search"
| "data-source-basket-trading-constituent-join"
| "data-source-instruments";
| "data-source-basket-constituent";

const NO_FILTER = { filter: "" };

Expand All @@ -24,7 +24,7 @@ export const useBasketTradingDataSources = ({
basketInstanceId,
basketTradingSchema,
basketTradingConstituentJoinSchema,
instrumentsSchema,
basketConstituentSchema,
}: BasketTradingFeatureProps & { basketInstanceId: string }) => {
const { notify } = useNotifications();
const { id, loadSession, saveSession, title } = useViewContext();
Expand All @@ -34,7 +34,7 @@ export const useBasketTradingDataSources = ({
dataSourceBasketTradingControl,
dataSourceBasketTradingSearch,
dataSourceBasketTradingConstituentJoin,
dataSourceInstruments,
dataSourceBasketConstituent,
] = useMemo(() => {
const basketFilter: VuuFilter = basketInstanceId
? {
Expand All @@ -61,7 +61,7 @@ export const useBasketTradingDataSources = ({
100,
basketFilter,
],
["data-source-instruments", instrumentsSchema, 100],
["data-source-basket-constituent", basketConstituentSchema, 100],
];

const dataSources: DataSource[] = [];
Expand All @@ -86,7 +86,7 @@ export const useBasketTradingDataSources = ({
basketTradingSchema,
basketInstanceId,
basketTradingConstituentJoinSchema,
instrumentsSchema,
basketConstituentSchema,
loadSession,
id,
title,
Expand Down Expand Up @@ -125,7 +125,7 @@ export const useBasketTradingDataSources = ({
dataSourceBasketTradingControl,
dataSourceBasketTradingSearch,
dataSourceBasketTradingConstituentJoin,
dataSourceInstruments,
dataSourceBasketConstituent,
onSendToMarket: handleSendToMarket,
onTakeOffMarket: handleTakeOffMarket,
};
Expand Down
10 changes: 6 additions & 4 deletions vuu-ui/sample-apps/feature-instrument-tiles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@
},
"vuu": {
"featureProps": {
"schemas": {
"module": "SIMUL",
"table": "instrumentPrices"
}
"schemas": [
{
"module": "SIMUL",
"table": "instrumentPrices"
}
]
},
"leftNavLocation": "vuu-features"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@ import { buildColumnMap, metadataKeys } from "@finos/vuu-utils";
import { useCallback, useEffect, useMemo } from "react";
import { InstrumentTile } from "./InstrumentTile";
import { InstrumentTileContainer } from "./InstrumentTileContainer";
// import { useDataSource } from "@finos/vuu-data-react";
import { useDataSource } from "./useDataSource";

import "./VuuInstrumentTilesFeature.css";

const classBase = "VuuInstrumentTilesFeature";

export interface InstrumentTilesFeatureProps {
tableSchema: TableSchema;
instrumentPricesSchema: TableSchema;
}

const { KEY } = metadataKeys;

const VuuInstrumentTilesFeature = ({
tableSchema,
instrumentPricesSchema,
}: InstrumentTilesFeatureProps) => {
const { id, save, loadSession, saveSession, title } = useViewContext();

Expand Down Expand Up @@ -65,8 +64,8 @@ const VuuInstrumentTilesFeature = ({
ds = new RemoteDataSource({
bufferSize: 200,
viewport: id,
table: tableSchema.table,
columns: tableSchema.columns.map((col) => col.name),
table: instrumentPricesSchema.table,
columns: instrumentPricesSchema.columns.map((col) => col.name),
filter,
title,
});
Expand All @@ -79,8 +78,8 @@ const VuuInstrumentTilesFeature = ({
id,
loadSession,
saveSession,
tableSchema.columns,
tableSchema.table,
instrumentPricesSchema.columns,
instrumentPricesSchema.table,
title,
]);

Expand Down
Loading