Bunch o’ fixes

This commit is contained in:
Andy Miller
2018-09-11 22:19:49 -06:00
parent c517ec19a0
commit bc66822598
12 changed files with 53 additions and 37 deletions

View File

@@ -860,6 +860,7 @@ class AdminPlugin extends Plugin
case 'tools/scheduler':
$e['type'] = 'config/scheduler';
break;
case 'tools':
case 'tools/backups':
$e['type'] = 'config/backups';
break;

View File

@@ -1,5 +1,5 @@
name: Admin Panel
version: 1.8.9
version: 1.9.0
description: Adds an advanced administration panel to manage your site
icon: empire
author:
@@ -13,7 +13,7 @@ docs: https://github.com/getgrav/grav-plugin-admin/blob/develop/README.md
license: MIT
dependencies:
- { name: grav, version: '>=1.5.2' }
- { name: grav, version: '>=1.6.0-rc.1' }
- { name: form, version: '>=2.14.0' }
- { name: login, version: '>=2.7.0' }
- { name: email, version: '>=2.7.0' }

View File

@@ -99,8 +99,14 @@ PLUGIN_ADMIN:
BACKUPS_NEWEST: "Newest Backup"
BACKUPS_OLDEST: "Oldest Backup"
BACKUPS_PURGE: "Purge"
BACKUPS_NOT_GENERATED: "No backups have been generated yet..."
BACKUPS_PURGE_NUMBER: "Using %s of %s backup slots"
BACKUPS_PURGE_TIME: "%s days of backups left"
BACKUPS_PURGE_SPACE: "Using %s of %s"
BACKUP_DELETED: "Backup Successfully Deleted"
BACKUP_NOT_FOUND: "Backup Not Found"
BACKUP_DATE: "Backup Date"
STATISTICS: "Statistics"
TODAY: "Today"
WEEK: "Week"
@@ -232,6 +238,8 @@ PLUGIN_ADMIN:
METADATA_HELP: "Default metadata values that will be displayed on every page unless overridden by the page"
NAME: "Name"
CONTENT: "Content"
SIZE: "Size"
ACTION: "Action"
REDIRECTS_AND_ROUTES: "Redirects & Routes"
CUSTOM_REDIRECTS: "Custom Redirects"
CUSTOM_REDIRECTS_HELP: "routes to redirect to other pages. Standard Regex replacement is valid"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1521,10 +1521,6 @@ form {
}
.dropdown-menu {
background: $update-bg;
button {
background: transparent;
color: $white;
}
}
}

View File

@@ -954,7 +954,7 @@ body.sidebar-quickopen #admin-main {
}
.button {
margin-left: 4px;
}
}

View File

@@ -3,26 +3,33 @@
<thead>
<tr>
<th>#</th>
<th>Backup Date</th>
<th>Name</th>
<th class="right pad">Size</th>
<th class="right pad">Action</th>
<th>{{ "PLUGIN_ADMIN.BACKUP_DATE"|tu }}</th>
<th>{{ "PLUGIN_ADMIN.NAME"|tu }}</th>
<th class="right pad">{{ "PLUGIN_ADMIN.SIZE"|tu }}</th>
<th class="right pad">{{ "PLUGIN_ADMIN.ACTION"|tu }}</th>
</tr>
</thead>
<tbody>
{% for backup in backups %}
{% set encoded_name = backup.filename|base64_encode|url_encode %}
{% set backup_delete = delete_url|replace({'%BACKUP_FILE': encoded_name}) %}
{% if backups|count == 0 %}
<tr>
<td>{{ loop.index }}</td>
<td style="white-space: nowrap;"> <i class="fa fa-clock-o"></i> {{ backup.date }}</td>
<td>{{ backup.title }}</td>
<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>
<span class="button button-small danger hint--bottom" data-hint="Delete" data-ajax="{{ backup_delete }}"><i class="fa fa-close"></i></span>
</td>
<td colspan="5" class="error" style="text-align: center;">{{ "PLUGIN_ADMIN.BACKUPS_NOT_GENERATED"|tu }}</td>
</tr>
{% endfor %}
{% else %}
{% for backup in backups %}
{% set encoded_name = backup.filename|base64_encode|url_encode %}
{% set backup_delete = delete_url|replace({'%BACKUP_FILE': encoded_name}) %}
<tr>
<td>{{ loop.index }}</td>
<td style="white-space: nowrap;"> <i class="fa fa-clock-o"></i> {{ backup.date }}</td>
<td>{{ backup.title }}</td>
<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>
<span class="button button-small danger hint--bottom" data-hint="Delete" data-ajax="{{ backup_delete }}"><i class="fa fa-close"></i></span>
</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>

View File

@@ -16,6 +16,6 @@
{% 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>
<button data-ajax="{{ backup_url|replace({'%BACKUP_ID':0}) }}" class="button"><i class="fa fa-life-ring"></i> {{ "PLUGIN_ADMIN.BACKUP_NOW"|tu }}</button>
{% endif %}
</div>

View File

@@ -4,22 +4,26 @@
{% set backups = grav.backups.getAvailableBackups() %}
{% set profiles = grav.backups.getBackupProfiles() %}
{% set purge_config = grav.backups.getPurgeConfig() %}
{% set newest_date = (backups|first).date %}
{% set newest_backup = newest_date ? newest_date|nicetime(false, false) : 'none' %}
{% set oldest_date = (backups|last).date %}
{% set oldest_backup = oldest_date ? oldest_date|nicetime(false, false) : 'none' %}
{% switch purge_config.trigger %}
{% case 'number' %}
{% set count = backups|count %}
{% set percent_used = 100 - (count / purge_config.max_backups_count * 100) %}
{% set bar_msg = "Using " ~ count ~ " of " ~ purge_config.max_backups_count ~ " backup slots" %}
{% set percent_used = count == 0 ? 0 : 100 - (count / purge_config.max_backups_count * 100) %}
{% set bar_msg = "PLUGIN_ADMIN.BACKUPS_PURGE_NUMBER"|tu([count, purge_config.max_backups_count]) %}
{% case 'time' %}
{% set last = backups|last %}
{% set days = (date('now')).diff(last.time).days %}
{% set percent_used = 100 - (days / purge_config.max_backups_time * 100) %}
{% set bar_msg = (purge_config.max_backups_time - days) ~ " days of backups left" %}
{% set days = last == null ? 0 : (date('now')).diff(last.time).days %}
{% set percent_used = days == 0 ? 0 : 100 - (days / purge_config.max_backups_time * 100) %}
{% set bar_msg = "PLUGIN_ADMIN.BACKUPS_PURGE_TIME"|tu([(purge_config.max_backups_time - days)]) %}
{% default %}
{% set space_used = grav.backups.getTotalBackupsSize() %}
{% set space_available = purge_config.max_backups_space * 1024 * 1024 * 1024 %}
{% set percent_used = 100 - (space_used / space_available * 100) %}
{% set bar_msg = "Using " ~ space_used|nicefilesize ~ " of " ~ space_available|nicefilesize %}
{% set percent_used = space_used == 0 ? 0 : 100 - (space_used / space_available * 100) %}
{% set bar_msg = "PLUGIN_ADMIN.BACKUPS_PURGE_SPACE"|tu([space_used|nicefilesize, space_available|nicefilesize]) %}
{% endswitch %}
{% if authorize(['admin.configuration_backups', 'admin.super']) %}
@@ -52,11 +56,11 @@
<i>{{ "PLUGIN_ADMIN.BACKUPS_PROFILES_COUNT"|tu }}</i>
</span>
<span class="stat">
<b>{{ (backups|first).date|nicetime(false, false) }}</b>
<b>{{ newest_backup }}</b>
<i>{{ "PLUGIN_ADMIN.BACKUPS_NEWEST"|tu }}</i>
</span>
<span class="stat">
<b>{{ (backups|last).date|nicetime(false, false) }}</b>
<b>{{ oldest_backup }}</b>
<i>{{ "PLUGIN_ADMIN.BACKUPS_OLDEST"|tu }}</i>
</span>
</div>