<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyProfile.aspx.cs" Inherits="eDocument.Server.Administrator.User.MyProfile" MasterPageFile="~/Site.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
    <h1 class="skjema-admin__page-title">
        Min profil
    </h1>

    <h3 class="skjema-admin__section-title">
        Oppdater personalia
    </h3>

    <div class="skjema-admin__page__field">

        <label class="skjema-admin__page__label">
            E-post
        </label>

        <asp:TextBox 
            ID="txtEmail" 
            CssClass="skjema-admin__page__text"
            runat="server" 
            MaxLength="300" >
        </asp:TextBox>

        <asp:RequiredFieldValidator runat="server" ControlToValidate="txtEmail" ForeColor="Red" Display="Dynamic">
            *
        </asp:RequiredFieldValidator>

        <asp:RegularExpressionValidator 
            runat="server" 
            ControlToValidate="txtEmail" 
            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
            Display="Dynamic" 
            ErrorMessage="Ugyldig e-postadresse" 
            ForeColor="Red">
        </asp:RegularExpressionValidator>
        
        <asp:Label runat="server" ID="lblEmail" ForeColor="Red" />
    </div>

    <div class="skjema-admin__page__field">
        <label class="skjema-admin__page__label">
            Navn
        </label>

        <asp:TextBox 
            CssClass="skjema-admin__page__text"
            ID="txtDisplayName" 
            runat="server" 
            MaxLength="300">
        </asp:TextBox>
        
        <asp:RequiredFieldValidator runat="server" ControlToValidate="txtDisplayName" Display="Dynamic" ForeColor="Red">*</asp:RequiredFieldValidator>
    </div>

    <div class="skjema-admin__page__field">

        <div class="mb-4">
            <asp:HyperLink 
                runat="server" 
                NavigateUrl="~/User/SetPassword.aspx">
                Endre passord
            </asp:HyperLink>
        </div>
        
        <br />
        
        <asp:CheckBox ID="chkEnableTwoFactor" runat="server" Text="Aktiver to-faktor autentisering" />
        
        <br/>

        <asp:Image ID="imgQrCode" runat="server" Visible="false"  Width="150px" Height="150px" />

        <br/><br/>

        <asp:Button 
            runat="server" 
            ID="btnSetProfileInfo" 
            CssClass="skjema-admin__button skjema-admin__button--primary"
            OnClick="btnSetProfileInfo_OnClick" 
            Text="Lagre endringer" />
    </div>
 
    <asp:Label runat="server" ID="lblOkMessage" ForeColor="Green"></asp:Label>
    <asp:Label runat="server" ID="lblErrorMessage" ForeColor="Green"></asp:Label>

    <br/>
    <br/>   
    <h3 class="skjema-admin__section-title">
        Mine roller og tilganger
    </h3>

    <asp:GridView 
        runat="server" 
        ID="grid"
        DataKeyNames="CustomerId"
        ItemType="eDocument.Server.Administrator.User.AdminUserOnCustomerWithRoles"
        CssClass="skjema-admin__table"
        Border="0"
        Width="100%"
        AutoGenerateEditButton="False"
        SelectMethod="GetData"
        AutoGenerateColumns="false">
        <Columns>
            <asp:DynamicField DataField="CustomerId" Visible="False" />
            <asp:DynamicField DataField="Username" HeaderText="Brukernavn"/>
            <asp:DynamicField DataField="Name" HeaderText="Organisasjon"/>
            <asp:TemplateField HeaderText="Roller">
                <ItemTemplate>
                    <%#eDocument.Server.Administrator.User.List.ConvertToDisplayFriendlyRoles(Eval("Roles"))%>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
</asp:Content>
