mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-03 03:46:30 +01:00
better dropdowns
This commit is contained in:
@@ -840,9 +840,9 @@ class AdminPlugin extends Plugin
|
||||
public function onAdminTools(Event $event)
|
||||
{
|
||||
$event['tools'] = array_merge($event['tools'], [
|
||||
$this->grav['language']->translate('PLUGIN_ADMIN.DIRECT_INSTALL'),
|
||||
$this->grav['language']->translate('PLUGIN_ADMIN.BACKUPS'),
|
||||
$this->grav['language']->translate('PLUGIN_ADMIN.SCHEDULER'),
|
||||
$this->grav['language']->translate('PLUGIN_ADMIN.BACKUPS')
|
||||
$this->grav['language']->translate('PLUGIN_ADMIN.DIRECT_INSTALL'),
|
||||
]);
|
||||
|
||||
return $event;
|
||||
|
||||
@@ -1386,6 +1386,69 @@ class AdminController extends AdminBaseController
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle delete backup action
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function taskDeleteBackup()
|
||||
{
|
||||
$param_sep = $this->grav['config']->get('system.param_sep', ':');
|
||||
if (!$this->authorizeTask('backup', ['admin.maintenance', 'admin.super'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$backup = $this->grav['uri']->param('backup', null);
|
||||
|
||||
if (!is_null($backup)) {
|
||||
$file = base64_decode(urldecode($backup));
|
||||
$backups_root_dir = $this->grav['locator']->findResource('backup://', true);
|
||||
|
||||
$backup_path = $backups_root_dir . '/' . $file;
|
||||
|
||||
if (file_exists($backup_path)) {
|
||||
unlink($backup_path);
|
||||
|
||||
$this->admin->json_response = [
|
||||
'status' => 'success',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.BACKUP_DELETED'),
|
||||
'toastr' => [
|
||||
'closeButton' => true
|
||||
]
|
||||
];
|
||||
} else {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'error',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.BACKUP_NOT_FOUND'),
|
||||
];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$download = urlencode(base64_encode($backup));
|
||||
$url = rtrim($this->grav['uri']->rootUrl(true), '/') . '/' . trim($this->admin->base,
|
||||
'/') . '/task' . $param_sep . 'backup/download' . $param_sep . $download . '/admin-nonce' . $param_sep . Utils::getNonce('admin-form');
|
||||
|
||||
$log->content([
|
||||
'time' => time(),
|
||||
'location' => $backup
|
||||
]);
|
||||
$log->save();
|
||||
|
||||
$this->admin->json_response = [
|
||||
'status' => 'success',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.YOUR_BACKUP_IS_READY_FOR_DOWNLOAD') . '. <a href="' . $url . '" class="button">' . $this->admin->translate('PLUGIN_ADMIN.DOWNLOAD_BACKUP') . '</a>',
|
||||
'toastr' => [
|
||||
'timeOut' => 0,
|
||||
'extendedTimeOut' => 0,
|
||||
'closeButton' => true
|
||||
]
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function taskGetChildTypes()
|
||||
{
|
||||
if (!$this->authorizeTask('get childtypes', ['admin.pages', 'admin.super'])) {
|
||||
|
||||
@@ -99,6 +99,8 @@ PLUGIN_ADMIN:
|
||||
BACKUPS_NEWEST: "Newest Backup"
|
||||
BACKUPS_OLDEST: "Oldest Backup"
|
||||
BACKUPS_PURGE: "Purge"
|
||||
BACKUP_DELETED: "Backup Successfully Deleted"
|
||||
BACKUP_NOT_FOUND: "Backup Not Found"
|
||||
STATISTICS: "Statistics"
|
||||
TODAY: "Today"
|
||||
WEEK: "Week"
|
||||
|
||||
2
themes/grav/css-compiled/preset.css
vendored
2
themes/grav/css-compiled/preset.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4
themes/grav/css-compiled/template.css
vendored
4
themes/grav/css-compiled/template.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -255,7 +255,9 @@ tr {
|
||||
|
||||
&:focus, &:hover {
|
||||
color: $button-text;
|
||||
background-color: $button-bg;
|
||||
&:hover {
|
||||
background: tint($button-bg,15%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1158,6 +1160,19 @@ form {
|
||||
.button {
|
||||
@include button-color($secondary-accent-bg, $secondary-accent-fg);
|
||||
}
|
||||
|
||||
.button-group {
|
||||
.dropdown-menu {
|
||||
background: $secondary-accent-bg;
|
||||
li {
|
||||
a {
|
||||
&:hover {
|
||||
background: tint($secondary-accent-bg,15%);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.card-item {
|
||||
|
||||
@@ -765,8 +765,11 @@ body.sidebar-quickopen #admin-main {
|
||||
display: flex;
|
||||
|
||||
.button {
|
||||
@extend %vertical-align;
|
||||
margin: 0;
|
||||
|
||||
&.dropdown-toggle {
|
||||
margin-left: -4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
%button {
|
||||
display: inline-block;
|
||||
padding: 0.3rem 1.5rem;
|
||||
padding: 0.5rem 1rem;
|
||||
font-weight: 400;
|
||||
cursor: pointer;
|
||||
vertical-align: middle;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
<td class="right pad">{{ backup.size|nicefilesize }}</td>
|
||||
<td class="right pad">
|
||||
<a class="button button-small hint--bottom" href="{{ grav.backups.getBackupDownloadUrl(backup.path, admin.base) }}" data-hint="Download"><i class="fa fa-download"></i></a>
|
||||
<a class="button button-small hint--bottom" data-hint="Re-run"><i class="fa fa-refresh"></i></a>
|
||||
<a class="button button-small danger hint--bottom" data-hint="Delete"><i class="fa fa-close"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
21
themes/grav/templates/partials/backups-button.html.twig
Normal file
21
themes/grav/templates/partials/backups-button.html.twig
Normal file
@@ -0,0 +1,21 @@
|
||||
<div class="button-group">
|
||||
{% set profiles = grav.backups.getBackupProfiles() %}
|
||||
{% set backup_url = uri.addNonce(base_url_relative ~ "/backup.json/id:%BACKUP_ID/task" ~ config.system.param_sep ~ 'backup', 'admin-form', 'admin-nonce') %}
|
||||
{% if profiles|length > 1 %}
|
||||
<button class="button" href="#modal" data-remodal-target="modal" data-ajax="{{ backup_url|replace({'%BACKUP_ID':'0'}) }}">
|
||||
<i class="fa fa-life-ring"></i> {{ "PLUGIN_ADMIN.BACKUP_NOW"|tu }}
|
||||
</button>
|
||||
<button type="button" class="button dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-caret-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
{% for id, profile in profiles %}
|
||||
<li>
|
||||
<a data-ajax="{{ backup_url|replace({'%BACKUP_ID':id}) }}" class="button">{{ profile.name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<button data-ajax="{{ backup_url|replace({'%BACKUP_ID':id}) }}" class="button"><i class="fa fa-life-ring"></i> {{ "PLUGIN_ADMIN.BACKUP_NOW"|tu }}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
@@ -23,21 +23,7 @@
|
||||
|
||||
<div class="flush-bottom button-bar">
|
||||
<a class="button hidden" href="#" data-update-packages data-remodal-target="update-packages" data-plugin-action="start-packages-update"><i class="fa fa-cloud-download"></i> {{ "PLUGIN_ADMIN.UPDATE"|tu }}</a>
|
||||
|
||||
<div class="button-group">
|
||||
<button type="button" class="button disabled" href="#modal" data-remodal-target="modal">
|
||||
<i class="fa fa-life-saver"></i> {{ "PLUGIN_ADMIN.BACKUP"|tu }}
|
||||
</button><button type="button" class="button dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-caret-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
{% for id, profile in grav.backups.getBackupProfiles() %}
|
||||
<li>
|
||||
<a data-ajax="{{ uri.addNonce(base_url_relative ~ '/backup.json/id:' ~ id ~ '/task' ~ config.system.param_sep ~ 'backup', 'admin-form', 'admin-nonce') }}" class="button">{{ profile.name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% include 'partials/backups-button.html.twig' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,21 +1,6 @@
|
||||
<div class="button-bar">
|
||||
<a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}</a>
|
||||
<a class="button" href="{{ base_url }}"><i class="fa fa-trash"></i> {{ "PLUGIN_ADMIN.BACKUPS_PURGE"|tu }}</a>
|
||||
<div class="button-group">
|
||||
<button type="button" class="button disabled" href="#modal" data-remodal-target="modal">
|
||||
<i class="fa fa-life-ring"></i> {{ "PLUGIN_ADMIN.BACKUP_NOW"|tu }}
|
||||
</button>
|
||||
<button type="button" class="button dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-caret-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
{% for id, profile in grav.backups.getBackupProfiles() %}
|
||||
<li>
|
||||
<a data-ajax="{{ uri.addNonce(base_url_relative ~ '/backup.json/id:' ~ id ~ '/task' ~ config.system.param_sep ~ 'backup', 'admin-form', 'admin-nonce') }}" class="button">{{ profile.name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% include 'partials/backups-button.html.twig' %}
|
||||
<button class="button" type="submit" name="task" value="save" form="blueprints"><i class="fa fa-check"></i> {{ "PLUGIN_ADMIN.SAVE"|tu }}</button>
|
||||
</div>
|
||||
<h1><i class="fa fa-fw fa-life-saver"></i> {{ "PLUGIN_ADMIN.BACKUPS"|tu }}</h1>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
{% extends 'partials/base.html.twig' %}
|
||||
|
||||
{% set tools_slug = uri.basename|e %}
|
||||
{% if tools_slug == 'tools' %}{% set tools_slug = 'direct-install' %}{% endif %}
|
||||
{% if tools_slug == 'tools' %}{% set tools_slug = 'backups' %}{% endif %}
|
||||
{% set title = "PLUGIN_ADMIN.TOOLS"|tu ~ ": " ~ ("PLUGIN_ADMIN." ~ tools_slug|underscorize|upper)|tu %}
|
||||
{% set tools = admin.tools() %}
|
||||
|
||||
{% set titlebar -%}
|
||||
{% include 'partials/tools-' ~ tools_slug ~ '-titlebar.html.twig' ignore missing %}
|
||||
@@ -20,19 +21,16 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content_top %}
|
||||
|
||||
{% if admin.tools|length > 1 %}
|
||||
|
||||
{% if tools|length > 1 %}
|
||||
<div class="form-tabs">
|
||||
<div class="tabs-nav">
|
||||
{% for tool in admin.tools %}
|
||||
{% for tool in tools %}
|
||||
<a href="{{ base_url_relative }}/tools/{{tool|hyphenize}}" {% if tools_slug == tool|hyphenize %}class="active"{% endif %}>
|
||||
{{ tool|tu|capitalize }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user