Chart.bundle.min.js
5 years ago
bootstrap-switch.min.js
5 years ago
bootstrap.min.js
5 years ago
deactivationSurvey.js
5 years ago
jquery-ui.js
5 years ago
jquery.fileupload.js
5 years ago
jquery.iframe-transport.js
5 years ago
jquery.rateyo.js
5 years ago
jquery.validate.min.js
5 years ago
jstree.checkbox.js
5 years ago
jstree.min.js
5 years ago
jstree.types.js
5 years ago
jstree.wholerow.js
5 years ago
less.min.js
5 years ago
main.js
5 years ago
popup.js
5 years ago
sgNoticeDismiss.js
5 years ago
sgbackup.js
5 years ago
sgcloud.js
5 years ago
sglicense.js
5 years ago
sglogin.js
5 years ago
sgrequesthandler.js
5 years ago
sgrequesthandler.wordpress.js
5 years ago
sgschedule.js
5 years ago
sgsettings.js
5 years ago
sgschedule.js
215 lines
| 1 | BG_SCHEDULE_INTERVAL_HOURLY = 0; |
| 2 | BG_SCHEDULE_INTERVAL_DAILY = 1; |
| 3 | BG_SCHEDULE_INTERVAL_WEEKLY = 2; |
| 4 | BG_SCHEDULE_INTERVAL_MONTHLY = 3; |
| 5 | BG_SCHEDULE_INTERVAL_YEARLY = 4; |
| 6 | |
| 7 | jQuery(document).ready( function() { |
| 8 | sgBackup.initTablePagination('sg-schedule'); |
| 9 | sgBackup.initScheduleCreation(); |
| 10 | }); |
| 11 | |
| 12 | sgBackup.initScheduleCreation = function() { |
| 13 | sgBackup.initScheduleSwitchButtons(); |
| 14 | sgBackup.initManulBackupRadioInputs(); |
| 15 | sgBackup.initManualBackupTooltips(); |
| 16 | sgBackup.toggleDaySelection(); |
| 17 | sgBackup.initIntervalSelection(); |
| 18 | } |
| 19 | |
| 20 | sgBackup.removeSchedule = function (id){ |
| 21 | var ajaxHandler = new sgRequestHandler('schedule', {remove: true, id: id}); |
| 22 | |
| 23 | if (!confirm(BG_SCHEDULE_STRINGS.confirm)) { |
| 24 | return false; |
| 25 | } |
| 26 | |
| 27 | ajaxHandler.callback = function(response){ |
| 28 | jQuery('.alert').remove(); |
| 29 | |
| 30 | if(typeof response.success !== 'undefined'){ |
| 31 | location.reload(); |
| 32 | } |
| 33 | else{ |
| 34 | //if error |
| 35 | var alert = sgBackup.alertGenerator(BG_SCHEDULE_STRINGS.deletionError, 'alert-danger'); |
| 36 | jQuery('.sg-schedule-container legend').after(alert); |
| 37 | } |
| 38 | |
| 39 | sgBackup.scrollToElement('.alert'); |
| 40 | }; |
| 41 | ajaxHandler.run(); |
| 42 | } |
| 43 | |
| 44 | sgBackup.initIntervalSelection = function() { |
| 45 | if (jQuery('#sg-schedule-interval').val() == BG_SCHEDULE_INTERVAL_WEEKLY) { |
| 46 | jQuery('#sg-schedule-day-of-week-select').show(); |
| 47 | } |
| 48 | else if(jQuery('#sg-schedule-interval').val() == BG_SCHEDULE_INTERVAL_MONTHLY) { |
| 49 | jQuery('#sg-schedule-day-of-month-select').show(); |
| 50 | } |
| 51 | else if(jQuery('#sg-schedule-interval').val() == BG_SCHEDULE_INTERVAL_HOURLY) { |
| 52 | jQuery('#sg-schedule-timezone').hide(); |
| 53 | } |
| 54 | |
| 55 | jQuery('#sg-schedule-interval').on('change', function(){ |
| 56 | jQuery('#sg-schedule-timezone').show(); |
| 57 | if (jQuery(this).val() == BG_SCHEDULE_INTERVAL_WEEKLY) { |
| 58 | jQuery('#sg-schedule-day-of-month-select').hide(); |
| 59 | jQuery('#sg-schedule-day-of-week-select').show(); |
| 60 | } |
| 61 | else if (jQuery(this).val() == BG_SCHEDULE_INTERVAL_MONTHLY) { |
| 62 | jQuery('#sg-schedule-day-of-week-select').hide(); |
| 63 | jQuery('#sg-schedule-day-of-month-select').show(); |
| 64 | } |
| 65 | else if(jQuery('#sg-schedule-interval').val() == BG_SCHEDULE_INTERVAL_HOURLY) { |
| 66 | jQuery('#sg-schedule-timezone').hide(); |
| 67 | } |
| 68 | else { |
| 69 | sgBackup.toggleDaySelection(); |
| 70 | } |
| 71 | }); |
| 72 | } |
| 73 | |
| 74 | sgBackup.toggleDaySelection = function(){ |
| 75 | jQuery('#sg-schedule-day-of-week-select').hide(); |
| 76 | jQuery('#sg-schedule-day-of-month-select').hide(); |
| 77 | } |
| 78 | |
| 79 | sgBackup.prependErrorMsg = function(alert) { |
| 80 | if (typeof jQuery('#sg-schedule-id').val() === 'undefined') { |
| 81 | jQuery('.sg-schedule-container legend').after(alert); |
| 82 | } |
| 83 | else { |
| 84 | jQuery('#sg-modal .modal-header').prepend(alert); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | //SGSchedule AJAX callback |
| 89 | sgBackup.schedule = function(){ |
| 90 | var error = []; |
| 91 | var scheduleForm = jQuery('form[data-type=schedule]'); |
| 92 | |
| 93 | //Validation |
| 94 | jQuery('.alert').remove(); |
| 95 | if(jQuery('input[type=radio][name=backupType]:checked').val() == 2) { |
| 96 | if (jQuery('.sg-custom-option:checked').length <= 0) { |
| 97 | error.push(BG_SCHEDULE_STRINGS.invalidBackupOption); |
| 98 | } |
| 99 | //Check if any file is selected |
| 100 | if (jQuery('input[type=checkbox][name=backupFiles]:checked').length > 0) { |
| 101 | if (jQuery('.sg-custom-backup-files input:checkbox:checked').length <= 0) { |
| 102 | error.push(BG_SCHEDULE_STRINGS.invalidDirectorySelected); |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | //Check if any cloud is selected |
| 107 | if(jQuery('input[type=checkbox][name=backupCloud]:checked').length > 0) { |
| 108 | if(jQuery('.sg-custom-backup-cloud input:checkbox:checked').length <= 0) { |
| 109 | error.push(BG_SCHEDULE_STRINGS.invalidCloud); |
| 110 | } |
| 111 | } |
| 112 | //If any error show it and abort ajax |
| 113 | if(error.length){ |
| 114 | var alert = sgBackup.alertGenerator(error, 'alert-danger'); |
| 115 | sgBackup.prependErrorMsg(alert); |
| 116 | sgBackup.scrollToElement('.alert'); |
| 117 | return false; |
| 118 | } |
| 119 | |
| 120 | //Before sending |
| 121 | jQuery('#sg-save-schedule').attr('disabled','disabled'); |
| 122 | jQuery('#sg-save-schedule').html(BG_SCHEDULE_STRINGS.savingInProgress); |
| 123 | |
| 124 | //On Success |
| 125 | var ajaxHandler = new sgRequestHandler('schedule', scheduleForm.serialize()); |
| 126 | ajaxHandler.dataIsObject = false; |
| 127 | ajaxHandler.callback = function(response){ |
| 128 | jQuery('.alert').remove(); |
| 129 | if(typeof response.success !== 'undefined'){ |
| 130 | var alert = sgBackup.alertGenerator(BG_SCHEDULE_STRINGS.successMessage, 'alert-success'); |
| 131 | sgBackup.prependErrorMsg(alert); |
| 132 | location.reload(); |
| 133 | } |
| 134 | else{ |
| 135 | //if error |
| 136 | var alert = sgBackup.alertGenerator(response, 'alert-danger'); |
| 137 | sgBackup.prependErrorMsg(alert); |
| 138 | } |
| 139 | |
| 140 | //Always |
| 141 | jQuery('#sg-save-schedule').removeAttr('disabled','disabled'); |
| 142 | jQuery('#sg-save-schedule').html(BG_SCHEDULE_STRINGS.saveButtonText); |
| 143 | sgBackup.scrollToElement('.alert'); |
| 144 | }; |
| 145 | ajaxHandler.run(); |
| 146 | }; |
| 147 | |
| 148 | sgBackup.initScheduleSwitchButtons = function() { |
| 149 | jQuery('.sg-switch').bootstrapSwitch(); |
| 150 | if(jQuery('#sg-backup-page-content-schedule .sg-switch').is(':checked')) |
| 151 | { |
| 152 | jQuery('#sg-backup-page-content-schedule .sg-schedule-settings').show(); |
| 153 | } |
| 154 | jQuery('.sg-switch').on('switchChange.bootstrapSwitch', function (event, state) { |
| 155 | var url = jQuery(this).attr('data-remote'); |
| 156 | if(state) { |
| 157 | var isFeatureAvailable = new sgRequestHandler('isFeatureAvailable', {sgFeature: "SCHEDULE"}); |
| 158 | isFeatureAvailable.callback = function(response) { |
| 159 | jQuery('.alert').remove(); |
| 160 | if (typeof response.success !== 'undefined') { |
| 161 | //Show or Hide settings panel |
| 162 | jQuery('.sg-schedule-settings').fadeIn(); |
| 163 | } |
| 164 | else { |
| 165 | var alert = sgBackup.alertGenerator(response.error, 'alert-warning'); |
| 166 | jQuery('.sg-schedule-container legend').after(alert); |
| 167 | jQuery('.sg-switch').bootstrapSwitch('state', false); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | isFeatureAvailable.run(); |
| 172 | } |
| 173 | else { |
| 174 | var ajaxHandler = new sgRequestHandler('schedule', {remove: true}); |
| 175 | ajaxHandler.run(); |
| 176 | jQuery('.sg-schedule-settings').fadeOut(); |
| 177 | } |
| 178 | }); |
| 179 | }; |
| 180 | |
| 181 | sgBackup.initManulBackupRadioInputs = function(){ |
| 182 | jQuery('input[type=radio][name=backupType]').off('change').on('change', function(){ |
| 183 | jQuery('.sg-custom-backup').fadeToggle(); |
| 184 | jQuery('.sg-custom-backup').children().find('input[class^=sg-custom]').removeAttr('checked'); |
| 185 | jQuery('.sg-custom-backup-files').hide(); |
| 186 | }); |
| 187 | jQuery('input[type=checkbox][name=backupFiles], input[type=checkbox][name=backupCloud], input[type=checkbox][name=backupDatabase]').off('change').on('change', function(){ |
| 188 | var sgCheckBoxWrapper = jQuery(this).closest('.checkbox').find('.sg-checkbox'); |
| 189 | sgCheckBoxWrapper.fadeToggle(); |
| 190 | if(jQuery(this).attr('name') == 'backupFiles') { |
| 191 | sgCheckBoxWrapper.find('input[type=checkbox]').attr('checked', 'checked'); |
| 192 | } |
| 193 | }); |
| 194 | jQuery('input[type=radio][name=backupDBType]').off('change').on('change',function(){ |
| 195 | var sgCheckBoxWrapper = jQuery(this).closest('.checkbox').find('.sg-custom-backup-tables'); |
| 196 | if(jQuery('input[type=radio][name=backupDBType]:checked').val() == '2'){ |
| 197 | sgCheckBoxWrapper.find('input[type=checkbox]').not("[disabled]").prop('checked', true) |
| 198 | sgCheckBoxWrapper.fadeIn(); |
| 199 | }else{ |
| 200 | sgCheckBoxWrapper.fadeOut(); |
| 201 | sgCheckBoxWrapper.find('input[type=checkbox][current="true"]').not("[disabled]").prop('checked', true) |
| 202 | sgCheckBoxWrapper.find('input[type=checkbox][current="false"]').prop('checked', false) |
| 203 | } |
| 204 | }) |
| 205 | } |
| 206 | |
| 207 | sgBackup.initManualBackupTooltips = function(){ |
| 208 | jQuery('[for=cloud-ftp]').tooltip(); |
| 209 | jQuery('[for=cloud-dropbox]').tooltip(); |
| 210 | jQuery('[for=cloud-gdrive]').tooltip(); |
| 211 | jQuery('[for=cloud-one-drive]').tooltip(); |
| 212 | jQuery('[for=cloud-amazon]').tooltip(); |
| 213 | jQuery('[for=cloud-backup-guard]').tooltip(); |
| 214 | } |
| 215 |