<!-- 新增任务 -->
<div class="container-fluid">
    <div class="info-center">
        <!--title-->
        <div class="info-center">
            <div class="page-header">
                <div class="pull-left">
                    <h4>{{.pageTitle}}</h4>      
                </div>
                <div class="pull-right">
                   <!--  <button type="button" class="btn btn-mystyle btn-sm refresh">刷新</button>
                    <button type="button" class="btn btn-mystyle btn-sm reback">返回</button> -->
                </div>
            </div>
        </div>
        
    </div>


    <!--content-list--> 
    <div class="content-list">
        <div class="search-box row">
            <p>
                <h5>{{.task.TaskName}} （#{{.task.Id}}）</h5>
                <pre>{{.task.Command}}</pre>
            </p>
        </div>
        <hr />
        <div class="mt20"></div>
        <div class="search-box row">
            <div class="col-md-4">
                <div class="btn-group pull-left" role="group" aria-label="...">
                    <div class="btn-group" role="group">
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            批量操作
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            
                            <li><a href="javascript:;" onclick="javascript:batch('delete');"> <span class="glyphicon glyphicon-remove-sign"></span> 删除</a></li>
                        </ul>
                    </div>

                    <button type="button" class="btn btn-default reback">返回</button>
                </div>
            </div>
            <div class="col-md-8">
                
            </div>
            
        </div>

        <div class="clearfix"></div>
        <div class="table-margin">
            <form id="form-list" method="post" action="">
                <table class="table table-bordered table-header">
                    <thead>
                        <tr>
                            <td><input type="checkbox" name="all_check" /></td>
                            <td>ID</td>
                            <td width="20%">开始时间</td>
                            <td>执行时间</td>
                            <td>输出</td>
                            <td>状态</td>
                            <td width="10%">操作</td>
                        </tr>
                    </thead>
                    <tbody>
                        {{range $k,$v := .list}}
                        <tr>
                            <td class="chk"><input type="checkbox" name="ids" value="{{$v.id}}" /></td>
                            <td> {{$v.id}} </td>
                            <td> {{$v.start_time}} </td>
                            <td>{{$v.process_time}} 秒</td>
                            <td>{{$v.ouput_size}}</td>

                            <td>
                                {{if eq $v.status 0}}
                                <span class="glyphicon glyphicon-ok-sign brand-success" aria-hidden="true"> </span>正常
                                {{else if eq $v.status -1}}
                                <span class="glyphicon glyphicon-remove-sign brand-danger" aria-hidden="true"> </span> 出错
                                {{else if eq $v.status -2}}
                                <span class="glyphicon glyphicon-exclamation-sign brand-warning" aria-hidden="true"> </span> 超时
                                {{end}}

                            </td>
                            <td>
                               <a class="btn btn-info btn-xs" href="{{urlfor "TaskController.ViewLog"}}?id={{$v.id}}">
                                <i class="glyphicon glyphicon-file"></i> 详情
                                </a> 
                            </td>
                        </tr>
                        {{end}}
                        
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="7">
                                <div class="pull-right">
                                    {{str2html .pageBar}}
                                </div>
                            </td>
                        </tr>
                    </tfoot>
                </table>
            </form>
        </div>
    </div>
</div> 

<script>


function batch(action) {
    if ($("input[name='ids']:checked").size() < 1) {
        alert_message("请选择要操作的任务","alert-danger","alert-success");
    } else {
        if (!confirm("确实要删除所选吗？")) return;
        var url = "{{urlfor "TaskController.LogBatch"}}";
        $.post(url + "?action=" + action, $("#form-list").serialize(), function(out) {
            if (out.status != 0) {
                alert_message(out.msg,"alert-danger","alert-success");
            } else {
                window.location.reload();
            }
        }, "json");
    }
    return false;
}
</script>