From 45e97b37538c79f26a1ac932e59e8da76c0f8b03 Mon Sep 17 00:00:00 2001 From: FreddleSpl0it Date: Tue, 30 Aug 2022 15:59:16 +0200 Subject: [PATCH] [BS5] fix merging bugs --- data/web/css/build/013-mailcow.css | 80 ++++++- data/web/css/themes/mailcow-darkmode.css | 2 +- data/web/js/site/admin.js | 2 - data/web/js/site/debug.js | 140 ++++++----- .../templates/admin/tab-config-admins.twig | 1 - data/web/templates/base.twig | 15 +- data/web/templates/debug.twig | 2 + data/web/templates/edit/mailbox.twig | 2 +- data/web/templates/modals/footer.twig | 225 +++++++++++++----- data/web/templates/tfa_keys.twig | 6 +- data/web/templates/user/tab-user-auth.twig | 2 +- 11 files changed, 341 insertions(+), 136 deletions(-) diff --git a/data/web/css/build/013-mailcow.css b/data/web/css/build/013-mailcow.css index 88d82e0c..685eb80d 100644 --- a/data/web/css/build/013-mailcow.css +++ b/data/web/css/build/013-mailcow.css @@ -271,6 +271,28 @@ code { margin-right: 5px; } +.dropdown-header { + font-weight: 600; +} + +.dataTables_info { + margin: 15px 0 !important; + padding: 0px !important; +} +.dataTables_paginate, .dataTables_length, .dataTables_filter { + margin: 15px 0 !important; +} +.dtr-details { + width: 100%; +} +.dtr-title { + width: 20%; +} +table.dataTable>tbody>tr.child ul.dtr-details>li { + border-bottom: 1px solid rgba(239, 239, 239, 0.129); + padding: 0.5em 0; +} + .tag-box { display: flex; flex-wrap: wrap; @@ -315,4 +337,60 @@ code { border: 1px solid #dfdfdf; background-color: #f9f9f9; padding: 10px; -} \ No newline at end of file +} + +table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control:before:hover, +table.dataTable.dtr-inline.collapsed>tbody>tr>th.dtr-control:before:hover { + background-color: #5e5e5e; +} +table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control:before, +table.dataTable.dtr-inline.collapsed>tbody>tr>th.dtr-control:before, +table.dataTable td.dt-control:before { + background-color: #979797 !important; + border: 1.5px solid #616161 !important; + border-radius: 2px !important; + color: #fff; + height: 1em; + width: 1em; + line-height: 1.25em; + border-radius: 0px; + box-shadow: none; + font-size: 14px; + transition: 0.5s all; +} +table.dataTable.dtr-inline.collapsed>tbody>tr.parent>td.dtr-control:before, +table.dataTable.dtr-inline.collapsed>tbody>tr.parent>th.dtr-control:before, +table.dataTable td.dt-control:before { + background-color: #979797 !important; +} +table.dataTable.dtr-inline.collapsed>tbody>tr>td.child, +table.dataTable.dtr-inline.collapsed>tbody>tr>th.child, +table.dataTable.dtr-inline.collapsed>tbody>tr>td.dataTables_empty { + background-color: #fbfbfb; +} +table.dataTable.table-striped>tbody>tr>td { + vertical-align: middle; +} +table.dataTable.table-striped>tbody>tr>td>input[type="checkbox"] { + margin-top: 7px; +} + + +.btn-check-label { + color: #555; +} + +.caret { + transform: rotate(0deg); +} +a[aria-expanded='true'] > .caret, +button[aria-expanded='true'] > .caret { + transform: rotate(-180deg); +} + +.list-group-details { + background: #fff; +} +.list-group-header { + background: #f7f7f7; +} diff --git a/data/web/css/themes/mailcow-darkmode.css b/data/web/css/themes/mailcow-darkmode.css index a0388aa0..7a84ddaa 100644 --- a/data/web/css/themes/mailcow-darkmode.css +++ b/data/web/css/themes/mailcow-darkmode.css @@ -48,7 +48,7 @@ legend { border-color: #7a7a7a !important; } .modal-content { - background-color: #383838; + background-color: #414141; } .modal-header { border-bottom: 1px solid #161616; diff --git a/data/web/js/site/admin.js b/data/web/js/site/admin.js index 61268b02..dcedf856 100644 --- a/data/web/js/site/admin.js +++ b/data/web/js/site/admin.js @@ -77,7 +77,6 @@ jQuery(function($){ type: "GET", url: "/api/v1/get/domain-admin/all", dataSrc: function(data){ - console.log(data); return process_table_data(data, 'domainadminstable'); } }, @@ -133,7 +132,6 @@ jQuery(function($){ }, ], initComplete: function(settings, json){ - console.log(settings); } }); } diff --git a/data/web/js/site/debug.js b/data/web/js/site/debug.js index 0575c5a0..1e633673 100644 --- a/data/web/js/site/debug.js +++ b/data/web/js/site/debug.js @@ -44,7 +44,9 @@ $(document).ready(function() { // create host cpu and mem charts createHostCpuAndMemChart(); // check for new version - check_update(mailcow_info.version_tag, mailcow_info.project_url); + if (mailcow_info.branch === "master"){ + check_update(mailcow_info.version_tag, mailcow_info.project_url); + } update_container_stats() }); jQuery(function($){ @@ -1108,75 +1110,83 @@ function update_stats(timeout=5){ } // update specific container stats - every n (default 5s) seconds function update_container_stats(timeout=5){ - for (let container in containersToUpdate){ - container_id = containersToUpdate[container].id; - if (containersToUpdate[container].state == "running") - continue; - containersToUpdate[container].state = "running"; + + if ($('#tab-containers').hasClass('active')) { + for (let container in containersToUpdate){ + container_id = containersToUpdate[container].id; + // check if container update stats is already running + if (containersToUpdate[container].state == "running") + continue; + containersToUpdate[container].state = "running"; - window.fetch("/api/v1/get/status/container/" + container_id, {method:'GET',cache:'no-cache'}).then(function(response) { - return response.json(); - }).then(function(data) { - var diskIOCtx = Chart.getChart(container + "_DiskIOChart"); - var netIOCtx = Chart.getChart(container + "_NetIOChart"); + window.fetch("/api/v1/get/status/container/" + container_id, {method:'GET',cache:'no-cache'}).then(function(response) { + return response.json(); + }).then(function(data) { + var diskIOCtx = Chart.getChart(container + "_DiskIOChart"); + var netIOCtx = Chart.getChart(container + "_NetIOChart"); - console.log(container); - console.log(data); - prev_stats = null; - if (data.length >= 2) - prev_stats = data[data.length -2] - data = data[data.length -1]; + console.log(container); + console.log(data); + prev_stats = null; + if (data.length >= 2) + prev_stats = data[data.length -2] + data = data[data.length -1]; - if (prev_stats != null){ - // calc time diff - var time_diff = (new Date(data.read) - new Date(prev_stats.read)) / 1000; - - // calc disk io b/s - var prev_read_bytes = 0; - var prev_write_bytes = 0; - for (var i = 0; i < prev_stats.blkio_stats.io_service_bytes_recursive.length; i++){ - if (prev_stats.blkio_stats.io_service_bytes_recursive[i].op == "read") - prev_read_bytes = prev_stats.blkio_stats.io_service_bytes_recursive[i].value; - else if (prev_stats.blkio_stats.io_service_bytes_recursive[i].op == "write") - prev_write_bytes = prev_stats.blkio_stats.io_service_bytes_recursive[i].value; + if (prev_stats != null){ + // calc time diff + var time_diff = (new Date(data.read) - new Date(prev_stats.read)) / 1000; + + // calc disk io b/s + if ('io_service_bytes_recursive' in prev_stats.blkio_stats && prev_stats.blkio_stats.io_service_bytes_recursive !== null){ + var prev_read_bytes = 0; + var prev_write_bytes = 0; + for (var i = 0; i < prev_stats.blkio_stats.io_service_bytes_recursive.length; i++){ + if (prev_stats.blkio_stats.io_service_bytes_recursive[i].op == "read") + prev_read_bytes = prev_stats.blkio_stats.io_service_bytes_recursive[i].value; + else if (prev_stats.blkio_stats.io_service_bytes_recursive[i].op == "write") + prev_write_bytes = prev_stats.blkio_stats.io_service_bytes_recursive[i].value; + } + var read_bytes = 0; + var write_bytes = 0; + for (var i = 0; i < data.blkio_stats.io_service_bytes_recursive.length; i++){ + if (data.blkio_stats.io_service_bytes_recursive[i].op == "read") + read_bytes = data.blkio_stats.io_service_bytes_recursive[i].value; + else if (data.blkio_stats.io_service_bytes_recursive[i].op == "write") + write_bytes = data.blkio_stats.io_service_bytes_recursive[i].value; + } + var diff_bytes_read = (read_bytes - prev_read_bytes) / time_diff; + var diff_bytes_write = (write_bytes - prev_write_bytes) / time_diff; + } + + // calc net io b/s + if ('networks' in prev_stats){ + var prev_recv_bytes = 0; + var prev_sent_bytes = 0; + for (var key in prev_stats.networks){ + prev_recv_bytes += prev_stats.networks[key].rx_bytes; + prev_sent_bytes += prev_stats.networks[key].tx_bytes; + } + var recv_bytes = 0; + var sent_bytes = 0; + for (var key in data.networks){ + recv_bytes += data.networks[key].rx_bytes; + sent_bytes += data.networks[key].tx_bytes; + } + var diff_bytes_recv = (recv_bytes - prev_recv_bytes) / time_diff; + var diff_bytes_sent = (sent_bytes - prev_sent_bytes) / time_diff; + } + + addReadWriteChart(diskIOCtx, diff_bytes_read, diff_bytes_write, ""); + addReadWriteChart(netIOCtx, diff_bytes_recv, diff_bytes_sent, ""); } - var read_bytes = 0; - var write_bytes = 0; - for (var i = 0; i < data.blkio_stats.io_service_bytes_recursive.length; i++){ - if (data.blkio_stats.io_service_bytes_recursive[i].op == "read") - read_bytes = data.blkio_stats.io_service_bytes_recursive[i].value; - else if (data.blkio_stats.io_service_bytes_recursive[i].op == "write") - write_bytes = data.blkio_stats.io_service_bytes_recursive[i].value; - } - var diff_bytes_read = (read_bytes - prev_read_bytes) / time_diff; - var diff_bytes_write = (write_bytes - prev_write_bytes) / time_diff; - - // calc net io b/s - var prev_recv_bytes = 0; - var prev_sent_bytes = 0; - for (var key in prev_stats.networks){ - prev_recv_bytes += prev_stats.networks[key].rx_bytes; - prev_sent_bytes += prev_stats.networks[key].tx_bytes; - } - var recv_bytes = 0; - var sent_bytes = 0; - for (var key in data.networks){ - recv_bytes += data.networks[key].rx_bytes; - sent_bytes += data.networks[key].tx_bytes; - } - var diff_bytes_recv = (recv_bytes - prev_recv_bytes) / time_diff; - var diff_bytes_sent = (sent_bytes - prev_sent_bytes) / time_diff; - - addReadWriteChart(diskIOCtx, diff_bytes_read, diff_bytes_write, ""); - addReadWriteChart(netIOCtx, diff_bytes_recv, diff_bytes_sent, ""); - } - - // run again in n seconds - containersToUpdate[container].state = "idle"; - }).catch(err => { - console.log(err); - }); + + // run again in n seconds + containersToUpdate[container].state = "idle"; + }).catch(err => { + console.log(err); + }); + } } // run again in n seconds diff --git a/data/web/templates/admin/tab-config-admins.twig b/data/web/templates/admin/tab-config-admins.twig index 1d903b56..1d2d05f2 100644 --- a/data/web/templates/admin/tab-config-admins.twig +++ b/data/web/templates/admin/tab-config-admins.twig @@ -32,7 +32,6 @@
{{ lang.tfa.tfa }}:
-

{{ tfa_data.pretty }}

{% include 'tfa_keys.twig' %}
diff --git a/data/web/templates/base.twig b/data/web/templates/base.twig index 3a34f6ba..70de0234 100644 --- a/data/web/templates/base.twig +++ b/data/web/templates/base.twig @@ -143,7 +143,8 @@ updatedAt: '{{ mailcow_info.updatedAt }}', project_url: '{{ mailcow_info.project_url }}', project_owner: '{{ mailcow_info.project_owner }}', - project_repo: '{{ mailcow_info.project_repo }}' + project_repo: '{{ mailcow_info.project_repo }}', + branch: '{{ mailcow_info.mailcow_branch }}' }; $(window).scroll(function() { @@ -202,7 +203,7 @@ function recursiveBase64StrToArrayBuffer(obj) { {% endfor %} // Confirm TFA modal - {% if pending_tfa_method %} + {% if pending_tfa_methods %} new bootstrap.Modal(document.getElementById("ConfirmTFAModal"), { backdrop: 'static', keyboard: false @@ -270,6 +271,11 @@ function recursiveBase64StrToArrayBuffer(obj) { var id = $(this).children('input').first().val(); $("#webauthn_selected_id").val(id); + var webauthn_status_auth = document.getElementById('webauthn_status_auth'); + webauthn_status_auth.style.setProperty('display', 'flex', 'important'); + var webauthn_return_code = document.getElementById('webauthn_return_code'); + webauthn_return_code.style.setProperty('display', 'none', 'important'); + $("#collapseWebAuthnTFA").collapse('show'); $(this).find('input[name=token]').focus(); @@ -307,8 +313,11 @@ function recursiveBase64StrToArrayBuffer(obj) { auth.value = AuthenticatorAttestationResponse; form.submit(); }).catch(function(err) { + var webauthn_status_auth = document.getElementById('webauthn_status_auth'); + webauthn_status_auth.style.setProperty('display', 'none', 'important'); + var webauthn_return_code = document.getElementById('webauthn_return_code'); - webauthn_return_code.style.display = webauthn_return_code.style.display === 'none' ? '' : null; + webauthn_return_code.style.setProperty('display', 'block', 'important'); webauthn_return_code.innerHTML = lang_tfa.error_code + ': ' + err + ' ' + lang_tfa.reload_retry; }); } diff --git a/data/web/templates/debug.twig b/data/web/templates/debug.twig index 61847759..3465da6e 100644 --- a/data/web/templates/debug.twig +++ b/data/web/templates/debug.twig @@ -56,12 +56,14 @@

+ {% if mailcow_info.mailcow_branch|lower == "master" %} Changelog {{ mailcow_info.project_url }}/releases/tag/{{ mailcow_info.version_tag }} + {% endif %} {{ lang.debug.current_time }} - diff --git a/data/web/templates/edit/mailbox.twig b/data/web/templates/edit/mailbox.twig index a503a151..0f72afc6 100644 --- a/data/web/templates/edit/mailbox.twig +++ b/data/web/templates/edit/mailbox.twig @@ -40,7 +40,7 @@
diff --git a/data/web/templates/modals/footer.twig b/data/web/templates/modals/footer.twig index 87e36514..d8b2b5a4 100644 --- a/data/web/templates/modals/footer.twig +++ b/data/web/templates/modals/footer.twig @@ -136,67 +136,176 @@