Apps

With Apps you can build and manage your own scripted extensions for the VehicleTracker application.


Installation
  1. Login to SiteAdmin.
  2. Go to Plugins tab.
  3. Set the Repository URL to http://update.gpsgate.com
  4. Under My Plugins tab, make sure that Patch.v4 is installed and up to date.
Enabling Apps

To be able to create Apps, you need to enable _EditScriptApp privilege. If you previously enabled Click Scripts or Web Service Scripts and had privileges for editing them enabled, you will have the _EditScriptApp privilege enabled automatically after the upgrade. Otherwise, follow these steps:

  1. Login to SiteAdmin.
  2. Go to Applications tab. Click Search and Manage.
  3. Click on the application for which you want to enable Apps.
  4. In Privileges and Roles section, under ScriptApp, check _EditScriptApp, _EditClickScript and _EditWebServiceScript privileges and click Save.
  5. Login to Vehicle Tracker Application. From the main menu, go to Admin>Roles.
  6. In Roles window, click on the role for which you want to enable Apps.
  7. Under Privileges, enable Apps in the same way you did for the application.

After this, a new App Builder menu option will be available in the Admin menu of the VehicleTracker application. Clicking it will take you to a list of existing Apps. If you previously used Click Scripts or Web Service Scripts, you will notice that the old “Click Script” and “Web Service Script” menu options are gone. Instead, an App has been created for each of the existing scripts. Otherwise, this list will be empty.

Apps after upgrade

Click on Add new App to create a new App. Click on an entry in the list to edit an existing App.

app step1

Specify a name for the App and assign some roles to it. These roles determine which actions are permitted to the Click Scripts in this App.

Click Save to save the App and move on to adding scripts to it. Apps for old Click / Web Service Scripts will have one script in the corresponding list. These scripts will run as before. Creating a new App with a single script allows you to work with Click / Web Service Scripts as before. Apps make these scripts easier to manage by enabling you to group the scripts by functionality. If several scripts are needed to achieve a specific goal, they can be created in the same App. Scripts in the same App may also interact. You can see how in the following example.

Example

In this example, we want to send a particular command to a particular group of users once per day.

Let us assume that the command is named “HelloCommand” and the relevant users are in a Tag called “Relevant Users”.

First we will create an App called “ExampleApp” and assign it _Administrator role.

Now add a Click Script named SendCommandOnTimer. Choose Timer kind, and specify the time of the first run. If hours/minutes/seconds fields are left at 0, this script will run once per day at the specified time.

send cmd timer

Edit the script to:

  Now save the script and we’re done - at 5 PM, the script will send a command to all connected devices.
Advanced
The command from the above example could also be sent manually by an operator. What if we wanted to skip the vehicles that already received the command sent by the operator when we send it from the script? In the App from the above example, create another Timer Click Script called “Reset”, set to run at an early time of day, e.g. 3:00 AM, that only does this:   Now change the “SendCommandOnTimer” script to this:   Now create a Command Tag called “HelloCommandTag” and add the “HelloCommand” to it. After this, create a new Command Click Script named “HelloCommandSuccess” in the ExampleApp and link it to HelloCommandTag. It should contain this script:   ExampleApp will now ensure that HelloCommand is sent from the script only to devices that have not received it yet.
Export
Apps will be included in the VehicleTracker application template when exporting/synchronizing the application.
You can export Apps separately, too, by using the Export context menu option of the App.
Import them via “Import Template” option in VehicleTracker. An App will be exported together with all the objects required by the script definitions. For example, if you create a Notifier Click Script, the Event Rule that it is connected to will be exported as well. Any objects that are not automatically included, yet are needed for the scripts in the App to function correctly (such as ‘RelevantUsers’ tag accessed from a script in the example above) can be manually added to the App in the References section.
app refs
Enable Logging at Runtime
The easiest way to see logs from your scrips is to use the App Console. Everything logged with the log() method will be displayed there.

You may also log to a file with the log function and logging of errors from Click Scripts at runtime by editing the NLog.config file in the IIS folder under the GpsGate Server installation folder (if you are not hosting your own server, you may contact support for access to files). Under <targets>, you should add a new target entry like this: where TARGET_NAME is an unique name for the file target and FILE_NAME is the name of the log file you wish to be created with full path to the file. Under <rules>, add an entry like this: where NAME_OF_CLICK_SCRIPT is the name of the click script which you want logged to the file, and TARGET_NAME is the unique name of the target you added above. Errors and data logged through log method in that Click Script will then be written to the specified file.

  Discuss this blog post on the forum please



Download free GpsGate Server

Install it on your own server. The installation is free for 5 users.

Download Now