You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haproxy-wi/app/templates/sections.html

121 lines
5.1 KiB

{% extends "base.html" %}
{% block content %}
{% if is_serv_protected and role > 2 %}
<meta http-equiv="refresh" content="0; url=/app/hapservers.py?service={{service}}">
{% else %}
<link rel="stylesheet" href="/inc/codemirror/lib/codemirror.css">
<link rel="stylesheet" href="/inc/codemirror/addon/dialog/dialog.css">
<link rel="stylesheet" href="/inc/codemirror/addon/fold/foldgutter.css">
<script src="/inc/codemirror/lib/codemirror.js"></script>
<script src="/inc/codemirror/addon/search/search.js"></script>
<script src="/inc/codemirror/addon/search/searchcursor.js"></script>
<script src="/inc/codemirror/addon/search/jump-to-line.js"></script>
<script src="/inc/codemirror/addon/search/matchesonscrollbar.js"></script>
<script src="/inc/codemirror/addon/search/match-highlighter.js"></script>
<script src="/inc/codemirror/addon/dialog/dialog.js"></script>
<script src="/inc/codemirror/addon/edit/matchbrackets.js"></script>
<script src="/inc/codemirror/addon/edit/closebrackets.js"></script>
<script src="/inc/codemirror/addon/comment/comment.js"></script>
<script src="/inc/codemirror/addon/wrap/hardwrap.js"></script>
<script src="/inc/codemirror/addon/fold/foldcode.js"></script>
<script src="/inc/codemirror/addon/fold/foldgutter.js"></script>
<script src="/inc/codemirror/addon/fold/brace-fold.js"></script>
<script src="/inc/codemirror/addon/fold/comment-fold.js"></script>
<script src="/inc/codemirror/addon/scroll/annotatescrollbar.js"></script>
<script src="/inc/codemirror/mode/nginx.js"></script>
<script src="/inc/codemirror/mode/haproxy.js"></script>
<script src="/inc/codemirror/keymap/sublime.js"></script>
<center>
<p>
<form action="{{ action }}" method="post">
<select autofocus required name="section" id="{{ select_id }}">
<option disabled>------</option>
{% for s in sections %}
{% if s == section %}
<option value="{{ s }}" selected>{{ s }}</option>
{% else %}
<option value="{{ s }}">{{ s }}</option>
{% endif %}
{% endfor %}
</select>
<input type="hidden" value="{{ serv }}" name="serv">
{% if role <= 3 %}
<button type="submit" value="open" name="open" class="btn btn-default" title="Edit running config">Edit</button>
{% endif %}
</form>
</p>
{% if config %}
{% if role <= 3 %}
<div id="config">
<h4>You are editing "{{section}}" section from server {{ serv }}</h4>
<form action="{{ action }}" name="saveconfig" method="post">
<input type="hidden" value="{{ serv }}" name="serv">
<input type="hidden" value="{{ start_line }}" name="start_line">
<input type="hidden" value="{{ end_line }}" name="end_line">
<input type="hidden" value="{{ cfg }}.old" name="oldconfig">
<div style="margin-left: 2%;width: 60%; text-align: left">
<textarea name="config" class="config" id="config_text_area" rows="35" cols="100" style="height: 40%">{{ config }}</textarea>
</div>
{% if not is_serv_protected or role <= 2 %}
<p>
<button type="submit" value="test" name="save" class="btn btn-default" title="Check config without saving the config">Check config</button>
<button type="submit" value="save" name="save" class="btn btn-default" title="Save config without reloading the service">Save</button>
{% if is_restart|int == 0 %}
<button type="submit" value="" name="" class="btn btn-default">Save and restart</button>
{% endif %}
<button type="submit" value="reload" name="save" class="btn btn-default">Save and reload</button>
{% if section != 'globals' and section != 'defaults' %}
<button type="submit" value="delete" name="save" class="btn btn-default">Delete this section</button>
{% endif %}
</p>
{% endif %}
</form>
<script>
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("config_text_area"),
{
mode: "haproxy",
lineNumbers: true,
lineWrapping: true,
autocapitalize: true,
autocorrect: true,
spellcheck: true,
autoCloseBrackets: true,
keyMap: "sublime",
matchBrackets: true,
foldGutter: true,
showCursorWhenSelecting: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "breakpoints"],
highlightSelectionMatches: {showToken: /\w/, annotateScrollbar: true}
});
</script>
<style>
.CodeMirror {
line-height: 1.2em;
height: 50%;
}
</style>
<script>
myCodeMirror.refresh();
</script>
{% endif %}
{% endif %}
{% if aftersave %}
<div class="alert alert-info">A new config has been saved as: {{ cfg }} </div>
{% if stderr or error %}
{% include 'include/errors.html' %}
{% else %}
<div class="alert alert-success">Config is ok</div>
{% if warning %}
<div class="alert alert-warning">{{warning}}</div>
{% endif %}
<a href="config.py?serv={{ serv }}" title="Working with HAProxy config">Config</a> |
<a href="statsview.py?serv={{ serv }}" target="_blank" title="View stats">Go to stats</a>
{% endif %}
<script>window.history.pushState("Config", "Config", cur_url[0])</script>
{% endif %}
</div>
</div>
{% endif %}
</center>
{% endblock %}