Utilities¶
Description¶
Utilities - additional programs for more specialized use.
Utilities of core¶
The utilities of the core are the most necessary utilities from the installation to the operation of the application and are located in the bin
folder. Before running them, specify the environment variable NODE_PATH
, if it is not set in advance (with an indication of the core folder).
The core includes 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 (latest 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 jobsbin/job.js
- to run the job 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 jobsbin/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, as a rule, JavaScript is used with the use of the available functionality of the modules included in the application.
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 should be the last line:
module.exports = CreatePlanIndicatorsHandler;
Connecting 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
}
Then 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 .