<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/FiniqAppMasterPage.Master" CodeBehind="OAuth2Clients.aspx.vb" Inherits="FinIQWebApp.OAuth2Clients" %>

<asp:Content ID="Content1" ContentPlaceHolderID="headScrtipsStyles" runat="server">
    <style>
        .container {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .wrapper {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

            .wrapper > span {
                display: block;
            }

        .tbl th {
            text-align: left
        }

        .tbl td > * {
            margin-right: 10px
        }

        .tbl td > .ddl {
            width: 100px;
        }

        .ddl {
            width: 100%;
        }

        .pages {
            float: left;
            width: auto;
        }

        .filters {
            display: flex;
            gap: 10px;
            align-items: center;
        }
    </style>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server"></asp:ScriptManagerProxy>
    <script src="../FinIQJS/SortFilter_Grid.js"></script>

    <div class="container">
        <div class="filters">
            <label class="lbl">Record(s) Per Page:</label>
            <asp:TextBox ID="txtPageSize" CssClass="txt" Width="40" Height="28" runat="server" Text="10" TextMode="Number" MaxLength="2"></asp:TextBox>
            <asp:Button ID="btnLoad" CssClass="btn" runat="server" Text="Load" OnClick="btnLoad_Click" />
            <asp:Button ID="btnExcel" runat="server" CssClass="btn" Text="Export Results(All)" OnClick="btnExcel_Click"></asp:Button>
        </div>

        <div class="wrapper">
            <span>Insert New Record:</span>
            <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" class="tbl">
                <tr>
                    <th style="width: 140px">Username:</th>
                    <th style="width: 140px">Password:</th>
                    <th style="width: 100px">Role:</th>
                    <th></th>
                </tr>
                <tr>
                    <td>
                        <asp:TextBox ID="txtNewUsername" CssClass="txt" runat="server" />
                    </td>
                    <td>
                        <asp:TextBox ID="txtNewPassword" CssClass="txt" runat="server" />
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlNewRole" CssClass="ddl" runat="server">
                            <asp:ListItem Text="Admin" Value="admin"></asp:ListItem>
                            <asp:ListItem Text="User" Value="user"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td>
                        <asp:Button ID="btnAddNewClient" CssClass="btn" runat="server" Text="Insert" OnClick="btnAddNewClient_Click" />
                    </td>
                </tr>
            </table>
        </div>

        <div class="wrapper">
            <asp:GridView ID="gvClients" runat="server" AutoGenerateColumns="False" CssClass="Grid" BorderStyle="None" BorderWidth="0px"
                ShowFooter="False" PageSize="10" AllowPaging="true" AllowSorting="true" ShowHeaderWhenEmpty="true" EmptyDataText="No Records Found"
                OnRowEditing="gvClients_RowEditing" OnRowCancelingEdit="gvClients_RowCancelingEdit" OnPageIndexChanging="gvClients_PageIndexChanging"
                OnRowUpdating="gvClients_RowUpdating" OnRowDeleting="gvClients_RowDeleting" OnRowDataBound="gvClients_RowDataBound">
                <EditRowStyle CssClass="GridItemSelect" />
                <RowStyle CssClass="GridItem" />
                <HeaderStyle CssClass="GridHeader" />
                <FooterStyle CssClass="GridFooter" />
                <PagerStyle CssClass="GridPager" />
                <PagerSettings Mode="Numeric"
                    Visible="true"
                    Position="Bottom" PageButtonCount="3" />
                <Columns>
                    <asp:TemplateField HeaderText="Id" ItemStyle-Width="140" Visible="false">
                        <ItemTemplate>
                            <asp:Label ID="lblId" CssClass="lbl" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="ClientId" ItemStyle-Width="180">
                        <ItemTemplate>
                            <asp:Label ID="lblClientId" CssClass="lbl" runat="server" Text='<%# Eval("ClientId") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="ClientSecret" ItemStyle-Width="180">
                        <ItemTemplate>
                            <asp:Label ID="lblClientSecret" CssClass="lbl" runat="server" Text='<%# Eval("ClientSecret") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Username" ItemStyle-Width="140">
                        <ItemTemplate>
                            <asp:Label ID="lblUsername" CssClass="lbl" runat="server" Text='<%# Eval("Username") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Password" ItemStyle-Width="140">
                        <ItemTemplate>
                            <asp:Label ID="lblPassword" CssClass="lbl" runat="server" Text='<%# Eval("Password") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtPassword" CssClass="txt" runat="server" Text='<%# Eval("Password") %>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Role" ItemStyle-Width="140">
                        <ItemTemplate>
                            <asp:Label ID="lblRole" CssClass="lbl" runat="server" Text='<%# Eval("Role") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="ddlRole" CssClass="ddl" runat="server" SelectedValue='<%# Eval("Role") %>'>
                                <asp:ListItem Text="Admin" Value="admin"></asp:ListItem>
                                <asp:ListItem Text="User" Value="user"></asp:ListItem>
                            </asp:DropDownList>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:CommandField HeaderText="Action" ButtonType="Link" InsertText="Add" ShowEditButton="true"
                        ShowDeleteButton="true" EditText="Update" />
                </Columns>
            </asp:GridView>
            <div class="pagination">
                <asp:Repeater ID="pageRepeater" runat="server">
                    <ItemTemplate>
                        <asp:LinkButton CssClass="GridPager pages" ID="lnkPage" runat="server" Text='<%#Eval("Text") %>' CommandArgument='<%# Eval("Value") %>'
                            Enabled='<%# Eval("Enabled") %>' OnClick="lnkPage_Click"></asp:LinkButton>
                    </ItemTemplate>
                </asp:Repeater>
            </div>
        </div>
    </div>
</asp:Content>
