Skip to content

Commit

Permalink
Fixed #77
Browse files Browse the repository at this point in the history
Also some small ui improvement in statuses
  • Loading branch information
getpinga committed Feb 13, 2024
1 parent bb032c7 commit 92fe965
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cp/resources/views/partials/js-applications.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
// Function to create a badge
function createBadge(text, badgeClass) {
return `<span class="badge bg-${badgeClass}-lt">${text}</span>`;
return `<span class="status status-${badgeClass}">${text}</span>`;
}
// Check if statusArray is empty or not
Expand Down
2 changes: 1 addition & 1 deletion cp/resources/views/partials/js-contacts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// Function to create a badge
function createBadge(text, badgeClass) {
return `<span class="badge bg-${badgeClass}-lt">${text}</span>`;
return `<span class="status status-${badgeClass}">${text}</span>`;
}
// Check if statusArray is empty or not
Expand Down
19 changes: 10 additions & 9 deletions cp/resources/views/partials/js-domains.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
<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>`;
var displayName = cell.getValue();
var punycodeName = cell.getRow().getData().name_o;
return `<a href="/domain/view/${punycodeName}" style="font-weight:bold;">${displayName}</a>`;
}
function actionsFormatter(cell, formatterParams, onRendered) {
Expand All @@ -21,15 +22,15 @@
var hasPendingRestore = rowData.rgpstatus ? rowData.rgpstatus.includes('pendingRestore') : false;
// Common action button for all statuses
actionButtons += `<a class="btn btn-outline-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> `;
actionButtons += `<a class="btn btn-outline-info btn-icon" href="domain/update/${cell.getRow().getData().name_o}" 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 report-btn" id="report-btn" href="javascript:void(0);" data-report-url="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>`;
actionButtons += `<a class="btn btn-outline-dark btn-icon report-btn" id="report-btn" href="javascript:void(0);" data-report-url="domain/report/${cell.getRow().getData().name_o}" 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 restore-btn" id="restore-btn" href="javascript:void(0);" data-restore-url="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>`;
actionButtons += `<a class="btn btn-outline-warning btn-icon restore-btn" id="restore-btn" href="javascript:void(0);" data-restore-url="domain/restore/${cell.getRow().getData().name_o}" 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-outline-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-outline-danger btn-icon delete-btn" id="delete-btn" href="javascript:void(0);" data-delete-url="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>`;
actionButtons += `<a class="btn btn-outline-success btn-icon" href="domain/renew/${cell.getRow().getData().name_o}" 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-outline-danger btn-icon delete-btn" id="delete-btn" href="javascript:void(0);" data-delete-url="domain/delete/${cell.getRow().getData().name_o}" 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;
Expand All @@ -41,7 +42,7 @@
// Function to create a badge
function createBadge(text, badgeClass) {
return `<span class="badge bg-${badgeClass}-lt">${text}</span>`;
return `<span class="status status-${badgeClass}">${text}</span>`;
}
// Check if statusArray is empty or not
Expand Down
2 changes: 1 addition & 1 deletion cp/resources/views/partials/js-hosts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// Function to create a badge
function createBadge(text, badgeClass) {
return `<span class="badge bg-${badgeClass}-lt">${text}</span>`;
return `<span class="status status-${badgeClass}">${text}</span>`;
}
// Check if statusArray is empty or not
Expand Down
2 changes: 1 addition & 1 deletion cp/resources/views/partials/js-support.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Function to create a badge with color based on status
function createBadge(text, badgeClass) {
return `<span class="badge bg-${badgeClass} text-${badgeClass}-fg">${text}</span>`;
return `<span class="status status-${badgeClass}">${text}</span>`;
}
switch (status) {
Expand Down
7 changes: 4 additions & 3 deletions cp/resources/views/partials/js-tlds.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
document.addEventListener("DOMContentLoaded", function(){
function tldLinkFormatter(cell){
var value = cell.getValue();
return `<a href="/registry/tld/${cell.getRow().getData().tld}" style="font-weight:bold;">${value}</a>`;
var displayName = cell.getValue();
var punycodeName = cell.getRow().getData().tld_o;
return `<a href="/registry/tld/${punycodeName}" style="font-weight:bold;">${displayName}</a>`;
}
function secureFormatter(cell) {
Expand All @@ -23,7 +24,7 @@
}
function actionsFormatter(cell, formatterParams, onRendered) {
return `<a class="btn btn-outline-info" href="/registry/tld/${cell.getRow().getData().tld}" title="Manage Settings"><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="M5 21v-16a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v16l-3 -2l-2 2l-2 -2l-2 2l-2 -2l-3 2" /><path d="M14 8h-2.5a1.5 1.5 0 0 0 0 3h1a1.5 1.5 0 0 1 0 3h-2.5m2 0v1.5m0 -9v1.5" /></svg> Settings</a>`;
return `<a class="btn btn-outline-info" href="/registry/tld/${cell.getRow().getData().tld_o}" title="Manage Settings"><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="M5 21v-16a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v16l-3 -2l-2 2l-2 -2l-2 2l-2 -2l-3 2" /><path d="M14 8h-2.5a1.5 1.5 0 0 0 0 3h1a1.5 1.5 0 0 1 0 3h-2.5m2 0v1.5m0 -9v1.5" /></svg> Settings</a>`;
}
// Mapping of database string values to script names
Expand Down
39 changes: 39 additions & 0 deletions cp/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,45 @@
}
$_SESSION['user'] = $_SESSION['auth_username'];
},
'customization.afterHandler' => function ($operation, $tableName, &$response, $environment) {
$bodyContent = (string) $response->getBody();
$response->getBody()->rewind();
$data = json_decode($bodyContent, true);

if ($tableName == 'domain') {
if (isset($data['records']) && is_array($data['records'])) {
foreach ($data['records'] as &$record) {
if (isset($record['name']) && stripos($record['name'], 'xn--') === 0) {
$record['name_o'] = $record['name'];
$record['name'] = idn_to_utf8($record['name'], 0, INTL_IDNA_VARIANT_UTS46);
} else {
$record['name_o'] = $record['name'];
}
}
unset($record);
}
}
else if ($tableName == 'domain_tld') {
if (isset($data['records']) && is_array($data['records'])) {
foreach ($data['records'] as &$record) {
if (isset($record['tld']) && stripos($record['tld'], '.xn--') === 0) {
$punycodeTld = ltrim($record['tld'], '.');
$record['tld_o'] = $record['tld'];
$record['tld'] = '.'.idn_to_utf8(strtolower($punycodeTld), 0, INTL_IDNA_VARIANT_UTS46);
} else {
$record['tld_o'] = $record['tld'];
}
}
unset($record);
}
}

$modifiedBodyContent = json_encode($data, JSON_UNESCAPED_UNICODE);
$stream = \Nyholm\Psr7\Stream::create($modifiedBodyContent);
$response = $response->withBody($stream);
$response = $response->withHeader('Content-Length', strlen($modifiedBodyContent));
return $response;
},
'dbAuth.usersTable' => 'users',
'dbAuth.usernameColumn' => 'email',
'dbAuth.passwordColumn' => 'password',
Expand Down

0 comments on commit 92fe965

Please sign in to comment.