summaryrefslogblamecommitdiffstats
path: root/modules-available/rebootcontrol/clientscript.js
blob: 447072a08c715f979610f34e5f8131ec1f1f5738 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                     





                                                                                   


                                                                                     










                                                                                        
                                                                                  


                         
                                           
  
var stillActive = 10;
document.addEventListener('DOMContentLoaded', function() {
	var clients = [];
	$('.machineuuid').each(function() { clients.push($(this).data('uuid')); });
	if (clients.length === 0)
		return;
	function updateClientStatus() {
		if (stillActive <= 0) return;
		stillActive--;
		setTimeout(updateClientStatus, Math.max(1, 30 - stillActive) * 1000);
		$.ajax({
			url: "?do=rebootcontrol",
			method: "POST",
			dataType: 'json',
			data: { token: TOKEN, action: "clientstatus", clients: clients }
		}).done(function(data) {
			console.log(data);
			if (!data)
				return;
			for (var e in data) {
				$('#status-' + e).prop('class', 'glyphicon ' + data[e]);
				if (stillActive <= 0) $('#spinner-' + e).remove();
			}
		});
	}
	setTimeout(updateClientStatus, 10);
});