diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-02-06 15:21:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-06 15:21:45 +0000 |
commit | 5fa7a97ccdb1be3c345868e149686ef0e46f419e (patch) | |
tree | c69402251d079ca59e9ca4e6591ce874640eeabd | |
parent | 3e368dfdf495029280e6f1d833ebaf4144d78052 (diff) | |
parent | 4cc0b0de9af58d085f9d2f21b9a1446cee47e354 (diff) | |
download | rspamd-5fa7a97ccdb1be3c345868e149686ef0e46f419e.tar.gz rspamd-5fa7a97ccdb1be3c345868e149686ef0e46f419e.zip |
Merge pull request #1397 from moisseev/webui
[WebUI] Add server selector to navbar
-rw-r--r-- | interface/index.html | 3 | ||||
-rw-r--r-- | interface/js/app/rspamd.js | 6 | ||||
-rw-r--r-- | interface/js/app/stats.js | 42 |
3 files changed, 28 insertions, 23 deletions
diff --git a/interface/index.html b/interface/index.html index 3fa0459b4..71b9d5754 100644 --- a/interface/index.html +++ b/interface/index.html @@ -19,6 +19,9 @@ <div class="navbar-header"> <a class="navbar-brand" href="."><img src="./img/rspamd_logo_navbar.png" style="width: 67px; margin-top: -16px;"/></a> </div> + <form class="navbar-form navbar-left"> + <select id="selSrv" class="form-control"></select> + </form> <ul class="nav navbar-nav nav-pills" role="tablist"> <li role="presentation" class="active"><a id="status_nav" aria-controls="status" role="tab" href="#status" data-toggle="tab">Status</a></li> diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index 1490c927c..98e6f5429 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -205,6 +205,12 @@ define(['jquery', 'd3pie', 'visibility', 'app/stats', 'app/graph', 'app/config', tabClick(tab_id); }); + $("#selSrv").change(function () { + checked_server = this.value; + $('#selSrv [value="' + checked_server + '"]').prop("checked", true); + tabClick("#" + $("#navBar ul li.active > a").attr("id")); + }); + // Radio buttons $(document).on('click', 'input:radio[name="clusterName"]', function () { if (!this.disabled) { diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js index e2ce33d0f..4010191cf 100644 --- a/interface/js/app/stats.js +++ b/interface/js/app/stats.js @@ -98,42 +98,38 @@ function($, d3pie, Humanize) { $('#statWidgets').find('li.pull-right').appendTo('#statWidgets'); $("#clusterTable tbody").empty(); + $("#selSrv").empty(); $.each(servers, function (key, val) { var glyph_status; + var short_id; + if (!('config_id' in val.data)) { + val.data.config_id = ""; + } if (val.status) { glyph_status = "glyphicon glyphicon-ok-circle"; + short_id = val.data.config_id.substring(0, 8); } else { glyph_status = "glyphicon glyphicon-remove-circle"; + short_id = "???"; } - if (!('config_id' in val.data)) { - val.data.config_id = ""; - } - if (checked_server == key) { + $('#clusterTable tbody').append('<tr>' + - '<td class="col1" title="Radio"><input type="radio" class="form-control radio" name="clusterName" value="' + key + '" checked></td>' + + '<td class="col1" title="Radio"><input type="radio" class="form-control radio" name="clusterName" value="' + key + '"></td>' + '<td class="col2" title="SNAme">' + key + '</td>' + '<td class="col3" title="SHost">' + val.host + '</td>' + '<td class="col4" title="SStatus"><span class="icon"><i class="' + glyph_status + '"></i></span></td>' + - '<td class="col5" title="SId">' + val.data.config_id.substring(0, 8) + '</td></tr>'); - } else { - if (val.status) { - $('#clusterTable tbody').append('<tr>' + - '<td class="col1" title="Radio"><input type="radio" class="form-control radio" name="clusterName" value="' + key + '"></td>' + - '<td class="col2" title="SNAme">' + key + '</td>' + - '<td class="col3" title="SHost">' + val.host + '</td>' + - '<td class="col4" title="SStatus"><span class="icon"><i class="' + glyph_status + '"></i></span></td>' + - '<td class="col5" title="SId">' + val.data.config_id.substring(0, 8) + '</td></tr>'); - } - else { - $('#clusterTable tbody').append('<tr>' + - '<td class="col1" title="Radio"><input type="radio" class="form-control radio disabled" disabled="disabled" name="clusterName" value="' + key + '"></td>' + - '<td class="col2" title="SNAme">' + key + '</td>' + - '<td class="col3" title="SHost">' + val.host + '</td>' + - '<td class="col4" title="SStatus"><span class="icon"><i class="' + glyph_status + '"></i></span></td>' + - '<td class="col5" title="SId">???</td></tr>'); - } + '<td class="col5" title="short_id">' + short_id + '</td></tr>'); + + $("#selSrv").append( $('<option value="' + key + '">' + key + '</option>')); + if (checked_server == key) { + $('#clusterTable tbody [value="' + key + '"]').prop("checked", true); + $('#selSrv [value="' + key + '"]').prop("selected", true); + } + else if (!val.status) { + $('#clusterTable tbody [value="' + key + '"]').prop("disabled", true); + $('#selSrv [value="' + key + '"]').prop("disabled", true); } }); $(widgets).show(); |