EqContext class

Encapsulates all information about EasyQuery components on some webpage and provides some basic operation over those components Each context includes the following main components:

  • one data model,
  • one query,
  • one result set
  • several UI widgets.

Index

Constructors

Public Properties

Public Methods

Protected Methods

Constructors


constructor

⊕ new EqContext(): EqContext


Public Properties


calcTotals

● calcTotals: boolean = false


clientListRequestHandler

● clientListRequestHandler: (data: any, callback: (list: any) => void) => boolean


dataLoader

● dataLoader: EasyQueryDataLoader


defaultModelId

● defaultModelId?: string


defaultQueryId

● defaultQueryId?: string


initialQuery

● initialQuery?: QueryData


loadModelOnStart

● loadModelOnStart: boolean = true


loadQueryOnStart

● loadQueryOnStart: boolean = false


resultContent

● resultContent?: string


resultStatement

● resultStatement?: string


resultTable

● resultTable: EasyDataTable


useBootstrap

● useBootstrap: boolean = false


Public Methods


addDefaultExporters

▸ addDefaultExporters(): void

Returns void


addEventListener

Adds event listener for event type.

▸ addEventListener(eventType: "ready" | "loadModel" | "initialModelLoad" | "loadQuery" | "syncQuery" | "fetchData" | "exportResult",handler: (context: EqContext) => void): string

Parameters:

  • eventType: "ready" | "loadModel" | "initialModelLoad" | "loadQuery" | "syncQuery" | "fetchData" | "exportResult" - The event type
  • handler: (context: EqContext) => void - The handler for event

Returns string

▸ addEventListener(eventType: "processStart" | "processEnd",handler: (context: EqContext, status: ActionStatus) => void): string

Parameters:

Returns string

▸ addEventListener(eventType: "error",handler: (context: EqContext, status: ActionStatus) => void): string

Parameters:

Returns string


addLocale

Adds the translations of the EasyQuery messages for some locale

▸ addLocale(locale: string,localeInfo: LocaleInfo): void

Parameters:

  • locale: string - the ISO code of the locale (like en or uk)
  • localeInfo: LocaleInfo - Locale settings and translations of EasyQuery texts and messages. We expected an object with the struture of LocaleInfo interface here.

Returns void


addQueryChangedCallback

Register a new handler for 'query changed' event

▸ addQueryChangedCallback(callback: any): void

Parameters:

  • callback: any -

Returns void


addWidget

Add a new widget to the context. After that the widget will start to receive messages from other context components.

▸ addWidget(widget: Widget): void

Parameters:

Returns void


callWhenModelLoaded

▸ callWhenModelLoaded(callFunc: any): void

Parameters:

  • callFunc: any

Returns void


clearQuery

Clears the content of the current query

▸ clearQuery(): void

Returns void


clearResult

Clears all query results (the data set and the statement, if any)

▸ clearResult(): void

Returns void


createQuery

Creates a new query object using the current instance of EqServices

▸ createQuery(): Query

Returns Query


endProcess

Notifies all context components about the finishing of some long process

▸ endProcess(action: ActionStatus,groups?: WidgetGroup): void

Parameters:

Returns void


exportResult

Fetches the data for defined by this context and exports them to the specified format.

▸ exportResult(options?: ContextExportResultOptions): void

Parameters:

  • options: ContextExportResultOptions, Optional - The content of the options parameter depends on EqExporter implementation. Usually it contains format property which defines the format of the exported data (e.g. csv), and success and error callbacks

Returns void

Example:


context.exportResult({
     format: csv
});



fetchData

Fetches the data (usuall by executing current query) and processes the result.

▸ fetchData(options?: ContextFetchDataOptions): void

Parameters:

  • options: ContextFetchDataOptions, Optional - The options parameter in addition to the options defined in ExecuteQueryOptions structure may also contain success and error callbacks.

Returns void

Example:


context.fetchData({ success: function(result) {
  //do whatever you want with the result
}})



fetchDataChunk

▸ fetchDataChunk(options?: ContextFetchDataOptions): void

Parameters:

Returns void


fetchDrillDownData

Fetches the data for a drill-down query (if defined) and processes the result.

▸ fetchDrillDownData(options: ContextFetchDataOptions): void

Parameters:

Returns void


fireEvent

Fires event.

▸ fireEvent(eventType: "ready" | "loadModel" | "initialModelLoad" | "loadQuery" | "syncQuery" | "fetchData" | "exportResult"): any

Parameters:

  • eventType: "ready" | "loadModel" | "initialModelLoad" | "loadQuery" | "syncQuery" | "fetchData" | "exportResult" - The event type.

Returns any

▸ fireEvent(eventType: "processStart" | "processEnd",data: ActionStatus): any

Parameters:

  • eventType: "processStart" | "processEnd"
  • data: ActionStatus

Returns any

▸ fireEvent(eventType: "error",data: Error): any

Parameters:

  • eventType: "error"
  • data: Error

Returns any


getAllWidgetsByType

Returns all widgets with current type.

▸ getAllWidgetsByType(widgetType: string): Widget[]

Parameters:

  • widgetType: string - The widget type

Returns Widget[]


getBaseEndpoint

▸ getBaseEndpoint(): string

Returns string


getDefaultTotalsSettings

▸ getDefaultTotalsSettings(): TotalsOptions

Returns TotalsOptions


getExportFormats

▸ getExportFormats(): string[]

Returns string[]


getExporter

▸ getExporter(format: string): EqExporter | null

Parameters:

  • format: string

Returns EqExporter | null


getListRequestHandler

Gets the handler for 'GetList' requests

▸ getListRequestHandler(): any

Returns any


getModel

Gets the current data model

▸ getModel(): DataModel

Returns DataModel


getQuery

Gets the current query

▸ getQuery(): Query

Returns Query


getQueryFile

▸ getQueryFile(options?: ContextGetQueryFileOptions): void

Parameters:

Returns void


getServices

▸ getServices(): EqServiceProvider

Returns EqServiceProvider


getTotalsSettings

▸ getTotalsSettings(): TotalsOptions

Returns TotalsOptions


getWidgetByType

Returns first registerd widget with current type

▸ getWidgetByType(widgetType: string): Widget | null

Parameters:

  • widgetType: string - The widget type

Returns Widget | null


init

Initializes the context

▸ init(options?: EqContextOptions): void

Parameters:

Returns void


loadDefaultModel

If defaultModelId property is define - this method calls loadModel function in the broker to load the model with such ID.

▸ loadDefaultModel(): void

Returns void


loadModel

Starts the process of the model loading. This method can initiate a request to EasyQueryServer backend or get the model from OData or GraphQL endpoint The content of the options parameter depends on concrete loader implementation.

▸ loadModel(options?: ContextLoadModelOptions): Promise<DataModel>

Parameters:

Returns Promise<DataModel>

Example:


context.loadModel()
   .then(model => {
      alert("Model loaded!");
   });


loadModelFromData

Sets the content of the current data model

▸ loadModelFromData(modelPlainData: ModelPlainData): void

Parameters:

Returns void


loadQuery

Loads the query

▸ loadQuery(options?: ContextLoadQueryOptions): void

Parameters:

  • options: ContextLoadQueryOptions, Optional - The content of the options parameter depends on QueryStorage implementation. Usually it contains success, error callbacks and queryId property of the query to load.

Returns void

Example:


context.loadQuery({
     queryId: "query-id"
});


loadQueryList

Loads the list of queries available for the current user.

▸ loadQueryList(options?: ContextLoadQueryListOptions): void

Parameters:

  • options: ContextLoadQueryListOptions, Optional - The content of the options parameter depends on QueryStorage implementation. Usually it contains success, error callbacks

Returns void


loadValueList

Sends a loadValueList requesthe server and processes the response.

▸ loadValueList(options?: ContextLoadValueListOptions): void

Parameters:

Returns void


newQuery

Creates a new query and returns its content back to the client-side.

▸ newQuery(options?: ContextNewQueryOptions): Query

Parameters:

  • options: ContextNewQueryOptions, Optional - The content of the options parameter depends on QueryStorage implementation. Usually it contains success, error callbacks and silent option

Returns Query

Example:


context.newQuery({
   silent: true
});


refreshWidgets

This method is called automatically when some change was made either in context's data model or query

▸ refreshWidgets(groups?: WidgetGroup): void

Parameters:

  • groups: WidgetGroup, Default value = WidgetGroup.All -

Returns void


registerExporter

▸ registerExporter(format: string,resolver: EqExporterResolver): void

Parameters:

  • format: string
  • resolver: EqExporterResolver

Returns void


registerServerExporter

▸ registerServerExporter(format: string,responseType: XMLHttpRequestResponseType): void

Parameters:

  • format: string
  • responseType: XMLHttpRequestResponseType

Returns void


removeEventListener

Remove event handler for event type .

▸ removeEventListener(eventType: string,handlerId: string): void

Parameters:

  • eventType: string - The event type.
  • handlerId: string - The handler id.

Returns void


removeQuery

Removes the current query from some storage on the server-side.

▸ removeQuery(options?: ContextRemoveQueryOptions): void

Parameters:

  • options: ContextRemoveQueryOptions, Optional - The content of the options parameter depends on QueryStorage implementation. Usually it contains success and error callbacks

Returns void


removeQueryChangedCallback

Removes the function from the list of registerd handlers for 'query changed' event

▸ removeQueryChangedCallback(callback: any): void

Parameters:

  • callback: any -

Returns void


resetListCache

Clears the current list cache.

▸ resetListCache(): void

Returns void


resolveEndpoint

▸ resolveEndpoint(endpointKey: EqEndpointKey,options?: any): string

Parameters:

  • endpointKey: EqEndpointKey
  • options: any, Optional

Returns string


saveQuery

Saves the current query to some storage on the server-side.

▸ saveQuery(options?: ContextSaveQueryOptions): void

Parameters:

  • options: ContextSaveQueryOptions, Optional - The content of the options parameter depends on QueryStorage implementation. Usually it contains success and error callbacks

Returns void


setDefaultModelId

Sets the ID of the default model

▸ setDefaultModelId(modelId: string): void

Parameters:

  • modelId: string -

Returns void


setEndpoint

▸ setEndpoint(key: EqEndpointKey,value: string): void

Parameters:

  • key: EqEndpointKey
  • value: string

Returns void


setEnpointIfNotExist

▸ setEnpointIfNotExist(key: EqEndpointKey,value: string): void

Parameters:

  • key: EqEndpointKey
  • value: string

Returns void


setExternalListCache

Sets the external 'list cache' provider - an object which implements ExternalListCache inteface

▸ setExternalListCache(cache: ExternalListCache): void

Parameters:

Returns void


setTotalsSettings

▸ setTotalsSettings(settings: TotalsOptions,silent?: boolean): void

Parameters:

  • settings: TotalsOptions
  • silent: boolean, Default value = false

Returns void


startProcess

Notifies context components about starting of some long process (e.g. model loading) This method raises onProcessStart event in the context and all its widgets

▸ startProcess(message: ActionStatus,groups?: WidgetGroup): void

Parameters:

Returns void


syncQuery

Syncronizes the current query.

▸ syncQuery(options?: ContextSyncQueryOptions): void

Parameters:

  • options: ContextSyncQueryOptions, Optional - The content of the options parameter depends on QuerySyncronizer implementation. Usually it contains success and error callbacks

Returns void


throwError

Throws the error passed in the function parameter. If onError event handler is defined - we call that method. Otherwise - just place the error message to the browser console.

▸ throwError(action: ActionStatus): void

Parameters:

Returns void


uploadQueryFile

▸ uploadQueryFile(options?: ContextUploadQueryFileOptions): void

Parameters:

Returns void


useEndpoint

Sets endpoint for all EasyQuery actions. Should be called before init and useEnterprise methods

▸ useEndpoint(endpoint: string): EqContext

Parameters:

  • endpoint: string

Returns EqContext

Example:


view.getContext() .useEndpoint('/api/easyquery') .useEnterprise(function () { view.init(); });



wereTotalsColumnsChanged

▸ wereTotalsColumnsChanged(settings?: TotalsOptions): boolean

Parameters:

  • settings: TotalsOptions, Optional

Returns boolean


Protected Methods


startQueryListLoading

▸ startQueryListLoading(options?: ContextLoadQueryListOptions): void

Parameters:

Returns void