@sassoftware/vi-api
Version:
Types used in the SAS Visual Investigator API
221 lines (220 loc) • 9.75 kB
TypeScript
import { ObjectIdentifier, ObjectSheetSettings, VIObject } from "../object/object-api";
import { NetworkData, Visualization } from "../search/client/client-search-api";
/**
* This API relates to SAS Visual Investigator's sheet functionality.
*
* Accessed from the window at `window.sas.vi.sheet`.
*
* @example window.sas.vi.sheet.getOpenObjects();
* @category API
*/
export interface SheetApi {
/**
* @method
* @description Gets a specified object that is currently open and allows sheets.
* @param objectId {string} Open object's ID.
* @param objectType {string} Open object's type.
* @returns The specified object or undefined if it is not found.
*/
getOpenObject(objectId: string, objectType: string): VIObject | undefined;
/**
* @method
* @description Gets all of the objects currently open that allow sheets.
* @returns A list of currently open objects or an empty list if none are found.
*/
getOpenObjects(): VIObject[];
/**
* @method
* @description Gets the open object containing the specified sheet.
* @param sheet {ClientSheet} Sheet contained within the expected object.
* @returns The requested object or undefined if it could not be found.
*/
getOpenObjectBySheet(sheet: ClientSheet): VIObject | undefined;
/**
* @deprecated use {@link registerNetworkMenuCallback} instead.
* @method
* @description Deprecated. This function is deprecated and replaced with registerNetworkMenuCallback. The original
* function did not allow users to extend the menu being constructed by a context click.
*
* Creates and returns the list containing all Context Menu Items for a right-click on a network diagram node.
* The menu is not rendered on the network diagram.
* @param workspace {ClientSheet} Workspace containing the network. The workspace should not be manually constructed.
* @param handleAddToWorkspaceFn {function} A callback to handle adding the selected nodes to a workspace.
* @param handleAddToInsightsFn {function} A callback to handle adding the NLD to an Insight.
* @returns Promise resolving to the list containing all Context Menu Items.
*/
createContextMenuForNodes(workspace: ClientSheet, handleAddToWorkspaceFn?: () => void, handleAddToInsightsFn?: () => void): Promise<ContextMenuItem[]>;
/**
* @method
* @description Registers a callback that is invoked whenever the node or network context menu is constructed.
* The caller can extend the menu to provide access to extra functionality. It is the caller's responsibility
* to ensure that they properly extend the menu. Failing to do so can result in application errors.
*
* The callback can be unregistered by calling this function without passing in a callback function
* or setting it to undefined.
*
* @param menuType {NetworkMenuType} The type of menu to extend.
* @param callback {NetworkMenuCallback} The callback function invoked when the context menu is constructed.
* This function is passed the menu object, which can be modified/extended, and the "client Id" of the current workspace.
* If callback not passed in or is undefined, the callback is unregistered.
* @returns void
*/
registerNetworkMenuCallback(menuType: NetworkMenuType, callback?: NetworkMenuCallback): void;
/**
* @method
* @description Adds objects to a workspace selected in the "Add Objects to Workspace" dialog box.
* @param objects {ObjectIdentifier[]} Objects to add to a workspace.
* @param [options] {AddAllObjectsToWorkspaceDialogOptions} Additional options to customize the dialog box and select the Visualization to display after the objects are added.
*/
openAddAllObjectsToWorkspaceDialog(objects: ObjectIdentifier[], options?: AddAllObjectsToWorkspaceDialogOptions): Promise<void>;
/**
* @method
* @description Adds an image to the Insights selected in the "Add image to Insights" dialog box.
* @param imageData {Uint8Array | HTMLElement} Image to add. Either directly as an array of bytes or from an HTMLElement on the page.
* @param [contentType="image/png"] {string} Used in the content-type header when the file is uploaded.
* @param [height] {string} Height of the Insights cell.
* @param [width] {string} Width of the Insights cell.
*/
openAddImageToInsightsDialog(imageData: Uint8Array | HTMLElement, contentType: string, height?: string, width?: string): Promise<void>;
/**
* @method
* @description Creates a new workspace in the target object, populating it with an initial set of objects.
* Allows the creation of new objects assuming create mode is supported for the object type.
* If options.targetObjectId is undefined, then a new object is created.
* @param objectsToAdd {ObjectIdentifier[]} Objects to add to the new workspace.
* @param targetObjectType {string} Object type where the workspace is created.
* @param [options] {AddToNewWorkspaceOptions} Additional options to set a target object ID, workspace name and so on.
*/
addToNewWorkspace(objectsToAdd: ObjectIdentifier[], targetObjectType: string, options: AddToNewWorkspaceOptions): Promise<void>;
/**
* @method
* @description Adds objects to an existing workspace.
* @param targetObject {VIObject} Object containing the existing workspace.
* @param workspaceClientId {string} Client ID of the workspace to add to.
* @param objectsToAdd {ObjectIdentifier[]} Objects to add. It is safe to pass objects that are already in the workspace.
* @param [networkData] {NetworkData} If provided, network data that will be merged into any existing network data on the workspace.
* @param [isUndoRedo] {boolean} Specifies if the function was called as part of an undo/redo operation.
*/
addToExistingWorkspace(targetObject: VIObject, workspaceClientId: string, objectsToAdd: ObjectIdentifier[], networkData?: NetworkData, isUndoRedo?: boolean): Promise<void>;
}
export interface AddAllObjectsToWorkspaceDialogOptions {
/**
* The visualization to initially display after the objects have been added.
*/
visualizationName?: Visualization;
/**
* The object the user is currently viewing. This is used as a visual aid in the dialog.
*/
currentObject?: ObjectIdentifier;
/**
* Network visualization data to be copied to the workspace.
*/
networkData?: NetworkData;
}
export interface AddToNewWorkspaceOptions {
/**
* The object to add the workspace to. If undefined a new object will be created.
*/
targetObjectId?: string;
/**
* The visualization to initially display in the new workspace.
*/
visualization?: Visualization;
/**
* The name of the new workspace.
*/
workspaceName?: string;
/**
* Network visualization data to be copied to the new workspace.
*/
networkData?: NetworkData;
}
export interface ContextMenuItem {
/**
* The default label string for the menu item.
*/
label?: string;
/**
* The default field for the font icon to be displayed next to the menu item.
*/
icon?: string;
/**
* The default name for the field used to place a checkmark on the menu item.
* The meaning of value is:
* true - will show a checkbox on the menu item
* false - will show no checkmark but an empty space will be reserved for a checkmark
* undefined - checkmarks are not used for this menu item.
*
* Notes: The menu component will not automatically change the value. It must be done by
* the selectItem handler.
* When value is false, it is recommended that the menu text indicate that the menu item
* can have a value.
*/
value?: boolean;
/**
* The default CSS class name of a SAS font icon that will be placed
* next to the menu expand arrow in the menu item.
*/
indicatorIcon?: string;
/**
* URL to retrieve custom icon to display
*/
iconUrl?: string;
/**
* Indicates whether the menu item can be clicked.
*/
disabled?: boolean;
/**
* If true, this item will be shown as a separator, and all other properties will be ignored.
*/
separator?: boolean;
/**
* Indicates that the menu item is not selectable but is displayed as a heading.
* If heading is true then the value field and indicator are ignored.
*/
heading?: boolean;
/**
* If there is a cascade menu then its data is in the items.
*/
items?: any[];
/**
* When present, this method will be called when this menu item is selected.
*/
click?: (event?: any) => void;
}
export interface SheetCell {
id: string;
type: string;
}
export interface Sheet {
id: number;
name: string;
cells: SheetCell[];
type: string;
created?: string;
createdBy?: string;
lastModified?: string;
lastModifiedBy?: string;
tabOrder: number;
version?: string;
document: {
id: string;
type: string;
};
}
export interface ClientSheet extends Sheet {
clientId: string;
document: ObjectSheetSettings;
}
/**
* The set of menu types which can be extended
* via the registerNetworkMenuCallback function.
*/
export declare enum NetworkMenuType {
NetworkContext = "networkContext",
NodeContext = "nodeContext"
}
/**
* The type of function that can be registered as a callback for modifying the Network menus.
*/
export type NetworkMenuCallback = (menu: ContextMenuItem, workspaceClientId: string) => void;