tools-backups.html.twig 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <div class="backups-content">
  2. {% set data = admin.data('config/backups') %}
  3. {% set backups = grav.backups.getAvailableBackups() %}
  4. {% set profiles = grav.backups.getBackupProfiles() %}
  5. {% set purge_config = grav.backups.getPurgeConfig() %}
  6. {% set newest_date = (backups|first).date %}
  7. {% set newest_backup = newest_date ? newest_date|nicetime(false, false) : 'none' %}
  8. {% set oldest_date = (backups|last).date %}
  9. {% set oldest_backup = oldest_date ? oldest_date|nicetime(false, false) : 'none' %}
  10. {% switch purge_config.trigger %}
  11. {% case 'number' %}
  12. {% set count = backups|count %}
  13. {% set percent_used = count == 0 ? 0 : 100 - (count / purge_config.max_backups_count * 100) %}
  14. {% set bar_msg = "PLUGIN_ADMIN.BACKUPS_PURGE_NUMBER"|tu([count, purge_config.max_backups_count]) %}
  15. {% case 'time' %}
  16. {% set last = backups|last %}
  17. {% set days = last == null ? 0 : (date('now')).diff(last.time).days %}
  18. {% set percent_used = days == 0 ? 0 : 100 - (days / purge_config.max_backups_time * 100) %}
  19. {% set bar_msg = "PLUGIN_ADMIN.BACKUPS_PURGE_TIME"|tu([(purge_config.max_backups_time - days)]) %}
  20. {% default %}
  21. {% set space_used = grav.backups.getTotalBackupsSize() %}
  22. {% set space_available = purge_config.max_backups_space * 1024 * 1024 * 1024 %}
  23. {% set percent_used = space_used == 0 ? 0 : 100 - (space_used / space_available * 100) %}
  24. {% set bar_msg = "PLUGIN_ADMIN.BACKUPS_PURGE_SPACE"|tu([space_used|nicefilesize, space_available|nicefilesize]) %}
  25. {% endswitch %}
  26. <div id="admin-dashboard">
  27. <div id="backups-stats" class="dashboard-item">
  28. <div class="primary-accent default-box-shadow">
  29. <h1>{{ "PLUGIN_ADMIN.BACKUPS_STATS"|tu }}</h1>
  30. <div class="admin-statistics-chart">
  31. <div class="stats-info">
  32. <div id="backups-usage">
  33. <div class="backups-usage-wrapper">
  34. {% if percent_used >= 100 %}
  35. <div class="usage full"></div>
  36. {% else %}
  37. <div class="usage" style="width:{{ percent_used }}%"></div>
  38. {% endif %}
  39. </div>
  40. <h1>{{ bar_msg }}</h1>
  41. </div>
  42. </div>
  43. <div class="flush-bottom button-bar stats-bar">
  44. <span class="stat">
  45. <b>{{ backups|length }}</b>
  46. <i>{{ "PLUGIN_ADMIN.BACKUPS_COUNT"|tu }}</i>
  47. </span>
  48. <span class="stat">
  49. <b>{{ profiles|count }}</b>
  50. <i>{{ "PLUGIN_ADMIN.BACKUPS_PROFILES_COUNT"|tu }}</i>
  51. </span>
  52. <span class="stat">
  53. <b>{{ newest_backup }}</b>
  54. <i>{{ "PLUGIN_ADMIN.BACKUPS_NEWEST"|tu }}</i>
  55. </span>
  56. <span class="stat">
  57. <b>{{ oldest_backup }}</b>
  58. <i>{{ "PLUGIN_ADMIN.BACKUPS_OLDEST"|tu }}</i>
  59. </span>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. {% include 'partials/blueprints.html.twig' with { blueprints: data.blueprints, data: data } %}
  66. {% include 'partials/modal-changes-detected.html.twig' %}
  67. </div>