<%+header%>
<%
	local running = luci.sys.exec("pgrep -x /usr/bin/daed")
%>
<% if tonumber(running) ~= nil then %>
	<div class="cbi-map">
		<iframe id="daed" class="daed-iframe"></iframe>
	</div>
	<style>
	.daed-iframe {
		width: 100%;
		height: 100vh;
		min-height: 780px;
		border: none;
		border-radius: .375rem;
		box-shadow: rgba(0, 0, 0, 0.75) 0px 0px 15px -5px;
		display: block;
	}
	</style>
	<script type="text/javascript">
		var listenAddr = "<%=luci.model.uci.cursor():get_first("daed", "daed", "listen_addr")%>";
		var portRegex = /:(\d+)/;
		var match = listenAddr.match(portRegex);
		if (match && match[1]) {
			var port = match[1];
			document.getElementById("daed").src = window.location.protocol + "//" + window.location.hostname + ":" + port;
		}
	</script>
<% else %>
	<style>.notrunning{text-align: center;} h1{font-size: 25px; color: #333; margin-bottom: 16px;} p{font-size: 18px; color: #666; margin-bottom: 24px;}</style>
	<div class="notrunning">
		<img src="data:image/png;base64,[encoded data, 77076 characters]" height="90px" />
		<h1><font color="color:red"><%:DAED is not running%></font></h1>
		<p><%:Please start the DAED service first and try again%></p>
    </div>
<% end -%>

<%+footer%>
