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
- clientListRequestHandler
- defaultModelId
- defaultQueryId
- initialQuery
- loadModelOnStart
- loadQueryOnStart
- resultContent
- resultSet
- resultStatement
- useBootstrap
Protected Properties
Public Methods
- addDefaultExporters
- addEventListener
- addLocale
- addQueryChangedCallback
- addWidget
- callWhenModelLoaded
- clearQuery
- clearResult
- endProcess
- executeQuery
- exportResult
- fireEvent
- getBaseEndpoint
- getBroker
- getExporter
- getListRequestHandler
- getModel
- getQuery
- getServices
- init
- loadDefaultModel
- loadModel
- loadModelFromData
- loadQuery
- loadQueryList
- loadValueList
- newQuery
- refreshWidgets
- registerExporter
- removeEventListener
- removeQuery
- removeQueryChangedCallback
- resetListCache
- resolveEndpoint
- saveQuery
- setDefaultModelId
- setEndpoint
- setEnpointIfNotExist
- setExternalListCache
- startProcess
- syncQuery
- throwError
Constructors
constructor
⊕ new EqContext(): EqContext
Public Properties
clientListRequestHandler
● clientListRequestHandler: (data: any
, callback: (list: any
) => void
) => boolean
defaultModelId
● defaultModelId?: string
defaultQueryId
● defaultQueryId?: string
initialQuery
● initialQuery?: QueryData
loadModelOnStart
● loadModelOnStart: boolean
= true
loadQueryOnStart
● loadQueryOnStart: boolean
= false
resultContent
● resultContent?: string
resultSet
● resultSet?: EqDataTable
resultStatement
● resultStatement?: string
useBootstrap
● useBootstrap: boolean
= false
Protected Properties
antiForgeryToken
● antiForgeryToken: string
Public Methods
addDefaultExporters
▸ addDefaultExporters(): void
Returns void
addEventListener
Adds event listener for event type.
▸ addEventListener(eventType: "ready"
,handler: () => void
): string
Parameters:
- eventType:
"ready"
- The event type - handler: () =>
void
- The handler for event
Returns string
▸ addEventListener(eventType: "loadModel"
| "initialModelLoad"
,handler: (model: DataModel) => void
): string
Parameters:
- eventType:
"loadModel"
|"initialModelLoad"
- handler: (model: DataModel) =>
void
Returns string
▸ addEventListener(eventType: "loadQuery"
,handler: (query: Query) => void
): string
Parameters:
- eventType:
"loadQuery"
- handler: (query: Query) =>
void
Returns string
▸ addEventListener(eventType: "processStart"
| "processEnd"
,handler: (message: StatusMessage) => void
): string
Parameters:
- eventType:
"processStart"
|"processEnd"
- handler: (message: StatusMessage) =>
void
Returns string
▸ addEventListener(eventType: "error"
,handler: (error: StatusMessage) => void
): string
Parameters:
- eventType:
"error"
- handler: (error: StatusMessage) =>
void
Returns string
addLocale
Adds the translations of the EasyQuery messages for some locale
▸ addLocale(locale: string
,localeTexts: any
): void
Parameters:
- locale:
string
- the ISO code of the locale (likeen
oruk
) - localeTexts:
any
- The translations of EasyQuery texts and messages. We expected an object with the struture of TextResources class 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:
- widget: Widget -
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
endProcess
Notifies all context components about the finishing of some long process
▸ endProcess(message: StatusMessage,groups?: WidgetGroup): void
Parameters:
- message: StatusMessage
- groups: WidgetGroup, Optional -
Returns void
executeQuery
Executes the current query and processes the result.
▸ executeQuery(options?: any
): void
Parameters:
- options:
any
, Optional - The content of theoptions
parameter depends onQueryExecutor
implementation. Usually it containspage
property which defines the page of the executed result (e.g. 2),success
anderror
callbacks
Returns void
Example:
context.executeQuery({
page: 2
})
exportResult
Executes the current query and exports the result to the specified format.
▸ exportResult(options?: any
): void
Parameters:
- options:
any
, Optional - The content of theoptions
parameter depends onEqExporter
implementation. Usually it containsformat
property which defines the format of the exported data (e.g.csv
),success
anderror
callbacks
Returns void
Example:
context.exportResult({
format: csv
});
fireEvent
Fires event.
▸ fireEvent(eventType: "ready"
): any
Parameters:
- eventType:
"ready"
- The event type.
Returns any
▸ fireEvent(eventType: "loadModel"
| "initialModelLoad"
,data: DataModel): any
Parameters:
- eventType:
"loadModel"
|"initialModelLoad"
- data: DataModel
Returns any
▸ fireEvent(eventType: "loadQuery"
,data: Query): any
Parameters:
- eventType:
"loadQuery"
- data: Query
Returns any
▸ fireEvent(eventType: "processStart"
| "processEnd"
,data: StatusMessage): any
Parameters:
- eventType:
"processStart"
|"processEnd"
- data: StatusMessage
Returns any
▸ fireEvent(eventType: "error"
,data: Error
): any
Parameters:
- eventType:
"error"
- data:
Error
Returns any
getBaseEndpoint
▸ getBaseEndpoint(): string
Returns string
getBroker
Gets the current broker component. REMOVE!!!!!
▸ getBroker(): this
Returns this
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
getServices
▸ getServices(): EqServiceProvider
Returns EqServiceProvider
init
Initializes the context
▸ init(options?: EqContextOptions): void
Parameters:
- options: EqContextOptions, Optional -
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?: any
): Promise
<DataModel>
Parameters:
- options:
any
, Optional - A map of options to pass toloadModel
function (can be ommited)
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:
- modelPlainData: ModelPlainData
Returns void
loadQuery
Loads the query
▸ loadQuery(options?: any
): void
Parameters:
- options:
any
, Optional - The content of theoptions
parameter depends onQueryStorage
implementation. Usually it containssuccess
,error
callbacks andid
option of query to load.
Returns void
Example:
context.loadQuery({
id: "query-id"
});
loadQueryList
Loads the list of queries available for the current user.
▸ loadQueryList(options?: any
): void
Parameters:
- options:
any
, Optional - The content of theoptions
parameter depends onQueryStorage
implementation. Usually it containssuccess
,error
callbacks
Returns void
loadValueList
Sends a loadValueList
requesthe server and processes the response.
▸ loadValueList(options?: any
): void
Parameters:
- options:
any
, Optional - A map of options to pass toloadValueList
function.
Returns void
newQuery
Creates a new query and returns its content back to the client-side.
▸ newQuery(options?: any
): void
Parameters:
- options:
any
, Optional - The content of theoptions
parameter depends onQueryStorage
implementation. Usually it containssuccess
,error
callbacks andsilent
option
Returns void
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
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?: any
): void
Parameters:
- options:
any
, Optional - The content of theoptions
parameter depends onQueryStorage
implementation. Usually it containssuccess
anderror
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?: any
): void
Parameters:
- options:
any
, Optional - The content of theoptions
parameter depends onQueryStorage
implementation. Usually it containssuccess
anderror
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:
- cache: ExternalListCache -
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: StatusMessage,groups?: WidgetGroup): void
Parameters:
- message: StatusMessage
- groups: WidgetGroup, Optional -
Returns void
syncQuery
Syncronizes the current query.
▸ syncQuery(options?: any
): void
Parameters:
- options:
any
, Optional - The content of theoptions
parameter depends onQuerySyncronizer
implementation. Usually it containssuccess
anderror
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(msg: StatusMessage): void
Parameters:
- msg: StatusMessage
Returns void