PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.1
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | modules/logs/ui/js/admin.js +57 -50 5.0.3.2 → 6.2.1 View file →
@@ -1,68 +1,46 @@
1 1 /* logs module js */
2 -jQuery(document).ready(function ($) {
2 +jQuery(function ($) {
3 3
4 4 if (jQuery('.mainwp-module-logs-content-wrap .ui.calendar').length > 0) {
5 5 if (mainwpParams.use_wp_datepicker == 1) {
6 6 jQuery('.mainwp-module-logs-content-wrap .ui.calendar input[type=text]').datepicker({ dateFormat: "yy-mm-dd" });
7 7 } else {
8 - jQuery('.mainwp-module-logs-content-wrap .ui.calendar').calendar({
9 - type: 'date',
10 - monthFirst: false,
11 - today: true,
12 - touchReadonly: false,
13 - formatter: {
14 - date: function (date) {
15 - if (!date) return '';
16 - var day = date.getDate();
17 - var month = date.getMonth() + 1;
18 - var year = date.getFullYear();
19 -
20 - if (month < 10) {
21 - month = '0' + month;
22 - }
23 - if (day < 10) {
24 - day = '0' + day;
25 - }
26 - return year + '-' + month + '-' + day;
27 - }
28 - }
29 - });
8 + mainwp_init_ui_calendar('.mainwp-module-logs-content-wrap .ui.calendar');
30 9 }
31 10 }
32 11
33 12 $('#logs_delete_records_button').on('click', function () {
34 - jQuery('#mainwp-message-zone').html("").hide();
35 - jQuery('#mainwp-message-zone').removeClass('red yellow green');
13 + mainwp_set_message_zone('#mainwp-message-zone');
36 14
37 - var str_startdate = jQuery('#log_delete_records_startdate').val();
38 - var str_enddate = jQuery('#log_delete_records_enddate').val();
39 - var errors = [];
15 + let str_startdate = jQuery('#log_delete_records_startdate').val();
16 + let str_enddate = jQuery('#log_delete_records_enddate').val();
17 + let errors = [];
40 18 if (str_startdate == '' || str_enddate == '') {
41 - errors.push(__('Please select Start Date and End Date.'));
19 + errors.push(MainWP.I18n.t('Please select Start Date and End Date.'));
42 20 }
43 21 if (errors.length > 0) {
44 - jQuery('#mainwp-message-zone').html('<i class="close icon"></i>' + errors).addClass('red').show();
22 + mainwp_set_message_zone('#mainwp-message-zone', '<i class="close icon"></i>' + errors, 'red');
45 23 return;
46 24 }
47 25
48 - var msg = __('Are you sure you want to delete logs for selected date?');
26 + let msg = MainWP.I18n.t('Are you sure you want to delete logs for selected date?');
49 27
50 28 mainwp_confirm(msg, function () {
51 - var data = mainwp_secure_data({
29 + let data = mainwp_secure_data({
52 30 action: 'mainwp_module_log_delete_records',
53 31 startdate: jQuery('#log_delete_records_startdate').val(),
54 32 enddate: jQuery('#log_delete_records_enddate').val(),
55 33 });
56 - jQuery('#mainwp-message-zone').html(__('Running ...')).addClass('green').show();
34 + mainwp_set_message_zone('#mainwp-message-zone', MainWP.I18n.t('Running ...'), 'green');
57 35 jQuery.post(ajaxurl, data, function (response) {
58 - jQuery('#mainwp-message-zone').removeClass('red yellow green');
36 + mainwp_set_message_zone('#mainwp-message-zone');
59 37 if (response.error) {
60 - jQuery('#mainwp-message-zone').html('<i class="close icon"></i>' + response.error).addClass('red');
38 + mainwp_set_message_zone('#mainwp-message-zone', '<i class="close icon"></i>' + response.error, 'red');
61 39 } else if (response.result) {
62 - jQuery('#mainwp-message-zone').html('<i class="close icon"></i>' + __('Logs records has been deleted successfully.')).addClass('green');
40 + mainwp_set_message_zone('#mainwp-message-zone', '<i class="close icon"></i>' + MainWP.I18n.t('Logs records has been deleted successfully.'), 'green');
63 41 } else {
64 - jQuery('#mainwp-message-zone').html('<i class="close icon"></i>' + __('Undefined error. Please try again.')).addClass('red');
42 + mainwp_set_message_zone('#mainwp-message-zone', '<i class="close icon"></i>' + MainWP.I18n.t('Undefined error. Please try again.'), 'red');
65 43 }
66 44 }, 'json');
67 45 });
68 46
@@ -69,35 +47,64 @@
69 47 return false;
70 48 });
71 49
72 50 jQuery('#logs_compact_records_button').on('click', function () {
73 - var year = jQuery('#mainwp_module_log_compact_year').dropdown('get value');
74 - jQuery('#mainwp-message-zone').html("").hide();
75 - jQuery('#mainwp-message-zone').removeClass('red yellow green');
76 -
51 + let year = jQuery('#mainwp_module_log_compact_year').dropdown('get value');
52 + mainwp_set_message_zone('#mainwp-message-zone');
77 53 if (0 == year) {
78 - jQuery('#mainwp-message-zone').html('<i class="close icon"></i>' + __('Please select year.')).addClass('red').show();
54 + mainwp_set_message_zone('#mainwp-message-zone', '<i class="close icon"></i>' + MainWP.I18n.t('Please select year.'), 'red');
79 55 return;
80 56 }
81 57
82 - var msg = __('Are you sure you want to compact logs for selected year?');
58 + let msg = MainWP.I18n.t('Are you sure you want to compact logs for selected year?');
83 59
84 60 mainwp_confirm(msg, function () {
85 - var data = mainwp_secure_data({
61 + let data = mainwp_secure_data({
86 62 action: 'mainwp_module_log_compact_records',
87 63 year: year,
88 64 });
89 -
90 - jQuery('#mainwp-message-zone').html(__('Running ...')).addClass('green').show();
65 + mainwp_set_message_zone('#mainwp-message-zone', MainWP.I18n.t('Running ...'), 'green');
91 66 jQuery.post(ajaxurl, data, function (response) {
92 - jQuery('#mainwp-message-zone').removeClass('red yellow green');
67 + mainwp_set_message_zone('#mainwp-message-zone');
93 68 if (response.error) {
94 - jQuery('#mainwp-message-zone').html('<i class="close icon"></i>' + response.error).addClass('red');
69 + mainwp_set_message_zone('#mainwp-message-zone', '<i class="close icon"></i>' + response.error, 'red');
95 70 } else if (response.result) {
96 - jQuery('#mainwp-message-zone').html('<i class="close icon"></i>' + __('Logs records has been compact successfully.')).addClass('green');
71 + mainwp_set_message_zone('#mainwp-message-zone', '<i class="close icon"></i>' + MainWP.I18n.t('Logs records has been compact successfully.'), 'green');
97 72 } else {
98 - jQuery('#mainwp-message-zone').html('<i class="close icon"></i>' + __('Undefined error. Please try again.')).addClass('red');
73 + mainwp_set_message_zone('#mainwp-message-zone', '<i class="close icon"></i>' + MainWP.I18n.t('Undefined error. Please try again.'), 'red');
99 74 }
75 + }, 'json');
76 + });
77 + return false;
78 + });
79 +
80 +
81 +
82 + jQuery('.mainwp-acts-logs-big-child-db-cleanup-btn').on('click', function () {
83 + let msg = MainWP.I18n.t('Are you sure you want to clean up activity logs for the selected site?');
84 + mainwp_confirm(msg, () => {
85 + let data = mainwp_secure_data({
86 + action: 'mainwp_module_log_clean_up_child_logs',
87 + siteid: jQuery(this).data('siteid'),
88 + });
89 +
90 + $(this).attr('disabled', 'disabled');
91 +
92 + let btn = $(this);
93 +
94 + mainwp_set_message_zone('#mainwp-message-zone', MainWP.I18n.t('Running ...'), 'green');
95 + jQuery.post(ajaxurl, data, function (response) {
96 + mainwp_set_message_zone('#mainwp-message-zone');
97 + if (response?.error) {
98 + mainwp_set_message_zone('#mainwp-message-zone', '<i class="close icon"></i>' + response.error, 'red');
99 + } else if (response?.success) {
100 + mainwp_set_message_zone('#mainwp-message-zone', '<i class="close icon"></i>' + MainWP.I18n.t('Log records were cleaned up successfully.'), 'green');
101 + $(btn).closest('.item').fadeOut(3000);
102 + return;
103 + } else {
104 + mainwp_set_message_zone('#mainwp-message-zone', '<i class="close icon"></i>' + MainWP.I18n.t('Undefined error. Please try again.'), 'red');
105 + }
106 + $(btn).attr('disabled', false);
100 107 }, 'json');
101 108 });
102 109 return false;
103 110 });