OPNsense Forum

English Forums => Development and Code Review => Topic started by: 8191 on December 15, 2015, 09:20:15 am

Title: Status display of MVC apps
Post by: 8191 on December 15, 2015, 09:20:15 am

I'd like to show some status information of an MVC app within the GUI (e.g. interface IP, sent/received bytes, etc.). I am planning to accomplish that through a script, which gets called by configd and returns the status info (as a JSON string). The configd action is being triggered by the service controller and the view requests the status info through the service controller, and then populates the corresponding layout.
Does that sound reasonable, or is there a better way to display status information of a service?

A down-side of this construct is, that the script delivering the status information does not have any well-defined (e.g. XML defined) model. The information passed between the script and the view are "loose" JSON objects. Is there any intended concept in defining models for external (Python) scripts?

Title: Re: Status display of MVC apps
Post by: AdSchellevis on December 15, 2015, 08:45:01 pm
Hi Manuel,

There's no predefined model for the backend scripts, when scripts depend on configuration data they should be supplied with their data through the template system of configd (the same as third part applications).
The definition of configuration data should only live at the middleware part (phalcon) of the system where it can be validated, the components linked via configd can be scripts/applications from us or any other party which we don't have control over.

Eventually we might look at some templates for shared actions, but no concrete ideas yet. (the configd actions are loosely coupled, which is an advantage in terms of testability and deployment).
Documenting the api is also something we should look at some point, but to be honest, the api controller part is more important here because that's what the end users are interacting with (in some cases the script output and api output might be the same).

The workflow we use now looks like this:
- configd actions, delivers human readable and json data (first one is not required, but practical from the console)
- the api controller fetches the data (if necessary extends it with config data) to be used by ui or api consumer.
- the UI uses jquery to fetch the remote data and handles presentation.

So I guess your idea sounded reasonable to start with :)


Title: Re: Status display of MVC apps
Post by: 8191 on December 16, 2015, 06:05:51 pm
Thanks for your input, Ad!