Allocation tokens can be viewed in the panel now

This commit is contained in:
Pinga 2024-03-06 00:24:15 +02:00
parent 420bd952f8
commit e0f77397d8
6 changed files with 115 additions and 14 deletions

View file

@ -1065,6 +1065,26 @@ class SystemController extends Controller
]);
}
public function manageTokens(Request $request, Response $response)
{
if ($_SESSION["auth_roles"] != 0) {
return $response->withHeader('Location', '/dashboard')->withStatus(302);
}
if ($request->getMethod() === 'POST') {
return $response->withHeader('Location', '/dashboard')->withStatus(302);
}
$db = $this->container->get('db');
$uri = $request->getUri()->getPath();
$tokens = $db->select("SELECT * FROM allocation_tokens");
return view($response,'admin/system/manageTokens.twig', [
'tokens' => $tokens,
'currentUri' => $uri
]);
}
public function managePromo(Request $request, Response $response)
{
if ($_SESSION["auth_roles"] != 0) {

View file

@ -20,16 +20,6 @@
<!-- 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('manageReserved')}}" class="btn btn-secondary">
{{ __('Manage Reserved Names') }}
</a>
</span>
<span class="d-sm-none">
<a href="{{route('manageReserved')}}" class="btn btn-secondary btn-icon" title="{{ __('Manage Reserved Names') }}" aria-label="{{ __('Manage Reserved Names') }}">
<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="M9 20h6" /><path d="M12 14v6" /><path d="M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z" /><path d="M9 9h6" /></svg>
</a>
</span>
<a href="{{route('createTld')}}" 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 New TLD') }}

View file

@ -0,0 +1,90 @@
{% extends "layouts/app.twig" %}
{% block title %}{{ __('Manage Allocation Tokens') }}{% 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">
{{ __('Manage Allocation Tokens') }}
</h2>
</div>
</div>
</div>
</div>
<!-- Page body -->
<div class="page-body">
<div class="container-xl">
<div class="col-12">
<div class="alert alert-info" role="alert">
<div class="d-flex">
<div>
<svg xmlns="http://www.w3.org/2000/svg" class="icon alert-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 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0" /><path d="M12 9h.01" /><path d="M11 12h1v4h1" /></svg>
</div>
<div>
<h4 class="alert-title">{{ __('Note on Allocation Tokens') }}</h4>
<div class="text-secondary">{{ __('For the moment, allocation tokens are managed directly via the database and can only be viewed in the control panel.') }}</div>
</div>
</div>
</div>
{% include 'partials/flash.twig' %}
<div class="card">
<form action="/registry/tokens" method="post">
{{ csrf.field | raw }}
<div class="table-responsive">
<table class="table table-vcenter card-table">
<thead>
<tr>
<th>{{ __('Token') }}</th>
<th>{{ __('Domain') }}</th>
<th>{{ __('Type') }}</th>
<th>{{ __('Status') }}</th>
<th>{{ __('Registrars') }}</th>
<th>{{ __('TLDs') }}</th>
<th>{{ __('Actions') }}</th>
<th>{{ __('Premiums') }}</th>
<th>{{ __('Discounts') }}</th>
<th class="w-1"></th>
</tr>
</thead>
<tbody>
{% if tokens is not empty %}
{% for token in tokens %}
<tr>
<td class="user-select-all">{{ token.token }}</td>
<td><strong>{{ token.domain_name }}</strong></td>
<td>{{ token.tokenType is empty ? 'Default' : token.tokenType }}</td>
<td><span class="status status-blue">{{ token.tokenStatus is empty ? 'OK' : token.tokenStatus }}</span></td>
<td class="text-secondary">{{ token.registrars is empty ? 'All' : token.registrars }}</td>
<td class="text-secondary">{{ token.tlds is empty ? 'All' : token.tlds }}</td>
<td class="text-secondary">{{ token.eppActions is empty ? 'All' : token.eppActions }}</td>
<td class="text-secondary">{{ token.reducePremium is empty ? 'N/A' : token.reducePremium }}</td>
<td class="text-secondary">{{ token.reduceYears is empty ? 'N/A' : token.reduceYears }}</td>
<td>
<a href="#">Edit</a>
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="10">No tokens found.</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% include 'partials/footer.twig' %}
</div>
{% endblock %}

View file

@ -194,7 +194,7 @@
</a>
</div>
</li>
<li {{ is_current_url('epphistory') or is_current_url('poll') or is_current_url('log') or is_current_url('registry') or is_current_url('reports') or is_current_url('listTlds') or is_current_url('createTld') or 'tld' in currentUri or 'reserved' in currentUri or (roles != 0 and 'registrar' in currentUri) ? 'class="nav-item dropdown active"' : 'class="nav-item dropdown"' }}>
<li {{ is_current_url('epphistory') or is_current_url('poll') or is_current_url('log') or is_current_url('registry') or is_current_url('reports') or is_current_url('listTlds') or is_current_url('createTld') or 'tld' in currentUri or 'reserved' in currentUri or 'tokens' in currentUri or (roles != 0 and 'registrar' 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="M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z"></path> <path d="M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0"></path></svg>
</span>

View file

@ -24,7 +24,7 @@
}
function actionsFormatter(cell, formatterParams, onRendered) {
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>`;
return `<a class="btn btn-icon 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="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 10h3v-3l-3.5 -3.5a6 6 0 0 1 8 8l6 6a2 2 0 0 1 -3 3l-6 -6a6 6 0 0 1 -8 -8l3.5 3.5" /></svg></a> <a class="btn btn-icon btn-outline-secondary" href="/registry/reserved" title="{{ __('Manage Reserved Names') }}"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 6l11 0" /><path d="M9 12l11 0" /><path d="M9 18l11 0" /><path d="M5 6l0 .01" /><path d="M5 12l0 .01" /><path d="M5 18l0 .01" /></svg></a> <a class="btn btn-icon btn-outline-dark" href="/registry/tokens" title="{{ __('Manage Allocation Tokens') }}"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 12l8 -4.5" /><path d="M12 12v9" /><path d="M12 12l-8 -4.5" /><path d="M12 12l8 4.5" /><path d="M12 3v9" /><path d="M12 12l-8 4.5" /></svg></a>`;
}
// Mapping of database string values to script names
@ -67,8 +67,8 @@
resizableColumns:false,
columns:[
{formatter:"responsiveCollapse", width:30, minWidth:30, hozAlign:"center", resizable:false, headerSort:false, responsive:0},
{title:"TLD", field:"tld", width:350, minWidth:50, headerSort:true, resizable:false, formatter: tldLinkFormatter, responsive:0},
{ title: "{{ __('Script') }}", field: "idn_table", width:250, minWidth:80, headerSort:true, resizable:false, formatter: scriptNameFormatter, responsive:2},
{title:"TLD", field:"tld", width:400, minWidth:50, headerSort:true, resizable:false, formatter: tldLinkFormatter, responsive:0},
{ title: "{{ __('Script') }}", field: "idn_table", width:300, minWidth:80, headerSort:true, resizable:false, formatter: scriptNameFormatter, responsive:2},
{title:"DNSSEC", field:"secure", width:250, minWidth:80, headerSort:true, resizable:false, formatter: secureFormatter, responsive:2},
{title: "{{ __('Actions') }}", formatter: actionsFormatter, headerSort: false, resizable:false, download:false, hozAlign: "center", responsive:0, cellClick:function(e, cell){ e.stopPropagation(); }},
],

View file

@ -120,6 +120,7 @@ $app->group('', function ($route) {
$route->map(['GET', 'POST'], '/registry/tld/{tld}', SystemController::class . ':manageTld')->setName('manageTld');
$route->get('/registry/tlds', SystemController::class .':listTlds')->setName('listTlds');
$route->map(['GET', 'POST'], '/registry/reserved', SystemController::class .':manageReserved')->setName('manageReserved');
$route->map(['GET', 'POST'], '/registry/tokens', SystemController::class .':manageTokens')->setName('manageTokens');
$route->post('/registry/promotions', SystemController::class . ':managePromo')->setName('managePromo');
$route->post('/registry/phases', SystemController::class . ':managePhases')->setName('managePhases');