commit 5776fef: [WebUI] Replace widget boxes with Bootstrap cards

moisseev moiseev at mezonplus.ru
Sat Jul 4 19:42:07 UTC 2020


Author: moisseev
Date: 2020-07-04 17:12:06 +0300
URL: https://github.com/rspamd/rspamd/commit/5776fef955347d53941cbc6c8711cf7895af86a6

[WebUI] Replace widget boxes with Bootstrap cards

---
 interface/css/rspamd.css   |  93 ++++++++-----------------------
 interface/index.html       | 134 +++++++++++++++++++++++----------------------
 interface/js/app/config.js |   4 +-
 interface/js/app/stats.js  |   4 +-
 4 files changed, 95 insertions(+), 140 deletions(-)

diff --git a/interface/css/rspamd.css b/interface/css/rspamd.css
index 81e481b47..5c925753c 100644
--- a/interface/css/rspamd.css
+++ b/interface/css/rspamd.css
@@ -206,32 +206,7 @@ table#symbolsTable input[type="number"] {
 }
 
 /* widget */
-.widget-box {
-    background: none repeat scroll 0 0 #f9f9f9;
-    border-top: 1px solid #cdcdcd;
-    border-left: 1px solid #cdcdcd;
-    border-right: 1px solid #cdcdcd;
-    clear: both;
-    margin-top: 16px;
-    margin-bottom: 16px;
-    position: relative;
-}
-.widget-box.widget-calendar,
-.widget-box.widget-chat {
-    overflow: hidden !important;
-}
-.accordion .widget-box {
-    margin-top: -2px;
-    margin-bottom: 0;
-    border-radius: 0;
-}
-.widget-box.widget-plain {
-    background: transparent;
-    border: none;
-    margin-top: 0;
-    margin-bottom: 0;
-}
-.widget-title,
+.card-header,
 .modal-header {
     background-color: #efefef;
     background-image: -webkit-gradient(linear, 0 0%, 0 100%, from(#fdfdfd), to(#eaeaea));
@@ -242,41 +217,12 @@ table#symbolsTable input[type="number"] {
     background-image: -linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
     /* stylelint-disable-next-line function-name-case */
     filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdfdfd', endColorstr='#eaeaea', GradientType=0); /* IE6-9 */
-    border-bottom: 1px solid #cdcdcd;
     height: 36px;
 }
-.widget-title span.icon {
-    border-right: 1px solid #cdcdcd;
-    padding: 9px 10px 7px 11px;
-    float: left;
-    opacity: .7;
-}
-.widget-title h5 {
-    color: #666666;
-    text-shadow: 0 1px 0 #ffffff;
-    /* float:left; */
-    display: block;
-    font-size: 12px;
-    font-weight: bold;
-    padding: 12px;
-    line-height: 12px;
-    margin: 0 0 0 36px;
-}
-.widget-title .buttons {
-    padding: 2px 2px 0 0;
-}
-.widget-title .label {
-    padding: 3px 5px 2px;
-    float: right;
-    margin: 9px 15px 0 0;
-    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) inset, 0 1px 0 #ffffff;
-}
-.widget-content {
-    padding: 12px 15px;
-    border-bottom: 1px solid #cdcdcd;
-    -moz-box-shadow: 0 1px 2px -1px rgba(0, 0, 0, 0.2);
-    box-shadow: 0 1px 2px -1px rgba(0, 0, 0, 0.2);
+.card-header h6 {
+    font-size: 0.857rem;
 }
+
 .stat-boxes {
     margin: 0;
     margin-right: -10px !important;
@@ -292,7 +238,6 @@ table#symbolsTable input[type="number"] {
     background-image: linear-gradient(to bottom, #f9f9f9 0%, #ededed 100%);
     border: 1px solid #d5d5d5;
     border-radius: 4px 4px 4px 4px;
-    box-shadow: 0 1px 0 0 #ffffff inset, 0 1px 0 rgba(255, 255, 255, 0.4);
     display: inline-block;
     line-height: 18px;
     margin: 0 10px 10px 0;
@@ -309,7 +254,6 @@ table#symbolsTable input[type="number"] {
     font-weight: bold;
     text-align: center;
     text-transform: capitalize;
-    text-shadow: 0 1px 0 white;
     color: #666;
 }
 .stat-box .left,
@@ -318,7 +262,6 @@ table#symbolsTable input[type="number"] {
 }
 .stat-box .left {
     border-right: 1px solid gainsboro;
-    box-shadow: 1px 0 0 0 white;
     margin-right: 14px;
     padding-right: 18px;
     font-size: 10px;
@@ -418,13 +361,13 @@ td.maps-cell {
     margin-right: 9px;
 }
 
-#throughput div.widget-content {
+#throughput div.card-body {
     text-align: center;
 }
-#throughput div.widget-content > div {
+#throughput div.card-body > div {
     display: inline-block;
 }
-#throughput div.widget-content div.row {
+#throughput div.card-body div.row {
     background: #fff;
 }
 
@@ -489,10 +432,6 @@ td.maps-cell {
     padding-right: 20px;
 }
 
-.widget-title-form label {
-    font-size: 12px;
-    font-weight: normal;
-}
 #history_page_size {
     width: 6em !important;
     text-align: center;
@@ -517,8 +456,6 @@ td.maps-cell {
 }
 
 #row-main {
-    margin-top: -12px;
-    margin-bottom: -12px;
     display: flex;
     flex-wrap: wrap;
     clear: both;
@@ -626,3 +563,19 @@ td.maps-cell {
 #navBar .navbar-nav .nav-link {
     padding: 15px;
 }
+
+#clusterTable td:last-child {
+    border-right: none;
+}
+#clusterTable tr:last-child td {
+    border-bottom: none;
+}
+#clusterTable thead th:last-child {
+    border-right: none;
+}
+#clusterTable tr:last-child td:first-child {
+    border-radius: 0 0 0 calc(.25rem - 1px);
+}
+#clusterTable tr:last-child td:last-child {
+    border-radius: 0 0 calc(.25rem - 1px) 0;
+}
diff --git a/interface/index.html b/interface/index.html
index c8748a2f8..88176624d 100644
--- a/interface/index.html
+++ b/interface/index.html
@@ -80,7 +80,7 @@
 			<div class="tab-pane active" id="status">
 				<div class="row">
 					<div class="col-lg-12">
-						<div class="widget-box widget-plain">
+						<div class="card border-0">
 							<ul id="statWidgets" class="stat-boxes" style="display: none;">
 							</ul>
 						</div>
@@ -88,12 +88,12 @@
 				</div>
 				<div class="row">
 					<div class="col-lg-6">
-						<div class="widget-box">
-							<div class="widget-title">
-								<span class="icon"><i class="glyphicon glyphicon-tasks"></i></span>
-								<h5>Servers</h5>
+						<div class="card bg-light shadow my-3">
+							<div class="card-header text-secondary">
+								<span class="icon float-left mr-3"><i class="glyphicon glyphicon-tasks"></i></span>
+								<h6 class="font-weight-bolder">Servers</h6>
 							</div>
-								<div class="widget-content nopadding table-responsive">
+								<div class="card-body nopadding table-responsive">
 									<table class="table table-sm table-hover table-bordered text-nowrap mb-0" id="clusterTable">
 										<thead>
 											<tr>
@@ -111,12 +111,12 @@
 						</div>
 					</div>
 					<div class="col-lg-6">
-						<div class="widget-box">
-							<div class="widget-title">
-								<span class="icon"><i class="glyphicon glyphicon-signal"></i></span>
-								<h5>Statistics</h5>
+						<div class="card bg-light shadow my-3">
+							<div class="card-header text-secondary">
+								<span class="icon float-left mr-3"><i class="glyphicon glyphicon-signal"></i></span>
+								<h6 class="font-weight-bolder">Statistics</h6>
 							</div>
-							<div class="widget-content chart-content">
+							<div class="card-body chart-content">
 								<div class="row">
 									<div class="chart" id="chart">
 										<span class="notice">Loading..</span>
@@ -130,12 +130,12 @@
 			</div>
 
 			<div class="tab-pane" id="throughput">
-				<div class="widget-box">
-					<div class="widget-title">
-						<span class="icon"><i class="glyphicon glyphicon-stats"></i></span>
-						<h5>Throughput</h5>
+				<div class="card bg-light shadow my-3">
+					<div class="card-header text-secondary">
+						<span class="icon float-left mr-3"><i class="glyphicon glyphicon-stats"></i></span>
+						<h6 class="font-weight-bolder">Throughput</h6>
 					</div>
-					<div class="widget-content">
+					<div class="card-body">
 						<div>
 							<div class="row">
 								<div id="graph" class="mx-auto">
@@ -200,17 +200,19 @@
 			</div>
 
 			<div class="tab-pane" id="configuration">
-				<div class="widget-box">
-					<div class="widget-title">
-						<span class="icon"><i class="glyphicon glyphicon-tasks"></i></span><h5>Actions</h5>
+				<div class="card bg-light shadow my-3">
+					<div class="card-header text-secondary">
+						<span class="icon float-left mr-3"><i class="glyphicon glyphicon-tasks"></i></span>
+						<h6 class="font-weight-bolder">Actions</h6>
 					</div>
-					<div class="widget-content actions-content" id="actionsBody"></div>
+					<div class="card-body actions-content" id="actionsBody"></div>
 				</div>
-				<div class="widget-box">
-					<div class="widget-title">
-						<span class="icon"><i class="glyphicon glyphicon-list"></i></span><h5>Lists</h5>
+				<div class="card bg-light shadow my-3">
+					<div class="card-header text-secondary">
+						<span class="icon float-left mr-3"><i class="glyphicon glyphicon-list"></i></span>
+						<h6 class="font-weight-bolder">Lists</h6>
 					</div>
-					<div class="widget-content nopadding">
+					<div class="card-body nopadding">
 						<table class="table table-sm table-hover" id="listMaps">
 						</table>
 					</div>
@@ -218,29 +220,29 @@
 			</div>
 
 			<div class="tab-pane" id="symbols">
-				<div class="widget-box">
-					<div class="widget-title  d-flex">
-						<span class="icon"><i class="glyphicon glyphicon-tasks"></i></span>
-						<h5 class="ml-0">Symbols and rules</h5>
-						<div class="buttons align-self-center ml-auto mr-1">
+				<div class="card bg-light shadow my-3">
+					<div class="card-header text-secondary  d-flex">
+						<span class="icon float-left mr-3"><i class="glyphicon glyphicon-tasks"></i></span>
+						<h6 class="font-weight-bolder" class="ml-0">Symbols and rules</h6>
+						<div class="align-self-center ml-auto mr-1">
 							<button class="btn btn-info btn-sm" id="updateSymbols">
 								<i class="glyphicon glyphicon-refresh"></i> Update
 							</button>
 						</div>
 					</div>
-					<div class="widget-content nopadding">
+					<div class="card-body nopadding">
 						<table class="table table-hover" id="symbolsTable"></table>
 					</div>
 				</div>
 			</div>
 
 			<div class="tab-pane" id="scan">
-				<div class="widget-box">
-					<div class="widget-title">
-						<span class="icon"><i class="glyphicon glyphicon-envelope"></i></span>
-						<h5>Scan suspected message</h5>
+				<div class="card bg-light shadow my-3">
+					<div class="card-header text-secondary">
+						<span class="icon float-left mr-3"><i class="glyphicon glyphicon-envelope"></i></span>
+						<h6 class="font-weight-bolder">Scan suspected message</h6>
 					</div>
-					<div class="widget-content">
+					<div class="card-body">
 						<div class="row">
 							<form class="col-lg-12" id="scanForm">
 								<div class="form-group">
@@ -255,15 +257,15 @@
 						</div>
 					</div>
 				</div>
-				<div class="widget-box learn" style="display: none;">
-					<div class="widget-title">
-						<span class="icon"><i class="glyphicon glyphicon-education"></i></span>
-						<h5>Learn Rspamd</h5>
+				<div class="card learn" style="display: none;">
+					<div class="card-header text-secondary">
+						<span class="icon float-left mr-3"><i class="glyphicon glyphicon-education"></i></span>
+						<h6 class="font-weight-bolder">Learn Rspamd</h6>
 					</div>
-					<div class="widget-content">
+					<div class="card-body">
 						<div class="row">
 							<div class="col-lg-6">
-								<div class="card bg-light card-body mb-3 card bg-faded p-2 mb-3">
+								<div class="card bg-light shadow card-body card p-2">
 									<p>Learn Bayessian classifier:</p>
 									<form class="form-inline">
 										<div class="form-group">
@@ -276,7 +278,7 @@
 								</div>
 							</div>
 							<div class="col-lg-6">
-								<div class="card bg-light card-body mb-3 card bg-faded p-2 mb-3">
+								<div class="card bg-light shadow card-body card p-2">
 									<p>Learn Fuzzy storage:</p>
 									<form class="form-inline">
 										<div class="form-group">
@@ -295,11 +297,11 @@
 					</div>
 				</div>
 
-				<div class="widget-box">
-					<div class="widget-title d-flex">
-						<span class="icon"><i class="glyphicon glyphicon-eye-open"></i></span>
-						<h5 class="ml-0">Scan results history</h5>
-						<div id="scanResult" class="form-inline widget-title-form input-group-sm buttons align-self-center ml-auto mr-1">
+				<div class="card bg-light shadow my-3">
+					<div class="card-header text-secondary d-flex">
+						<span class="icon float-left mr-3"><i class="glyphicon glyphicon-eye-open"></i></span>
+						<h6 class="font-weight-bolder" class="ml-0">Scan results history</h6>
+						<div id="scanResult" class="form-inline card-header-form input-group-sm align-self-center ml-auto mr-1">
 								<label for="selSymOrder_scan">Symbols order:</label>
 								<select id="selSymOrder_scan" class="form-control ml-1">
 									<option value="magnitude" selected>Score magnitude</option>
@@ -313,7 +315,7 @@
 							</button>
 						</div>
 					</div>
-					<div class="widget-content nopadding">
+					<div class="card-body nopadding">
 						<div id="scanLog">
 							<table class="table" id="historyTable_scan"></table>
 						</div>
@@ -322,12 +324,12 @@
 			</div>
 
 			<div class="tab-pane" id="selectors">
-				<div class="widget-box">
-					<div class="widget-title">
-						<span class="icon"><i class="glyphicon glyphicon-envelope"></i></span>
-						<h5>Test Rspamd selectors</h5>
+				<div class="card bg-light shadow my-3">
+					<div class="card-header text-secondary">
+						<span class="icon float-left mr-3"><i class="glyphicon glyphicon-envelope"></i></span>
+						<h6 class="font-weight-bolder">Test Rspamd selectors</h6>
 					</div>
-					<div class="widget-content">
+					<div class="card-body py-0">
 						<div class="row" id="row-main">
 							<div class="col-lg-3 sidebar" id="sidebar-left">
 								<div class="nopadding table-responsive">
@@ -404,11 +406,11 @@
 
 			<div class="tab-pane" id="history">
 
-				<div class="widget-box">
-					<div class="widget-title d-flex">
-						<span class="icon"><i class="glyphicon glyphicon-eye-open"></i></span>
-						<h5 class="ml-0">History</h5>
-						<div class="form-inline widget-title-form input-group-sm buttons align-self-center ml-auto mr-1">
+				<div class="card bg-light shadow my-3">
+					<div class="card-header text-secondary d-flex">
+						<span class="icon float-left mr-3"><i class="glyphicon glyphicon-eye-open"></i></span>
+						<h6 class="font-weight-bolder" class="ml-0">History</h6>
+						<div class="form-inline card-header-form input-group-sm align-self-center ml-auto mr-1">
 							<label for="selSymOrder_history">Symbols order:</label>
 							<select id="selSymOrder_history" class="form-control ml-1">
 								<option value="magnitude" selected>Score magnitude</option>
@@ -425,23 +427,23 @@
 							</button>
 						</div>
 					</div>
-					<div class="widget-content nopadding">
+					<div class="card-body nopadding">
 						<div id="historyLog">
 							<table class="table" id="historyTable_history"></table>
 						</div>
 					</div>
 				</div>
-				<div class="widget-box" id="errors-history">
-					<div class="widget-title d-flex">
-						<span class="icon"><i class="glyphicon glyphicon-eye-open"></i></span>
-						<h5 class="ml-0">Errors</h5>
-						<div class="buttons align-self-center ml-auto mr-1">
+				<div class="card bg-light shadow my-3" id="errors-history">
+					<div class="card-header text-secondary d-flex">
+						<span class="icon float-left mr-3"><i class="glyphicon glyphicon-eye-open"></i></span>
+						<h6 class="font-weight-bolder" class="ml-0">Errors</h6>
+						<div class="align-self-center ml-auto mr-1">
 							<button class="btn btn-info btn-sm" id="updateErrors">
 								<i class="glyphicon glyphicon-refresh"></i> Update
 							</button>
 						</div>
 					</div>
-					<div class="widget-content nopadding">
+					<div class="card-body nopadding">
 						<table class="table table-hover" id="errorsLog"></table>
 					</div>
 				</div>
@@ -474,7 +476,7 @@
 <!-- login modal -->
 <div id="connectDialog" class="modal" tabindex="-1" role="dialog" style="display: none;">
 	<div class="modal-dialog">
-		<div class="modal-content">
+		<div class="modal-content shadow">
 			<div class="modal-header">
 				<h3>Login to Rspamd</h3>
 			</div>
diff --git a/interface/js/app/config.js b/interface/js/app/config.js
index 05efcc7d4..431d9bb92 100644
--- a/interface/js/app/config.js
+++ b/interface/js/app/config.js
@@ -136,7 +136,7 @@ define(["jquery"],
 
         ui.getMaps = function (rspamd, checked_server) {
             var $listmaps = $("#listMaps");
-            $listmaps.closest(".widget-box").hide();
+            $listmaps.closest(".card").hide();
             rspamd.query("maps", {
                 success: function (json) {
                     var data = json[0].data;
@@ -156,7 +156,7 @@ define(["jquery"],
                         $tr.appendTo($tbody);
                     });
                     $tbody.appendTo($listmaps);
-                    $listmaps.closest(".widget-box").show();
+                    $listmaps.closest(".card").show();
                 },
                 server: (checked_server === "All SERVERS") ? "local" : checked_server
             });
diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js
index c6c320025..1f6a1b5b2 100644
--- a/interface/js/app/stats.js
+++ b/interface/js/app/stats.js
@@ -80,7 +80,7 @@ define(["jquery", "d3pie"],
                     $(widget).appendTo(widgets);
                 } else {
                     var titleAtt = d3.format(",")(item) + " " + i;
-                    widget = "<li class=\"stat-box\"><div class=\"widget\" title=\"" + titleAtt + "\"><strong>" +
+                    widget = "<li class=\"stat-box bg-light shadow-sm\"><div class=\"widget\" title=\"" + titleAtt + "\"><strong>" +
                     d3.format(".3~s")(item) + "</strong>" + i + "</div></li>";
                     if (i === "scanned") {
                         stat_w[0] = widget;
@@ -100,7 +100,7 @@ define(["jquery", "d3pie"],
             $.each(stat_w, function (i, item) {
                 $(item).appendTo(widgets);
             });
-            $("#statWidgets .left,#statWidgets .right").wrapAll("<li class=\"stat-box float-right\"><div class=\"widget\"></div></li>");
+            $("#statWidgets .left,#statWidgets .right").wrapAll("<li class=\"stat-box bg-light shadow-sm float-right\"><div class=\"widget\"></div></li>");
             $("#statWidgets").find("li.float-right").appendTo("#statWidgets");
 
             $("#clusterTable tbody").empty();


More information about the Commits mailing list