Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Moving global script functions to a server file


  • Heya,

    I would like to move the global scripts I have created to an external file(s) on the server to help with deployment and source control. Is this possible? Where/how would the file reside on the server? How would the file be included when the app was loaded and how would I call the functions in the file?

    Thanks
    Ian

    PS: mango v3.5.6


  • The global scripts are stored in the global scripts database table. You could store the scripts on a file in the filestore but you would need to import the script via JSON each time you want to update it.


  • @iperry said in Moving global script functions to a server file:

    How would the file be included when the app was loaded and how would I call the functions in the file?

    Sorry to barge in here, but I'm getting mixed signals, are you wanting to use global scripts that you have in the mango system for scripts and meta points to call on or are you talking about the mangoUI?

    Fox


  • Hi Matt, Craig

    The functions I have created in the global scripts are being used by meta points and scripting data sources. I was not intending for them to be used by the mangoUI.

    My hope was that I could move the global scripts and have them reside in a file(s) on the server outside the database. Currently, if I want to version control the global scripts, I need to export them using the configuration tool, save that file and then commit to source control. Comparing versions is a challenge as the scripts are each saved as a string in a JSON object. Any comparison tools shows the entire string has changed.

    Updating (or creating) an app would then just require that I copy the file over instead of importing using the configuration tool. One less step to manage.

    I'm hoping I'm making sense :)

    Thanks
    Ian


  • @iperry,
    If all you want is version control you can leverage our Audit Trail. The UI isn't highly evolved for it yet but it does let you look at the history for most of our configuration. See my images. I created a global script called 'Example' and then edited it once to add a second line of code.

    0_1582070875828_f9e550b8-ba16-41a8-8fe4-0acb1b93aabb-image.png

    0_1582070908122_af59a417-4051-43e3-a79f-2b0c3005b622-image.png

    0_1582070920366_aafc4003-be08-4d3a-bac3-c25ab1576d66-image.png

    Note we only save the changes to the object instead of the whole thing each time. For global scripts this will likely only be the latest version of the script.

    The general design was such that we can eventually allow an admin to 'restore' something to what it was at a previous date. The Dashboard designer uses this functionality to track revisions.


  • Hi @terrypacker

    Thanks for pointing me towards the audit trial. I hadn't realized what elements were tracked here.

    However, the audit trail doesn't offer any comparison tools, version tagging, etc that source control app would, like Github. This was my intention for saving the global scripts to an external file.

    Thanks
    Ian