Commit 2c14f78e authored by Matias Guijarro's avatar Matias Guijarro
Browse files

Merge branch 'view-config-object-in-yaml' into 'master'

Becon web: Find any config object in yaml file

See merge request !2712
parents 9978fa12 619e082b
Pipeline #30144 passed with stages
in 5 minutes and 4 seconds
......@@ -364,7 +364,7 @@ def index():
node = cfg.root
template = __get_jinja2().select_template(("index.html",))
template = __get_jinja2().get_template("index.html")
full_name = institute = node.get("institute", node.get("synchrotron"))
laboratory = node.get("laboratory", node.get("beamline"))
......@@ -442,7 +442,7 @@ def get_db_file_editor(filename):
try:
content = client.get_config_file(filename).decode()
file_info = __config.get_file_info(filename)
template = __get_jinja2().select_template(("editor.html",))
template = __get_jinja2().get_template("editor.html")
html = template.render(
dict(name=filename, ftype=file_info["type"], content=content)
)
......@@ -486,6 +486,12 @@ def get_item(cfg):
return item
def default_plugin(obj_cfg):
template = __get_jinja2().get_template("default_plugin.html")
html = template.render(dict(name=obj_cfg.get("name"), filename=obj_cfg.filename))
return html
@web_app.route("/item/<name>")
def item(name):
cfg = __config.get_config()
......@@ -531,10 +537,10 @@ def get_item_config(name):
cfg = __config.get_config()
obj_cfg = cfg.get_config(name)
plugin = _get_config_plugin(obj_cfg, "get_html")
if plugin:
if plugin and obj_cfg.get("class") != "MeasurementGroup":
obj_cfg = plugin(obj_cfg)
else:
obj_cfg = "<!-- TODO -->"
obj_cfg = default_plugin(obj_cfg)
return flask.json.dumps(dict(html=obj_cfg, name=name))
......@@ -604,7 +610,7 @@ def copy_file():
db_files = dict(client.get_config_db_files())
template = __get_jinja2().select_template(("editor.html",))
template = __get_jinja2().get_template("editor.html")
html = template.render(dict(name=dst_path, content=db_files[src_path]))
result = dict(
name=dst_path,
......
......@@ -41,11 +41,16 @@
padding: 4px;
}
.beacon-tree {
.beacon-navigation .beacon-tree {
overflow-y: auto;
height: 100%;
}
#session_form .beacon-tree {
overflow-y: auto;
height: calc(100% - 270px);
}
.beacon-tree ul.list-group {
margin-bottom: 0;
}
......
<!--
This file is part of the bliss project
Copyright (c) 2015-2020 Beamline Control Unit, ESRF
Distributed under the GNU LGPLv3. See LICENSE for more info.
-->
<div class="btn-group" role="group" aria-label="global functionality">
<a class="btn btn-default disabled-btn" href="javascript:void(0)">
{{name}}
</a>
<button type="button" class="btn btn-info"
data-name="{{name}}" data-filename="{{filename}}"
data-toggle="tooltip" title="View in yaml file">
<span class="fa fa-eye"></span>
Yaml
</button>
</div>
<h3>{{name}}</h3>
<a href="javascript:void(0)" data-name="{{name}}" data-filename="{{filename}}">
View in yaml file
</a>
......@@ -653,6 +653,10 @@
$(document).on("click", "li.list-group-item", toggle_folder_icon_state);
$(document).on("click", "[data-filename]", function () {
show_filename($(this).attr('data-filename'), $("#content-panel"), $(this).attr('data-name'))
});
$("#reload-config").on("click", function () {
var btn = $(this).button("reloading...");
request = $.ajax({
......
......@@ -73,7 +73,7 @@ function show_file(node, panel) {
show_filename(node.path, panel);
}
function show_filename(filename, panel) {
function show_filename(filename, panel, highlight_name) {
$.get("db_file_editor/" + filename, function(data) {
panel.empty();
if (data.html === undefined) {
......@@ -87,6 +87,14 @@ function show_filename(filename, panel) {
form.append(text_area);
} else {
panel.html(data.html);
if (highlight_name) {
// highlight given name in editor
var editor = ace.edit('file-editor')
var find = editor.find(new RegExp('name:\\s*' + highlight_name))
if (find)
editor.resize(true);
editor.scrollToLine(find.start.row, true)
}
}
panel.attr("style", "visibility: visible");
}, "json")
......
......@@ -12,6 +12,12 @@
<span class="fa fa-save"></span>
Save
</button>
<button id="apply" class="btn btn-info"
data-filename="{{filename}}"
data-toggle="tooltip" title="view in yaml file">
<span class="fa fa-eye"></span>
Yaml
</button>
</div>
</div>
......@@ -29,7 +35,7 @@
<!-- Text input-->
<div class="form-group">
<label class="col-md-2 control-label" for="{{ name }}">{{ name.capitalize() }}</label>
<div class="col-md-8">
<div class="col-md-4">
<input id="{{ name }}" name="{{ name }}" type="text"
class="form-control input-md"
placeholder="{{ value }}" value="{{ value }}">
......
......@@ -45,7 +45,7 @@ def __get_main(cfg):
params[k] = v
logo = cfg.root.get("logo", "res/logo.png")
html = template.render(dict(params=params, logo=logo))
html = template.render(dict(filename=cfg.root.filename, params=params, logo=logo))
return flask.json.dumps(dict(html=html))
......
......@@ -8,26 +8,31 @@
<div class="row">
<div class="btn-group btn-group" role="group" aria-label="global functionality">
<a class="btn btn-default disabled-btn" href="javascript:void(0)">
{{ config['filename'] if config['filename'] else "unknown file" }}
{{ config['name'] }}
</a>
<button id="apply" type="button" class="btn btn-primary"
data-toggle="tooltip" title="save changes">
Save
<span class="fa fa-save"></span>
</button>
<button id="revert" type="button" class="btn btn-primary"
<button id="revert" type="button" class="btn btn-info"
data-toggle="tooltip" title="revert changes">
Revert
<span class="fa fa-undo"></span>
</button>
<button type="button" class="btn btn-info"
data-name="{{config['name']}}" data-filename="{{config.filename}}"
data-toggle="tooltip" title="view in yaml file">
Yaml
<span class="fa fa-eye"></span>
</button>
</div>
</div>
</div>
<div style="height:10px;"></div>
<form id="device_form" class="form-horizontal">
<fieldset>
<div class="form-group">
<label class="col-md-4 control-label" for="device-name"
<label class="col-md-1 control-label" for="device-name"
data-toggle="tooltip" title="card name">
Name
</label>
......@@ -39,7 +44,7 @@
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="device-name"
<label class="col-md-1 control-label" for="device-name"
data-toggle="tooltip" title="type of card">
Type
</label>
......@@ -52,7 +57,7 @@
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="device-address"
<label class="col-md-1 control-label" for="device-address"
data-toggle="tooltip" title="device address">
Address
</label>
......@@ -64,7 +69,7 @@
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="device-clock"
<label class="col-md-1 control-label" for="device-clock"
data-toggle="tooltip" title="internal clock speed">
Clock
</label>
......@@ -105,7 +110,7 @@
name="ch-{{ch_id}}-counter-name"
class="form-control input-sm" type="text"
value="{{ ch['counter name'] }}"
style="border-radius: 0px;" />
/>
</td>
<td>
......@@ -139,8 +144,10 @@
{% endfor %}
</tbody>
</table>
</div>
</fieldset>
</form>
</div>
<script type="text/javascript">
......@@ -179,7 +186,7 @@
});
$("#revert").on("click", function() {
show_item("{{ config["name"] }}");
show_item("{{ config['name'] }}");
return false;
});
......
......@@ -59,7 +59,7 @@ def get_jinja2():
def get_item(cfg):
klass = cfg.get("class")
result = {"class": klass}
if klass is None:
if klass in [None, "MockupAxis", "ModuloAxis"]:
result["icon"] = "fa fa-gear"
result["type"] = "axis"
else:
......@@ -85,7 +85,7 @@ def get_tree(cfg, perspective):
def get_html(cfg):
ctrl_class = cfg.get("class")
if ctrl_class is None:
if ctrl_class in [None, "MockupAxis", "ModuloAxis"]:
return get_axis_html(cfg)
else:
return get_ctrl_html(cfg)
......@@ -96,6 +96,7 @@ def get_axis_html(cfg):
ctrl_class = cfg.parent.get("class")
ctrl_name = cfg.parent.get("name")
vars = dict(cfg.items())
vars["filename"] = cfg.filename
filename = "emotion_" + ctrl_class + "_axis.html"
html_template = get_jinja2().select_template([filename, "emotion_axis.html"])
......@@ -125,6 +126,7 @@ def get_axis_html(cfg):
def get_ctrl_html(cfg):
ctrl_class = cfg.get("class")
vars = dict(cfg.items())
vars["filename"] = cfg.filename
filename = "emotion_" + ctrl_class + ".html"
html_template = get_jinja2().select_template([filename, "emotion_controller.html"])
......
{% block toolbar %}
<div class="btn-toolbar" role="toolbar" id="main_toolbar" aria-label="main toolbar">
<div class="btn-toolbar mb-3" role="toolbar" id="main_toolbar" aria-label="main toolbar">
<button id="emotion_axis_apply" class="btn btn-primary">
<span class="fa fa-save"></span>
Apply
</button>
{% if __tango_server__ %}
</button>
{% if __tango_server__ %}
<button id="emotion_axis_apply_server" class="btn btn-primary">
<span class="fa fa-save"></span>
Apply & Update TANGO server
</button>
{% endif %}
{% endif %}
<button class="btn btn-info"
data-name="{{name}}" data-filename="{{filename}}">
<span class="fa fa-eye"></span>
Yaml
</button>
</div>
{% endblock %}
......@@ -29,8 +34,8 @@
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="name">Name</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="name">Name</label>
<div class="col-md-3">
<input id="name" name="name" type="text"
placeholder="{{ name }}" value="{{ name }}"
class="form-control input-md" required></input>
......@@ -42,8 +47,8 @@
{% block controller %}
<div class="form-group">
<label class="col-md-4 control-label" for="controller">Controller</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="controller">Controller</label>
<div class="col-md-3">
{% if controller_name %}
<input id="controller" name="controller" type="text"
placeholder="{{ controller_name }} ({{ controller_class }})"
......@@ -67,15 +72,15 @@
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="tags">Tags</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="tags">Tags</label>
<div class="col-md-3">
<input id="user_tag" name="user_tag" data-role="tagsinput"></input>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="unit">Unit</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="unit">Unit</label>
<div class="col-md-3">
<input id="unit" name="unit" type="text"
placeholder="{{ unit }}" value="{{ unit }}"
class="form-control input-md"></input>
......@@ -85,8 +90,8 @@
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="steps_per_unit">Steps per {{ units }}</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="steps_per_unit">Steps per {{ units }}</label>
<div class="col-md-3">
<input id="steps_per_unit" name="steps_per_unit" type="text"
placeholder="{{ steps_per_unit }}" value="{{ steps_per_unit }}"
class="form-control input-md"></input>
......@@ -95,8 +100,8 @@
<!-- Appended Input-->
<div class="form-group">
<label class="col-md-4 control-label" for="velocity">Velocity</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="velocity">Velocity</label>
<div class="col-md-3">
<div class="input-group">
<input id="velocity" name="velocity" type="text"
class="form-control"
......@@ -109,8 +114,8 @@
<!-- Appended Input-->
<div class="form-group">
<label class="col-md-4 control-label" for="acceleration">Acceleration</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="acceleration">Acceleration</label>
<div class="col-md-3">
<div class="input-group">
<input id="acceleration" name="acceleration" type="text"
class="form-control"
......@@ -123,8 +128,8 @@
<!-- Appended Input-->
<div class="form-group">
<label class="col-md-4 control-label" for="backlash">Backlash</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="backlash">Backlash</label>
<div class="col-md-3">
<div class="input-group">
<input id="backlash" name="backlash" type="text" class="form-control"
placeholder="{{ backlash }}" value="{{ backlash }}">
......@@ -136,8 +141,8 @@
<!-- Appended Input-->
<div class="form-group">
<label class="col-md-4 control-label" for="low_limit">Low limit</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="low_limit">Low limit</label>
<div class="col-md-3">
<div class="input-group">
<input id="low_limit" name="low_limit" type="text" class="form-control"
placeholder="{{ low_limit }}" value="{{ low_limit }}">
......@@ -149,8 +154,8 @@
<!-- Appended Input-->
<div class="form-group">
<label class="col-md-4 control-label" for="high_limit">High limit</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="high_limit">High limit</label>
<div class="col-md-3">
<div class="input-group">
<input id="high_limit" name="high_limit" type="text" class="form-control"
placeholder="{{ high_limit }}" value="{{ high_limit }}">
......@@ -167,8 +172,8 @@
{% for name in params.keys() %}
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="{{ name }}">{{ params[name].label }}</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="{{ name }}">{{ params[name].label }}</label>
<div class="col-md-3">
<input id="{{ name }}" name="{{ name }}" type="text"
class="form-control input-md"
placeholder="{{ params[name].value }}" value="{{ params[name].value }}">
......
......@@ -6,24 +6,27 @@
-->
{% block toolbar %}
<nav class="navbar navbar-static-top">
<button id="emotion_controller_apply" class="btn btn-primary navbar-btn">
<button id="emotion_controller_apply" class="btn btn-primary">
<span class="fa fa-save"></span>
Apply
</button>
{% if __tango_server__ %}
<button id="emotion_controller_apply_server" class="btn btn-primary navbar-btn">
{% if __tango_server__ %}
<button id="emotion_controller_apply_server" class="btn btn-primary">
<span class="fa fa-save"></span>
Apply & Update TANGO server
</button>
<button class="btn btn-info"
data-name="{{name}}" data-filename="{{filename}}">
<span class="fa fa-eye"></span>
Yaml
</button>
<br><br>
{% endif %}
</nav>
{% endblock %}
<form id="emotion_controller_form" class="form-horizontal">
......@@ -33,8 +36,8 @@
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="name">Name</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="name">Name</label>
<div class="col-md-3">
<input id="name" name="name" type="text"
placeholder="{{ name }}" placeholder="{{ name }}"
class="form-control input-md" required></input>
......@@ -47,8 +50,8 @@
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="class">Controller</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="class">Controller</label>
<div class="col-md-3">
<select class="selectpicker" id="class" name="class" class="form-control">
{% for c in controllers %}
<option {{ "selected" if c.class == class }}>{{c.class}}</option>
......@@ -64,8 +67,8 @@
{% for param in params %}
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="{{ param.name }}">{{ param.label }}</label>
<div class="col-md-4">
<label class="col-md-2 control-label" for="{{ param.name }}">{{ param.label }}</label>
<div class="col-md-3">
<input id="{{ param.name }}" name="{{ param.name }}" placeholder="{{ param.value }}"
class="form-control input-md" required="" type="text">
</div>
......
......@@ -34,15 +34,23 @@
{% block toolbar %}
<div class="container">
<div class="row">
<div class="btn-group" role="group" aria-label="global functionality">
<a class="btn btn-default disabled-btn" href="javascript:void(0)">
{{ name if name else "unknown session" }}
</a>
<button type="button" class="btn btn-primary apply"
data-toggle="tooltip" title="save changes">
Save
data-toggle="tooltip" title="save changes">
<span class="fa fa-save"></span>
Save
</button>
<button type="button" class="btn btn-info"
data-name="{{name}}" data-filename="{{filename}}"
data-toggle="tooltip" title="View in yaml file">
<span class="fa fa-eye"></span>
Yaml
</button>
</div>
</div>
......@@ -60,8 +68,8 @@
<div class="row">
<!-- Text input-->
<div class="form-group">
<label class="col-sm-4 control-label" for="name">Name</label>
<div class="col-sm-4">
<label class="col-sm-2 control-label" for="name">Name</label>
<div class="col-sm-3">
<input id="name" name="name" type="text"
placeholder="{{ name }}" value="{{ name }}"
class="form-control input-md" required></input>
......@@ -69,8 +77,8 @@
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-sm-4 control-label" for="setup">Setup script</label>
<div class="col-sm-4">
<label class="col-sm-2 control-label" for="setup">Setup script</label>
<div class="col-sm-3">
<input id="setup" name="setup" type="text"
placeholder="{{ setup }}" value="{{ setup }}"
class="form-control input-md"></input>
......@@ -116,12 +124,14 @@
<!-- vertical button bar -->
<div class="col-sm-1 col-v-center col-compact">
<button type="button" title="Select"
class="btn btn-default center-block add"
id="add-session-item">
class="btn btn-lg btn-default center-block add"
id="add-session-item"
style="margin-top: 25px; margin-bottom: 25px;">
<i class="fa fa-chevron-right"></i>
</button>
</button>
<button type="button" title="Unselect"
class="btn btn-default center-block remove"
class="btn btn-lg btn-default center-block remove"
id="remove-session-item">
<i class="fa fa-chevron-left"></i>
</button>
......@@ -166,6 +176,7 @@
</fieldset>
</form>
</div> <!-- row -->
</div> <!-- container -->
{% endblock %}
......@@ -246,6 +257,7 @@
function update_session_tree(tree_tag, items) {
var tree_options = get_tree_options();
tree_options.multiSelect = true;
tree_options.levels = 2;
tree_options.data = [];
add_session_tree_nodes(tree_options, items);
tree_tag.treeview(tree_options);
......
......@@ -83,7 +83,10 @@ def get_html(cfg):
plugin_items[item_cfg.plugin].append(item)
params = dict(
name=cfg["name"], setup=cfg.get("setup-file", ""), plugin_items=plugin_items
name=cfg["name"],
filename=cfg.filename,
setup=cfg.get("setup-file", ""),
plugin_items=plugin_items,
)
html_template = get_jinja2().select_template(["session.html"])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment