summaryrefslogtreecommitdiffstats
path: root/modules-available/rebootcontrol/templates/header.html
blob: d5e79a14de87d9f817fd4320d8f93f08720852b4 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<div class="page-header">
	<button type="button" id="settingsButton" class="btn btn-default pull-right" data-toggle="modal" data-target="#settingsModal">
		<span class="glyphicon glyphicon-cog"></span>
		{{lang_settings}}
	</button>
	<h1>{{lang_moduleHeading}}</h1>
</div>

<div id="settingsModal" class="modal fade" role="dialog">
	<div class="modal-dialog">

		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">&times;</button>
				<h4 class="modal-title"><b>{{lang_settings}}</b></h4>
			</div>
			<div class="modal-body">
				<label for="pubkey">{{lang_pubKey}}</label>
				<pre id="pubkey">{{pubkey}}</pre>
				<p>{{lang_newKeypairExplanation}}</p>
				<div class="checkbox">
					<input {{perms.newkeypair.disabled}} type="checkbox" id="keypair-confirm">
					<label for="keypair-confirm">{{lang_keypairConfirmCheck}}</label>
				</div>
				<button {{perms.newkeypair.disabled}} class="btn btn-danger pull-right" id="keypair-button"
						  onclick="generateNewKeypair()" type="button">
					<span class="glyphicon glyphicon-refresh"></span>
					{{lang_genNew}}
				</button>
				<div class="clearfix slx-space"></div>
			</div>
			<form method="post" action="?do=rebootcontrol">
				<input type="hidden" name="token" value="{{token}}">
				<input type="hidden" name="action" value="toggle-wol">
				<div class="modal-body">
					<label for="port-input">{{lang_wol}}</label>
					<div class="input-group">
						<span class="input-group-addon">{{lang_wolDestPort}}</span>
						<input {{perms.woldiscover.disabled}} type="number" min="1" max="65535"
								 class="form-control" name="port" value="{{port}}" id="port-input">
					</div>
				</div>
				<div class="modal-body">
					<label>{{lang_wolDiscoverHeading}}</label>
						<div class="checkbox">
							<input {{perms.woldiscover.disabled}} id="wol-auto-discover"
									 type="checkbox" name="enabled" {{wol_auto_checked}}>
							<label for="wol-auto-discover">{{lang_wolAutoDiscoverCheck}}</label>
						</div>
						<div class="checkbox">
							<input {{perms.woldiscover.disabled}} id="wol-c2c"
									 type="checkbox" name="enabled-c2c" {{wol_c2c_checked}}>
							<label for="wol-c2c">{{lang_wolDiscoverClientToClient}}</label>
						</div>
						<div class="slx-space"></div>
						<p>{{lang_wolDiscoverDescription}}</p>
						<button {{perms.woldiscover.disabled}} class="btn btn-primary pull-right"
								  onclick="generateNewKeypair()" type="submit">
							<span class="glyphicon glyphicon-floppy-disk"></span>
							{{lang_save}}
						</button>
						<div class="clearfix"></div>
				</div>
			</form>
			<div class="modal-body">
			</div>
		</div>
	</div>
</div>

<script type="application/javascript">
document.addEventListener('DOMContentLoaded', function() {
	var $btn = $('#keypair-button');
	var $chk = $('#keypair-confirm');
	$chk.prop('checked', false); // Firefox helpfully keeping state on F5
	$btn.click(function() {
		if (!$chk.is(':checked')) {
			var $p = $chk.parent();
			$p.fadeOut(100, function () {
				$p.fadeIn(75);
			});
			return;
		}
		$btn.prop('disabled', true);
		$.ajax({
			url: '?do=rebootcontrol',
			type: 'POST',
			data: { action: "generateNewKeypair", token: TOKEN },
			success: function(value) {
				$('#pubkey').text(value);
			},
			fail: function() {
				$('#pubkey').text('Error');
				$btn.prop('disabled', false);
			}
		});
	});
});


</script>