Esempio n. 1
0
File: TopBar.cs Progetto: qiqi545/HQ
        public override async void Render(Ui ui)
        {
            var accessor   = ui.Context.UiServices.GetRequiredService <IHttpContextAccessor>();
            var connection = accessor.HttpContext.Features.Get <IHttpConnectionFeature>();
            var local      = $"{connection?.LocalIpAddress}:{connection?.LocalPort}";

            ui.BeginDiv(new { @class = "ui fixed inverted menu" });
            {
                ui.BeginDiv(new { @class = "ui container" });
                {
                    ui.BeginElement("a", new { href = "#", @class = "header item" });
                    {
                        ui.Element("img", "HQ",
                                   new { @class = "logo", src = "assets/images/logo.png", style = "margin-right: 1.5em;" });
                    }
                    ui.EndElement("a");

                    ui.BeginA("item", id: "sidebar-btn");
                    ui.I(new { @class = "sidebar icon" });
                    ui.Literal("Menu");
                    ui.EndA();
                    ui.OnReady(@"
$('#sidebar-btn').click(function() {
    $('.ui.sidebar')
        .sidebar('toggle')
        .sidebar({ context: $('.ui.basic.section')});
});");
                    ui.BeginDiv(new { @class = "ui simple dropdown item" });
                    {
                        ui.Literal("Docs ");
                        ui.Element("i", new { @class = "dropdown icon" });
                        ui.BeginDiv(new { @class = "menu" });
                        {
                            ui.Div("Specs", new { @class = "header" });
                            ui.BeginA("item", href: "/meta/postman").Icon(BusinessIcons.FileOutline)
                            .Literal("Postman 2.1").EndA();
                            ui.BeginA("item", href: "/meta/swagger").Icon(BusinessIcons.FileOutline)
                            .Literal("Swagger 2.0").EndA();

                            ui.Div(new { @class = "divider" });

                            ui.Div("Help Pages", new { @class = "header" });
                            ui.BeginA("item", href: "/docs/swagger").Icon(BusinessIcons.Book).Literal("Swagger UI")
                            .EndA();
                        }
                        ui.EndDiv();
                    }
                    ui.EndDiv();

                    if (ui.Context.User.Identity.IsAuthenticated)
                    {
                        ui.BeginDiv(new { @class = "right menu" });
                        {
                            ui.BeginDiv("ui dropdown item");
                            {
                                ui.Literal("Language ");
                                ui.Element("i", new { @class = "dropdown icon" });
                                ui.BeginDiv(new { @class = "menu" });
                                {
                                    ui.BeginA("item", href: "#").Icon(BusinessIcons.Globe).Literal("English").EndA();
                                }
                                ui.EndDiv();
                            }
                            ui.EndDiv();

                            ui.BeginDiv("item");
                            {
                                var id = ui.NextId();
                                ui.Div("Sign Out", new { @class = "ui primary button", id = id.ToString() });
                                if (ui.OnClick())
                                {
                                    await accessor.HttpContext.SignOutAsync();
                                }
                            }
                            ui.EndDiv();
                        }
                        ui.EndDiv();
                    }
                }
                ui.EndDiv();
            }
            ui.EndDiv();
        }