Question luci ui and uci config files

Hi there,

I have been looking through the source for a number of modules in the luci repo and read through the API docs as well. I get the impression that a single form.Map can only have a single config file that it looks at. As such, each page in the luci UI can only edit the config of a single config file. This seems very limiting, so I am wondering if I am just missing something.

If there is a good pattern for modifying multiple config files with a single page in luci, where would be a good example of that. Like, can I add two form.Maps to the same page, for example?

Thanks!

UPDATE: Look like there are examples of pages with multiples forms, but I don't really understand how they are being rendered onto the same page yet. Are there any good examples that are relatively straightforward to understand? Also, where the renderRowActions defined? I don't see that in the docs at all?

Hi, welcome to the forum.

disclaimer: I haven't done this in JS yet, but I suspect it's similar to what was done in lua in previous branches.

I think a good example could be: modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js

The way it's done is by:

  • using chain() to load more configuration
  • handling the changes to these files explicitly (see the firewall.deleteNetwork(net.getName()) )

re. renderRowActions:

modules/luci-base/htdocs/luci-static/resources/form.js seems to be where it's at for renderRowActions() unless you write your own (in the example above, you can find one at line 808 in wireless.js)

JavaScript CBI maps can cover multiple configs without problems. You can override the .uciconfig, .ucisection and .ucioption properties per option to tie the widgets to different underlying UCI values.

Another option, which is also commonly used in legacy Lua code is to override the .cfgvalue(), .write() and .remove() methods of options to read and write different underlying UCI values.

The renderRowActions() function is an internal method inherited from the TableSection class. It can be overridden to render a nonstandard set of action buttons per row. I did not yet document it officially.