diff options
author | Simo Sorce <simo@redhat.com> | 2014-10-23 11:45:32 -0400 |
---|---|---|
committer | Patrick Uiterwijk <puiterwijk@redhat.com> | 2014-11-12 23:47:15 +0100 |
commit | 83da2bf3963db3e4427bced3b4c0681e751e54da (patch) | |
tree | 53f03ce8e60d2c68453cdb5fe6be9aad7ce2c362 /templates | |
parent | 0c14f7600de70baf5b3ee609288207dcdb65e1ae (diff) | |
download | ipsilon-83da2bf3963db3e4427bced3b4c0681e751e54da.tar.gz ipsilon-83da2bf3963db3e4427bced3b4c0681e751e54da.tar.xz ipsilon-83da2bf3963db3e4427bced3b4c0681e751e54da.zip |
Refactor plugin configuration
Fork a PluginConfig class out of PluginObject, the base object now supports
a simple dictionary config, while using PluginConfig provide access to
structured util.config based configuration.
Change UI code that deal with plugins configuration to properly use the new
structured config objects in order to represent data in appropriate format
based on the data type.
Use the new util.config objects to represent plugins configuration.
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Diffstat (limited to 'templates')
-rw-r--r-- | templates/admin/plugin_config.html | 61 | ||||
-rw-r--r-- | templates/admin/plugins.html | 4 | ||||
-rw-r--r-- | templates/admin/providers.html | 4 |
3 files changed, 55 insertions, 14 deletions
diff --git a/templates/admin/plugin_config.html b/templates/admin/plugin_config.html index 1372f55..7071c7e 100644 --- a/templates/admin/plugin_config.html +++ b/templates/admin/plugin_config.html @@ -19,18 +19,59 @@ <div id="options"> <form class="form-horizontal" role="form" id="{{ name }}" action="{{ action }}" method="post" enctype="application/x-www-form-urlencoded"> - - {% for o in options_order %} + {% for k, v in config.iteritems() %} <div class="form-group"> - <label class="col-sm-2" for="{{ o }}">{{ o }}:</label> + <label class="col-sm-2" for="{{ v.name }}">{{ v.name }}:</label> <div class="col-sm-10"> - {% set val = plugin.get_config_value(o) %} - {% if val is string %} - <input type="text" class="form-control" name="{{ o }}" value="{{ val }}"> - {% else %} - <input type="text" class="form-control" name="{{ o }}" value="{{ val|join(', ') }}"> - {% endif %} - <span class="help-block">{{ plugin.get_config_desc(o) }}</span> + {%- set value = v.get_value() -%} + {% if v.__class__.__name__ in ['String', 'Template'] -%} + <input type="text" class="form-control" name="{{ v.name }}" + {%- if value %} + value="{{ value }}" + {%- endif -%} + > + {% elif v.__class__.__name__ == 'List' -%} + <textarea class="form-control" name="{{ v.name }}"> + {%- if value %} + {{- value|join('\n') -}} + {%- endif -%} + </textarea> + {% elif v.__class__.__name__ == 'Choice' -%} + {% set entries = v.get_allowed() -%} + <div class="row"> + {% for e in entries -%} + <div class="col-md-4"> + <input type="checkbox" name="{{ v.name }}_{{ e }}" + {%- if value and e in value %} + checked="true" + {%- endif -%} + > {{ e }} + </div> + {% endfor %} + </div> + {% elif v.__class__.__name__ == 'Pick' -%} + {% set entries = v.get_allowed() -%} + <div class="row"> + {% for e in entries -%} + <div class="col-md-4"> + <input type="radio" name="{{ v.name }}" value="{{ e }}" + {%- if e == value %} + checked="true" + {%- endif -%} + > {{ e }} + </div> + {% endfor %} + </div> + {% elif v.__class__.__name__ == 'Condition' -%} + <input type="checkbox" name="{{ v.name }}" + {%- if value %} + checked="true" + {% endif -%} + > + {% else -%} + {{ v.__class__.__name__ }} + {% endif -%} + <span class="help-block">{{ v.description }}</span> </div> </div> <hr> diff --git a/templates/admin/plugins.html b/templates/admin/plugins.html index 7bbe544..7ef50a0 100644 --- a/templates/admin/plugins.html +++ b/templates/admin/plugins.html @@ -28,7 +28,7 @@ <a class="text-info" href="{{ baseurl }}/disable/{{ p }}">Disable</a> </div> <div class="col-md-6 col-sm-6 col-xs-12"> - {%- if available[p].get_config_desc() %} + {%- if available[p].get_config_obj() %} <a class="text-primary" href="{{ baseurl }}/{{ p }}">Configure</a> {% endif %} </div> @@ -88,7 +88,7 @@ <a class="text-info" href="{{ baseurl }}/enable/{{ p }}">Enable</a> </div> <div class="col-md-6 col-sm-6 col-xs-12"> - {%- if available[p].get_config_desc() %} + {%- if available[p].get_config_obj() %} <span class="text-muted">Configure</span> {% endif %} </div> diff --git a/templates/admin/providers.html b/templates/admin/providers.html index c0147d8..333b10d 100644 --- a/templates/admin/providers.html +++ b/templates/admin/providers.html @@ -28,7 +28,7 @@ <p class="text-info"><a href="{{ baseurl }}/disable/{{ p }}">Disable</a></p> </div> <div class="col-md-4 col-sm-4 col-xs-12"> - {%- if available[p].get_config_desc() %} + {%- if available[p].get_config_obj() %} <p class="text-primary"><a href="{{ baseurl }}/{{ p }}">Configure</a></p> {% endif %} </div> @@ -54,7 +54,7 @@ <p class="text-info"><a href="{{ baseurl }}/enable/{{ p }}">Enable</a></p> </div> <div class="col-md-4 col-sm-4 col-xs-12"> - {%- if available[p].get_config_desc() %} + {%- if available[p].get_config_obj() %} <p class="text-muted">Configure</p> {% endif %} </div> |