public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
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
[Web] Filter tables by Domain where possible
This feature was standard in Mailcow in pre-BS5 releases Signed-off-by: Kristian Feldsam <[email protected]>
8e5cd907
data/web/js/site/mailbox.js | 46 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 42 insertions(+), 4 deletions(-)
Diff
diff --git a/data/web/js/site/mailbox.js b/data/web/js/site/mailbox.js
index 3ddeea94..8381ab4d 100644
--- a/data/web/js/site/mailbox.js
+++ b/data/web/js/site/mailbox.js
@@ -851,8 +851,9 @@ jQuery(function($){
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
- initComplete: function(){
+ initComplete: function(settings, json){
hideTableExpandCollapseBtn('#tab-mailboxes', '#mailbox_table');
+ filterByDomain(json, 8, table);
},
ajax: {
type: "GET",
@@ -1362,8 +1363,9 @@ jQuery(function($){
"tr" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
- initComplete: function(){
+ initComplete: function(settings, json){
hideTableExpandCollapseBtn('#tab-resources', '#resource_table');
+ filterByDomain(json, 5, table);
},
ajax: {
type: "GET",
@@ -1509,8 +1511,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[2, 'desc']],
- initComplete: function(){
+ initComplete: function(settings, json){
hideTableExpandCollapseBtn('#collapse-tab-bcc', '#bcc_table');
+ filterByDomain(json, 6, table);
},
ajax: {
type: "GET",
@@ -1823,8 +1826,9 @@ jQuery(function($){
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
language: lang_datatables,
order: [[2, 'desc']],
- initComplete: function(){
+ initComplete: function(settings, json){
hideTableExpandCollapseBtn('#tab-mbox-aliases', '#alias_table');
+ filterByDomain(json, 5, table);
},
ajax: {
type: "GET",
@@ -2329,6 +2333,40 @@ jQuery(function($){
else
$(tab).find(".table_collapse_option").hide();
}
+
+ function filterByDomain(json, column, table){
+ var tableId = $(table.table().container()).attr('id');
+ // Create the `select` element
+ var select = $('<select class="btn btn-sm btn-xs-lg btn-light text-start mx-2"><option value="">'+lang.all_domains+'</option></select>')
+ .insertBefore(
+ $('#'+tableId+' .dataTables_filter > label > input')
+ )
+ .on( 'change', function(){
+ table.column(column)
+ .search($(this).val())
+ .draw();
+ });
+
+ // get all domains
+ var domains = [];
+ json.forEach(obj => {
+ Object.entries(obj).forEach(([key, value]) => {
+ if(key === 'domain') {
+ domains.push(value)
+ }
+ });
+ });
+
+ // get unique domain list
+ domains = domains.filter(function(value, index, array) {
+ return array.indexOf(value) === index;
+ });
+
+ // add domains to select
+ domains.forEach(function(domain) {
+ select.append($('<option>' + domain + '</option>'));
+ });
+ }
// detect element visibility changes
function onVisible(element, callback) {