<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>

<body>
<div class="layui-form timo-compile">
    <form th:action="@{/api/app/config/app}">
        <input type="hidden" name="id" th:if="${app}" th:value="${app?.id}"/>
        <div class="timo-detail-title">基本信息</div>
        <table class="layui-table timo-detail-table">
            <tbody>
            <tr>
                <th>应用 ID</th>
                <td>
                    <div class="layui-form-item" th:if="${app} == null">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="appId" placeholder="请输入应用 ID" required>
                        </div>
                    </div>
                    <div class="layui-form-item" th:if="${app} != null">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="appId" readonly="true" th:value="${app.appId}">
                        </div>
                    </div>
                </td>
                <th>应用名</th>
                <td >
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="appName" placeholder="请输入应用名" required th:value="${app?.appName}">
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <th>所属环境</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <select name="env">
                                <option th:each="item : ${environments}" th:value="${item.key}" th:selected="${app?.env} eq ${item.key}">[[${item.value}]]</option>
                            </select>
                        </div>
                    </div>
                </td>
                <th>应用类型</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <select name="appType">
                                <option th:each="item : ${appTypes}" th:value="${item.key}" th:selected="${app?.appType} eq ${item.key}">[[${item.value}]]</option>
                            </select>
                        </div>
                    </div>
                </td>
                <th>应用描述</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="description"  placeholder="请输入应用描述" required th:value="${app?.description}">
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <th>应用仓库</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="appRepo"  placeholder="请输入应用仓库" required th:value="${app?.appRepo}">
                        </div>
                    </div>
                </td>
                <th>仓库分支</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="repoBranch"  placeholder="请输入仓库分支" required th:value="${app?.repoBranch}">
                        </div>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="timo-detail-title">构建配置</div>
        <table class="layui-table timo-detail-table">
            <tbody>
            <tr>
                <th>代码目录</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="codeDirname"  placeholder="请输入应用代码目录" required th:value="${app?.codeDirname}">
                        </div>
                    </div>
                </td>
                <th>编译目录</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="compileHome"  placeholder="请输入应用编译主目录" required th:value="${app?.compileHome}">
                        </div>
                    </div>
                </td>
                <th>可执行文件名</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="execBinName"  placeholder="请输入构建生成的可执行文件名" required th:value="${app?.execBinName}">
                        </div>
                    </div>
                </td>
            </tr>
            <!-- TODO 若选择了项目，则仓库、编译和打包配置不用选择 -->
            <tr>
                <th>仓库认证(若选择了项目则不必选择)</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <select name="repoAuthConfig.name">
                                <option th:each="item : ${repoAuths}" th:value="${item.key}" th:selected="${app?.repoAuthConfig?.name} eq ${item.key}">[[${item.value}]]</option>
                            </select>
                        </div>
                    </div>
                </td>
                <th>编译器(若选择了项目则不必选择)</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <select name="compilerConfig.name">
                                <option th:each="item : ${compilers}" th:value="${item.key}" th:selected="${app?.compilerConfig?.name} eq ${item.key}">[[${item.value}]]</option>
                            </select>
                        </div>
                    </div>
                </td>
                <th>打包工具(若选择了项目则不必选择)</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <select name="packerConfig.name">
                                <option th:each="item : ${packers}" th:value="${item.key}" th:selected="${app?.packerConfig?.name} eq ${item.key}">[[${item.value}]]</option>
                            </select>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <th>Dockerfile</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <textarea class="layui-textarea" name="packScript" placeholder="打包类型是 docker 时才需要" th:text="${app?.packScript}"></textarea>
                        </div>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="timo-detail-title">运行配置</div>
        <table class="layui-table timo-detail-table">
            <tbody>
            <tr>
                <th>HTTP 端口</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="runningConfig.httpPort" placeholder="请输入应用的 HTTP 端口" th:value="${app?.runningConfig?.httpPort}">
                        </div>
                    </div>
                </td>
                <th>健康检查地址</th>
                <td >
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="runningConfig.healthCheck" placeholder="请输入健康检查 URI" required th:value="${app?.runningConfig?.healthCheck}">
                        </div>
                    </div>
                </td>
            </tr>
            <!-- TODO 应用日志 -->
            <!--<tr>
                <th>日志类型</th>
                <td >
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="runningConfig.healthCheck" placeholder="请选择日志类型" required th:value="${app?.runningConfig?.healthCheck}">
                        </div>
                    </div>
                </td>
                <th>日志级别</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="runningConfig.httpPort" placeholder="请选择日志级别" th:value="${app?.runningConfig?.httpPort}">
                        </div>
                    </div>
                </td>
                <th>日志目录或文件路径</th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="runningConfig.httpPort" placeholder="日志目录或文件路径" th:value="${app?.runningConfig?.httpPort}">
                        </div>
                    </div>
                </td>
                <th>是否为目录</th>
                <td >
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="runningConfig.healthCheck" placeholder="是否为目录" required th:value="${app?.runningConfig?.healthCheck}">
                        </div>
                    </div>
                </td>
            </tr>-->
            </tbody>
        </table>
        <div class="layui-form-item timo-finally">
            <button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
            <button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
        </div>
    </form>
</div>
<script th:replace="/common/template :: script"></script>
<script type="text/javascript" th:src="@{/js/plugins/jquery-2.2.4.min.js}"></script>
</body>
</html>