]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Combine Scan and Learning into one tab 2827/head
authorAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 31 Mar 2019 15:14:53 +0000 (18:14 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 31 Mar 2019 15:14:53 +0000 (18:14 +0300)
Closes: #1441
interface/css/rspamd.css
interface/index.html
interface/js/app/rspamd.js
interface/js/app/upload.js

index b99c3e2b3c299c39cece38ff4e82a5d74163d45b..2c4e40ab8970852b9376fc6a3d27f94dfe98a0fb 100644 (file)
@@ -63,11 +63,13 @@ textarea {
        display:inline;
        }
 
+input[type="number"] {
+    width:4em !important;
+    padding:2px 0;
+    text-align:center;
+}
 input.action-scores {
-  width:4em;
-  margin:5px -7em 5px 0;
-  padding:2px 0;
-  text-align:center;
+    margin:5px -7em 5px 0;
 }
 
 /* history table */
@@ -191,16 +193,6 @@ input.action-scores {
     background-color: #CDDBFF;
 }
 
-.upload-textarea,
-.scan-textarea {
-       width:100% !important;
-       }
-.upload-textarea {
-       height:200px;
-       }
-.scan-textarea {
-       height:300px;
-       }
  .stat-boxes {
        padding-left: 0;
   margin-right: -10px !important;
@@ -500,19 +492,6 @@ td.maps-cell {
        margin-right: 9px;
 }
 
-#learning p > button {
-    margin-top: 10px;
-    }
-#learning div.widget-content:last-child > div.row {
-    padding: 0 0 15px 15px;
-    }
-#learning form div.row {
-    padding-left: 15px;
-    }
-#scanForm button {
-    margin-top: 10px;
-    }
-
 #throughput div.widget-content {
     text-align: center;
 }
index 8b9b65c9dcdd72031e06065dbf15e5eeeac2b310..efe39a31dd1e86b351689b1c0a9e796e9fc524e6 100644 (file)
@@ -31,8 +31,7 @@
 
                        <li role="presentation"><a id="configuration_nav" aria-controls="configuration" role="tab" href="#configuration" data-toggle="tab">Configuration</a></li>
                        <li role="presentation"><a id="symbols_nav" aria-controls="symbols" role="tab" href="#symbols" data-toggle="tab">Symbols</a></li>
-                       <li role="presentation"><a id="learning_nav" aria-controls="learning" role="tab" href="#learning" data-toggle="tab" style="display: none;">Learning</a></li>
-                       <li role="presentation"><a id="scan_nav" aria-controls="scan" role="tab" href="#scan" data-toggle="tab">Scan</a></li>
+                       <li role="presentation"><a id="scan_nav" aria-controls="scan" role="tab" href="#scan" data-toggle="tab">Scan<span class="learn" style="display:none">/Learn</span></a></li>
                        <li role="presentation"><a id="history_nav" aria-controls="history" role="tab" href="#history" data-toggle="tab">History</a></li>
                </ul>
     <ul class="nav navbar-nav nav-pills pull-right" style="display:none">
                                </div>
                        </div>
 
-                       <div class="tab-pane" id="learning">
-                               <div class="widget-box">
-                                       <div class="widget-title">
-                                               <span class="icon"><i class="glyphicon glyphicon-file"></i></span>
-                                               <h5>Learn RSPAMD</h5>
-                                       </div>
-                                       <div class="widget-content">
-                                               <div class="row">
-                                                       <form class="col-md-6">
-                                                               <h5>Insert raw SPAM source:</h5>
-                                                               <textarea class="col-md-5 upload-textarea" id="spamTextSource" value=""></textarea>
-                                                               <p><button class="btn btn-default pull-right" data-upload="spam" disabled><i class="glyphicon glyphicon-upload"></i> Upload text</button></p>
-                                                       </form>
-                                                       <form class="col-md-6">
-                                                               <h5>Insert raw HAM source:</h5>
-                                                               <textarea class="col-md-5 upload-textarea" id="hamTextSource" value=""></textarea>
-                                                               <p><button class="btn btn-default pull-right" data-upload="ham" disabled><i class="glyphicon glyphicon-upload"></i> Upload text</button></p>
-                                                       </form>
-                                               </div>
-                                               <div class="row">
-                                                       <form class="col-md-6">
-                                                               <h5>Insert raw Fuzzy storage:</h5>
-                                                               <textarea class="col-md-5 upload-textarea" id="fuzzyTextSource" value=""></textarea>
-                                                       <div class="row">
-                                                               <label class="pull-left">
-                                                                               Flag
-                                                               </label>
-                                                                       <div class="pull-right col-md-10">
-                                                                               <input id="fuzzyFlagText" class="slider" type="slider" value="1"/>
-                                                                       </div>
-                                                       </div>
-                                                       <div class="row">
-                                                               <label class="pull-left">
-                                                                               Weight
-                                                               </label>
-                                                                       <div class="pull-right col-md-10">
-                                                                               <input id="fuzzyWeightText" class="slider" type="slider" value="1"/>
-                                                                       </div>
-                                                       </div>
-                                                               <p><button class="btn btn-default pull-right" data-upload="fuzzy" disabled><i class="glyphicon glyphicon-upload"></i> Upload text</button></p>
-                                                       </form>
-                                               </div>
-                                       </div>
-                               </div>
-                       </div>
-
                        <div class="tab-pane" id="scan">
                                <div class="widget-box">
                                        <div class="widget-title">
-                                               <span class="icon"><i class="glyphicon glyphicon-info-sign"></i></span>
-                                               <h5>Online scan suspected message</h5>
+                                               <span class="icon"><i class="glyphicon glyphicon-envelope"></i></span>
+                                               <h5>Scan suspected message</h5>
                                        </div>
                                        <div class="widget-content">
-                                               <h5>Paste and scan suspicious message</h5>
+                                               <h5>Message source:</h5>
                                                <div class="row">
-                                                       <form class="col-md-12 nomargin" id="scanForm">
-                                                               <textarea class="col-md-12 scan-textarea" id="scanTextSource"></textarea>
-                <button type="submit" class="btn btn-default btn-primary" data-upload="scan">Scan message</button>
-                   <!--span class="btn btn-default btn-file" style="margin-top:10px; margin-left:5px;">
-                       <i class="glyphicon glyphicon-upload"></i> Upload file <input type="file" class="btn btn-default" id="inputFile">
-                   </span-->
-                                                                        <button class="btn btn-default pull-right" id="scanClean">Clean form</button>
+                                                       <form class="col-md-12" id="scanForm">
+                                                               <div class="form-group">
+                                                                       <textarea class="form-control" id="scanMsgSource" rows="10" placeholder="Paste raw message source"></textarea>
+                                                               </div>
+                                                               <div class="form-group">
+                                                                       <button type="submit" class="btn btn-default btn-primary" data-upload="scan"><i class="glyphicon glyphicon-search"></i> Scan message</button>
+                                                                       <button class="btn btn-default pull-right" id="scanClean"><i class="glyphicon glyphicon-trash"></i> Clean form</button>
+                                                               </div>
                                                        </form>
                                                </div>
                                                <div id="scanResult" style="display:none">
                                                </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>
+                                       <div class="widget-content">
+                                               <div class="row">
+                                                       <div class="col-md-6">
+                                                               <div class="well well-sm">
+                                                                       <form class="form-inline" role="form">
+                                                                               <h5>Learn Bayessian classifier:</h5>
+                                                                               <div class="form-group">
+                                                                                       <div class="btn-group">
+                                                                                               <button class="btn btn-success" type="button" data-upload="ham" disabled><i class="glyphicon glyphicon-thumbs-up"></i> Upload HAM</button>
+                                                                                               <button class="btn btn-danger" type="button" data-upload="spam" disabled><i class="glyphicon glyphicon-thumbs-down"></i> Upload SPAM</button>
+                                                                                       </div>
+                                                                               </div>
+                                                                       </form>
+                                                               </div>
+                                                       </div>
+                                                       <div class="col-md-6">
+                                                               <div class="well well-sm">
+                                                                       <form class="form-inline" role="form">
+                                                                               <h5>Learn Fuzzy storage:</h5>
+                                                                               <div class="form-group">
+                                                                                       <label for="fuzzyFlagText">Flag:</label>
+                                                                                       <input name="fuzzyFlagText" id="fuzzyFlagText" class="form-control" type="number" value="1"/>
+                                                                               </div>
+                                                                               <div class="form-group">
+                                                                                       <label for="fuzzyWeightText">Weight:</label>
+                                                                                       <input name="fuzzyWeightText" id="fuzzyWeightText" class="form-control" type="number" value="1"/>
+                                                                               </div>
+                                                                               <button class="btn btn-warning" data-upload="fuzzy" disabled><i class="glyphicon glyphicon-upload"></i> Upload FUZZY</button>
+                                                                       </form>
+                                                               </div>
+                                                       </div>
+                                               </div>
+                                       </div>
+                               </div>
                        </div>
 
                        <div class="tab-pane" id="history">
index b0b2c45684e644799463196d9f460f6424dd87fb..c9034bedac03642034a06bc18e1555d3cfd896dc 100644 (file)
@@ -139,11 +139,11 @@ function ($, D3pie, visibility, NProgress, tab_stat, tab_graph, tab_config,
         // So when we store the boolean true or false, it actually stores the strings "true" or "false".
         ui.read_only = sessionStorage.getItem("read_only") === "true";
         if (ui.read_only) {
-            $("#learning_nav").hide();
+            $(".learn").hide();
             $("#resetHistory").attr("disabled", true);
             $("#errors-history").hide();
         } else {
-            $("#learning_nav").show();
+            $(".learn").show();
             $("#resetHistory").removeAttr("disabled", true);
             $("#errors-history").show();
         }
index d5d0768f180b0a22b0d2bf7b0258e9c734aa1295..2837ff666a5b9dfcfc2082c1e94d7f742b16bb5a 100644 (file)
@@ -150,14 +150,15 @@ define(["jquery"],
                 return e.options[e.selectedIndex].value;
             }
 
+            $("#scan button").attr("disabled", true);
             $("textarea").keyup(function () {
                 var $this = $(this);
-                $this.closest("form").find("button")
+                $("#scan button")
                     .prop("disabled", ($.trim($this.val()).length === 0));
             });
-
             $("#scanClean").on("click", function () {
-                $("#scanTextSource").val("");
+                $("#scan button").attr("disabled", true);
+                $("#scanMsgSource").val("");
                 $("#scanResult").hide();
                 $("#scanOutput tbody").remove();
                 $("html, body").animate({scrollTop:0}, 1000);
@@ -166,7 +167,7 @@ define(["jquery"],
             // @init upload
             $("[data-upload]").on("click", function () {
                 var source = $(this).data("upload");
-                var data = $("#" + source + "TextSource").val();
+                var data = $("#scanMsgSource").val();
                 var headers = (source === "fuzzy")
                     ? {
                         flag: $("#fuzzyFlagText").val(),