<%@ control language="VB" autoeventwireup="false" inherits="RCC_System_AccessControl_CC_LoginLockdown, MachSol.MachPanel.Web" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="EM" %>

<%@ Register Src="~/RCC/System/AccessControl/CC/LockedAccounts.ascx" TagPrefix="UC" TagName="LockedAccounts" %>

<div class="card">
    <div class="header">
        <h3>
            <asp:Literal ID="lbl_title" runat="server" Text='Login Lockdown Policy' EnableViewState="false"></asp:Literal>
        </h3>
    </div>
    <div class="body">

        <div class="row">
            <div class="col-sm-3 col-xs-12 row-label">
                <label>
                    <asp:Literal ID="Literal7" runat="server" Text="<%$ Resources:Content,strEnabled%>" />:
                </label>
            </div>
            <div class="col-sm-9 col-xs-12">
                <div class="form-group">
                    <asp:CheckBox ID="CB_IsEnabled" runat="server" Text=" " />
                </div>
            </div>
        </div>
        <div id="login-lockdown-policy-detail" class="hide">
            <div class="row">
                <div class="col-xs-12">
                    <strong>When enabled, this policy will lock down accounts on failed attempts to login to control panel. This policy will only be applicable when using Control Panel Authentication. For third party SSO these settings will not apply.
                    </strong>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-3 col-xs-12 row-label">
                    <asp:Label ID="Lbl_MaxAllowedAttempts" runat="server" Text='Max Allowed Attempts' EnableViewState="false"></asp:Label>:
                </div>
                <div class="col-sm-4  col-xs-12">
                    <asp:DropDownList ID="Ddl_MaxAllowedAttempts" runat="server">
                    </asp:DropDownList>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-3 col-xs-12 row-label">
                    <asp:Label ID="Lbl_WithinDuration" runat="server" Text='Within Duration (In Minutes)' EnableViewState="false"></asp:Label>
                </div>
                <div class="col-sm-4  col-xs-12">
                    <asp:DropDownList ID="Ddl_WithinDuration" runat="server">
                    </asp:DropDownList>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-3 col-xs-12 row-label">
                    <asp:Label ID="Lbl_UnblockAfter" runat="server" Text='Unblock After (In Minutes)' EnableViewState="false"></asp:Label>:
                </div>
                <div class="col-sm-4  col-xs-12">
                    <asp:DropDownList ID="Ddl_UnblockAfter" runat="server">
                    </asp:DropDownList>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-3 col-xs-12 row-label">
                    <label>
                        <asp:Literal ID="Literal1" runat="server" Text="Skip Local Addresses" />:
                    </label>
                </div>
                <div class="col-sm-9 col-xs-12">
                    <div class="form-group">
                        <asp:CheckBox ID="CB_SkipLocalAddresses" runat="server" Text=" " />
                    </div>
                </div>
            </div>
        </div>
        <div class="row  clearfix">
            <div class="col-sm-3 col-xs-12"></div>
            <div class="col-sm-9 col-xs-12">
                <asp:Button ID="Btn_Save" runat="server" Text="<%$Resources:Content,strUpdate%>" class="btn btn-primary waves-effect btnAction" />
            </div>
        </div>

        <asp:Button ID="Btn_FillLockedAccounts" runat="server" CssClass="btn-dummy" />
        <ajax:UpdatePanel ID="UP_LockedAccounts" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
            <Triggers>
                <ajax:AsyncPostBackTrigger ControlID="Btn_FillLockedAccounts" EventName="click" />
            </Triggers>
            <ContentTemplate>
                <UC:LockedAccounts ID="LockedAccounts1" runat="server" Visible="false" />
            </ContentTemplate>
        </ajax:UpdatePanel>
    </div>

</div>

<script>
    function handleIsEanbled() {
        console.log('handleIsEanbled');
        if ($get('<%= CB_IsEnabled.ClientID %>').checked)
            $('#login-lockdown-policy-detail').removeClass('hide');
        else
            $('#login-lockdown-policy-detail').addClass('hide');

        $get('<%= Btn_FillLockedAccounts.ClientID %>').click();
    }

    setTimeout(handleIsEanbled, 500);
    $('#<%= CB_IsEnabled.ClientID %>').on('change', (e) => { console.log(e); handleIsEanbled(); });
</script>

