histogram: Make histograms crash less
[ninja.git] / application / views / backup / list.php
blob2c72b42629f8a8e7d0a894da0831c13442f1191a
1 <?php defined('SYSPATH') OR die('No direct access allowed.'); ?>
3 <script type="text/javascript">
4 function backup(){
5 $('#backupstatus').load('<?php echo url::base() . 'index.php/backup/backup/'; ?>', function(){
6 if ($(this).find('span').hasClass('ok'))
8 var file = $('#backupfilename').text();
9 if ($('#backups tbody tr:first a:first').text() != file && !$('.download:contains('+file+')').length) {
10 $('#backups tbody tr:nth-child(2)').before('<tr class="' + ($('#backups tr:last').attr('class') == 'odd' ? 'even' : 'odd') + '">'
11 + '<td><a class="view" href="<?php echo url::base(); ?>index.php/backup/view/' + file
12 + '" style="border: 0px"><?php echo html::image($this->add_path('/icons/16x16/backup-view.png'),
13 array('alt' => _('View'), 'title' => _('View'))); ?></a>'
14 + ' <a class="restore" href="<?php echo url::base(); ?>index.php/backup/restore/' + file
15 + '" style="border: 0px" title="index.php/backup/restore/'+file+'"><?php echo html::image($this->add_path('/icons/16x16/backup-restore.png'),
16 array('alt' => _('Restore'), 'title' => _('Restore'))); ?></a>'
17 + ' <a class="delete" href="<?php echo url::base(); ?>index.php/backup/delete/' + file
18 + '" style="border: 0px"><?php echo html::image($this->add_path('/icons/16x16/backup-delete.png'),
19 array('alt' => _('Delete'), 'title' => _('Delete'))); ?></a>'
20 + '</td>' + '<td><a class="download" href="<?php echo url::base(); ?>index.php/backup/download/' + file + '">' + file + '</a></td></tr>');
23 });
26 $(document).ready(function() {
27 $('a.restore').fancybox({
28 'overlayOpacity': 0.7,
29 'overlayColor' : '#ffffff',
30 'hideOnContentClick': false,
31 'hideOnOverlayClick': false,
32 'titleShow': false,
33 'showCloseButton': false,
34 'enableEscapeButton': false,
35 'autoDimensions': false,
36 'width': 250,
37 'height': 70,
38 'onStart': function(link) {
39 var l = $(link);
40 if(l.is('.restore') && !confirm('Do you really want to restore the backup ' + l.closest('tr').find('.download').text() + ' ?')) {
41 l.data('cancelled', true);
42 return false;
45 });
46 });
48 $('#verify').live('click', function(){
49 if(status) {
50 alert("Already performing an action ("+status+"), try again soon");
51 return false;
54 var link = $(this);
55 status = 'saving';
56 $('#backupstatus').load($(link).attr('href'), function(){
57 status = '';
58 if ($(this).find('span').hasClass('ok'))
59 setTimeout(backup, 2000);
60 });
61 return false;
62 });
64 $('a.restore').live('click', function(ev){
65 if(status) {
66 alert("Already performing an action ("+status+"), try again soon");
67 return false;
69 var link = $(this);
70 if(link.data('cancelled')) {
71 link.removeData('cancelled');
72 return false;
75 $('#backupstatus').text('Restoring backup...');
76 status = 'restoring';
77 $('#fancybox-content').load(link.attr('title'), function() {
78 $('#fancybox-close').show();
79 status = '';
80 $('#backupstatus').text($('#fancybox-content').text());
81 });
83 return false;
84 });
86 $('a.delete').live('click', function(){
87 var link = $(this);
88 if (confirm('Do you really want to delete ' + $(link).closest('tr').find('.download').text() + ' ?'))
89 $('#backupstatus').load($(link).attr('href'), function(){
90 if ($(this).find('span').hasClass('ok'))
91 $(link).closest('tr').remove();
92 });
93 return false;
94 });
96 window.onbeforeunload = function(event){
97 event = event || window.event;
98 var message;
99 if(status == 'restoring'){
100 message = "Your configuration is being restored from a backup, do you really want to abort?";
101 } else if(status == 'saving') {
102 message = "Your configuration is being saved, do you really want to abort?";
104 if(message) {
105 event.returnValue = message;
106 return message;
109 var status = '';
110 </script>
112 <div >
113 <h2><?php echo _('Backup/Restore'); ?></h2>
114 <div id="backupstatus">&nbsp;</div>
115 <div style="display: none">
116 <div id="restore-status"><img src="/ninja/application/media/images/loading.gif" /></div>
117 </div>
119 <a id="verify" href="<?php echo url::base() . 'index.php/backup/verify/'; ?>"><?php echo html::image($this->add_path('/icons/16x16/backup.png'),array('alt' => _('Save your current Monitor configuration'), 'title' => _('Save your current Monitor configuration'), 'style' => 'margin-bottom: -3px')); ?> <?php echo _('Save your current op5 Monitor configuration'); ?></a>
120 </p>
121 <br />
122 <table id="backups">
123 <thead>
124 <tr>
125 <th style="width: 64px"><?php echo _('Actions'); ?></th>
126 <th><?php echo _('Backups'); ?></th>
127 </tr>
128 </thead>
129 <tbody>
130 <?php
131 $i = 0;
132 foreach ($files as $file): $i++;
134 <tr class="<?php echo ($i%2 == 0) ? 'odd' : 'even'; ?>">
135 <td>
136 <a class="view" href="<?php echo url::base() . 'index.php/backup/view/' . $file; ?>" style="border: 0px"><?php echo html::image($this->add_path('/icons/16x16/backup-view.png'), array('alt' => _('View'), 'title' => _('View'))); ?></a>
137 <a class="restore" href="#restore-status" title="<?php echo url::base() . 'index.php/backup/restore/' . $file; ?>" style="border: 0px"><?php echo html::image($this->add_path('/icons/16x16/backup-restore.png'), array('alt' => _('Restore'), 'title' => _('Restore'))); ?></a>
138 <a class="delete" href="<?php echo url::base() . 'index.php/backup/delete/' . $file; ?>" style="border: 0px"><?php echo html::image($this->add_path('/icons/16x16/backup-delete.png'), array('alt' => _('Delete'), 'title' => _('Delete'))); ?></a>
139 </td>
140 <td><a class="download" href="<?php echo url::base() . 'index.php/backup/download/' . $file; ?>" target="_blank"><?php echo $file; ?></a></td>
141 </tr>
142 <?php endforeach; ?>
143 </tbody>
144 </table>
145 </div>