Change log: https://roxy-wi.org/changelog.py#6_1_4
pull/334/head
Pavel Loginov 2022-08-18 06:30:55 +03:00
parent 4c17462e5a
commit 1fb426a7eb
2 changed files with 24 additions and 4 deletions

View File

@ -44,6 +44,8 @@ if serv is not None and section is not None:
pass pass
start_line, end_line, config_read = funct.get_section_from_config(cfg, section) start_line, end_line, config_read = funct.get_section_from_config(cfg, section)
server_id = sql.select_server_id_by_ip(serv)
is_restart = sql.select_service_setting(server_id, 'haproxy', 'restart')
os.system("/bin/mv %s %s.old" % (cfg, cfg)) os.system("/bin/mv %s %s.old" % (cfg, cfg))
@ -86,6 +88,6 @@ rendered_template = template.render(
h2=1, title="Working with HAProxy config sections", role=role, action="sections.py", user=user, select_id="serv", h2=1, title="Working with HAProxy config sections", role=role, action="sections.py", user=user, select_id="serv",
serv=serv, aftersave=aftersave, config=config_read, cfg=cfg, selects=servers, stderr=stderr, error=error, serv=serv, aftersave=aftersave, config=config_read, cfg=cfg, selects=servers, stderr=stderr, error=error,
start_line=start_line, end_line=end_line, section=section, sections=sections, is_serv_protected=is_serv_protected, start_line=start_line, end_line=end_line, section=section, sections=sections, is_serv_protected=is_serv_protected,
user_services=user_services, token=token, warning=warning user_services=user_services, token=token, warning=warning, is_restart=is_restart
) )
print(rendered_template) print(rendered_template)

View File

@ -53,14 +53,16 @@
<input type="hidden" value="{{ start_line }}" name="start_line"> <input type="hidden" value="{{ start_line }}" name="start_line">
<input type="hidden" value="{{ end_line }}" name="end_line"> <input type="hidden" value="{{ end_line }}" name="end_line">
<input type="hidden" value="{{ cfg }}.old" name="oldconfig"> <input type="hidden" value="{{ cfg }}.old" name="oldconfig">
<div style="margin-left: 23%;width: 60%; text-align: left"> <div style="margin-left: 2%;width: 60%; text-align: left">
<textarea name="config" class="config" id="config_text_area" rows="35" cols="80" style="height: 40%">{{ config }}</textarea> <textarea name="config" class="config" id="config_text_area" rows="35" cols="100" style="height: 40%">{{ config }}</textarea>
</div> </div>
{% if not is_serv_protected or role <= 2 %} {% if not is_serv_protected or role <= 2 %}
<p> <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="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> <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> <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> <button type="submit" value="reload" name="save" class="btn btn-default">Save and reload</button>
{% if section != 'globals' and section != 'defaults' %} {% if section != 'globals' and section != 'defaults' %}
<button type="submit" value="delete" name="save" class="btn btn-default">Delete this section</button> <button type="submit" value="delete" name="save" class="btn btn-default">Delete this section</button>
@ -69,7 +71,22 @@
{% endif %} {% endif %}
</form> </form>
<script> <script>
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("config_text_area"), {mode: "haproxy", lineNumbers: true}); 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> </script>
<style> <style>
.CodeMirror { .CodeMirror {
@ -99,4 +116,5 @@
</div> </div>
</div> </div>
{% endif %} {% endif %}
</center>
{% endblock %} {% endblock %}