<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>授权管理</title>
	<meta name="decorator" content="default"/>
	<%@include file="/WEB-INF/views/include/head.jsp" %>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/admin/sys/auth">授权信息</a></li>
		<li class="active"><a href="${ctx}/admin/sys/auth/edit">更新授权</a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="systemAuth" action="${ctx}/admin/sys/auth/update" method="post" class="form-horizontal" enctype="multipart/form-data">
		<tags:message content="${message}"/>
		<input type="hidden" name="id" value="${systemAuth.id}"/>
		<div class="control-group">
	        <label class="control-label">授权模式</label>
	        <div class="controls">
	            <select name="type" id="type">
	                <c:forEach items="${typeList}" var="item">
	                    <option value="${item.value}" <c:if test="${systemAuth.type.value==item.value }">selected="selected"</c:if>>${item.name}</option>
	                </c:forEach>
	            </select>
	        </div>
	    </div>
	    <div id="onlineDiv">
	    	<div class="control-group">
				<label class="control-label">导出</label>
				<div class="controls">
					<a href="${ctx}/admin/sys/auth/exportInfo" class="btn">硬件信息</a>　
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">导入授权文件</label>
				<div class="controls">
					<input name="file" type="file" style="width:330px"/>　　
				</div>
			</div>
	    </div>
	    <div id="offlineDiv">
	    	<div class="control-group">
			<label class="control-label">密匙</label>
			<div class="controls">
				<input name="accessKey" value=""/>
			</div>
			</div>
			<div class="control-group">
				<label class="control-label">密钥</label>
				<div class="controls">
					<input name="accessSecret" value=""/>
				</div>
			</div>
	    </div>
	    <div class="form-actions">
        	 <input class="btn btn-primary" type="submit" value="保  存"/>
    	</div>
	</form:form>
    <script type="text/javascript">
	    $(document).ready(function () {
	    	if ($("#type").val()==1) {
	            $("#offlineDiv").show();
	            $("#onlineDiv").hide();
	        } 
	        if ($("#type").val()==2) {
	        	$("#onlineDiv").show();
	        	$("#offlineDiv").hide();
	        }
	    });
	    $("#type").change(function () {
	        if ($("#type").val()==1) {
	            $("#offlineDiv").show();
	            $("#onlineDiv").hide();
	        } 
	        if ($("#type").val()==2) {
	        	$("#onlineDiv").show();
	        	$("#offlineDiv").hide();
	        }
	    });
    </script>
</body>
</html>