-
-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Added configuration variables to DeviceGroup #738 #779
Conversation
This part of the JS is affecting updating the "Configuration Variables" when the device group is changed in the admin.
Consider the following scenario:
Expected Result You would expect the configuration variables to reflect Actual Result The configuration variables stay Why does this bug occur? The aforementioned JS, only updates the configuration variables if the key is not defined in the So, when the configuration variables already has I guess, this was done to prevent overriding of configuration variables that were overridden by the user. This bugs also appear when two templates have same configuration variable defined. The configuration variable field of the device does not update when we select the second template. |
Makes sense. What about adding a new section called just "Group variables"? So the new precedence order would be:
For this please open a new issue and add a reference to this discussion. Preview configCan you make sure the preview takes into account the group too? |
@nemesifier having a new "Group variable" section would not solve the problem I shared in my previous comment. I think, we would eventually have to address #781. Having a separate section would only benefit UI aspects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation recommendations:
- add a reference to group variables in the explanation of configuration variables
- explain the precedence of the different type of variables (look at the code first) - I think this should go in the configuration variables section, we said we can have a list in the beginning of "How to use configuration variables" and link each section, then reorder the sections to make sure they follow the same order
- in the group section, please explain the differences between context and meta data (when to use one and when to use the other one), explain that both end up being available as variables, make sure to mention that both are available via REST API
README.rst
Outdated
@@ -934,6 +937,7 @@ for the devices of an organization: | |||
information across all groups using `"OPENWISP_CONTROLLER_DEVICE_GROUP_SCHEMA" <#openwisp-controller-device-group-schema>`_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this can become one shorter point which refers to a new section below
61e0a5a
to
279717d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this on a device which already had a group assigned:
- I defined a variable in a template and set a default value for it
- I selected this template in the device just mentioned
I expected the configuration variables section of the device to show this.
However, this is not happening.
It works properly if the group is not assigned yet and I assign it.
Or if the group is already assigned and I unassign it and reassign it.
@nemesifier When a device already has a group assigned, then the group's configuration variable is added to the "System Defined Variables" in the configuration section. Since the "System Defined Variables" have higher priority than "Default Values/Configuration Variables", therefore those variables are not added to the UI. |
279717d
to
37fcfe0
Compare
README.rst
Outdated
|
||
1. `User defined device variables <#user-defined-device-variables>`_ | ||
2. `Predefined device variables <#predefined-device-variables>`_ | ||
3. `Global variables <#global-variables>`_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure global variables would override group variables? I think it should be the opposite, group variables should override any global variable.
openwisp_controller/config/admin.py
Outdated
'meta_data', | ||
'created', | ||
'modified', | ||
] | ||
search_fields = ['name', 'description', 'meta_data'] | ||
search_fields = ['name', 'description', 'meta_data', 'context'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure of this? We don't have context
as search fields in the other models.
Looking through too many textfields could make the search slow if there's many rows in the DB.
For consistency I would remove it.
cb3fd36
to
c172123
Compare
c172123
to
6c67145
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! 👍
Closes #738