<!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/deploy}">
        <table class="layui-table timo-detail-table">
            <tbody>
            <tr>
                <th>
                    <label class="layui-form-label required">选择机器</label>
                </th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <select name="machineId">
                                <option th:each="item : ${machines}" th:value="${item.key}">[[${item.value}]]</option>
                            </select>
                        </div>
                    </div>
                </td>
                <th>
                    <label class="layui-form-label">应用 ID</label>
                </th>
                <td >
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="appId" readonly th:value="${appId}">
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <th>
                    <label class="layui-form-label">打包类型</label>
                </th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="packType" readonly th:value="${packType}">
                        </div>
                    </div>
                </td>
                <span th:if="${packType} ne 'docker' ">
                    <th>
                    <label class="layui-form-label required">启动目录</label>
                    </th>
                    <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="startHome" placeholder="可执行文件位置(可选)" required>
                        </div>
                    </div>
                    </td>
                </span>
            </tr>
            <tr>
                <th>
                    <label class="layui-form-label">启动脚本<i id="start_script_tips" class="fa fa-question-circle"></i></label>
                </th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <textarea class="layui-textarea" name="startScript" placeholder="启动脚本(选填, docker 应用默认为空 JSON {})"></textarea>
                        </div>
                    </div>
                </td>
                <span th:if="${packType} ne 'docker' ">
                <th>
                    <label class="layui-form-label required">解包脚本</label>
                </th>
                <td>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <textarea class="layui-textarea" name="unpackScript" placeholder="解包脚本(可选)"></textarea>
                        </div>
                    </div>
                </td>
                </span>
            </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>
<script type="text/javascript">
    $(function () {
        $("#start_script_tips").hover(function () {
            var tips = layer.tips(
                '对于 docker 打包类型, 启动脚本是一个 JSON 字符串<br/>' +
                '内容是 https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate 的 reqeust body<br/>',
                '#start_script_tips',{
                tips: [1, '#555555']
            });
            sleep(1000);
            layer.close(tips);
        })
    })
</script>
</body>
</html>