<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	// nginx proxy: proxy_set_header 	X-Scheme 	$scheme; 
	String scheme = request.getHeader("X-Scheme");
	if (scheme == null) {
		scheme = request.getScheme();
	}
	int port = request.getServerPort();
	String basePath = scheme + "://" + request.getServerName() + ((port == 80 || port == 443) ? "" : (":" + port)) + path + "/";
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="renderer" content="webkit">
<title>控制台-账户中心</title>
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="<%=basePath%>">
<link rel="shortcut icon" href="static/img/icon.png">
<link rel="stylesheet" type="text/css" href="static/lib/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="static/lib/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="static/lib/css/toastr.min.css">
<link rel="stylesheet" type="text/css" href="static/css/console.css" />
<meta name="referrer" content="origin" />
</head>
<body class="home-app">
	<!-- navigation start -->
	<c:set var="module" value="app" scope="session" />
	<jsp:include page="header.jsp" />
	<!-- navigation end -->

	<!-- main area start -->
	<div class="x-container">
		<div class="container">
			<div class="x-content-wrap clearfix" style="margin: 0 -15px">
				<div class="x-content">
					<!-- tab切换 start-->
					<ul class="nav nav-tabs x-nav-tabs x-navbar-right hidden-xs">
						<li><a data-type="INNER">内部</a></li>
						<li><a data-type="INNER">外部</a></li>
						<li class="active"><a data-type="">全部</a></li>

						<h2 class="hidden-xs">
							<i class="fa fa-file-text-o"></i> 应用
						</h2>
					</ul>
					<!-- tab切换 end-->
					<!-- 列表 start -->
					<div class="x-mod x-list x-list-2x x-chunk-list-wrap">
						<div class="x-mod-body">
							<!-- tab start -->
							<div id="app_list" class="x-chunk-list">
								<c:forEach items="${content}" var="app">
									<div class="x-item">
										<div class="x-icon">
											<i class="fa fa-file-o"></i>
										</div>
										<p class="x-title">
											<a class="x-text x-editor-trigger" href="javascript:;"
												data-id="${app.uid}">${app.description}</a>
										</p>
										<div class="text-muted">
											<span class="x-text"> <i
												class="fa fa-fw fa-check-square-o"></i>${app.uid}</span>
										</div>
										<div class="x-text-muted">
											绑定企业<b>${app.usCount}</b>
										</div>
									</div>
								</c:forEach>
							</div>
							<!-- tab end -->
							<!-- empty tag -->
							<c:if test="${content == null || content.size() == 0}">
								<div class="x-empty">
									<i class="fa fa-coffee"></i>
									<p>
										还没有添加应用，<a class="x-editor-trigger" href="javascript:;">点击添加</a>
									</p>
								</div>
							</c:if>
							<!-- new app -->
							<c:if test="${content != null && content.size() > 0}">
								<div class="x-item">
									<div class="x-icon">
										<a class="x-editor-trigger" href="javascript:;" title="添加应用"><i
											class="fa fa-plus"></i></a>
									</div>
								</div>
							</c:if>
						</div>
					</div>
					<!-- 列表 end -->
				</div>
			</div>
		</div>
	</div>
	<!-- main area end -->

	<script src="static/lib/js/jquery.min.js"></script>
	<script src="static/lib/js/bootstrap.min.js"></script>
	<script src="static/lib/js/toastr.min.js"></script>
	<script src="static/js/base.js"></script>
	<script src="static/js/app.js"></script>

	<!-- modal -->
	<script type="text/html" id="appModal">
	<div class="modal fade" role="dialog" aria-labelledby="appModal_title">
		<div class="modal-dialog x-modal-dialog modal-lg" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="appModal_title">应用</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal x-form">
						<div class="form-group">
							<label class="control-label col-sm-2">唯一标识</label>
							<div class="col-sm-3">
								<input type="text" class="form-control" name="uid"
									required>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">描述</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="description"
									required>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">主页</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="homePage"
									required>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">类型</label>
							<div class="col-sm-10">
									<label class="radio-inline"> <input type="radio"
												name="type" value="default" checked> 独立应用
											</label> <label class="radio-inline"> <input type="radio"
												name="type" value="control"> 级联应用
											</label>
								<div class="help-block">
									级联应用是指没有独立企业、用户及权限控制系统的应用，要借助其他应用的资源来达到控制效果
								</div>
							</div>
						</div>
						<div id="appModal_type_default">
						<div class="form-group">
							<label class="control-label col-sm-2">公钥</label>
							<div class="col-sm-10" id="keypair">
								<textarea name="publicKey" rows="3" class="form-control" readonly></textarea>
								<ul class="help-block x-menu">
									<li>点击<a class="btn-create" href="javascript:;">生成密钥对</a></li>
									<li>账户中心只保留公钥用于校验，请将私钥配置到程序中，并妥善保管</li>
									<li style="display:none"><a class="btn-download" target="_blank" href="/api/secret/private">下载私钥</a></li>
								</ul>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">企业回调</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="backSpaceUrl"
									required placeholder="应用接口，用于企业信息有变化时回调">
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">用户回调</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="backUserUrl"
									required placeholder="应用接口，用于用户信息有变化时回调">
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">用户密码回调</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="backUserPwdUrl"
									required placeholder="应用接口，用于用户密码修改时回调">
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">密码加密格式</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="encryFormat"
									required placeholder="用户密码加密的格式">
								<ul class="help-block x-menu">
									<li><code>$password</code>表示密码明文；<code>$salt</code>表示盐值</li>
									<li>可任意组合，例如：<code>$password($salt)</code>；不填写表示不对密码加密</li>
								</ul>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">登录回调</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="loginUrl"
									required placeholder="应用接口，用于企业信息有变化时回调">
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">登出回调</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" name="logoutUrl"
									required placeholder="应用接口，用于企业信息有变化时回调">
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">关联应用</label>
							<div class="col-sm-10">
								<textarea name="copyApps" rows="3" class="form-control" placeholder="填写应用唯一标识，不填表示全部；多个用逗号、分号、空格或回车分隔"></textarea>
								<ul class="help-block x-menu">
									<li>关联应用是指与当前应用有关的应用</li>
									<li>相关联的应用间，任何一方的企业或个人信息有修改，都会通过回调接口同步到其他应用</li>
								</ul>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">默认开通</label>
							<div class="col-sm-10">
									<label class="radio-inline"> <input type="radio"
												name="defaultUse" value="1"> 是
											</label> <label class="radio-inline"> <input type="radio"
												name="defaultUse" value="0" checked> 否
											</label>
								<div class="help-block">
									用户注册的时候，默认为该用户开通此应用
								</div>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">使用域</label>
							<div class="col-sm-10">
									<label class="radio-inline"> <input type="radio"
												name="scope" value="PUBLIC" checked> 开放
											</label> <label class="radio-inline"> <input type="radio"
												name="scope" value="PROTECTED"> 受保护
											</label> <label class="radio-inline"> <input type="radio"
												name="scope" value="PRIVATE"> 私有
											</label>
								<div class="help-block">
									私有应用只能内部使用；受保护应用只能指定用户群使用
								</div>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-sm-2">应用ID唯一</label>
							<div class="col-sm-10">
									<label class="radio-inline"> <input type="radio"
												name="dialectEnable" value="1" checked> 是
											</label> <label class="radio-inline"> <input type="radio"
												name="dialectEnable" value="0"> 否
											</label>
								<div class="help-block">
									当ID唯一时，可以使用ID作为账户登录
								</div>
							</div>
						</div>
						</div>
						<div id="appModal_type_control">
						<div class="form-group">
							<label class="control-label col-sm-2">级联应用</label>
							<div class="col-sm-3">
								<input type="text" class="form-control" name="userControl"
									placeholder="填写应用唯一标识" required>
							</div>
						</div>		
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-blank" data-dismiss="modal">取消</button>
					<button type="button" class="btn btn-blank btn-del">删除</button>
					<button type="button" class="btn btn-default btn-submit">保存</button>
				</div>
			</div>
		</div>
	</div>
	</script>
	<!-- loading -->
	<div id="loading">
		<div class="x-loading-wrap"></div>
		<div class="x-loading">
			<div></div>
			<div></div>
			<div></div>
		</div>
	</div>
</body>
</html>