@inject IWebHelper webHelper
@inject IDateTimeHelper dateTimeHelper
@inject IPermissionService permissionService
@inject ICustomerService customerService
@inject IEventPublisher eventPublisher
@inject LocalizationSettings localizationSettings
@inject StoreInformationSettings storeInformationSettings
@inject Nop.Services.Localization.ILanguageService languageService

@using Nop.Core.Domain
@using Nop.Core.Domain.Localization
@using Nop.Services.Customers
@using Nop.Services.Helpers
@using Nop.Services.Security

@{
    var returnUrl = webHelper.GetRawUrl(Context.Request);

    //page title
    string adminPageTitle = !string.IsNullOrWhiteSpace(ViewBag.PageTitle) ? ViewBag.PageTitle + " / " : "";
    adminPageTitle += T("Admin.PageTitle").Text;

    //has "Manage Maintenance" permission?
    var canManageMaintenance = await permissionService.AuthorizeAsync(StandardPermission.System.MANAGE_MAINTENANCE);

    //avatar
    var currentCustomer = await workContext.GetCurrentCustomerAsync();
    
    //event
    await eventPublisher.PublishAsync(new PageRenderingEvent(NopHtml));

    //info: we specify "Admin" area for actions and widgets here for cases when we use this layout in a plugin that is running in a different area than "admin"
}
<!DOCTYPE html>
<html lang="@CultureInfo.CurrentUICulture.TwoLetterISOLanguageName" dir="@Html.GetUIDirection(localizationSettings.IgnoreRtlPropertyForAdminArea)">
<head>
    <title>@adminPageTitle</title>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    
    @NopHtml.GenerateHeadCustom()

    @* CSS & Script resources *@
    @{
        await Html.RenderPartialAsync("_AdminScripts");
    }

    @*Insert favicon and app icons head code*@
    @await Component.InvokeAsync(typeof(FaviconViewComponent))
</head>
<body class="hold-transition sidebar-mini layout-fixed control-sidebar-slide-open">
    <div class="throbber">
        <div class="curtain">
        </div>
        <div class="curtain-content">
            <div>
                <h1 class="throbber-header">@T("Common.Wait")</h1>
                <p>
                    <img src="@Url.Content("~/css/admin/images/throbber-synchronizing.gif")" alt="" />
                </p>
            </div>
        </div>
    </div>
    <div id="ajaxBusy">
        <span>&nbsp;</span>
    </div>
    <div class="wrapper">
        @if (IsSectionDefined("header"))
        {
            @RenderSection("header")
        }
        else
        {
            @await Component.InvokeAsync(typeof(AdminWidgetViewComponent), new { widgetZone = AdminWidgetZones.HeaderBefore })
            <nav class="main-header navbar navbar-expand-md navbar-dark bg-dark">
                <ul class="navbar-nav pl-2 pl-md-0">
                    <li class="nav-item">
                        <a class="nav-link" id="nopSideBarPusher" data-widget="pushmenu" href="#"><i class="fa fa-bars"></i></a>
                    </li>
                    @await Component.InvokeAsync(typeof(AdminWidgetViewComponent), new { widgetZone = AdminWidgetZones.HeaderToggleAfter })
                </ul>
                <a href="@Url.Content("~/Admin")" class="brand-link navbar-dark">
                    <img src="~/css/admin/images/logo.png" alt="logo.png" class="brand-image logo d-block d-md-none d-sm-block d-sm-none">
                </a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                @await Component.InvokeAsync(typeof(AdminWidgetViewComponent), new { widgetZone = AdminWidgetZones.HeaderNavbarBefore })
                <div class="collapse navbar-collapse" id="navbarText">
                    <ul class="navbar-nav ml-auto pl-2">
                        <li class="nav-item">
                            @await Component.InvokeAsync(typeof(AdminLanguageSelectorViewComponent))
                        </li>
                        @if (await customerService.IsRegisteredAsync(currentCustomer))
                        {
                            <li class="nav-item">
                                <a href="#" class="nav-link disabled">@await customerService.GetCustomerFullNameAsync(currentCustomer)</a>
                            </li>
                            <li class="nav-item">
                                <a asp-controller="Customer" asp-action="Logout" asp-area="" class="nav-link">@T("Admin.Header.Logout")</a>
                            </li>
                        }
                        <li class="nav-item">
                            @await Component.InvokeAsync(typeof(AdminWidgetViewComponent), new { widgetZone = AdminWidgetZones.HeaderMiddle })
                        </li>
                        <li class="nav-item">
                            <a asp-controller="Home" asp-action="Index" asp-area="" class="nav-link">@T("Admin.Header.PublicStore")</a>
                        </li>
                        @if (canManageMaintenance)
                        {
                            <li class="nav-item dropdown">
                                <a class="nav-link" href="#" data-toggle="dropdown">
                                    <i class="fas fa-gears"></i>
                                </a>
                                <ul class="maintenance-menu dropdown-menu dropdown-menu-right" role="menu">
                                    <li class="dropdown-item">
                                        <form asp-controller="Common" asp-action="ClearCache" asp-area="@AreaNames.ADMIN">
                                            <input name="returnurl" type="hidden" value="@returnUrl">
                                            <div class="input-group-append">
                                                <button type="submit" style="width:210px;background-color: Transparent;">
                                                    <span>@T("Admin.Header.ClearCache")</span>
                                                </button>
                                            </div>
                                        </form>
                                    </li>
                                    <li class="dropdown-item">
                                        <form asp-controller="Common" asp-action="RestartApplication" asp-area="@AreaNames.ADMIN">
                                            <input name="returnurl" type="hidden" value="@returnUrl">
                                            <button id="restart-application" type="submit" style="width:210px;background-color: Transparent;">
                                                <span>@T("Admin.Header.RestartApplication")</span>
                                            </button>
                                            <script>
                                                $(function() {
                                                    $("#restart-application").click(function (e) {
                                                        showThrobber('@Html.Raw(JavaScriptEncoder.Default.Encode(T("Admin.Header.RestartApplication.Progress").Text))');
                                                    });
                                                });
                                            </script>
                                        </form>
                                    </li>
                                </ul>
                            </li>
                        }
                    </ul>
                </div>
                @await Component.InvokeAsync(typeof(AdminWidgetViewComponent), new { widgetZone = AdminWidgetZones.HeaderNavbarAfter })
            </nav>

            @await Component.InvokeAsync(typeof(AdminWidgetViewComponent), new { widgetZone = AdminWidgetZones.HeaderAfter })
        }
        @if (IsSectionDefined("headermenu"))
        {
            @RenderSection("headermenu")
        }
        else
        {
            <aside class="main-sidebar sidebar-dark-primary elevation-4">
                <!-- Brand Logo -->
            <a href="@Url.Content("~/Admin")" class="brand-link navbar-dark logo-switch">
                    <img src="~/css/admin/images/logo.png" alt="logo.png" class="brand-image-xl logo-xl">
                    <img src="~/css/admin/images/logo-mini.png" alt="logo.png" class="brand-image-xs logo-xs">
                </a>
                <div class="sidebar">
                    <div class="sidebar-form">
                        <div id="search-box">
                            <input type="text" class="form-control admin-search-box typeahead" placeholder="@T("Admin.Menu.Search")">
                        </div>
                    </div>
                    <nav class="mt-2">
                        @await Component.InvokeAsync(typeof(AdminWidgetViewComponent), new { widgetZone = AdminWidgetZones.SearchBoxBefore })
                        <script>
                            $(function() {
                                Admin.Search.init();
                            });
                        </script>
                        @await Component.InvokeAsync(typeof(AdminWidgetViewComponent), new { widgetZone = AdminWidgetZones.MenuBefore })
                        @await Html.PartialAsync("Menu")

                    </nav>
                </div>
            </aside>
        }
        <div class="content-wrapper">
            @await Html.PartialAsync("Notifications")
            <nop-antiforgery-token />
            @RenderBody()
        </div>
        <div class="main-footer">
            <div class="container-fluid">
                <div class="col-md-12">
                    <div class="row">
                        @if (!storeInformationSettings.HidePoweredByNopCommerce)
                        {
                            <div class="col-md-4 col-xs-12 text-md-left text-center">
                                @*Would you like to remove the "Powered by nopCommerce" link in the bottom of the footer?
                                    Please find more info at https://www.nopcommerce.com/nopcommerce-copyright-removal-key*@
                                Powered by <a href="@(OfficialSite.Main + Utm.OnAdminFooter)" target="_blank">nopCommerce</a>
                            </div>
                        }
                        else
                        {
                            <div class="col-md-4 col-xs-12"></div>
                        }
                        <div class="col-md-4 col-xs-12 text-center">
                            @((await dateTimeHelper.ConvertToUserTimeAsync(DateTime.Now)).ToString("f", CultureInfo.CurrentCulture))
                        </div>
                        <div class="col-md-4 col-xs-12 text-md-right text-center">
                            <b>nopCommerce version @NopVersion.FULL_VERSION</b>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        var AdminLTEOptions = {
            boxWidgetOptions: {
                boxWidgetIcons: {
                    collapse: 'fa-minus',
                    open: 'fa-plus'
                }
            }
        };
    </script>
    @{
        //scroll to a selected card (if specified)
        var selectedCardName = Html.GetSelectedCardName();
        if (!String.IsNullOrEmpty(selectedCardName))
        {
            <script>
                location.hash = '#@(selectedCardName)';
            </script>
        }
    }
    <a id="backTop" class="btn btn-back-top bg-teal"></a>
    <script>
        $(function() {
            //enable "back top" arrow
            $('#backTop').backTop();

            //enable tooltips
            $('[data-toggle="tooltip"]').tooltip({ placement: 'bottom' });
        });
    </script>

    @NopHtml.GenerateScripts(ResourceLocation.Footer)
    @NopHtml.GenerateInlineScripts(ResourceLocation.Footer)
</body>
</html>