diff --git a/vuu-ui/packages/vuu-data-react/src/hooks/useTypeaheadSuggestions.ts b/vuu-ui/packages/vuu-data-react/src/hooks/useTypeaheadSuggestions.ts index 9c35ffcd1..a464dd2b0 100644 --- a/vuu-ui/packages/vuu-data-react/src/hooks/useTypeaheadSuggestions.ts +++ b/vuu-ui/packages/vuu-data-react/src/hooks/useTypeaheadSuggestions.ts @@ -1,8 +1,8 @@ -import { makeRpcCall } from "@finos/vuu-data-remote"; +import {makeRpcCall, newMakeRpcCall} from "@finos/vuu-data-remote"; import { SuggestionFetcher, TableSchemaTable } from "@finos/vuu-data-types"; import { VuuRpcServiceRequest, - TypeaheadParams, + TypeaheadParams, NewVuuRpcServiceRequest, VuuContext, NewTypeaheadParams } from "@finos/vuu-protocol-types"; import { useCallback } from "react"; @@ -19,20 +19,30 @@ export const getTypeaheadParams = ( }; export const useTypeaheadSuggestions = () => - useCallback(async (params: TypeaheadParams) => { - const rpcMessage: VuuRpcServiceRequest = - params.length === 2 - ? { - type: "RPC_CALL", - service: "TypeAheadRpcHandler", - method: "getUniqueFieldValues", - params, + useCallback(async (paramsArray: TypeaheadParams) => { + + var context: VuuContext = { + type: "VIEWPORT_CONTEXT", + viewPortId: "" + } + + var params: NewTypeaheadParams = { + table: paramsArray[0]["table"], + module: paramsArray[0]["module"], + column: paramsArray[1] + }; + const rpcMessage: NewVuuRpcServiceRequest = + { + type: "RPC_REQUEST", + context, + rpcName: "getUniqueFieldValues", + params, } - : { - type: "RPC_CALL", - service: "TypeAheadRpcHandler", - method: "getUniqueFieldValuesStartingWith", - params, - }; - return makeRpcCall(rpcMessage); + // : { + // type: "RPC_REQUEST", + // context, + // rpcName: "getUniqueFieldValuesStartingWith", + // params, + // }; + return newMakeRpcCall(rpcMessage); }, []); diff --git a/vuu-ui/packages/vuu-data-remote/src/connection-manager.ts b/vuu-ui/packages/vuu-data-remote/src/connection-manager.ts index 4ec4523d1..681496446 100644 --- a/vuu-ui/packages/vuu-data-remote/src/connection-manager.ts +++ b/vuu-ui/packages/vuu-data-remote/src/connection-manager.ts @@ -16,7 +16,7 @@ import { VuuTable, VuuTableList, VuuCreateVisualLink, - VuuRemoveVisualLink, + VuuRemoveVisualLink, NewVuuRpcServiceRequest, } from "@finos/vuu-protocol-types"; import { EventEmitter, @@ -232,6 +232,7 @@ export interface ServerAPI { rpcCall: ( msg: | VuuRpcServiceRequest + | NewVuuRpcServiceRequest | VuuRpcMenuRequest | VuuRpcViewportRequest | VuuCreateVisualLink @@ -388,3 +389,13 @@ export const makeRpcCall = async ( throw Error("Error accessing server api"); } }; + +export const newMakeRpcCall = async ( + rpcRequest: NewVuuRpcServiceRequest, +) => { + try { + return (await serverAPI).rpcCall(rpcRequest); + } catch (err) { + throw Error("Error accessing server api"); + } +}; diff --git a/vuu-ui/packages/vuu-data-remote/src/server-proxy/server-proxy.ts b/vuu-ui/packages/vuu-data-remote/src/server-proxy/server-proxy.ts index 138fc36ec..283eae820 100644 --- a/vuu-ui/packages/vuu-data-remote/src/server-proxy/server-proxy.ts +++ b/vuu-ui/packages/vuu-data-remote/src/server-proxy/server-proxy.ts @@ -35,7 +35,7 @@ import type { VuuTable, VuuRpcRequest, VuuCreateVisualLink, - VuuRemoveVisualLink, + VuuRemoveVisualLink, NewVuuRpcServiceRequest, } from "@finos/vuu-protocol-types"; import { isVuuMenuRpcRequest, @@ -596,6 +596,13 @@ export class ServerProxy { this.sendMessageToServer(rpcRequest, requestId, { module }); } + private newRpcCall(message: WithRequestId) { + const [requestId, rpcRequest] = + stripRequestId(message); + const module = getRpcServiceModule("TypeAheadRpcHandler"); + this.sendMessageToServer(rpcRequest, requestId, { module }); + } + public handleMessageFromClient( message: | Exclude< @@ -605,11 +612,13 @@ export class ServerProxy { | VuuUIMessageOutUnsubscribe > | WithRequestId + | WithRequestId | WithRequestId | WithRequestId | WithRequestId, ) { if (isViewportMessage(message) || isVisualLinkMessage(message)) { + if (message.type === "disable") { // Viewport may already have been unsubscribed const viewport = this.getViewportForClient(message.viewport, false); @@ -693,6 +702,8 @@ export class ServerProxy { } case "RPC_CALL": return this.rpcCall(message); + case "RPC_REQUEST": + return this.newRpcCall(message); default: } } diff --git a/vuu-ui/packages/vuu-protocol-types/index.d.ts b/vuu-ui/packages/vuu-protocol-types/index.d.ts index 97a51977c..7cf897ee0 100644 --- a/vuu-ui/packages/vuu-protocol-types/index.d.ts +++ b/vuu-ui/packages/vuu-protocol-types/index.d.ts @@ -277,6 +277,13 @@ export declare type TypeaheadParams = | [VuuTable, string] | [VuuTable, string, string]; +export declare type NewTypeaheadParams = { + table: string; + module: string; + column: string; +} + + export declare type TypeAheadMethod = | "getUniqueFieldValues" | "getUniqueFieldValuesStartingWith"; @@ -362,6 +369,13 @@ export declare type VuuRpcResponse = | VuuRpcMenuResponse | VuuRpcEditResponse; +export declare type NewVuuRpcServiceRequest = { + type: "RPC_REQUEST"; + context: VuuContext; + rpcName: string; + params: NewTypeaheadParams; +} + export declare type VuuRpcServiceRequest = { type: "RPC_CALL"; service: "TypeAheadRpcHandler"; @@ -552,6 +566,12 @@ export declare type VuuRange = { to: number; }; +export declare type VuuContextType = "GLOBAL_CONTEXT" | "VIEWPORT_CONTEXT"|"VIEWPORT_ROW_CONTEXT"; +export declare type VuuContext = { + type: VuuContextType; + viewPortId: string; +} + export declare type VuuSortType = "A" | "D"; export declare type VuuSortCol = { diff --git a/vuu/src/main/scala/org/finos/vuu/net/json/JsonVsSerializer.scala b/vuu/src/main/scala/org/finos/vuu/net/json/JsonVsSerializer.scala index 6d41f1c44..413917d27 100644 --- a/vuu/src/main/scala/org/finos/vuu/net/json/JsonVsSerializer.scala +++ b/vuu/src/main/scala/org/finos/vuu/net/json/JsonVsSerializer.scala @@ -3,6 +3,7 @@ package org.finos.vuu.net.json import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.scala.DefaultScalaModule +import com.typesafe.scalalogging.StrictLogging import org.finos.vuu.net.{JsonViewServerMessage, MessageBody, ViewServerMessage} trait Serializer[R, SERTYPE] { @@ -11,7 +12,7 @@ trait Serializer[R, SERTYPE] { def deserialize(message: R): ViewServerMessage } -object JsonVsSerializer extends Serializer[String, MessageBody] { +object JsonVsSerializer extends Serializer[String, MessageBody] with StrictLogging { def getMapper = { val mapper = new ObjectMapper() @@ -24,6 +25,7 @@ object JsonVsSerializer extends Serializer[String, MessageBody] { def deserialize(s: String): JsonViewServerMessage = { val mapper = getMapper + logger.info(s); mapper.readValue(s, classOf[JsonViewServerMessage]) }