<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Porject management</title>

    <link rel="stylesheet" href="{{ url_for('static', filename='lib/easyui/themes/icon.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='lib/easyui/themes/bootstrap/easyui.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/auto.css') }}">

    <link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='favicon.ico') }}" />
    <style type="text/css">
        .lines-no .datagrid-body td {
            border-right: 1px dotted transparent;
            border-bottom: 1px dotted transparent;
        }
    </style>
</head>

<body>

    <div class="easyui-layout" style="width:100%; height:800px; padding:2px;">

        <table id="project_list" class="easyui-datagrid" style="width:100%;height:auto;" data-options="singleSelect:true,
                        fitColumns:true,
                        url:'/api/v1/project?method=project_list',
                        method:'get',
                        toolbar: toolbar">
            <thead>
                <tr>
                    <th data-options="field:'projectname',align:'center' , halign: 'center'">项目名称</th>
                    <th data-options="field:'owner',align:'center' , halign: 'center'">管理员</th>
                    <th data-options="field:'users',align:'center' , halign: 'center'">用户</th>
                    <th data-options="field:'cron',align:'center' , halign: 'center'">备注</th>
                </tr>
            </thead>
        </table>




        <div id="create_project" class="easyui-window" title="创建项目"
            data-options="modal:true,closed:true,minimizable:false,maximizable:false,collapsible:false"
            style="width:400px;height:270px;padding:10px;">
            <form id="create_project_ff" method="post">
                <div style="margin-bottom:10px">
                    <input class="easyui-textbox" id="name" name="name" label="项目名称" labelPosition="top"
                        style="width:100%" data-options="required:true">
                    <input class="easyui-textbox" id="manager" name="manager" label="项目管理员" labelPosition="top"
                        style="width:100%" data-options="required:true">
                </div>
            </form>
            <div style="text-align:right;padding:5px 0">
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="close_win('create_project')"
                    style="width:60px">取消</a>
                <a href="javascript:void(0)" class="easyui-linkbutton"
                    onclick="create_project_bt('create_project', 'create_project_ff')" style="width:60px">创建</a>
            </div>
        </div>

    </div>



    <script src="{{ url_for('static', filename='lib/easyui/jquery.min.js') }}"></script>
    <script src="{{ url_for('static', filename='lib/easyui/jquery.easyui.min.js') }}"></script>

    <!-- 自定义js库 -->
    <script type="text/javascript" src="{{ url_for('static', filename='lib/auto.js') }}"></script>
    <SCRIPT type="text/javascript">
        $(document).ready(function () {
            //$('#edit_smtp_ff').form('load','/api/v1/settings?method=smtp');

        });
        var toolbar = [{
                text: '刷新',
                iconCls: 'icon-refresh',
                handler: function () {
                    $("#setting_list").datagrid('reload');
                }
            }, '-',
            {
                text: '添加',
                iconCls: 'icon-expand',
                handler: function () {
                    manage_project('create_project', 'create_project_ff', 'create');
                    /*var data ={"method": "run", "category": "project", "project": "{{ project }}" };
                    do_ajax('post',
                        '/api/v1/task/',
                        data,
                        do_msg);

                    $("#user_list").datagrid('reload');
                    */
                }
            }, '-',
            {
                text: '删除',
                iconCls: 'icon-remove',
                handler: function () {
                    var row = $('#project_list').datagrid('getSelected');
                    if (row) {
                        $.messager.confirm('Alert', '删除项目?', function (r) {
                            if (r) {
                                var data = {
                                    "method": "delete",
                                    "name": "{0}".lym_format(row.projectname),
                                    "key": "unknown"
                                };
                                do_ajax('post', "/api/v1/project/", data, do_msg);

                                $("#project_list").datagrid('reload');
                            }
                        });
                    }
                }
            }
        ];
    </SCRIPT>
</body>

</html>