Project

General

Profile

« Previous | Next » 

Revision 8e07e708

Added by Steve Beaver almost 8 years ago

System info widget prepared for background version checks

View differences:

src/usr/local/www/widgets/widgets/system_information.widget.php
148 148
	header("Location: /index.php");
149 149
}
150 150

  
151
/*   Adding one second to the system widet update period
152
 *   will ensure that we update the GUI right after the stats are updated.
153
 */
154
$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000;
155
$widgetperiod += 1000;
156

  
157 151
$filesystems = get_mounted_filesystems();
158 152

  
159 153
$skipsysinfoitems = explode(",", $user_settings['widgets']['system_information']['filter']);
......
437 431
					<div id="cpuPB" class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
438 432
					</div>
439 433
				</div>
440
				<?php $update_period = (!empty($config['widgets']['period'])) ? $config['widgets']['period'] : "10"; ?>
441
				<span id="cpumeter"><?=sprintf(gettext("Updating in %s seconds"), $update_period)?></span>
434

  
435
				<span id="cpumeter"></span>
442 436
			</td>
443 437
		</tr>
444 438
<?php
......
558 552
	set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallsysinfoitems");
559 553
});
560 554

  
561
var update_interval = "<?=$widgetperiod?>";
562

  
563 555
function setProgress(barName, percent) {
564 556
	$('#' + barName).css('width', percent + '%').attr('aria-valuenow', percent);
565 557
}
......
736 728

  
737 729

  
738 730
events.push(function(){
739
	// --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------
731
	// --------------------- Centralized widget refresh system ------------------------------
740 732

  
741 733
	// Callback function called by refresh system when data is retrieved
742 734
	function meters_callback(s) {
......
759 751
	// Register the AJAX object
760 752
	register_ajax(metersObject);
761 753

  
754
	<?php if (!isset($config['system']['firmware']['disablecheck'])): ?>
755

  
756
	// Callback function called by refresh system when data is retrieved
757
	function version_callback(s) {
758
		$('[id^=widget-system_information] #updatestatus').html(s);
759

  
760
		// The click handler has to be attached after the div is updated
761
		$('#updver').click(function() {
762
			updver_ajax();
763
		});
764
	}
765

  
766
	// POST data to send via AJAX
767
	var postdata = {
768
		ajax: "ajax",
769
		getupdatestatus: "1"
770
	 };
771

  
772
	// Create an object defining the widget refresh AJAX call
773
	var versionObject = new Object();
774
	versionObject.name = "Version";
775
	versionObject.url = "/widgets/widgets/system_information.widget.php";
776
	versionObject.callback = version_callback;
777
	versionObject.parms = postdata;
778
	versionObject.freq = 100;
779

  
780
	// Register the AJAX object
781
	register_ajax(versionObject);
782
<?php endif; ?>
783

  
762 784
	//set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
763 785

  
786
	// AJAX function to update the version display with non-cached data
787
	function updver_ajax() {
788

  
789
		// Display the "updating" message
790
		$('[id^=widget-system_information] #updatestatus').html("<?=$updtext?>"); // <?=$updtext?>");
791

  
792
		$.ajax({
793
			type: 'POST',
794
			url: "/widgets/widgets/system_information.widget.php",
795
			dataType: 'html',
796
			data: {
797
				ajax: "ajax",
798
				getupdatestatus: "2"
799
			},
800

  
801
			success: function(data){
802
				// Display the returned data
803
				$('[id^=widget-system_information] #updatestatus').html(data);
804

  
805
				// Re-attach the click handler (The binding was lost when the <div> content was replaced)
806
				$('#updver').click(function() {
807
					updver_ajax();
808
				});
809
			},
810

  
811
			error: function(e){
812
			}
813
		});
814
	}
764 815
});
765 816
//]]>
766 817
</script>

Also available in: Unified diff