Utilities¶
Index¶
Back: Functionality¶
Description¶
Utilities - are additional programs for more specialized applications.
Core utilities¶
Core utilities are the most necessary utilities from installation to operating the application. They are stored in the bin
folder. Before start the utilities, you must set the environment variable NODE_PATH
if it was not set in advance (indicating the core folder).
The core contains the following utilities:
bin/acl.js
- to import and edit application security settings (resources, roles, users, access rights). Launch parameters:--u
- user--res
- resource--role
- role--p
- access right--m
- access application method--d
- directory with the security settings for import
bin/adduser.js
- to add new users to the application’s security settings. Launch parameters:--name
- user login (admin - by default)--pwd
- user password (admin - by default)
bin/bg.js
- to run low priority background procedures that require high power from the processor or run relatively long timebin/export.js
- to export the application to a local directory. Launch parameters:--dst
- path to the directory where the export result will be written (by default ../out)--ns
- application namespace--file-dir
- path to the directory to which files from file attributes will be exported--acl
- optional export of security settings--nodata
- skip export for all created objects in the application--nofiles
- skip file attribute export--ver
- version (last version - last)
bin/import.js
- to import the application metadata. Launch parameters:--src
- path to the directory from which the import will take place (by default ../in)--ns
- application namespace--ignoreIntegrityCheck
- data integrity ignored during import
bin/import-data.js
- to import the application data. Launch parameters:--src
- path to the directory from which the import will take place (by default ../in)--ns
- application namespace
bin/job-runner.js
- to run scheduled tasksbin/job.js
- to run the task component from the job-runner utilitybin/meta-update.js
- to convert application meta from one version to anotherbin/schedule.js
- for manual start of scheduled tasksbin/setup.js
- to set thedeploy
settings from the application. Launch parameters:--reset
- preliminary reset of alldeploy
settings in the application--sms
- when resetting the settings, thedeploy
settings that are marked as important are not deleted--rwa
- to override, not add to arrays indeploy
settings
Application utilities¶
Application utilities implement specific application functionality during the operation phase, which has not yet been implemented in the kernel in a unified form for various applications. Usually, these utilities are stored in the lib
directory and connect to the app via deploy
.
Examples of implemented utilities for the sakh-pm
application:
lib/actions/createIndicatorValueHandler.js
- utility that creates values in the collection for the selected periodlib/actions/createProjectReportsHandler.js
- the utility that automatically creates printed forms for the project saving files in the cloudlib/actions/assignmentToEventOnly.js
- utility that forms a checkpoint from an instruction
App utility creation using an example of createIndicatorValueHandler¶
Implementation¶
For implementation, the JavaScript language is used with the available functionality of the modules included in the application. :raw-html-m2r:`<br>`When implementing utilities in an application with relatively large functionality, the files themselves can be split into several dependent files.
In this example in the utility main file lib/actions/createPlanIndicatorsHandler.js
the export command should be the last line:
module.exports = CreatePlanIndicatorsHandler;
Connection to the application¶
Set the connection parameters in the deploy
to start the utility when using the application.
For example, you first need to add in the meta view an interface element for the utility that will launch the utility. Add the CREATE_INDICATOR_VALUE
button in the views/indicatorFinancial/item.json
file:
{
"id": "CREATE_INDICATOR_VALUE",
"caption": "Сформировать собираемые значения",
"visibilityCondition": null,
"enableCondition": null,
"needSelectedItem": false,
"signBefore": false,
"signAfter": false,
"isBulk": false
}
Add the settings in the deploy
file to connect the CREATE_INDICATOR_VALUE
button in the UI with the createIndicatorValueHandler
utility:
"modules": {
"registry": {
"globals": {
"di": {
"createIndicatorValueHandler": {
"module": "applications/sakh-pm/lib/actions/createIndicatorValueHandler",
"initMethod": "init",
"initLevel": 2,
"options": {
"data": "ion://securedDataRepo",
"workflows": "ion://workflows",
"log": "ion://sysLog",
"changelogFactory": "ion://changelogFactory",
"state": "onapp"
}
},
"actions": {
"options": {
"actions": [
{
"code": "CREATE_INDICATOR_VALUE",
"handler": "ion://createIndicatorValueHandler"
}
]
}
}
In this example all settings are held for the registry module, since the utility will be called out of it in the form of the indicatorFinancial
object by clicking the CREATE_INDICATOR_VALUE
button .