====== System configuration ======
There are three files involved in the system configuration for Track and Trace 2:
* The main backend configuration in [[#the_main_backend_configuration|/config/tntconfig.js]]
* The web client configuration in [[#the_web_client_configuration|/client/index.html]]
* The scanner app configuration in [[#the_scanner_app_configuration|/apps/scanner/config/config.js]]
The following chapter describes theese configuration files in detail.
===== The main backend configuration =====
The directory /config contains several configuration files named [site]_tntconfig.js, one for each site. To determine which one to use a symlink is created that is called tntconfig.js pointing at the chosen site configuration file.
The configuration file exports one single JSON object which is the configuration for all the server backend modules.
=== Configuration elements ===
== app ==
Configuration for the behaviour of the app synchronization.
app: {
syncallitems:false
}
* syncallitems (boolean) : If set to true all items in the current store will always be synchronized to the scanner, default **false**
== client ==
Configuration for the behaviour of the client backend.
client: {
modules: {
accounts: true,
reports:true
}
}
* modules (object) : A JSON object on the format [module_id]:[active] defining which optional modules are available in the web client. Currently the following modules are implemented [accounts, reports]
== db ==
Database configuration.
db: {
connectionstring: "mongodb://localhost:27017/tnt_test",
user: "admin",
pass: "admin"
}
* connectionstring (string) : The connectionstring telling the system which database to connect to
* user (string) : The username to connect to the database as
* pass (string) : The password for the given user
== errorhandling ==
Error management configuration.
errorhandling: {
logconsole: true,
logfile: "/tmp/tntErrorLog.log",
logcollection: "errors",
email: {
default: ["user1@domain.sample", "user2@domain.sample"]
}
}
* logconsole (boolean) : Log the error message to the console using //console.log//
* logfile (string) : Which file to output the log messages to
* logcollection (string) : Collection in the database to store the log messages in
* email (Object) :
* default (array) : Array of email addresses to notify on system errors (not yet implemented)
== integration ==
Integration module configuration for outgoing integrations.
integration: {
active: true,
modules: [
{
active: true,
name: "Testintegration module",
qprefix: "int.test.",
src: "test/test.js",
config: {}
}
],
schedule: "10 */2 * * * *"
}
* active (boolean) : Whether the integration module is active or not, if false no integrations will be run. **Observe** all transactions will still be created in the MQdata collection and when the integration module is activated all historic transactions will be integrated to the destination system. To prevent this make sure to remove all integration documents from the MQdata collection (q:/^int./)
* modules (array) : Array containing the configuration for each available integration module, for more detail see [[tnt2:techdoc:configuration:integration_modules|Integration Modules]]
* active (boolean) : Whether this integration module is active or not. If set to false the integration will not be triggered even if the main integration configuration is active.
* name (string) : The description of the integration component
* qprefix (string) : Prefix prepended to all the MQdata queue names for messages to and used in this integration component
* src (string) : The relative path to the /integration/modules path for the main .js file handing this component
* config (object): Optional configuration object to use with the integration module
* schedule (string) : The CRON-scehdule for the integration scheduling, for syntax see the node-cron documentation
== import ==
Configuration for data import modules readin data from source systems into TnT2.
import: {
mappings: [
{system: "SIB"}
],
storerooms: [
{system: "SIB"}
],
users: [
{system: "SIB"}
]
}
* mappings (array): List of import modules to read producerproductcode/type mappings from
* system (string): Name of the source system to read from
* storerooms (array): List of import modules to read storerooms from
* system (string): Name of the source system to read from
* users (array): List of import modules to read users from
* system (string): Name of the source system to read from
== logger ==
Logger configuration
logger: {
active:{
console: true,
file: true,
mqtt: false
},
path: "/opt/node/TrackAndTrace2/logs/",
topic: "test/log"
}
* active (Object): List of the active logger components
* console (boolean): Log to console using console.log and console.error
* file (boolean): Log to file
* mqtt (boolean): Log to an MQTT topic
* path (String): Absolute path where to store logfiles
* topic (String): The MQTT topic to post logs to
== mqtt ==
MQTT configuration, this part is currently not implemented
mqtt: {
enabled: false,
host: "mqtt://192.168.126.129",
prefix: "DEV/TNT2/"
}
* enabled (boolean): Whether the MQTT transport is active or not
* host (String): The MQTT host address
* prefix (String): Prefix to prepend to all MQTT topics used in the TnT2 system
== packs ==
Configuration of the creation of packs on manifest building.
packs: {
skipTypes: ["04", "05", "06", "07", "08", "09"]
}
* skipTypes (array): A list of packtypes in the manifest to not create packs for.
== permissions ==
Permission configuration telling the system what permissions the different user roles will have.
permissions: {
default: 1,
0: {client_lvl:0,description: "-",modules: {}},
1: {client_lvl: 0,description: "Shotfirer",modules: {doreturn:true, move:true, menu:{lang:false, store:false}}},
2: {client_lvl: 3,description: "Explosives responsible",modules: {doreturn: true,move: true,receipt: true,inventory: true,pack_add: true,pack_handover: true,pack_remove: true, menu:{lang:false, store:false}}},
3: {client_lvl: 0,description: "Storage personel",modules: {move: true,receipt: true,inventory: true, menu:{lang:false, store:false}}},
4: {client_lvl: 0,description: "Contractor",modules: {doreturn: true, menu:{lang:false, store:false}}},
9: {client_lvl: 9,description: "Admin",modules: {doreturn: true,move: true,receipt: true,inventory: false,pack_add: true,pack_issue:true,pack_handover: true,stockcheck:true,pack_remove: true, menu:{lang:true, store:true}}}
}
* default (int): The default permission to assign to all users on creation or import
* [0-] (Object): Configuration for each permission level
* client_lvl (int): The permission level for the web client
* 0: Not allowed to log in
* 1: Basic permission, can log in and read but not see transactions or users. Read only access. No reports.
* 3: Advanced permission, can log in and see everything but user management. Read/Write access.
* 9: Admin permission, full access to the client
* description (String): Description to show in the user management section of the web client
* modules (Object): Configuration telling the app which modules/buttons to show
* doreturn (boolean): Show the Return button
* move (boolean): Show the Store Transfer button
* receipt (boolean): Show the Shipment Receipt button
* inventory (boolean): Show the inventory button
* pack_add (boolean): Show the Create Package button
* pack_issue (boolean): Show the Issue Package button
* pack_handover (boolean): Show the Handover button
* pack_remove (boolean): Show the Remove Package button
* stockcheck (boolean): Show the Stock Check button
* menu (Object): Configuration of what to show in the app menu
* lang (boolean): Show the option to change the scanner language
* store (boolean): Show the option to change the scanner storeroom
== recipientsites ==
Configuration of which sites to show when sending an exported manifest to another TnT2 system.
recipientsites: [
{
name: "Test Recipient",
Receiver: {
Name:"Test Recipient Name",
Name2: "Test Recipient Name2",
City:"Test Recipient City"
},
cfg:{
type:"ftp",
host:"ftp.mysite.com",
port:21,
user:"ftpuser",
pass:"ftppass",
path:"/sendTest"
}
},
]
* name (String): Name of the recipient to show in the web client
* Receiver (Object): Data to insert into the XML manifest as the Receiver. This is used on the recipient side to match the XML manifest for import
* cfg (Object): Transfer configuration
* type (String): Which protocol to use to transfer the manifest
* For FTP see the code above for example
== reports ==
Configuration of which report modules to show in the web client. The reports is an array of Objects describing each report module.
reports: [
{
id:"tarHrsInStore",
description:"Hours in storage",
icon:"tar/hrsinstore/gfx/icon.png",
server:"tar/hrsinstore/report.js",
client:"tar/hrsinstore/report.js"
},
{
id:"usageStats",
description: "Usage report",
icon:"_/usage/gfx/icon.png",
server:"_/usage/report.js",
client:"_/usage/report.js"
}
]
* id (String): Unique ID for this report
* description (String): Description of the report
* icon (String): Relative path or url for the report icon to show in the web client
* server (String): Relative path to the .js file that will handle the backend data collection service
* client (String): Relative path to the client .js file that will display the report in the webn client
The full list of implemented reports at the moment:
{id:"tarHrsInStore", description:"Hours in storage", icon:"tar/hrsinstore/gfx/icon.png", server:"tar/hrsinstore/report.js", client:"tar/hrsinstore/report.js" },
{id:"usageStats", description: "Usage report", icon:"_/usage/gfx/icon.png", server:"_/usage/report.js", client:"_/usage/report.js"},
{id:"itemnumUsage", description:"Usage per ITEMNUM", icon:"_/itemnumusage/gfx/icon.png", server:"_/itemnumusage/reportsrv.js", client:"_/itemnumusage/report.js"},
{id:"siteStockCount", description:"Stock on site", icon:"_/sitestockcount/gfx/icon.png", server:"_/sitestockcount/reportsrv.js", client:"_/sitestockcount/report.js"},
{id:"stockCountMX", description: "Stock counts Maximo / TnT2", icon:"_/stockcountmx/gfx/icon.png", server:"_/stockcountmx/report.js", client:"_/stockcountmx/report.js"},
{id:"transactionReport", description:"Transactions", icon:"tar/transactionreport/gfx/icon.png", server:"tar/transactionreport/reportsrv.js", client:"tar/transactionreport/report.js"}
== rest ==
Configuration for the REST service providing data to the user components of the system.
rest: {
port: 4912,
modules: [
{desc: "GUI Frontend", file:"gui/gui.js", active: true},
{desc: "Scanner service", file:"scanner/scanner.js", active:true}
]
}
* port (int): The port number on which to listen for this service
* modules (array): List of rest service modules
* desc (String): Description of the module
* file (String): Relative path to the base .js file of the rest service module
* active (boolean): Whether this module is active or not
== SITE ==
Specifying which site this installation is for.
SITE: "TEST"
== STDSTORE ==
The standard storeroom to import and receive shipments to if none is specified in the purchase order
STDSTORE: "MyStore"
== worker ==
The configuration for the worker service doing grunt work in the background.
worker: {
modules: {
detonate: "detonate",
detonatebulk: "detonatebulk",
handover: "package",
inventory: "inventory",
manifest: "manifest",
move: "mover",
movebulk: "movebulk",
pack_add: "package",
pack_issue: "package",
pack_remove: "package",
return: "return",
returnbulk: "returnbulk",
use: "use",
usebulk: "usebulk"
},
services: {
packcheck: {
description: "Check for empty packages",
module: "packcheck",
schedule: "0,30 * * * *"
},
reruntransactions: {
description: "Rerun failed transactions",
maxcount: 48,
module: "reruntransactions",
schedule: "15 * * * *"
}
}
}
* modules (Object): A map of functions to modules on the form function:"module"
* services (Object): The service definitions for background repetitive tasks
* [servicename] (Object): Configuratioin for each active service. Here is a list of the common mandatory configuration elements, more elements can be supplied and are then passed on to the service script
* description (String): Description of the service
* module (String): Which worker module to run the handleService method in for this service
* schedule (String): Cron schedule when to execute this service
===== The web client configuration =====
The configuration for the web client is in the /client/index.html file and is simply a matter of setting the correct RESTURL identifying the backend REST Service to the global variable in the script.
var RESTURLs = {
DEV: "http://192.168.99.2:4912/",
TEST: "http://192.168.126.130:4912/"
};
RESTURL = RESTURLs.TEST;
There are a couple of preconfigured URLs to choose from and for future maintainability new sites will be added to the RESTURLs object.
===== The scanner app configuration =====
The configurations for the scanner app is in the script file /apps/scanner/config/config.js which defines a config_presets global variable to the scanner app. Theese presets are presented to the user of the scanner at the first startup and the user will choose which configuration preset the scanner will use in the future.
var config_presets = {
test: {
RESTURI: "http://192.168.126.130:4912/scn/",
site: "TestSite",
defaultStore: "TestStore",
doOnlineSync: true,
logoutAfter: 45*60*1000,
receiptRequireManifest: true,
syncInterval: 30*60*1000
}
}
* [preset_name] (Object): One object for each configuration preset
* RESTURI (String): The URI of the REST Service that this scanner configuration will use
* site (String): The site for this scanner
* defaultStore (String): The default store to use on first startup before store has been chosen
* doOnlineSync (boolean): Whether to try to connect to the REST service to fetch items/packs that are scanned but not synchronized to the server. Doing this in bad WiFi situations will make the scanner slower.
* logoutAfter (int): Number of milliseconds of inactivity that will trigger automatic logout
* recieptRequireManifest (boolean): Whether to syncrhonize all manifests in state Validated to the scanner to show on Shipment Receipt
* syncInterval (int): Maximum number of milliseconds to wait before forcing scanner synchronization in the background