Updating config.json for Application - with Javascript

3595
9
Jump to solution
04-25-2017 08:21 AM
ToddUlery
Occasional Contributor

Is there anybody out there with tips or samples for updating WAB config.json file?

More specifically adding a widget through Javascript.

I am trying to read in the json, find where i need to add, and update the json file.

I know how to just open and manually adding the widget.

Robert Scheitlin, GISP‌ ---hoping you have some tips. 

DevelopersWeb AppBuilder Custom Widgets

0 Kudos
1 Solution
9 Replies
ToddUlery
Occasional Contributor

Thanks Rebecca, I will give these a look over.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Todd,

   I am a little confused by your goal here. Why are you wanting to update the main config.json manually. Why not use the WAB UI for that?

0 Kudos
ToddUlery
Occasional Contributor

I have some grunt tasks that run to create the widgets, and what is missing is adding it into the application. I was hoping to just add another task that reads the json, prompts the Developer for position of the widget, and updates and saves out the file.

I have been tasked to work out a dev workflow. We would like to keep the builder out of the flow as much as possible.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Todd,

   I have never attempted anything like that but the main config.json is just a basic json/text file so if you grunt task and read and write and parse the json then you should have no problem.

0 Kudos
ToddUlery
Occasional Contributor

Yeah that was the thought, but then i started getting in the weeds, and then they started to grow higher. Just not a JSON master. But i am sure i am just over thinking it.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Todd,

   You probably are. Json is pretty simple text and the widgets are just part of a arrays like

"widgetsOnScreen" : {

  "widgets": [

    {

      "position" : {

        "left" : 105,

        "top" : 45,

        "relative" : "map"

      },

      "id" : "_6",

      "name" : "Query",

      "version" : "2.4",

      "uri" : "widgets/Query/widget",

      "config" : "configs/Query/config_Query widget.json",

      "icon" : "widgets/Query/images/icon.png"

    },

0 Kudos
ToddUlery
Occasional Contributor

Thanks, Robert Schmidley‌ and rastrauch‌ ---- It is a bit more complicated than I thought for the timeframe I have and would better serve to just wait on it.

On another objective; would you suggest a best practice when altering the WAB structure  (regarding CSS on Theme based Elements) to place these style updates in a separate CSS file and just @import or load this in separate. Or just tack them on to already existing CSS files where the original exists.  ???

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

Todd, if you haven't already done so, you may want to repost your new question in Web AppBuilder Custom Themes   or at least repost and then tag that group.

0 Kudos