From 7b425e4df7589adb58c64834453bf4971b684527 Mon Sep 17 00:00:00 2001 From: Ricardo Carneiro Date: Wed, 16 Oct 2024 23:43:47 -0300 Subject: [PATCH] feat: logs e cores dos planos --- VCart.Domain/Blinks.Domain.csproj | 8 ++++++ VCart.Domain/Entities/LinkBio.cs | 36 ++++++++++++++++++++++++ VCart.Domain/Entities/PageBio.cs | 18 ++++++++++++ VCart.Domain/Entities/PersonUser.cs | 6 +++- VCart.Domain/Entities/ServiceLinkPart.cs | 17 +++++++++++ VCart.Domain/Entities/ServiceLinks.cs | 34 ++++++++++++++++++++++ VCart.Domain/Entities/UserPlan.cs | 7 +++-- VCart.Infra/Blinks.Infra.csproj | 5 ++++ VCart/Blinks.csproj | 5 ++++ VCart/{VCart.sln => Blinks.sln} | 0 VCart/Controllers/HomeController.cs | 5 ++-- VCart/Controllers/LoginController.cs | 6 ++-- VCart/LogConfig/LogCredentials.cs | 12 ++++++++ VCart/LogConfig/LogLabelProvider.cs | 27 ++++++++++++++++++ VCart/Program.cs | 25 ++++++++++++++++ VCart/Resource.pt-BR.resx | 4 +-- VCart/Views/Plans/Index.cshtml | 9 +++++- VCart/Views/Plans/Index.cshtml.css | 12 ++++---- VCart/Views/Shared/_Layout.cshtml | 5 ++-- VCart/Views/Shared/_Layout.cshtml.css | 14 ++++----- 20 files changed, 227 insertions(+), 28 deletions(-) create mode 100644 VCart.Domain/Entities/LinkBio.cs create mode 100644 VCart.Domain/Entities/PageBio.cs create mode 100644 VCart.Domain/Entities/ServiceLinkPart.cs create mode 100644 VCart.Domain/Entities/ServiceLinks.cs rename VCart/{VCart.sln => Blinks.sln} (100%) create mode 100644 VCart/LogConfig/LogCredentials.cs create mode 100644 VCart/LogConfig/LogLabelProvider.cs diff --git a/VCart.Domain/Blinks.Domain.csproj b/VCart.Domain/Blinks.Domain.csproj index 58c2942..b6e91af 100644 --- a/VCart.Domain/Blinks.Domain.csproj +++ b/VCart.Domain/Blinks.Domain.csproj @@ -6,6 +6,14 @@ enable + + + + + + + + diff --git a/VCart.Domain/Entities/LinkBio.cs b/VCart.Domain/Entities/LinkBio.cs new file mode 100644 index 0000000..c858bac --- /dev/null +++ b/VCart.Domain/Entities/LinkBio.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Blinks.Domain.Entities +{ + public class LinkBio + { + /// + /// Ordem de exibição + /// + public int OrderNum { get; set; } + + /// + /// Parte customizada do link + /// + public string UrlData { get; set; } + + /// + /// Parte fixa do link (obter do service links quando cadastrar) + /// + public string ServiceUrl { get; set; } + + /// + /// Url/caminho do PNG do link + /// + public string ServiceIcon { get; set; } + + /// + /// Exibir/nao exibir + /// + public bool IsVisible { get; set; } + } +} diff --git a/VCart.Domain/Entities/PageBio.cs b/VCart.Domain/Entities/PageBio.cs new file mode 100644 index 0000000..219ff29 --- /dev/null +++ b/VCart.Domain/Entities/PageBio.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Blinks.Domain.Entities +{ + public class PageBio + { + public int Id { get; set; } + public string UrlParte1 { get; set; } + public string UrlParte2 { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public List? Links { get; set; } + } +} diff --git a/VCart.Domain/Entities/PersonUser.cs b/VCart.Domain/Entities/PersonUser.cs index 11e1a31..2b5a2a3 100644 --- a/VCart.Domain/Entities/PersonUser.cs +++ b/VCart.Domain/Entities/PersonUser.cs @@ -16,8 +16,12 @@ namespace Blinks.Domain.Entities public string LastName => Name.LastName; public Email Email { get; private set; } public DateChanged DateChanged { get; private set; } - public bool IsCompleted { get; private set; } + public bool IsProfileCompleted { get; private set; } public int CountryId { get; private set; } public int BusinessAreaId { get; private set; } + public string DesiredName { get; private set; } + public DateTime CreatedAt { get; private set; } + public UserPlan? Plano { get; private set; } + public List? PastPlans { get; private set; } } } diff --git a/VCart.Domain/Entities/ServiceLinkPart.cs b/VCart.Domain/Entities/ServiceLinkPart.cs new file mode 100644 index 0000000..9da3b32 --- /dev/null +++ b/VCart.Domain/Entities/ServiceLinkPart.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Blinks.Domain.Entities +{ + public class ServiceLinkPart + { + public int OrderNum { get; set; } + public string Name { get; set; } + public string VariableName { get; set; } + public string Value { get; set; } + public bool CanUserEdit { get; set; } + } +} diff --git a/VCart.Domain/Entities/ServiceLinks.cs b/VCart.Domain/Entities/ServiceLinks.cs new file mode 100644 index 0000000..b596c59 --- /dev/null +++ b/VCart.Domain/Entities/ServiceLinks.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Blinks.Domain.Entities +{ + /// + /// Vai ler uma lista estatica do BD com os links dos serviços + /// + public class ServiceLink + { + /// + /// Id do serviço + /// + public string Id { get; set; } + + /// + /// Nome do serviço + /// + public string Name { get; set; } + + /// + /// Guarda a primeira parta da url do serviço + /// + public string FirstPart { get; set; } + + /// + /// Guarda outras partes/parametros da url (indicando partes customizaveis) + /// + public List Parts { get; set; } + } +} diff --git a/VCart.Domain/Entities/UserPlan.cs b/VCart.Domain/Entities/UserPlan.cs index 4dffacb..11dd18d 100644 --- a/VCart.Domain/Entities/UserPlan.cs +++ b/VCart.Domain/Entities/UserPlan.cs @@ -9,11 +9,12 @@ namespace Blinks.Domain.Entities public class UserPlan { public int Id { get; set; } - public string Name { get; set; } - public string Description { get; set; } - public string UserPlanId { get; set; } + public string IdPagto { get; private set; } + public string EmailPagto { get; private set; } + public DateTime? DatePagto { get; private set; } + public DateTime? DateUntil { get; private set; } } } diff --git a/VCart.Infra/Blinks.Infra.csproj b/VCart.Infra/Blinks.Infra.csproj index 52787ab..41cbdd4 100644 --- a/VCart.Infra/Blinks.Infra.csproj +++ b/VCart.Infra/Blinks.Infra.csproj @@ -9,6 +9,11 @@ + + + + + diff --git a/VCart/Blinks.csproj b/VCart/Blinks.csproj index 3d940e9..85fe4e3 100644 --- a/VCart/Blinks.csproj +++ b/VCart/Blinks.csproj @@ -12,6 +12,11 @@ + + + + + diff --git a/VCart/VCart.sln b/VCart/Blinks.sln similarity index 100% rename from VCart/VCart.sln rename to VCart/Blinks.sln diff --git a/VCart/Controllers/HomeController.cs b/VCart/Controllers/HomeController.cs index 2836301..d9491cc 100644 --- a/VCart/Controllers/HomeController.cs +++ b/VCart/Controllers/HomeController.cs @@ -6,15 +6,16 @@ namespace Blinks.Controllers { public class HomeController : Controller { - private readonly ILogger _logger; + private readonly ILogger logger; public HomeController(ILogger logger) { - _logger = logger; + this.logger = logger; } public IActionResult Index() { + this.logger.LogInformation("Home carregada!"); return View(); } diff --git a/VCart/Controllers/LoginController.cs b/VCart/Controllers/LoginController.cs index edc066d..10688a0 100644 --- a/VCart/Controllers/LoginController.cs +++ b/VCart/Controllers/LoginController.cs @@ -18,11 +18,11 @@ namespace Blinks.Controllers { this.logger = logger; this.httpClientFactory = httpClientFactory; - } + } - public IActionResult Index() + public IActionResult Index() { - return View("~/Views/Login/Index.cshtml"); + return View("~/Views/Login/Index.cshtml"); } [HttpPost] diff --git a/VCart/LogConfig/LogCredentials.cs b/VCart/LogConfig/LogCredentials.cs new file mode 100644 index 0000000..aa357ac --- /dev/null +++ b/VCart/LogConfig/LogCredentials.cs @@ -0,0 +1,12 @@ +//using Serilog.Sinks.Loki; + +//namespace Blinks.LogConfig +//{ +// public class LogCredentials : LokiCredentials +// { +// public LogCredentials(string url) +// { +// this.Url = url; +// } +// } +//} diff --git a/VCart/LogConfig/LogLabelProvider.cs b/VCart/LogConfig/LogLabelProvider.cs new file mode 100644 index 0000000..dc8d067 --- /dev/null +++ b/VCart/LogConfig/LogLabelProvider.cs @@ -0,0 +1,27 @@ +//using Serilog.Sinks.Loki.Labels; + +namespace Blinks.LogConfig +{ + //public class LogLabelProvider : ILogLabelProvider + //{ + // public IList GetLabels() + // { + // return new List + // { + // new LokiLabel("app", "blinks"), + // new LokiLabel("namespace", "test") + // }; + // } + + // public IList PropertiesAsLabels { get; set; } = new List + // { + // "level", // Since 3.0.0, you need to explicitly add level if you want it! + // "MyLabelPropertyName" + // }; + // public IList PropertiesToAppend { get; set; } = new List + // { + // "MyAppendPropertyName" + // }; + // //public LokiFormatterStrategy FormatterStrategy { get; set; } = LokiFormatterStrategy.SpecificPropertiesAsLabelsOrAppended; + //} +} diff --git a/VCart/Program.cs b/VCart/Program.cs index 5fa2042..acf7a95 100644 --- a/VCart/Program.cs +++ b/VCart/Program.cs @@ -1,15 +1,37 @@ +using Blinks.LogConfig; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Google; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.Extensions.Options; +using Serilog; +using Serilog.Sinks.Grafana.Loki; using Stripe; using Stripe.Forwarding; using System.Globalization; +using System.Security.Policy; var builder = WebApplication.CreateBuilder(args); +//var credentials = new BasicAuthCredentials("http://192.168.0.82:3100"); +//var credentials = new LogCredentials("http://192.168.0.82:3100"); + +Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .Enrich.FromLogContext() + .Enrich.WithProperty("app", "blinks") + .WriteTo.Console() + .WriteTo.File("logs/log.txt", rollingInterval: RollingInterval.Day) + .WriteTo.GrafanaLoki( + uri: "http://192.168.0.82:3100", + propertiesAsLabels: new List { "app", "blinks" }, + restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Debug + ) + .CreateLogger(); + +builder.Host.UseSerilog(); + // Add services to the container. builder.Services.AddControllersWithViews(); @@ -64,6 +86,7 @@ builder.Services.Configure(options => StripeConfiguration.ApiKey = builder.Configuration["Stripe:SecretKey"]; builder.Services.AddControllersWithViews(); builder.Services.AddHttpClient(); +builder.Services.AddSerilog(); var app = builder.Build(); @@ -93,6 +116,8 @@ app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); +app.UseSerilogRequestLogging(); + app.UseRequestLocalization(); app.Run(); diff --git a/VCart/Resource.pt-BR.resx b/VCart/Resource.pt-BR.resx index 571a03c..13cb1d9 100644 --- a/VCart/Resource.pt-BR.resx +++ b/VCart/Resource.pt-BR.resx @@ -217,10 +217,10 @@ Email - Empresa / Grupo + Nome desejado para sua bio/página - Nome desejado para o grupo + Nome desejado na sua bio/página Dados iniciais diff --git a/VCart/Views/Plans/Index.cshtml b/VCart/Views/Plans/Index.cshtml index ffe33d9..03dc44a 100644 --- a/VCart/Views/Plans/Index.cshtml +++ b/VCart/Views/Plans/Index.cshtml @@ -21,7 +21,14 @@
  • Sem contador de Visualizações
  • diff --git a/VCart/Views/Plans/Index.cshtml.css b/VCart/Views/Plans/Index.cshtml.css index ce32725..3a1ee70 100644 --- a/VCart/Views/Plans/Index.cshtml.css +++ b/VCart/Views/Plans/Index.cshtml.css @@ -11,7 +11,7 @@ License: MIT BACKGROUND COLORS ============================================================*/ .db-bk-color-one { - background-color: #A9B595; + background-color: #D9EDD2; } .db-bk-color-two { @@ -19,7 +19,7 @@ BACKGROUND COLORS } .db-bk-color-three { - background-color: #97A47E; + background-color: #D9EDD2; } .db-bk-color-six { @@ -74,10 +74,10 @@ BACKGROUND COLORS } -.db-pricing-eleven .price { - background-color: rgba(0, 0, 0, 0); - color: #FFFFFF; -} + .db-pricing-eleven .price { + background-color: rgba(0, 0, 0, 0); + color: #353000; + } .db-pricing-eleven .price small { color: #63783F; diff --git a/VCart/Views/Shared/_Layout.cshtml b/VCart/Views/Shared/_Layout.cshtml index 81ec76f..3d183f9 100644 --- a/VCart/Views/Shared/_Layout.cshtml +++ b/VCart/Views/Shared/_Layout.cshtml @@ -122,10 +122,9 @@ }); $(document).ready(function () { - //$('#wrapper').fadeIn('slow'); - + $('#wrapper').fadeIn('slow'); $('a.nav-link').click(function () { - //$('#wrapper').fadeOut('slow'); + $('#wrapper').fadeOut('slow'); }); setActiveByLocation(); }); diff --git a/VCart/Views/Shared/_Layout.cshtml.css b/VCart/Views/Shared/_Layout.cshtml.css index 3fb7eac..27ff6c7 100644 --- a/VCart/Views/Shared/_Layout.cshtml.css +++ b/VCart/Views/Shared/_Layout.cshtml.css @@ -165,17 +165,17 @@ button.accept-policy { padding-right: 3px; } -.navbar .navbar-collapse ul.navbar-nav .nav-item.active { - color: white; - padding-left: 3px; - padding-right: 3px; - background-color: #C7CCB8 !important; - border-radius: 7px 7px 7px 7px; + .navbar .navbar-collapse ul.navbar-nav .nav-item.active { + color: white; + padding-left: 3px; + padding-right: 3px; + background-color: #809062 !important; + border-radius: 7px 7px 7px 7px; /* background-color: #b8f2a1 !important; */ -} + } a.nav-link.text-black { color: black !important;