<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Administration</title>
<meta name='description' content='Authentication app'>
<meta name='keywords' content='rkvac, smart-card authentication'>
<meta name='author' content='Bronislav Strava'>
<meta name='robots' content='all'>
<link href='/img/favicon2.png' rel='shortcut icon' type='image/png'>
	<!--	<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
    <link rel="stylesheet"
        href="https://use.fontawesome.com/releases/v5.4.1/css/all.css"
        integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz"
        crossorigin="anonymous">
    -->
	<link rel="stylesheet" th:href="@{/css/bootstrap.min.css}" type="text/css">
	<link rel="stylesheet" th:href="@{/css/fontawesome/css/all.css}" type="text/css">
</head>
<body>

	<div class="container my-2">
		<div class="card">
			<div class="card-header">
				<ul class="nav nav-tabs card-header-tabs">
					<li class="nav-item">
						<a class="nav-link" aria-current="true" href="/admin/list">Credentials</a>
					</li>
					<li class="nav-item">
						<a class="nav-link" href="/admin/parameters">Parameters</a>
					</li>
					<li class="nav-item">
						<a class="nav-link" href="/admin/logs">Logs</a>
					</li>
					<li class="nav-item">
						<a class="nav-link active" href="/admin/settings">Settings</a>
					</li>
					<li class="nav-item">
						<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Administration</a>
					</li>
					<li class="nav-item">
						<a class="nav-link" href="/admin/download-log"><i class="fas fa-arrow-circle-down" style="color:black"></i></a>
					</li>
					<li class="nav-item">
						<a class="nav-link" href="/logout"><i class="fas fa-sign-out-alt" style="color:black"></i></a>
					</li>
				</ul>
			</div>
			<div class="card-body">
				<div th:utext="${warning}"></div>
				<div class="row">
				<div class="col-md-4"></div>
				<div class="col-md-4 text-center">
					<form method="post" action="/admin/settings/set-ra-address" >
						<div class="form-group row">
							<h5 class="card-title">Revocation Authority IPv4 Address</h5>
							<p class="fw-bold" th:text="${raAddress}"></p>
							<p th:text="${raStatus}"></p>
							<div>
								<input type="text" class="form-control" id="raIP" name="raIP" placeholder="127.0.0.1" style="text-align:center;">
							</div>
						</div>
						<div class="form-group row">
							<div>
								<button type="submit" class="btn btn-primary">Set Address</button>
								<a href="/admin/settings/" class="btn btn-secondary">Refresh</a>
							</div>
						</div>
					</form>
				</div>
				<div class="col-md-4"></div>
				</div>
			</div>
			<div class="card-header">

			</div>
			<div class="card-body">
					<div class="text-center">
						<form method="post" action="/admin/settings/set-cron-epoch" >
							<div class="form-group row">
								<h5 class="card-title">Epoch Change Interval (crontab) <a href="https://crontab.guru/" style="color:black;"><i class="fas fa-question-circle"></i></a></h5>
								<p class="fw-bold" th:text="${cronValue}"></p>
								<p class="fw-bold" th:text="${cronDate}"></p>
								<p class="card-text">For help click on question mark above. <br>Enables to schedule epoch change in cron format. Please, do not set timer to midnight (service management).</p>
								<div class="row">
									<div class="col-md-4"></div>
									<div class="col-md-4">
										<input type="text" class="form-control" id="cron" name="cron" placeholder="5 0 * * 3" style="text-align:center;">
									</div>
									<div class="col-md-4"></div>
								</div>
							</div>
							<div class="form-group row">
								<div>
									<button type="submit" class="btn btn-primary">Set Interval</button>
								</div>
							</div>

						</form>
					</div>
			</div>
			<div class="card text-center">
				<div class="card-header">

				</div>
				<div class="card-body">
				<!--	<form>
						<div class="form-group row">
							<h5 class="card-title">Set Epoch Change Interval</h5>
							<div>
								<input type="text" class="form-control" id="epochInt" placeholder="127.0.0.1">
							</div>
						</div>
						<div class="form-group row">
							<div>
								<button type="submit" class="btn btn-primary">Set Address</button>
							</div>
						</div>
					</form> -->
					<h5 class="card-title">Epoch</h5>
					<p class="fw-bold" th:text="${epoch}"></p>
					<p class="card-text">Clicking on these buttons initializes a new epoch.</p>
					<p class="card-text">Change Epoch with RA includes online sync with entity available on RA IP Address. Change Epoch Offline initializes new epoch without RA.</p>
					<a href="/admin/settings/epoch-change" class="btn btn-primary">Change Epoch with RA</a>
					<a href="/admin/settings/offline-epoch-change" class="btn btn-secondary">Change Epoch Offline</a>
				</div>
			</div>
			<div class="card text-center">
				<div class="card-header">

				</div>
				<div class="card-body">
					<h5 class="card-title">Verification Loop</h5>
					<p class="fw-bold" th:text="${inCycles}"></p>
					<p class="card-text">Clicking on these buttons enables/disables public part verification.</p>
					<div class="row">
						<div class="col-md-4"></div>
						<div class="col-md-2"><a href="/admin/settings/enableverification" class="btn btn-primary">Enable</a></div>
						<div class="col-md-2"><a href="/admin/settings/disableverification" class="btn btn-secondary">Disable</a></div>
						<div class="col-md-4"></div>

					</div>
				</div>

			</div>
			<div class="card text-center">
				<div class="card-header">

				</div>
				<div class="card-body">
					<h5 class="card-title">Restart</h5>
					<p class="card-text">Allows to restart the service.</p>
					<div class="row">
						<div class="col-md-5"></div>
					<!--	<div class="col-md-2"><a href="/admin/settings/restart" class="btn btn-primary">Restart</a></div> -->
						<div class="col-md-2">

							<button type="submit" name="restart" value="restart" onclick="restartInfo()" class="btn btn-primary">Restart</button>

						</div>
						<div class="col-md-5"></div>
					</div>
				</div>
				<div class="card-footer text-muted">
					@ RKVAC BUT 2020
				</div>
			</div>
		</div>
	</div>
<script>
function restartInfo() {
  if (confirm("Restart may take about 2 minutes.")) {
    window.location.replace("/admin/settings/restart");
  } else {

  }

}
</script>
</body>
</html>