<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>UAS在线办公</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/iconfont.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <a class="navbar-brand" href="#">UAS在线办公管理</a>

    <div class="collapse navbar-collapse">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item">
                <a class="nav-link" href=".">数据中心</a>
            </li>
            <li class="nav-item active">
                <a class="nav-link" href="agent">应用管理</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="addrbook">通讯录管理</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="corp">企业设置</a>
            </li>
        </ul>
    </div>

    <div>
        <button class="btn btn-outline-success" id="addBtn"
                data-toggle="modal" data-target="#formModal">添加应用</button>
    </div>
</nav>
<!-- Modal -->
<div class="modal fade" id="formModal" tabindex="-1" role="dialog" aria-labelledby="formModalTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-scrollable" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="formModalTitle">应用参数</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form id="form">
                    <input type="hidden" id="idInput" name="id">
                    <div class="form-group">
                        <label for="codeInput">编号</label>
                        <input type="text" class="form-control" id="codeInput" name="code" required
                               aria-describedby="codeHelp">
                    </div>
                    <div class="form-group">
                        <label for="descriptionInput">描述</label>
                        <input type="text" class="form-control" id="descriptionInput" name="description" required
                               aria-describedby="descriptionHelp">
                    </div>
                    <div class="form-group">
                        <label for="agentIdInput">应用ID</label>
                        <input type="text" class="form-control" id="agentIdInput" name="agentId" required
                               aria-describedby="agentIdHelp">
                    </div>
                    <div class="form-group">
                        <label for="appKeyInput">appKey</label>
                        <input type="text" class="form-control" id="appKeyInput" name="appKey" required
                               aria-describedby="appKeyHelp">
                    </div>
                    <div class="form-group">
                        <label for="appSecretInput">appSecret</label>
                        <input type="text" class="form-control" id="appSecretInput" name="appSecret"
                               required aria-describedby="appSecretHelp">
                    </div>
                    <div class="form-group">
                        <label for="outerUrlInput">外网地址</label>
                        <input type="text" class="form-control" id="outerUrlInput" name="outerUrl"
                               required aria-describedby="outerUrlHelp">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary btn-save">保存</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="alertModal" tabindex="-1" role="dialog" aria-labelledby="alertModalTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-scrollable" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="alertModalTitle">提示</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <textarea readonly class="form-control alert-content" rows="7" autofocus style="width: 100%"></textarea>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<table class="table">
    <thead class="thead-light">
    <tr>
        <th scope="col">编号</th>
        <th scope="col">描述</th>
        <th scope="col">应用ID</th>
        <th scope="col">appKey</th>
        <th scope="col">appSecret</th>
        <th scope="col">外网地址</th>
        <th scope="col">操作</th>
    </tr>
    </thead>
    <tbody>
    </tbody>
</table>
<script id="template-html" type="text/html">
    <%for(var i in data){%>
    <tr>
        <td><%=data[i].code%></td>
        <td><%=data[i].description%></td>
        <td><%=data[i].agentId || ''%></td>
        <td><%=data[i].appKey || ''%></td>
        <td><%=data[i].appSecret || ''%></td>
        <td><%=data[i].outerUrl || ''%></td>
        <td>
            <button type="button" class="btn btn-link btn-edit" data-index="<%=i%>" title="编辑"
                    data-toggle="modal" data-target="#formModal">
                <span class="iconfont icon-edit"></span>
            </button>
            <button type="button" class="btn btn-link btn-delete" data-index="<%=i%>" title="删除">
                <span class="iconfont icon-delete"></span>
            </button>
            <button type="button" class="btn btn-link btn-auth" data-index="<%=i%>" title="创建授权链接">
                <span class="iconfont icon-link"></span>
            </button>
        </td>
    </tr>
    <%}%>
</script>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/template.min.js"></script>
<script src="js/agent.js"></script>
</body>