NobGit
public nobgit read

NobMail

Based on mailcow: dockerized

Languages

Repository composition by tracked source files.

PHP
PHP 49% JavaScript 35% HTML 9% CSS 4% Shell 2% Python 1% Lua 0% Perl 0% Ruby 0% SCSS 0%
Create file Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git

Commit

Fixed queue message error

75fdeb28
DerLinkman <[email protected]> 3 years, 9 months ago
data/Dockerfiles/dockerapi/dockerapi.py |  2 +-
 data/web/js/site/queue.js               | 14 +++++++++-----
 data/web/queue.php                      |  1 +
 data/web/templates/modals/admin.twig    | 14 --------------
 data/web/templates/modals/queue.twig    | 14 ++++++++++++++
 data/web/templates/queue.twig           |  5 ++++-
 6 files changed, 29 insertions(+), 21 deletions(-)
 create mode 100644 data/web/templates/modals/queue.twig

Diff

diff --git a/data/Dockerfiles/dockerapi/dockerapi.py b/data/Dockerfiles/dockerapi/dockerapi.py
index 965fc906..03ed5ef0 100644
--- a/data/Dockerfiles/dockerapi/dockerapi.py
+++ b/data/Dockerfiles/dockerapi/dockerapi.py
@@ -248,7 +248,7 @@ class DockerUtils:
         for container in (await self.docker_client.containers.list()):
           if container._id == container_id:
             postcat_exec = await container.exec(["/bin/bash", "-c", "/usr/sbin/postcat -q " + sanitized_string], user='postfix')
-            return exec_run_handler('utf8_text_only', postcat_exec)
+            return await exec_run_handler('utf8_text_only', postcat_exec)
 
    # api call: container_post - post_action: exec - cmd: mailq - task: unhold
   async def container_post__exec__mailq__unhold(self, container_id, request_json):
diff --git a/data/web/js/site/queue.js b/data/web/js/site/queue.js
index 88e48d97..057ad840 100644
--- a/data/web/js/site/queue.js
+++ b/data/web/js/site/queue.js
@@ -6,6 +6,9 @@ jQuery(function($){
       $('#' + table_name).DataTable().ajax.reload();
     });
 
+
+    function humanFileSize(i){if(Math.abs(i)<1024)return i+" B";var B=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],e=-1;do{i/=1024,++e}while(Math.abs(i)>=1024&&e<B.length-1);return i.toFixed(1)+" "+B[e]}
+
     // Queue item
     $('#showQueuedMsg').on('show.bs.modal', function (e) {
       $('#queue_msg_content').text(lang.loading);
@@ -18,6 +21,7 @@ jQuery(function($){
           url: '/api/v1/get/postcat/' + button.data('queue-id'),
           dataType: 'text',
           complete: function (data) {
+            console.log(data);
             $('#queue_msg_content').text(data.responseText);
           }
       });
@@ -78,7 +82,7 @@ jQuery(function($){
             defaultContent: ''
           },
           {
-            title: lang.arrival_time,
+            title: lang_admin.arrival_time,
             data: 'arrival_time',
             defaultContent: '',
             render: function (data, type){
@@ -87,7 +91,7 @@ jQuery(function($){
             }
           },
           {
-            title: lang.message_size,
+            title: lang_admin.message_size,
             data: 'message_size',
             defaultContent: '',
             render: function (data, type){
@@ -95,17 +99,17 @@ jQuery(function($){
             }
           },
           {
-            title: lang.sender,
+            title: lang_admin.sender,
             data: 'sender',
             defaultContent: ''
           },
           {
-            title: lang.recipients,
+            title: lang_admin.recipients,
             data: 'recipients',
             defaultContent: ''
           },
           {
-            title: lang.action,
+            title: lang_admin.action,
             data: 'action',
             className: 'text-md-end dt-sm-head-hidden dt-body-right',
             defaultContent: ''
diff --git a/data/web/queue.php b/data/web/queue.php
index 18c3b563..ffce8d8b 100644
--- a/data/web/queue.php
+++ b/data/web/queue.php
@@ -19,6 +19,7 @@ $template_data = [
   'acl_json' => json_encode($_SESSION['acl']),
   'role' => $role,
   'lang_admin' => json_encode($lang['admin']),
+  'lang_queue' => json_encode($lang['queue']),
   'lang_datatables' => json_encode($lang['datatables'])
 ];
 
diff --git a/data/web/templates/modals/admin.twig b/data/web/templates/modals/admin.twig
index a67e4848..15971e59 100644
--- a/data/web/templates/modals/admin.twig
+++ b/data/web/templates/modals/admin.twig
@@ -233,20 +233,6 @@
     </div>
   </div>
 </div><!-- test transport modal -->
-<!-- show queue item modal -->
-<div class="modal fade" id="showQueuedMsg" tabindex="-1" role="dialog" aria-hidden="true">
-  <div class="modal-dialog modal-xl">
-    <div class="modal-content">
-      <div class="modal-header">
-        <h3 class="modal-title"><i class="bi bi-card-checklist" style="font-size:18px"></i> ID <span id="queue_id"></span></h3>
-        <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
-      </div>
-      <div class="modal-body">
-        <textarea class="form-control" id="queue_msg_content" name="content" rows="40"></textarea>
-      </div>
-    </div>
-  </div>
-</div><!-- show queue item modal -->
 <!-- priv key modal -->
 <div class="modal fade" id="showDKIMprivKey" tabindex="-1" role="dialog" aria-hidden="true">
   <div class="modal-dialog">
diff --git a/data/web/templates/modals/queue.twig b/data/web/templates/modals/queue.twig
new file mode 100644
index 00000000..68fe9125
--- /dev/null
+++ b/data/web/templates/modals/queue.twig
@@ -0,0 +1,14 @@
+<!-- show queue item modal -->
+<div class="modal fade" id="showQueuedMsg" tabindex="-1" role="dialog" aria-hidden="true">
+  <div class="modal-dialog modal-xl">
+    <div class="modal-content">
+      <div class="modal-header">
+        <h3 class="modal-title"><i class="bi bi-card-checklist" style="font-size:18px"></i> ID <span id="queue_id"></span></h3>
+        <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
+      </div>
+      <div class="modal-body">
+        <textarea class="form-control" id="queue_msg_content" name="content" rows="40"></textarea>
+      </div>
+    </div>
+  </div>
+</div><!-- show queue item modal -->
\ No newline at end of file
diff --git a/data/web/templates/queue.twig b/data/web/templates/queue.twig
index 49c9f8ad..22c36a27 100644
--- a/data/web/templates/queue.twig
+++ b/data/web/templates/queue.twig
@@ -41,8 +41,11 @@
     </div>
   </div>
 
+{% include 'modals/queue.twig' %}
+
 <script type='text/javascript'>
-  var lang = {{ lang_admin|raw }};
+  var lang_admin = {{ lang_admin|raw }};
+  var lang = {{ lang_queue|raw }};
   var lang_datatables = {{ lang_datatables|raw }};
   var csrf_token = '{{ csrf_token }}';
   var pagination_size = '{{ pagination_size }}';