Scripting: Embed Custom Pages to Vehicle Tracker

You can now use scripting to open new windows displaying custom pages based on URLs specified in a script.


Installation
  1. Login to SiteAdmin.
  2. Go to Plugins tab.
  3. Set the Repository URL to http://beta.gpsgate.com
  4. Under My Plugins tab, make sure that Updates.v5 is installed and up to date.
Creating custom windows from Scripts

Custom windows can be created from UserRightClickMenu scripts. More information on enabling and creating this type of scripts can be found here.

This should be the content of the script:

 
Here is what each argument in the above call means:

  • KEY - a unique key used to denote a specific script-generated window/panel. If a window with the specified key is already open, it will be updated instead of creating a new window.
  • LABEL - displayed label for the window/panel.
  • URL - a custom URL that will be loaded inside this window/panel as an iframe.
Example: window displaying vehicle camera

If you have vehicles with cameras that can be viewed from a web page, you can integrate this view into the Vehicle Tracker application.

Set up a user custom field with the label VehicleCameraURL.

Now edit a user corresponding to a vehicle with a camera to contain the URL of its camera feed in this field:

edit custom field value

Next go to Developer > App Builder and create a new App. In this app, add a new Click Script. Select UserRightClickMenu as its kind. Call it ShowCamera.

script settings

Now edit the script to the content below:

Select the user that has the VehicleCameraURL value set when testing the script from the editor. Clicking Run Script will already open the URL in a new window, but you may close this window for now and save the script.

If you have a role with _UseClickScript privilege and Auto-allow new items enabled, the added script should immediately be available as a ShowCamera option in the right click menu of the vehicle list.

menu

Clicking the option will open a window and load the URL specified in VehicleCameraURL of the selected user. If you now click on another user with a different VehicleCameraURL specified, it will reload the content of the same window (as denoted by “ShowCameraWindow” key in the script).
If you right click on this window’s title bar, you can convert it to a panel and handle it like any other panel in the Vehicle Tracker application. The final result can look like this:

nested panel

Saving the workspace through Workspace > Save will save the position of windows/panels created this way. On next reload, URL that was displayed last before saving the workspace will be immediately loaded.


  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