Work on issue 192

This commit is contained in:
Pinga 2024-12-06 14:14:22 +02:00
parent 60b682c402
commit 561f8f514e
5 changed files with 262 additions and 76 deletions

View file

@ -20,24 +20,6 @@
<a class="btn btn-outline-danger btn-icon delete-btn" id="delete-btn" href="javascript:void(0);" data-delete-url="contact/delete/${cell.getRow().getData().identifier}"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M4 7h16"></path><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12"></path><path d="M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"></path><path d="M10 12l4 4m0 -4l-4 4"></path></svg></a>
`;
}
function statusFormatter(cell) {
var statusArray = cell.getValue();
var rowData = cell.getRow().getData(); // Get the entire row data
// Function to create a badge
function createBadge(text, badgeClass) {
return `<span class="status status-${badgeClass}">${text}</span>`;
}
// Check if statusArray is empty or not
if (statusArray && Array.isArray(statusArray) && statusArray.length > 0) {
return statusArray.map(item => createBadge(item.status, 'azure')).join(' ');
} else {
// Fallback to rgpstatus column if statusArray is empty
return rowData.rgpstatus ? createBadge(rowData.rgpstatus, 'lime') : "";
}
}
var searchTerm = ""; // global variable to hold the search term
@ -50,21 +32,29 @@
pagination: true,
paginationMode: "remote",
paginationSize: 10,
sortMode: "remote",
ajaxURL: "/api/records/contact",
ajaxParams: {
join: "contact_status"
},
ajaxURLGenerator: function(url, config, params) {
var queryParts = ["join=contact_status"];
var queryParts = [];
// Handle search term
if (searchTerm) {
queryParts.push("filter1=identifier,cs," + encodeURIComponent(searchTerm));
queryParts.push("filter2=email,cs," + encodeURIComponent(searchTerm));
queryParts.push("filter3=voice,cs," + encodeURIComponent(searchTerm));
queryParts.push("filter4=crdate,cs," + encodeURIComponent(searchTerm));
}
queryParts.push("order=id");
// Handle sorting from Tabulator
if (params.sort && params.sort.length > 0) {
var sorter = params.sort[0]; // single-column sorting
var sortField = encodeURIComponent(sorter.field);
var sortDir = (sorter.dir === "asc" ? "asc" : "desc");
queryParts.push("order=" + sortField + "," + sortDir);
} else {
// fallback default order if no sorters
queryParts.push("order=id,desc");
}
// Include pagination parameters
if (params.page) {
@ -85,9 +75,6 @@
return { last_page: 1, data: [] };
}
},
dataReceiveParams: {
"last_page": "results", // Mapping 'results' to 'last_page'
},
layout:"fitDataFill",
responsiveLayout: "collapse",
responsiveLayoutCollapseStartOpen:false,
@ -95,10 +82,10 @@
placeholder: "{{ __('No Data') }}",
columns:[
{formatter:"responsiveCollapse", width:30, minWidth:30, hozAlign:"center", resizable:false, headerSort:false, responsive:0},
{title:"{{ __('Identifier') }}", field:"identifier", width:250, resizable:false, headerSort:false, formatter: contactLinkFormatter, responsive:0},
{title:"{{ __('Email') }}", field:"email", width:300, minWidth:200, resizable:false, headerSort:false, responsive:2},
{title:"{{ __('Phone') }}", field:"voice", width:300, minWidth:200, resizable:false, headerSort:false, responsive:2},
{title:"{{ __('Status') }}", field:"contact_status", width:200, minWidth:100, formatter: statusFormatter, resizable:false, headerSort:false, download:false, responsive:2},
{title:"{{ __('Identifier') }}", field:"identifier", width:250, resizable:false, headerSort:true, formatter: contactLinkFormatter, responsive:0},
{title:"{{ __('Email') }}", field:"email", width:300, minWidth:200, resizable:false, headerSort:true, responsive:2},
{title:"{{ __('Phone') }}", field:"voice", width:200, minWidth:100, resizable:false, headerSort:true, responsive:2},
{title:"{{ __('Creation Date') }}", field:"crdate", width:280, minWidth:100, resizable:true, headerSort:true, responsive:2},
{title: "{{ __('Actions') }}", formatter: actionsFormatter, resizable:false, headerSort:false, download:false, hozAlign: "center", responsive:0, cellClick: function(e, cell){
if (e.target.closest('.delete-btn')) {
e.preventDefault(); // Prevent the default link behavior
@ -117,8 +104,13 @@
]
});
var searchInput = document.getElementById("search-input");
let searchTimeout;
searchInput.addEventListener("input", function () {
clearTimeout(searchTimeout);
searchTimeout = setTimeout(() => {
updateSearchTerm(searchInput.value);
}, 300); // 300ms delay
});
});

View file

@ -47,10 +47,10 @@
// Check if statusArray is empty or not
if (statusArray && Array.isArray(statusArray) && statusArray.length > 0) {
return statusArray.map(item => createBadge(item.status, 'azure')).join(' ');
return statusArray.map(item => createBadge(item.status, 'green')).join(' ');
} else if (rowData.rgpstatus) {
// Fallback to rgpstatus column if statusArray is empty
return createBadge(rowData.rgpstatus, 'lime');
return createBadge(rowData.rgpstatus, 'info');
} else {
// Display 'ok' status with info badge if both statusArray and rgpstatus are empty
return createBadge('ok', 'info');
@ -68,22 +68,30 @@
pagination: true,
paginationMode: "remote",
paginationSize: 10,
ajaxURL: "/api/records/domain",
ajaxParams: {
join: "contact",
join: "domain_status"
},
sortMode: "remote",
ajaxURL: "/dapi/domains",
ajaxURLGenerator: function(url, config, params) {
var queryParts = ["join=contact", "join=domain_status"];
var queryParts = [];
// Handle search term
if (searchTerm) {
queryParts.push("filter1=name,cs," + encodeURIComponent(searchTerm));
queryParts.push("filter2=crdate,cs," + encodeURIComponent(searchTerm));
queryParts.push("filter3=exdate,cs," + encodeURIComponent(searchTerm));
queryParts.push("filter4=registrant_identifier,cs," + encodeURIComponent(searchTerm));
queryParts.push("filter5=name_o,cs," + encodeURIComponent(searchTerm));
}
queryParts.push("order=crdate,desc");
// Handle sorting from Tabulator
if (params.sort && params.sort.length > 0) {
var sorter = params.sort[0]; // single-column sorting
var sortField = encodeURIComponent(sorter.field);
var sortDir = (sorter.dir === "asc" ? "asc" : "desc");
queryParts.push("order=" + sortField + "," + sortDir);
} else {
// fallback default order if no sorters
queryParts.push("order=crdate,desc");
}
// Include pagination parameters
if (params.page) {
@ -104,9 +112,6 @@
return { last_page: 1, data: [] };
}
},
dataReceiveParams: {
"last_page": "results", // Mapping 'results' to 'last_page'
},
layout:"fitDataFill",
responsiveLayout: "collapse",
responsiveLayoutCollapseStartOpen:false,
@ -114,11 +119,11 @@
placeholder: "{{ __('No Data') }}",
columns:[
{formatter:"responsiveCollapse", width:30, minWidth:30, hozAlign:"center", resizable:false, headerSort:false, responsive:0},
{title:"{{ __('Name') }}", field:"name", width:200, resizable:false, headerSort:false, formatter: domainLinkFormatter, responsive:0},
{title:"{{ __('Registrant') }}", width:200, field:"registrant.identifier", resizable:false, headerSort:false, responsive:2},
{title:"{{ __('Creation Date') }}", width:250, minWidth:150, field:"crdate", resizable:false, headerSort:false, responsive:2},
{title:"{{ __('Expiration Date') }}", width:250, minWidth:150, field:"exdate", resizable:false, headerSort:false, responsive:2},
{title:"{{ __('Status') }}", width:150, field:"domain_status", formatter: statusFormatter, resizable:false, headerSort:false, download:false, responsive:2},
{title:"{{ __('Name') }}", field:"name", width:200, resizable:false, headerSort:true, formatter: domainLinkFormatter, responsive:0},
{title:"{{ __('Registrant') }}", width:200, field:"registrant_identifier", resizable:false, headerSort:true, responsive:2},
{title:"{{ __('Creation Date') }}", width:250, minWidth:150, field:"crdate", resizable:false, headerSort:true, responsive:2},
{title:"{{ __('Expiration Date') }}", width:250, minWidth:150, field:"exdate", resizable:false, headerSort:true, responsive:2},
{title:"{{ __('Status') }}", width:150, field:"domain_status", formatter: statusFormatter, resizable:false, headerSort:true, download:false, responsive:2},
{title: "{{ __('Actions') }}", formatter: actionsFormatter, resizable:false, headerSort:false, download:false, hozAlign: "center", responsive:0, cellClick: function(e, cell){
if (e.target.closest('.delete-btn')) {
e.preventDefault(); // Prevent the default link behavior
@ -161,8 +166,13 @@
]
});
var searchInput = document.getElementById("search-input");
let searchTimeout;
searchInput.addEventListener("input", function () {
clearTimeout(searchTimeout);
searchTimeout = setTimeout(() => {
updateSearchTerm(searchInput.value);
}, 300); // 300ms delay
});
});

View file

@ -21,24 +21,6 @@
`;
}
function statusFormatter(cell) {
var statusArray = cell.getValue();
var rowData = cell.getRow().getData(); // Get the entire row data
// Function to create a badge
function createBadge(text, badgeClass) {
return `<span class="status status-${badgeClass}">${text}</span>`;
}
// Check if statusArray is empty or not
if (statusArray && Array.isArray(statusArray) && statusArray.length > 0) {
return statusArray.map(item => createBadge(item.status, 'azure')).join(' ');
} else {
// Fallback to rgpstatus column if statusArray is empty
return rowData.rgpstatus ? createBadge(rowData.rgpstatus, 'lime') : "";
}
}
var searchTerm = ""; // global variable to hold the search term
function updateSearchTerm(term) {
@ -50,20 +32,28 @@
pagination: true,
paginationMode: "remote",
paginationSize: 10,
sortMode: "remote",
ajaxURL: "/api/records/host",
ajaxParams: {
join: "host_status"
},
ajaxURLGenerator: function(url, config, params) {
var queryParts = ["join=host_status"];
var queryParts = [];
// Handle search term
if (searchTerm) {
queryParts.push("filter1=name,cs," + encodeURIComponent(searchTerm));
queryParts.push("filter2=crdate,cs," + encodeURIComponent(searchTerm));
queryParts.push("filter3=lastupdate,cs," + encodeURIComponent(searchTerm));
}
queryParts.push("order=id");
// Handle sorting from Tabulator
if (params.sort && params.sort.length > 0) {
var sorter = params.sort[0]; // single-column sorting
var sortField = encodeURIComponent(sorter.field);
var sortDir = (sorter.dir === "asc" ? "asc" : "desc");
queryParts.push("order=" + sortField + "," + sortDir);
} else {
// fallback default order if no sorters
queryParts.push("order=name,asc");
}
// Include pagination parameters
if (params.page) {
@ -84,9 +74,6 @@
return { last_page: 1, data: [] };
}
},
dataReceiveParams: {
"last_page": "results", // Mapping 'results' to 'last_page'
},
layout:"fitDataFill",
responsiveLayout: "collapse",
responsiveLayoutCollapseStartOpen:false,
@ -94,9 +81,9 @@
placeholder: "{{ __('No Data') }}",
columns:[
{formatter:"responsiveCollapse", width:30, minWidth:30, hozAlign:"center", resizable:false, headerSort:false, responsive:0},
{title:"{{ __('Host Name') }}", field:"name", width:300, resizable:false, headerSort:false, formatter: hostLinkFormatter, responsive:0},
{title:"{{ __('Creation Date') }}", field:"crdate", width:300, minWidth:200, resizable:false, headerSort:false, responsive:2},
{title:"{{ __('Status') }}", field:"host_status", width:300, minWidth:200, formatter: statusFormatter, resizable:false, headerSort:false, download:false, responsive:2},
{title:"{{ __('Host Name') }}", field:"name", width:300, minWidth:150, resizable:false, headerSort:true, formatter: hostLinkFormatter, responsive:0},
{title:"{{ __('Creation Date') }}", field:"crdate", width:300, minWidth:200, resizable:false, headerSort:true, responsive:2},
{title:"{{ __('Last Updated') }}", field:"lastupdate", width:300, minWidth:200, resizable:false, headerSort:true, responsive:2},
{title: "{{ __('Actions') }}", formatter: actionsFormatter, resizable:false, headerSort:false, download:false, hozAlign: "center", responsive:0, cellClick: function(e, cell){
if (e.target.closest('.delete-btn')) {
e.preventDefault(); // Prevent the default link behavior
@ -116,8 +103,13 @@
});
var searchInput = document.getElementById("search-input");
let searchTimeout;
searchInput.addEventListener("input", function () {
clearTimeout(searchTimeout);
searchTimeout = setTimeout(() => {
updateSearchTerm(searchInput.value);
}, 300); // 300ms delay
});
});