backup.js 831 B

123456789101112131415161718192021222324
  1. import $ from 'jquery';
  2. import { translations } from 'grav-config';
  3. import request from '../utils/request';
  4. import { Instances as Charts } from './chart';
  5. $('[data-ajax*="task:backup"]').on('click', function() {
  6. let element = $(this);
  7. let url = element.data('ajax');
  8. element
  9. .attr('disabled', 'disabled')
  10. .find('> .fa').removeClass('fa-database').addClass('fa-spin fa-refresh');
  11. request(url, (/* response */) => {
  12. if (Charts && Charts.backups) {
  13. Charts.backups.updateData({ series: [0, 100] });
  14. Charts.backups.element.find('.numeric').html(`0 <em>${translations.PLUGIN_ADMIN.DAYS.toLowerCase()}</em>`);
  15. }
  16. element
  17. .removeAttr('disabled')
  18. .find('> .fa').removeClass('fa-spin fa-refresh').addClass('fa-database');
  19. });
  20. });