shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

installer.twig (5785B)


      1 {{ header }}{{ column_left }}
      2 <div id="content">
      3 <div class="page-header">
      4   <div class="container-fluid">
      5     <h1>{{ heading_title }}</h1>
      6     <ul class="breadcrumb">
      7       {% for breadcrumb in breadcrumbs %}
      8       <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
      9       {% endfor %}
     10     </ul>
     11   </div>
     12 </div>
     13 <div class="container-fluid">
     14   <div class="panel panel-default">
     15     <div class="panel-heading">
     16       <h3 class="panel-title"><i class="fa fa-puzzle-piece"></i> {{ text_upload }}</h3>
     17     </div>
     18     <div class="panel-body">
     19       <form class="form-horizontal">
     20         <fieldset>
     21           <legend>{{ text_upload }}</legend>
     22           <div class="form-group required">
     23             <label class="col-sm-2 control-label" for="button-upload"><span data-toggle="tooltip" title="{{ help_upload }}">{{ entry_upload }}</span></label>
     24             <div class="col-sm-10">
     25               <button type="button" id="button-upload" data-loading-text="{{ text_loading }}" class="btn btn-primary"><i class="fa fa-upload"></i> {{ button_upload }}</button>
     26             </div>
     27           </div>
     28         </fieldset>
     29         <br />
     30         <fieldset>
     31           <legend>{{ text_progress }}</legend>
     32           <div class="form-group">
     33             <label class="col-sm-2 control-label">{{ entry_progress }}</label>
     34             <div class="col-sm-10">
     35               <div class="progress">
     36                 <div id="progress-bar" class="progress-bar" style="width: 0%;"></div>
     37               </div>
     38               <div id="progress-text"></div>
     39             </div>
     40           </div>
     41         </fieldset>
     42         <br />
     43         <fieldset>
     44           <legend>{{ text_history }}</legend>
     45           <div id="history"></div>
     46         </fieldset>
     47       </form>
     48     </div>
     49   </div>
     50   <script type="text/javascript"><!--
     51 $('#history').delegate('.pagination a', 'click', function(e) {
     52 	e.preventDefault();
     53 
     54 	$('#history').load(this.href);
     55 });
     56 
     57 $('#history').load('index.php?route=marketplace/installer/history&user_token={{ user_token }}');
     58   
     59 $('#button-upload').on('click', function() {
     60 	$('#form-upload').remove();
     61 
     62 	$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');
     63 
     64 	$('#form-upload input[name=\'file\']').trigger('click');
     65 
     66 	if (typeof timer != 'undefined') {
     67     	clearInterval(timer);
     68 	}
     69 
     70 	timer = setInterval(function() {
     71 		if ($('#form-upload input[name=\'file\']').val() != '') {
     72 			clearInterval(timer);
     73 
     74 			// Reset everything
     75 			$('.alert-dismissible').remove();
     76 			$('#progress-bar').css('width', '0%');
     77 			$('#progress-bar').removeClass('progress-bar-danger progress-bar-success');
     78 			$('#progress-text').html('');
     79 
     80 			$.ajax({
     81 				url: 'index.php?route=marketplace/installer/upload&user_token={{ user_token }}',
     82 				type: 'post',
     83 				dataType: 'json',
     84 				data: new FormData($('#form-upload')[0]),
     85 				cache: false,
     86 				contentType: false,
     87 				processData: false,
     88 				beforeSend: function() {
     89 					$('#button-upload').button('loading');
     90 				},
     91 				complete: function() {
     92 					$('#button-upload').button('reset');
     93 				},
     94 				success: function(json) {
     95 					if (json['error']) {
     96 						$('#progress-bar').addClass('progress-bar-danger');
     97 						$('#progress-text').html('<div class="text-danger">' + json['error'] + '</div>');
     98 					}
     99 			
    100 					if (json['text']) {
    101 						$('#progress-bar').css('width', '20%');
    102 						$('#progress-text').html(json['text']);
    103 					}
    104 			
    105 					if (json['next']) {
    106 						next(json['next'], 1);
    107 					}
    108 				},
    109 				error: function(xhr, ajaxOptions, thrownError) {
    110 					alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
    111 				}
    112 			});
    113 		}
    114 	}, 500);
    115 });
    116 
    117 function next(url, i) {
    118 	i = i + 1;
    119 
    120 	$.ajax({
    121 		url: url,
    122 		dataType: 'json',
    123 		success: function(json) {
    124 			$('#progress-bar').css('width', (i * 20) + '%');
    125 			
    126 			if (json['error']) {
    127 				$('#progress-bar').addClass('progress-bar-danger');
    128 				$('#progress-text').html('<div class="text-danger">' + json['error'] + '</div>');
    129 			}
    130 
    131 			if (json['success']) {
    132 				$('#progress-bar').addClass('progress-bar-success');
    133 				$('#progress-text').html('<span class="text-success">' + json['success'] + '</span>');
    134 				
    135 				$('#history').load('index.php?route=marketplace/installer/history&user_token={{ user_token }}');
    136 			}
    137 			
    138 			if (json['text']) {
    139 				$('#progress-text').html(json['text']);
    140 			}
    141 			
    142 			if (json['next']) {
    143 				next(json['next'], i);
    144 			}
    145 		},
    146 		error: function(xhr, ajaxOptions, thrownError) {
    147 			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
    148 		}
    149 	});
    150 }
    151 
    152 // Uninstall
    153 $('#history').on('click', '.btn-danger', function(e) {
    154 	e.preventDefault();
    155 
    156 	var element = this;
    157 
    158 	$.ajax({
    159 		url: 'index.php?route=marketplace/install/uninstall&user_token={{ user_token }}&extension_install_id=' + $(this).attr('value'),
    160 		dataType: 'json',
    161 		beforeSend: function() {
    162 			$(element).button('loading');
    163 		},
    164 		complete: function() {
    165 			$(element).button('reset');
    166 		},
    167 		success: function(json) {
    168 			$('.alert-dismissible').remove();
    169 			
    170 			if (json['success']) {
    171 				$('#content > .container-fluid').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
    172 
    173 				$('#history').load('index.php?route=marketplace/installer/history&user_token={{ user_token }}');
    174 			}
    175 		},
    176 		error: function(xhr, ajaxOptions, thrownError) {
    177 			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
    178 		}
    179 	});
    180 });
    181 //--></script></div>
    182 {{ footer }}