From bf6a08d3381910515f0c1ca33220a4612ae9ea82 Mon Sep 17 00:00:00 2001 From: Frank Wall Date: Thu, 18 Feb 2021 21:46:46 +0100 Subject: [PATCH] net/haproxy: show a message when config files are identical --- .../app/views/OPNsense/HAProxy/export.volt | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/net/haproxy/src/opnsense/mvc/app/views/OPNsense/HAProxy/export.volt b/net/haproxy/src/opnsense/mvc/app/views/OPNsense/HAProxy/export.volt index 9b4d7d072..160d93df9 100644 --- a/net/haproxy/src/opnsense/mvc/app/views/OPNsense/HAProxy/export.volt +++ b/net/haproxy/src/opnsense/mvc/app/views/OPNsense/HAProxy/export.volt @@ -45,24 +45,28 @@ POSSIBILITY OF SUCH DAMAGE. function update_showdiff() { ajaxCall(url="/api/haproxy/export/diff/", sendData={}, callback=function(data,status) { diff = ''; - var lines = data['response'].split("\n"); - $.each(lines, function(n, line) { - switch(line.substring(0,1)) { - case '+': - color = '#3bbb33'; - break; - case '-': - color = '#c13928'; - break; - case '@': - color = '#3bb9c3'; - break; - default: - color = '#000000'; - } - diff += '' + line + '
'; + if (data['response'] && data['response'].trim()) { + var lines = data['response'].split("\n"); + $.each(lines, function(n, line) { + switch(line.substring(0,1)) { + case '+': + color = '#3bbb33'; + break; + case '-': + color = '#c13928'; + break; + case '@': + color = '#3bb9c3'; + break; + default: + color = '#000000'; + } + diff += '' + line + '
'; - }); + }); + } else { + diff = "
{{ lang._('New and old config files are identical.') }}
"; + } $("#showdiff").append(diff); }); }