Added list of applications in panel

This commit is contained in:
Pinga 2023-12-17 10:33:24 +02:00
parent 11b5f212a5
commit fe1de8938d
5 changed files with 245 additions and 2 deletions

View file

@ -14,6 +14,11 @@ class DomainsController extends Controller
return view($response,'admin/domains/listDomains.twig');
}
public function listApplications(Request $request, Response $response)
{
return view($response,'admin/domains/listApplications.twig');
}
public function checkDomain(Request $request, Response $response)
{
if ($request->getMethod() === 'POST') {

View file

@ -0,0 +1,83 @@
{% extends "layouts/app.twig" %}
{% block title %}{{ __('Applications') }}{% endblock %}
{% block content %}
<div class="page-wrapper">
<!-- Page header -->
<div class="page-header d-print-none">
<div class="container-xl">
<div class="row g-2 align-items-center">
<div class="col">
<!-- Page pre-title -->
<div class="page-pretitle">
{{ __('Overview') }}
</div>
<h2 class="page-title">
{{ __('Applications') }}
</h2>
</div>
<!-- Page title actions -->
<div class="col-auto ms-auto d-print-none">
<div class="btn-list">
<span class="d-none d-sm-inline">
<a href="{{route('checkDomain')}}" class="btn">
{{ __('Check Domain') }}
</a>
</span>
<a href="{{route('createDomain')}}" class="btn btn-primary d-none d-sm-inline-block">
<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"/><line x1="12" y1="5" x2="12" y2="19" /><line x1="5" y1="12" x2="19" y2="12" /></svg>
{{ __('Create Domain') }}
</a>
<a href="{{route('createDomain')}}" class="btn btn-primary d-sm-none btn-icon" aria-label="{{ __('Create Domain') }}">
<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"/><line x1="12" y1="5" x2="12" y2="19" /><line x1="5" y1="12" x2="19" y2="12" /></svg>
</a>
</div>
</div>
</div>
</div>
</div>
<!-- Page body -->
<div class="page-body">
<div class="container-xl">
<div class="col-12">
{% include 'partials/flash.twig' %}
<div class="card">
<div class="card-body border-bottom py-3">
<div class="d-flex">
<div class="text-secondary">
<button class="btn btn-info btn-icon" onclick="downloadCSV()" title="Export page"><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="M10 15a1 1 0 0 0 1 1h2a1 1 0 0 0 1 -1v-2a1 1 0 0 0 -1 -1h-2a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1"></path><path d="M17 8l2 8l2 -8"></path><path d="M7 10a2 2 0 1 0 -4 0v4a2 2 0 1 0 4 0"></path></svg></button>
<button class="btn btn-info btn-icon" onclick="downloadJSON()" title="Export page"><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="M20 16v-8l3 8v-8"></path><path d="M15 8a2 2 0 0 1 2 2v4a2 2 0 1 1 -4 0v-4a2 2 0 0 1 2 -2z"></path><path d="M1 8h3v6.5a1.5 1.5 0 0 1 -3 0v-.5"></path><path d="M7 15a1 1 0 0 0 1 1h1a1 1 0 0 0 1 -1v-2a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1h1a1 1 0 0 1 1 1"></path></svg></button>
<button class="btn btn-green btn-icon" onclick="downloadXLSX()" title="Export page"><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="M14 3v4a1 1 0 0 0 1 1h4"></path><path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"></path><path d="M4 15l4 6"></path><path d="M4 21l4 -6"></path><path d="M17 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"></path><path d="M11 15v6h3"></path></svg></button>
<button class="btn btn-red btn-icon" onclick="downloadPDF()" title="Export page"><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="M10 8v8h2a2 2 0 0 0 2 -2v-4a2 2 0 0 0 -2 -2h-2z"></path><path d="M3 12h2a2 2 0 1 0 0 -4h-2v8"></path><path d="M17 12h3"></path><path d="M21 8h-4v8"></path></svg></button>
</div>
<div class="ms-auto text-secondary">
Search:
<div class="ms-2 d-inline-block">
<input id="search-input" type="text" class="form-control" aria-label="Search applications" autocapitalize="none">
</div>
</div>
</div>
<div class="table-responsive mt-3">
<div id="applicationTable"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<footer class="footer footer-transparent d-print-none">
<div class="container-xl">
<div class="col-12 col-lg-auto mt-3 mt-lg-0">
<ul class="list-inline list-inline-dots mb-0">
<li class="list-inline-item">
Copyright &copy; 2023
<a href="https://namingo.org" target="_blank" class="link-secondary">Namingo</a>.
</li>
</ul>
</div>
</div>
</div>
</footer>
</div>
{% endblock %}

View file

@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
<title>{% block title %}{% endblock %} | Namingo</title>
<!-- CSS files -->
{% if route_is('domains') or route_is('contacts') or route_is('hosts') or route_is('epphistory') or route_is('registrars') or route_is('transactions') or route_is('overview') or route_is('reports') or route_is('transfers') or route_is('users') or route_is('support') or route_is('poll') or route_is('log') or route_is('invoices') or route_is('registry/tlds') %}
{% if route_is('domains') or route_is('applications') or route_is('contacts') or route_is('hosts') or route_is('epphistory') or route_is('registrars') or route_is('transactions') or route_is('overview') or route_is('reports') or route_is('transfers') or route_is('users') or route_is('support') or route_is('poll') or route_is('log') or route_is('invoices') or route_is('registry/tlds') %}
{% include 'partials/css-tables.twig' %}
{% else %}
{% include 'partials/css.twig' %}
@ -83,7 +83,7 @@
</span>
</a>
</li>
<li {{ is_current_url('listDomains') or is_current_url('checkDomain') or is_current_url('createDomain') or is_current_url('listTransfers') or is_current_url('requestTransfer') or 'domain' in currentUri ? 'class="nav-item dropdown active"' : 'class="nav-item dropdown"' }}>
<li {{ is_current_url('listDomains') or is_current_url('listApplications') or is_current_url('checkDomain') or is_current_url('createDomain') or is_current_url('listTransfers') or is_current_url('requestTransfer') or 'domain' in currentUri ? 'class="nav-item dropdown active"' : 'class="nav-item dropdown"' }}>
<a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" data-bs-auto-close="outside" role="button" aria-expanded="false">
<span class="nav-link-icon d-md-none d-lg-inline-block"><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="M19.5 7a9 9 0 0 0 -7.5 -4a8.991 8.991 0 0 0 -7.484 4"></path><path d="M11.5 3a16.989 16.989 0 0 0 -1.826 4"></path><path d="M12.5 3a16.989 16.989 0 0 1 1.828 4"></path><path d="M19.5 17a9 9 0 0 1 -7.5 4a8.991 8.991 0 0 1 -7.484 -4"></path><path d="M11.5 21a16.989 16.989 0 0 1 -1.826 -4"></path><path d="M12.5 21a16.989 16.989 0 0 0 1.828 -4"></path><path d="M2 10l1 4l1.5 -4l1.5 4l1 -4"></path><path d="M17 10l1 4l1.5 -4l1.5 4l1 -4"></path><path d="M9.5 10l1 4l1.5 -4l1.5 4l1 -4"></path></svg>
</span>
@ -102,6 +102,10 @@
{{ __('Create Domain') }}
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{{route('listApplications')}}">
{{ __('List Applications') }}
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{{route('listTransfers')}}">
{{ __('Transfers') }}
</a>
@ -255,6 +259,8 @@
{% include 'partials/js-dash.twig' %}
{% elseif route_is('domains') %}
{% include 'partials/js-domains.twig' %}
{% elseif route_is('applications') %}
{% include 'partials/js-applications.twig' %}
{% elseif route_is('contacts') %}
{% include 'partials/js-contacts.twig' %}
{% elseif route_is('hosts') %}

View file

@ -0,0 +1,147 @@
<script src="/assets/js/tabulator.min.js" defer></script>
<script src="/assets/js/tabler.min.js" defer></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.6.0/jspdf.plugin.autotable.min.js"></script>
<script>
var table;
document.addEventListener("DOMContentLoaded", function(){
function domainLinkFormatter(cell){
var value = cell.getValue();
return `<a href="/domain/view/${value}" style="font-weight:bold;">${value}</a>`;
}
function actionsFormatter(cell, formatterParams, onRendered) {
var rowData = cell.getRow().getData();
var actionButtons = '';
var hasPendingDelete = rowData.domain_status.some(statusObj => statusObj.status && statusObj.status.includes('pendingDelete'));
var hasPendingRestore = rowData.rgpstatus ? rowData.rgpstatus.includes('pendingRestore') : false;
// Common action button for all statuses
actionButtons += `<a class="btn btn-info btn-icon" href="domain/update/${cell.getRow().getData().name}" title="Update Domain"><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="M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1"></path><path d="M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z"></path><path d="M16 5l3 3"></path></svg></a> `;
if (hasPendingRestore) {
actionButtons += `<a class="btn btn-outline-dark btn-icon" href="domain/report/${cell.getRow().getData().name}" title="Submit Report"><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 d="M3.06 13a9 9 0 1 0 .49 -4.087" /><path d="M3 4.001v5h5" /><path d="M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" /></svg></a>`;
} else if (hasPendingDelete) {
actionButtons += `<a class="btn btn-outline-warning btn-icon" href="domain/restore/${cell.getRow().getData().name}" title="Restore Domain"><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 d="M15 4.55a8 8 0 0 0 -6 14.9m0 -4.45v5h-5" /><path d="M18.37 7.16l0 .01" /><path d="M13 19.94l0 .01" /><path d="M16.84 18.37l0 .01" /><path d="M19.37 15.1l0 .01" /><path d="M19.94 11l0 .01" /></svg></a>`;
} else {
actionButtons += `<a class="btn btn-success btn-icon" href="domain/renew/${cell.getRow().getData().name}" title="Renew Domain"><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="M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"></path><path d="M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"></path></svg></a> `;
actionButtons += `<a class="btn btn-danger btn-icon" href="domain/delete/${cell.getRow().getData().name}" title="Delete Domain"><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>`;
}
return actionButtons;
}
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="badge bg-${badgeClass}-lt">${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 if (rowData.rgpstatus) {
// Fallback to rgpstatus column if statusArray is empty
return createBadge(rowData.rgpstatus, 'lime');
} else {
// Display 'ok' status with info badge if both statusArray and rgpstatus are empty
return createBadge('ok', 'info');
}
}
var searchTerm = ""; // global variable to hold the search term
function updateSearchTerm(term) {
searchTerm = term;
table.replaceData();
}
table = new Tabulator("#applicationTable", {
pagination: true,
paginationMode: "remote",
paginationSize: 10,
ajaxURL: "/api/records/application",
ajaxParams: {
join: "contact"
},
ajaxURLGenerator: function(url, config, params) {
var queryParts = ["join=contact"];
// Handle search term
if (searchTerm) {
queryParts.push("filter1=name,cs," + encodeURIComponent(searchTerm));
queryParts.push("filter2=crdate,cs," + encodeURIComponent(searchTerm));
}
queryParts.push("order=id");
// Include pagination parameters
if (params.page) {
queryParts.push("page=" + params.page + "," + params.size);
}
return url + "?" + queryParts.join("&");
},
ajaxResponse: function(url, params, response) {
if (response && Array.isArray(response.records) && typeof response.results === 'number') {
var lastPage = Math.ceil(response.results / this.options.paginationSize);
return {
last_page: lastPage, // Calculated total number of pages
data: response.records, // Data for the current page
};
} else {
console.error('Unexpected response format', response);
return { last_page: 1, data: [] };
}
},
dataReceiveParams: {
"last_page": "results", // Mapping 'results' to 'last_page'
},
layout:"fitDataFill",
responsiveLayout: "collapse",
responsiveLayoutCollapseStartOpen:false,
resizableColumns:false,
columns:[
{formatter:"responsiveCollapse", width:30, minWidth:30, hozAlign:"center", resizable:false, headerSort:false, responsive:0},
{title:"Name", field:"name", width:200, headerSort:false, formatter: domainLinkFormatter, responsive:0},
{title:"Applicant", width:200, field:"registrant.identifier", headerSort:false, responsive:2},
{title:"Creation Date", width:250, minWidth:150, field:"crdate", headerSort:false, responsive:2},
{title:"Expiration Date", width:250, minWidth:150, field:"exdate", headerSort:false, responsive:2},
{title: "Actions", formatter: actionsFormatter, headerSort: false, download:false, hozAlign: "center", responsive:0, cellClick:function(e, cell){ e.stopPropagation(); }},
],
placeholder:function(){
return this.getHeaderFilters().length ? "No Matching Data" : "No Data"; //set placeholder based on if there are currently any header filters
}
});
var searchInput = document.getElementById("search-input");
searchInput.addEventListener("input", function () {
updateSearchTerm(searchInput.value);
});
});
function downloadCSV() {
table.download("csv", "data.csv");
}
function downloadJSON() {
table.download("json", "data.json");
}
function downloadXLSX() {
table.download("xlsx", "data.xlsx", {sheetName:"My Applications"});
}
function downloadPDF() {
table.download("pdf", "data.pdf", {
orientation:"portrait",
title:"My Applications",
jsPDF:{unit:"mm", format:"a4", orientation:"p"}
});
}
</script>

View file

@ -50,6 +50,8 @@ $app->group('', function ($route) {
$route->map(['GET', 'POST'], '/domain/delete/{domain}', DomainsController::class . ':deleteDomain')->setName('deleteDomain');
$route->map(['GET', 'POST'], '/domain/restore/{domain}', DomainsController::class . ':restoreDomain')->setName('restoreDomain');
$route->map(['GET', 'POST'], '/domain/report/{domain}', DomainsController::class . ':reportDomain')->setName('reportDomain');
$route->get('/applications', DomainsController::class .':listApplications')->setName('listApplications');
$route->get('/transfers', DomainsController::class . ':listTransfers')->setName('listTransfers');
$route->map(['GET', 'POST'], '/transfer/request', DomainsController::class . ':requestTransfer')->setName('requestTransfer');