Browse Source

Merge branch 'master' of https://github.com/mailcow/mailcow-dockerized

andryyy 5 years ago
parent
commit
726235e9ee
2 changed files with 24 additions and 13 deletions
  1. 18 13
      data/web/js/site/debug.js
  2. 6 0
      data/web/js/site/quarantine.js

+ 18 - 13
data/web/js/site/debug.js

@@ -468,29 +468,34 @@ jQuery(function($){
       else {
         item.rcpt = item.rcpt_smtp.join(", ");
       }
-      Object.keys(item.symbols).map(function(key) {
+      item.symbols = Object.keys(item.symbols).sort(function (a, b) {
+        if (item.symbols[a].score === 0) return 1
+        if (item.symbols[b].score === 0) return -1
+        if (item.symbols[b].score < 0 && item.symbols[a].score < 0) {
+          return item.symbols[a].score - item.symbols[b].score
+        }
+        if (item.symbols[b].score > 0 && item.symbols[a].score > 0) {
+          return item.symbols[b].score - item.symbols[a].score
+        }
+        return item.symbols[b].score - item.symbols[a].score
+      }).map(function(key) {
         var sym = item.symbols[key];
-        if (sym.score <= 0) {
+        if (sym.score < 0) {
           sym.score_formatted = '(<span class="text-success"><b>' + sym.score + '</b></span>)'
         }
+        else if (sym.score === 0) {
+          sym.score_formatted = '(<span><b>' + sym.score + '</b></span>)'
+        }
         else {
           sym.score_formatted = '(<span class="text-danger"><b>' + sym.score + '</b></span>)'
         }
         var str = '<strong>' + key + '</strong> ' + sym.score_formatted;
         if (sym.options) {
-          str += ' [' + sym.options.join(",") + "]";
+          str += ' [' + sym.options.join(", ") + "]";
         }
-        item.symbols[key].str = str;
-      });
+        return str
+      }).join('<br>\n');
       item.subject = escapeHtml(item.subject);
-      item.symbols = Object.keys(item.symbols).
-      map(function(key) {
-        return item.symbols[key];
-      }).sort(function(e1, e2) {
-        return Math.abs(e1.score) < Math.abs(e2.score);
-      }).map(function(e) {
-        return e.str;
-      }).join("<br>\n");
       var scan_time = item.time_real.toFixed(3) + ' / ' + item.time_virtual.toFixed(3);
       item.scan_time = {
         "options": {

+ 6 - 0
data/web/js/site/quarantine.js

@@ -98,6 +98,12 @@ jQuery(function($){
           data.symbols.sort(function (a, b) {
             if (a.score === 0) return 1
             if (b.score === 0) return -1
+            if (b.score < 0 && a.score < 0) {
+              return a.score - b.score
+            }
+            if (b.score > 0 && a.score > 0) {
+              return b.score - a.score
+            }
             return b.score - a.score
           })
           $.each(data.symbols, function (index, value) {