summaryrefslogtreecommitdiffstats
path: root/modules-available/webinterface/templates/httpd-restart.html
blob: ac4e726bc3442545f026d9bd3978d0c7f616bf78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<div class="panel panel-default">
	<div class="panel-heading">{{lang_applyingSettings}}</div>
	<div class="panel-body">
		<div data-tm-id="{{taskid}}" data-tm-log="error" data-tm-callback="slxRestartCb">{{lang_installAndRestart}}</div>
	</div>
</div>
<script type="application/javascript"><!--

var slxRedirTimeout = 0;
var slxRedirTimer = false;

function slxRestartCb(task) {
	if (!task || !task.statusCode)
		return;
	if (task.statusCode === 'TASK_WAITING' || task.statusCode === 'TASK_PROCESSING') {
		// Polling still works, reset counter
		console.log('Resetting because ' + task.statusCode);
		slxRedirTimeout = 0;
	} else {
		console.log('Disabling because ' + task.statusCode);
		clearInterval(slxRedirTimer);
		window.location.replace(window.location.href.replace('&show=httpsupdate', ''));
	}
}

slxRedirTimer = setInterval(function() {
	// Didn't get status update from TM for 6 seconds - try to switch protocols
	if (++slxRedirTimeout > 6) {
		console.log('TIMEOUT REACHED');
		clearInterval(slxRedirTimer);
		var url = window.location.href.split(':', 2)[1];
		if (window.location.protocol === 'https:') {
			url = 'http:' + url;
		} else {
			url = 'https:' + url;
		}
		console.log('REDIRECT TO ' + url);
		window.location.replace(url);
	}
}, 1000);

//--></script>