show apikey details in modal-overlay; todo: edit allowed_from and valid_until
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -30,7 +30,6 @@ use Froxlor\UI\Request;
|
|||||||
$del_stmt = Database::prepare("DELETE FROM `" . TABLE_API_KEYS . "` WHERE id = :id");
|
$del_stmt = Database::prepare("DELETE FROM `" . TABLE_API_KEYS . "` WHERE id = :id");
|
||||||
$success_message = "";
|
$success_message = "";
|
||||||
$id = (int) Request::get('id');
|
$id = (int) Request::get('id');
|
||||||
$area = AREA;
|
|
||||||
|
|
||||||
// do the delete and then just show a success-message and the apikeys list again
|
// do the delete and then just show a success-message and the apikeys list again
|
||||||
if ($action == 'delete') {
|
if ($action == 'delete') {
|
||||||
|
|||||||
@@ -864,7 +864,7 @@ CREATE TABLE `panel_fpmdaemons` (
|
|||||||
|
|
||||||
|
|
||||||
INSERT INTO `panel_fpmdaemons` (`id`, `description`, `reload_cmd`, `config_dir`) VALUES
|
INSERT INTO `panel_fpmdaemons` (`id`, `description`, `reload_cmd`, `config_dir`) VALUES
|
||||||
(1, 'System default', 'service php7.3-fpm restart', '/etc/php/7.3/fpm/pool.d/');
|
(1, 'System default', 'service php7.4-fpm restart', '/etc/php/7.4/fpm/pool.d/');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Froxlor\UI\Callbacks;
|
|||||||
|
|
||||||
use Froxlor\PhpHelper;
|
use Froxlor\PhpHelper;
|
||||||
use Froxlor\UI\Panel\UI;
|
use Froxlor\UI\Panel\UI;
|
||||||
|
use Froxlor\Froxlor;
|
||||||
use Froxlor\User;
|
use Froxlor\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,4 +66,22 @@ class Text
|
|||||||
{
|
{
|
||||||
return wordwrap($attributes['data'], 100, '<br>', true);
|
return wordwrap($attributes['data'], 100, '<br>', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function apikeyDetailModal(array $attributes): array
|
||||||
|
{
|
||||||
|
$linker = UI::getLinker();
|
||||||
|
$result = $attributes['fields'];
|
||||||
|
$apikey_data = include Froxlor::getInstallDir() . '/lib/formfields/formfield.api_key.php';
|
||||||
|
|
||||||
|
$body = UI::twig()->render(UI::getTheme().'/user/inline-form.html.twig', [
|
||||||
|
'formaction' => $linker->getLink(array('section' => 'index', 'page' => 'apikeys')),
|
||||||
|
'formdata' => $apikey_data['apikey'],
|
||||||
|
'editid' => $attributes['fields']['id']
|
||||||
|
]);
|
||||||
|
return [
|
||||||
|
'id' => 'akModal' . $attributes['fields']['id'],
|
||||||
|
'title' => 'API-key ' . ($attributes['fields']['loginname'] ?? $attributes['fields']['adminname']),
|
||||||
|
'body' => $body
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,6 +171,11 @@ class Listing
|
|||||||
// Set actual link from linker
|
// Set actual link from linker
|
||||||
$actions[$key]['href'] = $linker->getLink($action['href']);
|
$actions[$key]['href'] = $linker->getLink($action['href']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// modal trigger - always require a valid callback
|
||||||
|
if (isset($action['modal']) && !empty($action['modal'])) {
|
||||||
|
$actions[$key]['modal'] = call_user_func($action['modal'], ['fields' => $item]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $actions;
|
return $actions;
|
||||||
|
|||||||
57
lib/formfields/formfield.api_key.php
Normal file
57
lib/formfields/formfield.api_key.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Froxlor\UI\Panel\UI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the COPYING
|
||||||
|
* file that was distributed with this source code. You can also view the
|
||||||
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright (c) the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||||
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
* @package Formfields
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
return [
|
||||||
|
'apikey' => [
|
||||||
|
'title' => UI::getLng('menue.main.apikeys'),
|
||||||
|
'sections' => [
|
||||||
|
'section_a' => [
|
||||||
|
'fields' => [
|
||||||
|
'loginname' => [
|
||||||
|
'label' => UI::getLng('login.username'),
|
||||||
|
'type' => 'label',
|
||||||
|
'value' => $result['loginname'] ?? $result['adminname']
|
||||||
|
],
|
||||||
|
'apikey' => [
|
||||||
|
'label' => 'API key',
|
||||||
|
'type' => 'text',
|
||||||
|
'readonly' => true,
|
||||||
|
'value' => $result['apikey']
|
||||||
|
],
|
||||||
|
'secret' => [
|
||||||
|
'label' => 'Secret',
|
||||||
|
'type' => 'text',
|
||||||
|
'readonly' => true,
|
||||||
|
'value' => $result['secret']
|
||||||
|
],
|
||||||
|
'allowed_from' => [
|
||||||
|
'label' => UI::getLng('apikeys.allowed_from'),
|
||||||
|
'type' => 'text',
|
||||||
|
'value' => $result['allowed_from'],
|
||||||
|
],
|
||||||
|
'valid_until' => [
|
||||||
|
'label' => UI::getLng('apikeys.valid_until'),
|
||||||
|
'type' => 'text',
|
||||||
|
'value' => $result['valid_until'],
|
||||||
|
'format_callback' => [Text::class, 'timestampUntil'],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
@@ -61,12 +61,7 @@ return [
|
|||||||
'show' => [
|
'show' => [
|
||||||
'icon' => 'fa fa-eye',
|
'icon' => 'fa fa-eye',
|
||||||
'title' => $lng['apikeys']['clicktoview'],
|
'title' => $lng['apikeys']['clicktoview'],
|
||||||
'href' => [
|
'modal' => [Text::class, 'apikeyDetailModal'],
|
||||||
'section' => 'index',
|
|
||||||
'page' => 'apikeys',
|
|
||||||
'action' => '#',
|
|
||||||
'id' => ':id'
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
'delete' => [
|
'delete' => [
|
||||||
'icon' => 'fa fa-trash',
|
'icon' => 'fa fa-trash',
|
||||||
|
|||||||
@@ -2164,4 +2164,5 @@ $lng['panel']['backtooverview'] = 'Back to overview';
|
|||||||
$lng['panel']['settingsmode'] = 'Mode';
|
$lng['panel']['settingsmode'] = 'Mode';
|
||||||
$lng['panel']['settingsmodebasic'] = 'Basic';
|
$lng['panel']['settingsmodebasic'] = 'Basic';
|
||||||
$lng['panel']['settingsmodeadvanced'] = 'Advanced';
|
$lng['panel']['settingsmodeadvanced'] = 'Advanced';
|
||||||
$lng['panel']['settingsmodetoggle'] = 'Click to toggle mode';
|
$lng['panel']['settingsmodetoggle'] = 'Click to toggle mode';
|
||||||
|
$lng['panel']['modalclose'] = 'Close';
|
||||||
|
|||||||
@@ -1803,3 +1803,4 @@ $lng['panel']['settingsmode'] = 'Modus';
|
|||||||
$lng['panel']['settingsmodebasic'] = 'Einfach';
|
$lng['panel']['settingsmodebasic'] = 'Einfach';
|
||||||
$lng['panel']['settingsmodeadvanced'] = 'Erweitert';
|
$lng['panel']['settingsmodeadvanced'] = 'Erweitert';
|
||||||
$lng['panel']['settingsmodetoggle'] = 'Modus umschalten';
|
$lng['panel']['settingsmodetoggle'] = 'Modus umschalten';
|
||||||
|
$lng['panel']['modalclose'] = 'Schließen';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{% macro form(form_data, formaction, title = "", hiddenid = "") %}
|
{% macro form(form_data, formaction, title = "", hiddenid = "", nosubmit = false) %}
|
||||||
|
|
||||||
{% import "Froxlor/form/formfields.html.twig" as formfields %}
|
{% import "Froxlor/form/formfields.html.twig" as formfields %}
|
||||||
|
|
||||||
@@ -21,25 +21,27 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<!-- submit buttons -->
|
{% if nosubmit == false %}
|
||||||
<div>
|
<!-- submit buttons -->
|
||||||
{% if hiddenid is not empty %}
|
<div>
|
||||||
<input type="hidden" name="id" value="{{ hiddenid }}"/>
|
{% if hiddenid is not empty %}
|
||||||
{% endif %}
|
<input type="hidden" name="id" value="{{ hiddenid }}"/>
|
||||||
<input type="hidden" name="page" value="{{ page }}"/>
|
|
||||||
<input type="hidden" name="action" value="{{ action }}"/>
|
|
||||||
<input type="hidden" name="send" value="send"/>
|
|
||||||
|
|
||||||
<div class="col-12 text-end">
|
|
||||||
{% if form_data.buttons is defined and form_data.buttons is iterable %}
|
|
||||||
{% for btn in form_data.buttons %}
|
|
||||||
<button type="{{ btn.type|default("submit") }}" class="btn {{ btn.class|default(" btn-primary") }}">{{ btn.label }}</button>
|
|
||||||
{% endfor %}
|
|
||||||
{% else %}
|
|
||||||
<button type="reset" class="btn btn-outline-secondary">{{ lng('panel.cancel') }}</button>
|
|
||||||
<button type="submit" class="btn btn-primary">{{ lng('panel.save') }}</button>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<input type="hidden" name="page" value="{{ page }}"/>
|
||||||
|
<input type="hidden" name="action" value="{{ action }}"/>
|
||||||
|
<input type="hidden" name="send" value="send"/>
|
||||||
|
|
||||||
|
<div class="col-12 text-end">
|
||||||
|
{% if form_data.buttons is defined and form_data.buttons is iterable %}
|
||||||
|
{% for btn in form_data.buttons %}
|
||||||
|
<button type="{{ btn.type|default("submit") }}" class="btn {{ btn.class|default(" btn-primary") }}">{{ btn.label }}</button>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<button type="reset" class="btn btn-outline-secondary">{{ lng('panel.cancel') }}</button>
|
||||||
|
<button type="submit" class="btn btn-primary">{{ lng('panel.save') }}</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|||||||
@@ -31,27 +31,45 @@
|
|||||||
|
|
||||||
{% macro link(data) %}
|
{% macro link(data) %}
|
||||||
{% apply spaceless %}
|
{% apply spaceless %}
|
||||||
<a href="{{ data.href }}" {% if data.class is defined %} class="{{ data.class }}" {% endif %} {% if data.target is defined %} target="{{ data.target }}" {% endif %}{% if data.title is defined %} title="{{ data.title }}" {% endif %}>
|
<a href="{{ data.href }}" {% if data.class is defined %} class="{{ data.class }}" {% endif %} {% if data.target is defined %} target="{{ data.target }}" {% endif %} {% if data.title is defined %} title="{{ data.title }}" {% endif %}>
|
||||||
{% if data.icon is defined %}
|
{% if data.icon is defined %}
|
||||||
<i class="{{ data.icon }}"></i>
|
<i class="{{ data.icon }}"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if data.text is defined %}
|
{% if data.text is defined %}
|
||||||
{{ data.text }}
|
{{ data.text }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
{% endapply %}
|
{% endapply %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro button(data) %}
|
{% macro button(data) %}
|
||||||
{% apply spaceless %}
|
{% apply spaceless %}
|
||||||
<a class="{% if data.class is defined %}btn btn-sm {{ data.class }}{% else %}btn btn-sm btn-outline-secondary{% endif %}" href="{{ data.href }}" {% if data.target is defined %} target="{{ data.target }}" {% endif %}{% if data.title is defined %} title="{{ data.title }}" {% endif %}>
|
<a class="{% if data.class is defined %}btn btn-sm {{ data.class }}{% else %}btn btn-sm btn-outline-secondary{% endif %}" {% if data.modal is defined and data.modal is iterable %} data-bs-toggle="modal" role="button" href="#{{ data.modal.id }}" {% else %} href="{{ data.href }}" {% endif %} {% if data.target is defined %} target="{{ data.target }}" {% endif %} {% if data.title is defined %} title="{{ data.title }}" {% endif %}>
|
||||||
{% if data.icon is defined %}
|
{% if data.icon is defined %}
|
||||||
<i class="{{ data.icon }}"></i>
|
<i class="{{ data.icon }}"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if data.text is defined %}
|
{% if data.text is defined %}
|
||||||
{{ data.text }}
|
{{ data.text }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
|
{% if data.modal is defined and data.modal is iterable %}
|
||||||
|
<div class="modal fade" id="{{ data.modal.id }}" aria-hidden="true" aria-labelledby="{{ data.modal.id }}Label" tabindex="-1">
|
||||||
|
<div class="modal-dialog {{ data.modal.size|default('modal-xl') }} modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="{{ data.modal.id }}Label">{{ data.modal.title }}</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{{ lng('panel.modalclose') }}"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body text-start">
|
||||||
|
{{ data.modal.body|raw }}
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn btn-primary" data-bs-dismiss="modal">{{ lng('panel.modalclose') }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endapply %}
|
{% endapply %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
|||||||
2
templates/Froxlor/user/inline-form.html.twig
Normal file
2
templates/Froxlor/user/inline-form.html.twig
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
{% import "Froxlor/form/form.html.twig" as form %}
|
||||||
|
{{ form.form(formdata, formaction|default('#'), formdata.title, editid|default(''), true) }}
|
||||||
Reference in New Issue
Block a user