<%@ Import Namespace="edu.jhu.Cas.Web" %>
<%@ Register TagPrefix="uc1" TagName="Trailer" Src="Trailer.ascx" %>
<%@ Import Namespace="System.IO" %>
<%@ Page Language="c#" Codebehind="ViewJobs.aspx.cs" AutoEventWireup="false" Inherits="edu.jhu.Cas.Web.ViewJobs" %>
<%@ Register TagPrefix="uc2" TagName="Header" Src="top.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>View Jobs</title>
    <link href="cjobs.css" rel="stylesheet" />
</head>
<body>
    <uc2:Header ID="Header" runat="server" />
    <br />
    <div>
        <i>Refresh this page to get latest info</i></div>
    <p style="margin:5 0 5 0;" class="message">
        <%=lmessage%>
    </p>
    <form runat="server">
        <table>
            <tr>
                <th class="bx">
                    Status</th>
                <th class="bx">
                    Context</th>
                <!--<th>  i do not like this 
                    Submitted</th> -->
                <th colspan="2" class="bx">
                    Name Like</th>                
            </tr>
            <tr>
                <td>
                    <asp:DropDownList ID="statusDdl" runat="server" />
                </td>
                <td>
                    <asp:DropDownList ID="targetDdl" runat="server" />
                </td>
                <!--<td>
                    <asp:DropDownList ID="sinceDdl" runat="server" />
                </td>-->
                <td>
                    <asp:TextBox runat="server" ID="nameBox" />
                </td>
                <td>
                    <asp:Button ID="filterButton" OnClick="ReLoadGrid" Text="Apply" runat="server" />
                </td>
            </tr>
        </table>
    </form>
    <asp:DataGrid ID="grid" runat="server" DataSource="<%# ds %>" BorderWidth="1px"
         AutoGenerateColumns="False" 
        CellPadding="0" CellSpacing="1">
        <HeaderStyle Font-Bold="True" />
        <Columns>
            <asp:HyperLinkColumn DataNavigateUrlField="jobid" DataNavigateUrlFormatString="jobdetails.aspx?id={0}&message=Details of {0}"
                Text="Info" Target="" />
            <asp:BoundColumn DataField="taskname" HeaderText="Name" />
            <asp:BoundColumn DataField="Query" HeaderText="Query" />
            <asp:BoundColumn DataField="tq" HeaderText="Context" />
            <asp:BoundColumn DataField="timesubmit" HeaderText="Submited" />
            <asp:BoundColumn DataField="elapsed" HeaderText="Time(h:m:s)" />
            <asp:BoundColumn DataField="rows" HeaderText="Rows" />
            <asp:BoundColumn DataField="status" HeaderText="Status" />
        </Columns>
    </asp:DataGrid><br/>
    <p>
        <%if (totalSetLinks > 1) {%>
        <b>Page:</b>&nbsp;&nbsp;<%}
                                  if (position - 5 >= 0) {%><a href="ViewJobs.aspx?position=<%=(position-5)%>">&lt;&lt;&nbsp;</a><%}
                                                                                             if (totalSetLinks > 1 && position > 0) {%><a href="ViewJobs.aspx?position=<%=(position-1)%>">&lt;</a>
        &nbsp;&nbsp;<%}%>
        <%
            if (position - 2 > 0) {%>
        <a href="ViewJobs.aspx?position=<%=0%>">
            <%=1%>
            ...&nbsp;</a><%}
                           for (int x = position - 2; x <= position + 2; x++) {
                               if (x >= 0 && x <= (totalSetLinks - 1)) {
                                   string rst = (x + 1).ToString();
                                   if (x == position) {
                                       rst = "<font color=\"red\">" + rst + "</font>";
                                       lmessage = rst;
                                   }
            %><a href="ViewJobs.aspx?position=<%=x%>"><%=rst%></a>&nbsp;<%
                                                                            }
                                                                        }
                                                                        if (position + 2 < totalSetLinks - 1) {%><a href="ViewJobs.aspx?position=<%=(totalSetLinks-1)%>">...<%=(totalSetLinks)%></a><%}
                                                                                                                        if (totalSetLinks > 1 && position + 1 < totalSetLinks) {%>&nbsp;&nbsp;<a href="ViewJobs.aspx?position=<%=(position+1)%>">&gt;</a><%}
                                                                                                                               if (totalSetLinks > 1 && position + 5 < totalSetLinks) {%>&nbsp;&nbsp;<a href="ViewJobs.aspx?position=<%=(position+5)%>">&nbsp;&gt;&gt;</a><%}%>
    </p>
    <uc1:Trailer ID="Trailer1" runat="server" cvsTag="$Name: v3_5_18 $" cvsRev="$Revision: 1.12 $">
    </uc1:Trailer>
</body>
</html>