From 49974d4ae5294275da186c54c73b815048baa211 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Sun, 12 Oct 2025 20:13:23 +0530 Subject: [PATCH 01/58] Added new config files --- appsettings.PreStaging.json | 21 +++++++++++++++++++++ appsettings.Production.json | 21 +++++++++++++++++++++ appsettings.Staging.json | 21 +++++++++++++++++++++ appsettings.json | 12 ++++++++++-- 4 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 appsettings.PreStaging.json create mode 100644 appsettings.Production.json create mode 100644 appsettings.Staging.json diff --git a/appsettings.PreStaging.json b/appsettings.PreStaging.json new file mode 100644 index 000000000..fd2b26842 --- /dev/null +++ b/appsettings.PreStaging.json @@ -0,0 +1,21 @@ +{ + "ApplicationInsights": { + "InstrumentationKey": "" + }, + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Warning", + "Microsoft": "Warning", + "Microsoft.AspNetCore": "Warning", + "System": "Warning" + } + }, + "AppConfiguration": { + "DevDomainSuffix": "-dev", + "BaseHost": "jpeevi.info", + "LocalPort": "41500", + "Scheme": "https://", + "ServerEventUrlPrefix" : "se" + } +} diff --git a/appsettings.Production.json b/appsettings.Production.json new file mode 100644 index 000000000..eb811de18 --- /dev/null +++ b/appsettings.Production.json @@ -0,0 +1,21 @@ +{ + "ApplicationInsights": { + "InstrumentationKey": "" + }, + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Error", + "Microsoft": "Error", + "Microsoft.AspNetCore": "Error", + "System": "Error" + } + }, + "AppConfiguration": { + "DevDomainSuffix": "-dev", + "BaseHost": "expressbase.com", + "LocalPort": "41500", + "Scheme": "https://", + "ServerEventUrlPrefix" : "se" + } +} diff --git a/appsettings.Staging.json b/appsettings.Staging.json new file mode 100644 index 000000000..eff72699f --- /dev/null +++ b/appsettings.Staging.json @@ -0,0 +1,21 @@ +{ + "ApplicationInsights": { + "InstrumentationKey": "" + }, + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.AspNetCore": "Warning", + "System": "Warning" + } + }, + "AppConfiguration": { + "DevDomainSuffix": "-dev", + "BaseHost": "eb-test.xyz", + "LocalPort": "41500", + "Scheme": "https://", + "ServerEventUrlPrefix" : "se" + } +} diff --git a/appsettings.json b/appsettings.json index d6672fd22..050690f14 100644 --- a/appsettings.json +++ b/appsettings.json @@ -6,8 +6,16 @@ "IncludeScopes": false, "LogLevel": { "Default": "Debug", - "System": "Information", - "Microsoft": "Information" + "Microsoft": "Warning", + "Microsoft.AspNetCore": "Warning", + "System": "Warning" } + }, + "AppConfiguration": { + "DevDomainSuffix" : "-dev", + "BaseHost" : "localhost:41500", + "LocalPort" : "41500", + "Scheme": "http://", + "ServerEventUrlPrefix" : "se" } } From d5860bb5469608d7dab52212a08860c56534dc82 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Sun, 12 Oct 2025 20:13:45 +0530 Subject: [PATCH 02/58] added a class to make config strict --- AppConfiguration.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 AppConfiguration.cs diff --git a/AppConfiguration.cs b/AppConfiguration.cs new file mode 100644 index 000000000..ced000269 --- /dev/null +++ b/AppConfiguration.cs @@ -0,0 +1,12 @@ +namespace ExpressBase.Web +{ + public sealed class AppConfiguration + { + public string DevDomainSuffix { get; set; } + public string BaseHost { get; set; } + public string Scheme { get; set; } + public string LocalPort { get; set; } + public string ServerEventUrlPrefix { get; set; } + } + +} From 8ff6f4ae13ac21f3eb0340786346c88560552867 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Sun, 12 Oct 2025 20:16:13 +0530 Subject: [PATCH 03/58] Code clean-up and optimisations ## Added * Explicit MVC compatibility: `CompatibilityVersion.Version_2_1` to lock MVC behavior to ASP.NET Core 2.1. ## Changed * **CORS:** Normalize scheme, use wildcard subdomain for configured `BaseHost`, and allow any header; fallback origins retained. * **Middleware order:** `UseCors("AllowSpecificOrigin")` moved before `UseMvc` for correct CORS enforcement. * **Framing policy:** Replace deprecated `X-Frame-Options` with CSP `frame-ancestors`; * Staging allows `{baseHost}` and subdomains. * Production restricts to `'self'`. * **App Insights (Dev):** Use SDK `DeveloperMode` instead of legacy builder flag. * **Redis DI:** Use interpolated connection string; register pooled manager via typed singleton inference. ## Fixed * **CORS baseHost check** that always fell back to hardcoded origins due to a duplicated condition. * **Scheme formatting** by ensuring `://` is present when building origins. ## Removed * `ILoggerFactory.AddConsole/AddDebug` from `Configure`; logging now expected to be configured in `Program.cs`. ## Security/Hardening * Consolidated on CSP `frame-ancestors` (modern, supported) and removed obsolete `X-Frame-Options ALLOW-FROM`. Production locked to self-framing only. --- Program.cs | 24 ++++- Startup.cs | 275 +++++++++++++++++++++++++++++++---------------------- 2 files changed, 181 insertions(+), 118 deletions(-) diff --git a/Program.cs b/Program.cs index b32900a4e..64165443e 100644 --- a/Program.cs +++ b/Program.cs @@ -4,6 +4,8 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Configuration; namespace ExpressBase.Web2 { @@ -11,6 +13,15 @@ public class Program { public static void Main(string[] args) { + + var config = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", + optional: true, reloadOnChange: true) + .AddEnvironmentVariables() + .Build(); + var host = new WebHostBuilder() .UseKestrel(options => { @@ -18,11 +29,20 @@ public static void Main(string[] args) options.Limits.RequestHeadersTimeout = TimeSpan.FromMinutes(5); options.Limits.MinResponseDataRate = null; }) + .UseConfiguration(config) .UseContentRoot(Directory.GetCurrentDirectory()) - //.UseUrls("http://*:41500/", "https://*:41502/") - .UseUrls(urls: "http://*:41500/") + .UseUrls($"http://*:{config.GetValue("AppConfiguration:LocalPort", 41500)}") + .ConfigureLogging(logging => + { + logging.ClearProviders(); + logging.AddConfiguration(config.GetSection("Logging")); + logging.AddConsole(); + logging.AddDebug(); + }) .UseStartup() .Build(); + + host.Run(); } } diff --git a/Startup.cs b/Startup.cs index 93d2e463c..0ab0d4c08 100644 --- a/Startup.cs +++ b/Startup.cs @@ -1,192 +1,205 @@ using ExpressBase.Common; using ExpressBase.Common.ServiceClients; +using ExpressBase.Web; using ExpressBase.Web.Filters; +using ExpressBase.Web.Middlewares; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Cors.Internal; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.AspNetCore.Http.Features; using ServiceStack; using ServiceStack.Redis; using System; -using System.Reflection; using System.Collections.Generic; namespace ExpressBase.Web2 { public class Startup { - public Startup(IHostingEnvironment env) - { - var builder = new ConfigurationBuilder() - .SetBasePath(env.ContentRootPath) - .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .AddEnvironmentVariables(); + private readonly IHostingEnvironment _env; + public IConfiguration Configuration { get; } - if (env.IsDevelopment()) - { - builder.AddApplicationInsightsSettings(developerMode: true); - } - Configuration = builder.Build(); + + public Startup(IConfiguration configuration, IHostingEnvironment env) + { + _env = env; + Configuration = configuration; } - public IConfigurationRoot Configuration { get; } - // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - // Add framework services. - services.AddApplicationInsightsTelemetry(Configuration); + + if (_env.IsDevelopment()) + { + services.AddApplicationInsightsTelemetry(options => { options.DeveloperMode = true; }); + } + else + { + services.AddApplicationInsightsTelemetry(Configuration); + } services.AddDataProtection(opts => { opts.ApplicationDiscriminator = "expressbase.web"; - }); // for antiforgery checking + }); + services.AddCors(options => { - options.AddPolicy("AllowSpecificOrigin", - builder => builder - .SetIsOriginAllowedToAllowWildcardSubdomains() - .WithOrigins("https://*.expressbase.com", "https://*." + RoutingConstants.STAGEHOST) - .AllowAnyMethod()); + var scheme = (Configuration["AppConfiguration:Scheme"] ?? "https://").Trim(); + + if (!scheme.Contains("://")) scheme = scheme + "://"; + + var baseHost = (Configuration["AppConfiguration:BaseHost"] ?? string.Empty).Trim(); + + options.AddPolicy("AllowSpecificOrigin", builder => + { + builder.SetIsOriginAllowedToAllowWildcardSubdomains(); + + if (!string.IsNullOrWhiteSpace(baseHost)) + { + + builder.WithOrigins($"{scheme}*.{baseHost}") + .AllowAnyMethod() + .AllowAnyHeader(); + } + else + { + + builder.WithOrigins( + "https://*.expressbase.com", + $"https://*.{RoutingConstants.STAGEHOST}" + ) + .AllowAnyMethod() + .AllowAnyHeader(); + } + }); }); - services.AddMvc(); + services.AddMvc() + .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.Configure(options => { options.Filters.Add(new CorsAuthorizationFilterFactory("AllowSpecificOrigin")); }); - services.Configure(options => - { - options.ForwardedHeaders = - ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; - }); + services.Configure(options => { + if (_env.IsProduction()) + { + options.ForwardedHeaders = + ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; + + + options.ForwardedForHeaderName = "Eb-X-Forwarded-For"; + } + else + { + options.ForwardedHeaders = + ForwardedHeaders.XForwardedFor | + ForwardedHeaders.XForwardedProto | + ForwardedHeaders.XForwardedHost; + + + options.KnownNetworks.Clear(); + options.KnownProxies.Clear(); + } + + options.ForwardLimit = 5; - options.ForwardedForHeaderName = "Eb-X-Forwarded-For"; }); + services.Configure(options => { - options.ValueCountLimit = 512; // 512 items max - options.ValueLengthLimit = 1024 * 1024 * 100; // 100MB max len form data + options.ValueCountLimit = 512; + options.ValueLengthLimit = 1024 * 1024 * 100; // 100 MB }); services.AddSingleton(); services.AddSingleton(); - // Added - uses IOptions for your settings. services.AddOptions(); - services.AddScoped(serviceProvider => + services.AddScoped(_ => { - JsonServiceClient client = new JsonServiceClient + var client = new JsonServiceClient { BaseUri = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_SERVICESTACK_EXT_URL), - RefreshTokenUri = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_GET_ACCESS_TOKEN_URL) + RefreshTokenUri = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_GET_ACCESS_TOKEN_URL), + Timeout = TimeSpan.FromMinutes(3) }; - client.Timeout = new TimeSpan(0, 3, 0); return client; }); - services.AddScoped(serviceProvider => - { - return new EbMqClient(); - }); - - services.AddScoped(serviceProvider => - { - return new EbAuthClient(); - }); - - services.AddScoped(serviceProvider => - { - return new EbStaticFileClient(); - }); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); - services.AddScoped(serviceProvider => - { - return new EbServerEventClient(); - }); - // StripeConfiguration.SetApiKey("sk_test_eOhkZcaSagCU9Hh33lcS6wQs"); - string env = Environment.GetEnvironmentVariable(EnvironmentConstants.ASPNETCORE_ENVIRONMENT); var redisServer = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_REDIS_SERVER); var redisPassword = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_REDIS_PASSWORD); var redisPort = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_REDIS_PORT); - //if (env == "Development") - //{ - // services.AddScoped(serviceProvider => - // { - // return new RedisClient(redisServer, Convert.ToInt32(redisPort), redisPassword); - // }); - //} - //else - //{ - var redisConnectionString = string.Format("redis://{0}@{1}:{2}", redisPassword, redisServer, redisPort); + + var redisConnectionString = $"redis://{redisPassword}@{redisServer}:{redisPort}"; var redisManager = new RedisManagerPool(redisConnectionString); - services.AddScoped(serviceProvider => - { - return redisManager.GetClient(); - }); - var listRWRedis = new List() { redisConnectionString }; var listRORedis = new List() { redisConnectionString.Replace("-master", "-replicas") }; - PooledRedisClientManager pooledRedisManager = new PooledRedisClientManager(listRWRedis, listRORedis); - services.AddSingleton(serviceProvider => - { - return pooledRedisManager; - }); - //} + services.AddScoped(_ => redisManager.GetClient()); + + var listRWRedis = new List { redisConnectionString }; + var listRORedis = new List { redisConnectionString.Replace("-master", "-replicas") }; + + var pooledRedisManager = new PooledRedisClientManager(listRWRedis, listRORedis); + services.AddSingleton(pooledRedisManager); + + //services.AddScoped(); //TODO: add in future for RedisRateLimitter + - ////Setting Assembly version in Redis - //AssemblyName assembly = Assembly.GetExecutingAssembly().GetName(); - //String version = assembly.Name.ToString() + " - " + assembly.Version.ToString(); - //client.Set("WebAssembly", version); + services.Configure(Configuration.GetSection("AppConfiguration")); } - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, AreaRouter areaRouter) + + public void Configure(IApplicationBuilder app, IHostingEnvironment env, AreaRouter areaRouter) { - loggerFactory.AddConsole(Configuration.GetSection("Logging")); - loggerFactory.AddDebug(); + var scheme = (Configuration["AppConfiguration:Scheme"] ?? string.Empty).Trim(); + var baseHost = (Configuration["AppConfiguration:BaseHost"] ?? string.Empty).Trim(); - //app.UseForwardedHeaders(new ForwardedHeadersOptions - //{ - // ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedHost - //}); app.UseForwardedHeaders(); + app.UseApplicationInsightsRequestTelemetry(); - if (env.IsDevelopment()) + if (env.IsDevelopment() || env.IsEnvironment("PreStaging")) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); - //app.UseHsts(); } else { app.UseExceptionHandler("/Home/Error"); } + app.UseMiddleware(); + app.UseApplicationInsightsExceptionTelemetry(); app.UseStatusCodePagesWithReExecute("/StatusCode/{0}"); - app.UseStaticFiles(new StaticFileOptions() + app.UseStaticFiles(new StaticFileOptions { - OnPrepareResponse = (context) => + OnPrepareResponse = context => { var headers = context.Context.Response.GetTypedHeaders(); headers.CacheControl = new Microsoft.Net.Http.Headers.CacheControlHeaderValue @@ -197,35 +210,65 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF } }); - app.UseMvc(routes => - { - routes.DefaultHandler = areaRouter; - //routes.MapRoute( - // name: "developer", - // template: "dev", - // defaults: new { controller = RoutingConstants.EXTCONTROLLER, action = "DevSignIn" } - //); - - routes.MapRoute( - name: "default", - template: "{controller=Ext}/{action=Index}"); - - }); app.UseCors("AllowSpecificOrigin"); + app.Use(async (context, next) => { + context.Response.Headers.Remove("X-Frame-Options"); - if (env.IsStaging()) + context.Response.Headers.Remove("Content-Security-Policy"); + + if (!string.IsNullOrWhiteSpace(baseHost)) + { + if (env.IsStaging()) + { + + context.Response.Headers.Add( + "Content-Security-Policy", + $"frame-ancestors 'self' https://{baseHost} https://*.{baseHost};" + ); + } + else if (env.IsProduction()) + { + + context.Response.Headers.Add( + "Content-Security-Policy", + "frame-ancestors 'self';" + ); + } + } + else { - context.Response.Headers.Add("X-Frame-Options", $"ALLOW-FROM SAMEDOMAIN *.{RoutingConstants.STAGEHOST}"); - context.Response.Headers.Add("Content-Security-Policy", $"frame-ancestors 'self' {RoutingConstants.STAGEHOST} *.{RoutingConstants.STAGEHOST};"); + + if (env.IsStaging()) + { + context.Response.Headers.Add( + "Content-Security-Policy", + $"frame-ancestors 'self' https://{RoutingConstants.STAGEHOST} https://*.{RoutingConstants.STAGEHOST};" + ); + } + else if (env.IsProduction()) + { + context.Response.Headers.Add( + "Content-Security-Policy", + "frame-ancestors 'self';" + ); + } } - if (env.IsProduction()) - context.Response.Headers.Add("X-Frame-Options", "ALLOW-FROM SAMEDOMAIN"); + await next(); - }); // for web forwarding with masking + }); + + + app.UseMvc(routes => + { + routes.DefaultHandler = areaRouter; + routes.MapRoute( + name: "default", + template: "{controller=Ext}/{action=Index}"); + }); } } -} +} \ No newline at end of file From 4379a7ca7fabcf4969928662a987bf16b53f9c83 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Sun, 12 Oct 2025 20:16:45 +0530 Subject: [PATCH 04/58] add new middleware to set contexts derived from the Host and URL --- Middlewares/AppUrlContextMiddleware.cs | 78 ++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Middlewares/AppUrlContextMiddleware.cs diff --git a/Middlewares/AppUrlContextMiddleware.cs b/Middlewares/AppUrlContextMiddleware.cs new file mode 100644 index 000000000..93ab70ee5 --- /dev/null +++ b/Middlewares/AppUrlContextMiddleware.cs @@ -0,0 +1,78 @@ +using ExpressBase.Common.Helpers; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; +using System; +using System.Threading.Tasks; + +namespace ExpressBase.Web.Middlewares +{ + public class AppUrlContextMiddleware + { + private readonly RequestDelegate _next; + private readonly AppConfiguration _cfg; + public AppUrlContextMiddleware(RequestDelegate next, IOptions cfg) + { + _next = next; + _cfg = cfg.Value; + } + + public async Task Invoke(HttpContext context) + { + + //DebugHelper.PrintObject(this._cfg, printAsJson: true, label: "this._cfg"); + //DebugHelper.PrintObject(context.Request, label: "context"); + + var host = context.Request.Host.ToString(); //demobakerystaging-dev.expressbase.com + string baseHost = _cfg.BaseHost; //expressbase.com + + string subdomain = null; + string domain = null; + string devConsoleHost = null; + string userConsoleHost = null; + string externalSolutionId = null; + + if (this._cfg.Scheme.Replace("://", String.Empty) != context.Request.Scheme) + { + context.Response.StatusCode = StatusCodes.Status400BadRequest; + await context.Response.WriteAsync("Invalid Scheme."); + return; + } + + if (host.EndsWith(baseHost, StringComparison.OrdinalIgnoreCase)) + { + subdomain = host.Substring(0, host.Length - baseHost.Length).TrimEnd('.'); + domain = baseHost; + + } else + { + context.Response.StatusCode = StatusCodes.Status400BadRequest; + await context.Response.WriteAsync("Invalid Host header."); + return; + } + + if (StringHelper.HasValue(subdomain) == true) + { + + if (subdomain.EndsWith(this._cfg.DevDomainSuffix, StringComparison.OrdinalIgnoreCase) == false) + { + context.Items["DevConsoleHost"] = subdomain + this._cfg.DevDomainSuffix + "." + baseHost; //demobakerystaging-dev.expressbase.com + } else + { + context.Items["DevConsoleHost"] = subdomain + "." + baseHost; //demobakerystaging-dev.expressbase.com + } + + + context.Items["ExternalSolutionId"] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty); //demobakerystaging + context.Items["UserConsoleHost"] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty) + "." + baseHost; //demobakerystaging.expressbase.com + context.Items["SubDomain"] = subdomain; + } + + context.Items["BaseHost"] = baseHost; + context.Items["Scheme"] = this._cfg.Scheme; + context.Items["Host"] = host; + context.Items["Domain"] = domain; + + await _next(context); + } + } +} From 14e8f98f6707a1cdc350ad61bd851daf26ed8a32 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Sun, 12 Oct 2025 21:59:11 +0530 Subject: [PATCH 05/58] Made and empty method return new EmptyResult() --- Controllers/SupportTicketController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controllers/SupportTicketController.cs b/Controllers/SupportTicketController.cs index f18a1e039..b8c694e61 100644 --- a/Controllers/SupportTicketController.cs +++ b/Controllers/SupportTicketController.cs @@ -60,7 +60,7 @@ public IActionResult BugTickets() //// Directly return all tickets as JSON response //// No filtering is done here //return Json(fsr.supporttkt ?? new List()); - return null; + return new EmptyResult(); } From a6bb0e403670a723c5c0031ceb17e8e3b579ab1c Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Sun, 12 Oct 2025 21:59:28 +0530 Subject: [PATCH 06/58] Debug level adjustments --- appsettings.PreStaging.json | 6 +++--- appsettings.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/appsettings.PreStaging.json b/appsettings.PreStaging.json index fd2b26842..ea3dc333b 100644 --- a/appsettings.PreStaging.json +++ b/appsettings.PreStaging.json @@ -5,10 +5,10 @@ "Logging": { "IncludeScopes": false, "LogLevel": { - "Default": "Warning", + "Default": "Information", "Microsoft": "Warning", - "Microsoft.AspNetCore": "Warning", - "System": "Warning" + "Microsoft.AspNetCore": "Information", + "System": "Error" } }, "AppConfiguration": { diff --git a/appsettings.json b/appsettings.json index 050690f14..9b57a60a8 100644 --- a/appsettings.json +++ b/appsettings.json @@ -6,8 +6,8 @@ "IncludeScopes": false, "LogLevel": { "Default": "Debug", - "Microsoft": "Warning", - "Microsoft.AspNetCore": "Warning", + "Microsoft": "Debug", + "Microsoft.AspNetCore": "Information", "System": "Warning" } }, From 355944c5d53ffab6cd20c048555d3794d24e32c2 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Sun, 12 Oct 2025 22:34:02 +0530 Subject: [PATCH 07/58] debug for Redis issue --- Controllers/External/ExtController.cs | 6 ++++++ appsettings.PreStaging.json | 2 +- appsettings.json | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Controllers/External/ExtController.cs b/Controllers/External/ExtController.cs index aef14a2e0..0efda3b98 100644 --- a/Controllers/External/ExtController.cs +++ b/Controllers/External/ExtController.cs @@ -321,6 +321,10 @@ public async Task ResetPasswordAsync(string emcde, string tkn, string psw, private bool isAvailSolution() { bool IsAvail = false; + + DebugHelper.LogRaw(this.Redis, label: "this.Redis"); + DebugHelper.LogRaw(ViewBag.SolutionId, label: "this.Redis"); + if (ViewBag.SolutionId != String.Empty && ViewBag.SolutionId != null) { IsAvail = isAvailInRedis(); @@ -337,6 +341,8 @@ public bool isAvailInRedis() { bool IsAvail = false; IEnumerable resp = this.Redis.GetKeysByPattern(string.Format(CoreConstants.SOLUTION_INTEGRATION_REDIS_KEY, ViewBag.SolutionId)); + DebugHelper.LogRaw(resp, label: "this.Redis"); + DebugHelper.LogRaw(string.Format(CoreConstants.SOLUTION_INTEGRATION_REDIS_KEY, ViewBag.SolutionId), label: "this.Redis"); if (resp.Any() || (ViewBag.SolutionId == CoreConstants.ADMIN)) IsAvail = true; return IsAvail; diff --git a/appsettings.PreStaging.json b/appsettings.PreStaging.json index ea3dc333b..3467f7992 100644 --- a/appsettings.PreStaging.json +++ b/appsettings.PreStaging.json @@ -7,7 +7,7 @@ "LogLevel": { "Default": "Information", "Microsoft": "Warning", - "Microsoft.AspNetCore": "Information", + "Microsoft.AspNetCore": "Warning", "System": "Error" } }, diff --git a/appsettings.json b/appsettings.json index 9b57a60a8..e0f9fe3d5 100644 --- a/appsettings.json +++ b/appsettings.json @@ -7,7 +7,7 @@ "LogLevel": { "Default": "Debug", "Microsoft": "Debug", - "Microsoft.AspNetCore": "Information", + "Microsoft.AspNetCore": "Debug", "System": "Warning" } }, From 39345595cb455db3132ebd7bc21e7bf5fd57d850 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Sun, 12 Oct 2025 22:48:52 +0530 Subject: [PATCH 08/58] Debug --- BaseControllers/EbBaseController.cs | 5 +++++ Controllers/External/ExtController.cs | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/BaseControllers/EbBaseController.cs b/BaseControllers/EbBaseController.cs index 1a030b6f1..fcdce984f 100644 --- a/BaseControllers/EbBaseController.cs +++ b/BaseControllers/EbBaseController.cs @@ -344,6 +344,9 @@ public byte[] FromBase64Url(string base64Url) public string GetIsolutionId(string esid) { + DebugHelper.LogRaw(esid, label: "esid"); + DebugHelper.LogRaw(string.Format(CoreConstants.SOLUTION_ID_MAP, esid), label: "string.Format(CoreConstants.SOLUTION_ID_MAP, esid)"); + string solnId = string.Empty; if (esid == CoreConstants.MYACCOUNT) @@ -367,6 +370,8 @@ public string GetIsolutionId(string esid) solnId = this.Redis.Get(string.Format(CoreConstants.SOLUTION_ID_MAP, esid)); } } + + DebugHelper.LogRaw(solnId, label: "solnId"); return solnId; } diff --git a/Controllers/External/ExtController.cs b/Controllers/External/ExtController.cs index 0efda3b98..8e13c45f7 100644 --- a/Controllers/External/ExtController.cs +++ b/Controllers/External/ExtController.cs @@ -323,7 +323,7 @@ private bool isAvailSolution() bool IsAvail = false; DebugHelper.LogRaw(this.Redis, label: "this.Redis"); - DebugHelper.LogRaw(ViewBag.SolutionId, label: "this.Redis"); + DebugHelper.LogRaw(ViewBag.SolutionId, label: "ViewBag.SolutionId"); if (ViewBag.SolutionId != String.Empty && ViewBag.SolutionId != null) { @@ -341,8 +341,8 @@ public bool isAvailInRedis() { bool IsAvail = false; IEnumerable resp = this.Redis.GetKeysByPattern(string.Format(CoreConstants.SOLUTION_INTEGRATION_REDIS_KEY, ViewBag.SolutionId)); - DebugHelper.LogRaw(resp, label: "this.Redis"); - DebugHelper.LogRaw(string.Format(CoreConstants.SOLUTION_INTEGRATION_REDIS_KEY, ViewBag.SolutionId), label: "this.Redis"); + DebugHelper.LogRaw(resp, label: "resp"); + DebugHelper.LogRaw(string.Format(CoreConstants.SOLUTION_INTEGRATION_REDIS_KEY, ViewBag.SolutionId), label: "string.Format(CoreConstants.SOLUTION_INTEGRATION_REDIS_KEY, ViewBag.SolutionId)"); if (resp.Any() || (ViewBag.SolutionId == CoreConstants.ADMIN)) IsAvail = true; return IsAvail; From 4b1d8799ba94182a244be21baf5f10ceae39c4be Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Sun, 12 Oct 2025 22:59:46 +0530 Subject: [PATCH 09/58] updated the base control to pick the hots from the url context middleware --- BaseControllers/EbBaseController.cs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/BaseControllers/EbBaseController.cs b/BaseControllers/EbBaseController.cs index fcdce984f..2ef2d8fc5 100644 --- a/BaseControllers/EbBaseController.cs +++ b/BaseControllers/EbBaseController.cs @@ -186,9 +186,33 @@ public EbBaseController(IServiceClient _ssclient, IRedisClient _redis, IHttpCont public override void OnActionExecuting(ActionExecutingContext context) { - Host = context.HttpContext.Request.Host.Host.Replace(RoutingConstants.WWWDOT, string.Empty).Replace(RoutingConstants.LIVEHOSTADDRESS, string.Empty).Replace(RoutingConstants.STAGEHOSTADDRESS, string.Empty).Replace(RoutingConstants.LOCALHOSTADDRESS, string.Empty); + if (HttpContext.Items.ContainsKey("SubDomain")) + { + Host = HttpContext.Items["SubDomain"]?.ToString(); + } + else + { + /* + * Here host is actually just the actual subdomain and not the http host; + * http://demobakerystaging-dev.localhost:41500/; will be demobakerystaging-dev; + */ + Host = context.HttpContext.Request.Host.Host + .Replace(RoutingConstants.WWWDOT, string.Empty) + .Replace(RoutingConstants.LIVEHOSTADDRESS, string.Empty) + .Replace(RoutingConstants.STAGEHOSTADDRESS, string.Empty) + .Replace(RoutingConstants.LOCALHOSTADDRESS, string.Empty); + } + + if (HttpContext.Items.ContainsKey("ExternalSolutionId")) + { + ExtSolutionId = HttpContext.Items["ExternalSolutionId"]?.ToString(); + + } + else + { + ExtSolutionId = Host.Replace(RoutingConstants.DASHDEV, string.Empty); + } - ExtSolutionId = Host.Replace(RoutingConstants.DASHDEV, string.Empty); IntSolutionId = this.GetIsolutionId(ExtSolutionId); WhichConsole = Host.Contains(RoutingConstants.DASHDEV) ? RoutingConstants.DC : (IntSolutionId == CoreConstants.EXPRESSBASE) ? RoutingConstants.TC : RoutingConstants.UC; From e615616c1abaf665c2aa6f9c86d0c3193e7a531b Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 13 Oct 2025 13:38:11 +0530 Subject: [PATCH 10/58] code optimisations --- BaseControllers/EbBaseController.cs | 9 +++------ Controllers/External/ExtController.cs | 21 +++++++++------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/BaseControllers/EbBaseController.cs b/BaseControllers/EbBaseController.cs index 2ef2d8fc5..1ddbbd50d 100644 --- a/BaseControllers/EbBaseController.cs +++ b/BaseControllers/EbBaseController.cs @@ -193,8 +193,8 @@ public override void OnActionExecuting(ActionExecutingContext context) else { /* - * Here host is actually just the actual subdomain and not the http host; - * http://demobakerystaging-dev.localhost:41500/; will be demobakerystaging-dev; + * Here host is actually just the actual subdomain and not the actual http host; + * so in http://demobakerystaging-dev.localhost:41500/; the host will be demobakerystaging-dev; */ Host = context.HttpContext.Request.Host.Host .Replace(RoutingConstants.WWWDOT, string.Empty) @@ -368,9 +368,7 @@ public byte[] FromBase64Url(string base64Url) public string GetIsolutionId(string esid) { - DebugHelper.LogRaw(esid, label: "esid"); - DebugHelper.LogRaw(string.Format(CoreConstants.SOLUTION_ID_MAP, esid), label: "string.Format(CoreConstants.SOLUTION_ID_MAP, esid)"); - + string solnId = string.Empty; if (esid == CoreConstants.MYACCOUNT) @@ -395,7 +393,6 @@ public string GetIsolutionId(string esid) } } - DebugHelper.LogRaw(solnId, label: "solnId"); return solnId; } diff --git a/Controllers/External/ExtController.cs b/Controllers/External/ExtController.cs index 8e13c45f7..4594285fc 100644 --- a/Controllers/External/ExtController.cs +++ b/Controllers/External/ExtController.cs @@ -320,32 +320,29 @@ public async Task ResetPasswordAsync(string emcde, string tkn, string psw, private bool isAvailSolution() { - bool IsAvail = false; - - DebugHelper.LogRaw(this.Redis, label: "this.Redis"); - DebugHelper.LogRaw(ViewBag.SolutionId, label: "ViewBag.SolutionId"); - if (ViewBag.SolutionId != String.Empty && ViewBag.SolutionId != null) { - IsAvail = isAvailInRedis(); + return isAvailInRedis(); //if (!IsAvail) //{ // RefreshSolutionExtResponse res = this.MqClient.Post(new RefreshSolutionExtRequest { SolnId = ViewBag.SolutionId }); // IsAvail = isAvailInRedis(); //} } - return IsAvail; + + return false; } public bool isAvailInRedis() { - bool IsAvail = false; IEnumerable resp = this.Redis.GetKeysByPattern(string.Format(CoreConstants.SOLUTION_INTEGRATION_REDIS_KEY, ViewBag.SolutionId)); - DebugHelper.LogRaw(resp, label: "resp"); - DebugHelper.LogRaw(string.Format(CoreConstants.SOLUTION_INTEGRATION_REDIS_KEY, ViewBag.SolutionId), label: "string.Format(CoreConstants.SOLUTION_INTEGRATION_REDIS_KEY, ViewBag.SolutionId)"); + if (resp.Any() || (ViewBag.SolutionId == CoreConstants.ADMIN)) - IsAvail = true; - return IsAvail; + { + return true; + } + + return false; } private string GetDefaultHtmlPageRefId() From ef36e7c76b547cdba1a32c0e10642d7ea39b4c7a Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 13 Oct 2025 13:38:37 +0530 Subject: [PATCH 11/58] added a shared layout for core scripts --- Views/Shared/_EbCoreScripts.cshtml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Views/Shared/_EbCoreScripts.cshtml diff --git a/Views/Shared/_EbCoreScripts.cshtml b/Views/Shared/_EbCoreScripts.cshtml new file mode 100644 index 000000000..5983d38a1 --- /dev/null +++ b/Views/Shared/_EbCoreScripts.cshtml @@ -0,0 +1,13 @@ +@using ExpressBase.Web.Helpers + + + + + + + + + + From a5936997b26f38234c00fafe18b23c4b64218051 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 13 Oct 2025 13:39:06 +0530 Subject: [PATCH 12/58] added the core scripts to all global layouts --- Views/Shared/LayoutBuilders.cshtml | 2 ++ Views/Shared/LayoutDashboard.cshtml | 2 ++ Views/Shared/LayoutExternal.cshtml | 1 + Views/Shared/LayoutInner.cshtml | 1 + 4 files changed, 6 insertions(+) diff --git a/Views/Shared/LayoutBuilders.cshtml b/Views/Shared/LayoutBuilders.cshtml index 091598583..89f551509 100644 --- a/Views/Shared/LayoutBuilders.cshtml +++ b/Views/Shared/LayoutBuilders.cshtml @@ -18,6 +18,8 @@ @ViewBag.Title + @await Html.PartialAsync("_EbCoreScripts") + @* CORE CSS *@ diff --git a/Views/Shared/LayoutDashboard.cshtml b/Views/Shared/LayoutDashboard.cshtml index 5863be774..000652337 100644 --- a/Views/Shared/LayoutDashboard.cshtml +++ b/Views/Shared/LayoutDashboard.cshtml @@ -18,6 +18,8 @@ @ViewBag.Title + @await Html.PartialAsync("_EbCoreScripts") + @* CORE CSS *@ diff --git a/Views/Shared/LayoutExternal.cshtml b/Views/Shared/LayoutExternal.cshtml index dd17f826e..b562d5f71 100644 --- a/Views/Shared/LayoutExternal.cshtml +++ b/Views/Shared/LayoutExternal.cshtml @@ -16,6 +16,7 @@ @t + @await Html.PartialAsync("_EbCoreScripts") diff --git a/Views/Shared/LayoutInner.cshtml b/Views/Shared/LayoutInner.cshtml index 3c2de5f96..df0b8f1a7 100644 --- a/Views/Shared/LayoutInner.cshtml +++ b/Views/Shared/LayoutInner.cshtml @@ -14,6 +14,7 @@ @ViewBag.Title + @await Html.PartialAsync("_EbCoreScripts") From ce58aac67069a4c0573c2aa388ea54edca88aa41 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 13 Oct 2025 13:39:39 +0530 Subject: [PATCH 13/58] add a config helper to bring appsettings configs to front end --- Helpers/AppConfigViewHelper.cs | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Helpers/AppConfigViewHelper.cs diff --git a/Helpers/AppConfigViewHelper.cs b/Helpers/AppConfigViewHelper.cs new file mode 100644 index 000000000..2952477bf --- /dev/null +++ b/Helpers/AppConfigViewHelper.cs @@ -0,0 +1,45 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using System; + +namespace ExpressBase.Web.Helpers +{ + public static class AppConfigViewHelper + { + public static string RenderJson(HttpContext context) + { + if (context == null) + throw new ArgumentNullException(nameof(context)); + + // Get IOptions directly from DI + var cfg = context.RequestServices.GetService(typeof(IOptions)) + as IOptions; + + if (cfg == null) + throw new InvalidOperationException("IOptions not found in RequestServices."); + + var appConfig = new + { + Env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"), + Scheme = context.Items["Scheme"]?.ToString(), + Host = context.Items["Host"]?.ToString(), + BaseHost = cfg.Value.BaseHost, + LocalPort = cfg.Value.LocalPort, + Domain = context.Items["Domain"]?.ToString(), + ServerEventUrlPrefix = cfg.Value.ServerEventUrlPrefix, + DevConsoleHost = context.Items["DevConsoleHost"]?.ToString(), + UserConsoleHost = context.Items["UserConsoleHost"]?.ToString() + }; + + var jsonSettings = new JsonSerializerSettings + { + StringEscapeHandling = StringEscapeHandling.EscapeHtml, + ContractResolver = new CamelCasePropertyNamesContractResolver() + }; + + return JsonConvert.SerializeObject(appConfig, jsonSettings); + } + } +} From 2c3c76620ad966172af7def0a26916b488301ec2 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 13 Oct 2025 13:40:54 +0530 Subject: [PATCH 14/58] added core JS classes * added helper JS classes * added view support JS classes --- wwwroot/js/Common/EbControlClone.js | 59 ++++ wwwroot/js/Common/EbShareModal.js | 290 ++++++++++++++++++ wwwroot/js/Common/EbToast.js | 176 +++++++++++ .../js/Common/Helpers/EbApiClientHelper.js | 42 +++ .../js/Common/Helpers/EbClipBoardHelper.js | 31 ++ wwwroot/js/Common/Helpers/EbDebugHelper.js | 88 ++++++ wwwroot/js/Common/Helpers/EbUrlHelper.js | 39 +++ 7 files changed, 725 insertions(+) create mode 100644 wwwroot/js/Common/EbControlClone.js create mode 100644 wwwroot/js/Common/EbShareModal.js create mode 100644 wwwroot/js/Common/EbToast.js create mode 100644 wwwroot/js/Common/Helpers/EbApiClientHelper.js create mode 100644 wwwroot/js/Common/Helpers/EbClipBoardHelper.js create mode 100644 wwwroot/js/Common/Helpers/EbDebugHelper.js create mode 100644 wwwroot/js/Common/Helpers/EbUrlHelper.js diff --git a/wwwroot/js/Common/EbControlClone.js b/wwwroot/js/Common/EbControlClone.js new file mode 100644 index 000000000..2bf5b0d13 --- /dev/null +++ b/wwwroot/js/Common/EbControlClone.js @@ -0,0 +1,59 @@ + +// ---- usage ---- +// const cloner = new EbControlClone(); +// const copy = cloner.clone(originalCtrl); +class EbControlClone { + /** + * Deep clone data-only. Cycles preserved; non-serializables dropped. + * @param {*} input + * @returns {*} cloned + */ + clone(input) { + const seen = new WeakMap(); + + const isDomNode = (v) => + (typeof Node !== 'undefined' && v instanceof Node) || + (v && v.nodeType && typeof v.nodeName === 'string'); + + const cloneVal = (val) => { + // primitives & null + if (val === null || typeof val !== 'object') return val; + + // drop problematic/object-environment values + if (typeof Window !== 'undefined' && val instanceof Window) return undefined; + if (isDomNode(val)) return undefined; + + // drop functions/symbols + const t = typeof val; + if (t === 'function' || t === 'symbol') return undefined; + + // special cases + if (val instanceof Date) return new Date(val.getTime()); + if (val instanceof RegExp) return new RegExp(val.source, val.flags); + if (val instanceof Map) return Array.from(val.entries()).map(([k, v]) => [cloneVal(k), cloneVal(v)]); + if (val instanceof Set) return Array.from(val.values()).map(cloneVal); + + // cycle handling + if (seen.has(val)) return seen.get(val); + + const out = Array.isArray(val) ? [] : {}; + seen.set(val, out); + + if (Array.isArray(val)) { + for (let i = 0; i < val.length; i++) { + const c = cloneVal(val[i]); + if (c !== undefined) out.push(c); // skip dropped entries + } + } else { + for (const k of Object.keys(val)) { + const c = cloneVal(val[k]); + if (c !== undefined) out[k] = c; // omit dropped keys + } + } + return out; + }; + + return cloneVal(input); + } +} + diff --git a/wwwroot/js/Common/EbShareModal.js b/wwwroot/js/Common/EbShareModal.js new file mode 100644 index 000000000..922880127 --- /dev/null +++ b/wwwroot/js/Common/EbShareModal.js @@ -0,0 +1,290 @@ +class EbShareModal { + host; shadow; backdrop; card; input; copyBtn; + _prevOverflow = null; _prevPaddingRight = null; lastFocused = null; + + constructor({ + title = 'Shareable URL', + helperText = 'This link may contain a one-time ticket. Keep it private if it includes sensitive info.', + copyLabel = 'Copy', + cancelLabel = 'Cancel', + closeAriaLabel = 'Close', + url = null, + autoDestroy = false, + } = {}) { + this.autoDestroy = !!autoDestroy; + + this.host = document.createElement('div'); + this.host.style.all = 'initial'; + document.body.appendChild(this.host); + this.shadow = this.host.attachShadow({ mode: 'open' }); + + const style = document.createElement('style'); + style.textContent = ` + .EbShareModal-backdrop { + --eb-bg-default: #f6f7f9; + --eb-fg-default: #0b0c0e; + --eb-card-default: #ffffff; + --eb-border-default: #e5e7eb; + --eb-accent-default: #2563eb; + --eb-muted-default: #5b616e; + } + @media (prefers-color-scheme: dark) { + .EbShareModal-backdrop { + --eb-bg-default: #0b0c0e; + --eb-fg-default: #e5e7eb; + --eb-card-default: #111317; + --eb-border-default: #1f232a; + --eb-accent-default: #60a5fa; + --eb-muted-default: #9aa3af; + } + } + .EbShareModal-backdrop { + position: fixed; inset: 0; + background: rgba(0,0,0,.45); + display: none; + align-items: center; justify-content: center; + padding: 28px; + z-index: 9999; + backdrop-filter: blur(2px); + color-scheme: light dark; + color: var(--fg, var(--eb-fg-default)); + font-family: var(--font, system-ui,-apple-system,'Segoe UI',Roboto,'Helvetica Neue',Arial,'Noto Sans','Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol','Noto Color Emoji'); + } + .EbShareModal-backdrop[aria-hidden="false"] { display: flex; } + .EbShareModal-card { + display: block; + width: 100%; max-width: 900px; + background: var(--card, var(--eb-card-default)); + color: var(--fg, var(--eb-fg-default)); + border: 1px solid var(--border, var(--eb-border-default)); + border-radius: 16px; + box-shadow: 0 16px 48px rgba(0,0,0,.28); + padding: 24px; + transform: translateY(8px); + transition: transform .18s ease, opacity .18s ease; + opacity: 0; + outline: none; + pointer-events: auto; + } + .EbShareModal-backdrop[aria-hidden="false"] .EbShareModal-card { transform: translateY(0); opacity: 1; } + .EbShareModal-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; } + .EbShareModal-title { margin: 0; font-size: 20px; font-weight: 700; } + .EbShareModal-close { + display: grid; place-items: center; + width: 38px; height: 38px; + border: 1px solid var(--border, var(--eb-border-default)); + border-radius: 10px; + background: transparent; + color: inherit; + cursor: pointer; + line-height: 1; + } + .EbShareModal-close:hover { border-color: var(--accent, var(--eb-accent-default)); } + .EbShareModal-body { display: grid; gap: 14px; } + .EbShareModal-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; justify-content: flex-end; } + .EbShareModal-inputrow { display: grid; grid-template-columns: 1fr auto; gap: 12px; } + .EbShareModal-input { + display: block; width: 100%; + padding: 12px 14px; + background: transparent; + color: inherit; + border: 1px solid var(--border, var(--eb-border-default)); + border-radius: 10px; + font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace); + font-size: 15px; line-height: 1.4; + white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + } + .EbShareModal-input:focus { outline: none; border-color: var(--accent, var(--eb-accent-default)); } + .EbShareModal-btn { + display: inline-block; + padding: 12px 16px; + border: 1px solid var(--border, var(--eb-border-default)); + border-radius: 10px; + background: transparent; + color: inherit; + font: inherit; + font-weight: 700; + cursor: pointer; + text-align: center; + user-select: none; + } + .EbShareModal-btn:hover { border-color: var(--accent, var(--eb-accent-default)); } + .EbShareModal-btn-primary { + background: var(--accent, var(--eb-accent-default)); + border-color: var(--accent, var(--eb-accent-default)); + color: #fff; + } + .EbShareModal-btn-primary:hover { filter: brightness(1.05); } + .EbShareModal-helper { font-size: 13px; color: var(--muted, var(--eb-muted-default)); } + @media (max-width: 600px) { + .EbShareModal-card { padding: 20px; border-radius: 14px; } + .EbShareModal-title { font-size: 18px; } + .EbShareModal-inputrow { grid-template-columns: 1fr; } + } + `; + + this.backdrop = document.createElement('div'); + this.backdrop.className = 'EbShareModal-backdrop'; + this.backdrop.setAttribute('role', 'dialog'); + this.backdrop.setAttribute('aria-modal', 'true'); + this.backdrop.setAttribute('aria-hidden', 'true'); + + this.card = document.createElement('div'); + this.card.className = 'EbShareModal-card'; + this.card.setAttribute('tabindex', '-1'); + + const header = document.createElement('div'); + header.className = 'EbShareModal-header'; + + const h2 = document.createElement('h2'); + h2.className = 'EbShareModal-title'; + const titleId = `EbShareModal-title-${Math.random().toString(36).slice(2)}`; + h2.id = titleId; + h2.textContent = title; + this.backdrop.setAttribute('aria-labelledby', titleId); + + const closeBtn = document.createElement('button'); + closeBtn.className = 'EbShareModal-close'; + closeBtn.type = 'button'; + closeBtn.setAttribute('aria-label', closeAriaLabel); + closeBtn.textContent = '×'; + + const body = document.createElement('div'); + body.className = 'EbShareModal-body'; + + const inputRow = document.createElement('div'); + inputRow.className = 'EbShareModal-inputrow'; + + this.input = document.createElement('input'); + this.input.className = 'EbShareModal-input'; + this.input.type = 'text'; + this.input.readOnly = true; + + this.copyBtn = document.createElement('button'); + this.copyBtn.className = 'EbShareModal-btn EbShareModal-btn-primary'; + this.copyBtn.type = 'button'; + this.copyBtn.textContent = copyLabel; + + inputRow.appendChild(this.input); + inputRow.appendChild(this.copyBtn); + + const helper = document.createElement('div'); + helper.className = 'EbShareModal-helper'; + helper.textContent = helperText; + + const actions = document.createElement('div'); + actions.className = 'EbShareModal-row'; + + const cancelBtn = document.createElement('button'); + cancelBtn.className = 'EbShareModal-btn'; + cancelBtn.type = 'button'; + cancelBtn.textContent = cancelLabel; + + actions.appendChild(cancelBtn); + + header.appendChild(h2); + header.appendChild(closeBtn); + body.appendChild(inputRow); + body.appendChild(helper); + body.appendChild(actions); + this.card.appendChild(header); + this.card.appendChild(body); + this.backdrop.appendChild(this.card); + + this.shadow.appendChild(style); + this.shadow.appendChild(this.backdrop); + + this.copyBtn.addEventListener('click', () => this.copyToClipboard(this.input.value)); + closeBtn.addEventListener('click', () => this.close()); + cancelBtn.addEventListener('click', () => this.close()); + this.backdrop.addEventListener('click', this.#onBackdropClick); + + if (url != null) this.setUrl(url); + } + + open(url = null) { + if (url != null) this.setUrl(url); + this.lastFocused = document.activeElement; + this.backdrop.setAttribute('aria-hidden', 'false'); + this.#lockScroll(); + setTimeout(() => this.card.focus(), 0); + document.addEventListener('keydown', this.#trapFocus, { passive: false }); + } + + close() { + this.backdrop.setAttribute('aria-hidden', 'true'); + document.removeEventListener('keydown', this.#trapFocus); + this.#unlockScroll(); + if (this.lastFocused && typeof this.lastFocused.focus === 'function') { + try { this.lastFocused.focus(); } catch {} + } + if (this.autoDestroy) this.destroy(); + } + + destroy() { + this.backdrop.removeEventListener('click', this.#onBackdropClick); + document.removeEventListener('keydown', this.#trapFocus); + this.#unlockScroll(); + this.host?.remove(); + } + + setUrl(url) { this.input.value = url ?? ''; } + + copyToClipboard(text) { + try { + EbClipBoardHelper.copy(text); + EbToast.success('Copied to clipboard', { position: 'bottom-center' }); + } catch { + EbToast.error('Copy failed. Long-press to select.', { position: 'bottom-center' }); + } + } + + #trapFocus = (e) => { + if (this.backdrop.getAttribute('aria-hidden') === 'true') return; + const focusables = this.card.querySelectorAll('button,[href],input,select,textarea,[tabindex]:not([tabindex="-1"])'); + if (!focusables.length) { + if (e.key === 'Escape') this.close(); + return; + } + const first = focusables[0]; + const last = focusables[focusables.length - 1]; + if (e.key === 'Tab') { + if (e.shiftKey && document.activeElement === first) { last.focus(); e.preventDefault(); } + else if (!e.shiftKey && document.activeElement === last) { first.focus(); e.preventDefault(); } + } else if (e.key === 'Escape') { + this.close(); + } + }; + + #onBackdropClick = (e) => { if (e.target === this.backdrop) this.close(); }; + + #lockScroll() { + const docEl = document.documentElement; + const body = document.body; + const scrollBar = window.innerWidth - docEl.clientWidth; + this._prevOverflow = body.style.overflow; + this._prevPaddingRight = body.style.paddingRight; + body.style.overflow = 'hidden'; + if (scrollBar > 0) { + const current = getComputedStyle(body).paddingRight; + body.style.paddingRight = `calc(${current} + ${scrollBar}px)`; + } + } + + #unlockScroll() { + const body = document.body; + if (body.style.overflow === 'hidden') { + body.style.overflow = this._prevOverflow ?? ''; + body.style.paddingRight = this._prevPaddingRight ?? ''; + } + } +} + +// Usage example: +// +// diff --git a/wwwroot/js/Common/EbToast.js b/wwwroot/js/Common/EbToast.js new file mode 100644 index 000000000..24b4da7f8 --- /dev/null +++ b/wwwroot/js/Common/EbToast.js @@ -0,0 +1,176 @@ +class EbToast { + static #stylesInjected = false; + static #root = null; + + static #injectStyles() { + if (EbToast.#stylesInjected) return; + const css = ` + .EbToast-root { + position: fixed; + inset: auto 0 20px 0; /* default: bottom-center */ + display: grid; place-items: center; + gap: 8px; + pointer-events: none; /* clicks pass through gaps */ + z-index: 100000; /* above most modals */ + padding: 0 12px; + } + .EbToast-root[data-pos^="top"] { top: 20px; bottom: auto; } + .EbToast-root[data-pos$="left"] { place-items: start; } + .EbToast-root[data-pos$="right"] { place-items: end; } + + /* tokens (light) */ + .EbToast-item { + --bg: #ffffff; + --fg: #0b0c0e; + --muted: #5b616e; + --border: #e5e7eb; + + background: var(--bg); + color: var(--fg); + border: 1px solid var(--border); + border-radius: 10px; + padding: 10px 14px; + box-shadow: 0 8px 24px rgba(0,0,0,.18); + font: 13px/1.35 system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans"; + display: inline-flex; align-items: center; gap: 10px; + pointer-events: auto; /* allow hover to pause */ + opacity: 0; transform: translateY(6px); + transition: opacity .18s ease, transform .18s ease, filter .12s ease; + max-width: min(90vw, 520px); + word-break: break-word; + } + @media (prefers-color-scheme: dark) { + .EbToast-item { + --bg: #111317; + --fg: #e5e7eb; + --muted: #9aa0aa; + --border: #1f232a; + } + } + .EbToast-item[data-kind="success"] { border-color: #16a34a33; box-shadow: 0 8px 24px rgba(22,163,74,.18); } + .EbToast-item[data-kind="error"] { border-color: #b91c1c33; box-shadow: 0 8px 24px rgba(185,28,28,.18); } + .EbToast-item[data-kind="info"] { border-color: #2563eb33; box-shadow: 0 8px 24px rgba(37,99,235,.18); } + .EbToast-item[data-kind="warn"] { border-color: #d9770633; box-shadow: 0 8px 24px rgba(217,119,6,.18); } + + .EbToast-icon { font-size: 16px; line-height: 1; opacity: .9; } + .EbToast-msg { flex: 1 1 auto; } + .EbToast-close { + appearance: none; border: 0; background: transparent; color: inherit; + font-size: 16px; line-height: 1; padding: 4px; margin: -4px -2px -4px 4px; + border-radius: 6px; cursor: pointer; + } + .EbToast-close:hover { filter: brightness(1.1); } + + .EbToast-item.EbToast-in { opacity: 1; transform: translateY(0); } + .EbToast-item.EbToast-out { opacity: 0; transform: translateY(6px); } + `; + const style = document.createElement('style'); + style.textContent = css; + document.head.appendChild(style); + EbToast.#stylesInjected = true; + } + + static #ensureRoot(position = "bottom-center") { + if (!EbToast.#root) { + const root = document.createElement('div'); + root.className = 'EbToast-root'; + root.setAttribute('role', 'region'); + root.setAttribute('aria-label', 'Notifications'); + document.body.appendChild(root); + EbToast.#root = root; + } + EbToast.#setPosition(position); + } + + static #setPosition(position) { + // normalize like "bottom-center" + const allowed = new Set([ + "bottom-center","bottom-left","bottom-right", + "top-center","top-left","top-right" + ]); + const pos = allowed.has(position) ? position : "bottom-center"; + EbToast.#root.dataset.pos = pos; + // map to grid alignment via data-pos in CSS + EbToast.#root.style.inset = pos.startsWith('top') ? "20px 0 auto 0" : "auto 0 20px 0"; + EbToast.#root.style.placeItems = + pos.endsWith('left') ? "start" : + pos.endsWith('right') ? "end" : "center"; + } + + /** + * Show a toast. + * @param {string|Node} message + * @param {Object} opts + * @param {number} [opts.duration=1800] auto-hide in ms (0 disables) + * @param {"default"|"success"|"error"|"info"|"warn"} [opts.kind="default"] + * @param {"bottom-center"|"bottom-left"|"bottom-right"|"top-center"|"top-left"|"top-right"} [opts.position] + * @param {string|null} [opts.icon] optional text/emoji/icon HTML (kept simple) + * @returns {{close:Function, el:HTMLElement}} + */ + static show(message, { + duration = 1800, + kind = "default", + position = "bottom-center", + icon = null + } = {}) { + EbToast.#injectStyles(); + EbToast.#ensureRoot(position); + + const toast = document.createElement('div'); + toast.className = 'EbToast-item'; + toast.setAttribute('role', 'status'); + toast.setAttribute('aria-live', 'polite'); + toast.dataset.kind = kind; + + if (icon) { + const ic = document.createElement('span'); + ic.className = 'EbToast-icon'; + ic.innerHTML = icon; + toast.appendChild(ic); + } + + const msg = document.createElement('div'); + msg.className = 'EbToast-msg'; + if (message instanceof Node) msg.appendChild(message); + else msg.textContent = String(message ?? ''); + toast.appendChild(msg); + + const btn = document.createElement('button'); + btn.className = 'EbToast-close'; + btn.type = 'button'; + btn.setAttribute('aria-label', 'Dismiss'); + btn.innerHTML = '×'; + btn.addEventListener('click', () => api.close()); + toast.appendChild(btn); + + // insert and animate + EbToast.#root.appendChild(toast); + requestAnimationFrame(() => toast.classList.add('EbToast-in')); + + // auto-hide with hover pause + let timer = null; + const start = () => { + if (duration > 0) timer = setTimeout(() => api.close(), duration); + }; + const stop = () => { if (timer) { clearTimeout(timer); timer = null; } }; + toast.addEventListener('mouseenter', stop); + toast.addEventListener('mouseleave', start); + start(); + + const api = { + el: toast, + close: () => { + stop(); + toast.classList.remove('EbToast-in'); + toast.classList.add('EbToast-out'); + setTimeout(() => toast.remove(), 200); + } + }; + return api; + } + + static success(msg, opts={}) { return EbToast.show(msg, { kind: 'success', icon: '✔️', ...opts }); } + static error(msg, opts={}) { return EbToast.show(msg, { kind: 'error', icon: '⛔', ...opts }); } + static info(msg, opts={}) { return EbToast.show(msg, { kind: 'info', icon: 'ℹ️', ...opts }); } + static warn(msg, opts={}) { return EbToast.show(msg, { kind: 'warn', icon: '⚠️', ...opts }); } +} diff --git a/wwwroot/js/Common/Helpers/EbApiClientHelper.js b/wwwroot/js/Common/Helpers/EbApiClientHelper.js new file mode 100644 index 000000000..6b05b2f5d --- /dev/null +++ b/wwwroot/js/Common/Helpers/EbApiClientHelper.js @@ -0,0 +1,42 @@ +class EbApiClientHelper { + constructor(baseUrl = '') { + this.baseUrl = baseUrl; + } + + async request(endpoint, options = {}) { + + let url = this.baseUrl + endpoint; + if (options.query) { + const qs = new URLSearchParams(options.query).toString(); + url += (url.includes('?') ? '&' : '?') + qs; + } + + const headers = { + 'Content-Type': 'application/json', + ...(options.headers || {}) + }; + + const resp = await fetch(url, { + method: options.method || 'POST', + headers, + body: options.body ? JSON.stringify(options.body) : undefined, + credentials: options.credentials || 'same-origin' + }); + + if (!resp.ok) { + let errText = `${resp.status} ${resp.statusText}`; + try { + const errJson = await resp.json(); + if (errJson.message) errText = errJson.message; + } catch (_) {} + throw new Error(errText); + } + + const contentType = resp.headers.get('content-type') || ''; + if (contentType.includes('application/json')) { + return await resp.json(); + } else { + return await resp.text(); + } + } +} diff --git a/wwwroot/js/Common/Helpers/EbClipBoardHelper.js b/wwwroot/js/Common/Helpers/EbClipBoardHelper.js new file mode 100644 index 000000000..fec102b77 --- /dev/null +++ b/wwwroot/js/Common/Helpers/EbClipBoardHelper.js @@ -0,0 +1,31 @@ +class EbClipBoardHelper { + static async copy(text) { + if (!text) throw new Error('Nothing to copy'); + + try { + await navigator.clipboard.writeText(text); + return true; + } catch (err) { + EbDebugHelper.error("Copy to clipboard failed",err); + return EbClipBoardHelper._fallbackCopyText(text); + } + } + + static _fallbackCopyText(text) { + try { + const ta = document.createElement('textarea'); + ta.value = text; + ta.style.position = 'fixed'; + ta.style.left = '-9999px'; + document.body.appendChild(ta); + ta.focus(); + ta.select(); + const successful = document.execCommand('copy'); + document.body.removeChild(ta); + return successful; + } catch (e) { + EbDebugHelper.error("Copy to clipboard fallback failed",e); + return false; + } + } +} diff --git a/wwwroot/js/Common/Helpers/EbDebugHelper.js b/wwwroot/js/Common/Helpers/EbDebugHelper.js new file mode 100644 index 000000000..173926c2d --- /dev/null +++ b/wwwroot/js/Common/Helpers/EbDebugHelper.js @@ -0,0 +1,88 @@ +class EbDebugHelper { + static get isEnabled() { + return true; + // return !!(window.AppConfig && window.AppConfig.debug); + } + + static _getCallerLocation() { + // --- Preferred: V8 callsites (Chrome/Edge/Node) --- + const isV8 = typeof Error.captureStackTrace === 'function'; + if (isV8) { + const orig = Error.prepareStackTrace; + try { + Error.prepareStackTrace = (_, callsites) => callsites; + const err = new Error(); + // Skip this function in the stack + Error.captureStackTrace(err, EbDebugHelper._getCallerLocation); + const frames = err.stack; + + for (const cs of frames) { + const file = cs.getFileName?.() || ''; + const fn = cs.getFunctionName?.() || cs.getMethodName?.() || ''; + if (!file) continue; + + // Skip helper frames + if (file.includes('EbDebugHelper.js')) continue; + if ((fn || '').includes('EbDebugHelper')) continue; + + const line = cs.getLineNumber?.(); + const col = cs.getColumnNumber?.(); + if (line != null && col != null) { + return `${file}:${line}:${col}`; + } + return file; // fallback if no line/col + } + } catch (_) { + // fall through to string parse + } finally { + Error.prepareStackTrace = orig; + } + } + + // --- Fallback: parse stack string (Firefox/Safari/others) --- + const stack = new Error().stack || ''; + const lines = stack.split('\n') + // common prefixes: "Error", " at ..." + .map(s => s.trim()) + .filter(Boolean); + + for (const ln of lines) { + // Skip frames that are clearly the helper + if (ln.includes('EbDebugHelper')) continue; + if (ln.includes('EbDebugHelper.js')) continue; + + // Extract (file:line:col) or URL:line:col + // Handles formats like: + // at myFunc (http://.../file.js:123:45) + // http://.../file.js:123:45 + const m = ln.match(/\(?([^\s()]+?\.\w+:\d+:\d+)\)?$/); + if (m) return m[1]; + } + + return ''; + } + + static _format(level, args) { + const loc = EbDebugHelper._getCallerLocation(); + const prefix = `[${level}]${loc ? ` (${loc})` : ''}`; + return [prefix, ...args]; + } + + static log(...args) { if (EbDebugHelper.isEnabled) console.log (...EbDebugHelper._format('DEBUG', args)); } + static info(...args) { if (EbDebugHelper.isEnabled) console.info(...EbDebugHelper._format('INFO', args)); } + static warn(...args) { if (EbDebugHelper.isEnabled) console.warn(...EbDebugHelper._format('WARN', args)); } + static error(...args){ if (EbDebugHelper.isEnabled) console.error(...EbDebugHelper._format('ERROR', args)); } + + static trace(...args) { + if (!EbDebugHelper.isEnabled) return; + console.log(...EbDebugHelper._format('TRACE', args)); + const stack = new Error().stack; + if (stack) { + // Hide helper frames from the printed stack for clarity + const filtered = stack.split('\n') + .filter(l => !l.includes('EbDebugHelper')) + .join('\n'); + console.log(filtered); + } + } +} diff --git a/wwwroot/js/Common/Helpers/EbUrlHelper.js b/wwwroot/js/Common/Helpers/EbUrlHelper.js new file mode 100644 index 000000000..4bb7fb0f0 --- /dev/null +++ b/wwwroot/js/Common/Helpers/EbUrlHelper.js @@ -0,0 +1,39 @@ +class EbUrlHelper { + + static getParam(key, defaultValue = null) { + const params = new URLSearchParams(window.location.search); + return params.has(key) ? params.get(key) : defaultValue; + } + + + static getAllParams() { + const params = new URLSearchParams(window.location.search); + return Object.fromEntries(params.entries()); + } + + + static hasParam(key) { + const params = new URLSearchParams(window.location.search); + return params.has(key); + } + + static getEbServerEventUrl() + { + if (!window?.EbAppConfig?.serverEventUrlPrefix) { + + throw new Error("required EbAppConfig are missing"); + } + + return this.getEbWebUrl(window?.EbAppConfig?.serverEventUrlPrefix); + } + + static getEbWebUrl(subDomain) + { + if (!window?.EbAppConfig?.domain || !window?.EbAppConfig?.scheme) { + + throw new Error("required EbAppConfigs are missing"); + } + + return `${window.EbAppConfig.scheme}${subDomain}.${window.EbAppConfig.domain}`; + } +} \ No newline at end of file From 3d3bceb8b72c0013f0be0f6ee854bb3228a8945c Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 13 Oct 2025 22:46:32 +0530 Subject: [PATCH 15/58] changes related to URL consolidation --- BaseControllers/EbBaseController.cs | 2 +- BaseControllers/EbBaseExtController.cs | 21 ++++++-- Controllers/ConnectionManagerController.cs | 26 ++++++++-- Controllers/PayPalController.cs | 57 ++++++++++++--------- Middlewares/AppUrlContextMiddleware.cs | 2 +- Views/Bote/Bots.cshtml | 14 +++-- Views/Dev/AppDashBoard.cshtml | 35 +++++++++---- Views/Ext/SignUp.cshtml | 41 +++++++++------ Views/Ext/TenantSignIn.cshtml | 41 ++++++++++----- Views/Shared/ExtPageHeader.cshtml | 33 ++++++++---- Views/Tenant/SolutionManager.cshtml | 59 +++++++++++++++------- Views/Wiki/WikiAdd.cshtml | 2 +- 12 files changed, 224 insertions(+), 109 deletions(-) diff --git a/BaseControllers/EbBaseController.cs b/BaseControllers/EbBaseController.cs index 1ddbbd50d..68ff0f302 100644 --- a/BaseControllers/EbBaseController.cs +++ b/BaseControllers/EbBaseController.cs @@ -188,7 +188,7 @@ public override void OnActionExecuting(ActionExecutingContext context) { if (HttpContext.Items.ContainsKey("SubDomain")) { - Host = HttpContext.Items["SubDomain"]?.ToString(); + Host = HttpContext.Items["SubDomain"].ToString(); } else { diff --git a/BaseControllers/EbBaseExtController.cs b/BaseControllers/EbBaseExtController.cs index ad2043a3d..d4eb40357 100644 --- a/BaseControllers/EbBaseExtController.cs +++ b/BaseControllers/EbBaseExtController.cs @@ -45,13 +45,24 @@ public override void OnActionExecuting(ActionExecutingContext context) controller.ViewBag.WhichConsole = WhichConsole; controller.ViewBag.HostValue = context.HttpContext.Request.Host.Value; controller.ViewBag.Env = Environment.GetEnvironmentVariable(EnvironmentConstants.ASPNETCORE_ENVIRONMENT); - if (controller.ViewBag.Env == "Production") + + if (HttpContext.Items.ContainsKey("SubDomain") && HttpContext.Items.ContainsKey("Scheme")) { - controller.ViewBag.Root = "https://expressbase.com"; + + controller.ViewBag.Root = HttpContext.Items["Scheme"].ToString() + HttpContext.Items["SubDomain"].ToString(); + } - else - { - controller.ViewBag.Root = "https://" + RoutingConstants.STAGEHOST; + else //TODO: TestAndRemoveInTheNextDeployment + { + + if (controller.ViewBag.Env == "Production") + { + controller.ViewBag.Root = "https://expressbase.com"; + } + else + { + controller.ViewBag.Root = "https://" + RoutingConstants.STAGEHOST; + } } } diff --git a/Controllers/ConnectionManagerController.cs b/Controllers/ConnectionManagerController.cs index d2a0cba95..5300743ae 100644 --- a/Controllers/ConnectionManagerController.cs +++ b/Controllers/ConnectionManagerController.cs @@ -791,11 +791,27 @@ public string AddGoogleDriveAsync() AuthorizationCodeFlow flow = new AuthorizationCodeFlow(init); Console.WriteLine("Fetching token for code: _" + req["code"] + "_"); - if (ViewBag.Env == "Staging") - RedirectUri = "https://myaccount." + RoutingConstants.STAGEHOST; - else if (ViewBag.Env == "Production") - RedirectUri = "https://myaccount.expressbase.com"; - Console.WriteLine(RedirectUri); + if (HttpContext.Items.ContainsKey("SubDomain") && HttpContext.Items.ContainsKey("Scheme")) + { + + RedirectUri = HttpContext.Items["Scheme"].ToString() + "myaccount." + HttpContext.Items["SubDomain"].ToString(); + + } + else //TODO: TestAndRemoveInTheNextDeployment + { + if (ViewBag.Env == "Staging") + { + RedirectUri = "https://myaccount." + RoutingConstants.STAGEHOST; + } + else if (ViewBag.Env == "Production") + { + RedirectUri = "https://myaccount.expressbase.com"; + } + + } + + //Console.WriteLine(RedirectUri); + TokenResponse result = AsyncHelper.RunSync(() => GetGoogleDriveKey(flow, req["code"], RedirectUri)); Console.WriteLine(JsonConvert.SerializeObject(result)); con.RefreshToken = result.RefreshToken; diff --git a/Controllers/PayPalController.cs b/Controllers/PayPalController.cs index 9e7a25811..8306b3d39 100644 --- a/Controllers/PayPalController.cs +++ b/Controllers/PayPalController.cs @@ -1,26 +1,26 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Runtime.Serialization.Json; -using System.Runtime.Serialization; -using System.Globalization; +using ExpressBase.Common; +using ExpressBase.Common.Enums; +using ExpressBase.Common.ServiceStack.ReqNRes; +using ExpressBase.Web.BaseControllers; +using Flurl.Http; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using RestSharp; -using System.Net; using RestSharp.Authenticators; -using Newtonsoft.Json; -using System.Collections.ObjectModel; -using Flurl.Http; -using ExpressBase.Web.BaseControllers; using ServiceStack; using ServiceStack.Redis; -using Microsoft.AspNetCore.Mvc; -using ExpressBase.Common.ServiceStack.ReqNRes; -using ExpressBase.Common.Enums; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; using System.IO; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Runtime.Serialization; +using System.Runtime.Serialization.Json; +using System.Threading.Tasks; using System.Web; -using ExpressBase.Common; namespace ExpressBase.Web.Controllers { @@ -90,12 +90,23 @@ public IActionResult PayPalPayment() int usercount = Convert.ToInt32(this.HttpContext.Request.Form["UserCount"]); string sid = this.HttpContext.Request.Form["Sid"]; string Env = ""; - if (ViewBag.Env == "Development") - Env = "https://myaccount." + RoutingConstants.STAGEHOST; - else if (ViewBag.Env == "Staging") - Env = "https://myaccount." + RoutingConstants.STAGEHOST; - else if (ViewBag.Env == "Production") - Env = "https://myaccount.expressbase.com"; + + if (HttpContext.Items.ContainsKey("SubDomain") && HttpContext.Items.ContainsKey("Scheme")) + { + + Env = HttpContext.Items["Scheme"].ToString() + "myaccount." + HttpContext.Items["SubDomain"].ToString(); + + } + else //TODO: TestAndRemoveInTheNextDeployment + { + if (ViewBag.Env == "Development") + Env = "https://myaccount." + RoutingConstants.STAGEHOST; + else if (ViewBag.Env == "Staging") + Env = "https://myaccount." + RoutingConstants.STAGEHOST; + else if (ViewBag.Env == "Production") + Env = "https://myaccount.expressbase.com"; + } + var rsp = this.ServiceClient.Post(new PayPalPaymentRequest { diff --git a/Middlewares/AppUrlContextMiddleware.cs b/Middlewares/AppUrlContextMiddleware.cs index 93ab70ee5..d4b0c943b 100644 --- a/Middlewares/AppUrlContextMiddleware.cs +++ b/Middlewares/AppUrlContextMiddleware.cs @@ -62,7 +62,7 @@ public async Task Invoke(HttpContext context) } - context.Items["ExternalSolutionId"] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty); //demobakerystaging + context.Items["ExternalSolutionId"] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty); //demobakerystaging context.Items["UserConsoleHost"] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty) + "." + baseHost; //demobakerystaging.expressbase.com context.Items["SubDomain"] = subdomain; } diff --git a/Views/Bote/Bots.cshtml b/Views/Bote/Bots.cshtml index d0fcf402b..46f51cada 100644 --- a/Views/Bote/Bots.cshtml +++ b/Views/Bote/Bots.cshtml @@ -181,16 +181,22 @@ window.hostValue = '@ViewBag.HostValue'; console.log("host=" + window.hostValue); /**/ - var jssrc = "https://"+solutionId+".localhost:41502"; + //var jssrc = "https://"+solutionId+".localhost:41502"; //TODO: TestAndRemoveInTheNextDeployment + + var jssrc = EbUrlHelper.getEbWebUrl(solutionId); + + //TODO: TestAndRemoveInTheNextDeployment + + /* if (d.ebmod === 'Production') jssrc = "https://"+solutionId+".expressbase.com"; else if (d.ebmod === 'Staging') jssrc = "https://" + solutionId + "." + "@RoutingConstants.STAGEHOST"; - + */ window.EXPRESSbase_SOLUTION_ID ='@ViewBag.SolutionIdExt'; window.EXPRESSbase_cid = '@ViewBag.SolutionId'; - console.log("EXPRESSbase_SOLUTION_ID=" + window.EXPRESSbase_SOLUTION_ID); - console.log("EXPRESSbase_cid=" + window.EXPRESSbase_cid); + //console.log("EXPRESSbase_SOLUTION_ID=" + window.EXPRESSbase_SOLUTION_ID); + //console.log("EXPRESSbase_cid=" + window.EXPRESSbase_cid); window.EXPRESSbase_APP_IDS = []; d.ebbotThemeColorColl = []; d.botWelcomeMsgColl = []; diff --git a/Views/Dev/AppDashBoard.cshtml b/Views/Dev/AppDashBoard.cshtml index b92c24b35..02167dc67 100644 --- a/Views/Dev/AppDashBoard.cshtml +++ b/Views/Dev/AppDashBoard.cshtml @@ -10,21 +10,34 @@ string jssrc = string.Empty; var sol_cid = ViewBag.cid; var solutionid = ViewBag.cide; - if (ViewBag.Env == "Development") - { - domurl = "http://" + solutionid + ".localhost:41500"; - jssrc = "https://" + sol_cid + ".localhost:41502"; - } - if (ViewBag.Env == "Staging") + + + if (Context.Items.ContainsKey("SubDomain") && Context.Items.ContainsKey("Scheme")) { - domurl = "https://" + solutionid + "." + RoutingConstants.STAGEHOST; - jssrc = "https://" + sol_cid + "." + RoutingConstants.STAGEHOST; + + domurl = Context.Items["Scheme"] + solutionid + "." + Context.Items["SubDomain"]; + jssrc = Context.Items["Scheme"] + sol_cid + "." + Context.Items["SubDomain"]; + } - if (ViewBag.Env == "Production") + else //TODO: TestAndRemoveInTheNextDeployment { - domurl = "https://" + solutionid + ".expressbase.com"; - jssrc = "https://" + sol_cid + ".expressbase.com"; + if (ViewBag.Env == "Development") + { + domurl = "http://" + solutionid + ".localhost:41500"; + jssrc = "https://" + sol_cid + ".localhost:41502"; + } + if (ViewBag.Env == "Staging") + { + domurl = "https://" + solutionid + "." + RoutingConstants.STAGEHOST; + jssrc = "https://" + sol_cid + "." + RoutingConstants.STAGEHOST; + } + if (ViewBag.Env == "Production") + { + domurl = "https://" + solutionid + ".expressbase.com"; + jssrc = "https://" + sol_cid + ".expressbase.com"; + } } + } @section StyleSheet{ diff --git a/Views/Ext/SignUp.cshtml b/Views/Ext/SignUp.cshtml index 1f0b679d3..ab31c72ea 100644 --- a/Views/Ext/SignUp.cshtml +++ b/Views/Ext/SignUp.cshtml @@ -1,29 +1,40 @@ @{ @using ExpressBase.Common.Constants; @using ExpressBase.Common.Helpers; -@using ExpressBase.Common; + @using ExpressBase.Common; Layout = "~/Views/Shared/LayoutExternal.cshtml"; string home = string.Empty; string sociallink = string.Empty; string signinLink = string.Empty; - if (ViewBag.Env == "Development") - { - home = "http://localhost:41400/"; - sociallink = "http://localhost:41600"; - signinLink = "http://myaccount.localhost:41500"; - } - if (ViewBag.Env == "Staging") + if (Context.Items.ContainsKey("SubDomain") && Context.Items.ContainsKey("Scheme")) { - home = "https://" + RoutingConstants.STAGEHOST; - sociallink = "https://ss." + RoutingConstants.STAGEHOST; - signinLink = "https://myaccount." + RoutingConstants.STAGEHOST; + + home = Context.Items["Scheme"].ToString() + Context.Items["SubDomain"]; + sociallink = Context.Items["Scheme"].ToString() + "ss." + Context.Items["SubDomain"]; + signinLink = Context.Items["Scheme"].ToString() + "myaccount." + Context.Items["SubDomain"]; } - if (ViewBag.Env == "Production") + else //TODO: TestAndRemoveInTheNextDeployment { - home = "https://expressbase.com"; - sociallink = "https://ss.expressbase.com"; - signinLink = "https://myaccount.expressbase.com"; + if (ViewBag.Env == "Development") + { + home = "http://localhost:41400/"; + sociallink = "http://localhost:41600"; + signinLink = "http://myaccount.localhost:41500"; + + } + if (ViewBag.Env == "Staging") + { + home = "https://" + RoutingConstants.STAGEHOST; + sociallink = "https://ss." + RoutingConstants.STAGEHOST; + signinLink = "https://myaccount." + RoutingConstants.STAGEHOST; + } + if (ViewBag.Env == "Production") + { + home = "https://expressbase.com"; + sociallink = "https://ss.expressbase.com"; + signinLink = "https://myaccount.expressbase.com"; + } } } diff --git a/Views/Ext/TenantSignIn.cshtml b/Views/Ext/TenantSignIn.cshtml index c764ca748..0e3a081ac 100644 --- a/Views/Ext/TenantSignIn.cshtml +++ b/Views/Ext/TenantSignIn.cshtml @@ -5,24 +5,37 @@ string home = string.Empty; string sociallink = string.Empty; string signinLink = string.Empty; - if (ViewBag.Env == "Development") - { - home = "http://localhost:41400"; - sociallink = "http://localhost:41600"; - signinLink = "http://myaccount.localhost:41500"; - } - if (ViewBag.Env == "Staging") + + if (Context.Items.ContainsKey("SubDomain") && Context.Items.ContainsKey("Scheme")) { - home = "https://" + RoutingConstants.STAGEHOST; - sociallink = "https://ss." + RoutingConstants.STAGEHOST; - signinLink = "https://myaccount." + RoutingConstants.STAGEHOST; + + home = Context.Items["Scheme"].ToString() + Context.Items["SubDomain"]; + sociallink = Context.Items["Scheme"].ToString() + "ss." + Context.Items["SubDomain"]; + signinLink = Context.Items["Scheme"].ToString() + "myaccount." + Context.Items["SubDomain"]; + } - if (ViewBag.Env == "Production") + else //TODO: TestAndRemoveInTheNextDeployment { - home = "https://expressbase.com"; - sociallink = "https://ss.expressbase.com"; - signinLink = "https://myaccount.expressbase.com"; + if (ViewBag.Env == "Development") + { + home = "http://localhost:41400"; + sociallink = "http://localhost:41600"; + signinLink = "http://myaccount.localhost:41500"; + } + if (ViewBag.Env == "Staging") + { + home = "https://" + RoutingConstants.STAGEHOST; + sociallink = "https://ss." + RoutingConstants.STAGEHOST; + signinLink = "https://myaccount." + RoutingConstants.STAGEHOST; + } + if (ViewBag.Env == "Production") + { + home = "https://expressbase.com"; + sociallink = "https://ss.expressbase.com"; + signinLink = "https://myaccount.expressbase.com"; + } } + } @section StyleSheet{ diff --git a/Views/Shared/ExtPageHeader.cshtml b/Views/Shared/ExtPageHeader.cshtml index f539a4a0c..d705143b7 100644 --- a/Views/Shared/ExtPageHeader.cshtml +++ b/Views/Shared/ExtPageHeader.cshtml @@ -2,21 +2,32 @@ @using ExpressBase.Common; @{ string signinurl = string.Empty, appstoreurl = string.Empty, home = string.Empty; ; - if (ViewBag.Env == "Development") - { - home = "http://localhost:41400"; - signinurl = "http://myaccount.localhost:41500"; - } - if (ViewBag.Env == "Staging") + + if (Context.Items.ContainsKey("SubDomain") && Context.Items.ContainsKey("Scheme")) { - home = "https://" + RoutingConstants.STAGEHOST; - signinurl = "https://myaccount." + RoutingConstants.STAGEHOST; + home = Context.Items["Scheme"].ToString() + Context.Items["SubDomain"].ToString(); + signinurl = Context.Items["Scheme"].ToString() + "myaccount." + Context.Items["SubDomain"].ToString(); + } - if (ViewBag.Env == "Production") + else //TODO: TestAndRemoveInTheNextDeployment { - home = "https://expressbase.com"; - signinurl = "https://myaccount.expressbase.com"; + if (ViewBag.Env == "Development") + { + home = "http://localhost:41400"; + signinurl = "http://myaccount.localhost:41500"; + } + if (ViewBag.Env == "Staging") + { + home = "https://" + RoutingConstants.STAGEHOST; + signinurl = "https://myaccount." + RoutingConstants.STAGEHOST; + } + if (ViewBag.Env == "Production") + { + home = "https://expressbase.com"; + signinurl = "https://myaccount.expressbase.com"; + } } + bool isLogined = (ViewBag.AvailToken == null) ? false : ViewBag.AvailToken; }
diff --git a/Views/Tenant/SolutionManager.cshtml b/Views/Tenant/SolutionManager.cshtml index c7c01b72f..22f3e2963 100644 --- a/Views/Tenant/SolutionManager.cshtml +++ b/Views/Tenant/SolutionManager.cshtml @@ -15,30 +15,59 @@ } @{ string proto = string.Empty; + string sso_dev = string.Empty; + string sso_user = string.Empty; + string devaction = string.Empty; + string useraction = string.Empty; - if (ViewBag.Env == "Development") + + if (Context.Items.ContainsKey("SubDomain") && Context.Items.ContainsKey("Scheme") && Context.Items.ContainsKey("DevConsoleHost")) { - proto = "http://"; + sso_dev = Context.Items["Scheme"].ToString() + Context.Items["DevConsoleHost"].ToString() + "/Ext/SwitchContext"; + sso_user = Context.Items["Scheme"].ToString() + Context.Items["UserConsoleHost"].ToString() + "/Ext/SwitchContext"; } - else if (ViewBag.Env == "Staging") + else //TODO: TestAndRemoveInTheNextDeployment { - proto = "https://"; + if (ViewBag.Env == "Development") + { + proto = "http://"; + } + else if (ViewBag.Env == "Staging") + { + proto = "https://"; + } + else if (ViewBag.Env == "Production") + { + proto = "https://"; + } + + sso_dev = proto + ViewBag.Connections.SolutionInfo.EsolutionId + "-dev." + ViewBag.Domain + "/Ext/SwitchContext"; + sso_user = proto + ViewBag.Connections.SolutionInfo.EsolutionId + "." + ViewBag.Domain + "/Ext/SwitchContext"; + } - else if (ViewBag.Env == "Production") + + devaction = sso_dev.Replace("myaccount.", ""); + useraction = sso_user.Replace("myaccount.", ""); + + if (ViewBag.Connections.SolutionInfo.EsolutionId.Contains(".")) { - proto = "https://"; + devaction = sso_dev.Replace("myaccount.", "") + .Replace(ViewBag.Connections.SolutionInfo.EsolutionId, ViewBag.Connections.SolutionInfo.IsolutionId); + + useraction = sso_user.Replace("myaccount.", "") + .Replace(RoutingConstants.LIVEHOSTADDRESS, string.Empty) + .Replace(RoutingConstants.STAGEHOSTADDRESS, string.Empty) + .Replace(RoutingConstants.LOCALHOSTADDRESS + ":41500", string.Empty); } - string sso_dev = proto + ViewBag.Connections.SolutionInfo.EsolutionId + "-dev." + ViewBag.Domain + "/Ext/SwitchContext"; - string sso_user = proto + ViewBag.Connections.SolutionInfo.EsolutionId + "." + ViewBag.Domain + "/Ext/SwitchContext"; + //string dbdefault = /*(EbConnections.DataDbConnection.IsDefault) ? "(Default)" :*/ ""; //string filedefault = ""; //if (EbConnections.FilesDbConnection != null) //{ // filedefault = (EbConnections.FilesDbConnection.IsDefault)? "(Default)" : ""; //} - Dictionary - Image_url = new Dictionary - (); + + Dictionary Image_url = new Dictionary(); Image_url.Add("PGSQL", ""); Image_url.Add("MSSQL", ""); Image_url.Add("MYSQL", ""); @@ -82,13 +111,7 @@
@{ - string devaction = sso_dev.Replace("myaccount.", ""); - string useraction = sso_user.Replace("myaccount.", ""); - if (ViewBag.Connections.SolutionInfo.EsolutionId.Contains(".")) - { - devaction = sso_dev.Replace("myaccount.", "").Replace(ViewBag.Connections.SolutionInfo.EsolutionId, ViewBag.Connections.SolutionInfo.IsolutionId); - useraction = sso_user.Replace("myaccount.", "").Replace(RoutingConstants.LIVEHOSTADDRESS, string.Empty).Replace(RoutingConstants.STAGEHOSTADDRESS, string.Empty).Replace(RoutingConstants.LOCALHOSTADDRESS + ":41500", string.Empty); - } +
diff --git a/Views/Wiki/WikiAdd.cshtml b/Views/Wiki/WikiAdd.cshtml index 396b81b62..275f33ae1 100644 --- a/Views/Wiki/WikiAdd.cshtml +++ b/Views/Wiki/WikiAdd.cshtml @@ -323,7 +323,7 @@ Toggle: "#btnUploadImg", Container: "eb-wiki-uploader", Multiple: true, - ServerEventUrl: 'https://se.' + '@RoutingConstants.STAGEHOST', + ServerEventUrl: 'https://se.' + '@RoutingConstants.STAGEHOST', EnableCrop: true, MaxSize:(("@ViewBag.Env" === "Staging")? 15: 2),//in MegaBytes CustomMenu: [{ name: "Copy link", icon: "fa-user" }] From 312aea074313b4c51fcaeff9ea650dc731ff02d5 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 13 Oct 2025 22:47:12 +0530 Subject: [PATCH 16/58] removed internal bug tickets --- Views/Shared/LayoutBuilders.cshtml | 2 +- Views/Shared/LayoutDashboard.cshtml | 2 +- Views/Shared/LayoutInner.cshtml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Views/Shared/LayoutBuilders.cshtml b/Views/Shared/LayoutBuilders.cshtml index 89f551509..0e500a93a 100644 --- a/Views/Shared/LayoutBuilders.cshtml +++ b/Views/Shared/LayoutBuilders.cshtml @@ -218,7 +218,7 @@ - + @**@ diff --git a/Views/Shared/LayoutDashboard.cshtml b/Views/Shared/LayoutDashboard.cshtml index 000652337..b347797d7 100644 --- a/Views/Shared/LayoutDashboard.cshtml +++ b/Views/Shared/LayoutDashboard.cshtml @@ -188,7 +188,7 @@ - + @**@ diff --git a/Views/Shared/LayoutInner.cshtml b/Views/Shared/LayoutInner.cshtml index df0b8f1a7..0b599db74 100644 --- a/Views/Shared/LayoutInner.cshtml +++ b/Views/Shared/LayoutInner.cshtml @@ -84,7 +84,7 @@ - + @**@ From 443e53bb98a150b6b407f960af0ec2425477358d Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 13 Oct 2025 22:47:29 +0530 Subject: [PATCH 17/58] removed internal bug tickets --- Views/Shared/Components/PageHeaderCommon/Default.cshtml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Views/Shared/Components/PageHeaderCommon/Default.cshtml b/Views/Shared/Components/PageHeaderCommon/Default.cshtml index 533cc9ee6..9031fd539 100644 --- a/Views/Shared/Components/PageHeaderCommon/Default.cshtml +++ b/Views/Shared/Components/PageHeaderCommon/Default.cshtml @@ -130,6 +130,7 @@ } + /* @if ((ViewBag.wc == "uc" || ViewBag.wc == "dc") && (ViewBag.Env != "Production" || ViewBag.email == "support@expressbase.com")) { } + */ }
From ac571dff37af6583f100d9caf9ac9341552e673d Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 13 Oct 2025 22:50:00 +0530 Subject: [PATCH 18/58] detached bug tickets --- Views/Shared/Components/ObjectDashboard/Default.cshtml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Views/Shared/Components/ObjectDashboard/Default.cshtml b/Views/Shared/Components/ObjectDashboard/Default.cshtml index b395bbd7b..34814c7b1 100644 --- a/Views/Shared/Components/ObjectDashboard/Default.cshtml +++ b/Views/Shared/Components/ObjectDashboard/Default.cshtml @@ -149,6 +149,7 @@ } + /* if ((ViewBag.wc == "uc" || ViewBag.wc == "dc") && (ViewBag.Env != "Production" || ViewBag.email == "support@expressbase.com")) { } + */ }
From 2b2f120517351cf3cac689262e6041b570beb093 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Tue, 14 Oct 2025 16:20:41 +0530 Subject: [PATCH 19/58] fixed the swap between domain and sub-domain --- BaseControllers/EbBaseExtController.cs | 4 ++-- Controllers/ConnectionManagerController.cs | 4 ++-- Controllers/PayPalController.cs | 4 ++-- Middlewares/AppUrlContextMiddleware.cs | 2 +- Views/Dev/AppDashBoard.cshtml | 6 +++--- Views/Ext/SignUp.cshtml | 8 ++++---- Views/Ext/TenantSignIn.cshtml | 8 ++++---- Views/Shared/ExtPageHeader.cshtml | 6 +++--- Views/Tenant/SolutionManager.cshtml | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/BaseControllers/EbBaseExtController.cs b/BaseControllers/EbBaseExtController.cs index d4eb40357..428d029bc 100644 --- a/BaseControllers/EbBaseExtController.cs +++ b/BaseControllers/EbBaseExtController.cs @@ -46,10 +46,10 @@ public override void OnActionExecuting(ActionExecutingContext context) controller.ViewBag.HostValue = context.HttpContext.Request.Host.Value; controller.ViewBag.Env = Environment.GetEnvironmentVariable(EnvironmentConstants.ASPNETCORE_ENVIRONMENT); - if (HttpContext.Items.ContainsKey("SubDomain") && HttpContext.Items.ContainsKey("Scheme")) + if (HttpContext.Items.ContainsKey("Domain") && HttpContext.Items.ContainsKey("Scheme")) { - controller.ViewBag.Root = HttpContext.Items["Scheme"].ToString() + HttpContext.Items["SubDomain"].ToString(); + controller.ViewBag.Root = HttpContext.Items["Scheme"].ToString() + HttpContext.Items["Domain"].ToString(); } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/Controllers/ConnectionManagerController.cs b/Controllers/ConnectionManagerController.cs index 5300743ae..4a1a781de 100644 --- a/Controllers/ConnectionManagerController.cs +++ b/Controllers/ConnectionManagerController.cs @@ -791,10 +791,10 @@ public string AddGoogleDriveAsync() AuthorizationCodeFlow flow = new AuthorizationCodeFlow(init); Console.WriteLine("Fetching token for code: _" + req["code"] + "_"); - if (HttpContext.Items.ContainsKey("SubDomain") && HttpContext.Items.ContainsKey("Scheme")) + if (HttpContext.Items.ContainsKey("Domain") && HttpContext.Items.ContainsKey("Scheme")) { - RedirectUri = HttpContext.Items["Scheme"].ToString() + "myaccount." + HttpContext.Items["SubDomain"].ToString(); + RedirectUri = HttpContext.Items["Scheme"].ToString() + "myaccount." + HttpContext.Items["Domain"].ToString(); } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/Controllers/PayPalController.cs b/Controllers/PayPalController.cs index 8306b3d39..05d4752f0 100644 --- a/Controllers/PayPalController.cs +++ b/Controllers/PayPalController.cs @@ -91,10 +91,10 @@ public IActionResult PayPalPayment() string sid = this.HttpContext.Request.Form["Sid"]; string Env = ""; - if (HttpContext.Items.ContainsKey("SubDomain") && HttpContext.Items.ContainsKey("Scheme")) + if (HttpContext.Items.ContainsKey("Domain") && HttpContext.Items.ContainsKey("Scheme")) { - Env = HttpContext.Items["Scheme"].ToString() + "myaccount." + HttpContext.Items["SubDomain"].ToString(); + Env = HttpContext.Items["Scheme"].ToString() + "myaccount." + HttpContext.Items["Domain"].ToString(); } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/Middlewares/AppUrlContextMiddleware.cs b/Middlewares/AppUrlContextMiddleware.cs index d4b0c943b..112260eb7 100644 --- a/Middlewares/AppUrlContextMiddleware.cs +++ b/Middlewares/AppUrlContextMiddleware.cs @@ -64,7 +64,7 @@ public async Task Invoke(HttpContext context) context.Items["ExternalSolutionId"] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty); //demobakerystaging context.Items["UserConsoleHost"] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty) + "." + baseHost; //demobakerystaging.expressbase.com - context.Items["SubDomain"] = subdomain; + context.Items["SubDomain"] = subdomain; //demobakerystaging || demobakerystaging-dev } context.Items["BaseHost"] = baseHost; diff --git a/Views/Dev/AppDashBoard.cshtml b/Views/Dev/AppDashBoard.cshtml index 02167dc67..8f266e065 100644 --- a/Views/Dev/AppDashBoard.cshtml +++ b/Views/Dev/AppDashBoard.cshtml @@ -12,11 +12,11 @@ var solutionid = ViewBag.cide; - if (Context.Items.ContainsKey("SubDomain") && Context.Items.ContainsKey("Scheme")) + if (Context.Items.ContainsKey("Domain") && Context.Items.ContainsKey("Scheme")) { - domurl = Context.Items["Scheme"] + solutionid + "." + Context.Items["SubDomain"]; - jssrc = Context.Items["Scheme"] + sol_cid + "." + Context.Items["SubDomain"]; + domurl = Context.Items["Scheme"] + solutionid + "." + Context.Items["Domain"]; + jssrc = Context.Items["Scheme"] + sol_cid + "." + Context.Items["Domain"]; } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/Views/Ext/SignUp.cshtml b/Views/Ext/SignUp.cshtml index ab31c72ea..5c0da8438 100644 --- a/Views/Ext/SignUp.cshtml +++ b/Views/Ext/SignUp.cshtml @@ -7,12 +7,12 @@ string sociallink = string.Empty; string signinLink = string.Empty; - if (Context.Items.ContainsKey("SubDomain") && Context.Items.ContainsKey("Scheme")) + if (Context.Items.ContainsKey("Domain") && Context.Items.ContainsKey("Scheme")) { - home = Context.Items["Scheme"].ToString() + Context.Items["SubDomain"]; - sociallink = Context.Items["Scheme"].ToString() + "ss." + Context.Items["SubDomain"]; - signinLink = Context.Items["Scheme"].ToString() + "myaccount." + Context.Items["SubDomain"]; + home = Context.Items["Scheme"].ToString() + Context.Items["Domain"]; + sociallink = Context.Items["Scheme"].ToString() + "ss." + Context.Items["Domain"]; + signinLink = Context.Items["Scheme"].ToString() + "myaccount." + Context.Items["Domain"]; } else //TODO: TestAndRemoveInTheNextDeployment { diff --git a/Views/Ext/TenantSignIn.cshtml b/Views/Ext/TenantSignIn.cshtml index 0e3a081ac..9dc80eef1 100644 --- a/Views/Ext/TenantSignIn.cshtml +++ b/Views/Ext/TenantSignIn.cshtml @@ -6,12 +6,12 @@ string sociallink = string.Empty; string signinLink = string.Empty; - if (Context.Items.ContainsKey("SubDomain") && Context.Items.ContainsKey("Scheme")) + if (Context.Items.ContainsKey("Domain") && Context.Items.ContainsKey("Scheme")) { - home = Context.Items["Scheme"].ToString() + Context.Items["SubDomain"]; - sociallink = Context.Items["Scheme"].ToString() + "ss." + Context.Items["SubDomain"]; - signinLink = Context.Items["Scheme"].ToString() + "myaccount." + Context.Items["SubDomain"]; + home = Context.Items["Scheme"].ToString() + Context.Items["Domain"]; + sociallink = Context.Items["Scheme"].ToString() + "ss." + Context.Items["Domain"]; + signinLink = Context.Items["Scheme"].ToString() + "myaccount." + Context.Items["Domain"]; } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/Views/Shared/ExtPageHeader.cshtml b/Views/Shared/ExtPageHeader.cshtml index d705143b7..a4d76de10 100644 --- a/Views/Shared/ExtPageHeader.cshtml +++ b/Views/Shared/ExtPageHeader.cshtml @@ -3,10 +3,10 @@ @{ string signinurl = string.Empty, appstoreurl = string.Empty, home = string.Empty; ; - if (Context.Items.ContainsKey("SubDomain") && Context.Items.ContainsKey("Scheme")) + if (Context.Items.ContainsKey("Domain") && Context.Items.ContainsKey("Scheme")) { - home = Context.Items["Scheme"].ToString() + Context.Items["SubDomain"].ToString(); - signinurl = Context.Items["Scheme"].ToString() + "myaccount." + Context.Items["SubDomain"].ToString(); + home = Context.Items["Scheme"].ToString() + Context.Items["Domain"].ToString(); + signinurl = Context.Items["Scheme"].ToString() + "myaccount." + Context.Items["Domain"].ToString(); } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/Views/Tenant/SolutionManager.cshtml b/Views/Tenant/SolutionManager.cshtml index 22f3e2963..5cc0f98d8 100644 --- a/Views/Tenant/SolutionManager.cshtml +++ b/Views/Tenant/SolutionManager.cshtml @@ -21,7 +21,7 @@ string useraction = string.Empty; - if (Context.Items.ContainsKey("SubDomain") && Context.Items.ContainsKey("Scheme") && Context.Items.ContainsKey("DevConsoleHost")) + if (Context.Items.ContainsKey("Scheme") && Context.Items.ContainsKey("DevConsoleHost") && Context.Items.ContainsKey("UserConsoleHost")) { sso_dev = Context.Items["Scheme"].ToString() + Context.Items["DevConsoleHost"].ToString() + "/Ext/SwitchContext"; sso_user = Context.Items["Scheme"].ToString() + Context.Items["UserConsoleHost"].ToString() + "/Ext/SwitchContext"; From 90f57d4c0f3c4d67c299c7a988396491579d4fc1 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Tue, 14 Oct 2025 17:16:35 +0530 Subject: [PATCH 20/58] Removed support for PayPal --- Controllers/PayPalController.cs | 132 -------------------------- Controllers/PayPalReturnController.cs | 78 --------------- Views/PayPal/Billing.cshtml | 93 ------------------ Views/PayPal/CancelAgreement.cshtml | 4 - Views/PayPal/Index.cshtml | 16 ---- Views/PayPal/ReturnSuccess.cshtml | 4 - 6 files changed, 327 deletions(-) delete mode 100644 Controllers/PayPalController.cs delete mode 100644 Controllers/PayPalReturnController.cs delete mode 100644 Views/PayPal/Billing.cshtml delete mode 100644 Views/PayPal/CancelAgreement.cshtml delete mode 100644 Views/PayPal/Index.cshtml delete mode 100644 Views/PayPal/ReturnSuccess.cshtml diff --git a/Controllers/PayPalController.cs b/Controllers/PayPalController.cs deleted file mode 100644 index 05d4752f0..000000000 --- a/Controllers/PayPalController.cs +++ /dev/null @@ -1,132 +0,0 @@ -using ExpressBase.Common; -using ExpressBase.Common.Enums; -using ExpressBase.Common.ServiceStack.ReqNRes; -using ExpressBase.Web.BaseControllers; -using Flurl.Http; -using Microsoft.AspNetCore.Mvc; -using Newtonsoft.Json; -using RestSharp; -using RestSharp.Authenticators; -using ServiceStack; -using ServiceStack.Redis; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Globalization; -using System.IO; -using System.Net; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Json; -using System.Threading.Tasks; -using System.Web; - -namespace ExpressBase.Web.Controllers -{ - public class PayPalController : EbBaseIntCommonController - { - public PayPalController(IServiceClient _ssclient, IRedisClient _redis) : base(_ssclient, _redis) - { - } - - //[HttpGet] - //public IActionResult Index() - //{ - // PayPalPaymentRequest req = new PayPalPaymentRequest(); - // var PayPalRes = this.ServiceClient.Post(req); - - // return Redirect(PayPalRes.ApprovalUrl); - //} - [HttpPost] - public void PayPalWebHook(string action) - { - Console.WriteLine("WEBHOOK HANDLER: Received Webhook Request Successfully"); - var BodyStream = this.HttpContext.Request.Body; - string content = string.Empty; - Console.WriteLine("WEBHOOK HANDLER: Webhook Request Body: \n\n" + content); - using (var reader = new StreamReader(BodyStream)) - content = reader.ReadToEnd(); - var Response = this.ServiceClient.Post(new PayPalWebHookHandler - { - JsonBody = content, - Action = action - }); - } - - [HttpGet("PayPal/ReturnSuccess/{sid}")] - public IActionResult ReturnSuccess(string token) - { - string reqpath = HttpContext.Request.Path; - reqpath = reqpath.Trim(); - string[] urlParts = reqpath.Split('/'); - string sid = urlParts[urlParts.Length - 1]; - var Res = this.ServiceClient.Post(new PayPalSuccessReturnRequest - { - PaymentId = token, - SolutionId = sid - }); - return View(); - } - - [HttpGet("PayPal/CancelAgreement/{sid}")] - public IActionResult CancelAgreement(string sid, string token) - { - var Res = this.ServiceClient.Post(new PayPalFailureReturnRequest{ - PaymentId=token, - SolutionId=sid - }); - return View(); - } - - [HttpGet("Billing")] - public IActionResult Billing() - { - return View(); - } - - public IActionResult PayPalPayment() - { - int usercount = Convert.ToInt32(this.HttpContext.Request.Form["UserCount"]); - string sid = this.HttpContext.Request.Form["Sid"]; - string Env = ""; - - if (HttpContext.Items.ContainsKey("Domain") && HttpContext.Items.ContainsKey("Scheme")) - { - - Env = HttpContext.Items["Scheme"].ToString() + "myaccount." + HttpContext.Items["Domain"].ToString(); - - } - else //TODO: TestAndRemoveInTheNextDeployment - { - if (ViewBag.Env == "Development") - Env = "https://myaccount." + RoutingConstants.STAGEHOST; - else if (ViewBag.Env == "Staging") - Env = "https://myaccount." + RoutingConstants.STAGEHOST; - else if (ViewBag.Env == "Production") - Env = "https://myaccount.expressbase.com"; - } - - - var rsp = this.ServiceClient.Post(new PayPalPaymentRequest - { - BillingMethod = PaymentMethod.paypal, - Environment = Env, - SolutionId = sid, - UserCount = usercount - }); - if (rsp.ApprovalUrl.Length > 0) - return Redirect(rsp.ApprovalUrl); - return View(); - } - - public IActionResult GetApproval() - { - - return View(); - } - - } - - -} diff --git a/Controllers/PayPalReturnController.cs b/Controllers/PayPalReturnController.cs deleted file mode 100644 index fba19d2ee..000000000 --- a/Controllers/PayPalReturnController.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Routing; -using Microsoft.Extensions.Options; -using System.Net; -using Newtonsoft.Json; -using System.Web; -using ExpressBase.Web.BaseControllers; -using ServiceStack; -using ServiceStack.Redis; -using Microsoft.AspNetCore.Mvc; -using Flurl.Http; -using System.Net.Http; - -namespace ExpressBase.Web.Controllers -{ - public enum UserAcceptance { WAITING, ACCEPTED, CANCELED }; - - public class PaymentReturnController : EbBaseExtController - { - // private UserAcceptance accepted = UserAcceptance.WAITING; - - public PaymentReturnController (IServiceClient _client, IRedisClient _redis) : base(_client, _redis) { } - - public static string GetStringFromStream(System.IO.Stream stream) - { - System.IO.StreamReader reader = new System.IO.StreamReader(stream); - return reader.ReadToEnd(); - } - - private void HandleApproval() - { - // accepted = UserAcceptance.ACCEPTED; - Console.WriteLine("Accepted By User"); - } - - private void HandleCancelation() - { - // accepted = UserAcceptance.CANCELED; - Console.WriteLine("Rejected By User"); - } - - private async Task Send(FlurlRequest request) - { - return await request.SendAsync(HttpMethod.Post); - } - - private async Task GetresponseString(HttpResponseMessage response) - { - return await response.Content.ReadAsStringAsync(); - } - - [HttpGet] - public IActionResult PaypalReturn(string res, string tok, string token) - { - if(res.ToLower().Trim() == "accept") - { - Console.WriteLine("Before HttpPost"); - FlurlClient flurlClient = new FlurlClient(); - flurlClient.Headers.Add("Content-Type", "application/json"); - flurlClient.Headers.Add("Authorization", "Bearer " + tok); - FlurlRequest fRequest = new FlurlRequest("https://api.sandbox.paypal.com/v1/payments/billing-agreements/" + token + "/agreement-execute/"); - fRequest.Client = flurlClient; - var frespone = Send(fRequest).Result; - string responseString = GetresponseString(frespone).Result; - Console.WriteLine("HTTP Response : " + responseString); - } - else - { - HandleCancelation(); - } - - return View(); - } - } -} diff --git a/Views/PayPal/Billing.cshtml b/Views/PayPal/Billing.cshtml deleted file mode 100644 index eb96c78c9..000000000 --- a/Views/PayPal/Billing.cshtml +++ /dev/null @@ -1,93 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; -} - -@await Component.InvokeAsync("PageHeaderCommon") -@*
-
-
-

Payment methods

-

- Please enter your preferred payment method below. You can use a credit card or prepay through PayPal. -

-
- -
-
- - - - -
-
-
-
-
-
- -
-
-
-

- Card will be charged monthly for number of users. All major credit cards accepted. -

- -
-
- -
- - -
-
- -
- - - - -
-
-
-
- -
- -
-
- -
-
-
- - -
-
-
- -
- -
-
-
-

- Add PayPal credit to your account. This is a one-time payment and will take some time to process. -

-
- -
-
-
-
-
-
-
*@ diff --git a/Views/PayPal/CancelAgreement.cshtml b/Views/PayPal/CancelAgreement.cshtml deleted file mode 100644 index b87b0dc9a..000000000 --- a/Views/PayPal/CancelAgreement.cshtml +++ /dev/null @@ -1,4 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; -} -

payment cancelled

\ No newline at end of file diff --git a/Views/PayPal/Index.cshtml b/Views/PayPal/Index.cshtml deleted file mode 100644 index 7f5e696db..000000000 --- a/Views/PayPal/Index.cshtml +++ /dev/null @@ -1,16 +0,0 @@ - -@{ - Layout = null; -} - - - - - - - Index - - -

Paypal

- - diff --git a/Views/PayPal/ReturnSuccess.cshtml b/Views/PayPal/ReturnSuccess.cshtml deleted file mode 100644 index 2f88ad370..000000000 --- a/Views/PayPal/ReturnSuccess.cshtml +++ /dev/null @@ -1,4 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; -} -

payment Success

\ No newline at end of file From ce67fed4967e92049c9418c9609767cedfd013f7 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Tue, 14 Oct 2025 17:17:05 +0530 Subject: [PATCH 21/58] Removed the support for Stripe --- Controllers/StripeController.cs | 346 ------------- Controllers/StripeWebhookController.cs | 44 -- Views/Stripe/CustomerInvoices.cshtml | 199 -------- Views/Stripe/GetCustomerInvoice.cshtml | 247 --------- .../Stripe/GetCustomerUpcomingInvoice.cshtml | 225 --------- Views/Stripe/Index.cshtml | 279 ---------- Views/Stripe/Payment2.cshtml | 286 ----------- Views/Stripe/StripeHome.cshtml | 475 ------------------ Views/Stripe/SubscribedView.cshtml | 46 -- .../Stripe/UpdateCustomerSubscription.cshtml | 105 ---- Views/Stripe/ViewPlans.cshtml | 106 ---- 11 files changed, 2358 deletions(-) delete mode 100644 Controllers/StripeController.cs delete mode 100644 Controllers/StripeWebhookController.cs delete mode 100644 Views/Stripe/CustomerInvoices.cshtml delete mode 100644 Views/Stripe/GetCustomerInvoice.cshtml delete mode 100644 Views/Stripe/GetCustomerUpcomingInvoice.cshtml delete mode 100644 Views/Stripe/Index.cshtml delete mode 100644 Views/Stripe/Payment2.cshtml delete mode 100644 Views/Stripe/StripeHome.cshtml delete mode 100644 Views/Stripe/SubscribedView.cshtml delete mode 100644 Views/Stripe/UpdateCustomerSubscription.cshtml delete mode 100644 Views/Stripe/ViewPlans.cshtml diff --git a/Controllers/StripeController.cs b/Controllers/StripeController.cs deleted file mode 100644 index 6a270fecc..000000000 --- a/Controllers/StripeController.cs +++ /dev/null @@ -1,346 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using ServiceStack.Stripe; -using ServiceStack.Stripe.Types; -using System.IO; -using Newtonsoft.Json; -using ServiceStack; -using ServiceStack.Redis; -using ExpressBase.Web.BaseControllers; -using ExpressBase.Objects.ServiceStack_Artifacts; -using Stripe; -using ExpressBase.Common; -using ExpressBase.Common.LocationNSolution; -using Newtonsoft.Json.Linq; - -namespace StripeApp.Controllers -{ - public class StripeController : EbBaseIntCommonController - { - public StripeController(IServiceClient sclient, IRedisClient redis) : base(sclient, redis) { } - public static int i = 0; - public IActionResult Index() - { - ViewBag.pb_key = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_STRIPE_PUBLISHABLE_KEY); - Eb_Solution soln = GetSolutionObject(ViewBag.cid); - if (soln.PricingTier == 0) - { - ViewBag.Status = true; - } - else - { - ViewBag.Status = false; - CheckCustomerSubscribedResponse cust = this.ServiceClient.Post(new CheckCustomerSubscribedRequest - { - }); - ViewBag.Plan = cust.Plan; - ViewBag.Users = cust.Users; - } - return View("Index"); - } - - public IActionResult Payment2() - { - return View("Payment2"); - } - - public IActionResult StripeHome() - { - ViewBag.pb_key = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_STRIPE_PUBLISHABLE_KEY); - Eb_Solution soln = GetSolutionObject(ViewBag.cid); - string cust_id = ""; - if (soln.PricingTier == 0) - { - ViewBag.Status = true; - // return View("Index"); - } - else - { - ViewBag.Status = false; - //---------------------------Plan------------------------ - CheckCustomerSubscribedResponse cust1 = this.ServiceClient.Post(new CheckCustomerSubscribedRequest - { - }); - ViewBag.Plan = cust1.Plan; - ViewBag.Users = cust1.Users; - cust_id = cust1.CustId; - //--------------------------Customer---------------------- - GetCustomerResponse cust = this.ServiceClient.Post(new GetCustomerRequest - { - CustId = cust_id - }); - ViewBag.Cust = cust; - //-------------------------Card------------------------------- - GetCardResponse resp = this.ServiceClient.Post(new GetCardRequest - { - CustId = cust_id - }); - ViewBag.Card = resp; - - //---------------------------Invoice---------------------- - GetCustomerInvoiceResponse stripeinvoice = this.ServiceClient.Post(new GetCustomerInvoiceRequest - { - CustId = cust_id, - }); - ViewBag.Count = stripeinvoice.Invoices.List.Count; - ViewBag.StripeInvoice = stripeinvoice; - - GetCustomerUpcomingInvoiceResponse stripeupcominginvoice = this.ServiceClient.Post(new GetCustomerUpcomingInvoiceRequest - { - CustId = cust_id - }); - ViewBag.UpCount = stripeupcominginvoice.Invoice.Data.Count; - ViewBag.StripeUpcomingInvoice = stripeupcominginvoice; - } - return View("StripeHome"); - } - //public IActionResult Charge(string stripeEmail, string stripeToken) - //{ - // var customers = new CustomerService(); - // var charges = new ChargeService(); - - // var customer = customers.Create(new CustomerCreateOptions - // { - // Email = stripeEmail, - // SourceToken = stripeToken - // }); - - // var charge = charges.Create(new ChargeCreateOptions - // { - // Amount = 500, - // Description = "Sample Charge", - // Currency = "usd", - // CustomerId = customer.Id - // }); - - // return View(); - //} - - [HttpPost] - public Object Index(int user_no, string name, string email, string address, string city, string state, string zip, string country, string token, string sid) - { - //string planId = "TEST-PLAN-02"; - string CouponId = "COUPON-2-15-3-2-15000"; - StripeToken Token = JsonConvert.DeserializeObject(token); - string custid = ""; - string planId = ""; - - if (CheckCustomer(Token.Id, email, sid)) - { - custid = CreateCustomer(Token.Id, email, sid); - } - else - { - custid = CreateCustomer(Token.Id, email, sid); - UpdateCard(custid, Token.Id, Token.Card.Id, name, address, city, state, zip, country); - } - //planId = "plan_FH9R9kOAeqMdva"; - planId = "TestPlan-01"; - - CreateCharge(custid); - - CreateSubscriptionResponse res = CreateSubscription(custid, planId, CouponId, user_no, sid); - return res; - } - - public bool CheckCustomer(string tokenid, string email, string sid) - { - CheckCustomerResponse res = this.ServiceClient.Post(new CheckCustomerRequest - { - EmailId = email, - TokenId = tokenid, - SolutionId = sid - }); - return res.Status; - } - - public void UpdateCard(string custid,string token_id, string cardid, string name, string address, string city, string state, string zip, string country) - { - this.ServiceClient.Post(new UpdateCardRequest - { - CustId = custid, - CardId = cardid, - TokenId = token_id, - Name = name, - Address = address, - City = city, - State = state, - Country = country, - Zip = zip - }); - } - - public void CreateInvoice(string custid) - { - this.ServiceClient.Post(new CreateInvoiceRequest - { - CustId = custid, - Total = Request.Form["tot"] - }); - } - - public string CreateCustomer(string tokenid, string email, string sid) - { - CreateCustomerResponse res = this.ServiceClient.Post(new CreateCustomerRequest - { - EmailId = email, - TokenId = tokenid, - SolnId = sid - }); - return res.CustomerId; - } - - public void CreateCharge(string custid) - { - this.ServiceClient.Post(new CreateChargeRequest { CustId = custid }); - } - - public void CreateCharge2(string custid) - { - this.ServiceClient.Post(new CreateCharge2Request { CustId = custid, Total = Request.Form["tot"] }); - } - - public string CreatePlan() - { - CreatePlanResponse res = this.ServiceClient.Post(new CreatePlanRequest { Total = Request.Form["tot"], Interval = 0, Interval_count = 1 }); - return res.PlanId; - } - - public string CreateCoupon() - { - CreateCouponResponse res = this.ServiceClient.Post(new CreateCouponRequest { Duration = 2, PercentageOff = 13, DurationInMonth = 2, RedeemBy = 3, MaxRedeem = 15000 }); - return res.CouponId; - } - - public CreateSubscriptionResponse CreateSubscription(string custid, string planid, string coupid, int userno, string sid) - { - Eb_Solution soln = GetSolutionObject(ViewBag.cid); - CreateSubscriptionResponse res = this.ServiceClient.Post(new CreateSubscriptionRequest - { - Total = userno, - CustId = custid, - PlanId = planid, - CoupId = coupid, - SolnId = sid - }); - return res; - } - - public Object UpdateCustomerSubscription(int user_no,string cust_id, string sid) - { - string planId = "TestPlan-01"; - Eb_Solution soln = GetSolutionObject(ViewBag.cid); - UpgradeSubscriptionResponse res = this.ServiceClient.Post(new UpgradeSubscriptionRequest - { - CustId = cust_id, - Total = user_no, - PlanId = planId, - SolnId = sid - }); - - GetCustomerUpcomingInvoiceResponse stripeupcominginvoice = this.ServiceClient.Post(new GetCustomerUpcomingInvoiceRequest - { - CustId = cust_id - }); - - res.Invoice = stripeupcominginvoice.Invoice; - res.Count = stripeupcominginvoice.Invoice.Data.Count; - - return res; - } - - public Object AddCustomerCard(string cust_id,string token, string sid) - { - StripeToken Token = JsonConvert.DeserializeObject(token); - Eb_Solution soln = GetSolutionObject(ViewBag.cid); - AddCustomerCardResponse res = this.ServiceClient.Post(new AddCustomerCardRequest - { - CustId = cust_id, - TokenId = Token.Id, - CardId = Token.Card.Id, - SolnId = sid - }); - return res; - } - - public Object UpdateCustomerCard(string cust_id, string name, string email, string address, string city, string state, string zip, string country, string sid) - { - Eb_Solution soln = GetSolutionObject(ViewBag.cid); - UpdateCustomerCardResponse res = this.ServiceClient.Post(new UpdateCustomerCardRequest - { - CustId = cust_id, - Name = name, - Address = address, - City = city, - State = state, - Country = country, - Zip = zip, - SolnId = sid - }); - res.Email = email; - return res; - } - - public Object RemoveCustomerCard(string cust_id, string card_id, string sid) - { - Eb_Solution soln = GetSolutionObject(ViewBag.cid); - RemoveCustomerCardResponse res = this.ServiceClient.Post(new RemoveCustomerCardRequest - { - CustId = cust_id, - CardId = card_id, - SolnId = sid - }); - return res; - } - - public Object EditCardExp(string cust_id, string card_id, int expmonth, int expyear, string sid) - { - Eb_Solution soln = GetSolutionObject(ViewBag.cid); - EditCardExpResponse res = this.ServiceClient.Post(new EditCardExpRequest - { - CustId = cust_id, - CardId = card_id, - ExpMonth = expmonth, - ExpYear = expyear, - SolnId = sid - }); - return res; - } - - public Object ChangeCardSource(string cust_id, string card_id, string sid) - { - Eb_Solution soln = GetSolutionObject(ViewBag.cid); - ChangeCardSourceResponse res = this.ServiceClient.Post(new ChangeCardSourceRequest - { - CustId = cust_id, - CardId = card_id, - SolnId = sid - }); - return res; - } - - public Object GetCustomer(string cust_id, string sid) - { - Eb_Solution soln = GetSolutionObject(ViewBag.cid); - GetCustomerResponse cust = this.ServiceClient.Post(new GetCustomerRequest - { - CustId = cust_id - }); - return cust; - } - - public IActionResult ViewPlans(object ob) - { - GetPlansResponse stripeplans = this.ServiceClient.Post(new GetPlansRequest - { - }); - ViewBag.Count = stripeplans.Plans.Plans.Count; - ViewBag.Plans = stripeplans; - return View(); - } - - } -} \ No newline at end of file diff --git a/Controllers/StripeWebhookController.cs b/Controllers/StripeWebhookController.cs deleted file mode 100644 index 920a63c93..000000000 --- a/Controllers/StripeWebhookController.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using ExpressBase.Web.BaseControllers; -using Microsoft.AspNetCore.Mvc; -using ServiceStack; -using ServiceStack.Redis; -using ExpressBase.Objects.ServiceStack_Artifacts; -using Stripe; -using Microsoft.AspNetCore.Authorization; - -// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 - -namespace ExpressBase.Web.Controllers -{ - public class StripeWebhookController : EbBaseExtController - { - public StripeWebhookController(IServiceClient _ssclient, IRedisClient _redis) : base(_ssclient, _redis) { } - - [HttpPost] - public IActionResult Index() - { - Stripewebhook(); - return View(); - } - - [AllowAnonymous] - [HttpPost] - [Microsoft.AspNetCore.Mvc.Route("Stripewebhook")] - public void Stripewebhook() - { - string json = new StreamReader(HttpContext.Request.Body).ReadToEnd(); - string header = Request.Headers["Stripe-Signature"]; - Console.WriteLine("Web Hook Json in web: " + json); - this.ServiceClient.Post(new StripewebhookRequest - { - Json = json, - Header = header - }); - } - } -} diff --git a/Views/Stripe/CustomerInvoices.cshtml b/Views/Stripe/CustomerInvoices.cshtml deleted file mode 100644 index 5ddc1b7cd..000000000 --- a/Views/Stripe/CustomerInvoices.cshtml +++ /dev/null @@ -1,199 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; -} - - Customer Upcoming Stripe Invoice - - - - - @**@ - - - @**@ - - @**@ - - - -
-
- -
-
-
-

DATE

-
-
-

DESCRIPTION

-
-
-

DEBIT

-
-
-

CREDIT

-
-
-
- @{ - int debt_tot = 0; - int credit_tot = 0; - for (int i = 0; i < ViewBag.UpCount; i++) - { -
-
-

- @ViewBag.StripeUpcomingInvoice.Invoice.Date.ToString("dd MMM,yyyy") -

-
-
-

- (@ViewBag.StripeUpcomingInvoice.Invoice.Data[i].PeriodStart.ToString("dd MMM") - @ViewBag.StripeUpcomingInvoice.Invoice.Data[i].PeriodEnd.ToString("dd MMM,yyyy")) - @ViewBag.StripeUpcomingInvoice.Invoice.Data[i].Description -

-
-
-

-
-
-

$@ViewBag.StripeUpcomingInvoice.Invoice.Data[i].Amount

-
-
- - } - } - - @{ - for (int i = 0; i < ViewBag.Count; i++) - { - if (ViewBag.StripeInvoice.Invoices.List[i].Status) - { -
-
-

- @ViewBag.StripeInvoice.Invoices.List[i].PeriodEnd.ToString("dd MMM,yyyy") -

-
- -
- $@ViewBag.StripeInvoice.Invoices.List[i].Total - @{debt_tot = debt_tot + ViewBag.StripeInvoice.Invoices.List[i].Total; - } -
-
-

-
-
- -
-
-

- @ViewBag.StripeInvoice.Invoices.List[i].PeriodEnd.ToString("dd MMM,yyyy") -

-
-
-

- (@ViewBag.StripeInvoice.Invoices.List[i].PeriodStart.ToString("dd MMM") - @ViewBag.StripeInvoice.Invoices.List[i].PeriodEnd.ToString("dd MMM,yyyy")) - @ViewBag.StripeInvoice.Invoices.List[i].Description -

-
-
- -
-
-

- $@ViewBag.StripeInvoice.Invoices.List[i].Total - @{credit_tot = credit_tot + ViewBag.StripeInvoice.Invoices.List[i].Total; - } -

-
-
- } - else - { -
-
-

- @ViewBag.StripeInvoice.Invoices.List[i].PeriodEnd.ToString("dd MMM,yyyy") -

-
-
-

- (@ViewBag.StripeInvoice.Invoices.List[i].PeriodStart.ToString("dd MMM") - @ViewBag.StripeInvoice.Invoices.List[i].PeriodEnd.ToString("dd MMM,yyyy")) - @ViewBag.StripeInvoice.Invoices.List[i].Description -

-
-
- -
-
-

- $@ViewBag.StripeInvoice.Invoices.List[i].Total - @{credit_tot = credit_tot + ViewBag.StripeInvoice.Invoices.List[i].Total; - } -

-
-
- } - - } - } -
-
-
-

- Total -

-
-
-

- $@debt_tot -

-
-
-

- $@credit_tot -

-
-
-
-
-

- Balance -

-
- @{ - int bal = debt_tot - credit_tot; - string debtbal = ""; - string creditbal = ""; - if (bal < 0) - { - creditbal = "-$" + (-1 * bal); - } - else - { - debtbal = "$" + bal; - } - } -
-

- @debtbal -

-
-
-

- @creditbal -

-
-
-
- \ No newline at end of file diff --git a/Views/Stripe/GetCustomerInvoice.cshtml b/Views/Stripe/GetCustomerInvoice.cshtml deleted file mode 100644 index 30a340fe9..000000000 --- a/Views/Stripe/GetCustomerInvoice.cshtml +++ /dev/null @@ -1,247 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; -} - - Customer Stripe Invoice - - - - - - - - - - -
-
-
-

INVOICES

-
-
- @{ - int x = 0; - - for (int i = 0; i < ViewBag.Count; i++) - { - x = x + ViewBag.StripeInvoice.Invoices.List[i].Total; - } - } -

$@x @ViewBag.StripeInvoice.Invoices.List[0].Currency.ToUpper() on @ViewBag.Month @ViewBag.StripeInvoice.Invoices.List[0].Date.Day,@ViewBag.StripeInvoice.Invoices.List[0].Date.Year

-
-
-
-
-
-

DESCRIPTION

-
-
-

PERIOD

-
-
-

QTY

-
-
-

PRICE

-
-
-

TOTAL

-
-
- -
- @{ - x = 0; - - for (int i = 0; i < ViewBag.Count; i++) - { -
-
-

@ViewBag.StripeInvoice.Invoices.List[i].PlanId

-
-
-

@ViewBag.StripeInvoice.Invoices.List[i].PeriodStart.Day @(((string[])ViewData["MonthStart"])[i]) - @ViewBag.StripeInvoice.Invoices.List[i].PeriodEnd.Day @(((string[])ViewData["MonthEnd"])[i]),@ViewBag.StripeInvoice.Invoices.List[i].PeriodEnd.Year

-
-
-

@ViewBag.StripeInvoice.Invoices.List[i].Quantity

-
-
-

$@ViewBag.StripeInvoice.Invoices.List[i].Amount

-
-
-

$@ViewBag.StripeInvoice.Invoices.List[i].Amount

-
-
- x = x + ViewBag.StripeInvoice.Invoices.List[i].Total; - } - } - -
-
-
-

@ViewBag.StripeInvoice.Invoices.List[0].CouponId (@ViewBag.StripeInvoice.Invoices.List[0].PercentOff%)

-
-
-

-$@((x * ViewBag.StripeInvoice.Invoices.List[0].PercentOff) / 100)

-
-
- -
-
-

Total Amount

-
-
-

$@x

-
-
- -
-
- \ No newline at end of file diff --git a/Views/Stripe/GetCustomerUpcomingInvoice.cshtml b/Views/Stripe/GetCustomerUpcomingInvoice.cshtml deleted file mode 100644 index f6b1679d0..000000000 --- a/Views/Stripe/GetCustomerUpcomingInvoice.cshtml +++ /dev/null @@ -1,225 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; -} - - Customer Upcoming Stripe Invoice - - - - - - - - - - -
-
-
-

UPCOMING INVOICE

-
-
-

$@ViewBag.StripeUpcomingInvoice.Invoice.Total @ViewBag.StripeUpcomingInvoice.Invoice.Currency.ToUpper() on @ViewBag.Month @ViewBag.StripeUpcomingInvoice.Invoice.Date.Day,@ViewBag.StripeUpcomingInvoice.Invoice.Date.Year

-
-
-
-
-
-

DESCRIPTION

-
-
-

QTY

-
-
-

PRICE

-
-
-

TOTAL

-
-
- -
- @{ - int x = 0; - - for (int i = 0; i < ViewBag.Count; i++) - { -
-
-

@ViewBag.StripeUpcomingInvoice.Invoice.Data[i].PlanId

-
-
-

@ViewBag.StripeUpcomingInvoice.Invoice.Data[i].Quantity

-
-
-

$@ViewBag.StripeUpcomingInvoice.Invoice.Data[i].Amount

-
-
-

$@ViewBag.StripeUpcomingInvoice.Invoice.Data[i].Amount

-
-
- x = x + ViewBag.StripeUpcomingInvoice.Invoice.Data[i].Amount; - } - } - -
-
-
-

@ViewBag.StripeUpcomingInvoice.Invoice.CouponId (@ViewBag.StripeUpcomingInvoice.Invoice.PercentOff%)

-
-
-

-$@((x * ViewBag.StripeUpcomingInvoice.Invoice.PercentOff) / 100)

-
-
- -
-
-

Total Amount

-
-
-

$@ViewBag.StripeUpcomingInvoice.Invoice.Total

-
-
- -
-
- \ No newline at end of file diff --git a/Views/Stripe/Index.cshtml b/Views/Stripe/Index.cshtml deleted file mode 100644 index 73de48945..000000000 --- a/Views/Stripe/Index.cshtml +++ /dev/null @@ -1,279 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; -} - - Customer Creation - - - - - - - - - - @{ - if (ViewBag.Status) - { -
-
-
-

UPGRADE

-
-
- You are currently using Free Plan (Free for first 5 users). You can upgrade your plan for having more users, cost $5 for each. -
-
-
- -
-
- - -
- } - else - { -
-
-
-

UPGRADE

-
-
- You are currently using @ViewBag.Plan plan for @ViewBag.Users users per month. You can upgrade your plan for having more users, cost $5 for each. -
-
-
- -
-
- - - } - } - - - \ No newline at end of file diff --git a/Views/Stripe/Payment2.cshtml b/Views/Stripe/Payment2.cshtml deleted file mode 100644 index c229aae8c..000000000 --- a/Views/Stripe/Payment2.cshtml +++ /dev/null @@ -1,286 +0,0 @@ -@*@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; -}*@ - - Customer Creation - - - - - - - -
-
-
- - -
- -
- - - -
-
-
- -
- -
-
-
- -
- -
- -
- - -
- -
-
-            -
- -
- -
-
-
-
-
- -
- -
-
-            -
- -
- -
-
-
-
-
- -
- -
-
-            -
- -
- -
-
-
-
-
- -
-
-
- - \ No newline at end of file diff --git a/Views/Stripe/StripeHome.cshtml b/Views/Stripe/StripeHome.cshtml deleted file mode 100644 index e57e7dfa0..000000000 --- a/Views/Stripe/StripeHome.cshtml +++ /dev/null @@ -1,475 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; -} - - Stripe Home - - - - - @**@ - - @**@ - - - @**@ - - @**@ - - - - -
-
-
-
-
- -
- @{ - if (ViewBag.Status) - { -
-
-
- You are currently using Free Plan (Free for first 5 users). You can upgrade your plan for having more users, cost $5 for each. -
-
-
- } - else - { -
-
-
- You are currently using @ViewBag.Plan plan for @ViewBag.Users users per month. You can upgrade your plan for having more users, cost $5 for each. -
-
-
- - } - } -
-
-
- Upgrade -
-
-
-
-
-
-
-
- -
-
-
- Name -
-
- @ViewBag.Cust.Name -
-
-
-
- Email -
-
- @ViewBag.Cust.Email -
-
-
-
- Address -
-
- @ViewBag.Cust.Address -
-
-
-
- City -
-
- @ViewBag.Cust.City -
-
- State -
-
- @ViewBag.Cust.State -
-
-
-
- Country -
-
- @ViewBag.Cust.Country -
-
- Zip -
-
- @ViewBag.Cust.Zip -
-
-
-
-
- Change -
-
-
-
-
-
-
-
- -
-
-
-
-
- **** **** **** @ViewBag.Card.Last4 -
-
- Exp. (@ViewBag.Card.ExpMonth / @ViewBag.Card.ExpYear) -
-
-
-
-
-
- **** **** **** @ViewBag.Card.Last4 -
-
- Exp. (@ViewBag.Card.ExpMonth / @ViewBag.Card.ExpYear) -
-
-
-
-
-
- **** **** **** @ViewBag.Card.Last4 -
-
- Exp. (@ViewBag.Card.ExpMonth / @ViewBag.Card.ExpYear) -
-
-
-
-
-
-
- Change -
-
-
-
-
- -
- @{ - if (!ViewBag.Status) - { -
-
-
-
- -
-
-
-

DATE

-
-
-

DESCRIPTION

-
-
-

DEBIT

-
-
-

CREDIT

-
-
-
- @{ - int debt_tot = 0; - int credit_tot = 0; - for (int i = 0; i < ViewBag.UpCount; i++) - { -
-
-

- @ViewBag.StripeUpcomingInvoice.Invoice.Date.ToString("dd MMM,yyyy") -

-
-
-

- (@ViewBag.StripeUpcomingInvoice.Invoice.Data[i].PeriodStart.ToString("dd MMM") - @ViewBag.StripeUpcomingInvoice.Invoice.Data[i].PeriodEnd.ToString("dd MMM,yyyy")) - @ViewBag.StripeUpcomingInvoice.Invoice.Data[i].Description -

-
-
-

-
-
-

$@ViewBag.StripeUpcomingInvoice.Invoice.Data[i].Amount

-
-
- - } - } - - @{ - for (int i = 0; i < ViewBag.Count; i++) - { - if (ViewBag.StripeInvoice.Invoices.List[i].Status) - { -
-
-

- @ViewBag.StripeInvoice.Invoices.List[i].PeriodEnd.ToString("dd MMM,yyyy") -

-
- -
- $@ViewBag.StripeInvoice.Invoices.List[i].Total - @{debt_tot = debt_tot + ViewBag.StripeInvoice.Invoices.List[i].Total; - } -
-
-

-
-
- -
-
-

- @ViewBag.StripeInvoice.Invoices.List[i].PeriodEnd.ToString("dd MMM,yyyy") -

-
-
-

- (@ViewBag.StripeInvoice.Invoices.List[i].PeriodStart.ToString("dd MMM") - @ViewBag.StripeInvoice.Invoices.List[i].PeriodEnd.ToString("dd MMM,yyyy")) - @ViewBag.StripeInvoice.Invoices.List[i].Description -

-
-
- -
-
-

- $@ViewBag.StripeInvoice.Invoices.List[i].Total - @{credit_tot = credit_tot + ViewBag.StripeInvoice.Invoices.List[i].Total; - } -

-
-
- } - else - { -
-
-

- @ViewBag.StripeInvoice.Invoices.List[i].PeriodEnd.ToString("dd MMM,yyyy") -

-
-
-

- (@ViewBag.StripeInvoice.Invoices.List[i].PeriodStart.ToString("dd MMM") - @ViewBag.StripeInvoice.Invoices.List[i].PeriodEnd.ToString("dd MMM,yyyy")) - @ViewBag.StripeInvoice.Invoices.List[i].Description -

-
-
- -
-
-

- $@ViewBag.StripeInvoice.Invoices.List[i].Total - @{credit_tot = credit_tot + ViewBag.StripeInvoice.Invoices.List[i].Total; - } -

-
-
- } - - } - } -
-
-
-

- Total -

-
-
-

- $@debt_tot -

-
-
-

- $@credit_tot -

-
-
-
-
-

- Balance -

-
- @{ - int bal = debt_tot - credit_tot; - string debtbal = ""; - string creditbal = ""; - if (bal < 0) - { - creditbal = "-$" + (-1 * bal); - } - else - { - debtbal = "$" + bal; - } - } -
-

- @debtbal -

-
-
-

- @creditbal -

-
-
-
-
-
- } - } -
- \ No newline at end of file diff --git a/Views/Stripe/SubscribedView.cshtml b/Views/Stripe/SubscribedView.cshtml deleted file mode 100644 index bb7476adf..000000000 --- a/Views/Stripe/SubscribedView.cshtml +++ /dev/null @@ -1,46 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; -} - - Customer Stripe Invoice - - - - - - - - -
-
- -
-
- SUBSCRIBED SUCCESSFULLY -
-
- You have successfully subscribed to @ViewBag.SubscribeObjects.Plan on @ViewBag.SubscribeObjects.Created.ToString("dd MMM,yyyy") -
-
-
-
- Amount per Users -
-
- $@(ViewBag.SubscribeObjects.Amount / 100) -
-
-
-
- Total Amount -
-
- $@(ViewBag.SubscribeObjects.Amount / 100 * ViewBag.SubscribeObjects.Quantity) ($@(ViewBag.SubscribeObjects.Amount / 100) * @ViewBag.SubscribeObjects.Quantity Users) -
-
-
- -
- diff --git a/Views/Stripe/UpdateCustomerSubscription.cshtml b/Views/Stripe/UpdateCustomerSubscription.cshtml deleted file mode 100644 index 3aa609f07..000000000 --- a/Views/Stripe/UpdateCustomerSubscription.cshtml +++ /dev/null @@ -1,105 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; -} - - Customer Upcoming Stripe Invoice - - - - - - - - - - - -
-
-
- -
- -
-
-
- (Free for 5 Users) - -
-
- -
-
-
- \ No newline at end of file diff --git a/Views/Stripe/ViewPlans.cshtml b/Views/Stripe/ViewPlans.cshtml deleted file mode 100644 index 17a55ceff..000000000 --- a/Views/Stripe/ViewPlans.cshtml +++ /dev/null @@ -1,106 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; -} - - Stripe Plans - - - - - - - - - -
-
-
-

PLANS

-
-
-
- @{ - for (int i = 0; i < ViewBag.Count; i++) - { - int x = (ViewBag.Plans.Plans.Plans[i].Amount / 100); - int v = (x / 20) + 5; -
-
-
@ViewBag.Plans.Plans.Plans[i].Id
-

$@(ViewBag.Plans.Plans.Plans[i].Amount / 100) @ViewBag.Plans.Plans.Plans[i].Currency.ToUpper() for @v Users

-

For @ViewBag.Plans.Plans.Plans[i].Interval_count @ViewBag.Plans.Plans.Plans[i].Interval

- Buy -
-
- ///Stripe/Index?id=@ViewBag.Plans.Plans.Plans[i].Id - x = 0; - } - } -
-
- - From 619e515528c69e33e6a4fc3ac5cb4c764036e785 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Tue, 14 Oct 2025 17:17:20 +0530 Subject: [PATCH 22/58] Removed Wiki --- Controllers/PublicWikiController.cs | 118 --- Controllers/WikiController.cs | 230 ----- Views/PublicWiki/GetArticleById.cshtml | 94 -- Views/PublicWiki/GetWikiList.cshtml | 280 ------ Views/Wiki/AddWiki.cshtml | 446 ---------- Views/Wiki/WikiAdd.cshtml | 366 -------- Views/Wiki/WikiAdmin.cshtml | 95 -- Views/Wiki/wiki.cshtml | 69 -- wwwroot/css/EbWiki/eb_wiki.css | 1017 ---------------------- wwwroot/css/EbWiki/tagsinput.css | 73 -- wwwroot/css/EbWiki/themes/3024-night.css | 109 --- wwwroot/js/wiki/AddWiki.js | 915 ------------------- wwwroot/js/wiki/eb_wiki.js | 1004 --------------------- wwwroot/js/wiki/run_prettify.js | 1 - wwwroot/js/wiki/tagsinput.js | 684 --------------- 15 files changed, 5501 deletions(-) delete mode 100644 Controllers/PublicWikiController.cs delete mode 100644 Controllers/WikiController.cs delete mode 100644 Views/PublicWiki/GetArticleById.cshtml delete mode 100644 Views/PublicWiki/GetWikiList.cshtml delete mode 100644 Views/Wiki/AddWiki.cshtml delete mode 100644 Views/Wiki/WikiAdd.cshtml delete mode 100644 Views/Wiki/WikiAdmin.cshtml delete mode 100644 Views/Wiki/wiki.cshtml delete mode 100644 wwwroot/css/EbWiki/eb_wiki.css delete mode 100644 wwwroot/css/EbWiki/tagsinput.css delete mode 100644 wwwroot/css/EbWiki/themes/3024-night.css delete mode 100644 wwwroot/js/wiki/AddWiki.js delete mode 100644 wwwroot/js/wiki/eb_wiki.js delete mode 100644 wwwroot/js/wiki/run_prettify.js delete mode 100644 wwwroot/js/wiki/tagsinput.js diff --git a/Controllers/PublicWikiController.cs b/Controllers/PublicWikiController.cs deleted file mode 100644 index 93b1c17af..000000000 --- a/Controllers/PublicWikiController.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ExpressBase.Common; -using ExpressBase.Common.Constants; -using ExpressBase.Objects.ServiceStack_Artifacts; -using ExpressBase.Web.BaseControllers; -using Microsoft.AspNetCore.Mvc; -using ServiceStack; -using ServiceStack.Redis; -namespace ExpressBase.Web.Controllers -{ - public class PublicWikiController : EbBaseExtController - { - public PublicWikiController(IServiceClient _ssclient, IRedisClient _redis) : base(_ssclient, _redis) - { - } - - [HttpPost] - public object GetWiki(string wiki_id) - { - GetWikiResponse resp = this.ServiceClient.Get(new GetWikiRequest() - { - Id = Convert.ToInt32(wiki_id) - }); - return resp.Wiki; - } - - - [HttpGet("/Wiki")] - public IActionResult GetWikiList() - { - GetWikiListResponse resp = this.ServiceClient.Get(new GetWikiListRequest()); - Console.WriteLine("Info: GetWikiList Wiki Count: " + resp.WikiList.Count); - ViewBag.WikiList = resp.WikiList; - ViewBag.WikiCat = resp.WikiCat; - - var host = base.HttpContext.Request.Host.Host.Replace(RoutingConstants.WWWDOT, string.Empty); - string[] hostParts = host.Split(CharConstants.DOT); - string sBToken = base.HttpContext.Request.Cookies[RoutingConstants.BEARER_TOKEN]; - string sRToken = base.HttpContext.Request.Cookies[RoutingConstants.REFRESH_TOKEN]; - if (!String.IsNullOrEmpty(sBToken) || !String.IsNullOrEmpty(sRToken)) - { - if (IsTokensValid(sRToken, sBToken, hostParts[0])) - ViewBag.isLogedIn = true; - else - ViewBag.isLogedIn = false; - } - else - { - ViewBag.isLogedIn = false; - } - return View(); - } - - [HttpGet("/Wiki/{id}")] - public IActionResult GetWikiListRedirect1(string id) - { - return Redirect("/Wiki"); - } - - [HttpGet("/Wiki/{category}/{wikiname}")] - public IActionResult GetWikiListRedirect2(string category, string wikiname) - { - TempData["Category"] = category; - TempData["WikiName"] = wikiname; - return Redirect("/Wiki"); - } - - [HttpGet("/Wiki/{category}/{id}/{title}")] - public IActionResult GetArticleById(string id) - { - GetWikiByIdResponse resp = this.ServiceClient.Get(new GetWikiByIdRequest() - { - Id = Convert.ToInt32(id) - }); - - ViewBag.Wiki = resp.Wiki; - var location = new Uri($"{Request.Scheme}s://{Request.Host}{Request.Path}{Request.QueryString}"); - ViewBag.Url = location.AbsoluteUri; - object TagObject; - TagObject = resp.Wiki.Tags.Split(','); - ViewBag.TagObject = TagObject; - ViewBag.Title = resp.Wiki.Title + " | EXPRESSbase Systems"; - return View(); - } - - - public object GetWikiBySearch(string search_wiki) - { - GetWikiBySearchResponse resp = this.ServiceClient.Get(new GetWikiBySearchRequest() - { - Wiki_Search = search_wiki - }); - return resp.WikiListBySearch; - } - - public IActionResult WikiLayout() - { - return View(); - } - public IActionResult Edit() - { - return View(); - } - //public bool UserReviewRate(string userreview) - //{ - // UserReviewRateResponse = new UserReviewRateRequest() - // { - // UserReview = Convert.ToInt32(userreview); - // } - //} - - - } -} diff --git a/Controllers/WikiController.cs b/Controllers/WikiController.cs deleted file mode 100644 index 522187f78..000000000 --- a/Controllers/WikiController.cs +++ /dev/null @@ -1,230 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ExpressBase.Objects.ServiceStack_Artifacts; -using ExpressBase.Web.BaseControllers; -using Microsoft.AspNetCore.Mvc; -using Newtonsoft.Json; -using ServiceStack; -using ServiceStack.Redis; -namespace ExpressBase.Web.Controllers -{ - public class WikiController : EbBaseIntAdminController - { - public WikiController(IServiceClient sclient, IRedisClient redis) : base(sclient, redis) { } - - [HttpGet("wiki/add/{id}")] - public IActionResult AddWiki(int id) - - { - FileRefByContextResponse res = this.ServiceClient.Get(new FileRefByContextRequest - { - Context = "eb_wiki" - }); - - ViewBag.Images = JsonConvert.SerializeObject(res.Images); - - ViewBag.id = id; - if (id > 0) - { - GetWikiByIdResponse resp = this.ServiceClient.Get(new GetWikiByIdRequest() - { - Id = Convert.ToInt32(id) - }); - if (resp == null) - return Redirect("0"); - else - ViewBag.Wiki = resp.Wiki; - ViewBag.WikiCat = resp.WikiCat; - } - else - { - AddNewWikiResponse resp = this.ServiceClient.Get(new AddNewWikiRequest()); - ViewBag.WikiCat = resp.WikiCat; - ViewBag.Wiki = new Wiki() { Id = 0 ,CatId = 0}; - } - return View(); - } - - [HttpGet("add/wiki/{id}")] - public IActionResult WikiAdd(int id) - - { - FileRefByContextResponse res = this.ServiceClient.Get(new FileRefByContextRequest - { - Context = "eb_wiki" - }); - - ViewBag.Images = JsonConvert.SerializeObject(res.Images); - - ViewBag.id = id; - if (id > 0) - { - GetWikiByIdResponse resp = this.ServiceClient.Get(new GetWikiByIdRequest() - { - Id = Convert.ToInt32(id) - }); - if (resp == null) - return Redirect("0"); - else - ViewBag.Wiki = resp.Wiki; - ViewBag.WikiCat = resp.WikiCat; - } - else - { - AddNewWikiResponse resp = this.ServiceClient.Get(new AddNewWikiRequest()); - ViewBag.WikiCat = resp.WikiCat; - ViewBag.Wiki = new Wiki() { Id = 0, CatId = 0 }; - } - return View(); - } - - - - //[HttpGet("/apitest")] - //public IActionResult Test() - //{ - // this.ServiceClient.BearerToken = "HxSLXUHuM5X_pZDW_0_SvbpupByEIlCw"; - // ServiceClient.Get(new ApiTestReq()); - - // return Redirect("/statuscode/404"); ; - //} - - - //[HttpGet("wiki/add/{}")] - //public IActionResult EditWiki(string id) - //{ - // GetWikiByIdResponse resp = this.ServiceClient.Get(new GetWikiByIdRequest() - // { - // Wiki = new Wiki() - // { - // Id = Convert.ToInt32(id) - // } - // }); - - // ViewBag.Wiki = resp.Wiki; - // return View(); - //} - - [HttpPost("wiki/save")] - public object SaveWiki(Wiki wiki) - { - int id = wiki.Id ; - if (id > 0) - { - UpdateWikiResponse resp = this.ServiceClient.Post(new UpdateWikiRequest - { - Wiki = new Wiki - { - Category = wiki.Category, - Title = wiki.Title, - HTML = wiki.HTML, - CreatedBy = ViewBag.UId, - Tags = wiki.Tags, - Status = wiki.Status, - CatId = wiki.CatId, - Id = id - } - }); - - return resp; - } - else - { - PersistWikiResponse resp = this.ServiceClient.Post(new PersistWikiRequest - { - Wiki = new Wiki - { - Category = wiki.Category, - Title = wiki.Title, - HTML = wiki.HTML, - CreatedBy = ViewBag.UId, - Tags = wiki.Tags, - Status = wiki.Status, - CatId = wiki.CatId, - } - - }); - return resp; - } - } - - - [HttpGet("wiki/admin")] - public IActionResult WikiAdmin() - { - //WikiAdminResponse resp = this.ServiceClient.Get(new WikiAdminRequest()); - - //Console.WriteLine("Info: WikiAdmin Wiki Count: " + resp.WikiList.Count); - - //ViewBag.WikiList = resp.WikiList; - var location = new Uri($"{Request.Scheme}s://{Request.Host}"); - ViewBag.Url = location.AbsoluteUri +"wiki/add/0"; - ViewBag.Title = "Manage Wikies"; - return View(); - - } - - - public object Admin_Wiki_list(string status) - { - Admin_Wiki_ListResponse resp = this.ServiceClient.Get(new Admin_Wiki_ListRequest() - { - Status = status - }); - - Console.WriteLine("Info: Admin_Wiki_list Wiki Count: " + resp.WikiList.Count + " Status: " + status); - - return resp; - - } - - public object Publish_wiki(int wiki_id, string wiki_status) - { - if (wiki_status == "Draft" || wiki_status == "Unpublish") - { - Publish_wikiResponse resp = this.ServiceClient.Post(new Publish_wikiRequest() - { - Wiki_id = wiki_id, - Status = "Publish" - }); - return resp; - } - else - { - Publish_wikiResponse resp = this.ServiceClient.Post(new Publish_wikiRequest() - { - Wiki_id = wiki_id, - Status = "Unpublish" - }); - return resp; - } - } - - - public object PublicView() - { - PublicViewResponse resp = this.ServiceClient.Get(new PublicViewRequest()); - - Console.WriteLine("Info: PublicView Wiki Count: " + resp.WikiList.Count); - return resp; - - } - - public bool UpdateOrder(string myList) - { - - UpdateOrderResponse resp = this.ServiceClient.Post(new UpdateOrderRequest() - { - Wiki_id = myList, - }); - - - return resp.ResponseStatus; - } - - - } -} \ No newline at end of file diff --git a/Views/PublicWiki/GetArticleById.cshtml b/Views/PublicWiki/GetArticleById.cshtml deleted file mode 100644 index 418c61a7b..000000000 --- a/Views/PublicWiki/GetArticleById.cshtml +++ /dev/null @@ -1,94 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutExternal.cshtml"; - -} -@Html.Raw(new System.Net.WebClient().DownloadString("https://expressbase.com/GetHeader/" + ViewBag.Env)) -@using ExpressBase.Objects.ServiceStack_Artifacts; - - - - -@section StyleSheet{ - @**@ - @* - - - - - - - - - - - - - - - *@ - - - - - - - - - - @foreach (Object ob in ViewBag.TagObject) - { - - } - - - - - - - - - - - - - -} - -
-
-
- @{ - Wiki wiki = ViewBag.Wiki; - - @Html.Raw(wiki.HTML) - } -
- -
-
diff --git a/Views/PublicWiki/GetWikiList.cshtml b/Views/PublicWiki/GetWikiList.cshtml deleted file mode 100644 index 62681aac6..000000000 --- a/Views/PublicWiki/GetWikiList.cshtml +++ /dev/null @@ -1,280 +0,0 @@ -@using ExpressBase.Objects.ServiceStack_Artifacts; -@{ - Layout = "~/Views/Shared/LayoutExternal.cshtml"; -} -@section StyleSheet{ - - - - - - - - - - - - - -} - -@section JavaScript{ - - -} - -@Html.Raw(new System.Net.WebClient().DownloadString("https://expressbase.com/GetHeader/" + ViewBag.Env)) -@if (ViewBag.isLogedIn) -{ - -} - - - - -
- - - -
-
- -
-
- -
- -
-
-
-
- -
-
-
- -
-
-
- - - -
- -
- - - -
-
- -
-

Welcome to ExpressBase!

-

Get familiar with the ExpressBase products and explore their features:

- - - - @for (var i = 0; i < ViewBag.WikiCat.Count; i = i + 2) - { - string WikiCategory = ViewBag.WikiCat[i].WikiCategory; - string WikiIconClass = ViewBag.WikiCat[i].WikiIconClass; - string WikiDescription = ViewBag.WikiCat[i].WikiDescription; - string WikiCategory1 = ""; - string WikiIconClass1 = ""; - string WikiDescription1 = ""; - if ((i + 1) < ViewBag.WikiCat.Count) - { - WikiCategory1 = ViewBag.WikiCat[i + 1].WikiCategory; - WikiIconClass1 = ViewBag.WikiCat[i + 1].WikiIconClass; - WikiDescription1 = ViewBag.WikiCat[i + 1].WikiDescription; - } - -
-
-
-
-
@WikiCategory
-
@WikiDescription
-
-
- @if (WikiCategory1 != "") - { -
-
-
-
@WikiCategory1
-
@WikiDescription1
-
-
} -
- } -
-
-
-
-
- -
- -
- - -
- -@section JsCode{ - -} - - - - diff --git a/Views/Wiki/AddWiki.cshtml b/Views/Wiki/AddWiki.cshtml deleted file mode 100644 index ae69c1982..000000000 --- a/Views/Wiki/AddWiki.cshtml +++ /dev/null @@ -1,446 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; - //Html.RenderPartial("ExtPageHeader"); -} -@using ExpressBase.Common; -@using ExpressBase.Objects.ServiceStack_Artifacts; - -@*icon*@ - - - -@**@ - - - - - - - - - - - - - - - - -
-
-
- -
- - -
-
-
- - - - -
-
-
- - -
-
- -
-
- -
-
-
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - @**@ - @**@ -
-
-
- -
- -
-
-
-
-
-
-
- -
- -
-
-
- -
-
- -
-
- -
-
-
-
- - - - - -
- -
- -
-
- - - - - - - - - - - - - \ No newline at end of file diff --git a/Views/Wiki/WikiAdd.cshtml b/Views/Wiki/WikiAdd.cshtml deleted file mode 100644 index 275f33ae1..000000000 --- a/Views/Wiki/WikiAdd.cshtml +++ /dev/null @@ -1,366 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; - //Html.RenderPartial("ExtPageHeader"); -} -@using ExpressBase.Common; -@using ExpressBase.Objects.ServiceStack_Artifacts; - -@*icon*@ - - -@**@ - -@**@ - - - - - - - - - - - - - - - - - -
-
-
- -
- - -
-
-
- - - - -
-
-
- - -
-
- -
-
- -
-
-
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - @**@ - @**@ -
-
-
- -
- -
-
-
- -
-
-
- -
-
- -
-
- -
-
-
-
- - - - - -
- -
- -
-
- - - - - - diff --git a/Views/Wiki/WikiAdmin.cshtml b/Views/Wiki/WikiAdmin.cshtml deleted file mode 100644 index 2e475fe8b..000000000 --- a/Views/Wiki/WikiAdmin.cshtml +++ /dev/null @@ -1,95 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; - //Html.RenderPartial("ExtPageHeader"); -} -@using ExpressBase.Objects.ServiceStack_Artifacts; - - - - - - - -
- @**@ -
-
-
-

Wiki Admin

-
-
- Add Wiki -
-
-
-
- - -
-
- @*
-
-

Drafts

-

Published

-

UnPublished

-

Ordering

- -
-
*@ -
- -
-
-
- -
-
-
-
-
-
- - - - diff --git a/Views/Wiki/wiki.cshtml b/Views/Wiki/wiki.cshtml deleted file mode 100644 index 6a14289a3..000000000 --- a/Views/Wiki/wiki.cshtml +++ /dev/null @@ -1,69 +0,0 @@ -@{ - Layout = "~/Views/Shared/LayoutInner.cshtml"; - Html.RenderPartial("ExtPageHeader"); -} -@using ExpressBase.Objects.ServiceStack_Artifacts; - - - - -
-

-

Some text..

-
-

- Title : - -

- -

Sub Title :

-

Content :

-

Upload Image :

-

Codes :

- -
-
diff --git a/wwwroot/css/EbWiki/eb_wiki.css b/wwwroot/css/EbWiki/eb_wiki.css deleted file mode 100644 index 77923c19b..000000000 --- a/wwwroot/css/EbWiki/eb_wiki.css +++ /dev/null @@ -1,1017 +0,0 @@ - -/*new style*/ - - -.pd-0{ - padding:0; -} -.eb-wiki-sidebar { - position: fixed; - height: 100vh; - padding-top: 60px; -} - -.eb-wiki-pane { - margin-left: auto; - padding-top: 60px; -} - -.eb-wiki-sidebar .sidebar { - border-right: 1px solid #ccc; - line-height: 2em; - padding-top: 20px; - overflow-y: auto; - padding-bottom:20px; -} - -.sidebar-item-wraper { -} - - .sidebar-item-wraper .sidebar-item { - padding: 4px 4px 4px 10px; - cursor: default; - } - - .sidebar-item-wraper .sidebar-item .i-con { - font-size: 17px; - width:25px; - } - - .sidebar-item-wraper .sidebar-item .text { - - } -.sidebar-item:hover{ - cursor:pointer; -} -.eb-wiki-sidebar .sidebar-list-wraper { -} -.eb-wiki-sidebar .wraper-link { - font-size: 15px; - font-weight: 500; - color: #333; -} - .eb-wiki-sidebar .wraper-link:hover { - background: #e8e8e8; - } -.eb-wiki-sidebar .sidebar-list-wraper ul { - list-style: none; -} -.eb-wiki-sidebar .sidebar-list-wraper ul li{ - cursor:pointer; -} - .eb-wiki-sidebar .sidebar-list-wraper ul li:hover a { - color: #4d86d6; - text-decoration:none; - } -.eb-wiki-sidebar .sidebar-list-wraper .wikilist { - color: #2b2b2b; - font-weight: 400; -} -.eb-wiki-sidebar .sidebar-list-wraper .CurrentSelection { - color: #2b2b2b; - font-weight: 500; -} - -.eb-wiki-pane .eb-wiki-pane-inner { - display:flex; - flex-flow:column; -} -.eb-wiki-pane .eb-wiki-pane-header { - background-color: #f2f2f2; - border-bottom: 1px solid #d2d2d2; - display: flex; - padding: 20px; - align-items: center; - justify-content: space-between; -} -.eb-wiki-pane-brdcrmb { - font-size: 18px; - font-weight: 400; -} - .eb-wiki-pane-brdcrmb .slash { - margin: 0 5PX; - color: #8c8989; - } -.eb-wiki-pane .eb-wiki-pane-inner .eb-wiki-searchbox { - display: flex; - align-items: center; - width:300px; -} - .eb-wiki-pane .eb-wiki-pane-inner .eb-wiki-searchbox input { - width: 100%; - height: 40px; - padding-left: 35px; - } - .eb-wiki-pane .eb-wiki-pane-inner .eb-wiki-searchbox:after { - content: "\f002"; - font-family: FontAwesome; - position: absolute; - margin-left: 10px; - } -.eb-wiki-pane .eb-wiki-contentdynamic { - padding: 20px; - text-align: justify; -} -.eb-wiki-pane h1 { - font-size: 31px; - font-weight: 400; - margin-top: 0; - margin-bottom: 15px; -} -.eb-wiki-pane h3 { - font-size: 22px; - font-weight: 400; - margin-top: 20px; - margin-bottom: 15px; -} -.eb-wiki-pane p { - font-size: 15px; - line-height: 1.8em; - text-align: justify; -} -.eb-wiki-pane .SearchWithTag { - background: #dcf0ff; - border: 1px solid #dcf0ff; - /* background: linear-gradient(to right,#eef9fe,#edf7ff); */ - border-radius: 4px; - padding: 3px 10px; - margin: 10px 3px; -} -.eb-wiki-pane .WasItHelp { - background: white; - border: 1px solid #4987fb; - margin: 0 5px; - border-radius: 4px; - font-size: 12px; - font-weight: 500; - color: #4987fb; - padding: 2px 5px; - line-height: 1.5; -} -.eb-wiki-pane .wiki_data { - font-size: 15px; - line-height: 1.8em; -} -.eb-wiki-pane pre.prettyprint { - padding: 10px; - border: 1px solid #e2e2e2; - background: #f1f5f9; - margin-bottom:20px; -} -/*new style end*/ -.wiki_data_div { - color: #2b2b2b; - font-family: Montserrat; - text-align: justify; - font-weight: 400; - padding: 0% 10% 0% 10%; -} -.wiki_data_div h1 { - font-size: 32px; - font-weight: 400; - margin-top: 0; - margin-bottom: 15px; -} -.wiki_data_div p{ - font-size: 15px; - line-height: 1.8em; -} -.wiki_data_div a{ - font-size: 15px; - line-height: 1.8em; -} -.wiki_data_div li{ - font-size: 15px; - line-height: 1.8em; -} -.wiki_data_div h2 { - font-size: 27px; - font-weight: 400; - margin-top: 20px; - margin-bottom: 15px; -} -.wiki_data_div h3 { - font-size: 22px; - font-weight: 400; - margin-top: 20px; - margin-bottom: 15px; -} -.wiki_data_div img { - max-height : 300px; -} - .wiki_data_div iframe { - min-height: 315px; - min-width: 560px; - margin-left: 25%; - } - -div.searchDiv { - width: 100%; - height: 80px; - overflow: hidden; - border-bottom: solid 1px #bfbfbf; - margin: 5px 0; - margin-bottom: 10px; - flex-flow: column; - display: flex; - line-height: 1.8em; -} - - div.searchDiv center { - text-align: left; - } - - div.searchDiv h1 { - display: none; - } - - div.searchDiv p { - font-size: 15px; - line-height: 1.8em; - } - - div.searchDiv a { - font-size: 20px; - cursor:pointer; - } - div.searchDiv a:hover { - text-decoration:none; - } - -div.searchDiv iframe{ - display:none; -} - -.block { - position: fixed; - background: #f4f4f4; - padding: 0px; - width: 876px; - overflow: auto; -} - -.input-group { - width: 301px; - height: 31px; - position: relative; - margin-left: 62px; -} - - .input-group input { - height: 35px; - box-shadow: none; - border-right: 0; - border-color: #508cf9; - } - - -.ButtonBox input, .ButtonBox button { - background: #fff; - border-right: solid 1px #9a9a9a; - border-top: solid 0px #9a9a9a; - border-left: solid 0px #9a9a9a; - border-bottom: solid 0px #9a9a9a; - width: 100%; -} - - .ButtonBox input:hover { - background-color: #d3e5ff; - } - - .ButtonBox input:active { - background-color: cornflowerblue; - } - .ButtonBox input:last-child { - border-right: 0px solid; - border-top-right-radius: 4px; - } - .ButtonBox input:first-child { - border-top-left-radius: 4px; - } - - - -iframe { - width: 470px; - height: 315px; -} - -.img { - width: 470px; - height: 315px; -} - -.style-4::-webkit-scrollbar-track { - -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); - background-color: #F5F5F5; -} - -.style-4::-webkit-scrollbar { - width: 10px; - background-color: #F5F5F5; -} - -.style-4::-webkit-scrollbar-thumb { - background-color: lightgrey #557aff; -} -.animation { - -webkit-transition-property: font-size; /* Safari */ - -webkit-transition-duration: .2s; /* Safari */ - -webkit-transition-delay: .1s; - transition-timing-function: linear; - font-size: 19px; - color: #23527c; - text-decoration: none; -} - -.GettingStartedWrapper { - display: flex; - width: 85%; -} - - - .GettingStarted { - display: flex; - height: 80px; - border-radius: 10px; - border: solid 1px #d2d2d2; - width: 48%; - margin: 5px 15px 15px 5px; - } - .GettingStarted .divIcon { - width: 56px; - font-size: 35px; - padding: 16px 10px 15px 10px; - color: #7f7f80; - } - .GettingStarted .h1Wrap { - font-size: 14px; - font-weight:500; - padding: 10px 0px 0px 10px; - } - .GettingStarted .PWrap { - padding: 1px 5px 5px 10px; - font-size: 13px; - } - .GettingStarted:hover { - cursor:pointer; - -webkit-box-shadow: 1px 0px 5px 1px rgba(158,158,158,0.4); - -moz-box-shadow: 1px 0px 5px 1px rgba(158,158,158,0.4); - box-shadow: 1px 0px 5px 1px rgba(158,158,158,0.4); - } - - - /*share links*/ - .icon-bar { - font-size: 20px; - padding: 4px; - } - - -/*wiki add*/ - -#btnUploadImg { - border: solid 1px #fff; - border-radius: 4px; - color: #fff; - font-size: 12px; - padding: 2px 15px 2px 15px; - background: #1573ff; -} - -.wiki-preview { - color: #2b2b2b; - text-align: justify; - padding: 0% 10% 0% 10%; -} - .wiki-preview .render { - - } - - .wiki-preview .render h1 { - font-size: 31px; - font-weight: 300; - margin-top: 0; - margin-bottom: 15px; - } - .wiki-preview .render h3 { - font-size: 22px; - font-weight: 300; - margin-top: 20px; - margin-bottom: 15px; - } - - .wiki-preview .render p { - font-weight:300; - font-size: 15px; - line-height: 1.8em; - text-align: justify; - } - - .wiki-preview .render pre.prettyprint { - padding: 10px; - border: 1px solid #e2e2e2; - background: #f1f5f9; - margin-bottom: 20px; - } - - - .wiki-preview .render a { - font-size: 15px; - line-height: 1.8em; - } - - .wiki-preview .render li { - font-size: 15px; - line-height: 1.8em; - } - - .wiki-preview .render h2 { - font-size: 27px; - font-weight: 400; - margin-top: 20px; - margin-bottom: 15px; - } - - .wiki-preview .render h3 { - font-size: 22px; - font-weight: 400; - margin-top: 20px; - margin-bottom: 15px; - } - - .wiki-preview .render img { - max-height: 300px; - } - - .wiki-preview .render iframe { - min-height: 315px; - min-width: 560px; - margin-left: 25%; - } - - - - .manage-wiki-nav { - display: flex; - width: 100%; - flex-flow: column; - } - .public h1 { - font-size: 18px; - padding: 0px; - margin-bottom: 0px; - margin-top: 0px; - text-align: left; - font-weight: 200; - } - - -.form-control { - width: 120px; -} - -.popover { - max-width: 400px; -} - -#popover-content-logout > * { - background-color: #ff0000 !important; -} - - -.dragable_wiki_list { - list-style-type: none; - margin: 0; - padding: 0; - margin-left: 7%; -} -.dragable_wiki_list:last-child{ - margin-bottom:10px; -} - .dragable_wiki_list li { - cursor: move; - margin: 0 0px 2px 0px; - padding: 0.2em; - padding-left: 1.5em; - font-size: 12px; - font-weight: 400; - height: 23px; - width: 92%; - border-radius: 2px; - } - .dragable_wiki_list li:hover { - color: black; - background: #508bf9; - } - .dragable_wiki_list li:active { - color: #fff; - background: #508bf9; - } - - .dragable_wiki_list li span { - position: center; - margin-left: -1.3em; - } - -#layout_div { - background-color: white; -} - -.WikiMenu { - font-size: 16px; - line-height: 30px; - color: #5f6c7d; - font-weight: 400; - padding-left: 2em; - margin-bottom: 10px; - border-top-right-radius: 4px; - border-top-left-radius: 4px; - border-bottom: solid 1px #eee; -} - .WikiMenu i { - font-size: 14px; - } -.BoxView { - width: 31%; - border: solid 1px #ccc; - margin: 15px 15px 0px 0px; - border-radius: 4px; - -webkit-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.17); - -moz-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.17); - box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.17); -} - -.WikiList { - width: auto; - margin-left: 7%; - margin-right: 7%; - border-radius: 4px; - margin-bottom: 10px; - border: solid 1px #d4d4d4; - padding: 6px; -} - .WikiList h1 { - font-size: 18px; - padding: 0px; - margin-bottom: 0px; - margin-top: 0px; - text-align: left; - font-weight: 200; - } - .WikiList p { - font-size: 12px; - padding: 0px; - margin-bottom: 0px; - margin-top: 0px; - text-align: left; - font-weight: 200; - } - .WikiList:hover { - cursor:pointer; - -webkit-box-shadow: 1px 1px 3px 0px rgba(0,0,0,0.13); - -moz-box-shadow: 1px 1px 3px 0px rgba(0,0,0,0.13); - box-shadow: 1px 1px 3px 0px rgba(0,0,0,0.13); - } - .wikilist:active { - background-color: #f5f5f5; - } -.UpdateOrder { - width: 133px; - height: 25px; - font-size: 14px; - color: white; - background: #508bf9; - border: 0px; - margin: 1% 1% 1% 43%; - border-radius: 4px; -} - - - -.wiki_btn:hover { - border: 0px; -} - - -/*ADmin Wiki*/ -.wiki_admin { - font-size: 30px; - margin-top: 20px; - margin-bottom: 10px; - color: #5f6c7d; - font-size: 35px; - font-weight: 300; -} -.menu_border { - font-weight: bold; -} -.search-box-fab{ - position:absolute; -} - .search-box-fab .fab-icon { - - } -.NextPreWiki { - background: #ffffff; - border: 1px solid #adadad; - border-radius: 4px; - padding: 3px 10px; - margin: 0px 3px 15px 0px; - width: 100px; - text-align: center; - cursor: pointer; -} - .NextPreWiki:hover { - background: #dcf0ff; - - } - .NextPreWiki:active { - background-color: white; - } -.GrpAddSel { - width: 100%; - padding: 1px; - border-radius: 4px; - border: solid 1px #bfbfbf; - font-size: 13px; - outline: none; - padding-left: 7px; -} -.btnGrp2 { - margin: 10px; - font-size: 12px; - font-weight: 500; - width: 20%; - height: 25px; - padding: 2px; - margin-right: 10px; - border: solid 1px #cecece; - background: #efefef; - border-radius: 4px; - outline: none; -} - - .btnGrp2:hover { - background-color: #8AB6F7 - } - - .btnGrp2:active { - background-color: cornflowerblue; - } - -.WikiDefaultImage { - height: 400px; - align-items: center; - border-radius :2px; -} - -.readtext { - caret-color: black; - color: transparent; - outline: none; - border: solid 1px #9a9a9a; - border-radius: 0px 0px 4px 4px; - background: transparent; -} - -@import url(https://fonts.googleapis.com/css?family=Open+Sans); - -*, *::before, *::after { - box-sizing: border-box; -} - -.backdrop { - padding-top: 3px; - padding-left: 2px; - /*width: 1312px;*/ - height: 507px; - margin-right:15px; -} - -.highlights, textarea { - padding: 10px; - font: 18px/28px 'Open Sans', sans-serif; - letter-spacing: 1px; -} - - -.backdrop { - position: absolute; - border: 2px solid #685972; - background-color: #fff; - overflow: auto; - pointer-events: none; - border: 0px solid; -} - -.highlights { - white-space: pre-wrap; - word-wrap: break-word; - border: 0px solid; -} - -mark { - padding: 0px; - border-radius: 3px; - color:red; - background:#fff; -} - - -.ButtonBox { - border-top: solid 1px #9a9a9a; - border-left: solid 1px #9a9a9a; - border-right: solid 1px #9a9a9a; - border-bottom: solid 1px #fff; - border-radius:4px 4px 0px 0px; -} -.FullScreenDiv1 { - display: flex; - padding-left: 10%; - border-bottom: solid 1px; -} -.Save_Btn { - color: white; - background-color: #2f82fd; - width: 100%; - min-height: 23px; - font-size: 12px; - border: solid 1px; - border-radius: 4px; -} - -.nav > li > a { - padding: 10px 15px 2px 15px; -} -.nav > li > input { - color: white; - background-color: #2f82fd; - float: right; - padding: 5px; - margin: 0px 25px 0px 0px; - -} -.wiki-add .eb-styledTab { - margin-right: -30px; - margin-left: -30px; - padding-left: 13px; - margin-bottom: 10px; -} - -.modal-class select { - width: 70px; - height: 25px; -} -.modal-class p { - width: 50px; - height: 25px; - margin: 4px; -} -#Help{ - padding-top:20px; -} -#Help span{ - padding-top:0px; -} -#internal-links-view { - display: flex; - flex-flow: row wrap; - padding-right: 0px; -} -#author{ - margin-left:37%; -} - #author img{ - padding:10px; - } - #author p{ - padding:5px; - } - #author .authorimg { - width: 40px; - height: 40px; - border: solid 1px #9c9c9c; - border-radius: 25px; - } - -.mob-view { - display: none; -} -.sidenav { - width: 250px; -} - - -/* side bar mobile view*/ - -.sidenav { - height: 100%; - width: 0; - position: fixed; - z-index: 1; - top: 45px; - left: 0; - background-color: #f2f2f2; - overflow-x: auto; - transition: 0.5s; - padding-top: 60px; -} - - .sidenav a { - display: block; - transition: 0.3s; - color: #2b2b2b; - text-decoration:none; - } - .sidenav .eb-wiki-sidebar .sidebar-list-wraper ul { - list-style: none; - } - .sidenav .closebtn { - position: absolute; - top: 45px; - right: 20px; - font-size: 20px; - margin-left: 50px; - } - -@media screen and (max-height: 450px) { - .sidenav { - padding-top: 15px; - } - - .sidenav a { - font-size: 18px; - } -} -/* side bar mobile view close*/ - - /*media query*/ -/* - ##Device = Tablets, Ipads (portrait) - ##Screen = B/w 768px to 1024px -*/ - -@media (min-width: 768px) and (max-width: 1024px) { - .eb-wiki-sidebar{ - display:none; - } - .mob-view { - display: block; - height: 40px; - font-size: 25px; - color: #696969; - border-radius: 4px; - border: 1px solid #bbb8b8; - } - .GettingStartedWrapper { - width: 100%; - flex-direction: column; - } - - .GettingStarted { - width: 100%; - } - .eb-wiki-pane { - margin-left: 0px; - width: 100%; - } - .addr-wiki { - display: none; - } - .eb-wiki-pane { - margin-left: 0px; - width: 100%; - } - .eb-wiki-pane .eb-wiki-pane-header { - padding-top: 25px; - } - .sidenav { - width: 310px; - } - -} - -/* - ##Device = Tablets, Ipads (landscape) - ##Screen = B/w 768px to 1024px -*/ - -@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) { - .eb-wiki-sidebar { - display: none; - } - .mob-view { - display: block; - height: 40px; - font-size: 25px; - color: #696969; - border-radius: 4px; - border: 1px solid #bbb8b8; - } - .GettingStartedWrapper { - width: 100%; - flex-direction: column; - } - .GettingStarted { - width: 100%; - } - .eb-wiki-pane { - margin-left: 0px; - width: 100%; - } - .eb-wiki-pane .eb-wiki-pane-header { - padding-top: 40px; - } - .sidenav { - width: 310px; - } -} - -/* - ##Device = Low Resolution Tablets, Mobiles (Landscape) - ##Screen = B/w 481px to 767px -*/ - -@media (min-width: 481px) and (max-width: 767px) { - .eb-wiki-sidebar { - display: none; - } - .mob-view { - display: block; - height: 40px; - font-size: 25px; - color: #696969; - border-radius: 4px; - border: 1px solid #bbb8b8; - } - - .GettingStartedWrapper { - width: 100%; - flex-direction: column; - } - .GettingStarted { - width: 100%; - } - .eb-wiki-pane { - margin-left: 0px; - width: 100%; - } - .eb-wiki-pane .eb-wiki-pane-header { - padding-top: 40px; - } - .front_page_wiki h2 { - font-size: 28px; - } - .sidenav { - width: 310px; - } -} - -/* - ##Device = Most of the Smartphones Mobiles (Portrait) - ##Screen = B/w 320px to 479px -*/ - -@media (min-width: 320px) and (max-width: 480px) { - .eb-wiki-sidebar { - display: none; - } - .mob-view { - display: block; - height: 40px; - font-size: 25px; - color: #696969; - border-radius: 4px; - border: 1px solid #bbb8b8; - } - .GettingStartedWrapper { - width: 100%; - flex-direction: column; - } - .GettingStarted{ - width:100%; - } - .eb-wiki-pane { - margin-left: 0px; - width: 100%; - } - .eb-wiki-pane .eb-wiki-pane-header { - padding-top: 40px; - } - .front_page_wiki h2 { - font-size: 28px; - } -} - -.backdrop::-webkit-scrollbar { - width: 0px; -} - -.backdrop::-webkit-scrollbar-thumb { - background: transparent; -} - -.backdrop::-webkit-scrollbar-track { - background: transparent; -} \ No newline at end of file diff --git a/wwwroot/css/EbWiki/tagsinput.css b/wwwroot/css/EbWiki/tagsinput.css deleted file mode 100644 index 58176f95d..000000000 --- a/wwwroot/css/EbWiki/tagsinput.css +++ /dev/null @@ -1,73 +0,0 @@ - - - - -.bootstrap-tagsinput { - background-color: #fff; - border: 1px solid #c1c1c1; - display: inline-block; - padding: 1px; - color: #555; - vertical-align: middle; - width: 100%; - line-height: 0px; - cursor: text; - min-height : 22px; - border-radius: 4px; - font-size: 12px; -} -.bootstrap-tagsinput input { - border: none; - box-shadow: none; - outline: none; - background-color: transparent; - padding: 0 6px; - margin: 0; - width: auto; - max-width: inherit; - -} -.bootstrap-tagsinput.form-control input::-moz-placeholder { - color: #777; - opacity: 1; -} -.bootstrap-tagsinput.form-control input:-ms-input-placeholder { - color: #777; -} -.bootstrap-tagsinput.form-control input::-webkit-input-placeholder { - color: #777; -} -.bootstrap-tagsinput input:focus { - border: none; - box-shadow: none; -} - .bootstrap-tagsinput .badge { - margin: 1px 0; - padding: 4px 8px; - font-size: 12px; - font-weight: 400; - line-height: 0.7; - color: #fff; - text-align: center; - white-space: nowrap; - vertical-align: baseline; - background-color: #3a3a3a; - border-radius: 11px; - } -.bootstrap-tagsinput .badge [data-role="remove"] { - margin-left: 8px; - cursor: pointer; -} -.bootstrap-tagsinput .badge [data-role="remove"]:after { - content: "×"; - padding: 0px 4px; - background-color:rgba(0, 0, 0, 0.1); - border-radius:10%; - font-size:12px -} -.bootstrap-tagsinput .badge [data-role="remove"]:hover:after { - - background-color:rgba(0, 0, 0, 0.62);} -.bootstrap-tagsinput .badge [data-role="remove"]:hover:active { - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); -} diff --git a/wwwroot/css/EbWiki/themes/3024-night.css b/wwwroot/css/EbWiki/themes/3024-night.css deleted file mode 100644 index 4ce58aa34..000000000 --- a/wwwroot/css/EbWiki/themes/3024-night.css +++ /dev/null @@ -1,109 +0,0 @@ -/* - - Name: 3024 night - Author: Jan T. Sott (http://github.com/idleberg) - - CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror) - Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) - -*/ - -.cm-s-3024-night.CodeMirror { - background: #090300; - color: #d6d5d4; -} - -.cm-s-3024-night div.CodeMirror-selected { - background: #3a3432; -} - -.cm-s-3024-night .CodeMirror-line::selection, .cm-s-3024-night .CodeMirror-line > span::selection, .cm-s-3024-night .CodeMirror-line > span > span::selection { - background: rgba(58, 52, 50, .99); -} - -.cm-s-3024-night .CodeMirror-line::-moz-selection, .cm-s-3024-night .CodeMirror-line > span::-moz-selection, .cm-s-3024-night .CodeMirror-line > span > span::-moz-selection { - background: rgba(58, 52, 50, .99); -} - -.cm-s-3024-night .CodeMirror-gutters { - background: #090300; - border-right: 0px; -} - -.cm-s-3024-night .CodeMirror-guttermarker { - color: #db2d20; -} - -.cm-s-3024-night .CodeMirror-guttermarker-subtle { - color: #5c5855; -} - -.cm-s-3024-night .CodeMirror-linenumber { - color: #5c5855; -} - -.cm-s-3024-night .CodeMirror-cursor { - border-left: 1px solid #807d7c; -} - -.cm-s-3024-night span.cm-comment { - color: #cdab53; -} - -.cm-s-3024-night span.cm-atom { - color: #a16a94; -} - -.cm-s-3024-night span.cm-number { - color: #a16a94; -} - -.cm-s-3024-night span.cm-property, .cm-s-3024-night span.cm-attribute { - color: #01a252; -} - -.cm-s-3024-night span.cm-keyword { - color: #db2d20; -} - -.cm-s-3024-night span.cm-string { - color: #fded02; -} - -.cm-s-3024-night span.cm-variable { - color: #01a252; -} - -.cm-s-3024-night span.cm-variable-2 { - color: #01a0e4; -} - -.cm-s-3024-night span.cm-def { - color: #e8bbd0; -} - -.cm-s-3024-night span.cm-bracket { - color: #d6d5d4; -} - -.cm-s-3024-night span.cm-tag { - color: #db2d20; -} - -.cm-s-3024-night span.cm-link { - color: #a16a94; -} - -.cm-s-3024-night span.cm-error { - background: #db2d20; - color: #807d7c; -} - -.cm-s-3024-night .CodeMirror-activeline-background { - background: #2F2F2F; -} - -.cm-s-3024-night .CodeMirror-matchingbracket { - text-decoration: underline; - color: white !important; -} diff --git a/wwwroot/js/wiki/AddWiki.js b/wwwroot/js/wiki/AddWiki.js deleted file mode 100644 index 362c20b57..000000000 --- a/wwwroot/js/wiki/AddWiki.js +++ /dev/null @@ -1,915 +0,0 @@ - -//var Addwiki = function () { -// var htmlEditor = CodeMirror.fromTextArea(document.getElementById("code"), { -// lineNumbers: true, -// mode: 'htmlmixed', -// // theme: 'default', -// }); - -// this.AppendHTMLtag = function (e) { -// let id = e.target.getAttribute("value"); -// var val = htmlEditor.getValue(); -// var SelectedString = htmlEditor.getSelection(); -// htmlEditor.replaceSelection(`<${id}>` + SelectedString + `<${id}/>`); - -// }; - -// this.init = function () { -// $(".props").off("click").on("click", this.AppendHTMLtag.bind(this)); -// }; -// this.init(); -//} - -var htmlEditor; -$(document).ready(function () { - var obj = new Addwiki(); - $("#status").val("@ViewBag.Wiki.Status"); - $("#iconselect").iconpicker({ - placement: 'bottom', - iconset: 'fontawesome', - icon: '' - - }).on('change', function (e) { - let str = ""; - obj.insertToCursorPosition(str); - }); -}); -$(document).keydown(function (e) { - if ((e.key == 's' || e.key == 'S') && (e.ctrlKey || e.metaKey)) { - e.preventDefault(); - $("#wikisave").click(); - } -}); - -let Addwiki = function () { - - htmlEditor = CodeMirror.fromTextArea(document.getElementById("code"), { - lineNumbers: true, - mode: "text/html", - theme: "default", - indentWithTabs: false, - }); - //htmlEditor.setOption('theme', theme); - - this.AppendHTMLtag = function (e) { - let id = e.target.getAttribute("val"); - if (id == `img` || id == `iframe`) { - let insertVal = `<${id} src=" "> ` - this.insertToCursorPosition(insertVal , 14); - } - else if (id == `a`) { - let insertVal = `<${id} src=" "> `; - this.insertToCursorPosition(insertVal , 8); - } - else { - var val = htmlEditor.getValue(); - var SelectedString = htmlEditor.getSelection(); - var doc = htmlEditor.getDoc(); - var cursor = doc.getCursor(); - if (id == 'left') { htmlEditor.replaceSelection(`

${SelectedString}

`); cursor.ch += 28} - else if (id == 'right') { htmlEditor.replaceSelection(`

${SelectedString}

`); cursor.ch += 29} - else if (id == 'center') { htmlEditor.replaceSelection(`

${SelectedString}

`); cursor.ch += 30 } - else if (id == 'code') { htmlEditor.replaceSelection(`
${SelectedString} 
`); cursor.ch += 25 } - else if (id == "u") { htmlEditor.replaceSelection(`${SelectedString} `); cursor.ch += 41 } - else if (id == "b") { htmlEditor.replaceSelection(`${SelectedString} `); cursor.ch += 31 } - else if (id == "i") { htmlEditor.replaceSelection(`${SelectedString} `); cursor.ch += 33 } - else { htmlEditor.replaceSelection(`<${id}> ${SelectedString}<${id}/>`); cursor.ch += id.length + 2 } - htmlEditor.focus(); - htmlEditor.setCursor(cursor); - } - }; - - this.insertToCursorPosition = function (str, ExtraCurPos) { - var doc = htmlEditor.getDoc(); - var cursor = doc.getCursor(); - if (ExtraCurPos) { cursor.ch += ExtraCurPos} - var pos = { - line: cursor.line, - ch: cursor.ch - } - doc.replaceRange(str, pos); - htmlEditor.focus(); - htmlEditor.setCursor(cursor); - return cursor; - } - - this.tbl_size_select = function (e) { - let rows = $("#tbl-row").val(); - let cols = $("#tbl-col").val(); - let $tbl = $(`
`); - for (i = 0; i < rows; i++) { - let $tblRow = $(" "); - if (i == 0) { - for (j = 0; j < cols; j++) { $tblRow.append(" "); } - $tbl.append($tblRow); - } - else { - for (j = 0; j < cols; j++) { $tblRow.append(" "); } - $tbl.append($tblRow); - } - } - this.insertToCursorPosition($tbl.outerHTML() , 58); - } - - this.ul_type_select = function () { - let ul_row = $("#ul-row").val(); - let type = $("#ul-style-sel option:selected").text(); - let $ul = $(`
`); - for (i = 0; i < ul_row; i++) { $ul.append("
  • "); } - var abc = this.insertToCursorPosition($ul.outerHTML(), 40); - htmlEditor.focus(); - htmlEditor.setCursor(abc); - - } - - this.ol_type_select = function () { - let ul_row = $("#ol-row").val(); - let type = $("#ol-style-sel option:selected").text(); - let $ul = $(`
    `); - for (i = 0; i < ul_row; i++) { $ul.append("
  • ");} - this.insertToCursorPosition($ul.outerHTML()); - } - - - this.AppendHtml = function () { - let SelectedString = $('#text').val(); - $('#render').html(SelectedString); - $('#new1').append(''); - }; - - this.show_home = function () { - $('#wiki_data_div').hide(); - $('.front_page_wiki').show(); - window.history.pushState('obj', 'PageTitle', `/Wiki`); - }; - - let start; - let end; - let id; - - - this.SelectInternalLink = function () { - $.contextMenu({ - selector: '.InternalLinks', - trigger: 'left', - items: { - "edit": { - name: "edit", icon: "edit", callback: this.editWiki.bind(this) - }, - "publish": { - name: "publish", icon: "cut", callback: this.PublishWiki.bind(this) - }, - - } - }); - } - - this.FetchWikiList = function (e) { - let id = e.target.getAttribute('data-id'); - let wname = e.target.getAttribute('val').trim(); - let con = $(`[data-id="${id}"]`).parent().parent().parent().attr("id"); - wiki_name = wname.replace(/ /g, '~'); - $(".wikilist").removeClass("CurrentSelection"); - $(`[data-id='${id}']`).addClass("CurrentSelection"); - $(".commonLoader").EbLoader("show"); - this.AjaxCalFetchWikiList(id); - window.history.pushState('obj', 'PageTitle', `/Wiki/${con}/${wiki_name}`); - } - - this.AjaxCalFetchWikiList = function (id) { - let orderId = $(`[data-id="${id}"]`).parent().attr("order-id"); - $.ajax({ - type: 'POST', - url: "/PublicWiki/GetWiki", - data: { - wiki_id: id - }, - success: this.FetchWikiListSuccess.bind(this, id, orderId) - }); - } - - this.FetchWikiListSuccess = function (id, orderId, ob) { - $('#wiki_data_div').show(); - $("#wiki_data_div").scrollTop(0); - $('.edit').attr('href', '../wiki/add/' + ob.id); - $('.edit').attr('id', ob.id); - document.title = ob.title; - $("#ebwiki_panebrd").html(`${ob.category} / ${ob.title}`) - urlTitle = ob.title.replace(/\s+/g, '-'); - //var url = window.location.origin + "/Wiki/View/" + id + "/" + urlTitle; - var url = window.location.origin + `/Wiki/${ob.category}/${urlTitle}`; - let fbUrl = "https://www.facebook.com/share.php?u=" + url + "&title=" + ob.title; - let twUrl = "https://twitter.com/intent/tweet?status=" + url; - let lnUrl = "https://www.linkedin.com/shareArticle?mini=true&url=" + url + "&title=" + ob.title + "&summary=YourarticleSummary&source=expressbase.com"; - let whUrl = "https://wa.me/?text=" + url; - let $Wiki_dat = $(`
    `); - $Wiki_dat.append(`

    ${ob.title}

    `); - $Wiki_dat.append(ob.html); - //$('#wiki_data_div').html(ob.title); - $('#wiki_data_div').html($Wiki_dat).slideUp(10).slideDown(200).fadeIn(100); - var res; let $Tags = $(`
    `); - if (ob.tags !== null) { - var res = ob.tags.split(","); - for (var i = 0; i < res.length; i++) { - if (res[i] != "") { - $Tags.append(``); - } - } - }; - $('#wiki_data_div').append($Tags); - //var $author = $("
    "); - //$author.append("

    "+ob.authorName+"

    "); - //$('#wiki_data_div').append($author); - $('.front_page_wiki').hide(); - - let next = $(`[order-id="${orderId}"]`).next().attr("order-id"); - let Pre = $(`[order-id="${orderId}"]`).prev().attr("order-id"); - let $nextPre = $(`
    `); - if (next) { - $nextPre.append(`Next`); - } - if (Pre) { - $nextPre.append(` Previous`); - } - - $('#wiki_data_div').append($nextPre); - $WasItHelpFul = `
    -
    -

    Questions?

    - - Please mail support@expressbase.com , we are always happy to help. - - - - - -
    `; - $('#wiki_data_div').append($WasItHelpFul); - let title = $(".wiki_data h1").text(); - let desc = $(".wiki_data p").text().substring(0, $(".wiki_data p").text().indexOf(".")); - $(`meta[property="og:title"]`).attr("content", `${title}`); - $(`meta[property="og:description"]`).attr("content", `${desc}`); - $(`meta[property="og:image"]`).attr("content", ``); - $(`meta[property="og:url"]`).attr("content", `${url}`); - $(`meta[name="twitter:card"]`).attr("content", "large image"); - //this.AddMetaTags(); - if (PR) - PR.prettyPrint(); - $(".commonLoader").EbLoader("hide"); - } - - this.WikiSearch = function () { - let key = $('#search_wiki').val(); - if (key.length == 0) { - let url = window.location.href; - //alert(url); - let urlSplit = url.split("/"); - let id = urlSplit[urlSplit.length - 1]; - if ($.isNumeric(id)) { - this.AjaxCalFetchWikiList(id); - } - else { - let url = window.location.href; - //alert(url); - let urlSplit = url.split("/"); - let wiki_name = urlSplit[urlSplit.length - 1]; - let wname = wiki_name.replace(/\~/g, ' '); - let id = $(`[val="${wname}"]`).attr("data-id"); - $(".wikilist").removeClass("CurrentSelection"); - $(`[data-id='${id}']`).addClass("CurrentSelection"); - if ($.isNumeric(id)) { - obj.AjaxCalFetchWikiList(id); - } - else { - obj.show_home(); - } - } - } - else if (key.length < 3) { - $("#wiki_data_div").empty(); - $("#wiki_data_div").show(); - $("#wiki_data_div").append("Type minimum 3 letters") - $('.front_page_wiki').hide(); - } - else { - $("#ebwiki_panebrd").text("").text("Wiki Search Result"); - $(".commonLoader").EbLoader("show"); - $.ajax({ - type: 'POST', - url: "/PublicWiki/GetWikiBySearch", - data: { - search_wiki: key - }, - success: function (ob) { - - - if (!ob.length && key.length != 0) { - $("#wiki_data_div").empty(); - $("#wiki_data_div").show(300); - $('.front_page_wiki').hide(); - $("#wiki_data_div").append("

    Result not Found

    "); - } - else - $("#wiki_data_div").empty(); - for (let i = 0; i < ob.length; i++) { - $("#wiki_data_div").show(500); - $('.front_page_wiki').hide(100); - let $Report = $(`
    `); - $Report.append(` ${ob[i].title} `); - $Report.append(` ${ob[i].html}`); - let $Tags = $(`

    ${ob[i].tags}

    `); - $("#wiki_data_div").append($Report); - //$("#wiki_data_div").append($Tags); - $('#' + ob[i].id).attr('title', ob[i].category); - }; - $(".commonLoader").EbLoader("hide"); - } - }); - } - } - - this.add_tag = function (e) { - let tag = $('#list_tag').val(); - alert(tag); - $("#view-tags").append("") - } - - this.WikiListToggle = function (e) { - $(".wikilist").removeClass("CurrentSelection"); - let id = $(e.target).closest(".wraper-link").attr('val'); - if (id == "home") { - $("#ebwiki_panebrd").html("Getting started"); - $('#wiki_data_div').hide(); - $('.front_page_wiki').show(); - window.history.pushState('obj', 'PageTitle', `/Wiki`); - } - else { - $("#" + id).toggle(200); - $("#ebwiki_panebrd").html(`${id}`); - window.history.pushState('obj', 'PageTitle', `/Wiki/${id}`); - } - } - - this.show_draft_items = function (e) { - let key = e.target.getAttribute('val'); - - if (key == 'draft') { - $(".publish").hide(); - $(".unpublish").hide(); - $(".draft").show(200); - } - else if (key == 'publish') { - $(".publish").show(200); - $(".unpublish").hide(); - $(".draft").hide(); - } - else if (key == 'unpublish') { - $(".publish").hide(); - $(".unpublish").show(200); - $(".draft").hide(); - } - - } - - this.Admin_Wiki_List = function (e) { - let status = e.target.getAttribute('data-val'); - if (status == "PublicView") { - this.PublicView(); - } - else - $.ajax({ - type: 'POST', - url: "/Wiki/Admin_Wiki_List", - data: { - status: status - }, - success: this.ajaxAdminWikiFetch.bind(this) - }); - } - - this.ajaxAdminWikiFetch = function (ob) { - $("#public").empty(); - if (ob.length == 0) { - $("#public").append(`

    You haven’t any wikies yet.

    `); - } - else { - $("#public").empty(); - for (let j = 0; j < ob.wikiCat.length; j++) { - let temp = 0; - let $divObj = $(`
    `); - $divObj.append(`
    ${ob.wikiCat[j].wikiCategory} - -
    `); - let $Form = $(`
    `); - for (let i = 0; i < ob.wikiList.length; i++) { - if (ob.wikiList[i].category == `${ob.wikiCat[j].wikiCategory}`) { - // var date = new Date(ob.wikiList[i].createdAt); - var date = ob.wikiList[i].createdAt.split("T"); - - $Form.append(` -
    -

    ${ob.wikiList[i].title}

    -

    Created On ${date[0]}

    -
    - `); - temp++; - } - } - if (temp == 0) { - $Form.append(`
    Empty List
    `); - } - $divObj.append($Form); - $("#public").append($divObj); - } - } - this.Draftcontextmenu(); - - this.Publishcontextmenu(); - - this.Unpublishcontextmenu(); - $("#eb_common_loader").EbLoader("hide"); - - } - - this.PublicView = function () { - $.ajax({ - type: 'POST', - url: "/Wiki/PublicView", - data: { - status: status - }, - success: this.ajaxPublicViewSuccess.bind(this) - }); - } - - this.ajaxPublicViewSuccess = function (ob) { - - $("#public").empty(); - - for (let j = 0; j < ob.wikiCat.length; j++) { - let temp = 0; - let $divObj = $(`
    `); - $divObj.append(`
    ${ob.wikiCat[j].wikiCategory} - -
    `); - let $Form = $(`
      `); - for (let i = 0; i < ob.wikiList.length; i++) { - if (ob.wikiList[i].category == `${ob.wikiCat[j].wikiCategory}`) { - $Form.append(`
    • ${ob.wikiList[i].title}
    • `); - temp++; - } - } - - if (temp == 0) { - $Form.append(`
      Empty List
      `); - } - - $divObj.append($Form); - $("#public").append($divObj); - let dataVal = ob.wikiCat[j].wikiCategory; - this.draggableFun(dataVal); - } - - $("#public").append(``); - - - $("#eb_common_loader").EbLoader("hide"); - } - - this.draggableFun = function (dataVal) { - $(`[data-val="${dataVal}"]`).sortable(); - $(`[data-val="${dataVal}"]`).disableSelection(); - } - - //Context menu Wiki - this.Draftcontextmenu = function () { - $.contextMenu({ - selector: '.Draft', - trigger: 'right', - items: { - "edit": { - name: "edit", icon: "edit", callback: this.editWiki.bind(this) - }, - "publish": { - name: "publish", icon: "cut", callback: this.PublishWiki.bind(this) - }, - - } - }); - } - - this.Publishcontextmenu = function () { - $.contextMenu({ - selector: '.Publish', - trigger: 'right', - items: { - "edit": { - name: "edit", icon: "edit", callback: this.editWiki.bind(this) - }, - "Unpublish": { - name: "Unpublish", icon: "delete", callback: this.UnpublishWiki.bind(this) - - }, - - } - }); - } - - this.Unpublishcontextmenu = function () { - $.contextMenu({ - selector: '.Unpublish', - trigger: 'right', - items: { - "edit": { - name: "edit", icon: "edit", callback: this.editWiki.bind(this) - }, - "publish": { - name: "publish", icon: "cut", callback: this.PublishWiki.bind(this) - - }, - - } - }); - } - - this.editWiki = function (key, options) { - let id = $(options.$trigger).attr("data-id"); - let url = window.location.origin + "/wiki/add/" + id - window.open(window.location.origin + "/wiki/add/" + id, '_blank'); - }; - - this.PublishWiki = function (key, options) { - let id = $(options.$trigger).attr("data-id"); - let status = $(options.$trigger).attr("val"); - - $.ajax({ - type: 'POST', - url: "/Wiki/Publish_wiki", - data: { - wiki_id: id, - wiki_status: status - - }, - success: function (ob) { - if (ob.id != null) { - if (status == "Draft") { - $("[style-val=Draft]").click(); - } - else { - $("[style-val=Unpublish]").click(); - } - } - } - }); - }; - - this.UnpublishWiki = function (key, options) { - let id = $(options.$trigger).attr("data-id"); - let status = $(options.$trigger).attr("val"); - $.ajax({ - type: 'POST', - url: "/Wiki/Publish_wiki", - data: { - wiki_id: id, - wiki_status: status - }, - success: function (ob) { - if (ob.id != null) { - - $("[style-val=Publish]").click(); - } - } - }); - }; - - this.WikiMenuToggle = function (e) { - let togVal = e.target.getAttribute("toggleval"); - let val = e.target.getAttribute('val'); - if (togVal == "show") { - $(`[val="${val}"]`).removeAttr("toggleval").attr("toggleval", "hide"); - $(`[val="${val}"] i`).removeClass("fa-chevron-circle-down").addClass("fa-chevron-circle-right"); - } - else { - $(`[val="${val}"]`).removeAttr("toggleval").attr("toggleval", "show"); - $(`[val="${val}"] i`).removeClass("fa-chevron-circle-right").addClass("fa-chevron-circle-down"); - - } - - $(`[data-val=${val}]`).toggle(300); - } - - this.UpdateOrder = function (e) { - $("#eb_common_loader").EbLoader("show"); - var myList = []; - $(".ui-state-default").each(function () { - //alert($(this).attr("wiki-id")) - myList.push($(this).attr("wiki-id")); - }); - - $.ajax( - { - url: '/Wiki/UpdateOrder', - type: 'POST', - data: { myList: JSON.stringify(myList) }, - success: function (data) { - if (data == true) { - EbPopBox("show", { - Message: "Success...", - ButtonStyle: { - Text: "Ok", - Color: "white", - Background: "#508bf9", - Callback: function () { - } - } - }); - $("#eb_common_loader").EbLoader("hide"); - } - else { - EbPopBox("show", { - Message: "Failed to update the order...", - ButtonStyle: { - Text: "Ok", - Color: "white", - Background: "#508bf9", - Callback: function () { - } - } - }); - - $("#eb_common_loader").EbLoader("hide"); - } - - } - }); - } - - this.WikiAdminMenuBarHighlight = function (e) { - $("#eb_common_loader").EbLoader("show"); - let style_val = e.target.getAttribute("style-val"); - if (style_val == "PublicView") { - this.PublicView(); - } - else - this.WikiAdminMenuBarHighlightAjax(style_val); - } - - this.WikiAdminMenuBarHighlightAjax = function (style_val) { - $.ajax({ - type: 'POST', - url: "/Wiki/Admin_Wiki_List", - data: { - status: style_val - }, - success: this.ajaxAdminWikiFetch.bind(this) - }); - } - - this.SearchWithTagFun = function (e) { - let val = e.target.getAttribute('val'); - $("#search_wiki").val(val); - $("#search_wiki").focus(); - $("#search_wiki").click(); - } - - this.WasItHelp = function (e) { - let answer = e.target.getAttribute("val"); - $("#Help").hide(); - $("#EbHelp").show(); - $.ajax({ - type: 'POST', - url: "/Wiki/UserReviewRate", - data: { - answer: answer - }, - success: this.ajaxUserReviewRateSuccess.bind(this) - }); - } - - this.ajaxUserReviewRateSuccess = function () { - - } - - this.GetStartToWikiDocs = function (e) { - let value = $(e.target).closest(".GettingStarted").attr("val"); - $(`#${value}>ul>li:first>a`).click(); - } - - this.NextAndPreWiki = function (e) { - let OrderId = e.target.getAttribute("Next-id"); - let dataId = $(`[order-id="${OrderId}"]`).children().attr("data-id"); - $(`[data-id="${dataId}"]`).click(); - } - - this.gallerytab = function () { - $("#gallery").click(); - } - - this.WikiPreviewTab = function () { - $("#render").empty().append(htmlEditor.getValue()); - } - - this.EbloaderTrigger = function () { - $(".eb_common_loader").EbLoader("show"); - } - - this.SaveWiki = function () { - let sts = true; - let a = ""; - $("#eb_common_loader").EbLoader("show"); - var wiki = {}; - wiki["category"] = $("#category option:selected").text(); - wiki["CatId"] = $("#category").val(); - wiki["title"] = $("#title").val(); - wiki["status"] = $("#status option:selected").text(); - wiki["html"] = htmlEditor.getValue(); - wiki["tags"] = $("#tagbox").val(); - wiki["Id"] = $("#wiki-id").val(); - if (wiki["title"] == "") { - sts = false; - a = a + "Title/"; - } - if (wiki["status"] == "Select Status") { - sts = false; - a = a + "Status/"; - } - if (wiki["category"] == "Select Category") { - sts = false; - a = a + "Category"; - } - if (sts == true) { - this.SaveWikiTrue(wiki); - } - else { - EbPopBox("show", { - Message: "Enter " + a, - ButtonStyle: { - Text: "Ok", - Color: "white", - Background: "#508bf9", - Callback: function () { - } - } - }); - $("#eb_common_loader").EbLoader("hide"); - } - } - - this.SaveWikiTrue = function (wiki) { - $.ajax( - { - url: '/Wiki/Save', - type: 'POST', - data: { wiki: wiki }, - success: function (data) { - if (data.responseStatus === true) { - EbPopBox("show", { - Message: "Success...", - ButtonStyle: { - Text: "Ok", - Color: "white", - Background: "#508bf9", - Callback: function () { - let url = window.location.origin + "/add/wiki/" + data.wiki.id; - window.location.replace(url); - } - } - }); - $("#eb_common_loader").EbLoader("hide"); - } - else { - EbPopBox("show", { - Message: "Failed to Save", - ButtonStyle: { - Text: "Ok", - Color: "white", - Background: "#508bf9", - Callback: function () { - } - } - }); - $("#eb_common_loader").EbLoader("hide"); - } - } - }); - } - - - this.InternalLinksFun = function () { - $.ajax({ - type: 'POST', - url: "/Wiki/Admin_Wiki_List", - data: { - status: 'Publish' - }, - success: this.AjaxInternalLinksFun.bind(this) - }); - } - - this.AjaxInternalLinksFun = function (ob) { - $("#internal-links-view").empty(); - if (ob.length == 0) { - $("#internal-links-view").append(` -

      You haven’t any wikies yet.

      - `) - } - else { - $("#internal-links-view").empty(); - - for (let j = 0; j < ob.wikiCat.length; j++) { - let temp = 0; - let $divObj = $(`
      `); - $divObj.append(`
      ${ob.wikiCat[j].wikiCategory} - -
      `); - let $Form = $(`
      `); - for (let i = 0; i < ob.wikiList.length; i++) { - if (ob.wikiList[i].category == `${ob.wikiCat[j].wikiCategory}`) { - // var date = new Date(ob.wikiList[i].createdAt); - var date = ob.wikiList[i].createdAt.split("T"); - - $Form.append(` -
      -

      ${ob.wikiList[i].title}

      -
      - `); - temp++; - } - } - if (temp == 0) { - $Form.append(`
      Empty List
      `); - } - - $divObj.append($Form); - $("#internal-links-view").append($divObj); - } - } - this.InternalLinkContextMenu(); - $("#eb_common_loader").EbLoader("hide"); - - } - - this.InternalLinkContextMenu = function () { - $.contextMenu({ - selector: '.Publish', - trigger: 'right', - items: { - "edit": { - name: "Copy", icon: "copy", callback: this.CopyInternalLink.bind(this) - }, - } - }); - } - - this.CopyInternalLink = function (key, options) { - let id = $(options.$trigger).attr("data-id"); - let title = $(options.$trigger).attr("val"); - let link = ` ${title} ` - copyStringToClipboard(link); - }; - - this.copyStringToClipboard = function (str) { - var el = document.createElement('textarea'); - el.value = str; - el.setAttribute('readonly', ''); - el.style = { position: 'absolute', left: '-9999px' }; - document.body.appendChild(el); - el.select(); - document.execCommand('copy'); - document.body.removeChild(el); - } - - - - this.init = function () { - $(".wikilist").on("click", this.FetchWikiList.bind(this)); - $("#wiki_data_div").on("click", ".searchshow", this.FetchWikiList.bind(this)); - $("#text").on("keyup", this.AppendHtml.bind(this)); - $("#text").on("click", this.AppendHtml.bind(this)); - $("#search_wiki").on("keyup change", this.WikiSearch.bind(this)); - $(".wraper-link").on("click", this.WikiListToggle.bind(this)); - //$("#render_page_toggle").on("click", this.render_page_toggle.bind(this)); - $(".wiki_data").on("click", ".SearchWithTag ", this.SearchWithTagFun.bind(this)); - // $(".wiki_data").on("click", ".wikilist", this.SearchWithTagFun.bind(this)); - $(".wiki_data").on("click", ".NextPreWiki", this.NextAndPreWiki.bind(this)); - $(".GettingStarted").on("click", this.GetStartToWikiDocs.bind(this)); - - //wiki admin - $("#wikisave").on("click", this.SaveWiki.bind(this)); - $(".wikies_list").on("click", this.Admin_Wiki_List.bind(this)); - $("#public").on("click", ".WikiMenu", this.WikiMenuToggle.bind(this)); - $("#public").on("click", ".UpdateOrder", this.UpdateOrder.bind(this)); - $(".WikiAdminMenuBar").on("click", this.WikiAdminMenuBarHighlight.bind(this)); - $("#gallery-tab1").on("click", this.gallerytab.bind(this)); - $("#preview").on("click", this.WikiPreviewTab.bind(this)); - $("#tbl-size-select").on("click", this.tbl_size_select.bind(this)); - $("#ul-type-select").on("click", this.ul_type_select.bind(this)); - $("#ol-type-select").on("click", this.ol_type_select.bind(this)); - $("#internal-a").on("click", this.InternalLinksFun.bind(this)); - $("#wiki_data_div").on("click", ".wikilist", this.FetchWikiList.bind(this)); - - $(".props").off("click").on("click", this.AppendHTMLtag.bind(this)); - }; - - this.init(); -} diff --git a/wwwroot/js/wiki/eb_wiki.js b/wwwroot/js/wiki/eb_wiki.js deleted file mode 100644 index d33b90e86..000000000 --- a/wwwroot/js/wiki/eb_wiki.js +++ /dev/null @@ -1,1004 +0,0 @@ -let addwiki = function () { - - this.AppendHtml = function () { - let SelectedString = $('#text').val(); - $('#render').html(SelectedString); - $('#new1').append(''); - }; - - this.show_home = function () { - $('#wiki_data_div').hide(); - $('.front_page_wiki').show(); - window.history.pushState('obj', 'PageTitle', `/Wiki`); - }; - - let start; - let end; - let id; - - this.appendVal = function (e) { - var cursorPos = $("#text").prop('selectionStart'); - document.getElementById('text'); - let SelectedString = window.getSelection().toString(); - var ele = document.getElementById('text'); - var text = ele.value; - start = ele.selectionStart; - end = ele.selectionEnd; - text = text.slice(0, start) + text.slice(end); - ele.value = text; - - id = e.target.getAttribute('val'); - if (id == `img` || id == `iframe`) { - let insertVal = `<${id} src=" "> ` - let txt = 'text'; - if (SelectedString == "") { - this.insertAtCaret(insertVal, cursorPos); - } - else { - let insertVal = `<${id} src=''> ${SelectedString} ` - this.insertAtCaret(insertVal, cursorPos); - } - } - else if (id == `a`) { - let insertVal = `<${id} src="link"> ` - let txt = 'text'; - if (SelectedString == "") { - this.insertAtCaret(insertVal, cursorPos); - } - else { - let insertVal = `<${id} src=''> ${SelectedString} ` - this.insertAtCaret(insertVal, cursorPos); - } - } - else if (id == `right`) { - let insertVal = `

      ` - let txt = 'text'; - if (SelectedString == "") { - this.insertAtCaret(insertVal, cursorPos); - } - else { - let insertVal = `

      ${SelectedString}

      ` - this.insertAtCaret(insertVal, cursorPos); - } - } - else if (id == `left`) { - let insertVal = `

      ` - let txt = 'text'; - if (SelectedString == "") { - this.insertAtCaret(insertVal, cursorPos); - } - else { - let insertVal = `

      ${SelectedString}

      ` - this.insertAtCaret(insertVal, cursorPos); - } - } - - else if (id == `code`) { - let insertVal = `
       
      ` - let txt = 'text'; - if (SelectedString == "") { - this.insertAtCaret(insertVal, cursorPos); - } - else { - let insertVal = `
       ${SelectedString} 
      ` - this.insertAtCaret(insertVal, cursorPos); - } - } - else if (id == `br`) { - let insertVal = `
      ` - let txt = 'text'; - if (SelectedString == "") { - this.insertAtCaret(insertVal, cursorPos); - } - else { - let insertVal = `
      ` - this.insertAtCaret(insertVal, cursorPos); - } - } - else { - let insertVal = `<${id}> ` - let txt = 'text'; - if (SelectedString == "") { - this.insertAtCaret(insertVal, cursorPos); - } - else { - let insertVal = `<${id}> ${SelectedString} ` - this.insertAtCaret(insertVal, cursorPos); - } - } - } - - this.insertAtCaret = function (text, cur) { - var cursorPos = cur; - var v = $("#text").val(); - var textBefore = v.substring(0, cursorPos); - var textAfter = v.substring(cursorPos, v.length); - $("#text").focus(); - $("#text").val(textBefore + text + textAfter); - var cur = textBefore.length + text.length; - - this.clickfun(cur); - this.handleInput(); - } - - this.clickfun = function (curpos) { - var v = $("#text").val(); - - var str = v.substring(0, curpos); - var regex = /\<([a-z1-9A-Z\/]+\>)/gi, result, indices = []; - while ((result = regex.exec(str))) { - indices.push(result.index); - } - var cursorPosition = $("#text").prop("selectionStart"); - $("#text").prop('selectionEnd'); - var closestPosition = this.closest(cursorPosition, indices); - $("#text").prop('selectionEnd', closestPosition); - var cursorPos = $("#text").prop('selectionStart'); - - } - - this.closest = function (num, arr) { - var curr = arr[0]; - - var diff = Math.abs(num - curr); - for (var val = 0; val < arr.length; val++) { - var newdiff = Math.abs(num - arr[val]); - if (newdiff < diff) { - diff = newdiff; - curr = arr[val]; - } - } - return curr; - } - - this.SelectInternalLink = function () { - $.contextMenu({ - selector: '.InternalLinks', - trigger: 'left', - items: { - "edit": { - name: "edit", icon: "edit", callback: this.editWiki.bind(this) - }, - "publish": { - name: "publish", icon: "cut", callback: this.PublishWiki.bind(this) - }, - - } - }); - } - - this.FetchWikiList = function (e) { - let id = e.target.getAttribute('data-id'); - let wname = e.target.getAttribute('val').trim(); - - let con = $(`[data-id="${id}"]`).parent().parent().parent().attr("id"); - //$(`[data-id="${id}"]`).attr("val" ,wname); - wiki_name = wname.replace(/ /g, '~'); - //let orderId = $(`[data-id="${id}"]`).parent().attr("order-id"); - $(".wikilist").removeClass("CurrentSelection"); - $(`[data-id='${id}']`).addClass("CurrentSelection"); - $(".commonLoader").EbLoader("show"); - this.AjaxCalFetchWikiList(id); - //let title = $(".wiki_data h1").text(); - window.history.pushState('obj', 'PageTitle', `/Wiki/${con}/${wiki_name}`); - } - - this.AjaxCalFetchWikiList = function (id) { - let orderId = $(`[data-id="${id}"]`).parent().attr("order-id"); - $.ajax({ - type: 'POST', - url: "/PublicWiki/GetWiki", - data: { - wiki_id: id - }, - success: this.FetchWikiListSuccess.bind(this, id, orderId) - }); - } - - this.FetchWikiListSuccess = function (id, orderId, ob) { - $('#wiki_data_div').show(); - $("#wiki_data_div").scrollTop(0); - $('.edit').attr('href', '../wiki/add/' + ob.id); - $('.edit').attr('id', ob.id); - document.title = ob.title; - $("#ebwiki_panebrd").html(`${ob.category} / ${ob.title}`) - urlTitle = ob.title.replace(/\s+/g, '-'); - //var url = window.location.origin + "/Wiki/View/" + id + "/" + urlTitle; - var url = window.location.origin + `/Wiki/${ob.category}/${urlTitle}`; - let fbUrl = "https://www.facebook.com/share.php?u=" + url + "&title=" + ob.title; - let twUrl = "https://twitter.com/intent/tweet?status=" + url; - let lnUrl = "https://www.linkedin.com/shareArticle?mini=true&url=" + url + "&title=" + ob.title + "&summary=YourarticleSummary&source=expressbase.com"; - let whUrl = "https://wa.me/?text=" + url; - let $Wiki_dat = $(`
      `); - $Wiki_dat.append(`

      ${ob.title}

      `); - $Wiki_dat.append(ob.html); - //$('#wiki_data_div').html(ob.title); - $('#wiki_data_div').html($Wiki_dat).slideUp(10).slideDown(200).fadeIn(100); - var res; let $Tags = $(`
      `); - if (ob.tags !== null) { - var res = ob.tags.split(","); - for (var i = 0; i < res.length; i++) { - if (res[i] != "") { - $Tags.append(``); - } - } - }; - $('#wiki_data_div').append($Tags); - //var $author = $("
      "); - //$author.append("

      "+ob.authorName+"

      "); - //$('#wiki_data_div').append($author); - $('.front_page_wiki').hide(); - - let next = $(`[order-id="${orderId}"]`).next().attr("order-id"); - let Pre = $(`[order-id="${orderId}"]`).prev().attr("order-id"); - let $nextPre = $(`
      `); - if (next) { - $nextPre.append(`Next`); - } - if (Pre) { - $nextPre.append(` Previous`); - } - - $('#wiki_data_div').append($nextPre); - $WasItHelpFul = `
      -
      -

      Questions?

      - - Please mail support@expressbase.com , we are always happy to help. - - - - - -
      `; - $('#wiki_data_div').append($WasItHelpFul); - let title = $(".wiki_data h1").text(); - let desc = $(".wiki_data p").text().substring(0, $(".wiki_data p").text().indexOf(".")); - $(`meta[property="og:title"]`).attr("content", `${title}`); - $(`meta[property="og:description"]`).attr("content", `${desc}`); - $(`meta[property="og:image"]`).attr("content", ``); - $(`meta[property="og:url"]`).attr("content", `${url}`); - $(`meta[name="twitter:card"]`).attr("content", "large image"); - //this.AddMetaTags(); - if (PR) - PR.prettyPrint(); - $(".commonLoader").EbLoader("hide"); - } - - this.WikiSearch = function () { - - let key = $('#search_wiki').val(); - if (key.length == 0) { - let url = window.location.href; - //alert(url); - let urlSplit = url.split("/"); - let id = urlSplit[urlSplit.length - 1]; - if ($.isNumeric(id)) { - this.AjaxCalFetchWikiList(id); - } - else { - let url = window.location.href; - //alert(url); - let urlSplit = url.split("/"); - let wiki_name = urlSplit[urlSplit.length - 1]; - let wname = wiki_name.replace(/\~/g, ' '); - let id = $(`[val="${wname}"]`).attr("data-id"); - $(".wikilist").removeClass("CurrentSelection"); - $(`[data-id='${id}']`).addClass("CurrentSelection"); - if ($.isNumeric(id)) { - obj.AjaxCalFetchWikiList(id); - } - else { - obj.show_home(); - } - } - } - else if (key.length < 3) { - $("#wiki_data_div").empty(); - $("#wiki_data_div").show(); - $("#wiki_data_div").append("Type minimum 3 letters") - $('.front_page_wiki').hide(); - } - else { - $("#ebwiki_panebrd").text("").text("Wiki Search Result"); - $(".commonLoader").EbLoader("show"); - $.ajax({ - type: 'POST', - url: "/PublicWiki/GetWikiBySearch", - data: { - search_wiki: key - }, - success: function (ob) { - - - if (!ob.length && key.length != 0) { - $("#wiki_data_div").empty(); - $("#wiki_data_div").show(300); - $('.front_page_wiki').hide(); - $("#wiki_data_div").append("

      Result not Found

      "); - } - else - $("#wiki_data_div").empty(); - for (let i = 0; i < ob.length; i++) { - $("#wiki_data_div").show(500); - $('.front_page_wiki').hide(100); - let $Report = $(`
      `); - $Report.append(` ${ob[i].title} `); - $Report.append(` ${ob[i].html}`); - let $Tags = $(`

      ${ob[i].tags}

      `); - $("#wiki_data_div").append($Report); - //$("#wiki_data_div").append($Tags); - $('#' + ob[i].id).attr('title', ob[i].category); - }; - $(".commonLoader").EbLoader("hide"); - } - }); - } - } - - this.add_tag = function (e) { - let tag = $('#list_tag').val(); - alert(tag); - $("#view-tags").append("") - } - - this.WikiListToggle = function (e) { - $(".wikilist").removeClass("CurrentSelection"); - let id = $(e.target).closest(".wraper-link").attr('val'); - if (id == "home") { - $("#ebwiki_panebrd").html("Getting started"); - $('#wiki_data_div').hide(); - $('.front_page_wiki').show(); - window.history.pushState('obj', 'PageTitle', `/Wiki`); - } - else { - $("#" + id).toggle(200); - $("#ebwiki_panebrd").html(`${id}`); - window.history.pushState('obj', 'PageTitle', `/Wiki/${id}`); - } - } - - this.show_draft_items = function (e) { - let key = e.target.getAttribute('val'); - - if (key == 'draft') { - $(".publish").hide(); - $(".unpublish").hide(); - $(".draft").show(200); - } - else if (key == 'publish') { - $(".publish").show(200); - $(".unpublish").hide(); - $(".draft").hide(); - } - else if (key == 'unpublish') { - $(".publish").hide(); - $(".unpublish").show(200); - $(".draft").hide(); - } - - } - - this.Admin_Wiki_List = function (e) { - let status = e.target.getAttribute('data-val'); - if (status == "PublicView") { - this.PublicView(); - } - else - $.ajax({ - type: 'POST', - url: "/Wiki/Admin_Wiki_List", - data: { - status: status - }, - success: this.ajaxAdminWikiFetch.bind(this) - }); - } - - this.ajaxAdminWikiFetch = function (ob) { - $("#public").empty(); - if (ob.length == 0) { - $("#public").append(`

      You haven’t any wikies yet.

      `); - } - else { - $("#public").empty(); - for (let j = 0; j < ob.wikiCat.length; j++) { - let temp = 0; - let $divObj = $(`
      `); - $divObj.append(`
      ${ob.wikiCat[j].wikiCategory} - -
      `); - let $Form = $(`
      `); - for (let i = 0; i < ob.wikiList.length; i++) { - if (ob.wikiList[i].category == `${ob.wikiCat[j].wikiCategory}`) { - // var date = new Date(ob.wikiList[i].createdAt); - var date = ob.wikiList[i].createdAt.split("T"); - - $Form.append(` -
      -

      ${ob.wikiList[i].title}

      -

      Created On ${date[0]}

      -
      - `); - temp++; - } - } - if (temp == 0) { - $Form.append(`
      Empty List
      `); - } - $divObj.append($Form); - $("#public").append($divObj); - } - } - this.Draftcontextmenu(); - - this.Publishcontextmenu(); - - this.Unpublishcontextmenu(); - $("#eb_common_loader").EbLoader("hide"); - - } - - this.PublicView = function () { - $.ajax({ - type: 'POST', - url: "/Wiki/PublicView", - data: { - status: status - }, - success: this.ajaxPublicViewSuccess.bind(this) - }); - } - - this.ajaxPublicViewSuccess = function (ob) { - - $("#public").empty(); - - for (let j = 0; j < ob.wikiCat.length; j++) { - let temp = 0; - let $divObj = $(`
      `); - $divObj.append(`
      ${ob.wikiCat[j].wikiCategory} - -
      `); - let $Form = $(`
        `); - for (let i = 0; i < ob.wikiList.length; i++) { - if (ob.wikiList[i].category == `${ob.wikiCat[j].wikiCategory}`) { - $Form.append(`
      • ${ob.wikiList[i].title}
      • `); - temp++; - } - } - - if (temp == 0) { - $Form.append(`
        Empty List
        `); - } - - $divObj.append($Form); - $("#public").append($divObj); - let dataVal = ob.wikiCat[j].wikiCategory; - this.draggableFun(dataVal); - } - - $("#public").append(``); - - - $("#eb_common_loader").EbLoader("hide"); - } - - this.draggableFun = function (dataVal) { - $(`[data-val="${dataVal}"]`).sortable(); - $(`[data-val="${dataVal}"]`).disableSelection(); - } - - //Context menu Wiki - this.Draftcontextmenu = function () { - $.contextMenu({ - selector: '.Draft', - trigger: 'right', - items: { - "edit": { - name: "edit", icon: "edit", callback: this.editWiki.bind(this) - }, - "publish": { - name: "publish", icon: "cut", callback: this.PublishWiki.bind(this) - }, - - } - }); - } - - this.Publishcontextmenu = function () { - $.contextMenu({ - selector: '.Publish', - trigger: 'right', - items: { - "edit": { - name: "edit", icon: "edit", callback: this.editWiki.bind(this) - }, - "Unpublish": { - name: "Unpublish", icon: "delete", callback: this.UnpublishWiki.bind(this) - - }, - - } - }); - } - - this.Unpublishcontextmenu = function () { - $.contextMenu({ - selector: '.Unpublish', - trigger: 'right', - items: { - "edit": { - name: "edit", icon: "edit", callback: this.editWiki.bind(this) - }, - "publish": { - name: "publish", icon: "cut", callback: this.PublishWiki.bind(this) - - }, - - } - }); - } - - this.editWiki = function (key, options) { - let id = $(options.$trigger).attr("data-id"); - let url = window.location.origin + "/wiki/add/" + id - window.open(window.location.origin + "/wiki/add/" + id, '_blank'); - }; - - this.PublishWiki = function (key, options) { - let id = $(options.$trigger).attr("data-id"); - let status = $(options.$trigger).attr("val"); - - $.ajax({ - type: 'POST', - url: "/Wiki/Publish_wiki", - data: { - wiki_id: id, - wiki_status: status - - }, - success: function (ob) { - if (ob.id != null) { - if (status == "Draft") { - $("[style-val=Draft]").click(); - } - else { - $("[style-val=Unpublish]").click(); - } - } - } - }); - }; - - this.UnpublishWiki = function (key, options) { - let id = $(options.$trigger).attr("data-id"); - let status = $(options.$trigger).attr("val"); - $.ajax({ - type: 'POST', - url: "/Wiki/Publish_wiki", - data: { - wiki_id: id, - wiki_status: status - }, - success: function (ob) { - if (ob.id != null) { - - $("[style-val=Publish]").click(); - } - } - }); - }; - - this.WikiMenuToggle = function (e) { - let togVal = e.target.getAttribute("toggleval"); - let val = e.target.getAttribute('val'); - if (togVal == "show") { - $(`[val="${val}"]`).removeAttr("toggleval").attr("toggleval", "hide"); - $(`[val="${val}"] i`).removeClass("fa-chevron-circle-down").addClass("fa-chevron-circle-right"); - } - else { - $(`[val="${val}"]`).removeAttr("toggleval").attr("toggleval", "show"); - $(`[val="${val}"] i`).removeClass("fa-chevron-circle-right").addClass("fa-chevron-circle-down"); - - } - - $(`[data-val=${val}]`).toggle(300); - } - - this.UpdateOrder = function (e) { - $("#eb_common_loader").EbLoader("show"); - var myList = []; - $(".ui-state-default").each(function () { - //alert($(this).attr("wiki-id")) - myList.push($(this).attr("wiki-id")); - }); - - $.ajax( - { - url: '/Wiki/UpdateOrder', - type: 'POST', - data: { myList: JSON.stringify(myList) }, - success: function (data) { - if (data == true) { - EbPopBox("show", { - Message: "Success...", - ButtonStyle: { - Text: "Ok", - Color: "white", - Background: "#508bf9", - Callback: function () { - } - } - }); - $("#eb_common_loader").EbLoader("hide"); - } - else { - EbPopBox("show", { - Message: "Failed to update the order...", - ButtonStyle: { - Text: "Ok", - Color: "white", - Background: "#508bf9", - Callback: function () { - } - } - }); - - $("#eb_common_loader").EbLoader("hide"); - } - - } - }); - } - - this.WikiAdminMenuBarHighlight = function (e) { - $("#eb_common_loader").EbLoader("show"); - let style_val = e.target.getAttribute("style-val"); - if (style_val == "PublicView") { - this.PublicView(); - } - else - this.WikiAdminMenuBarHighlightAjax(style_val); - } - - this.WikiAdminMenuBarHighlightAjax = function (style_val) { - $.ajax({ - type: 'POST', - url: "/Wiki/Admin_Wiki_List", - data: { - status: style_val - }, - success: this.ajaxAdminWikiFetch.bind(this) - }); - } - - this.SearchWithTagFun = function (e) { - let val = e.target.getAttribute('val'); - $("#search_wiki").val(val); - $("#search_wiki").focus(); - $("#search_wiki").click(); - } - - this.WasItHelp = function (e) { - let answer = e.target.getAttribute("val"); - $("#Help").hide(); - $("#EbHelp").show(); - $.ajax({ - type: 'POST', - url: "/Wiki/UserReviewRate", - data: { - answer: answer - }, - success: this.ajaxUserReviewRateSuccess.bind(this) - }); - } - - this.ajaxUserReviewRateSuccess = function () { - - } - - this.GetStartToWikiDocs = function (e) { - let value = $(e.target).closest(".GettingStarted").attr("val"); - $(`#${value}>ul>li:first>a`).click(); - } - - this.NextAndPreWiki = function (e) { - let OrderId = e.target.getAttribute("Next-id"); - let dataId = $(`[order-id="${OrderId}"]`).children().attr("data-id"); - $(`[data-id="${dataId}"]`).click(); - } - - this.gallerytab = function () { - $("#gallery").click(); - } - - this.WikiPreviewTab = function () { - $("#preview").click(); - } - - this.EbloaderTrigger = function () { - $(".eb_common_loader").EbLoader("show"); - } - - this.SaveWiki = function () { - let sts = true; - let a = ""; - $("#eb_common_loader").EbLoader("show"); - var wiki = {}; - wiki["category"] = $("#category option:selected").text(); - wiki["CatId"] = $("#category").val(); - wiki["title"] = $("#title").val(); - wiki["status"] = $("#status option:selected").text(); - wiki["html"] = $("#text").val(); - wiki["tags"] = $("#tagbox").val(); - wiki["Id"] = $("#wiki-id").val(); - if (wiki["title"] == "") { - sts = false; - a = a + "Title/"; - } - if (wiki["status"] == "Select Status") { - sts = false; - a = a + "Status/"; - } - if (wiki["category"] == "Select Category") { - sts = false; - a = a + "Category"; - } - if (sts == true) { - this.SaveWikiTrue(wiki); - } - else { - EbPopBox("show", { - Message: "Enter " + a, - ButtonStyle: { - Text: "Ok", - Color: "white", - Background: "#508bf9", - Callback: function () { - } - } - }); - $("#eb_common_loader").EbLoader("hide"); - } - } - - this.SaveWikiTrue = function (wiki) { - $.ajax( - { - url: '/Wiki/Save', - type: 'POST', - data: { wiki: wiki }, - success: function (data) { - if (data.responseStatus === true) { - EbPopBox("show", { - Message: "Success...", - ButtonStyle: { - Text: "Ok", - Color: "white", - Background: "#508bf9", - Callback: function () { - let url = window.location.origin + "/Wiki/add/" + data.wiki.id; - window.location.replace(url); - } - } - }); - $("#eb_common_loader").EbLoader("hide"); - } - else { - EbPopBox("show", { - Message: "Failed to Save", - ButtonStyle: { - Text: "Ok", - Color: "white", - Background: "#508bf9", - Callback: function () { - } - } - }); - $("#eb_common_loader").EbLoader("hide"); - } - } - }); - } - - - this.tbl_size_select = function (e) { - var cursorPos = $("#text").prop('selectionStart'); - let rows = $("#tbl-row").val(); - let cols = $("#tbl-col").val(); - let $tbl = $(`
        `); - for (i = 0; i < rows; i++) { - let $tblRow = $(" "); - if (i == 0) { - for (j = 0; j < cols; j++) { - $tblRow.append(" "); - } - $tbl.append($tblRow); - } - else { - for (j = 0; j < cols; j++) { - $tblRow.append(" "); - } - $tbl.append($tblRow); - } - - } - let insertVal = $tbl.outerHTML(); - this.insertAtCaret(insertVal, cursorPos); - - } - - this.ul_type_select = function () { - var cursorPos = $("#text").prop('selectionStart'); - let ul_row = $("#ul-row").val(); - let type = $("#ul-style-sel option:selected").text(); - let $ul = $(`
        `); - for (i = 0; i < ul_row; i++) { - $ul.append("
      • "); - } - let insertVal = $ul.outerHTML(); - this.insertAtCaret(insertVal, cursorPos); - } - - this.ol_type_select = function () { - var cursorPos = $("#text").prop('selectionStart'); - let ul_row = $("#ol-row").val(); - let type = $("#ol-style-sel option:selected").text(); - let $ul = $(`
        `); - for (i = 0; i < ul_row; i++) { - $ul.append("
      • "); - } - let insertVal = $ul.outerHTML(); - this.insertAtCaret(insertVal, cursorPos); - } - - this.InternalLinksFun = function () { - $.ajax({ - type: 'POST', - url: "/Wiki/Admin_Wiki_List", - data: { - status: 'Publish' - }, - success: this.AjaxInternalLinksFun.bind(this) - }); - } - - this.AjaxInternalLinksFun = function (ob) { - $("#internal-links-view").empty(); - if (ob.length == 0) { - $("#internal-links-view").append(` -

        You haven’t any wikies yet.

        - `) - } - else { - - - $("#internal-links-view").empty(); - - for (let j = 0; j < ob.wikiCat.length; j++) { - let temp = 0; - let $divObj = $(`
        `); - $divObj.append(`
        ${ob.wikiCat[j].wikiCategory} - -
        `); - let $Form = $(`
        `); - for (let i = 0; i < ob.wikiList.length; i++) { - if (ob.wikiList[i].category == `${ob.wikiCat[j].wikiCategory}`) { - // var date = new Date(ob.wikiList[i].createdAt); - var date = ob.wikiList[i].createdAt.split("T"); - - $Form.append(` -
        -

        ${ob.wikiList[i].title}

        -
        - `); - temp++; - } - } - if (temp == 0) { - $Form.append(`
        Empty List
        `); - } - - $divObj.append($Form); - $("#internal-links-view").append($divObj); - } - } - this.InternalLinkContextMenu(); - $("#eb_common_loader").EbLoader("hide"); - - } - - this.InternalLinkContextMenu = function () { - $.contextMenu({ - selector: '.Publish', - trigger: 'right', - items: { - "edit": { - name: "Copy", icon: "copy", callback: this.CopyInternalLink.bind(this) - }, - } - }); - } - - this.CopyInternalLink = function (key, options) { - let id = $(options.$trigger).attr("data-id"); - let title = $(options.$trigger).attr("val"); - let link = ` ${title} ` - copyStringToClipboard(link); - }; - - this.copyStringToClipboard = function (str) { - var el = document.createElement('textarea'); - el.value = str; - el.setAttribute('readonly', ''); - el.style = { position: 'absolute', left: '-9999px' }; - document.body.appendChild(el); - el.select(); - document.execCommand('copy'); - document.body.removeChild(el); - } - - var $highlights = $('.highlights'); - var $textarea = $('#text'); - // yeah, browser sniffing sucks, but there are browser-specific quirks to handle that are not a matter of feature detection - var ua = window.navigator.userAgent.toLowerCase(); - var isIE = !!ua.match(/msie|trident\/7|edge/); - var isWinPhone = ua.indexOf('windows phone') !== -1; - var isIOS = !isWinPhone && !!ua.match(/ipad|iphone|ipod/); - - this.applyHighlights = function (text) { - text = text - .replace(/\n$/g, '\n\n') - .replace(/<[^>]*>/g, '$&') - .replace(/<\s*[a-z].*?>/g, '$&') - .replace(/<\s*\/\s*\w\s*.*?>|<\s*br\s*>/g, '$&'); - - if (isIE) { - // IE wraps whitespace differently in a div vs textarea, this fixes it - text = text.replace(/ /g, ' '); - } - - return text; - } - - this.handleInput = function () { - var text = $textarea.val(); - var text = text.replace(/\>/g, '>'); - var text = text.replace(/\
        '); - this.$input = $('').appendTo(this.$container); - - this.$element.before(this.$container); - - this.build(options); - this.isInit = false; - } - - TagsInput.prototype = { - constructor: TagsInput, - - /** - * Adds the given item as a new tag. Pass true to dontPushVal to prevent - * updating the elements val() - */ - add: function(item, dontPushVal, options) { - var self = this; - - if (self.options.maxTags && self.itemsArray.length >= self.options.maxTags) - return; - - // Ignore falsey values, except false - if (item !== false && !item) - return; - - // Trim value - if (typeof item === "string" && self.options.trimValue) { - item = $.trim(item); - } - - // Throw an error when trying to add an object while the itemValue option was not set - if (typeof item === "object" && !self.objectItems) - throw("Can't add objects when itemValue option is not set"); - - // Ignore strings only containg whitespace - if (item.toString().match(/^\s*$/)) - return; - - // If SELECT but not multiple, remove current tag - if (self.isSelect && !self.multiple && self.itemsArray.length > 0) - self.remove(self.itemsArray[0]); - - if (typeof item === "string" && this.$element[0].tagName === 'INPUT') { - var delimiter = (self.options.delimiterRegex) ? self.options.delimiterRegex : self.options.delimiter; - var items = item.split(delimiter); - if (items.length > 1) { - for (var i = 0; i < items.length; i++) { - this.add(items[i], true); - } - - if (!dontPushVal) - self.pushVal(self.options.triggerChange); - return; - } - } - - var itemValue = self.options.itemValue(item), - itemText = self.options.itemText(item), - tagClass = self.options.tagClass(item), - itemTitle = self.options.itemTitle(item); - - // Ignore items allready added - var existing = $.grep(self.itemsArray, function(item) { return self.options.itemValue(item) === itemValue; } )[0]; - if (existing && !self.options.allowDuplicates) { - // Invoke onTagExists - if (self.options.onTagExists) { - var $existingTag = $(".badge", self.$container).filter(function() { return $(this).data("item") === existing; }); - self.options.onTagExists(item, $existingTag); - } - return; - } - - // if length greater than limit - if (self.items().toString().length + item.length + 1 > self.options.maxInputLength) - return; - - // raise beforeItemAdd arg - var beforeItemAddEvent = $.Event('beforeItemAdd', { item: item, cancel: false, options: options}); - self.$element.trigger(beforeItemAddEvent); - if (beforeItemAddEvent.cancel) - return; - - // register item in internal array and map - self.itemsArray.push(item); - - // add a tag element - - var $tag = $('' + htmlEncode(itemText) + ''); - $tag.data('item', item); - self.findInputWrapper().before($tag); - - // Check to see if the tag exists in its raw or uri-encoded form - var optionExists = ( - $('option[value="' + encodeURIComponent(itemValue) + '"]', self.$element).length || - $('option[value="' + htmlEncode(itemValue) + '"]', self.$element).length - ); - - // add
        +*@ + + +
        From 2f35540e1557556eada94720ae5e2c56f486df4b Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Fri, 17 Oct 2025 00:57:03 +0530 Subject: [PATCH 46/58] removed the wiki ref. --- Views/Shared/PageFooter.cshtml | 1 - 1 file changed, 1 deletion(-) diff --git a/Views/Shared/PageFooter.cshtml b/Views/Shared/PageFooter.cshtml index 54a5f4b26..1461902ff 100644 --- a/Views/Shared/PageFooter.cshtml +++ b/Views/Shared/PageFooter.cshtml @@ -31,7 +31,6 @@
      • Home
      • About us
      • Blog
      • -
      • Wiki
      • FAQ
      • Support
      • From 4ecef20eea0ee82233adbf49d4d0ed5876ff7806 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Fri, 17 Oct 2025 00:57:39 +0530 Subject: [PATCH 47/58] added new loaders --- wwwroot/js/Common/EbFrostGlassLoader.js | 97 +++++++++++++++++ wwwroot/js/Common/EbFunnyGlassLoader.js | 136 ++++++++++++++++++++++++ 2 files changed, 233 insertions(+) create mode 100644 wwwroot/js/Common/EbFrostGlassLoader.js create mode 100644 wwwroot/js/Common/EbFunnyGlassLoader.js diff --git a/wwwroot/js/Common/EbFrostGlassLoader.js b/wwwroot/js/Common/EbFrostGlassLoader.js new file mode 100644 index 000000000..5a932c036 --- /dev/null +++ b/wwwroot/js/Common/EbFrostGlassLoader.js @@ -0,0 +1,97 @@ +class EbFrostGlassLoader { + constructor({ + blur = 10, + brightness = 1.1, + saturate = 1.2, + background = 'rgba(255,255,255,0.2)', + border = '1px solid rgba(255,255,255,0.3)', + boxShadow = '0 4px 30px rgba(0, 0, 0, 0.1)', + borderRadius = '16px', + zIndex = 2147483647, + blockScroll = true, + showSpinner = true, + autoTimeout = 0 + } = {}) { + this.opts = { blur, brightness, saturate, background, border, boxShadow, borderRadius, zIndex, blockScroll, showSpinner, autoTimeout }; + this._overlayId = 'expressbase-blur-overlay'; + this._styleId = 'expressbase-blur-style'; + this._timer = null; + } + + attach() { + if (this.isActive()) return; + const ensure = () => { + this.#injectStyle(); + + const overlay = document.createElement('div'); + overlay.id = this._overlayId; + overlay.setAttribute('role', 'presentation'); + overlay.tabIndex = -1; + + Object.assign(overlay.style, { + position: 'fixed', + inset: '0', + zIndex: String(this.opts.zIndex), + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: this.opts.background, + backdropFilter: `blur(${this.opts.blur}px) brightness(${this.opts.brightness}) saturate(${this.opts.saturate})`, + WebkitBackdropFilter: `blur(${this.opts.blur}px) brightness(${this.opts.brightness}) saturate(${this.opts.saturate})`, + border: this.opts.border, + borderRadius: this.opts.borderRadius, + boxShadow: this.opts.boxShadow, + pointerEvents: 'auto', + animation: 'fadeInGlass 0.3s ease-out', + }); + + if (this.opts.showSpinner) { + const spin = document.createElement('div'); + spin.className = 'expressbase-blur-spinner'; + overlay.appendChild(spin); + } + + if (this.opts.blockScroll) document.documentElement.style.overflow = 'hidden'; + + document.body.appendChild(overlay); + + if (this.opts.autoTimeout > 0) + this._timer = setTimeout(() => this.detach(), this.opts.autoTimeout); + }; + if (!document.body) window.addEventListener('DOMContentLoaded', ensure, { once: true }); + else ensure(); + } + + detach() { + const overlay = document.getElementById(this._overlayId); + if (!overlay) return; + if (this._timer) clearTimeout(this._timer); + overlay.remove(); + document.documentElement.style.overflow = ''; + } + + isActive() { return !!document.getElementById(this._overlayId); } + + #injectStyle() { + if (document.getElementById(this._styleId)) return; + const style = document.createElement('style'); + style.id = this._styleId; + style.textContent = ` + #${this._overlayId} .expressbase-blur-spinner { + width: 40px; height: 40px; + border-radius: 50%; + border: 4px solid rgba(255,255,255,0.4); + border-top-color: rgba(255,255,255,0.8); + animation: spin 1s linear infinite; + } + @keyframes spin { + to { transform: rotate(360deg); } + } + @keyframes fadeInGlass { + from { opacity: 0; } + to { opacity: 1; } + } + `; + document.head.appendChild(style); + } +} \ No newline at end of file diff --git a/wwwroot/js/Common/EbFunnyGlassLoader.js b/wwwroot/js/Common/EbFunnyGlassLoader.js new file mode 100644 index 000000000..48fbf507f --- /dev/null +++ b/wwwroot/js/Common/EbFunnyGlassLoader.js @@ -0,0 +1,136 @@ +class EbFunnyGlassLoader { + constructor({ + zIndex = 2147483647, + blockScroll = true, + autoTimeout = 0 + } = {}) { + this.opts = { zIndex, blockScroll, autoTimeout }; + this._overlayId = 'eb-funky-frost-overlay'; + this._styleId = 'eb-funky-frost-style'; + this._timer = null; + this._beat = null; + } + + attach() { + if (this.isActive()) return; + const ensure = () => { + this.#injectStyle(); + + const overlay = document.createElement('div'); + overlay.id = this._overlayId; + + Object.assign(overlay.style, { + position: 'fixed', + inset: '0', + zIndex: this.opts.zIndex, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + backdropFilter: 'blur(20px) brightness(1.2)', + WebkitBackdropFilter: 'blur(20px) brightness(1.2)', + animation: 'funky-bg 6s linear infinite', + overflow: 'hidden' + }); + + const dj = document.createElement('div'); + dj.className = 'dj'; + dj.textContent = this.#randomEmoji(); + + const msg = document.createElement('div'); + msg.className = 'funky-text'; + msg.textContent = this.#randomMessage(); + + overlay.appendChild(dj); + overlay.appendChild(msg); + document.body.appendChild(overlay); + + if (this.opts.blockScroll) document.documentElement.style.overflow = 'hidden'; + this.#startFunk(dj, msg); + + if (this.opts.autoTimeout > 0) + this._timer = setTimeout(() => this.detach(), this.opts.autoTimeout); + }; + + if (!document.body) window.addEventListener('DOMContentLoaded', ensure, { once: true }); + else ensure(); + } + + detach() { + if (this._timer) clearTimeout(this._timer); + if (this._beat) clearInterval(this._beat); + const overlay = document.getElementById(this._overlayId); + if (overlay) overlay.remove(); + document.documentElement.style.overflow = ''; + } + + isActive() { + return !!document.getElementById(this._overlayId); + } + + #startFunk(dj, msg) { + let step = 0; + + const emojis = ['🔧', '⏰', '⏳']; + + const messages = [ + 'കിട്ടും... കിട്ടും... കുറച്ച് കഴിഞ്ഞിട്ട് കിട്ടും', + 'ഇപ്പോ ശരിയാക്കിത്തരാം' + ]; + + + this._beat = setInterval(() => { + dj.textContent = emojis[step % emojis.length]; + msg.textContent = messages[Math.floor(Math.random() * messages.length)]; + step++; + }, 1500); + } + + #randomEmoji() { + const arr = ['🔧', '⏰', '⏳']; + return arr[Math.floor(Math.random() * arr.length)]; + } + + #randomMessage() { + const arr = [ + 'കിട്ടും... കിട്ടും... കുറച്ച് കഴിഞ്ഞിട്ട് കിട്ടും', + 'ഇപ്പോ ശരിയാക്കിത്തരാം' + ]; + return arr[Math.floor(Math.random() * arr.length)]; + } + + #injectStyle() { + if (document.getElementById(this._styleId)) return; + const style = document.createElement('style'); + style.id = this._styleId; + style.textContent = ` + @keyframes funky-bg { + 0% { background: linear-gradient(135deg, #ff00ff, #00ffff); } + 25% { background: linear-gradient(135deg, #00ffff, #ff8800); } + 50% { background: linear-gradient(135deg, #ff8800, #00ff66); } + 75% { background: linear-gradient(135deg, #00ff66, #ff00ff); } + 100% { background: linear-gradient(135deg, #ff00ff, #00ffff); } + } + @keyframes bop { + 0%,100% { transform: scale(1) rotate(0deg); } + 50% { transform: scale(1.3) rotate(10deg); } + } + @keyframes glow { + 0%,100% { text-shadow: 0 0 8px #fff, 0 0 12px #ff00ff; } + 50% { text-shadow: 0 0 18px #0ff, 0 0 28px #ff0080; } + } + #${this._overlayId} .dj { + font-size: 72px; + animation: bop 0.8s ease-in-out infinite; + } + #${this._overlayId} .funky-text { + margin-top: 20px; + font-family: 'Comic Sans MS', 'Comic Neue', cursive; + font-size: 22px; + color: white; + text-align: center; + animation: glow 1.4s ease-in-out infinite; + } + `; + document.head.appendChild(style); + } +} \ No newline at end of file From d134c1c8b4593bcee1141d5452f606602ce7f061 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Fri, 17 Oct 2025 00:58:00 +0530 Subject: [PATCH 48/58] added a lang file for messages --- wwwroot/js/Common/EbMessages.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 wwwroot/js/Common/EbMessages.js diff --git a/wwwroot/js/Common/EbMessages.js b/wwwroot/js/Common/EbMessages.js new file mode 100644 index 000000000..f5d22b207 --- /dev/null +++ b/wwwroot/js/Common/EbMessages.js @@ -0,0 +1,12 @@ +class EbMessages { + static data = { + somethingWentWrongJSRefresh: "Something went wrong, kindly do a hard refresh (Ctrl + Shift + R)", + networkError: "Network error. Please check your connection.", + unauthorized: "You are not authorized to perform this action.", + }; + + static get(key) { + return this.data[key] || "Unknown message key."; + } +} + From 29f891cc0eb855f9b59e2f7aff741b68d2ff262c Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Fri, 17 Oct 2025 00:58:11 +0530 Subject: [PATCH 49/58] optimised the API client --- .../js/Common/Helpers/EbApiClientHelper.js | 61 ++++++++++++------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/wwwroot/js/Common/Helpers/EbApiClientHelper.js b/wwwroot/js/Common/Helpers/EbApiClientHelper.js index 6b05b2f5d..28c4b5565 100644 --- a/wwwroot/js/Common/Helpers/EbApiClientHelper.js +++ b/wwwroot/js/Common/Helpers/EbApiClientHelper.js @@ -1,42 +1,61 @@ class EbApiClientHelper { - constructor(baseUrl = '') { + constructor(baseUrl = '', defaultTimeout = 10000) { this.baseUrl = baseUrl; + this.defaultTimeout = defaultTimeout; } async request(endpoint, options = {}) { + const controller = new AbortController(); + const timeout = options.timeout ?? this.defaultTimeout; + const signal = controller.signal; + // Construct final URL with query params let url = this.baseUrl + endpoint; if (options.query) { const qs = new URLSearchParams(options.query).toString(); url += (url.includes('?') ? '&' : '?') + qs; } + // Prepare headers const headers = { 'Content-Type': 'application/json', ...(options.headers || {}) }; - const resp = await fetch(url, { - method: options.method || 'POST', - headers, - body: options.body ? JSON.stringify(options.body) : undefined, - credentials: options.credentials || 'same-origin' - }); - - if (!resp.ok) { - let errText = `${resp.status} ${resp.statusText}`; - try { - const errJson = await resp.json(); - if (errJson.message) errText = errJson.message; - } catch (_) {} - throw new Error(errText); - } + // Setup timeout + const timeoutId = setTimeout(() => controller.abort(), timeout); + + try { + const resp = await fetch(url, { + method: options.method || 'POST', + headers, + body: options.body ? JSON.stringify(options.body) : undefined, + credentials: options.credentials || 'same-origin', + signal + }); + + clearTimeout(timeoutId); + + if (!resp.ok) { + let errText = `${resp.status} ${resp.statusText}`; + try { + const errJson = await resp.json(); + if (errJson.message) errText = errJson.message; + } catch (_) {} + throw new Error(errText); + } + + const contentType = resp.headers.get('content-type') || ''; + return contentType.includes('application/json') + ? await resp.json() + : await resp.text(); - const contentType = resp.headers.get('content-type') || ''; - if (contentType.includes('application/json')) { - return await resp.json(); - } else { - return await resp.text(); + } catch (err) { + clearTimeout(timeoutId); + if (err.name === 'AbortError') { + throw new Error(`Request timed out after ${timeout} ms`); + } + throw err; } } } From 96cea9c88a9c473ec676e5f1c8fc4440dfa6e77c Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Fri, 17 Oct 2025 00:58:37 +0530 Subject: [PATCH 50/58] removed the ref. to old copy pub from url modal --- wwwroot/js/Eb_ObjectCommon.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/wwwroot/js/Eb_ObjectCommon.js b/wwwroot/js/Eb_ObjectCommon.js index 6c9683c2a..55f9838dd 100644 --- a/wwwroot/js/Eb_ObjectCommon.js +++ b/wwwroot/js/Eb_ObjectCommon.js @@ -36,9 +36,9 @@ $('#singlesave').off('click').on('click', this.SingleSave.bind(this)); $('#offline').off('click').on('click', this.MakeOffline.bind(this)); $('#live').off('click').on('click', this.MakeLive.bind(this)); - $('#make_public').off('click').on('click', this.MakePublic.bind(this)); - $('#make_private').off('click').on('click', this.MakePrivate.bind(this)); - $('#copy_url').off('click').on('click', this.OpenUrlContainer.bind(this)); + //$('#make_public').off('click').on('click', this.MakePublic.bind(this)); + //$('#make_private').off('click').on('click', this.MakePrivate.bind(this)); + //$('#copy_url').off('click').on('click', this.OpenUrlContainer.bind(this)); $('#clone').off('click').on('click', this.Clone.bind(this)); if (this.Current_obj !== null) @@ -769,7 +769,8 @@ }.bind(this)); }; - this.MakePublic = function () { + //TODO: TestAndRemoveInTheNextDeployment + /*this.MakePublic = function () { $("#eb_common_loader").EbLoader("show"); $.post("../Eb_Object/ChangeAccess", { @@ -789,9 +790,10 @@ } $("#eb_common_loader").EbLoader("hide"); }.bind(this)); - }; + };*/ - this.MakePrivate = function () { + //TODO: TestAndRemoveInTheNextDeployment + /*this.MakePrivate = function () { $("#eb_common_loader").EbLoader("show"); $.post("../Eb_Object/ChangeAccess", { @@ -811,11 +813,12 @@ } $("#eb_common_loader").EbLoader("hide"); }.bind(this)); - }; + };*/ - this.OpenUrlContainer = function () { + //TODO: TestAndRemoveInTheNextDeployment + /*this.OpenUrlContainer = function () { $('#url-container').show(); - }; + };*/ this.Clone = function () { EbDialog("show", From e1b0dd4f452bdfdc211e64ae44fc77b0030e3b6a Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Fri, 17 Oct 2025 00:58:57 +0530 Subject: [PATCH 51/58] commented out server events --- wwwroot/js/EbDashBoards/AppDashBoard.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wwwroot/js/EbDashBoards/AppDashBoard.js b/wwwroot/js/EbDashBoards/AppDashBoard.js index aa1735257..dcc2547a7 100644 --- a/wwwroot/js/EbDashBoards/AppDashBoard.js +++ b/wwwroot/js/EbDashBoards/AppDashBoard.js @@ -496,6 +496,7 @@ }; this.DpImageUpload = function () { + /* var dpImg = new EbFileUpload({ Type: "image", Toggle: "#dpBrowse", @@ -519,10 +520,14 @@ } }; + + */ }; this.BgImageUpload = function () { + /* + var bgimg = new EbFileUpload({ Type: "image", Toggle: "#bgimg_btn", @@ -554,6 +559,8 @@ //img.src = URL.createObjectURL(this.files[i]); //img.height = 60; }; + + */ }; $("input[name='bgradio']").click(function () { From 91c434658d5d40641824b49e10d4021e788ce4d2 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Fri, 17 Oct 2025 00:59:18 +0530 Subject: [PATCH 52/58] commented out server events --- wwwroot/js/location-config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wwwroot/js/location-config.js b/wwwroot/js/location-config.js index bfb631b6d..48c9d5f27 100644 --- a/wwwroot/js/location-config.js +++ b/wwwroot/js/location-config.js @@ -112,6 +112,7 @@ this.imageUploader = function (container, toggle, prev, extra, viwportresize) { let resize = viwportresize ? true : false; + /* this.Cropies[extra.Name] = new EbFileUpload({ Type: "image", Toggle: toggle, @@ -127,6 +128,7 @@ Context: "location",//if single and crop ResizeViewPort: false //if single and crop }); + */ this.Cropies[extra.Name].uploadSuccess = function (fileid) { $("#loc_logoId").val(""); From 0610bce7ffc8a7d793953093fbf1bfa0b481746c Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 20 Oct 2025 20:17:36 +0530 Subject: [PATCH 53/58] Revert "platform optimizations " --- BaseControllers/EbBaseController.cs | 15 +- BaseControllers/EbBaseExtController.cs | 4 +- BaseControllers/EbBaseIntCommonController.cs | 5 - Controllers/CalendarController.cs | 2 +- Controllers/ConnectionManagerController.cs | 4 +- .../ControllersV2/Api/BuilderApiController.cs | 27 -- .../ControllersV2/HealthCheckController.cs | 86 ----- .../InternalExceptionController.cs | 89 ----- .../ControllersV2/PublicFormController.cs | 73 ---- Controllers/Eb_ObjectController.cs | 87 +---- Controllers/StaticFileController.cs | 7 +- Controllers/WebFormController.cs | 81 ++-- Filters/ApiUserAuthenticationFilter.cs | 156 -------- Filters/PublicUserAuthenticationFilter.cs | 175 --------- Filters/SolutionContextFilter.cs | 67 ---- Helpers/AppConfigViewHelper.cs | 11 +- Helpers/EbPublicFormHelper.cs | 31 -- Helpers/HttpContextHelper.cs | 76 ---- Helpers/InternalExcepionHelper.cs | 78 ---- Helpers/UserAuthenticationHelper.cs | 170 -------- Middlewares/AppUrlContextMiddleware.cs | 28 +- Startup.cs | 4 - Views/Dev/AppDashBoard.cshtml | 6 +- Views/Docs/ImageUpHome.cshtml | 5 +- Views/Ext/SignUp.cshtml | 8 +- Views/Ext/TenantSignIn.cshtml | 8 +- Views/Ext/VerifyEmailSrtucture.cshtml | 1 + Views/ImportExport/ShareToPublic.cshtml | 2 - Views/InternalException/Index.cshtml | 364 ------------------ Views/Security/MyProfile.cshtml | 2 - .../Components/ObjectDashboard/Default.cshtml | 42 -- .../PageHeaderCommon/Default.cshtml | 18 +- Views/Shared/EbQuickMenu.cshtml | 5 + Views/Shared/ExtPageHeader.cshtml | 16 +- Views/Shared/LayoutBuilders.cshtml | 3 - Views/Shared/PageFooter.cshtml | 1 + Views/Shared/_EbCoreScripts.cshtml | 6 - Views/Tenant/SolutionManager.cshtml | 6 +- wwwroot/js/Common/EbFrostGlassLoader.js | 97 ----- wwwroot/js/Common/EbFunnyGlassLoader.js | 136 ------- wwwroot/js/Common/EbMessages.js | 12 - .../js/Common/Helpers/EbApiClientHelper.js | 61 +-- wwwroot/js/EbDashBoards/AppDashBoard.js | 7 - wwwroot/js/Eb_ObjectCommon.js | 21 +- .../EbPublicFormPropertyControl.js | 178 --------- wwwroot/js/FormBuilder/Eb_PropertyGrid.js | 145 +++---- wwwroot/js/FormBuilder/FormBuilder.js | 10 +- wwwroot/js/FormBuilder/InitFormControls.js | 2 +- wwwroot/js/location-config.js | 2 - 49 files changed, 219 insertions(+), 2221 deletions(-) delete mode 100644 Controllers/ControllersV2/Api/BuilderApiController.cs delete mode 100644 Controllers/ControllersV2/HealthCheckController.cs delete mode 100644 Controllers/ControllersV2/InternalExceptionController.cs delete mode 100644 Controllers/ControllersV2/PublicFormController.cs delete mode 100644 Filters/ApiUserAuthenticationFilter.cs delete mode 100644 Filters/PublicUserAuthenticationFilter.cs delete mode 100644 Filters/SolutionContextFilter.cs delete mode 100644 Helpers/EbPublicFormHelper.cs delete mode 100644 Helpers/HttpContextHelper.cs delete mode 100644 Helpers/InternalExcepionHelper.cs delete mode 100644 Helpers/UserAuthenticationHelper.cs delete mode 100644 Views/InternalException/Index.cshtml delete mode 100644 wwwroot/js/Common/EbFrostGlassLoader.js delete mode 100644 wwwroot/js/Common/EbFunnyGlassLoader.js delete mode 100644 wwwroot/js/Common/EbMessages.js delete mode 100644 wwwroot/js/FormBuilder/EbPublicFormPropertyControl.js diff --git a/BaseControllers/EbBaseController.cs b/BaseControllers/EbBaseController.cs index 249f04296..68ff0f302 100644 --- a/BaseControllers/EbBaseController.cs +++ b/BaseControllers/EbBaseController.cs @@ -7,7 +7,6 @@ using ExpressBase.Common.ServiceStack.Auth; using ExpressBase.Objects.ServiceStack_Artifacts; using ExpressBase.Security; -using ExpressBase.Web.Helpers; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; @@ -58,11 +57,11 @@ public string RequestSourceIp { get { - - return HttpContextHelper.GetIp(this.HttpContext); + string val = this.HttpContext.Request.Headers["X-Forwarded-For"]; + return string.IsNullOrWhiteSpace(val) ? string.Empty : val.Split(",")[0]; } } - + public string UserAgent { get @@ -187,9 +186,9 @@ public EbBaseController(IServiceClient _ssclient, IRedisClient _redis, IHttpCont public override void OnActionExecuting(ActionExecutingContext context) { - if (HttpContext.Items.ContainsKey(RoutingConstants.SUB_DOMAIN)) + if (HttpContext.Items.ContainsKey("SubDomain")) { - Host = HttpContext.Items[RoutingConstants.SUB_DOMAIN].ToString(); + Host = HttpContext.Items["SubDomain"].ToString(); } else { @@ -204,9 +203,9 @@ public override void OnActionExecuting(ActionExecutingContext context) .Replace(RoutingConstants.LOCALHOSTADDRESS, string.Empty); } - if (HttpContext.Items.ContainsKey(RoutingConstants.EXTERNAL_SOLUTION_ID)) + if (HttpContext.Items.ContainsKey("ExternalSolutionId")) { - ExtSolutionId = HttpContext.Items[RoutingConstants.EXTERNAL_SOLUTION_ID]?.ToString(); + ExtSolutionId = HttpContext.Items["ExternalSolutionId"]?.ToString(); } else diff --git a/BaseControllers/EbBaseExtController.cs b/BaseControllers/EbBaseExtController.cs index 951d585eb..428d029bc 100644 --- a/BaseControllers/EbBaseExtController.cs +++ b/BaseControllers/EbBaseExtController.cs @@ -46,10 +46,10 @@ public override void OnActionExecuting(ActionExecutingContext context) controller.ViewBag.HostValue = context.HttpContext.Request.Host.Value; controller.ViewBag.Env = Environment.GetEnvironmentVariable(EnvironmentConstants.ASPNETCORE_ENVIRONMENT); - if (HttpContext.Items.ContainsKey(RoutingConstants.DOMAIN) && HttpContext.Items.ContainsKey(RoutingConstants.SCHEME)) + if (HttpContext.Items.ContainsKey("Domain") && HttpContext.Items.ContainsKey("Scheme")) { - controller.ViewBag.Root = HttpContext.Items[RoutingConstants.SCHEME].ToString() + HttpContext.Items[RoutingConstants.DOMAIN].ToString(); + controller.ViewBag.Root = HttpContext.Items["Scheme"].ToString() + HttpContext.Items["Domain"].ToString(); } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/BaseControllers/EbBaseIntCommonController.cs b/BaseControllers/EbBaseIntCommonController.cs index 33bd5ea75..b9fc75b13 100644 --- a/BaseControllers/EbBaseIntCommonController.cs +++ b/BaseControllers/EbBaseIntCommonController.cs @@ -150,11 +150,6 @@ public override void OnActionExecuting(ActionExecutingContext context) controller.ViewBag.StaticFileServerUrl = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_STATICFILESERVER_EXT_URL); controller.ViewBag.BrowserURLContext = context.HttpContext.Request.Host.Value; - controller.ViewBag.SessionTag = - (bToken?.Payload != null && bToken.Payload.TryGetValue(TokenConstants.SESSION_TAG, out var value)) - ? value - : null; - this.LoggedInUser = this.GetUserObject(bToken.Payload[TokenConstants.SUB].ToString()); controller.ViewBag.UserDisplayName = this.LoggedInUser.FullName; diff --git a/Controllers/CalendarController.cs b/Controllers/CalendarController.cs index d80d60abf..8f03e52e5 100644 --- a/Controllers/CalendarController.cs +++ b/Controllers/CalendarController.cs @@ -41,7 +41,7 @@ public IActionResult CalendarView(string refid) RefId = refid }); ViewBag.Refid = refid; - ViewBag.VersionNumber = Resp.Data[0].VersionNumber; // TODO: add null check + ViewBag.VersionNumber = Resp.Data[0].VersionNumber; ViewBag.ObjType = Resp.Data[0].EbObjectType; ViewBag.dsObj = Resp.Data[0].Json; ViewBag.DisplayName = Resp.Data[0].DisplayName; diff --git a/Controllers/ConnectionManagerController.cs b/Controllers/ConnectionManagerController.cs index 073792be1..4a1a781de 100644 --- a/Controllers/ConnectionManagerController.cs +++ b/Controllers/ConnectionManagerController.cs @@ -791,10 +791,10 @@ public string AddGoogleDriveAsync() AuthorizationCodeFlow flow = new AuthorizationCodeFlow(init); Console.WriteLine("Fetching token for code: _" + req["code"] + "_"); - if (HttpContext.Items.ContainsKey(RoutingConstants.DOMAIN) && HttpContext.Items.ContainsKey(RoutingConstants.SCHEME)) + if (HttpContext.Items.ContainsKey("Domain") && HttpContext.Items.ContainsKey("Scheme")) { - RedirectUri = HttpContext.Items[RoutingConstants.SCHEME].ToString() + "myaccount." + HttpContext.Items[RoutingConstants.DOMAIN].ToString(); + RedirectUri = HttpContext.Items["Scheme"].ToString() + "myaccount." + HttpContext.Items["Domain"].ToString(); } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/Controllers/ControllersV2/Api/BuilderApiController.cs b/Controllers/ControllersV2/Api/BuilderApiController.cs deleted file mode 100644 index 18753cc01..000000000 --- a/Controllers/ControllersV2/Api/BuilderApiController.cs +++ /dev/null @@ -1,27 +0,0 @@ -using ExpressBase.Common; -using ExpressBase.Web.Filters; -using ExpressBase.Web.Helpers; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; - -namespace ExpressBase.Web.Controllers.ControllersV2.Api -{ - [Route("internal/api/v2/[controller]")] - [ApiController] - public class BuilderApiController : ControllerBase - { - [ServiceFilter(typeof(SolutionContextFilter))] - [TypeFilter(typeof(ApiUserAuthenticationFilter), Arguments = new object[] { RoutingConstants.DC })] - [HttpGet("GetPublicFormUrl")] - public IActionResult GetPublicFormUrl(string RefId) - { - var toReturn = new - { - RefId = RefId, - PublicFormUrl = EbPublicFormHelper.GenerateUrl(this.HttpContext,Url, RefId) - }; - - return Ok(toReturn); - } - } -} diff --git a/Controllers/ControllersV2/HealthCheckController.cs b/Controllers/ControllersV2/HealthCheckController.cs deleted file mode 100644 index f60204001..000000000 --- a/Controllers/ControllersV2/HealthCheckController.cs +++ /dev/null @@ -1,86 +0,0 @@ -using ExpressBase.Common.Helpers; -using ExpressBase.Web.Helpers; -using Microsoft.AspNetCore.Mvc; -using ServiceStack.Redis; -using System; - -namespace ExpressBase.Web.Controllers.ControllersV2 -{ - [ApiController] - [Route("v2/[controller]")] - public class HealthCheckController : ControllerBase - { - [HttpGet] - public IActionResult Index() - { - try - { - - string redisStatus = "Unknown"; - string testValue = null; - string testKey = "healthcheck:testkey"; - string testData = Guid.NewGuid().ToString(); - var serverTimeZone = TimeZoneInfo.Local; - var utcNow = DateTime.UtcNow; - var localNow = TimeZoneInfo.ConvertTimeFromUtc(utcNow, serverTimeZone); - - try - { - var sp = HttpContext != null ? HttpContext.RequestServices : null; - - if (sp?.GetService(typeof(PooledRedisClientManager)) is PooledRedisClientManager pooledRedisClientManager) - { - - var ttl = TimeSpan.FromSeconds(30); - RedisCacheHelper.SetRaw(pooledRedisClientManager, testKey, testData, ttl); - testValue = RedisCacheHelper.GetRaw(pooledRedisClientManager, testKey); - - redisStatus = testValue == testData ? "ReadWriteOK" : "ReadWriteMismatch"; - - } - else - { - redisStatus = "NoServiceProvider"; - } - } - catch (Exception ex) - { - redisStatus = "Error: " + ex.Message; - } - - var response = new - { - status = "Healthy", - timestamp = localNow, - timeZone = new - { - id = serverTimeZone.Id, - displayName = serverTimeZone.DisplayName - }, - environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Unknown", - machine = Environment.MachineName, - redis = new - { - status = redisStatus, - sampleValue = testValue, - ttlSeconds = 30 - }, - clientIp = HttpContextHelper.GetIp(this.HttpContext), - host = HttpContext.Items["Host"]?.ToString() - }; - - return Ok(response); - } - catch (Exception exception) - { - var response = new - { - status = "UnHealthy", - exception = exception.Message, - }; - - return Ok(response); - } - } - } -} diff --git a/Controllers/ControllersV2/InternalExceptionController.cs b/Controllers/ControllersV2/InternalExceptionController.cs deleted file mode 100644 index fa07c287a..000000000 --- a/Controllers/ControllersV2/InternalExceptionController.cs +++ /dev/null @@ -1,89 +0,0 @@ -using ExpressBase.Common.Helpers; -using ExpressBase.Web.Helpers; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; -using System; - -namespace ExpressBase.Web.Controllers.ControllersV2 -{ - [Microsoft.AspNetCore.Mvc.Route("v2/InternalException")] - [ApiExplorerSettings(IgnoreApi = true)] - public class InternalExceptionController : Controller - { - private readonly IHostingEnvironment _env; - private readonly IServiceProvider _serviceProvider; - private static readonly TimeSpan TicketTtl = TimeSpan.FromSeconds(90); - - public InternalExceptionController(IServiceProvider serviceProvider,IHostingEnvironment env) - { - _env = env; - _serviceProvider = serviceProvider; - } - - [HttpGet("{ticketId?}")] - //[RedisRateLimit(limit: 6, windowSeconds: 60, useIp: true, perPath: true, useExternalSolutionId: true, customKey: "internal_exceptions:v2")] - public IActionResult Index(string ticketId) - { - var isDev = _env.IsDevelopment(); - - if (HttpContextHelper.WantsJson(HttpContext)) - { - SerializableExceptionDto exception = null; - - if (StringHelper.HasValue(ticketId)) - { - exception = InternalExcepionHelper.Get(this, ticketId); - } - - var jsonResponse = new - { - IsDevelopment = isDev, - TicketId = ticketId, - Exception = isDev ? exception?.Message : "an excpetion oocurred", - StackTrace = isDev ? exception?.StackTrace : null, - InnerExcerption = isDev ? exception?.InnerException?.Message : null, - InnerExcerptionStackTrace = isDev ? exception?.InnerException?.StackTrace : null, - }; - - return new JsonResult(jsonResponse); - } - - - if (StringHelper.HasValue(ticketId)) - { - SerializableExceptionDto exception = InternalExcepionHelper.Get(this, ticketId); - - if (exception != null) - { - return View( - "~/Views/InternalException/Index.cshtml", - new InternalExceptionViewModel - { - IsDevelopment = isDev, - TicketId = ticketId, - Exception = exception - } - ); - } - } - - return View( - "~/Views/InternalException/Index.cshtml", - new InternalExceptionViewModel - { - IsDevelopment = isDev, - TicketId = ticketId - } - ); - } - - } - - public sealed class InternalExceptionViewModel - { - public bool IsDevelopment { get; set; } - public string TicketId { get; set; } - public SerializableExceptionDto Exception { get; set; } - } - -} diff --git a/Controllers/ControllersV2/PublicFormController.cs b/Controllers/ControllersV2/PublicFormController.cs deleted file mode 100644 index 63090a095..000000000 --- a/Controllers/ControllersV2/PublicFormController.cs +++ /dev/null @@ -1,73 +0,0 @@ -using ExpressBase.Common; -using ExpressBase.Common.Extensions; -using ExpressBase.Common.Helpers; -using ExpressBase.Objects.Dtos; -using ExpressBase.Web.Filters; -using ExpressBase.Web.Helpers; -using Microsoft.AspNetCore.Mvc; -using System; - -namespace ExpressBase.Web.Controllers.ControllersV2 -{ - [ServiceFilter(typeof(SolutionContextFilter))] - [ServiceFilter(typeof(PublicUserAuthenticationFilter))] - public class PublicFormController : Controller - { - [HttpGet("v2/PublicForm")] - public IActionResult Index(string publicFormQparams) - { - - try - { - - if(publicFormQparams == null) - { - throw new ArgumentNullException(nameof(publicFormQparams), "publicFormQparams is required"); - } - - string base64Key = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_AES_ENC_KEY) ?? throw new Exception(EnvironmentConstants.EB_AES_ENC_KEY + " EnvironmentConstant not found"); - - PublicFormV2QueryParamsDto dto = - QueryStringEncDecHelper.DecryptEncryptedString(publicFormQparams, base64Key); - - string publicFormRefId = dto.PublicFormRefId; - //string sourceFormRefId = publicFormV2QueryParamsDto.SourceFormRefId; - //int formDataId = publicFormV2QueryParamsDto.FormDataId; - - - if (StringHelper.HasValue(publicFormRefId) == false) - { - - throw new ArgumentNullException(nameof(publicFormRefId), "publicFormRefId is required"); - } - - string paramsToPrefillInPublicForm = String.Empty; - - if (dto.PrefillParams != null) - { - - paramsToPrefillInPublicForm = Newtonsoft.Json.JsonConvert.SerializeObject(dto.PrefillParams).ToBase64(); - } - - return RedirectToAction( - "Index", - "WebForm", - new - { - _r = publicFormRefId, - _p = paramsToPrefillInPublicForm, - _m = "2", - _l = "1", - _rm = "5" - } - ); - } - catch (Exception ex) - { - return InternalExcepionHelper.Redirect(ex, this, TimeSpan.FromSeconds(120)); - } - - } - - } -} diff --git a/Controllers/Eb_ObjectController.cs b/Controllers/Eb_ObjectController.cs index 74bd9f7bd..639ef9504 100644 --- a/Controllers/Eb_ObjectController.cs +++ b/Controllers/Eb_ObjectController.cs @@ -1,31 +1,27 @@ -using DiffPlex; -using DiffPlex.DiffBuilder; -using DiffPlex.DiffBuilder.Model; -using ExpressBase.Common; -using ExpressBase.Common.Constants; -using ExpressBase.Common.Helpers; -using ExpressBase.Common.LocationNSolution; -using ExpressBase.Common.Objects; -using ExpressBase.Common.SqlProfiler; -using ExpressBase.Common.Structures; -using ExpressBase.Objects; -using ExpressBase.Objects.Dtos; -using ExpressBase.Objects.Objects.DVRelated; -using ExpressBase.Objects.Objects.SmsRelated; -using ExpressBase.Objects.ServiceStack_Artifacts; -using ExpressBase.Web.BaseControllers; -using ExpressBase.Web.Filters; -using ExpressBase.Web.Helpers; -using iTextSharp.text; +using System; +using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; -using Newtonsoft.Json; using ServiceStack; using ServiceStack.Redis; -using System; -using System.Collections.Generic; +using ExpressBase.Common; +using ExpressBase.Objects.ServiceStack_Artifacts; +using ExpressBase.Common.Objects; +using ExpressBase.Objects; using System.Reflection; +using DiffPlex.DiffBuilder; +using DiffPlex; +using DiffPlex.DiffBuilder.Model; +using Newtonsoft.Json; using System.Text; +using ExpressBase.Common.Structures; +using ExpressBase.Web.BaseControllers; using System.Text.RegularExpressions; +using ExpressBase.Web.Filters; +using ExpressBase.Objects.Objects.SmsRelated; +using ExpressBase.Common.SqlProfiler; +using ExpressBase.Objects.Objects.DVRelated; +using ExpressBase.Common.LocationNSolution; +using ExpressBase.Common.Helpers; namespace ExpressBase.Web.Controllers { public class Eb_ObjectController : EbBaseIntCommonController @@ -37,7 +33,6 @@ public Eb_ObjectController(IServiceClient sclient, IRedisClient redis) : base(sc [HttpPost] public IActionResult Index(string objid, int objtype, bool buildermode = true) { - EbObjectWrapper element = new EbObjectWrapper(); if (ViewBag.wc == "dc") { ViewBag.al_arz_map_key = Environment.GetEnvironmentVariable(EnvironmentConstants.AL_GOOGLE_MAP_KEY); @@ -56,7 +51,7 @@ public IActionResult Index(string objid, int objtype, bool buildermode = true) { ViewBag.Obj_id = objid; EbObjectExploreObjectResponse resultlist = ServiceClient.Get(new EbObjectExploreObjectRequest { Id = Convert.ToInt32(objid) }); - element = resultlist.Data; + EbObjectWrapper element = resultlist.Data; if (element != null) { ViewBag.IsNew = "false"; @@ -348,15 +343,6 @@ public IActionResult Index(string objid, int objtype, bool buildermode = true) EbWebForm _dsobj = _object as EbWebForm; _dsobj.AfterRedisGet(Redis, this.ServiceClient); ViewBag.dsObj = _dsobj; - - if(element.RefId != null && element.IsPublic == true) - { - - - ViewBag.PublicFormUrl = EbPublicFormHelper.GenerateUrl(this.HttpContext, Url, element.RefId); - } - - } else if (_object is EbUserControl) { @@ -365,7 +351,6 @@ public IActionResult Index(string objid, int objtype, bool buildermode = true) ViewBag.dsObj = _dsobj; } } - ViewBag.Meta = _c2js.AllMetas; ViewBag.JsObjects = _c2js.JsObjects; ViewBag.EbObjectTypes = _c2js.EbObjectTypes; @@ -570,34 +555,6 @@ public EbRootObjectResponse CommitEbObject(string _refid, string _json, string _ _response.Refid = res.RefId; _response.Message = res.Message; } - - - if (obj is EbWebForm webForm && string.IsNullOrWhiteSpace(_response.Refid) == false) - { - int objectId = Convert.ToInt32(_response.Refid?.Split(CharConstants.DASH)[3]); - int status = ObjectConstants.WEB_FORM_PRIVATE_STATUS_CODE; - - if (objectId > 0) - { - if (webForm.IsPublicForm == true) - { - status = ObjectConstants.WEB_FORM_PUBLIC_STATUS_CODE; - } - - this.ServiceClient.Post( - new ChangeObjectAccessRequest - { - ObjId = objectId, - Status = status - } - ); - } - else - { - throw new Exception("unable to fetch objectId"); - } - - } } catch (Exception e) { @@ -934,11 +891,6 @@ public IActionResult UpdateObjectDashboard(string refid, bool versioning) EbObjectWrapper w = obj; ViewBag.IsPublic = w.IsPublic; ViewBag.workingMode = w.WorkingMode; - if(w.IsPublic == true) - { - ViewBag.PublicFormUrl = EbPublicFormHelper.GenerateUrl(this.HttpContext, Url, refid); - } - return ViewComponent("ObjectDashboard", new { refid, objname = w.Name, w.Status, vernum = w.VersionNumber, workcopies = w.Wc_All, _tags = w.Tags, _apps = w.Apps, _dashbord_tiles = w.Dashboard_Tiles, _versioning = versioning }); } @@ -1016,7 +968,6 @@ public IActionResult UpdateBuilder(string _refid, int _tabnum, int _ObjType, str versionObj = Redis.Get(_refid); return ViewComponent("MobilePage", new { dsobj = EbSerializers.Json_Serialize(versionObj), tabnum = _tabnum, type = _ObjType, refid = _refid, ssurl = _ssurl }); } - return View(); } diff --git a/Controllers/StaticFileController.cs b/Controllers/StaticFileController.cs index 099d5dca2..ea13eef37 100644 --- a/Controllers/StaticFileController.cs +++ b/Controllers/StaticFileController.cs @@ -53,12 +53,9 @@ public IActionResult GetLogo(string solnid) } [HttpGet("/wiki/images/{quality}/{refid}")] - [Obsolete] public IActionResult GetWikiImage(string refid, string quality) { - return new EmptyResult(); - - /*DownloadFileResponse dfs = null; + DownloadFileResponse dfs = null; ActionResult resp = new EmptyResult(); @@ -84,7 +81,7 @@ public IActionResult GetWikiImage(string refid, string quality) { Console.WriteLine("Exception: " + e.Message.ToString()); } - return resp;*/ + return resp; } [HttpGet("/botExt/images/{quality}/{refid}")] diff --git a/Controllers/WebFormController.cs b/Controllers/WebFormController.cs index c91e609e7..e1e2a8726 100644 --- a/Controllers/WebFormController.cs +++ b/Controllers/WebFormController.cs @@ -1,35 +1,34 @@ -using ExpressBase.Common; -using ExpressBase.Common.Constants; -using ExpressBase.Common.Data; -using ExpressBase.Common.Extensions; -using ExpressBase.Common.LocationNSolution; -using ExpressBase.Common.Objects; -using ExpressBase.Common.Objects.Attributes; -using ExpressBase.Common.ServerEvents_Artifacts; -using ExpressBase.Common.ServiceClients; -using ExpressBase.Common.Structures; -using ExpressBase.Objects; -using ExpressBase.Objects.Objects; -using ExpressBase.Objects.Objects.DVRelated; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using ExpressBase.Common; using ExpressBase.Objects.ServiceStack_Artifacts; -using ExpressBase.Objects.WebFormRelated; -using ExpressBase.Security; +using ExpressBase.Objects.Objects.DVRelated; using ExpressBase.Web.BaseControllers; -using ExpressBase.Web.Helpers; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Newtonsoft.Json; using ServiceStack; using ServiceStack.Redis; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; +using Newtonsoft.Json; +using ExpressBase.Common.Structures; +using ExpressBase.Objects; +using ExpressBase.Common.Objects; +using ExpressBase.Common.Extensions; +using System.Reflection; +using ExpressBase.Common.Objects.Attributes; +using ExpressBase.Common.Data; +using ExpressBase.Common.LocationNSolution; +using ExpressBase.Common.Constants; +using ExpressBase.Objects.Objects; using System.IO; -using System.Linq; using System.Net; -using System.Reflection; -using System.Threading.Tasks; +using ExpressBase.Common.ServerEvents_Artifacts; +using ExpressBase.Common.ServiceClients; +using ExpressBase.Security; +using System.Collections; +using ExpressBase.Objects.WebFormRelated; +using Microsoft.AspNetCore.Http; +using System.Globalization; namespace ExpressBase.Web.Controllers { @@ -39,29 +38,19 @@ public WebFormController(IServiceClient _ssclient, IRedisClient _redis, IEbServe public IActionResult Index(string _r, string _p, int _m, int _l, int _rm, string _lg) { - try - { - - string refId = _r, _params = _p, _language = _lg ?? this.CurrentLanguage ?? "en"; - int _mode = _m, _locId = _l; - string resp = GetFormForRendering(refId, _params, _mode, _locId, _rm, false, false, _language); - - EbFormAndDataWrapper result = JsonConvert.DeserializeObject(resp); - - if (result.ErrorMessage != null) - { - TempData["ErrorResp"] = GetFormattedErrMsg(result.ErrorMessage); - return RedirectToAction("Index", "StatusCode", new { statusCode = result.ErrorCode, m = GetFormattedErrMsg(result.ErrorMessage, true) }); - } - - ViewBag.EbFormAndDataWrapper = resp; - - return View(); - - }catch(Exception exception) + //_r => refId; _p => params; _m => mode; _l => locId; _rm => renderMode + string refId = _r, _params = _p, _language = _lg ?? this.CurrentLanguage ?? "en"; + int _mode = _m, _locId = _l;// + Console.WriteLine(string.Format("Webform Render - refid : {0}, prams : {1}, mode : {2}, locid : {3}", refId, _params, _mode, _locId)); + string resp = GetFormForRendering(refId, _params, _mode, _locId, _rm, false, false, _language); + EbFormAndDataWrapper result = JsonConvert.DeserializeObject(resp); + if (result.ErrorMessage != null) { - return InternalExcepionHelper.Redirect(exception, this, TimeSpan.FromSeconds(120)); + TempData["ErrorResp"] = GetFormattedErrMsg(result.ErrorMessage); + return RedirectToAction("Index", "StatusCode", new { statusCode = result.ErrorCode, m = GetFormattedErrMsg(result.ErrorMessage, true) }); } + ViewBag.EbFormAndDataWrapper = resp; + return View(); } public IActionResult Inde(int _r, string _p, int _m, int _l, int _rm, string _lg) diff --git a/Filters/ApiUserAuthenticationFilter.cs b/Filters/ApiUserAuthenticationFilter.cs deleted file mode 100644 index cddb9ce80..000000000 --- a/Filters/ApiUserAuthenticationFilter.cs +++ /dev/null @@ -1,156 +0,0 @@ -using DocumentFormat.OpenXml.Presentation; -using ExpressBase.Common; -using ExpressBase.Common.Constants; -using ExpressBase.Common.Helpers; -using ExpressBase.Common.ServiceClients; -using ExpressBase.Objects.ServiceStack_Artifacts; -using ExpressBase.Security; -using ExpressBase.Web.Helpers; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.Extensions.DependencyInjection; -using ServiceStack; -using ServiceStack.Auth; -using ServiceStack.Redis; -using System; -using System.Collections.Generic; -using System.IdentityModel.Tokens.Jwt; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; - -namespace ExpressBase.Web.Filters -{ - - public sealed class ApiUserAuthenticationFilter : IAsyncResourceFilter - { - private readonly IServiceClient _serviceClient; - private readonly IEbAuthClient _authClient; - private string _forcedConsole; - - //TODO: add support for stateless APIs - public ApiUserAuthenticationFilter(IServiceClient serviceClient, IEbAuthClient authClient, string forcedConsole) - { - _serviceClient = serviceClient; - _authClient = authClient; - _forcedConsole = forcedConsole; - } - - public Task OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next) - { - string externalSoltionId; - string internalSolutionId; - string bearerToken = context.HttpContext.Request.Cookies[RoutingConstants.WEB_BEARER_TOKEN] ?? context.HttpContext.Request.Cookies[RoutingConstants.BEARER_TOKEN]; - string refreshToken = context.HttpContext.Request.Cookies[RoutingConstants.WEB_REFRESH_TOKEN] ?? context.HttpContext.Request.Cookies[RoutingConstants.REFRESH_TOKEN]; - User user; - string userId; - string userAuthId; - string clientIp = HttpContextHelper.GetIp(context.HttpContext); - string currentConsole; - - if (context.HttpContext.Items.ContainsKey(RoutingConstants.EXTERNAL_SOLUTION_ID)) - { - externalSoltionId = context.HttpContext.Items[RoutingConstants.EXTERNAL_SOLUTION_ID].ToString(); - } - else - { - throw new InvalidOperationException("External solution ID not found in context."); - } - - if (context.HttpContext.Items.ContainsKey(RoutingConstants.INTERNAL_SOLUTION_ID)) - { - internalSolutionId = context.HttpContext.Items[RoutingConstants.INTERNAL_SOLUTION_ID].ToString(); - } - else - { - throw new InvalidOperationException("InternalSolutionId solution ID not found in context."); - } - if (context.HttpContext.Items.ContainsKey("Console")) - { - currentConsole = context.HttpContext.Items["Console"].ToString(); - } - else - { - throw new InvalidOperationException("Console not found in context."); - } - - if(this._forcedConsole != null && this._forcedConsole != currentConsole) - { - context.Result = new JsonResult(new - { - success = false, - message = "Unauthorized access", - statusCode = 401 - }) - { - StatusCode = 401 - }; - } - - if(UserAuthenticationHelper.IsTokensValid(refreshToken, bearerToken, internalSolutionId, clientIp, currentConsole) ) - { - - var bearerTokenPayload = new JwtSecurityToken(bearerToken).Payload; - - userId = bearerTokenPayload[TokenConstants.UID]?.ToString() ?? throw new InvalidOperationException("Invalid session."); - - userAuthId = bearerTokenPayload[TokenConstants.SUB]?.ToString() ?? throw new InvalidOperationException("Invalid session."); - - var redisManager = context.HttpContext.RequestServices.GetRequiredService(); - - user = UserAuthenticationHelper.GetUserObject( - redisManager, - _serviceClient, - userId, - userAuthId, - currentConsole, - internalSolutionId - ); - - } else - { - - context.Result = new JsonResult(new - { - success = false, - message = "Unauthorized access", - statusCode = 401 - }) - { - StatusCode = 401 - }; - - return Task.CompletedTask; - - - } - - if(user != null) - { - context.HttpContext.Items[RoutingConstants.CONTEXT_BEARER_TOKEN] = bearerToken; - context.HttpContext.Items[RoutingConstants.CONTEXT_REFRESH_TOKEN] = refreshToken; - context.HttpContext.Items[RoutingConstants.AUTH_ID] = user.AuthId; - context.HttpContext.Items[RoutingConstants.USER] = user; - - } - else - { - context.Result = new JsonResult(new - { - success = false, - message = "Unauthorized access", - statusCode = 401 - }) - { - StatusCode = 401 - }; - - return Task.CompletedTask; - } - - return next(); - - } - } -} diff --git a/Filters/PublicUserAuthenticationFilter.cs b/Filters/PublicUserAuthenticationFilter.cs deleted file mode 100644 index de409d73c..000000000 --- a/Filters/PublicUserAuthenticationFilter.cs +++ /dev/null @@ -1,175 +0,0 @@ -using DocumentFormat.OpenXml.Presentation; -using ExpressBase.Common; -using ExpressBase.Common.Constants; -using ExpressBase.Common.Helpers; -using ExpressBase.Common.ServiceClients; -using ExpressBase.Objects.ServiceStack_Artifacts; -using ExpressBase.Security; -using ExpressBase.Web.Helpers; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.Extensions.DependencyInjection; -using ServiceStack; -using ServiceStack.Auth; -using ServiceStack.Redis; -using System; -using System.Collections.Generic; -using System.IdentityModel.Tokens.Jwt; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; - -namespace ExpressBase.Web.Filters -{ - - public sealed class PublicUserAuthenticationFilter : IAsyncResourceFilter - { - private readonly IServiceClient _serviceClient; - private readonly IEbAuthClient _authClient; - - public PublicUserAuthenticationFilter(IServiceClient serviceClient, IEbAuthClient authClient) - { - _serviceClient = serviceClient; - _authClient = authClient; - } - - public Task OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next) - { - string externalSoltionId; - string internalSolutionId; - string bearerToken = context.HttpContext.Request.Cookies[RoutingConstants.WEB_BEARER_TOKEN] ?? context.HttpContext.Request.Cookies[RoutingConstants.BEARER_TOKEN]; - string refreshToken = context.HttpContext.Request.Cookies[RoutingConstants.WEB_REFRESH_TOKEN] ?? context.HttpContext.Request.Cookies[RoutingConstants.REFRESH_TOKEN]; - User user; - string userId; - string userAuthId; - string clientIp = HttpContextHelper.GetIp(context.HttpContext); - string currentConsole; - - if (context.HttpContext.Items.ContainsKey(RoutingConstants.EXTERNAL_SOLUTION_ID)) - { - externalSoltionId = context.HttpContext.Items[RoutingConstants.EXTERNAL_SOLUTION_ID].ToString(); - } - else - { - throw new InvalidOperationException("External solution ID not found in context."); - } - - if (context.HttpContext.Items.ContainsKey(RoutingConstants.INTERNAL_SOLUTION_ID)) - { - internalSolutionId = context.HttpContext.Items[RoutingConstants.INTERNAL_SOLUTION_ID].ToString(); - } - else - { - throw new InvalidOperationException("InternalSolutionId solution ID not found in context."); - } - if (context.HttpContext.Items.ContainsKey("Console")) - { - currentConsole = context.HttpContext.Items["Console"].ToString(); - } - else - { - throw new InvalidOperationException("Console not found in context."); - } - - if(currentConsole != RoutingConstants.UC) - { - throw new InvalidOperationException("Invalid console."); - } - - - if(UserAuthenticationHelper.IsTokensValid(refreshToken, bearerToken, internalSolutionId, clientIp, currentConsole) == false) - { - - var authRequest = new Authenticate - { - provider = CredentialsAuthProvider.Name, - UserName = "NIL", - Password = "NIL", - Meta = new Dictionary { - { RoutingConstants.WC, TokenConstants.UC }, - { TokenConstants.EMAIL, TokenConstants.PUBLIC_FORM_V2_ANONYMOUS_USER_EMAIL }, - { TokenConstants.CID, internalSolutionId }, - { TokenConstants.IP, clientIp}, - { RoutingConstants.USER_AGENT, context.HttpContext.Request.Headers["User-Agent"].ToString()}, - { TokenConstants.SESSION_TAG, TokenConstants.ANONYMOUS_USER_V2_SESSION_TAG}, - }, - RememberMe = true - }; - - - var authResponse = this._authClient.Get(authRequest); - - if (authResponse != null && authResponse.User != null) - { - user = authResponse.User; - bearerToken = authResponse.BearerToken; - refreshToken = authResponse.RefreshToken; - //userAuthId = authResponse.User.AuthId; - - var cookieOpts = new Microsoft.AspNetCore.Http.CookieOptions - { - HttpOnly = true, - Secure = context.HttpContext.Request.IsHttps, - SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Strict, - Expires = DateTimeOffset.UtcNow.AddMinutes(59) //TODO: shouldn't this be same as token expiry? - }; - - context.HttpContext.Response.Cookies.Append(RoutingConstants.WEB_BEARER_TOKEN, bearerToken, cookieOpts); - context.HttpContext.Response.Cookies.Append(RoutingConstants.BEARER_TOKEN, bearerToken, cookieOpts); - context.HttpContext.Response.Cookies.Append(RoutingConstants.WEB_REFRESH_TOKEN, refreshToken, cookieOpts); - context.HttpContext.Response.Cookies.Append(RoutingConstants.REFRESH_TOKEN, refreshToken, cookieOpts); - - if (_serviceClient is JsonServiceClient jsonServiceClient) - { - jsonServiceClient.BearerToken = bearerToken ?? string.Empty; - jsonServiceClient.RefreshToken = refreshToken ?? string.Empty; - jsonServiceClient.Headers.Add(CacheConstants.RTOKEN, refreshToken ?? string.Empty); - } - - } - else - { - throw new InvalidOperationException("Invalid session."); - } - - } else - { - - var bearerTokenPayload = new JwtSecurityToken(bearerToken).Payload; - - userId = bearerTokenPayload[TokenConstants.UID]?.ToString() ?? throw new InvalidOperationException("Invalid session."); - - userAuthId = bearerTokenPayload[TokenConstants.SUB]?.ToString() ?? throw new InvalidOperationException("Invalid session."); - - var redisManager = context.HttpContext.RequestServices.GetRequiredService(); - - user = UserAuthenticationHelper.GetUserObject( - redisManager, - _serviceClient, - userId, - userAuthId, - currentConsole, - internalSolutionId - ); - - - } - - if(user != null) - { - context.HttpContext.Items[RoutingConstants.CONTEXT_BEARER_TOKEN] = bearerToken; - context.HttpContext.Items[RoutingConstants.CONTEXT_REFRESH_TOKEN] = refreshToken; - context.HttpContext.Items[RoutingConstants.AUTH_ID] = user.AuthId; - context.HttpContext.Items[RoutingConstants.USER] = user; - - } - else - { - throw new InvalidOperationException("Invalid session."); - } - - return next(); - - } - } -} diff --git a/Filters/SolutionContextFilter.cs b/Filters/SolutionContextFilter.cs deleted file mode 100644 index 69d4b0832..000000000 --- a/Filters/SolutionContextFilter.cs +++ /dev/null @@ -1,67 +0,0 @@ -using DocumentFormat.OpenXml.Presentation; -using ExpressBase.Common; -using ExpressBase.Common.Constants; -using ExpressBase.Common.Helpers; -using ExpressBase.Objects.ServiceStack_Artifacts; -using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.Extensions.DependencyInjection; -using ServiceStack; -using ServiceStack.Redis; -using System; -using System.Threading.Tasks; - -namespace ExpressBase.Web.Filters -{ - - public sealed class SolutionContextFilter : IAsyncResourceFilter - { - private readonly IServiceClient _serviceClient; - - public SolutionContextFilter(IServiceClient serviceClient) - { - _serviceClient = serviceClient; - } - - public Task OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next) - { - string internalSolutionId; - string externalSoultionId; - - if(context.HttpContext.Items.ContainsKey(RoutingConstants.EXTERNAL_SOLUTION_ID)) - { - externalSoultionId = context.HttpContext.Items[RoutingConstants.EXTERNAL_SOLUTION_ID].ToString(); - - } else - { - throw new InvalidOperationException("External solution ID not found in context."); - } - - - /*if (externalSoultionId == CoreConstants.MYACCOUNT) - { - internalSolutionId = CoreConstants.EXPRESSBASE; - } - else if (externalSoultionId == CoreConstants.ADMIN) - { - externalSoultionId = CoreConstants.ADMIN; - }*/ - - var redisManager = context.HttpContext.RequestServices.GetRequiredService(); - - if(RedisCacheHelper.Exists(redisManager, string.Format(CoreConstants.SOLUTION_ID_MAP, externalSoultionId))) - { - internalSolutionId = RedisCacheHelper.Get(redisManager,string.Format(CoreConstants.SOLUTION_ID_MAP, externalSoultionId)); - - } else - { - this._serviceClient.Post(new UpdateSidMapRequest { ExtSolutionId = externalSoultionId }); - internalSolutionId = RedisCacheHelper.Get(redisManager, string.Format(CoreConstants.SOLUTION_ID_MAP, externalSoultionId)); - } - - context.HttpContext.Items[RoutingConstants.INTERNAL_SOLUTION_ID] = internalSolutionId ?? throw new InvalidOperationException("External solution ID is invalid."); - - return next(); - - } - } -} diff --git a/Helpers/AppConfigViewHelper.cs b/Helpers/AppConfigViewHelper.cs index 5a69c9e1b..2952477bf 100644 --- a/Helpers/AppConfigViewHelper.cs +++ b/Helpers/AppConfigViewHelper.cs @@ -1,4 +1,3 @@ -using ExpressBase.Common; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; using Newtonsoft.Json; @@ -24,14 +23,14 @@ public static string RenderJson(HttpContext context) var appConfig = new { Env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"), - Scheme = context.Items[RoutingConstants.SCHEME]?.ToString(), - Host = context.Items[RoutingConstants.HOST]?.ToString(), + Scheme = context.Items["Scheme"]?.ToString(), + Host = context.Items["Host"]?.ToString(), BaseHost = cfg.Value.BaseHost, LocalPort = cfg.Value.LocalPort, - Domain = context.Items[RoutingConstants.DOMAIN]?.ToString(), + Domain = context.Items["Domain"]?.ToString(), ServerEventUrlPrefix = cfg.Value.ServerEventUrlPrefix, - DevConsoleHost = context.Items[RoutingConstants.DEV_CONSOLE_HOST]?.ToString(), - UserConsoleHost = context.Items[RoutingConstants.USER_CONSOLE_HOST]?.ToString() + DevConsoleHost = context.Items["DevConsoleHost"]?.ToString(), + UserConsoleHost = context.Items["UserConsoleHost"]?.ToString() }; var jsonSettings = new JsonSerializerSettings diff --git a/Helpers/EbPublicFormHelper.cs b/Helpers/EbPublicFormHelper.cs deleted file mode 100644 index 8cb664223..000000000 --- a/Helpers/EbPublicFormHelper.cs +++ /dev/null @@ -1,31 +0,0 @@ -using ExpressBase.Common; -using ExpressBase.Common.Helpers; -using ExpressBase.Objects.Dtos; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using System; - -namespace ExpressBase.Web.Helpers -{ - public static class EbPublicFormHelper - { - public static string GenerateUrl(HttpContext HttpContext, IUrlHelper UrlHelper, string RefId) - { - string base64Key = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_AES_ENC_KEY) ?? throw new Exception(EnvironmentConstants.EB_AES_ENC_KEY + " EnvironmentConstant not found"); - - var dto = new PublicFormV2QueryParamsDto - { - PublicFormRefId = RefId - }; - - return - HttpContext.Items[RoutingConstants.SCHEME].ToString() + - HttpContext.Items[RoutingConstants.USER_CONSOLE_HOST].ToString() + - UrlHelper.Action( - action: "Index", - controller: "PublicForm", - values: new { publicFormQparams = QueryStringEncDecHelper.EncryptString(dto, base64Key) } - ); - } - } -} diff --git a/Helpers/HttpContextHelper.cs b/Helpers/HttpContextHelper.cs deleted file mode 100644 index 6a2427215..000000000 --- a/Helpers/HttpContextHelper.cs +++ /dev/null @@ -1,76 +0,0 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Filters; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace ExpressBase.Web.Helpers -{ - public class HttpContextHelper - { - - - public static string GetIp(HttpContext httpContext) - { - - string headerValue = null; - - if (httpContext.Request.Headers.TryGetValue("Eb-X-Forwarded-For", out var ebFwd) && - !string.IsNullOrWhiteSpace(ebFwd)) - { - headerValue = ebFwd.ToString(); - } - else if (httpContext.Request.Headers.TryGetValue("X-Forwarded-For", out var stdFwd) && - !string.IsNullOrWhiteSpace(stdFwd)) - { - headerValue = stdFwd.ToString(); - } - - if (!string.IsNullOrWhiteSpace(headerValue)) - { - - var commaIndex = headerValue.IndexOf(','); - var clientIp = commaIndex >= 0 ? headerValue.Substring(0, commaIndex) : headerValue; - return clientIp.Trim(); - } - - - var remoteIp = httpContext.Connection.RemoteIpAddress; - - return remoteIp?.MapToIPv4().ToString(); - } - - public static bool WantsJson(HttpContext httpContext) - { - - if (httpContext.Request.Headers.TryGetValue("Accept", out var accept)) - { - var a = accept.ToString().ToLowerInvariant(); - if (a.Contains("application/json") || a.Contains("+json") || a.Contains("text/json")) - { - return true; - } - - } - - - var q = httpContext.Request.Query; - if (q.TryGetValue("format", out var fmt) && string.Equals(fmt.ToString(), "json", StringComparison.OrdinalIgnoreCase)) - { - return true; - } - - - if (httpContext.Request.Headers.TryGetValue("X-Requested-With", out var xrw) && - xrw.ToString().Equals("XMLHttpRequest", StringComparison.OrdinalIgnoreCase)) - { - return true; - } - - - return false; - } - } -} diff --git a/Helpers/InternalExcepionHelper.cs b/Helpers/InternalExcepionHelper.cs deleted file mode 100644 index 8093ff003..000000000 --- a/Helpers/InternalExcepionHelper.cs +++ /dev/null @@ -1,78 +0,0 @@ -using ExpressBase.Common.Helpers; -using Microsoft.AspNetCore.Mvc; -using ServiceStack.Redis; -using System; -namespace ExpressBase.Web.Helpers -{ - public static class InternalExcepionHelper - { - private const string CachePrefix = "InternalExcepionHelper"; - private const int DefaultTimeSpanSeconds = 60; - - private static PooledRedisClientManager GetRedisManager(Controller controller) - { - if (controller == null) - throw new ArgumentNullException(nameof(controller)); - - var serviceProvider = controller.HttpContext?.RequestServices; - - if (serviceProvider == null) - throw new InvalidOperationException("RequestServices not available in controller context."); - - var redisManager = serviceProvider.GetService(typeof(PooledRedisClientManager)) as PooledRedisClientManager; - - if (redisManager == null) - throw new InvalidOperationException("PooledRedisClientManager not registered in DI container."); - - return redisManager; - } - - private static void Set(Controller controller, Exception exception, string prefix, TimeSpan? ttl = null) - { - var redisManager = GetRedisManager(controller); - var serializableEx = SerializableExceptionDto.FromException(exception); - - RedisCacheHelper.Set(redisManager, CachePrefix + prefix, serializableEx, ttl); - } - - public static IActionResult Redirect(Exception exception, Controller controller, TimeSpan? ttl = null) - { - if (controller == null) - throw new ArgumentNullException(nameof(controller)); - - if (exception == null) - throw new ArgumentNullException(nameof(exception)); - - string ticketId = Guid.NewGuid().ToString("N"); - - Set(controller, exception, ticketId, ttl ?? TimeSpan.FromSeconds(DefaultTimeSpanSeconds)); - - return controller.RedirectToAction( - "Index", - "InternalException", - new { ticketId } - ); - } - - public static SerializableExceptionDto Get(Controller controller, string ticketId) - { - if (controller == null) - throw new ArgumentNullException(nameof(controller)); - - if (string.IsNullOrWhiteSpace(ticketId)) - throw new ArgumentNullException(nameof(ticketId)); - - var redisManager = GetRedisManager(controller); - - var key = CachePrefix + ticketId; - - if (RedisCacheHelper.Exists(redisManager, key)) - { - return RedisCacheHelper.Get(redisManager, key); - } - - return null; - } - - } -} diff --git a/Helpers/UserAuthenticationHelper.cs b/Helpers/UserAuthenticationHelper.cs deleted file mode 100644 index 3179bc254..000000000 --- a/Helpers/UserAuthenticationHelper.cs +++ /dev/null @@ -1,170 +0,0 @@ -using ExpressBase.Common; -using ExpressBase.Common.Constants; -using ExpressBase.Common.Helpers; -using ExpressBase.Objects.ServiceStack_Artifacts; -using ExpressBase.Security; -using ServiceStack; -using ServiceStack.Redis; -using System; -using System.IdentityModel.Tokens.Jwt; -using System.Security.Cryptography; -using System.Text; - -namespace ExpressBase.Web.Helpers -{ - public static class UserAuthenticationHelper - { - public static bool IsTokensValid( - string refreshToken, - string bearerToken, - string internalSolutionId, - string clientIp, - string currentConsole - ) - { - if (StringHelper.HasValue(refreshToken) == false || StringHelper.HasValue(bearerToken) == false) - { - return false; - } - - try - { - - if (VerifySignature(refreshToken) && VerifySignature(bearerToken)) - { - var refreshTokenData = new JwtSecurityToken(refreshToken); - var bearerTokenData = new JwtSecurityToken(bearerToken); - - if (bearerTokenData.Payload[TokenConstants.CID].ToString() == internalSolutionId) - { - string rSub = refreshTokenData.Payload[TokenConstants.SUB].ToString(); - string bSub = bearerTokenData.Payload[TokenConstants.SUB].ToString(); - string ipFromToken = bearerTokenData.Payload[TokenConstants.IP].ToString(); - - - var tokenExpiry = Convert.ToInt64(refreshTokenData.Payload[TokenConstants.EXP]); - DateTime tokenExpiryDateTime = DateTimeOffset.FromUnixTimeSeconds(tokenExpiry).UtcDateTime; - - if(tokenExpiryDateTime < DateTime.UtcNow) - { - return false; - } - - if(StringHelper.HasValue(ipFromToken) != false && clientIp != ipFromToken) - { - return false; - } - - if (rSub == bSub) - { - - string[] subParts = rSub.Split(CharConstants.COLON); - - if (rSub.EndsWith(TokenConstants.TC)) - { - return true; - } - - else if (currentConsole == RoutingConstants.DC) - { - if (subParts[0] == internalSolutionId && rSub.EndsWith(TokenConstants.DC)) - { - return true; - } - - } - else if (rSub.EndsWith(TokenConstants.UC) || rSub.EndsWith(TokenConstants.BC) || rSub.EndsWith(TokenConstants.MC) || rSub.EndsWith(TokenConstants.PC)) - { - return true; - } - } - } - } - } - catch (Exception) - { - - return false; - } - - return false; - } - - public static bool VerifySignature(string token) - { - string PublicKey = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_JWT_PUBLIC_KEY_XML); - int pos1 = PublicKey.IndexOf(""); - int pos2 = PublicKey.IndexOf(""); - int pos3 = PublicKey.IndexOf(""); - int pos4 = PublicKey.IndexOf(""); - string modkeypub = PublicKey.Substring(pos1 + 9, pos2 - pos1 - 9); - string expkeypub = PublicKey.Substring(pos3 + 10, pos4 - pos3 - 10); - - try - { - string[] tokenParts = token.Split('.'); - RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); - rsa.ImportParameters( - new RSAParameters() - { - Modulus = FromBase64Url(modkeypub), - Exponent = FromBase64Url(expkeypub) - }); - - SHA256 sha256 = SHA256.Create(); - byte[] hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(tokenParts[0] + '.' + tokenParts[1])); - - RSAPKCS1SignatureDeformatter rsaDeformatter = new RSAPKCS1SignatureDeformatter(rsa); - rsaDeformatter.SetHashAlgorithm("SHA256"); - if (rsaDeformatter.VerifySignature(hash, FromBase64Url(tokenParts[2]))) - { - return true; - } - } - catch (Exception e) { Console.WriteLine("Exception from VerifySignature:" + e.ToString()); } - return false; - } - - public static byte[] FromBase64Url(string base64Url) - { - string padded = base64Url.Length % 4 == 0 ? base64Url : base64Url + "====".Substring(base64Url.Length % 4); - - string base64 = padded.Replace("_", "/").Replace("-", "+"); - - return Convert.FromBase64String(base64); - } - - public static User GetUserObject( - PooledRedisClientManager pooledRedisManager, - IServiceClient serviceClient, - string userId, - string userAuthId, - string currentConsole, - string internalSolutionId - ) - { - - if (RedisCacheHelper.Exists(pooledRedisManager, userAuthId)) - { - return RedisCacheHelper.Get(pooledRedisManager, userAuthId); - - } else - { - serviceClient.Post( - new UpdateUserObjectRequest() - { - SolnId = internalSolutionId, - UserId = Convert.ToInt32(userId), - UserAuthId = userAuthId, - WC = currentConsole, - IsApiUser = false - } - ); - - return RedisCacheHelper.Get(pooledRedisManager, userAuthId); - } - - - } - } -} diff --git a/Middlewares/AppUrlContextMiddleware.cs b/Middlewares/AppUrlContextMiddleware.cs index e9e01a182..112260eb7 100644 --- a/Middlewares/AppUrlContextMiddleware.cs +++ b/Middlewares/AppUrlContextMiddleware.cs @@ -1,5 +1,4 @@ -using ExpressBase.Common; -using ExpressBase.Common.Helpers; +using ExpressBase.Common.Helpers; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; using System; @@ -23,8 +22,8 @@ public async Task Invoke(HttpContext context) //DebugHelper.PrintObject(this._cfg, printAsJson: true, label: "this._cfg"); //DebugHelper.PrintObject(context.Request, label: "context"); - var host = context.Request.Host.ToString(); // demobakerystaging-dev.expressbase.com - string baseHost = _cfg.BaseHost; // expressbase.com + var host = context.Request.Host.ToString(); //demobakerystaging-dev.expressbase.com + string baseHost = _cfg.BaseHost; //expressbase.com string subdomain = null; string domain = null; @@ -56,25 +55,22 @@ public async Task Invoke(HttpContext context) if (subdomain.EndsWith(this._cfg.DevDomainSuffix, StringComparison.OrdinalIgnoreCase) == false) { - context.Items[RoutingConstants.DEV_CONSOLE_HOST] = subdomain + this._cfg.DevDomainSuffix + "." + baseHost; // demobakerystaging-dev.expressbase.com - context.Items[RoutingConstants.CONSOLE] = RoutingConstants.UC; - + context.Items["DevConsoleHost"] = subdomain + this._cfg.DevDomainSuffix + "." + baseHost; //demobakerystaging-dev.expressbase.com } else { - context.Items[RoutingConstants.DEV_CONSOLE_HOST] = subdomain + "." + baseHost; // demobakerystaging-dev.expressbase.com - context.Items[RoutingConstants.CONSOLE] = RoutingConstants.DC; + context.Items["DevConsoleHost"] = subdomain + "." + baseHost; //demobakerystaging-dev.expressbase.com } - context.Items[RoutingConstants.EXTERNAL_SOLUTION_ID] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty); // demobakerystaging - context.Items[RoutingConstants.USER_CONSOLE_HOST] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty) + "." + baseHost; // demobakerystaging.expressbase.com - context.Items[RoutingConstants.SUB_DOMAIN] = subdomain; // demobakerystaging || demobakerystaging-dev + context.Items["ExternalSolutionId"] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty); //demobakerystaging + context.Items["UserConsoleHost"] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty) + "." + baseHost; //demobakerystaging.expressbase.com + context.Items["SubDomain"] = subdomain; //demobakerystaging || demobakerystaging-dev } - context.Items[RoutingConstants.BASE_HOST] = baseHost; // expressbase.com - context.Items[RoutingConstants.SCHEME] = this._cfg.Scheme; // https:// || http:// - context.Items[RoutingConstants.HOST] = host; // demobakerystaging-dev.expressbase.com || demobakerystaging.expressbase.com - context.Items[RoutingConstants.DOMAIN] = domain; // expressbase.com + context.Items["BaseHost"] = baseHost; + context.Items["Scheme"] = this._cfg.Scheme; + context.Items["Host"] = host; + context.Items["Domain"] = domain; await _next(context); } diff --git a/Startup.cs b/Startup.cs index 17af0f720..0ab0d4c08 100644 --- a/Startup.cs +++ b/Startup.cs @@ -167,10 +167,6 @@ public void ConfigureServices(IServiceCollection services) services.Configure(Configuration.GetSection("AppConfiguration")); - - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); } diff --git a/Views/Dev/AppDashBoard.cshtml b/Views/Dev/AppDashBoard.cshtml index 70378027e..8f266e065 100644 --- a/Views/Dev/AppDashBoard.cshtml +++ b/Views/Dev/AppDashBoard.cshtml @@ -12,11 +12,11 @@ var solutionid = ViewBag.cide; - if (Context.Items.ContainsKey(RoutingConstants.DOMAIN) && Context.Items.ContainsKey(RoutingConstants.SCHEME)) + if (Context.Items.ContainsKey("Domain") && Context.Items.ContainsKey("Scheme")) { - domurl = Context.Items[RoutingConstants.SCHEME] + solutionid + "." + Context.Items[RoutingConstants.DOMAIN]; - jssrc = Context.Items[RoutingConstants.SCHEME] + sol_cid + "." + Context.Items[RoutingConstants.DOMAIN]; + domurl = Context.Items["Scheme"] + solutionid + "." + Context.Items["Domain"]; + jssrc = Context.Items["Scheme"] + sol_cid + "." + Context.Items["Domain"]; } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/Views/Docs/ImageUpHome.cshtml b/Views/Docs/ImageUpHome.cshtml index c43f6f3f8..066178a52 100644 --- a/Views/Docs/ImageUpHome.cshtml +++ b/Views/Docs/ImageUpHome.cshtml @@ -143,7 +143,6 @@ var im = new ImageUploader_Doc({Tenantid:'@ViewBag.cid'}); *@ -@* -*@ \ No newline at end of file + \ No newline at end of file diff --git a/Views/Ext/SignUp.cshtml b/Views/Ext/SignUp.cshtml index a48760e75..5c0da8438 100644 --- a/Views/Ext/SignUp.cshtml +++ b/Views/Ext/SignUp.cshtml @@ -7,12 +7,12 @@ string sociallink = string.Empty; string signinLink = string.Empty; - if (Context.Items.ContainsKey(RoutingConstants.DOMAIN) && Context.Items.ContainsKey(RoutingConstants.SCHEME)) + if (Context.Items.ContainsKey("Domain") && Context.Items.ContainsKey("Scheme")) { - home = Context.Items[RoutingConstants.SCHEME].ToString() + Context.Items[RoutingConstants.DOMAIN]; - sociallink = Context.Items[RoutingConstants.SCHEME].ToString() + "ss." + Context.Items[RoutingConstants.DOMAIN]; - signinLink = Context.Items[RoutingConstants.SCHEME].ToString() + "myaccount." + Context.Items[RoutingConstants.DOMAIN]; + home = Context.Items["Scheme"].ToString() + Context.Items["Domain"]; + sociallink = Context.Items["Scheme"].ToString() + "ss." + Context.Items["Domain"]; + signinLink = Context.Items["Scheme"].ToString() + "myaccount." + Context.Items["Domain"]; } else //TODO: TestAndRemoveInTheNextDeployment { diff --git a/Views/Ext/TenantSignIn.cshtml b/Views/Ext/TenantSignIn.cshtml index 4b21aeca5..9dc80eef1 100644 --- a/Views/Ext/TenantSignIn.cshtml +++ b/Views/Ext/TenantSignIn.cshtml @@ -6,12 +6,12 @@ string sociallink = string.Empty; string signinLink = string.Empty; - if (Context.Items.ContainsKey(RoutingConstants.SCHEME) && Context.Items.ContainsKey(RoutingConstants.DOMAIN)) + if (Context.Items.ContainsKey("Domain") && Context.Items.ContainsKey("Scheme")) { - home = Context.Items[RoutingConstants.SCHEME].ToString() + Context.Items[RoutingConstants.DOMAIN]; - sociallink = Context.Items[RoutingConstants.SCHEME].ToString() + "ss." + Context.Items[RoutingConstants.DOMAIN]; - signinLink = Context.Items[RoutingConstants.SCHEME].ToString() + "myaccount." + Context.Items[RoutingConstants.DOMAIN]; + home = Context.Items["Scheme"].ToString() + Context.Items["Domain"]; + sociallink = Context.Items["Scheme"].ToString() + "ss." + Context.Items["Domain"]; + signinLink = Context.Items["Scheme"].ToString() + "myaccount." + Context.Items["Domain"]; } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/Views/Ext/VerifyEmailSrtucture.cshtml b/Views/Ext/VerifyEmailSrtucture.cshtml index 099214b51..af04ac15b 100644 --- a/Views/Ext/VerifyEmailSrtucture.cshtml +++ b/Views/Ext/VerifyEmailSrtucture.cshtml @@ -13,6 +13,7 @@ Dear {UserName},

        Welcome to EXPRESSbase! An Open-Source, Low-Code Rapid application development & delivery platform on the cloud for businesses & developers to build & run business apps 10 times faster.
        + We're excited to help you get started with your new EXPRESSbase account. Please go thru our Wiki for tutorials.
        If you wish to connect the database used by your existing applications, you could do it in very simple steps – and it is secure too!
        Just click the button below to verify your email address.
        diff --git a/Views/ImportExport/ShareToPublic.cshtml b/Views/ImportExport/ShareToPublic.cshtml index 1ce409cb6..e2c21dede 100644 --- a/Views/ImportExport/ShareToPublic.cshtml +++ b/Views/ImportExport/ShareToPublic.cshtml @@ -371,7 +371,6 @@ else $("#price").removeAttr("disabled"); - @* var screenshot = new EbFileUpload({ Type: "image", Toggle: "#uploadscreenshot", @@ -396,7 +395,6 @@ $("input[name='images']").val(v); $(".screenshot-body").append(`
        `); } - *@ }); $('input[type=radio][name=price_option]').change(function () { if (this.value === '1') { diff --git a/Views/InternalException/Index.cshtml b/Views/InternalException/Index.cshtml deleted file mode 100644 index 24d87da23..000000000 --- a/Views/InternalException/Index.cshtml +++ /dev/null @@ -1,364 +0,0 @@ -@using ExpressBase.Common.Helpers -@using ExpressBase.Web.Controllers.ControllersV2 -@using Microsoft.Extensions.Configuration -@inject IConfiguration Configuration -@model InternalExceptionViewModel - -@{ - bool isDev = Model.IsDevelopment; - string ticketId = Model.TicketId; - SerializableExceptionDto exception = Model.Exception; - bool hasTicket = (exception != null); - string baseUrl = Configuration["AppSettings:Scheme"] + Configuration["AppSettings:BaseHost"]; -} - - - - - - Something went wrong | @ticketId - @await Html.PartialAsync("_EbCoreScripts") - - - - - -
        -
        - - -

        Something went wrong

        - - @if (hasTicket) - { -

        Ticket ID: @ticketId

        - } - - @if (!hasTicket) - { - if (isDev) - { -

        - No error details present. In Dev, ensure you redirected here using a valid ticket created within the TTL. -

        - -

        - We’re sorry, but something didn’t go as expected. Don’t worry, our team has been notified and is already looking into it. - Please try reloading the page or return to the homepage. -

        - } - else - { -

        - We’re sorry, but something didn’t go as expected. Don’t worry, our team has been notified and is already looking into it. - Please try reloading the page or return to the homepage. -

        - } - } - - @if (hasTicket && isDev) - { -
        - Details -
        - @if (!string.IsNullOrEmpty(exception?.GetType().FullName)) - { -
        Exception Type
        -
        @exception.GetType().FullName
        - } - - @if (!string.IsNullOrEmpty(exception?.Message)) - { -
        Message
        -
        @exception.Message
        - } - - @if (!string.IsNullOrEmpty(exception?.Source)) - { -
        Source
        -
        @exception.Source
        - } - - @if (!string.IsNullOrEmpty(exception?.TargetSite?.ToString())) - { -
        Target Site
        -
        @exception.TargetSite.ToString()
        - } - - @if (exception?.Data?.Count > 0) - { -
        Data
        -
        -
          - @foreach (var kvp in exception.Data) - { -
        • @kvp.Key: @kvp.Value
        • - } -
        -
        - } - - @if (!string.IsNullOrEmpty(exception?.StackTrace)) - { -
        Stack Trace
        -
        -
        -
        @exception.StackTrace
        -
        -
        - } - - @if (exception?.InnerException != null) - { -
        Inner Exception
        -
        -
        - @exception.InnerException.Message -
        -
        Type
        -
        @exception.InnerException.GetType().FullName
        - - @if (!string.IsNullOrEmpty(exception.InnerException.Source)) - { -
        Source
        -
        @exception.InnerException.Source
        - } - - @if (!string.IsNullOrEmpty(exception.InnerException.StackTrace)) - { -
        Stack Trace
        -
        -
        -
        @exception.InnerException.StackTrace
        -
        -
        - } - - @if (exception.InnerException.Data?.Count > 0) - { -
        Data
        -
        -
          - @foreach (var kvp in exception.InnerException.Data) - { -
        • @kvp.Key: @kvp.Value
        • - } -
        -
        - } -
        -
        -
        - } -
        -
        - - } - -
        - - @* *@ -
        -
        -
        - - - - diff --git a/Views/Security/MyProfile.cshtml b/Views/Security/MyProfile.cshtml index 2fa9fed90..e3b15da1b 100644 --- a/Views/Security/MyProfile.cshtml +++ b/Views/Security/MyProfile.cshtml @@ -519,7 +519,6 @@ new myProfileJs(@UserData, '@Mode', @LocsData); - @* var d = new EbFileUpload({ Type:"image", Toggle: "#btnChngDp", @@ -541,7 +540,6 @@ d.windowClose = function () { EbMessage("show", { Message: "window closed",Background: "red" }); } - *@ }); diff --git a/Views/Shared/Components/ObjectDashboard/Default.cshtml b/Views/Shared/Components/ObjectDashboard/Default.cshtml index 58b6f7172..34814c7b1 100644 --- a/Views/Shared/Components/ObjectDashboard/Default.cshtml +++ b/Views/Shared/Components/ObjectDashboard/Default.cshtml @@ -114,49 +114,11 @@ } if (ViewBag.Refid.Length > 0 && (ViewBag.Refid as string).Split("-")[2] == "0") // if is webform { - //TODO: TestAndRemoveInTheNextDeployment - @* - *@ - - - - - @* - @if(ViewBag.PublicFormUrl != null) - { - - - - } - - *@ - - } - if(ViewBag.Refid != null && ViewBag.PublicFormUrl != null) - { - - - } else if(ViewBag.Refid != null) - { - - } else - { - - } - - } @@ -426,9 +388,6 @@
        - -@* -//TODO: TestAndRemoveInTheNextDeployment
        External URL
        @@ -437,7 +396,6 @@
        -*@ - - -
        diff --git a/Views/Shared/PageFooter.cshtml b/Views/Shared/PageFooter.cshtml index 1461902ff..54a5f4b26 100644 --- a/Views/Shared/PageFooter.cshtml +++ b/Views/Shared/PageFooter.cshtml @@ -31,6 +31,7 @@
      • Home
      • About us
      • Blog
      • +
      • Wiki
      • FAQ
      • Support
      • diff --git a/Views/Shared/_EbCoreScripts.cshtml b/Views/Shared/_EbCoreScripts.cshtml index 95d7057f8..5983d38a1 100644 --- a/Views/Shared/_EbCoreScripts.cshtml +++ b/Views/Shared/_EbCoreScripts.cshtml @@ -1,14 +1,9 @@ @using ExpressBase.Web.Helpers - - - - @@ -16,4 +11,3 @@ - diff --git a/Views/Tenant/SolutionManager.cshtml b/Views/Tenant/SolutionManager.cshtml index e45fe1825..5cc0f98d8 100644 --- a/Views/Tenant/SolutionManager.cshtml +++ b/Views/Tenant/SolutionManager.cshtml @@ -21,10 +21,10 @@ string useraction = string.Empty; - if (Context.Items.ContainsKey(RoutingConstants.SCHEME) && Context.Items.ContainsKey(RoutingConstants.DEV_CONSOLE_HOST) && Context.Items.ContainsKey(RoutingConstants.USER_CONSOLE_HOST)) + if (Context.Items.ContainsKey("Scheme") && Context.Items.ContainsKey("DevConsoleHost") && Context.Items.ContainsKey("UserConsoleHost")) { - sso_dev = Context.Items[RoutingConstants.SCHEME].ToString() + Context.Items[RoutingConstants.DEV_CONSOLE_HOST].ToString() + "/Ext/SwitchContext"; - sso_user = Context.Items[RoutingConstants.SCHEME].ToString() + Context.Items[RoutingConstants.USER_CONSOLE_HOST].ToString() + "/Ext/SwitchContext"; + sso_dev = Context.Items["Scheme"].ToString() + Context.Items["DevConsoleHost"].ToString() + "/Ext/SwitchContext"; + sso_user = Context.Items["Scheme"].ToString() + Context.Items["UserConsoleHost"].ToString() + "/Ext/SwitchContext"; } else //TODO: TestAndRemoveInTheNextDeployment { diff --git a/wwwroot/js/Common/EbFrostGlassLoader.js b/wwwroot/js/Common/EbFrostGlassLoader.js deleted file mode 100644 index 5a932c036..000000000 --- a/wwwroot/js/Common/EbFrostGlassLoader.js +++ /dev/null @@ -1,97 +0,0 @@ -class EbFrostGlassLoader { - constructor({ - blur = 10, - brightness = 1.1, - saturate = 1.2, - background = 'rgba(255,255,255,0.2)', - border = '1px solid rgba(255,255,255,0.3)', - boxShadow = '0 4px 30px rgba(0, 0, 0, 0.1)', - borderRadius = '16px', - zIndex = 2147483647, - blockScroll = true, - showSpinner = true, - autoTimeout = 0 - } = {}) { - this.opts = { blur, brightness, saturate, background, border, boxShadow, borderRadius, zIndex, blockScroll, showSpinner, autoTimeout }; - this._overlayId = 'expressbase-blur-overlay'; - this._styleId = 'expressbase-blur-style'; - this._timer = null; - } - - attach() { - if (this.isActive()) return; - const ensure = () => { - this.#injectStyle(); - - const overlay = document.createElement('div'); - overlay.id = this._overlayId; - overlay.setAttribute('role', 'presentation'); - overlay.tabIndex = -1; - - Object.assign(overlay.style, { - position: 'fixed', - inset: '0', - zIndex: String(this.opts.zIndex), - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - background: this.opts.background, - backdropFilter: `blur(${this.opts.blur}px) brightness(${this.opts.brightness}) saturate(${this.opts.saturate})`, - WebkitBackdropFilter: `blur(${this.opts.blur}px) brightness(${this.opts.brightness}) saturate(${this.opts.saturate})`, - border: this.opts.border, - borderRadius: this.opts.borderRadius, - boxShadow: this.opts.boxShadow, - pointerEvents: 'auto', - animation: 'fadeInGlass 0.3s ease-out', - }); - - if (this.opts.showSpinner) { - const spin = document.createElement('div'); - spin.className = 'expressbase-blur-spinner'; - overlay.appendChild(spin); - } - - if (this.opts.blockScroll) document.documentElement.style.overflow = 'hidden'; - - document.body.appendChild(overlay); - - if (this.opts.autoTimeout > 0) - this._timer = setTimeout(() => this.detach(), this.opts.autoTimeout); - }; - if (!document.body) window.addEventListener('DOMContentLoaded', ensure, { once: true }); - else ensure(); - } - - detach() { - const overlay = document.getElementById(this._overlayId); - if (!overlay) return; - if (this._timer) clearTimeout(this._timer); - overlay.remove(); - document.documentElement.style.overflow = ''; - } - - isActive() { return !!document.getElementById(this._overlayId); } - - #injectStyle() { - if (document.getElementById(this._styleId)) return; - const style = document.createElement('style'); - style.id = this._styleId; - style.textContent = ` - #${this._overlayId} .expressbase-blur-spinner { - width: 40px; height: 40px; - border-radius: 50%; - border: 4px solid rgba(255,255,255,0.4); - border-top-color: rgba(255,255,255,0.8); - animation: spin 1s linear infinite; - } - @keyframes spin { - to { transform: rotate(360deg); } - } - @keyframes fadeInGlass { - from { opacity: 0; } - to { opacity: 1; } - } - `; - document.head.appendChild(style); - } -} \ No newline at end of file diff --git a/wwwroot/js/Common/EbFunnyGlassLoader.js b/wwwroot/js/Common/EbFunnyGlassLoader.js deleted file mode 100644 index 48fbf507f..000000000 --- a/wwwroot/js/Common/EbFunnyGlassLoader.js +++ /dev/null @@ -1,136 +0,0 @@ -class EbFunnyGlassLoader { - constructor({ - zIndex = 2147483647, - blockScroll = true, - autoTimeout = 0 - } = {}) { - this.opts = { zIndex, blockScroll, autoTimeout }; - this._overlayId = 'eb-funky-frost-overlay'; - this._styleId = 'eb-funky-frost-style'; - this._timer = null; - this._beat = null; - } - - attach() { - if (this.isActive()) return; - const ensure = () => { - this.#injectStyle(); - - const overlay = document.createElement('div'); - overlay.id = this._overlayId; - - Object.assign(overlay.style, { - position: 'fixed', - inset: '0', - zIndex: this.opts.zIndex, - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - backdropFilter: 'blur(20px) brightness(1.2)', - WebkitBackdropFilter: 'blur(20px) brightness(1.2)', - animation: 'funky-bg 6s linear infinite', - overflow: 'hidden' - }); - - const dj = document.createElement('div'); - dj.className = 'dj'; - dj.textContent = this.#randomEmoji(); - - const msg = document.createElement('div'); - msg.className = 'funky-text'; - msg.textContent = this.#randomMessage(); - - overlay.appendChild(dj); - overlay.appendChild(msg); - document.body.appendChild(overlay); - - if (this.opts.blockScroll) document.documentElement.style.overflow = 'hidden'; - this.#startFunk(dj, msg); - - if (this.opts.autoTimeout > 0) - this._timer = setTimeout(() => this.detach(), this.opts.autoTimeout); - }; - - if (!document.body) window.addEventListener('DOMContentLoaded', ensure, { once: true }); - else ensure(); - } - - detach() { - if (this._timer) clearTimeout(this._timer); - if (this._beat) clearInterval(this._beat); - const overlay = document.getElementById(this._overlayId); - if (overlay) overlay.remove(); - document.documentElement.style.overflow = ''; - } - - isActive() { - return !!document.getElementById(this._overlayId); - } - - #startFunk(dj, msg) { - let step = 0; - - const emojis = ['🔧', '⏰', '⏳']; - - const messages = [ - 'കിട്ടും... കിട്ടും... കുറച്ച് കഴിഞ്ഞിട്ട് കിട്ടും', - 'ഇപ്പോ ശരിയാക്കിത്തരാം' - ]; - - - this._beat = setInterval(() => { - dj.textContent = emojis[step % emojis.length]; - msg.textContent = messages[Math.floor(Math.random() * messages.length)]; - step++; - }, 1500); - } - - #randomEmoji() { - const arr = ['🔧', '⏰', '⏳']; - return arr[Math.floor(Math.random() * arr.length)]; - } - - #randomMessage() { - const arr = [ - 'കിട്ടും... കിട്ടും... കുറച്ച് കഴിഞ്ഞിട്ട് കിട്ടും', - 'ഇപ്പോ ശരിയാക്കിത്തരാം' - ]; - return arr[Math.floor(Math.random() * arr.length)]; - } - - #injectStyle() { - if (document.getElementById(this._styleId)) return; - const style = document.createElement('style'); - style.id = this._styleId; - style.textContent = ` - @keyframes funky-bg { - 0% { background: linear-gradient(135deg, #ff00ff, #00ffff); } - 25% { background: linear-gradient(135deg, #00ffff, #ff8800); } - 50% { background: linear-gradient(135deg, #ff8800, #00ff66); } - 75% { background: linear-gradient(135deg, #00ff66, #ff00ff); } - 100% { background: linear-gradient(135deg, #ff00ff, #00ffff); } - } - @keyframes bop { - 0%,100% { transform: scale(1) rotate(0deg); } - 50% { transform: scale(1.3) rotate(10deg); } - } - @keyframes glow { - 0%,100% { text-shadow: 0 0 8px #fff, 0 0 12px #ff00ff; } - 50% { text-shadow: 0 0 18px #0ff, 0 0 28px #ff0080; } - } - #${this._overlayId} .dj { - font-size: 72px; - animation: bop 0.8s ease-in-out infinite; - } - #${this._overlayId} .funky-text { - margin-top: 20px; - font-family: 'Comic Sans MS', 'Comic Neue', cursive; - font-size: 22px; - color: white; - text-align: center; - animation: glow 1.4s ease-in-out infinite; - } - `; - document.head.appendChild(style); - } -} \ No newline at end of file diff --git a/wwwroot/js/Common/EbMessages.js b/wwwroot/js/Common/EbMessages.js deleted file mode 100644 index f5d22b207..000000000 --- a/wwwroot/js/Common/EbMessages.js +++ /dev/null @@ -1,12 +0,0 @@ -class EbMessages { - static data = { - somethingWentWrongJSRefresh: "Something went wrong, kindly do a hard refresh (Ctrl + Shift + R)", - networkError: "Network error. Please check your connection.", - unauthorized: "You are not authorized to perform this action.", - }; - - static get(key) { - return this.data[key] || "Unknown message key."; - } -} - diff --git a/wwwroot/js/Common/Helpers/EbApiClientHelper.js b/wwwroot/js/Common/Helpers/EbApiClientHelper.js index 28c4b5565..6b05b2f5d 100644 --- a/wwwroot/js/Common/Helpers/EbApiClientHelper.js +++ b/wwwroot/js/Common/Helpers/EbApiClientHelper.js @@ -1,61 +1,42 @@ class EbApiClientHelper { - constructor(baseUrl = '', defaultTimeout = 10000) { + constructor(baseUrl = '') { this.baseUrl = baseUrl; - this.defaultTimeout = defaultTimeout; } async request(endpoint, options = {}) { - const controller = new AbortController(); - const timeout = options.timeout ?? this.defaultTimeout; - const signal = controller.signal; - // Construct final URL with query params let url = this.baseUrl + endpoint; if (options.query) { const qs = new URLSearchParams(options.query).toString(); url += (url.includes('?') ? '&' : '?') + qs; } - // Prepare headers const headers = { 'Content-Type': 'application/json', ...(options.headers || {}) }; - // Setup timeout - const timeoutId = setTimeout(() => controller.abort(), timeout); - - try { - const resp = await fetch(url, { - method: options.method || 'POST', - headers, - body: options.body ? JSON.stringify(options.body) : undefined, - credentials: options.credentials || 'same-origin', - signal - }); - - clearTimeout(timeoutId); - - if (!resp.ok) { - let errText = `${resp.status} ${resp.statusText}`; - try { - const errJson = await resp.json(); - if (errJson.message) errText = errJson.message; - } catch (_) {} - throw new Error(errText); - } - - const contentType = resp.headers.get('content-type') || ''; - return contentType.includes('application/json') - ? await resp.json() - : await resp.text(); + const resp = await fetch(url, { + method: options.method || 'POST', + headers, + body: options.body ? JSON.stringify(options.body) : undefined, + credentials: options.credentials || 'same-origin' + }); + + if (!resp.ok) { + let errText = `${resp.status} ${resp.statusText}`; + try { + const errJson = await resp.json(); + if (errJson.message) errText = errJson.message; + } catch (_) {} + throw new Error(errText); + } - } catch (err) { - clearTimeout(timeoutId); - if (err.name === 'AbortError') { - throw new Error(`Request timed out after ${timeout} ms`); - } - throw err; + const contentType = resp.headers.get('content-type') || ''; + if (contentType.includes('application/json')) { + return await resp.json(); + } else { + return await resp.text(); } } } diff --git a/wwwroot/js/EbDashBoards/AppDashBoard.js b/wwwroot/js/EbDashBoards/AppDashBoard.js index dcc2547a7..aa1735257 100644 --- a/wwwroot/js/EbDashBoards/AppDashBoard.js +++ b/wwwroot/js/EbDashBoards/AppDashBoard.js @@ -496,7 +496,6 @@ }; this.DpImageUpload = function () { - /* var dpImg = new EbFileUpload({ Type: "image", Toggle: "#dpBrowse", @@ -520,14 +519,10 @@ } }; - - */ }; this.BgImageUpload = function () { - /* - var bgimg = new EbFileUpload({ Type: "image", Toggle: "#bgimg_btn", @@ -559,8 +554,6 @@ //img.src = URL.createObjectURL(this.files[i]); //img.height = 60; }; - - */ }; $("input[name='bgradio']").click(function () { diff --git a/wwwroot/js/Eb_ObjectCommon.js b/wwwroot/js/Eb_ObjectCommon.js index 55f9838dd..6c9683c2a 100644 --- a/wwwroot/js/Eb_ObjectCommon.js +++ b/wwwroot/js/Eb_ObjectCommon.js @@ -36,9 +36,9 @@ $('#singlesave').off('click').on('click', this.SingleSave.bind(this)); $('#offline').off('click').on('click', this.MakeOffline.bind(this)); $('#live').off('click').on('click', this.MakeLive.bind(this)); - //$('#make_public').off('click').on('click', this.MakePublic.bind(this)); - //$('#make_private').off('click').on('click', this.MakePrivate.bind(this)); - //$('#copy_url').off('click').on('click', this.OpenUrlContainer.bind(this)); + $('#make_public').off('click').on('click', this.MakePublic.bind(this)); + $('#make_private').off('click').on('click', this.MakePrivate.bind(this)); + $('#copy_url').off('click').on('click', this.OpenUrlContainer.bind(this)); $('#clone').off('click').on('click', this.Clone.bind(this)); if (this.Current_obj !== null) @@ -769,8 +769,7 @@ }.bind(this)); }; - //TODO: TestAndRemoveInTheNextDeployment - /*this.MakePublic = function () { + this.MakePublic = function () { $("#eb_common_loader").EbLoader("show"); $.post("../Eb_Object/ChangeAccess", { @@ -790,10 +789,9 @@ } $("#eb_common_loader").EbLoader("hide"); }.bind(this)); - };*/ + }; - //TODO: TestAndRemoveInTheNextDeployment - /*this.MakePrivate = function () { + this.MakePrivate = function () { $("#eb_common_loader").EbLoader("show"); $.post("../Eb_Object/ChangeAccess", { @@ -813,12 +811,11 @@ } $("#eb_common_loader").EbLoader("hide"); }.bind(this)); - };*/ + }; - //TODO: TestAndRemoveInTheNextDeployment - /*this.OpenUrlContainer = function () { + this.OpenUrlContainer = function () { $('#url-container').show(); - };*/ + }; this.Clone = function () { EbDialog("show", diff --git a/wwwroot/js/FormBuilder/EbPublicFormPropertyControl.js b/wwwroot/js/FormBuilder/EbPublicFormPropertyControl.js deleted file mode 100644 index 98efeb78d..000000000 --- a/wwwroot/js/FormBuilder/EbPublicFormPropertyControl.js +++ /dev/null @@ -1,178 +0,0 @@ -class EbPublicFormPropertyControl { - - static checkbox = null; - static container = null; - static btn = null; - static modal = null; - static publicFormUrl = null; - static refId = null; - static _boundToggle = null; - - static handleFromSave() { - - } - - - static handlePGControlStateChange(checkboxEl = null) { - try { - this.checkbox = checkboxEl; - - if (!this.checkbox) throw new Error("Checkbox element not found"); - - this.container = document.querySelector('#publicFormActions'); - - if (!this.container) throw new Error("#publicFormActions not found"); - - this.initDataSetFromContainer(); - - if (this.checkbox.checked) { - return this.handleCheck(); - } else { - return this.handleUncheck(); - } - } catch (error) { - EbDebugHelper?.error?.("Unable to init EbPublicFormPropertyControl (static)", error); - } - } - - static initDataSetFromContainer() { - const {refid, publicformurl} = this.container.dataset ?? {}; - - this.refId = null; - this.publicFormUrl = null; - - if (refid) { - this.refId = refid; - } - - if (publicformurl) { - this.publicFormUrl = publicformurl; - } - } - - - static generateCopyUrlButton(forceRegenerate = false) { - - if (!this.container || forceRegenerate === true) { - - this.container = document.querySelector('#publicFormActions'); - - if (!this.container) { - EbDebugHelper.error("#publicFormActions not found while generating button"); - return; - } - - this.container.replaceChildren(); - this.btn = null; - this.initDataSetFromContainer(); - } - - this.modal ??= new EbShareModal({title: "Public Form Link"}); - - this.btn = document.getElementById('copy_url') || document.createElement('button'); - this.btn.className = 'btn'; - this.btn.id = 'copy_url'; - this.btn.title = 'Copy public form Link'; - this.btn.style.display = 'none'; - - - if (!this.btn.querySelector('i')) { - const icon = document.createElement('i'); - icon.className = 'fa fa-clipboard'; - icon.setAttribute('aria-hidden', 'true'); - this.btn.appendChild(icon); - } - - if (this.publicFormUrl) { - this.btn.onclick = () => this.modal.open(this.publicFormUrl); - this.btn.style.display = 'inline-block'; - this.btn.removeAttribute("aria-disabled"); - } else { - this.btn.style.display = "none"; - this.btn.onclick = null; - this.btn.setAttribute("aria-disabled", "true"); - } - - - if (!this.btn.parentElement || forceRegenerate === true) { - this.container.appendChild(this.btn); - } - } - - - static async handleCheck() { - window.jQuery ? $("#eb_common_loader").EbLoader?.("show") : undefined; - - try { - if (!this.refId) { - EbToast?.info?.("Save the form to generate a public form link"); - return; - } - - if (!this.publicFormUrl) { - - const response = await new EbApiClientHelper().request( - '/internal/api/v2/BuilderApi/GetPublicFormUrl', - { - method: 'GET', - query: {RefId: this.refId}, - credentials: 'include' - } - ); - - - if (!response?.publicFormUrl) throw new Error("Unable to fetch the public form from XHR"); - this.publicFormUrl = response.publicFormUrl; - } - - this.generateCopyUrlButton(); - - EbToast.info("Public form link generated successfully. Save this form to make it public.") - - } catch (err) { - EbDebugHelper?.error?.("An exception occurred while changing the form state", err); - EbToast?.error?.("Unable to change the state of the form"); - if (this.btn) { - this.btn.style.display = "none"; - this.btn.onclick = null; - this.btn.setAttribute("aria-disabled", "true"); - } - } finally { - window.jQuery ? $("#eb_common_loader").EbLoader?.("hide") : undefined; - } - } - - - static handleUncheck() { - window.jQuery ? $("#eb_common_loader").EbLoader?.("show") : undefined; - try { - if (!this.refId) { - EbToast?.info?.("Save the form to ensure the state change"); - return; - } - - this.publicFormUrl = null; - - this.generateCopyUrlButton(); - EbToast.info("Save this form to make it private.") - } catch (err) { - EbToast?.error?.("Unable to change the state of the form"); - } finally { - window.jQuery ? $("#eb_common_loader").EbLoader?.("hide") : undefined; - } - } - - - static retarget(checkboxEl = null, containerEl = null) { - if (checkboxEl && this.checkbox !== checkboxEl) { - if (this._boundToggle && this.checkbox) { - this.checkbox.removeEventListener('change', this._boundToggle); - } - this.checkbox = checkboxEl; - this._attachChangeHandler(); - } - if (containerEl && this.container !== containerEl) { - this.container = containerEl; - } - } -} diff --git a/wwwroot/js/FormBuilder/Eb_PropertyGrid.js b/wwwroot/js/FormBuilder/Eb_PropertyGrid.js index f4a588416..38c8567b4 100644 --- a/wwwroot/js/FormBuilder/Eb_PropertyGrid.js +++ b/wwwroot/js/FormBuilder/Eb_PropertyGrid.js @@ -237,7 +237,7 @@ SolutionId: this.Cid, Container: "mb_" + this.wraperId, Multiple: false, - ServerEventUrl: EbUrlHelper.getEbServerEventUrl(), + ServerEventUrl: ebcontext.env === "Production" ? 'https://se.expressbase.com' : 'https://se.eb-test.xyz', EnableTag: false, EnableCrop: false, DisableUpload: false @@ -600,98 +600,77 @@ //fires when a property value changes through PG this.OnInputchangedFn = function (e) { ////////// need optimization + let oldVal = ""; + let subTypeOf = null; + if (e) { + var $e = $(e.target); + this.CurProp = $e.closest("tr").attr("name").slice(0, -2); + subTypeOf = $e.closest("tr").attr("subtype-of"); + } try { + oldVal = this.PropsObj.__oldValues[this.CurProp]; + } + catch (e) { + alert(e); + console.log(e); + } + this.getvaluesFromPG(); + let newVal = this.PropsObj[this.CurProp]; + if (newVal === oldVal) + return; + let objCopy = ($.extend({}, this.PropsObj)); + delete objCopy.__oldValues; + this.PropsObj.__oldValues = objCopy; + //let res = this.getvaluesFromPG(); + //$('#txtValues').val(JSON.stringify(res) + '\n\n'); - if (e?.currentTarget?.id === 'pgWraperIsPublicForm') { - - try { - - EbPublicFormPropertyControl.handlePGControlStateChange(e.currentTarget); + this.CurMeta = getObjByval(this.Metas, "name", this.CurProp); + this.check4ReservedVals(); - } catch (error) { - EbDebugHelper.error("unable to change the status of the form", error); - EbToast.warn(EbMessages.get('somethingWentWrongJSRefresh')); - } - } - - let oldVal = ""; - let subTypeOf = null; - if (e) { - var $e = $(e.target); - this.CurProp = $e.closest("tr").attr("name").slice(0, -2); - subTypeOf = $e.closest("tr").attr("subtype-of"); - } - - try { - oldVal = this.PropsObj.__oldValues[this.CurProp]; - } - catch (e) { - EbDebugHelper.error("an exception occurred", error); - EbToast.error("An exception occurred"); - } - this.getvaluesFromPG(); - let newVal = this.PropsObj[this.CurProp]; - if (newVal === oldVal) + if (subTypeOf) { + this.CurMeta = getObjByval(this.Metas, "name", subTypeOf); + } + if (this.CurProp === "Name" || this.CurProp === "name") { + this.updateDD(this.PropsObj); + let $colTile = ""; + if (this.ParentPG && this.ParentPG.isModalOpen) + $colTile = $(`#${e.target.defaultValue}.colTile`); + if ($colTile.length) + $colTile.attr("id", this.PropsObj[this.CurProp]).find("span").text(this.PropsObj[this.CurProp]); + } + if (this.CurMeta && typeof EbOnChangeUIfns !== "undefined" && this.CurMeta.UIChangefn) { + this.execUiChangeFn(this.CurMeta.UIChangefn, this.PropsObj); + } + if (this.CurProp === 'DataSourceId' && this.PropsObj.ObjType !== "DataGrid") { + this.PGHelper.dataSourceInit(); + } + if (this.CurProp === 'Url' && this.PropsObj.ObjType !== "DataGrid") { + if (!EbIsValidURL(this.PropsObj.Url.trim())) { + this.EbAlert.alert({ + id: this.CurProp + "EbIsValidURL", + head: "Invalid URL string.", + body: " The value entered '" + this.PropsObj.Url + "' is an invalid URL.", + type: "warning", + delay: 3000 + }); + if (e) + $e.select(); return; - - let objCopy = ($.extend({}, this.PropsObj)); - delete objCopy.__oldValues; - this.PropsObj.__oldValues = objCopy; - //let res = this.getvaluesFromPG(); - //$('#txtValues').val(JSON.stringify(res) + '\n\n'); - - this.CurMeta = getObjByval(this.Metas, "name", this.CurProp); - this.check4ReservedVals(); - - if (subTypeOf) { - this.CurMeta = getObjByval(this.Metas, "name", subTypeOf); } - if (this.CurProp === "Name" || this.CurProp === "name") { - this.updateDD(this.PropsObj); - let $colTile = ""; - if (this.ParentPG && this.ParentPG.isModalOpen) - $colTile = $(`#${e.target.defaultValue}.colTile`); - if ($colTile.length) - $colTile.attr("id", this.PropsObj[this.CurProp]).find("span").text(this.PropsObj[this.CurProp]); - } - if (this.CurMeta && typeof EbOnChangeUIfns !== "undefined" && this.CurMeta.UIChangefn) { - this.execUiChangeFn(this.CurMeta.UIChangefn, this.PropsObj); - } - if (this.CurProp === 'DataSourceId' && this.PropsObj.ObjType !== "DataGrid") { - this.PGHelper.dataSourceInit(); - } - if (this.CurProp === 'Url' && this.PropsObj.ObjType !== "DataGrid") { - if (!EbIsValidURL(this.PropsObj.Url.trim())) { - this.EbAlert.alert({ - id: this.CurProp + "EbIsValidURL", - head: "Invalid URL string.", - body: " The value entered '" + this.PropsObj.Url + "' is an invalid URL.", - type: "warning", - delay: 3000 - }); - if (e) - $e.select(); - return; - } - if (this.PropsObj.IsDataFromApi) { - let opt = { - url: "../DS/GetColumnsFromApi", - apiUrl: this.PropsObj.Url, - headers: this.PropsObj.Headers.$values, - parameters: this.PropsObj.DataApiParams.$values, - method: this.PropsObj.Method - } - this.PGHelper.UrlInit(opt); + if (this.PropsObj.IsDataFromApi) { + let opt = { + url: "../DS/GetColumnsFromApi", + apiUrl: this.PropsObj.Url, + headers: this.PropsObj.Headers.$values, + parameters: this.PropsObj.DataApiParams.$values, + method: this.PropsObj.Method } + this.PGHelper.UrlInit(opt); } - this.PropertyChanged(this.PropsObj, this.CurProp, newVal, oldVal); - - } catch (error) { - EbDebugHelper.error("an exception occurred", error); - EbToast.warn(EbMessages.get('somethingWentWrongJSRefresh')); } + this.PropertyChanged(this.PropsObj, this.CurProp, newVal, oldVal); }; this.execUiChangeFn = function (UIChangefn, PropsObj) { diff --git a/wwwroot/js/FormBuilder/FormBuilder.js b/wwwroot/js/FormBuilder/FormBuilder.js index 66a662491..78adfa632 100644 --- a/wwwroot/js/FormBuilder/FormBuilder.js +++ b/wwwroot/js/FormBuilder/FormBuilder.js @@ -78,14 +78,6 @@ this.GenerateButtons = function () { if (options.builderType === 'WebForm' && options.objInEditMode !== null) { - - try{ - EbPublicFormPropertyControl.generateCopyUrlButton(true); - }catch (error) { - EbToast.warn(EbMessages.get('somethingWentWrongJSRefresh')); - EbDebugHelper.error("unable to attach the copy public form url button", error); - } - $("#obj_icons").empty().append(` @@ -798,7 +790,7 @@ let ctrlObj = new this.EbObjects["Eb" + type](ebsid); ctrlObj.DataObjCtrlName = CntrlName; ctrlObj.DataObjColName = ColumnlName; - ctrlObj.Label = ColumnlName + ctrlObj.Label = ColumnlName; let $ctrl = ctrlObj.$Control; if (type === "UserControl") {///user control refid set on ctrlobj diff --git a/wwwroot/js/FormBuilder/InitFormControls.js b/wwwroot/js/FormBuilder/InitFormControls.js index 0172933ae..70c3fb15a 100644 --- a/wwwroot/js/FormBuilder/InitFormControls.js +++ b/wwwroot/js/FormBuilder/InitFormControls.js @@ -90,7 +90,7 @@ SolutionId: this.Cid, Container: ctrl.EbSid, Multiple: ctrl.IsMultipleUpload, - ServerEventUrl: EbUrlHelper.getEbServerEventUrl(), + ServerEventUrl: this.Env === "Production" ? 'https://se.expressbase.com' : 'https://se.eb-test.xyz', EnableTag: ctrl.EnableTag, EnableCrop: ctrl.EnableCrop, MaxSize: ctrl.MaxFileSize, diff --git a/wwwroot/js/location-config.js b/wwwroot/js/location-config.js index 48c9d5f27..bfb631b6d 100644 --- a/wwwroot/js/location-config.js +++ b/wwwroot/js/location-config.js @@ -112,7 +112,6 @@ this.imageUploader = function (container, toggle, prev, extra, viwportresize) { let resize = viwportresize ? true : false; - /* this.Cropies[extra.Name] = new EbFileUpload({ Type: "image", Toggle: toggle, @@ -128,7 +127,6 @@ Context: "location",//if single and crop ResizeViewPort: false //if single and crop }); - */ this.Cropies[extra.Name].uploadSuccess = function (fileid) { $("#loc_logoId").val(""); From a01623d363ddda5664aa9b74efc3372d7b11f127 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 20 Oct 2025 20:24:23 +0530 Subject: [PATCH 54/58] Revert "Revert "platform optimizations "" --- BaseControllers/EbBaseController.cs | 15 +- BaseControllers/EbBaseExtController.cs | 4 +- BaseControllers/EbBaseIntCommonController.cs | 5 + Controllers/CalendarController.cs | 2 +- Controllers/ConnectionManagerController.cs | 4 +- .../ControllersV2/Api/BuilderApiController.cs | 27 ++ .../ControllersV2/HealthCheckController.cs | 86 +++++ .../InternalExceptionController.cs | 89 +++++ .../ControllersV2/PublicFormController.cs | 73 ++++ Controllers/Eb_ObjectController.cs | 87 ++++- Controllers/StaticFileController.cs | 7 +- Controllers/WebFormController.cs | 81 ++-- Filters/ApiUserAuthenticationFilter.cs | 156 ++++++++ Filters/PublicUserAuthenticationFilter.cs | 175 +++++++++ Filters/SolutionContextFilter.cs | 67 ++++ Helpers/AppConfigViewHelper.cs | 11 +- Helpers/EbPublicFormHelper.cs | 31 ++ Helpers/HttpContextHelper.cs | 76 ++++ Helpers/InternalExcepionHelper.cs | 78 ++++ Helpers/UserAuthenticationHelper.cs | 170 ++++++++ Middlewares/AppUrlContextMiddleware.cs | 28 +- Startup.cs | 4 + Views/Dev/AppDashBoard.cshtml | 6 +- Views/Docs/ImageUpHome.cshtml | 5 +- Views/Ext/SignUp.cshtml | 8 +- Views/Ext/TenantSignIn.cshtml | 8 +- Views/Ext/VerifyEmailSrtucture.cshtml | 1 - Views/ImportExport/ShareToPublic.cshtml | 2 + Views/InternalException/Index.cshtml | 364 ++++++++++++++++++ Views/Security/MyProfile.cshtml | 2 + .../Components/ObjectDashboard/Default.cshtml | 42 ++ .../PageHeaderCommon/Default.cshtml | 18 +- Views/Shared/EbQuickMenu.cshtml | 5 - Views/Shared/ExtPageHeader.cshtml | 16 +- Views/Shared/LayoutBuilders.cshtml | 3 + Views/Shared/PageFooter.cshtml | 1 - Views/Shared/_EbCoreScripts.cshtml | 6 + Views/Tenant/SolutionManager.cshtml | 6 +- wwwroot/js/Common/EbFrostGlassLoader.js | 97 +++++ wwwroot/js/Common/EbFunnyGlassLoader.js | 136 +++++++ wwwroot/js/Common/EbMessages.js | 12 + .../js/Common/Helpers/EbApiClientHelper.js | 61 ++- wwwroot/js/EbDashBoards/AppDashBoard.js | 7 + wwwroot/js/Eb_ObjectCommon.js | 21 +- .../EbPublicFormPropertyControl.js | 178 +++++++++ wwwroot/js/FormBuilder/Eb_PropertyGrid.js | 145 ++++--- wwwroot/js/FormBuilder/FormBuilder.js | 10 +- wwwroot/js/FormBuilder/InitFormControls.js | 2 +- wwwroot/js/location-config.js | 2 + 49 files changed, 2221 insertions(+), 219 deletions(-) create mode 100644 Controllers/ControllersV2/Api/BuilderApiController.cs create mode 100644 Controllers/ControllersV2/HealthCheckController.cs create mode 100644 Controllers/ControllersV2/InternalExceptionController.cs create mode 100644 Controllers/ControllersV2/PublicFormController.cs create mode 100644 Filters/ApiUserAuthenticationFilter.cs create mode 100644 Filters/PublicUserAuthenticationFilter.cs create mode 100644 Filters/SolutionContextFilter.cs create mode 100644 Helpers/EbPublicFormHelper.cs create mode 100644 Helpers/HttpContextHelper.cs create mode 100644 Helpers/InternalExcepionHelper.cs create mode 100644 Helpers/UserAuthenticationHelper.cs create mode 100644 Views/InternalException/Index.cshtml create mode 100644 wwwroot/js/Common/EbFrostGlassLoader.js create mode 100644 wwwroot/js/Common/EbFunnyGlassLoader.js create mode 100644 wwwroot/js/Common/EbMessages.js create mode 100644 wwwroot/js/FormBuilder/EbPublicFormPropertyControl.js diff --git a/BaseControllers/EbBaseController.cs b/BaseControllers/EbBaseController.cs index 68ff0f302..249f04296 100644 --- a/BaseControllers/EbBaseController.cs +++ b/BaseControllers/EbBaseController.cs @@ -7,6 +7,7 @@ using ExpressBase.Common.ServiceStack.Auth; using ExpressBase.Objects.ServiceStack_Artifacts; using ExpressBase.Security; +using ExpressBase.Web.Helpers; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; @@ -57,11 +58,11 @@ public string RequestSourceIp { get { - string val = this.HttpContext.Request.Headers["X-Forwarded-For"]; - return string.IsNullOrWhiteSpace(val) ? string.Empty : val.Split(",")[0]; + + return HttpContextHelper.GetIp(this.HttpContext); } } - + public string UserAgent { get @@ -186,9 +187,9 @@ public EbBaseController(IServiceClient _ssclient, IRedisClient _redis, IHttpCont public override void OnActionExecuting(ActionExecutingContext context) { - if (HttpContext.Items.ContainsKey("SubDomain")) + if (HttpContext.Items.ContainsKey(RoutingConstants.SUB_DOMAIN)) { - Host = HttpContext.Items["SubDomain"].ToString(); + Host = HttpContext.Items[RoutingConstants.SUB_DOMAIN].ToString(); } else { @@ -203,9 +204,9 @@ public override void OnActionExecuting(ActionExecutingContext context) .Replace(RoutingConstants.LOCALHOSTADDRESS, string.Empty); } - if (HttpContext.Items.ContainsKey("ExternalSolutionId")) + if (HttpContext.Items.ContainsKey(RoutingConstants.EXTERNAL_SOLUTION_ID)) { - ExtSolutionId = HttpContext.Items["ExternalSolutionId"]?.ToString(); + ExtSolutionId = HttpContext.Items[RoutingConstants.EXTERNAL_SOLUTION_ID]?.ToString(); } else diff --git a/BaseControllers/EbBaseExtController.cs b/BaseControllers/EbBaseExtController.cs index 428d029bc..951d585eb 100644 --- a/BaseControllers/EbBaseExtController.cs +++ b/BaseControllers/EbBaseExtController.cs @@ -46,10 +46,10 @@ public override void OnActionExecuting(ActionExecutingContext context) controller.ViewBag.HostValue = context.HttpContext.Request.Host.Value; controller.ViewBag.Env = Environment.GetEnvironmentVariable(EnvironmentConstants.ASPNETCORE_ENVIRONMENT); - if (HttpContext.Items.ContainsKey("Domain") && HttpContext.Items.ContainsKey("Scheme")) + if (HttpContext.Items.ContainsKey(RoutingConstants.DOMAIN) && HttpContext.Items.ContainsKey(RoutingConstants.SCHEME)) { - controller.ViewBag.Root = HttpContext.Items["Scheme"].ToString() + HttpContext.Items["Domain"].ToString(); + controller.ViewBag.Root = HttpContext.Items[RoutingConstants.SCHEME].ToString() + HttpContext.Items[RoutingConstants.DOMAIN].ToString(); } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/BaseControllers/EbBaseIntCommonController.cs b/BaseControllers/EbBaseIntCommonController.cs index b9fc75b13..33bd5ea75 100644 --- a/BaseControllers/EbBaseIntCommonController.cs +++ b/BaseControllers/EbBaseIntCommonController.cs @@ -150,6 +150,11 @@ public override void OnActionExecuting(ActionExecutingContext context) controller.ViewBag.StaticFileServerUrl = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_STATICFILESERVER_EXT_URL); controller.ViewBag.BrowserURLContext = context.HttpContext.Request.Host.Value; + controller.ViewBag.SessionTag = + (bToken?.Payload != null && bToken.Payload.TryGetValue(TokenConstants.SESSION_TAG, out var value)) + ? value + : null; + this.LoggedInUser = this.GetUserObject(bToken.Payload[TokenConstants.SUB].ToString()); controller.ViewBag.UserDisplayName = this.LoggedInUser.FullName; diff --git a/Controllers/CalendarController.cs b/Controllers/CalendarController.cs index 8f03e52e5..d80d60abf 100644 --- a/Controllers/CalendarController.cs +++ b/Controllers/CalendarController.cs @@ -41,7 +41,7 @@ public IActionResult CalendarView(string refid) RefId = refid }); ViewBag.Refid = refid; - ViewBag.VersionNumber = Resp.Data[0].VersionNumber; + ViewBag.VersionNumber = Resp.Data[0].VersionNumber; // TODO: add null check ViewBag.ObjType = Resp.Data[0].EbObjectType; ViewBag.dsObj = Resp.Data[0].Json; ViewBag.DisplayName = Resp.Data[0].DisplayName; diff --git a/Controllers/ConnectionManagerController.cs b/Controllers/ConnectionManagerController.cs index 4a1a781de..073792be1 100644 --- a/Controllers/ConnectionManagerController.cs +++ b/Controllers/ConnectionManagerController.cs @@ -791,10 +791,10 @@ public string AddGoogleDriveAsync() AuthorizationCodeFlow flow = new AuthorizationCodeFlow(init); Console.WriteLine("Fetching token for code: _" + req["code"] + "_"); - if (HttpContext.Items.ContainsKey("Domain") && HttpContext.Items.ContainsKey("Scheme")) + if (HttpContext.Items.ContainsKey(RoutingConstants.DOMAIN) && HttpContext.Items.ContainsKey(RoutingConstants.SCHEME)) { - RedirectUri = HttpContext.Items["Scheme"].ToString() + "myaccount." + HttpContext.Items["Domain"].ToString(); + RedirectUri = HttpContext.Items[RoutingConstants.SCHEME].ToString() + "myaccount." + HttpContext.Items[RoutingConstants.DOMAIN].ToString(); } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/Controllers/ControllersV2/Api/BuilderApiController.cs b/Controllers/ControllersV2/Api/BuilderApiController.cs new file mode 100644 index 000000000..18753cc01 --- /dev/null +++ b/Controllers/ControllersV2/Api/BuilderApiController.cs @@ -0,0 +1,27 @@ +using ExpressBase.Common; +using ExpressBase.Web.Filters; +using ExpressBase.Web.Helpers; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace ExpressBase.Web.Controllers.ControllersV2.Api +{ + [Route("internal/api/v2/[controller]")] + [ApiController] + public class BuilderApiController : ControllerBase + { + [ServiceFilter(typeof(SolutionContextFilter))] + [TypeFilter(typeof(ApiUserAuthenticationFilter), Arguments = new object[] { RoutingConstants.DC })] + [HttpGet("GetPublicFormUrl")] + public IActionResult GetPublicFormUrl(string RefId) + { + var toReturn = new + { + RefId = RefId, + PublicFormUrl = EbPublicFormHelper.GenerateUrl(this.HttpContext,Url, RefId) + }; + + return Ok(toReturn); + } + } +} diff --git a/Controllers/ControllersV2/HealthCheckController.cs b/Controllers/ControllersV2/HealthCheckController.cs new file mode 100644 index 000000000..f60204001 --- /dev/null +++ b/Controllers/ControllersV2/HealthCheckController.cs @@ -0,0 +1,86 @@ +using ExpressBase.Common.Helpers; +using ExpressBase.Web.Helpers; +using Microsoft.AspNetCore.Mvc; +using ServiceStack.Redis; +using System; + +namespace ExpressBase.Web.Controllers.ControllersV2 +{ + [ApiController] + [Route("v2/[controller]")] + public class HealthCheckController : ControllerBase + { + [HttpGet] + public IActionResult Index() + { + try + { + + string redisStatus = "Unknown"; + string testValue = null; + string testKey = "healthcheck:testkey"; + string testData = Guid.NewGuid().ToString(); + var serverTimeZone = TimeZoneInfo.Local; + var utcNow = DateTime.UtcNow; + var localNow = TimeZoneInfo.ConvertTimeFromUtc(utcNow, serverTimeZone); + + try + { + var sp = HttpContext != null ? HttpContext.RequestServices : null; + + if (sp?.GetService(typeof(PooledRedisClientManager)) is PooledRedisClientManager pooledRedisClientManager) + { + + var ttl = TimeSpan.FromSeconds(30); + RedisCacheHelper.SetRaw(pooledRedisClientManager, testKey, testData, ttl); + testValue = RedisCacheHelper.GetRaw(pooledRedisClientManager, testKey); + + redisStatus = testValue == testData ? "ReadWriteOK" : "ReadWriteMismatch"; + + } + else + { + redisStatus = "NoServiceProvider"; + } + } + catch (Exception ex) + { + redisStatus = "Error: " + ex.Message; + } + + var response = new + { + status = "Healthy", + timestamp = localNow, + timeZone = new + { + id = serverTimeZone.Id, + displayName = serverTimeZone.DisplayName + }, + environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Unknown", + machine = Environment.MachineName, + redis = new + { + status = redisStatus, + sampleValue = testValue, + ttlSeconds = 30 + }, + clientIp = HttpContextHelper.GetIp(this.HttpContext), + host = HttpContext.Items["Host"]?.ToString() + }; + + return Ok(response); + } + catch (Exception exception) + { + var response = new + { + status = "UnHealthy", + exception = exception.Message, + }; + + return Ok(response); + } + } + } +} diff --git a/Controllers/ControllersV2/InternalExceptionController.cs b/Controllers/ControllersV2/InternalExceptionController.cs new file mode 100644 index 000000000..fa07c287a --- /dev/null +++ b/Controllers/ControllersV2/InternalExceptionController.cs @@ -0,0 +1,89 @@ +using ExpressBase.Common.Helpers; +using ExpressBase.Web.Helpers; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using System; + +namespace ExpressBase.Web.Controllers.ControllersV2 +{ + [Microsoft.AspNetCore.Mvc.Route("v2/InternalException")] + [ApiExplorerSettings(IgnoreApi = true)] + public class InternalExceptionController : Controller + { + private readonly IHostingEnvironment _env; + private readonly IServiceProvider _serviceProvider; + private static readonly TimeSpan TicketTtl = TimeSpan.FromSeconds(90); + + public InternalExceptionController(IServiceProvider serviceProvider,IHostingEnvironment env) + { + _env = env; + _serviceProvider = serviceProvider; + } + + [HttpGet("{ticketId?}")] + //[RedisRateLimit(limit: 6, windowSeconds: 60, useIp: true, perPath: true, useExternalSolutionId: true, customKey: "internal_exceptions:v2")] + public IActionResult Index(string ticketId) + { + var isDev = _env.IsDevelopment(); + + if (HttpContextHelper.WantsJson(HttpContext)) + { + SerializableExceptionDto exception = null; + + if (StringHelper.HasValue(ticketId)) + { + exception = InternalExcepionHelper.Get(this, ticketId); + } + + var jsonResponse = new + { + IsDevelopment = isDev, + TicketId = ticketId, + Exception = isDev ? exception?.Message : "an excpetion oocurred", + StackTrace = isDev ? exception?.StackTrace : null, + InnerExcerption = isDev ? exception?.InnerException?.Message : null, + InnerExcerptionStackTrace = isDev ? exception?.InnerException?.StackTrace : null, + }; + + return new JsonResult(jsonResponse); + } + + + if (StringHelper.HasValue(ticketId)) + { + SerializableExceptionDto exception = InternalExcepionHelper.Get(this, ticketId); + + if (exception != null) + { + return View( + "~/Views/InternalException/Index.cshtml", + new InternalExceptionViewModel + { + IsDevelopment = isDev, + TicketId = ticketId, + Exception = exception + } + ); + } + } + + return View( + "~/Views/InternalException/Index.cshtml", + new InternalExceptionViewModel + { + IsDevelopment = isDev, + TicketId = ticketId + } + ); + } + + } + + public sealed class InternalExceptionViewModel + { + public bool IsDevelopment { get; set; } + public string TicketId { get; set; } + public SerializableExceptionDto Exception { get; set; } + } + +} diff --git a/Controllers/ControllersV2/PublicFormController.cs b/Controllers/ControllersV2/PublicFormController.cs new file mode 100644 index 000000000..63090a095 --- /dev/null +++ b/Controllers/ControllersV2/PublicFormController.cs @@ -0,0 +1,73 @@ +using ExpressBase.Common; +using ExpressBase.Common.Extensions; +using ExpressBase.Common.Helpers; +using ExpressBase.Objects.Dtos; +using ExpressBase.Web.Filters; +using ExpressBase.Web.Helpers; +using Microsoft.AspNetCore.Mvc; +using System; + +namespace ExpressBase.Web.Controllers.ControllersV2 +{ + [ServiceFilter(typeof(SolutionContextFilter))] + [ServiceFilter(typeof(PublicUserAuthenticationFilter))] + public class PublicFormController : Controller + { + [HttpGet("v2/PublicForm")] + public IActionResult Index(string publicFormQparams) + { + + try + { + + if(publicFormQparams == null) + { + throw new ArgumentNullException(nameof(publicFormQparams), "publicFormQparams is required"); + } + + string base64Key = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_AES_ENC_KEY) ?? throw new Exception(EnvironmentConstants.EB_AES_ENC_KEY + " EnvironmentConstant not found"); + + PublicFormV2QueryParamsDto dto = + QueryStringEncDecHelper.DecryptEncryptedString(publicFormQparams, base64Key); + + string publicFormRefId = dto.PublicFormRefId; + //string sourceFormRefId = publicFormV2QueryParamsDto.SourceFormRefId; + //int formDataId = publicFormV2QueryParamsDto.FormDataId; + + + if (StringHelper.HasValue(publicFormRefId) == false) + { + + throw new ArgumentNullException(nameof(publicFormRefId), "publicFormRefId is required"); + } + + string paramsToPrefillInPublicForm = String.Empty; + + if (dto.PrefillParams != null) + { + + paramsToPrefillInPublicForm = Newtonsoft.Json.JsonConvert.SerializeObject(dto.PrefillParams).ToBase64(); + } + + return RedirectToAction( + "Index", + "WebForm", + new + { + _r = publicFormRefId, + _p = paramsToPrefillInPublicForm, + _m = "2", + _l = "1", + _rm = "5" + } + ); + } + catch (Exception ex) + { + return InternalExcepionHelper.Redirect(ex, this, TimeSpan.FromSeconds(120)); + } + + } + + } +} diff --git a/Controllers/Eb_ObjectController.cs b/Controllers/Eb_ObjectController.cs index 639ef9504..74bd9f7bd 100644 --- a/Controllers/Eb_ObjectController.cs +++ b/Controllers/Eb_ObjectController.cs @@ -1,27 +1,31 @@ -using System; -using System.Collections.Generic; -using Microsoft.AspNetCore.Mvc; -using ServiceStack; -using ServiceStack.Redis; +using DiffPlex; +using DiffPlex.DiffBuilder; +using DiffPlex.DiffBuilder.Model; using ExpressBase.Common; -using ExpressBase.Objects.ServiceStack_Artifacts; +using ExpressBase.Common.Constants; +using ExpressBase.Common.Helpers; +using ExpressBase.Common.LocationNSolution; using ExpressBase.Common.Objects; +using ExpressBase.Common.SqlProfiler; +using ExpressBase.Common.Structures; using ExpressBase.Objects; -using System.Reflection; -using DiffPlex.DiffBuilder; -using DiffPlex; -using DiffPlex.DiffBuilder.Model; +using ExpressBase.Objects.Dtos; +using ExpressBase.Objects.Objects.DVRelated; +using ExpressBase.Objects.Objects.SmsRelated; +using ExpressBase.Objects.ServiceStack_Artifacts; +using ExpressBase.Web.BaseControllers; +using ExpressBase.Web.Filters; +using ExpressBase.Web.Helpers; +using iTextSharp.text; +using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; +using ServiceStack; +using ServiceStack.Redis; +using System; +using System.Collections.Generic; +using System.Reflection; using System.Text; -using ExpressBase.Common.Structures; -using ExpressBase.Web.BaseControllers; using System.Text.RegularExpressions; -using ExpressBase.Web.Filters; -using ExpressBase.Objects.Objects.SmsRelated; -using ExpressBase.Common.SqlProfiler; -using ExpressBase.Objects.Objects.DVRelated; -using ExpressBase.Common.LocationNSolution; -using ExpressBase.Common.Helpers; namespace ExpressBase.Web.Controllers { public class Eb_ObjectController : EbBaseIntCommonController @@ -33,6 +37,7 @@ public Eb_ObjectController(IServiceClient sclient, IRedisClient redis) : base(sc [HttpPost] public IActionResult Index(string objid, int objtype, bool buildermode = true) { + EbObjectWrapper element = new EbObjectWrapper(); if (ViewBag.wc == "dc") { ViewBag.al_arz_map_key = Environment.GetEnvironmentVariable(EnvironmentConstants.AL_GOOGLE_MAP_KEY); @@ -51,7 +56,7 @@ public IActionResult Index(string objid, int objtype, bool buildermode = true) { ViewBag.Obj_id = objid; EbObjectExploreObjectResponse resultlist = ServiceClient.Get(new EbObjectExploreObjectRequest { Id = Convert.ToInt32(objid) }); - EbObjectWrapper element = resultlist.Data; + element = resultlist.Data; if (element != null) { ViewBag.IsNew = "false"; @@ -343,6 +348,15 @@ public IActionResult Index(string objid, int objtype, bool buildermode = true) EbWebForm _dsobj = _object as EbWebForm; _dsobj.AfterRedisGet(Redis, this.ServiceClient); ViewBag.dsObj = _dsobj; + + if(element.RefId != null && element.IsPublic == true) + { + + + ViewBag.PublicFormUrl = EbPublicFormHelper.GenerateUrl(this.HttpContext, Url, element.RefId); + } + + } else if (_object is EbUserControl) { @@ -351,6 +365,7 @@ public IActionResult Index(string objid, int objtype, bool buildermode = true) ViewBag.dsObj = _dsobj; } } + ViewBag.Meta = _c2js.AllMetas; ViewBag.JsObjects = _c2js.JsObjects; ViewBag.EbObjectTypes = _c2js.EbObjectTypes; @@ -555,6 +570,34 @@ public EbRootObjectResponse CommitEbObject(string _refid, string _json, string _ _response.Refid = res.RefId; _response.Message = res.Message; } + + + if (obj is EbWebForm webForm && string.IsNullOrWhiteSpace(_response.Refid) == false) + { + int objectId = Convert.ToInt32(_response.Refid?.Split(CharConstants.DASH)[3]); + int status = ObjectConstants.WEB_FORM_PRIVATE_STATUS_CODE; + + if (objectId > 0) + { + if (webForm.IsPublicForm == true) + { + status = ObjectConstants.WEB_FORM_PUBLIC_STATUS_CODE; + } + + this.ServiceClient.Post( + new ChangeObjectAccessRequest + { + ObjId = objectId, + Status = status + } + ); + } + else + { + throw new Exception("unable to fetch objectId"); + } + + } } catch (Exception e) { @@ -891,6 +934,11 @@ public IActionResult UpdateObjectDashboard(string refid, bool versioning) EbObjectWrapper w = obj; ViewBag.IsPublic = w.IsPublic; ViewBag.workingMode = w.WorkingMode; + if(w.IsPublic == true) + { + ViewBag.PublicFormUrl = EbPublicFormHelper.GenerateUrl(this.HttpContext, Url, refid); + } + return ViewComponent("ObjectDashboard", new { refid, objname = w.Name, w.Status, vernum = w.VersionNumber, workcopies = w.Wc_All, _tags = w.Tags, _apps = w.Apps, _dashbord_tiles = w.Dashboard_Tiles, _versioning = versioning }); } @@ -968,6 +1016,7 @@ public IActionResult UpdateBuilder(string _refid, int _tabnum, int _ObjType, str versionObj = Redis.Get(_refid); return ViewComponent("MobilePage", new { dsobj = EbSerializers.Json_Serialize(versionObj), tabnum = _tabnum, type = _ObjType, refid = _refid, ssurl = _ssurl }); } + return View(); } diff --git a/Controllers/StaticFileController.cs b/Controllers/StaticFileController.cs index ea13eef37..099d5dca2 100644 --- a/Controllers/StaticFileController.cs +++ b/Controllers/StaticFileController.cs @@ -53,9 +53,12 @@ public IActionResult GetLogo(string solnid) } [HttpGet("/wiki/images/{quality}/{refid}")] + [Obsolete] public IActionResult GetWikiImage(string refid, string quality) { - DownloadFileResponse dfs = null; + return new EmptyResult(); + + /*DownloadFileResponse dfs = null; ActionResult resp = new EmptyResult(); @@ -81,7 +84,7 @@ public IActionResult GetWikiImage(string refid, string quality) { Console.WriteLine("Exception: " + e.Message.ToString()); } - return resp; + return resp;*/ } [HttpGet("/botExt/images/{quality}/{refid}")] diff --git a/Controllers/WebFormController.cs b/Controllers/WebFormController.cs index e1e2a8726..c91e609e7 100644 --- a/Controllers/WebFormController.cs +++ b/Controllers/WebFormController.cs @@ -1,34 +1,35 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using ExpressBase.Common; -using ExpressBase.Objects.ServiceStack_Artifacts; -using ExpressBase.Objects.Objects.DVRelated; -using ExpressBase.Web.BaseControllers; -using Microsoft.AspNetCore.Mvc; -using ServiceStack; -using ServiceStack.Redis; -using Newtonsoft.Json; -using ExpressBase.Common.Structures; -using ExpressBase.Objects; -using ExpressBase.Common.Objects; -using ExpressBase.Common.Extensions; -using System.Reflection; -using ExpressBase.Common.Objects.Attributes; +using ExpressBase.Common; +using ExpressBase.Common.Constants; using ExpressBase.Common.Data; +using ExpressBase.Common.Extensions; using ExpressBase.Common.LocationNSolution; -using ExpressBase.Common.Constants; -using ExpressBase.Objects.Objects; -using System.IO; -using System.Net; +using ExpressBase.Common.Objects; +using ExpressBase.Common.Objects.Attributes; using ExpressBase.Common.ServerEvents_Artifacts; using ExpressBase.Common.ServiceClients; -using ExpressBase.Security; -using System.Collections; +using ExpressBase.Common.Structures; +using ExpressBase.Objects; +using ExpressBase.Objects.Objects; +using ExpressBase.Objects.Objects.DVRelated; +using ExpressBase.Objects.ServiceStack_Artifacts; using ExpressBase.Objects.WebFormRelated; +using ExpressBase.Security; +using ExpressBase.Web.BaseControllers; +using ExpressBase.Web.Helpers; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using ServiceStack; +using ServiceStack.Redis; +using System; +using System.Collections; +using System.Collections.Generic; using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Reflection; +using System.Threading.Tasks; namespace ExpressBase.Web.Controllers { @@ -38,19 +39,29 @@ public WebFormController(IServiceClient _ssclient, IRedisClient _redis, IEbServe public IActionResult Index(string _r, string _p, int _m, int _l, int _rm, string _lg) { - //_r => refId; _p => params; _m => mode; _l => locId; _rm => renderMode - string refId = _r, _params = _p, _language = _lg ?? this.CurrentLanguage ?? "en"; - int _mode = _m, _locId = _l;// - Console.WriteLine(string.Format("Webform Render - refid : {0}, prams : {1}, mode : {2}, locid : {3}", refId, _params, _mode, _locId)); - string resp = GetFormForRendering(refId, _params, _mode, _locId, _rm, false, false, _language); - EbFormAndDataWrapper result = JsonConvert.DeserializeObject(resp); - if (result.ErrorMessage != null) + try { - TempData["ErrorResp"] = GetFormattedErrMsg(result.ErrorMessage); - return RedirectToAction("Index", "StatusCode", new { statusCode = result.ErrorCode, m = GetFormattedErrMsg(result.ErrorMessage, true) }); + + string refId = _r, _params = _p, _language = _lg ?? this.CurrentLanguage ?? "en"; + int _mode = _m, _locId = _l; + string resp = GetFormForRendering(refId, _params, _mode, _locId, _rm, false, false, _language); + + EbFormAndDataWrapper result = JsonConvert.DeserializeObject(resp); + + if (result.ErrorMessage != null) + { + TempData["ErrorResp"] = GetFormattedErrMsg(result.ErrorMessage); + return RedirectToAction("Index", "StatusCode", new { statusCode = result.ErrorCode, m = GetFormattedErrMsg(result.ErrorMessage, true) }); + } + + ViewBag.EbFormAndDataWrapper = resp; + + return View(); + + }catch(Exception exception) + { + return InternalExcepionHelper.Redirect(exception, this, TimeSpan.FromSeconds(120)); } - ViewBag.EbFormAndDataWrapper = resp; - return View(); } public IActionResult Inde(int _r, string _p, int _m, int _l, int _rm, string _lg) diff --git a/Filters/ApiUserAuthenticationFilter.cs b/Filters/ApiUserAuthenticationFilter.cs new file mode 100644 index 000000000..cddb9ce80 --- /dev/null +++ b/Filters/ApiUserAuthenticationFilter.cs @@ -0,0 +1,156 @@ +using DocumentFormat.OpenXml.Presentation; +using ExpressBase.Common; +using ExpressBase.Common.Constants; +using ExpressBase.Common.Helpers; +using ExpressBase.Common.ServiceClients; +using ExpressBase.Objects.ServiceStack_Artifacts; +using ExpressBase.Security; +using ExpressBase.Web.Helpers; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.DependencyInjection; +using ServiceStack; +using ServiceStack.Auth; +using ServiceStack.Redis; +using System; +using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace ExpressBase.Web.Filters +{ + + public sealed class ApiUserAuthenticationFilter : IAsyncResourceFilter + { + private readonly IServiceClient _serviceClient; + private readonly IEbAuthClient _authClient; + private string _forcedConsole; + + //TODO: add support for stateless APIs + public ApiUserAuthenticationFilter(IServiceClient serviceClient, IEbAuthClient authClient, string forcedConsole) + { + _serviceClient = serviceClient; + _authClient = authClient; + _forcedConsole = forcedConsole; + } + + public Task OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next) + { + string externalSoltionId; + string internalSolutionId; + string bearerToken = context.HttpContext.Request.Cookies[RoutingConstants.WEB_BEARER_TOKEN] ?? context.HttpContext.Request.Cookies[RoutingConstants.BEARER_TOKEN]; + string refreshToken = context.HttpContext.Request.Cookies[RoutingConstants.WEB_REFRESH_TOKEN] ?? context.HttpContext.Request.Cookies[RoutingConstants.REFRESH_TOKEN]; + User user; + string userId; + string userAuthId; + string clientIp = HttpContextHelper.GetIp(context.HttpContext); + string currentConsole; + + if (context.HttpContext.Items.ContainsKey(RoutingConstants.EXTERNAL_SOLUTION_ID)) + { + externalSoltionId = context.HttpContext.Items[RoutingConstants.EXTERNAL_SOLUTION_ID].ToString(); + } + else + { + throw new InvalidOperationException("External solution ID not found in context."); + } + + if (context.HttpContext.Items.ContainsKey(RoutingConstants.INTERNAL_SOLUTION_ID)) + { + internalSolutionId = context.HttpContext.Items[RoutingConstants.INTERNAL_SOLUTION_ID].ToString(); + } + else + { + throw new InvalidOperationException("InternalSolutionId solution ID not found in context."); + } + if (context.HttpContext.Items.ContainsKey("Console")) + { + currentConsole = context.HttpContext.Items["Console"].ToString(); + } + else + { + throw new InvalidOperationException("Console not found in context."); + } + + if(this._forcedConsole != null && this._forcedConsole != currentConsole) + { + context.Result = new JsonResult(new + { + success = false, + message = "Unauthorized access", + statusCode = 401 + }) + { + StatusCode = 401 + }; + } + + if(UserAuthenticationHelper.IsTokensValid(refreshToken, bearerToken, internalSolutionId, clientIp, currentConsole) ) + { + + var bearerTokenPayload = new JwtSecurityToken(bearerToken).Payload; + + userId = bearerTokenPayload[TokenConstants.UID]?.ToString() ?? throw new InvalidOperationException("Invalid session."); + + userAuthId = bearerTokenPayload[TokenConstants.SUB]?.ToString() ?? throw new InvalidOperationException("Invalid session."); + + var redisManager = context.HttpContext.RequestServices.GetRequiredService(); + + user = UserAuthenticationHelper.GetUserObject( + redisManager, + _serviceClient, + userId, + userAuthId, + currentConsole, + internalSolutionId + ); + + } else + { + + context.Result = new JsonResult(new + { + success = false, + message = "Unauthorized access", + statusCode = 401 + }) + { + StatusCode = 401 + }; + + return Task.CompletedTask; + + + } + + if(user != null) + { + context.HttpContext.Items[RoutingConstants.CONTEXT_BEARER_TOKEN] = bearerToken; + context.HttpContext.Items[RoutingConstants.CONTEXT_REFRESH_TOKEN] = refreshToken; + context.HttpContext.Items[RoutingConstants.AUTH_ID] = user.AuthId; + context.HttpContext.Items[RoutingConstants.USER] = user; + + } + else + { + context.Result = new JsonResult(new + { + success = false, + message = "Unauthorized access", + statusCode = 401 + }) + { + StatusCode = 401 + }; + + return Task.CompletedTask; + } + + return next(); + + } + } +} diff --git a/Filters/PublicUserAuthenticationFilter.cs b/Filters/PublicUserAuthenticationFilter.cs new file mode 100644 index 000000000..de409d73c --- /dev/null +++ b/Filters/PublicUserAuthenticationFilter.cs @@ -0,0 +1,175 @@ +using DocumentFormat.OpenXml.Presentation; +using ExpressBase.Common; +using ExpressBase.Common.Constants; +using ExpressBase.Common.Helpers; +using ExpressBase.Common.ServiceClients; +using ExpressBase.Objects.ServiceStack_Artifacts; +using ExpressBase.Security; +using ExpressBase.Web.Helpers; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.DependencyInjection; +using ServiceStack; +using ServiceStack.Auth; +using ServiceStack.Redis; +using System; +using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace ExpressBase.Web.Filters +{ + + public sealed class PublicUserAuthenticationFilter : IAsyncResourceFilter + { + private readonly IServiceClient _serviceClient; + private readonly IEbAuthClient _authClient; + + public PublicUserAuthenticationFilter(IServiceClient serviceClient, IEbAuthClient authClient) + { + _serviceClient = serviceClient; + _authClient = authClient; + } + + public Task OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next) + { + string externalSoltionId; + string internalSolutionId; + string bearerToken = context.HttpContext.Request.Cookies[RoutingConstants.WEB_BEARER_TOKEN] ?? context.HttpContext.Request.Cookies[RoutingConstants.BEARER_TOKEN]; + string refreshToken = context.HttpContext.Request.Cookies[RoutingConstants.WEB_REFRESH_TOKEN] ?? context.HttpContext.Request.Cookies[RoutingConstants.REFRESH_TOKEN]; + User user; + string userId; + string userAuthId; + string clientIp = HttpContextHelper.GetIp(context.HttpContext); + string currentConsole; + + if (context.HttpContext.Items.ContainsKey(RoutingConstants.EXTERNAL_SOLUTION_ID)) + { + externalSoltionId = context.HttpContext.Items[RoutingConstants.EXTERNAL_SOLUTION_ID].ToString(); + } + else + { + throw new InvalidOperationException("External solution ID not found in context."); + } + + if (context.HttpContext.Items.ContainsKey(RoutingConstants.INTERNAL_SOLUTION_ID)) + { + internalSolutionId = context.HttpContext.Items[RoutingConstants.INTERNAL_SOLUTION_ID].ToString(); + } + else + { + throw new InvalidOperationException("InternalSolutionId solution ID not found in context."); + } + if (context.HttpContext.Items.ContainsKey("Console")) + { + currentConsole = context.HttpContext.Items["Console"].ToString(); + } + else + { + throw new InvalidOperationException("Console not found in context."); + } + + if(currentConsole != RoutingConstants.UC) + { + throw new InvalidOperationException("Invalid console."); + } + + + if(UserAuthenticationHelper.IsTokensValid(refreshToken, bearerToken, internalSolutionId, clientIp, currentConsole) == false) + { + + var authRequest = new Authenticate + { + provider = CredentialsAuthProvider.Name, + UserName = "NIL", + Password = "NIL", + Meta = new Dictionary { + { RoutingConstants.WC, TokenConstants.UC }, + { TokenConstants.EMAIL, TokenConstants.PUBLIC_FORM_V2_ANONYMOUS_USER_EMAIL }, + { TokenConstants.CID, internalSolutionId }, + { TokenConstants.IP, clientIp}, + { RoutingConstants.USER_AGENT, context.HttpContext.Request.Headers["User-Agent"].ToString()}, + { TokenConstants.SESSION_TAG, TokenConstants.ANONYMOUS_USER_V2_SESSION_TAG}, + }, + RememberMe = true + }; + + + var authResponse = this._authClient.Get(authRequest); + + if (authResponse != null && authResponse.User != null) + { + user = authResponse.User; + bearerToken = authResponse.BearerToken; + refreshToken = authResponse.RefreshToken; + //userAuthId = authResponse.User.AuthId; + + var cookieOpts = new Microsoft.AspNetCore.Http.CookieOptions + { + HttpOnly = true, + Secure = context.HttpContext.Request.IsHttps, + SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Strict, + Expires = DateTimeOffset.UtcNow.AddMinutes(59) //TODO: shouldn't this be same as token expiry? + }; + + context.HttpContext.Response.Cookies.Append(RoutingConstants.WEB_BEARER_TOKEN, bearerToken, cookieOpts); + context.HttpContext.Response.Cookies.Append(RoutingConstants.BEARER_TOKEN, bearerToken, cookieOpts); + context.HttpContext.Response.Cookies.Append(RoutingConstants.WEB_REFRESH_TOKEN, refreshToken, cookieOpts); + context.HttpContext.Response.Cookies.Append(RoutingConstants.REFRESH_TOKEN, refreshToken, cookieOpts); + + if (_serviceClient is JsonServiceClient jsonServiceClient) + { + jsonServiceClient.BearerToken = bearerToken ?? string.Empty; + jsonServiceClient.RefreshToken = refreshToken ?? string.Empty; + jsonServiceClient.Headers.Add(CacheConstants.RTOKEN, refreshToken ?? string.Empty); + } + + } + else + { + throw new InvalidOperationException("Invalid session."); + } + + } else + { + + var bearerTokenPayload = new JwtSecurityToken(bearerToken).Payload; + + userId = bearerTokenPayload[TokenConstants.UID]?.ToString() ?? throw new InvalidOperationException("Invalid session."); + + userAuthId = bearerTokenPayload[TokenConstants.SUB]?.ToString() ?? throw new InvalidOperationException("Invalid session."); + + var redisManager = context.HttpContext.RequestServices.GetRequiredService(); + + user = UserAuthenticationHelper.GetUserObject( + redisManager, + _serviceClient, + userId, + userAuthId, + currentConsole, + internalSolutionId + ); + + + } + + if(user != null) + { + context.HttpContext.Items[RoutingConstants.CONTEXT_BEARER_TOKEN] = bearerToken; + context.HttpContext.Items[RoutingConstants.CONTEXT_REFRESH_TOKEN] = refreshToken; + context.HttpContext.Items[RoutingConstants.AUTH_ID] = user.AuthId; + context.HttpContext.Items[RoutingConstants.USER] = user; + + } + else + { + throw new InvalidOperationException("Invalid session."); + } + + return next(); + + } + } +} diff --git a/Filters/SolutionContextFilter.cs b/Filters/SolutionContextFilter.cs new file mode 100644 index 000000000..69d4b0832 --- /dev/null +++ b/Filters/SolutionContextFilter.cs @@ -0,0 +1,67 @@ +using DocumentFormat.OpenXml.Presentation; +using ExpressBase.Common; +using ExpressBase.Common.Constants; +using ExpressBase.Common.Helpers; +using ExpressBase.Objects.ServiceStack_Artifacts; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.DependencyInjection; +using ServiceStack; +using ServiceStack.Redis; +using System; +using System.Threading.Tasks; + +namespace ExpressBase.Web.Filters +{ + + public sealed class SolutionContextFilter : IAsyncResourceFilter + { + private readonly IServiceClient _serviceClient; + + public SolutionContextFilter(IServiceClient serviceClient) + { + _serviceClient = serviceClient; + } + + public Task OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next) + { + string internalSolutionId; + string externalSoultionId; + + if(context.HttpContext.Items.ContainsKey(RoutingConstants.EXTERNAL_SOLUTION_ID)) + { + externalSoultionId = context.HttpContext.Items[RoutingConstants.EXTERNAL_SOLUTION_ID].ToString(); + + } else + { + throw new InvalidOperationException("External solution ID not found in context."); + } + + + /*if (externalSoultionId == CoreConstants.MYACCOUNT) + { + internalSolutionId = CoreConstants.EXPRESSBASE; + } + else if (externalSoultionId == CoreConstants.ADMIN) + { + externalSoultionId = CoreConstants.ADMIN; + }*/ + + var redisManager = context.HttpContext.RequestServices.GetRequiredService(); + + if(RedisCacheHelper.Exists(redisManager, string.Format(CoreConstants.SOLUTION_ID_MAP, externalSoultionId))) + { + internalSolutionId = RedisCacheHelper.Get(redisManager,string.Format(CoreConstants.SOLUTION_ID_MAP, externalSoultionId)); + + } else + { + this._serviceClient.Post(new UpdateSidMapRequest { ExtSolutionId = externalSoultionId }); + internalSolutionId = RedisCacheHelper.Get(redisManager, string.Format(CoreConstants.SOLUTION_ID_MAP, externalSoultionId)); + } + + context.HttpContext.Items[RoutingConstants.INTERNAL_SOLUTION_ID] = internalSolutionId ?? throw new InvalidOperationException("External solution ID is invalid."); + + return next(); + + } + } +} diff --git a/Helpers/AppConfigViewHelper.cs b/Helpers/AppConfigViewHelper.cs index 2952477bf..5a69c9e1b 100644 --- a/Helpers/AppConfigViewHelper.cs +++ b/Helpers/AppConfigViewHelper.cs @@ -1,3 +1,4 @@ +using ExpressBase.Common; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; using Newtonsoft.Json; @@ -23,14 +24,14 @@ public static string RenderJson(HttpContext context) var appConfig = new { Env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"), - Scheme = context.Items["Scheme"]?.ToString(), - Host = context.Items["Host"]?.ToString(), + Scheme = context.Items[RoutingConstants.SCHEME]?.ToString(), + Host = context.Items[RoutingConstants.HOST]?.ToString(), BaseHost = cfg.Value.BaseHost, LocalPort = cfg.Value.LocalPort, - Domain = context.Items["Domain"]?.ToString(), + Domain = context.Items[RoutingConstants.DOMAIN]?.ToString(), ServerEventUrlPrefix = cfg.Value.ServerEventUrlPrefix, - DevConsoleHost = context.Items["DevConsoleHost"]?.ToString(), - UserConsoleHost = context.Items["UserConsoleHost"]?.ToString() + DevConsoleHost = context.Items[RoutingConstants.DEV_CONSOLE_HOST]?.ToString(), + UserConsoleHost = context.Items[RoutingConstants.USER_CONSOLE_HOST]?.ToString() }; var jsonSettings = new JsonSerializerSettings diff --git a/Helpers/EbPublicFormHelper.cs b/Helpers/EbPublicFormHelper.cs new file mode 100644 index 000000000..8cb664223 --- /dev/null +++ b/Helpers/EbPublicFormHelper.cs @@ -0,0 +1,31 @@ +using ExpressBase.Common; +using ExpressBase.Common.Helpers; +using ExpressBase.Objects.Dtos; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; + +namespace ExpressBase.Web.Helpers +{ + public static class EbPublicFormHelper + { + public static string GenerateUrl(HttpContext HttpContext, IUrlHelper UrlHelper, string RefId) + { + string base64Key = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_AES_ENC_KEY) ?? throw new Exception(EnvironmentConstants.EB_AES_ENC_KEY + " EnvironmentConstant not found"); + + var dto = new PublicFormV2QueryParamsDto + { + PublicFormRefId = RefId + }; + + return + HttpContext.Items[RoutingConstants.SCHEME].ToString() + + HttpContext.Items[RoutingConstants.USER_CONSOLE_HOST].ToString() + + UrlHelper.Action( + action: "Index", + controller: "PublicForm", + values: new { publicFormQparams = QueryStringEncDecHelper.EncryptString(dto, base64Key) } + ); + } + } +} diff --git a/Helpers/HttpContextHelper.cs b/Helpers/HttpContextHelper.cs new file mode 100644 index 000000000..6a2427215 --- /dev/null +++ b/Helpers/HttpContextHelper.cs @@ -0,0 +1,76 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace ExpressBase.Web.Helpers +{ + public class HttpContextHelper + { + + + public static string GetIp(HttpContext httpContext) + { + + string headerValue = null; + + if (httpContext.Request.Headers.TryGetValue("Eb-X-Forwarded-For", out var ebFwd) && + !string.IsNullOrWhiteSpace(ebFwd)) + { + headerValue = ebFwd.ToString(); + } + else if (httpContext.Request.Headers.TryGetValue("X-Forwarded-For", out var stdFwd) && + !string.IsNullOrWhiteSpace(stdFwd)) + { + headerValue = stdFwd.ToString(); + } + + if (!string.IsNullOrWhiteSpace(headerValue)) + { + + var commaIndex = headerValue.IndexOf(','); + var clientIp = commaIndex >= 0 ? headerValue.Substring(0, commaIndex) : headerValue; + return clientIp.Trim(); + } + + + var remoteIp = httpContext.Connection.RemoteIpAddress; + + return remoteIp?.MapToIPv4().ToString(); + } + + public static bool WantsJson(HttpContext httpContext) + { + + if (httpContext.Request.Headers.TryGetValue("Accept", out var accept)) + { + var a = accept.ToString().ToLowerInvariant(); + if (a.Contains("application/json") || a.Contains("+json") || a.Contains("text/json")) + { + return true; + } + + } + + + var q = httpContext.Request.Query; + if (q.TryGetValue("format", out var fmt) && string.Equals(fmt.ToString(), "json", StringComparison.OrdinalIgnoreCase)) + { + return true; + } + + + if (httpContext.Request.Headers.TryGetValue("X-Requested-With", out var xrw) && + xrw.ToString().Equals("XMLHttpRequest", StringComparison.OrdinalIgnoreCase)) + { + return true; + } + + + return false; + } + } +} diff --git a/Helpers/InternalExcepionHelper.cs b/Helpers/InternalExcepionHelper.cs new file mode 100644 index 000000000..8093ff003 --- /dev/null +++ b/Helpers/InternalExcepionHelper.cs @@ -0,0 +1,78 @@ +using ExpressBase.Common.Helpers; +using Microsoft.AspNetCore.Mvc; +using ServiceStack.Redis; +using System; +namespace ExpressBase.Web.Helpers +{ + public static class InternalExcepionHelper + { + private const string CachePrefix = "InternalExcepionHelper"; + private const int DefaultTimeSpanSeconds = 60; + + private static PooledRedisClientManager GetRedisManager(Controller controller) + { + if (controller == null) + throw new ArgumentNullException(nameof(controller)); + + var serviceProvider = controller.HttpContext?.RequestServices; + + if (serviceProvider == null) + throw new InvalidOperationException("RequestServices not available in controller context."); + + var redisManager = serviceProvider.GetService(typeof(PooledRedisClientManager)) as PooledRedisClientManager; + + if (redisManager == null) + throw new InvalidOperationException("PooledRedisClientManager not registered in DI container."); + + return redisManager; + } + + private static void Set(Controller controller, Exception exception, string prefix, TimeSpan? ttl = null) + { + var redisManager = GetRedisManager(controller); + var serializableEx = SerializableExceptionDto.FromException(exception); + + RedisCacheHelper.Set(redisManager, CachePrefix + prefix, serializableEx, ttl); + } + + public static IActionResult Redirect(Exception exception, Controller controller, TimeSpan? ttl = null) + { + if (controller == null) + throw new ArgumentNullException(nameof(controller)); + + if (exception == null) + throw new ArgumentNullException(nameof(exception)); + + string ticketId = Guid.NewGuid().ToString("N"); + + Set(controller, exception, ticketId, ttl ?? TimeSpan.FromSeconds(DefaultTimeSpanSeconds)); + + return controller.RedirectToAction( + "Index", + "InternalException", + new { ticketId } + ); + } + + public static SerializableExceptionDto Get(Controller controller, string ticketId) + { + if (controller == null) + throw new ArgumentNullException(nameof(controller)); + + if (string.IsNullOrWhiteSpace(ticketId)) + throw new ArgumentNullException(nameof(ticketId)); + + var redisManager = GetRedisManager(controller); + + var key = CachePrefix + ticketId; + + if (RedisCacheHelper.Exists(redisManager, key)) + { + return RedisCacheHelper.Get(redisManager, key); + } + + return null; + } + + } +} diff --git a/Helpers/UserAuthenticationHelper.cs b/Helpers/UserAuthenticationHelper.cs new file mode 100644 index 000000000..3179bc254 --- /dev/null +++ b/Helpers/UserAuthenticationHelper.cs @@ -0,0 +1,170 @@ +using ExpressBase.Common; +using ExpressBase.Common.Constants; +using ExpressBase.Common.Helpers; +using ExpressBase.Objects.ServiceStack_Artifacts; +using ExpressBase.Security; +using ServiceStack; +using ServiceStack.Redis; +using System; +using System.IdentityModel.Tokens.Jwt; +using System.Security.Cryptography; +using System.Text; + +namespace ExpressBase.Web.Helpers +{ + public static class UserAuthenticationHelper + { + public static bool IsTokensValid( + string refreshToken, + string bearerToken, + string internalSolutionId, + string clientIp, + string currentConsole + ) + { + if (StringHelper.HasValue(refreshToken) == false || StringHelper.HasValue(bearerToken) == false) + { + return false; + } + + try + { + + if (VerifySignature(refreshToken) && VerifySignature(bearerToken)) + { + var refreshTokenData = new JwtSecurityToken(refreshToken); + var bearerTokenData = new JwtSecurityToken(bearerToken); + + if (bearerTokenData.Payload[TokenConstants.CID].ToString() == internalSolutionId) + { + string rSub = refreshTokenData.Payload[TokenConstants.SUB].ToString(); + string bSub = bearerTokenData.Payload[TokenConstants.SUB].ToString(); + string ipFromToken = bearerTokenData.Payload[TokenConstants.IP].ToString(); + + + var tokenExpiry = Convert.ToInt64(refreshTokenData.Payload[TokenConstants.EXP]); + DateTime tokenExpiryDateTime = DateTimeOffset.FromUnixTimeSeconds(tokenExpiry).UtcDateTime; + + if(tokenExpiryDateTime < DateTime.UtcNow) + { + return false; + } + + if(StringHelper.HasValue(ipFromToken) != false && clientIp != ipFromToken) + { + return false; + } + + if (rSub == bSub) + { + + string[] subParts = rSub.Split(CharConstants.COLON); + + if (rSub.EndsWith(TokenConstants.TC)) + { + return true; + } + + else if (currentConsole == RoutingConstants.DC) + { + if (subParts[0] == internalSolutionId && rSub.EndsWith(TokenConstants.DC)) + { + return true; + } + + } + else if (rSub.EndsWith(TokenConstants.UC) || rSub.EndsWith(TokenConstants.BC) || rSub.EndsWith(TokenConstants.MC) || rSub.EndsWith(TokenConstants.PC)) + { + return true; + } + } + } + } + } + catch (Exception) + { + + return false; + } + + return false; + } + + public static bool VerifySignature(string token) + { + string PublicKey = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_JWT_PUBLIC_KEY_XML); + int pos1 = PublicKey.IndexOf(""); + int pos2 = PublicKey.IndexOf(""); + int pos3 = PublicKey.IndexOf(""); + int pos4 = PublicKey.IndexOf(""); + string modkeypub = PublicKey.Substring(pos1 + 9, pos2 - pos1 - 9); + string expkeypub = PublicKey.Substring(pos3 + 10, pos4 - pos3 - 10); + + try + { + string[] tokenParts = token.Split('.'); + RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); + rsa.ImportParameters( + new RSAParameters() + { + Modulus = FromBase64Url(modkeypub), + Exponent = FromBase64Url(expkeypub) + }); + + SHA256 sha256 = SHA256.Create(); + byte[] hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(tokenParts[0] + '.' + tokenParts[1])); + + RSAPKCS1SignatureDeformatter rsaDeformatter = new RSAPKCS1SignatureDeformatter(rsa); + rsaDeformatter.SetHashAlgorithm("SHA256"); + if (rsaDeformatter.VerifySignature(hash, FromBase64Url(tokenParts[2]))) + { + return true; + } + } + catch (Exception e) { Console.WriteLine("Exception from VerifySignature:" + e.ToString()); } + return false; + } + + public static byte[] FromBase64Url(string base64Url) + { + string padded = base64Url.Length % 4 == 0 ? base64Url : base64Url + "====".Substring(base64Url.Length % 4); + + string base64 = padded.Replace("_", "/").Replace("-", "+"); + + return Convert.FromBase64String(base64); + } + + public static User GetUserObject( + PooledRedisClientManager pooledRedisManager, + IServiceClient serviceClient, + string userId, + string userAuthId, + string currentConsole, + string internalSolutionId + ) + { + + if (RedisCacheHelper.Exists(pooledRedisManager, userAuthId)) + { + return RedisCacheHelper.Get(pooledRedisManager, userAuthId); + + } else + { + serviceClient.Post( + new UpdateUserObjectRequest() + { + SolnId = internalSolutionId, + UserId = Convert.ToInt32(userId), + UserAuthId = userAuthId, + WC = currentConsole, + IsApiUser = false + } + ); + + return RedisCacheHelper.Get(pooledRedisManager, userAuthId); + } + + + } + } +} diff --git a/Middlewares/AppUrlContextMiddleware.cs b/Middlewares/AppUrlContextMiddleware.cs index 112260eb7..e9e01a182 100644 --- a/Middlewares/AppUrlContextMiddleware.cs +++ b/Middlewares/AppUrlContextMiddleware.cs @@ -1,4 +1,5 @@ -using ExpressBase.Common.Helpers; +using ExpressBase.Common; +using ExpressBase.Common.Helpers; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; using System; @@ -22,8 +23,8 @@ public async Task Invoke(HttpContext context) //DebugHelper.PrintObject(this._cfg, printAsJson: true, label: "this._cfg"); //DebugHelper.PrintObject(context.Request, label: "context"); - var host = context.Request.Host.ToString(); //demobakerystaging-dev.expressbase.com - string baseHost = _cfg.BaseHost; //expressbase.com + var host = context.Request.Host.ToString(); // demobakerystaging-dev.expressbase.com + string baseHost = _cfg.BaseHost; // expressbase.com string subdomain = null; string domain = null; @@ -55,22 +56,25 @@ public async Task Invoke(HttpContext context) if (subdomain.EndsWith(this._cfg.DevDomainSuffix, StringComparison.OrdinalIgnoreCase) == false) { - context.Items["DevConsoleHost"] = subdomain + this._cfg.DevDomainSuffix + "." + baseHost; //demobakerystaging-dev.expressbase.com + context.Items[RoutingConstants.DEV_CONSOLE_HOST] = subdomain + this._cfg.DevDomainSuffix + "." + baseHost; // demobakerystaging-dev.expressbase.com + context.Items[RoutingConstants.CONSOLE] = RoutingConstants.UC; + } else { - context.Items["DevConsoleHost"] = subdomain + "." + baseHost; //demobakerystaging-dev.expressbase.com + context.Items[RoutingConstants.DEV_CONSOLE_HOST] = subdomain + "." + baseHost; // demobakerystaging-dev.expressbase.com + context.Items[RoutingConstants.CONSOLE] = RoutingConstants.DC; } - context.Items["ExternalSolutionId"] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty); //demobakerystaging - context.Items["UserConsoleHost"] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty) + "." + baseHost; //demobakerystaging.expressbase.com - context.Items["SubDomain"] = subdomain; //demobakerystaging || demobakerystaging-dev + context.Items[RoutingConstants.EXTERNAL_SOLUTION_ID] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty); // demobakerystaging + context.Items[RoutingConstants.USER_CONSOLE_HOST] = subdomain?.Replace(this._cfg.DevDomainSuffix, string.Empty) + "." + baseHost; // demobakerystaging.expressbase.com + context.Items[RoutingConstants.SUB_DOMAIN] = subdomain; // demobakerystaging || demobakerystaging-dev } - context.Items["BaseHost"] = baseHost; - context.Items["Scheme"] = this._cfg.Scheme; - context.Items["Host"] = host; - context.Items["Domain"] = domain; + context.Items[RoutingConstants.BASE_HOST] = baseHost; // expressbase.com + context.Items[RoutingConstants.SCHEME] = this._cfg.Scheme; // https:// || http:// + context.Items[RoutingConstants.HOST] = host; // demobakerystaging-dev.expressbase.com || demobakerystaging.expressbase.com + context.Items[RoutingConstants.DOMAIN] = domain; // expressbase.com await _next(context); } diff --git a/Startup.cs b/Startup.cs index 0ab0d4c08..17af0f720 100644 --- a/Startup.cs +++ b/Startup.cs @@ -167,6 +167,10 @@ public void ConfigureServices(IServiceCollection services) services.Configure(Configuration.GetSection("AppConfiguration")); + + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); } diff --git a/Views/Dev/AppDashBoard.cshtml b/Views/Dev/AppDashBoard.cshtml index 8f266e065..70378027e 100644 --- a/Views/Dev/AppDashBoard.cshtml +++ b/Views/Dev/AppDashBoard.cshtml @@ -12,11 +12,11 @@ var solutionid = ViewBag.cide; - if (Context.Items.ContainsKey("Domain") && Context.Items.ContainsKey("Scheme")) + if (Context.Items.ContainsKey(RoutingConstants.DOMAIN) && Context.Items.ContainsKey(RoutingConstants.SCHEME)) { - domurl = Context.Items["Scheme"] + solutionid + "." + Context.Items["Domain"]; - jssrc = Context.Items["Scheme"] + sol_cid + "." + Context.Items["Domain"]; + domurl = Context.Items[RoutingConstants.SCHEME] + solutionid + "." + Context.Items[RoutingConstants.DOMAIN]; + jssrc = Context.Items[RoutingConstants.SCHEME] + sol_cid + "." + Context.Items[RoutingConstants.DOMAIN]; } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/Views/Docs/ImageUpHome.cshtml b/Views/Docs/ImageUpHome.cshtml index 066178a52..c43f6f3f8 100644 --- a/Views/Docs/ImageUpHome.cshtml +++ b/Views/Docs/ImageUpHome.cshtml @@ -143,6 +143,7 @@ var im = new ImageUploader_Doc({Tenantid:'@ViewBag.cid'}); *@ +@* \ No newline at end of file + + +*@ \ No newline at end of file diff --git a/Views/Ext/SignUp.cshtml b/Views/Ext/SignUp.cshtml index 5c0da8438..a48760e75 100644 --- a/Views/Ext/SignUp.cshtml +++ b/Views/Ext/SignUp.cshtml @@ -7,12 +7,12 @@ string sociallink = string.Empty; string signinLink = string.Empty; - if (Context.Items.ContainsKey("Domain") && Context.Items.ContainsKey("Scheme")) + if (Context.Items.ContainsKey(RoutingConstants.DOMAIN) && Context.Items.ContainsKey(RoutingConstants.SCHEME)) { - home = Context.Items["Scheme"].ToString() + Context.Items["Domain"]; - sociallink = Context.Items["Scheme"].ToString() + "ss." + Context.Items["Domain"]; - signinLink = Context.Items["Scheme"].ToString() + "myaccount." + Context.Items["Domain"]; + home = Context.Items[RoutingConstants.SCHEME].ToString() + Context.Items[RoutingConstants.DOMAIN]; + sociallink = Context.Items[RoutingConstants.SCHEME].ToString() + "ss." + Context.Items[RoutingConstants.DOMAIN]; + signinLink = Context.Items[RoutingConstants.SCHEME].ToString() + "myaccount." + Context.Items[RoutingConstants.DOMAIN]; } else //TODO: TestAndRemoveInTheNextDeployment { diff --git a/Views/Ext/TenantSignIn.cshtml b/Views/Ext/TenantSignIn.cshtml index 9dc80eef1..4b21aeca5 100644 --- a/Views/Ext/TenantSignIn.cshtml +++ b/Views/Ext/TenantSignIn.cshtml @@ -6,12 +6,12 @@ string sociallink = string.Empty; string signinLink = string.Empty; - if (Context.Items.ContainsKey("Domain") && Context.Items.ContainsKey("Scheme")) + if (Context.Items.ContainsKey(RoutingConstants.SCHEME) && Context.Items.ContainsKey(RoutingConstants.DOMAIN)) { - home = Context.Items["Scheme"].ToString() + Context.Items["Domain"]; - sociallink = Context.Items["Scheme"].ToString() + "ss." + Context.Items["Domain"]; - signinLink = Context.Items["Scheme"].ToString() + "myaccount." + Context.Items["Domain"]; + home = Context.Items[RoutingConstants.SCHEME].ToString() + Context.Items[RoutingConstants.DOMAIN]; + sociallink = Context.Items[RoutingConstants.SCHEME].ToString() + "ss." + Context.Items[RoutingConstants.DOMAIN]; + signinLink = Context.Items[RoutingConstants.SCHEME].ToString() + "myaccount." + Context.Items[RoutingConstants.DOMAIN]; } else //TODO: TestAndRemoveInTheNextDeployment diff --git a/Views/Ext/VerifyEmailSrtucture.cshtml b/Views/Ext/VerifyEmailSrtucture.cshtml index af04ac15b..099214b51 100644 --- a/Views/Ext/VerifyEmailSrtucture.cshtml +++ b/Views/Ext/VerifyEmailSrtucture.cshtml @@ -13,7 +13,6 @@ Dear {UserName},

        Welcome to EXPRESSbase! An Open-Source, Low-Code Rapid application development & delivery platform on the cloud for businesses & developers to build & run business apps 10 times faster.
        - We're excited to help you get started with your new EXPRESSbase account. Please go thru our Wiki for tutorials.
        If you wish to connect the database used by your existing applications, you could do it in very simple steps – and it is secure too!
        Just click the button below to verify your email address.
        diff --git a/Views/ImportExport/ShareToPublic.cshtml b/Views/ImportExport/ShareToPublic.cshtml index e2c21dede..1ce409cb6 100644 --- a/Views/ImportExport/ShareToPublic.cshtml +++ b/Views/ImportExport/ShareToPublic.cshtml @@ -371,6 +371,7 @@ else $("#price").removeAttr("disabled"); + @* var screenshot = new EbFileUpload({ Type: "image", Toggle: "#uploadscreenshot", @@ -395,6 +396,7 @@ $("input[name='images']").val(v); $(".screenshot-body").append(`
        `); } + *@ }); $('input[type=radio][name=price_option]').change(function () { if (this.value === '1') { diff --git a/Views/InternalException/Index.cshtml b/Views/InternalException/Index.cshtml new file mode 100644 index 000000000..24d87da23 --- /dev/null +++ b/Views/InternalException/Index.cshtml @@ -0,0 +1,364 @@ +@using ExpressBase.Common.Helpers +@using ExpressBase.Web.Controllers.ControllersV2 +@using Microsoft.Extensions.Configuration +@inject IConfiguration Configuration +@model InternalExceptionViewModel + +@{ + bool isDev = Model.IsDevelopment; + string ticketId = Model.TicketId; + SerializableExceptionDto exception = Model.Exception; + bool hasTicket = (exception != null); + string baseUrl = Configuration["AppSettings:Scheme"] + Configuration["AppSettings:BaseHost"]; +} + + + + + + Something went wrong | @ticketId + @await Html.PartialAsync("_EbCoreScripts") + + + + + +
        +
        + + +

        Something went wrong

        + + @if (hasTicket) + { +

        Ticket ID: @ticketId

        + } + + @if (!hasTicket) + { + if (isDev) + { +

        + No error details present. In Dev, ensure you redirected here using a valid ticket created within the TTL. +

        + +

        + We’re sorry, but something didn’t go as expected. Don’t worry, our team has been notified and is already looking into it. + Please try reloading the page or return to the homepage. +

        + } + else + { +

        + We’re sorry, but something didn’t go as expected. Don’t worry, our team has been notified and is already looking into it. + Please try reloading the page or return to the homepage. +

        + } + } + + @if (hasTicket && isDev) + { +
        + Details +
        + @if (!string.IsNullOrEmpty(exception?.GetType().FullName)) + { +
        Exception Type
        +
        @exception.GetType().FullName
        + } + + @if (!string.IsNullOrEmpty(exception?.Message)) + { +
        Message
        +
        @exception.Message
        + } + + @if (!string.IsNullOrEmpty(exception?.Source)) + { +
        Source
        +
        @exception.Source
        + } + + @if (!string.IsNullOrEmpty(exception?.TargetSite?.ToString())) + { +
        Target Site
        +
        @exception.TargetSite.ToString()
        + } + + @if (exception?.Data?.Count > 0) + { +
        Data
        +
        +
          + @foreach (var kvp in exception.Data) + { +
        • @kvp.Key: @kvp.Value
        • + } +
        +
        + } + + @if (!string.IsNullOrEmpty(exception?.StackTrace)) + { +
        Stack Trace
        +
        +
        +
        @exception.StackTrace
        +
        +
        + } + + @if (exception?.InnerException != null) + { +
        Inner Exception
        +
        +
        + @exception.InnerException.Message +
        +
        Type
        +
        @exception.InnerException.GetType().FullName
        + + @if (!string.IsNullOrEmpty(exception.InnerException.Source)) + { +
        Source
        +
        @exception.InnerException.Source
        + } + + @if (!string.IsNullOrEmpty(exception.InnerException.StackTrace)) + { +
        Stack Trace
        +
        +
        +
        @exception.InnerException.StackTrace
        +
        +
        + } + + @if (exception.InnerException.Data?.Count > 0) + { +
        Data
        +
        +
          + @foreach (var kvp in exception.InnerException.Data) + { +
        • @kvp.Key: @kvp.Value
        • + } +
        +
        + } +
        +
        +
        + } +
        +
        + + } + +
        + + @* *@ +
        +
        +
        + + + + diff --git a/Views/Security/MyProfile.cshtml b/Views/Security/MyProfile.cshtml index e3b15da1b..2fa9fed90 100644 --- a/Views/Security/MyProfile.cshtml +++ b/Views/Security/MyProfile.cshtml @@ -519,6 +519,7 @@ new myProfileJs(@UserData, '@Mode', @LocsData); + @* var d = new EbFileUpload({ Type:"image", Toggle: "#btnChngDp", @@ -540,6 +541,7 @@ d.windowClose = function () { EbMessage("show", { Message: "window closed",Background: "red" }); } + *@ }); diff --git a/Views/Shared/Components/ObjectDashboard/Default.cshtml b/Views/Shared/Components/ObjectDashboard/Default.cshtml index 34814c7b1..58b6f7172 100644 --- a/Views/Shared/Components/ObjectDashboard/Default.cshtml +++ b/Views/Shared/Components/ObjectDashboard/Default.cshtml @@ -114,11 +114,49 @@ } if (ViewBag.Refid.Length > 0 && (ViewBag.Refid as string).Split("-")[2] == "0") // if is webform { + //TODO: TestAndRemoveInTheNextDeployment + @* + *@ + + + + + @* + @if(ViewBag.PublicFormUrl != null) + { + + + + } + + *@ + + } + if(ViewBag.Refid != null && ViewBag.PublicFormUrl != null) + { + + + } else if(ViewBag.Refid != null) + { + + } else + { + + } + + } @@ -388,6 +426,9 @@
        + +@* +//TODO: TestAndRemoveInTheNextDeployment
        External URL
        @@ -396,6 +437,7 @@
        +*@ + + +
        diff --git a/Views/Shared/PageFooter.cshtml b/Views/Shared/PageFooter.cshtml index 54a5f4b26..1461902ff 100644 --- a/Views/Shared/PageFooter.cshtml +++ b/Views/Shared/PageFooter.cshtml @@ -31,7 +31,6 @@
      • Home
      • About us
      • Blog
      • -
      • Wiki
      • FAQ
      • Support
      • diff --git a/Views/Shared/_EbCoreScripts.cshtml b/Views/Shared/_EbCoreScripts.cshtml index 5983d38a1..95d7057f8 100644 --- a/Views/Shared/_EbCoreScripts.cshtml +++ b/Views/Shared/_EbCoreScripts.cshtml @@ -1,9 +1,14 @@ @using ExpressBase.Web.Helpers + + + + @@ -11,3 +16,4 @@ + diff --git a/Views/Tenant/SolutionManager.cshtml b/Views/Tenant/SolutionManager.cshtml index 5cc0f98d8..e45fe1825 100644 --- a/Views/Tenant/SolutionManager.cshtml +++ b/Views/Tenant/SolutionManager.cshtml @@ -21,10 +21,10 @@ string useraction = string.Empty; - if (Context.Items.ContainsKey("Scheme") && Context.Items.ContainsKey("DevConsoleHost") && Context.Items.ContainsKey("UserConsoleHost")) + if (Context.Items.ContainsKey(RoutingConstants.SCHEME) && Context.Items.ContainsKey(RoutingConstants.DEV_CONSOLE_HOST) && Context.Items.ContainsKey(RoutingConstants.USER_CONSOLE_HOST)) { - sso_dev = Context.Items["Scheme"].ToString() + Context.Items["DevConsoleHost"].ToString() + "/Ext/SwitchContext"; - sso_user = Context.Items["Scheme"].ToString() + Context.Items["UserConsoleHost"].ToString() + "/Ext/SwitchContext"; + sso_dev = Context.Items[RoutingConstants.SCHEME].ToString() + Context.Items[RoutingConstants.DEV_CONSOLE_HOST].ToString() + "/Ext/SwitchContext"; + sso_user = Context.Items[RoutingConstants.SCHEME].ToString() + Context.Items[RoutingConstants.USER_CONSOLE_HOST].ToString() + "/Ext/SwitchContext"; } else //TODO: TestAndRemoveInTheNextDeployment { diff --git a/wwwroot/js/Common/EbFrostGlassLoader.js b/wwwroot/js/Common/EbFrostGlassLoader.js new file mode 100644 index 000000000..5a932c036 --- /dev/null +++ b/wwwroot/js/Common/EbFrostGlassLoader.js @@ -0,0 +1,97 @@ +class EbFrostGlassLoader { + constructor({ + blur = 10, + brightness = 1.1, + saturate = 1.2, + background = 'rgba(255,255,255,0.2)', + border = '1px solid rgba(255,255,255,0.3)', + boxShadow = '0 4px 30px rgba(0, 0, 0, 0.1)', + borderRadius = '16px', + zIndex = 2147483647, + blockScroll = true, + showSpinner = true, + autoTimeout = 0 + } = {}) { + this.opts = { blur, brightness, saturate, background, border, boxShadow, borderRadius, zIndex, blockScroll, showSpinner, autoTimeout }; + this._overlayId = 'expressbase-blur-overlay'; + this._styleId = 'expressbase-blur-style'; + this._timer = null; + } + + attach() { + if (this.isActive()) return; + const ensure = () => { + this.#injectStyle(); + + const overlay = document.createElement('div'); + overlay.id = this._overlayId; + overlay.setAttribute('role', 'presentation'); + overlay.tabIndex = -1; + + Object.assign(overlay.style, { + position: 'fixed', + inset: '0', + zIndex: String(this.opts.zIndex), + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: this.opts.background, + backdropFilter: `blur(${this.opts.blur}px) brightness(${this.opts.brightness}) saturate(${this.opts.saturate})`, + WebkitBackdropFilter: `blur(${this.opts.blur}px) brightness(${this.opts.brightness}) saturate(${this.opts.saturate})`, + border: this.opts.border, + borderRadius: this.opts.borderRadius, + boxShadow: this.opts.boxShadow, + pointerEvents: 'auto', + animation: 'fadeInGlass 0.3s ease-out', + }); + + if (this.opts.showSpinner) { + const spin = document.createElement('div'); + spin.className = 'expressbase-blur-spinner'; + overlay.appendChild(spin); + } + + if (this.opts.blockScroll) document.documentElement.style.overflow = 'hidden'; + + document.body.appendChild(overlay); + + if (this.opts.autoTimeout > 0) + this._timer = setTimeout(() => this.detach(), this.opts.autoTimeout); + }; + if (!document.body) window.addEventListener('DOMContentLoaded', ensure, { once: true }); + else ensure(); + } + + detach() { + const overlay = document.getElementById(this._overlayId); + if (!overlay) return; + if (this._timer) clearTimeout(this._timer); + overlay.remove(); + document.documentElement.style.overflow = ''; + } + + isActive() { return !!document.getElementById(this._overlayId); } + + #injectStyle() { + if (document.getElementById(this._styleId)) return; + const style = document.createElement('style'); + style.id = this._styleId; + style.textContent = ` + #${this._overlayId} .expressbase-blur-spinner { + width: 40px; height: 40px; + border-radius: 50%; + border: 4px solid rgba(255,255,255,0.4); + border-top-color: rgba(255,255,255,0.8); + animation: spin 1s linear infinite; + } + @keyframes spin { + to { transform: rotate(360deg); } + } + @keyframes fadeInGlass { + from { opacity: 0; } + to { opacity: 1; } + } + `; + document.head.appendChild(style); + } +} \ No newline at end of file diff --git a/wwwroot/js/Common/EbFunnyGlassLoader.js b/wwwroot/js/Common/EbFunnyGlassLoader.js new file mode 100644 index 000000000..48fbf507f --- /dev/null +++ b/wwwroot/js/Common/EbFunnyGlassLoader.js @@ -0,0 +1,136 @@ +class EbFunnyGlassLoader { + constructor({ + zIndex = 2147483647, + blockScroll = true, + autoTimeout = 0 + } = {}) { + this.opts = { zIndex, blockScroll, autoTimeout }; + this._overlayId = 'eb-funky-frost-overlay'; + this._styleId = 'eb-funky-frost-style'; + this._timer = null; + this._beat = null; + } + + attach() { + if (this.isActive()) return; + const ensure = () => { + this.#injectStyle(); + + const overlay = document.createElement('div'); + overlay.id = this._overlayId; + + Object.assign(overlay.style, { + position: 'fixed', + inset: '0', + zIndex: this.opts.zIndex, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + backdropFilter: 'blur(20px) brightness(1.2)', + WebkitBackdropFilter: 'blur(20px) brightness(1.2)', + animation: 'funky-bg 6s linear infinite', + overflow: 'hidden' + }); + + const dj = document.createElement('div'); + dj.className = 'dj'; + dj.textContent = this.#randomEmoji(); + + const msg = document.createElement('div'); + msg.className = 'funky-text'; + msg.textContent = this.#randomMessage(); + + overlay.appendChild(dj); + overlay.appendChild(msg); + document.body.appendChild(overlay); + + if (this.opts.blockScroll) document.documentElement.style.overflow = 'hidden'; + this.#startFunk(dj, msg); + + if (this.opts.autoTimeout > 0) + this._timer = setTimeout(() => this.detach(), this.opts.autoTimeout); + }; + + if (!document.body) window.addEventListener('DOMContentLoaded', ensure, { once: true }); + else ensure(); + } + + detach() { + if (this._timer) clearTimeout(this._timer); + if (this._beat) clearInterval(this._beat); + const overlay = document.getElementById(this._overlayId); + if (overlay) overlay.remove(); + document.documentElement.style.overflow = ''; + } + + isActive() { + return !!document.getElementById(this._overlayId); + } + + #startFunk(dj, msg) { + let step = 0; + + const emojis = ['🔧', '⏰', '⏳']; + + const messages = [ + 'കിട്ടും... കിട്ടും... കുറച്ച് കഴിഞ്ഞിട്ട് കിട്ടും', + 'ഇപ്പോ ശരിയാക്കിത്തരാം' + ]; + + + this._beat = setInterval(() => { + dj.textContent = emojis[step % emojis.length]; + msg.textContent = messages[Math.floor(Math.random() * messages.length)]; + step++; + }, 1500); + } + + #randomEmoji() { + const arr = ['🔧', '⏰', '⏳']; + return arr[Math.floor(Math.random() * arr.length)]; + } + + #randomMessage() { + const arr = [ + 'കിട്ടും... കിട്ടും... കുറച്ച് കഴിഞ്ഞിട്ട് കിട്ടും', + 'ഇപ്പോ ശരിയാക്കിത്തരാം' + ]; + return arr[Math.floor(Math.random() * arr.length)]; + } + + #injectStyle() { + if (document.getElementById(this._styleId)) return; + const style = document.createElement('style'); + style.id = this._styleId; + style.textContent = ` + @keyframes funky-bg { + 0% { background: linear-gradient(135deg, #ff00ff, #00ffff); } + 25% { background: linear-gradient(135deg, #00ffff, #ff8800); } + 50% { background: linear-gradient(135deg, #ff8800, #00ff66); } + 75% { background: linear-gradient(135deg, #00ff66, #ff00ff); } + 100% { background: linear-gradient(135deg, #ff00ff, #00ffff); } + } + @keyframes bop { + 0%,100% { transform: scale(1) rotate(0deg); } + 50% { transform: scale(1.3) rotate(10deg); } + } + @keyframes glow { + 0%,100% { text-shadow: 0 0 8px #fff, 0 0 12px #ff00ff; } + 50% { text-shadow: 0 0 18px #0ff, 0 0 28px #ff0080; } + } + #${this._overlayId} .dj { + font-size: 72px; + animation: bop 0.8s ease-in-out infinite; + } + #${this._overlayId} .funky-text { + margin-top: 20px; + font-family: 'Comic Sans MS', 'Comic Neue', cursive; + font-size: 22px; + color: white; + text-align: center; + animation: glow 1.4s ease-in-out infinite; + } + `; + document.head.appendChild(style); + } +} \ No newline at end of file diff --git a/wwwroot/js/Common/EbMessages.js b/wwwroot/js/Common/EbMessages.js new file mode 100644 index 000000000..f5d22b207 --- /dev/null +++ b/wwwroot/js/Common/EbMessages.js @@ -0,0 +1,12 @@ +class EbMessages { + static data = { + somethingWentWrongJSRefresh: "Something went wrong, kindly do a hard refresh (Ctrl + Shift + R)", + networkError: "Network error. Please check your connection.", + unauthorized: "You are not authorized to perform this action.", + }; + + static get(key) { + return this.data[key] || "Unknown message key."; + } +} + diff --git a/wwwroot/js/Common/Helpers/EbApiClientHelper.js b/wwwroot/js/Common/Helpers/EbApiClientHelper.js index 6b05b2f5d..28c4b5565 100644 --- a/wwwroot/js/Common/Helpers/EbApiClientHelper.js +++ b/wwwroot/js/Common/Helpers/EbApiClientHelper.js @@ -1,42 +1,61 @@ class EbApiClientHelper { - constructor(baseUrl = '') { + constructor(baseUrl = '', defaultTimeout = 10000) { this.baseUrl = baseUrl; + this.defaultTimeout = defaultTimeout; } async request(endpoint, options = {}) { + const controller = new AbortController(); + const timeout = options.timeout ?? this.defaultTimeout; + const signal = controller.signal; + // Construct final URL with query params let url = this.baseUrl + endpoint; if (options.query) { const qs = new URLSearchParams(options.query).toString(); url += (url.includes('?') ? '&' : '?') + qs; } + // Prepare headers const headers = { 'Content-Type': 'application/json', ...(options.headers || {}) }; - const resp = await fetch(url, { - method: options.method || 'POST', - headers, - body: options.body ? JSON.stringify(options.body) : undefined, - credentials: options.credentials || 'same-origin' - }); - - if (!resp.ok) { - let errText = `${resp.status} ${resp.statusText}`; - try { - const errJson = await resp.json(); - if (errJson.message) errText = errJson.message; - } catch (_) {} - throw new Error(errText); - } + // Setup timeout + const timeoutId = setTimeout(() => controller.abort(), timeout); + + try { + const resp = await fetch(url, { + method: options.method || 'POST', + headers, + body: options.body ? JSON.stringify(options.body) : undefined, + credentials: options.credentials || 'same-origin', + signal + }); + + clearTimeout(timeoutId); + + if (!resp.ok) { + let errText = `${resp.status} ${resp.statusText}`; + try { + const errJson = await resp.json(); + if (errJson.message) errText = errJson.message; + } catch (_) {} + throw new Error(errText); + } + + const contentType = resp.headers.get('content-type') || ''; + return contentType.includes('application/json') + ? await resp.json() + : await resp.text(); - const contentType = resp.headers.get('content-type') || ''; - if (contentType.includes('application/json')) { - return await resp.json(); - } else { - return await resp.text(); + } catch (err) { + clearTimeout(timeoutId); + if (err.name === 'AbortError') { + throw new Error(`Request timed out after ${timeout} ms`); + } + throw err; } } } diff --git a/wwwroot/js/EbDashBoards/AppDashBoard.js b/wwwroot/js/EbDashBoards/AppDashBoard.js index aa1735257..dcc2547a7 100644 --- a/wwwroot/js/EbDashBoards/AppDashBoard.js +++ b/wwwroot/js/EbDashBoards/AppDashBoard.js @@ -496,6 +496,7 @@ }; this.DpImageUpload = function () { + /* var dpImg = new EbFileUpload({ Type: "image", Toggle: "#dpBrowse", @@ -519,10 +520,14 @@ } }; + + */ }; this.BgImageUpload = function () { + /* + var bgimg = new EbFileUpload({ Type: "image", Toggle: "#bgimg_btn", @@ -554,6 +559,8 @@ //img.src = URL.createObjectURL(this.files[i]); //img.height = 60; }; + + */ }; $("input[name='bgradio']").click(function () { diff --git a/wwwroot/js/Eb_ObjectCommon.js b/wwwroot/js/Eb_ObjectCommon.js index 6c9683c2a..55f9838dd 100644 --- a/wwwroot/js/Eb_ObjectCommon.js +++ b/wwwroot/js/Eb_ObjectCommon.js @@ -36,9 +36,9 @@ $('#singlesave').off('click').on('click', this.SingleSave.bind(this)); $('#offline').off('click').on('click', this.MakeOffline.bind(this)); $('#live').off('click').on('click', this.MakeLive.bind(this)); - $('#make_public').off('click').on('click', this.MakePublic.bind(this)); - $('#make_private').off('click').on('click', this.MakePrivate.bind(this)); - $('#copy_url').off('click').on('click', this.OpenUrlContainer.bind(this)); + //$('#make_public').off('click').on('click', this.MakePublic.bind(this)); + //$('#make_private').off('click').on('click', this.MakePrivate.bind(this)); + //$('#copy_url').off('click').on('click', this.OpenUrlContainer.bind(this)); $('#clone').off('click').on('click', this.Clone.bind(this)); if (this.Current_obj !== null) @@ -769,7 +769,8 @@ }.bind(this)); }; - this.MakePublic = function () { + //TODO: TestAndRemoveInTheNextDeployment + /*this.MakePublic = function () { $("#eb_common_loader").EbLoader("show"); $.post("../Eb_Object/ChangeAccess", { @@ -789,9 +790,10 @@ } $("#eb_common_loader").EbLoader("hide"); }.bind(this)); - }; + };*/ - this.MakePrivate = function () { + //TODO: TestAndRemoveInTheNextDeployment + /*this.MakePrivate = function () { $("#eb_common_loader").EbLoader("show"); $.post("../Eb_Object/ChangeAccess", { @@ -811,11 +813,12 @@ } $("#eb_common_loader").EbLoader("hide"); }.bind(this)); - }; + };*/ - this.OpenUrlContainer = function () { + //TODO: TestAndRemoveInTheNextDeployment + /*this.OpenUrlContainer = function () { $('#url-container').show(); - }; + };*/ this.Clone = function () { EbDialog("show", diff --git a/wwwroot/js/FormBuilder/EbPublicFormPropertyControl.js b/wwwroot/js/FormBuilder/EbPublicFormPropertyControl.js new file mode 100644 index 000000000..98efeb78d --- /dev/null +++ b/wwwroot/js/FormBuilder/EbPublicFormPropertyControl.js @@ -0,0 +1,178 @@ +class EbPublicFormPropertyControl { + + static checkbox = null; + static container = null; + static btn = null; + static modal = null; + static publicFormUrl = null; + static refId = null; + static _boundToggle = null; + + static handleFromSave() { + + } + + + static handlePGControlStateChange(checkboxEl = null) { + try { + this.checkbox = checkboxEl; + + if (!this.checkbox) throw new Error("Checkbox element not found"); + + this.container = document.querySelector('#publicFormActions'); + + if (!this.container) throw new Error("#publicFormActions not found"); + + this.initDataSetFromContainer(); + + if (this.checkbox.checked) { + return this.handleCheck(); + } else { + return this.handleUncheck(); + } + } catch (error) { + EbDebugHelper?.error?.("Unable to init EbPublicFormPropertyControl (static)", error); + } + } + + static initDataSetFromContainer() { + const {refid, publicformurl} = this.container.dataset ?? {}; + + this.refId = null; + this.publicFormUrl = null; + + if (refid) { + this.refId = refid; + } + + if (publicformurl) { + this.publicFormUrl = publicformurl; + } + } + + + static generateCopyUrlButton(forceRegenerate = false) { + + if (!this.container || forceRegenerate === true) { + + this.container = document.querySelector('#publicFormActions'); + + if (!this.container) { + EbDebugHelper.error("#publicFormActions not found while generating button"); + return; + } + + this.container.replaceChildren(); + this.btn = null; + this.initDataSetFromContainer(); + } + + this.modal ??= new EbShareModal({title: "Public Form Link"}); + + this.btn = document.getElementById('copy_url') || document.createElement('button'); + this.btn.className = 'btn'; + this.btn.id = 'copy_url'; + this.btn.title = 'Copy public form Link'; + this.btn.style.display = 'none'; + + + if (!this.btn.querySelector('i')) { + const icon = document.createElement('i'); + icon.className = 'fa fa-clipboard'; + icon.setAttribute('aria-hidden', 'true'); + this.btn.appendChild(icon); + } + + if (this.publicFormUrl) { + this.btn.onclick = () => this.modal.open(this.publicFormUrl); + this.btn.style.display = 'inline-block'; + this.btn.removeAttribute("aria-disabled"); + } else { + this.btn.style.display = "none"; + this.btn.onclick = null; + this.btn.setAttribute("aria-disabled", "true"); + } + + + if (!this.btn.parentElement || forceRegenerate === true) { + this.container.appendChild(this.btn); + } + } + + + static async handleCheck() { + window.jQuery ? $("#eb_common_loader").EbLoader?.("show") : undefined; + + try { + if (!this.refId) { + EbToast?.info?.("Save the form to generate a public form link"); + return; + } + + if (!this.publicFormUrl) { + + const response = await new EbApiClientHelper().request( + '/internal/api/v2/BuilderApi/GetPublicFormUrl', + { + method: 'GET', + query: {RefId: this.refId}, + credentials: 'include' + } + ); + + + if (!response?.publicFormUrl) throw new Error("Unable to fetch the public form from XHR"); + this.publicFormUrl = response.publicFormUrl; + } + + this.generateCopyUrlButton(); + + EbToast.info("Public form link generated successfully. Save this form to make it public.") + + } catch (err) { + EbDebugHelper?.error?.("An exception occurred while changing the form state", err); + EbToast?.error?.("Unable to change the state of the form"); + if (this.btn) { + this.btn.style.display = "none"; + this.btn.onclick = null; + this.btn.setAttribute("aria-disabled", "true"); + } + } finally { + window.jQuery ? $("#eb_common_loader").EbLoader?.("hide") : undefined; + } + } + + + static handleUncheck() { + window.jQuery ? $("#eb_common_loader").EbLoader?.("show") : undefined; + try { + if (!this.refId) { + EbToast?.info?.("Save the form to ensure the state change"); + return; + } + + this.publicFormUrl = null; + + this.generateCopyUrlButton(); + EbToast.info("Save this form to make it private.") + } catch (err) { + EbToast?.error?.("Unable to change the state of the form"); + } finally { + window.jQuery ? $("#eb_common_loader").EbLoader?.("hide") : undefined; + } + } + + + static retarget(checkboxEl = null, containerEl = null) { + if (checkboxEl && this.checkbox !== checkboxEl) { + if (this._boundToggle && this.checkbox) { + this.checkbox.removeEventListener('change', this._boundToggle); + } + this.checkbox = checkboxEl; + this._attachChangeHandler(); + } + if (containerEl && this.container !== containerEl) { + this.container = containerEl; + } + } +} diff --git a/wwwroot/js/FormBuilder/Eb_PropertyGrid.js b/wwwroot/js/FormBuilder/Eb_PropertyGrid.js index 38c8567b4..f4a588416 100644 --- a/wwwroot/js/FormBuilder/Eb_PropertyGrid.js +++ b/wwwroot/js/FormBuilder/Eb_PropertyGrid.js @@ -237,7 +237,7 @@ SolutionId: this.Cid, Container: "mb_" + this.wraperId, Multiple: false, - ServerEventUrl: ebcontext.env === "Production" ? 'https://se.expressbase.com' : 'https://se.eb-test.xyz', + ServerEventUrl: EbUrlHelper.getEbServerEventUrl(), EnableTag: false, EnableCrop: false, DisableUpload: false @@ -600,77 +600,98 @@ //fires when a property value changes through PG this.OnInputchangedFn = function (e) { ////////// need optimization - let oldVal = ""; - let subTypeOf = null; - if (e) { - var $e = $(e.target); - this.CurProp = $e.closest("tr").attr("name").slice(0, -2); - subTypeOf = $e.closest("tr").attr("subtype-of"); - } try { - oldVal = this.PropsObj.__oldValues[this.CurProp]; - } - catch (e) { - alert(e); - console.log(e); - } - this.getvaluesFromPG(); - let newVal = this.PropsObj[this.CurProp]; - if (newVal === oldVal) - return; - let objCopy = ($.extend({}, this.PropsObj)); - delete objCopy.__oldValues; - this.PropsObj.__oldValues = objCopy; - //let res = this.getvaluesFromPG(); - //$('#txtValues').val(JSON.stringify(res) + '\n\n'); - this.CurMeta = getObjByval(this.Metas, "name", this.CurProp); - this.check4ReservedVals(); + if (e?.currentTarget?.id === 'pgWraperIsPublicForm') { - if (subTypeOf) { - this.CurMeta = getObjByval(this.Metas, "name", subTypeOf); - } - if (this.CurProp === "Name" || this.CurProp === "name") { - this.updateDD(this.PropsObj); - let $colTile = ""; - if (this.ParentPG && this.ParentPG.isModalOpen) - $colTile = $(`#${e.target.defaultValue}.colTile`); - if ($colTile.length) - $colTile.attr("id", this.PropsObj[this.CurProp]).find("span").text(this.PropsObj[this.CurProp]); - } - if (this.CurMeta && typeof EbOnChangeUIfns !== "undefined" && this.CurMeta.UIChangefn) { - this.execUiChangeFn(this.CurMeta.UIChangefn, this.PropsObj); - } - if (this.CurProp === 'DataSourceId' && this.PropsObj.ObjType !== "DataGrid") { - this.PGHelper.dataSourceInit(); - } - if (this.CurProp === 'Url' && this.PropsObj.ObjType !== "DataGrid") { - if (!EbIsValidURL(this.PropsObj.Url.trim())) { - this.EbAlert.alert({ - id: this.CurProp + "EbIsValidURL", - head: "Invalid URL string.", - body: " The value entered '" + this.PropsObj.Url + "' is an invalid URL.", - type: "warning", - delay: 3000 - }); - if (e) - $e.select(); + try { + + EbPublicFormPropertyControl.handlePGControlStateChange(e.currentTarget); + + } catch (error) { + EbDebugHelper.error("unable to change the status of the form", error); + EbToast.warn(EbMessages.get('somethingWentWrongJSRefresh')); + } + } + + let oldVal = ""; + let subTypeOf = null; + if (e) { + var $e = $(e.target); + this.CurProp = $e.closest("tr").attr("name").slice(0, -2); + subTypeOf = $e.closest("tr").attr("subtype-of"); + } + + try { + oldVal = this.PropsObj.__oldValues[this.CurProp]; + } + catch (e) { + EbDebugHelper.error("an exception occurred", error); + EbToast.error("An exception occurred"); + } + this.getvaluesFromPG(); + let newVal = this.PropsObj[this.CurProp]; + if (newVal === oldVal) return; + + let objCopy = ($.extend({}, this.PropsObj)); + delete objCopy.__oldValues; + this.PropsObj.__oldValues = objCopy; + //let res = this.getvaluesFromPG(); + //$('#txtValues').val(JSON.stringify(res) + '\n\n'); + + this.CurMeta = getObjByval(this.Metas, "name", this.CurProp); + this.check4ReservedVals(); + + if (subTypeOf) { + this.CurMeta = getObjByval(this.Metas, "name", subTypeOf); } - if (this.PropsObj.IsDataFromApi) { - let opt = { - url: "../DS/GetColumnsFromApi", - apiUrl: this.PropsObj.Url, - headers: this.PropsObj.Headers.$values, - parameters: this.PropsObj.DataApiParams.$values, - method: this.PropsObj.Method + if (this.CurProp === "Name" || this.CurProp === "name") { + this.updateDD(this.PropsObj); + let $colTile = ""; + if (this.ParentPG && this.ParentPG.isModalOpen) + $colTile = $(`#${e.target.defaultValue}.colTile`); + if ($colTile.length) + $colTile.attr("id", this.PropsObj[this.CurProp]).find("span").text(this.PropsObj[this.CurProp]); + } + if (this.CurMeta && typeof EbOnChangeUIfns !== "undefined" && this.CurMeta.UIChangefn) { + this.execUiChangeFn(this.CurMeta.UIChangefn, this.PropsObj); + } + if (this.CurProp === 'DataSourceId' && this.PropsObj.ObjType !== "DataGrid") { + this.PGHelper.dataSourceInit(); + } + if (this.CurProp === 'Url' && this.PropsObj.ObjType !== "DataGrid") { + if (!EbIsValidURL(this.PropsObj.Url.trim())) { + this.EbAlert.alert({ + id: this.CurProp + "EbIsValidURL", + head: "Invalid URL string.", + body: " The value entered '" + this.PropsObj.Url + "' is an invalid URL.", + type: "warning", + delay: 3000 + }); + if (e) + $e.select(); + return; + } + if (this.PropsObj.IsDataFromApi) { + let opt = { + url: "../DS/GetColumnsFromApi", + apiUrl: this.PropsObj.Url, + headers: this.PropsObj.Headers.$values, + parameters: this.PropsObj.DataApiParams.$values, + method: this.PropsObj.Method + } + this.PGHelper.UrlInit(opt); } - this.PGHelper.UrlInit(opt); } + this.PropertyChanged(this.PropsObj, this.CurProp, newVal, oldVal); + + } catch (error) { + EbDebugHelper.error("an exception occurred", error); + EbToast.warn(EbMessages.get('somethingWentWrongJSRefresh')); } - this.PropertyChanged(this.PropsObj, this.CurProp, newVal, oldVal); }; this.execUiChangeFn = function (UIChangefn, PropsObj) { diff --git a/wwwroot/js/FormBuilder/FormBuilder.js b/wwwroot/js/FormBuilder/FormBuilder.js index 78adfa632..66a662491 100644 --- a/wwwroot/js/FormBuilder/FormBuilder.js +++ b/wwwroot/js/FormBuilder/FormBuilder.js @@ -78,6 +78,14 @@ this.GenerateButtons = function () { if (options.builderType === 'WebForm' && options.objInEditMode !== null) { + + try{ + EbPublicFormPropertyControl.generateCopyUrlButton(true); + }catch (error) { + EbToast.warn(EbMessages.get('somethingWentWrongJSRefresh')); + EbDebugHelper.error("unable to attach the copy public form url button", error); + } + $("#obj_icons").empty().append(` @@ -790,7 +798,7 @@ let ctrlObj = new this.EbObjects["Eb" + type](ebsid); ctrlObj.DataObjCtrlName = CntrlName; ctrlObj.DataObjColName = ColumnlName; - ctrlObj.Label = ColumnlName; + ctrlObj.Label = ColumnlName let $ctrl = ctrlObj.$Control; if (type === "UserControl") {///user control refid set on ctrlobj diff --git a/wwwroot/js/FormBuilder/InitFormControls.js b/wwwroot/js/FormBuilder/InitFormControls.js index 70c3fb15a..0172933ae 100644 --- a/wwwroot/js/FormBuilder/InitFormControls.js +++ b/wwwroot/js/FormBuilder/InitFormControls.js @@ -90,7 +90,7 @@ SolutionId: this.Cid, Container: ctrl.EbSid, Multiple: ctrl.IsMultipleUpload, - ServerEventUrl: this.Env === "Production" ? 'https://se.expressbase.com' : 'https://se.eb-test.xyz', + ServerEventUrl: EbUrlHelper.getEbServerEventUrl(), EnableTag: ctrl.EnableTag, EnableCrop: ctrl.EnableCrop, MaxSize: ctrl.MaxFileSize, diff --git a/wwwroot/js/location-config.js b/wwwroot/js/location-config.js index bfb631b6d..48c9d5f27 100644 --- a/wwwroot/js/location-config.js +++ b/wwwroot/js/location-config.js @@ -112,6 +112,7 @@ this.imageUploader = function (container, toggle, prev, extra, viwportresize) { let resize = viwportresize ? true : false; + /* this.Cropies[extra.Name] = new EbFileUpload({ Type: "image", Toggle: toggle, @@ -127,6 +128,7 @@ Context: "location",//if single and crop ResizeViewPort: false //if single and crop }); + */ this.Cropies[extra.Name].uploadSuccess = function (fileid) { $("#loc_logoId").val(""); From 37c229e8d147bb7960c8759c063ac2b00fa624d4 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 20 Oct 2025 20:28:13 +0530 Subject: [PATCH 55/58] removed the comments in EbFileUpload() from various files --- Views/CustomPage/LeadManagement.cshtml | 4 ++-- Views/Docs/ImageUpHome.cshtml | 4 +--- Views/ImportExport/ShareToPublic.cshtml | 3 +-- Views/Security/MyProfile.cshtml | 2 -- wwwroot/js/EbDashBoards/AppDashBoard.js | 6 ------ wwwroot/js/location-config.js | 3 +-- 6 files changed, 5 insertions(+), 17 deletions(-) diff --git a/Views/CustomPage/LeadManagement.cshtml b/Views/CustomPage/LeadManagement.cshtml index 1281a2a18..afc1dce05 100644 --- a/Views/CustomPage/LeadManagement.cshtml +++ b/Views/CustomPage/LeadManagement.cshtml @@ -1368,7 +1368,7 @@ //imgup2.contextM_REcallback = fupTriggerRecentCallBack.bind('', 'prpImg', imgup2); - @*var imgup = new EbFileUpload({ + var imgup = new EbFileUpload({ Type: "image", PreviewWraper: "#divAllImg1", Categories: ["Blood Tests", "Forms and Reports", "Pre consultation", "Consultation", "Hairline", "Post procedure", "Clot removal", "M1", "M2", "M3", "M4", "M5", "M6", "M7", "M8", "M9", "M10", "PRP1", "PRP2", "PRP3", "PRP4", "PRP5", "PRP6", "PRP7", "PRP8", "PRP9", "PRP10"], @@ -1450,6 +1450,6 @@ } }); } - }*@ + } diff --git a/Views/Docs/ImageUpHome.cshtml b/Views/Docs/ImageUpHome.cshtml index c43f6f3f8..fa2c7db22 100644 --- a/Views/Docs/ImageUpHome.cshtml +++ b/Views/Docs/ImageUpHome.cshtml @@ -143,7 +143,6 @@ var im = new ImageUploader_Doc({Tenantid:'@ViewBag.cid'}); *@ -@* -*@ \ No newline at end of file + \ No newline at end of file diff --git a/Views/ImportExport/ShareToPublic.cshtml b/Views/ImportExport/ShareToPublic.cshtml index 1ce409cb6..a6def6712 100644 --- a/Views/ImportExport/ShareToPublic.cshtml +++ b/Views/ImportExport/ShareToPublic.cshtml @@ -371,7 +371,6 @@ else $("#price").removeAttr("disabled"); - @* var screenshot = new EbFileUpload({ Type: "image", Toggle: "#uploadscreenshot", @@ -396,7 +395,7 @@ $("input[name='images']").val(v); $(".screenshot-body").append(`
        `); } - *@ + }); $('input[type=radio][name=price_option]').change(function () { if (this.value === '1') { diff --git a/Views/Security/MyProfile.cshtml b/Views/Security/MyProfile.cshtml index 2fa9fed90..e3b15da1b 100644 --- a/Views/Security/MyProfile.cshtml +++ b/Views/Security/MyProfile.cshtml @@ -519,7 +519,6 @@ new myProfileJs(@UserData, '@Mode', @LocsData); - @* var d = new EbFileUpload({ Type:"image", Toggle: "#btnChngDp", @@ -541,7 +540,6 @@ d.windowClose = function () { EbMessage("show", { Message: "window closed",Background: "red" }); } - *@ }); diff --git a/wwwroot/js/EbDashBoards/AppDashBoard.js b/wwwroot/js/EbDashBoards/AppDashBoard.js index dcc2547a7..7d5b53ff5 100644 --- a/wwwroot/js/EbDashBoards/AppDashBoard.js +++ b/wwwroot/js/EbDashBoards/AppDashBoard.js @@ -496,7 +496,6 @@ }; this.DpImageUpload = function () { - /* var dpImg = new EbFileUpload({ Type: "image", Toggle: "#dpBrowse", @@ -521,13 +520,10 @@ }; - */ }; this.BgImageUpload = function () { - /* - var bgimg = new EbFileUpload({ Type: "image", Toggle: "#bgimg_btn", @@ -559,8 +555,6 @@ //img.src = URL.createObjectURL(this.files[i]); //img.height = 60; }; - - */ }; $("input[name='bgradio']").click(function () { diff --git a/wwwroot/js/location-config.js b/wwwroot/js/location-config.js index 48c9d5f27..a8c642eba 100644 --- a/wwwroot/js/location-config.js +++ b/wwwroot/js/location-config.js @@ -112,7 +112,7 @@ this.imageUploader = function (container, toggle, prev, extra, viwportresize) { let resize = viwportresize ? true : false; - /* + this.Cropies[extra.Name] = new EbFileUpload({ Type: "image", Toggle: toggle, @@ -128,7 +128,6 @@ Context: "location",//if single and crop ResizeViewPort: false //if single and crop }); - */ this.Cropies[extra.Name].uploadSuccess = function (fileid) { $("#loc_logoId").val(""); From e4f73a49054bd328e6c195faace7ed5858d234f1 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 20 Oct 2025 20:28:36 +0530 Subject: [PATCH 56/58] commented the call for EbServerEvents from EbFileUpload --- wwwroot/js/EbControls/EbFileUpload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wwwroot/js/EbControls/EbFileUpload.js b/wwwroot/js/EbControls/EbFileUpload.js index 3b99ac76c..3045a6f9e 100644 --- a/wwwroot/js/EbControls/EbFileUpload.js +++ b/wwwroot/js/EbControls/EbFileUpload.js @@ -764,7 +764,7 @@ class EbFileUpload extends EbFupStaticData { }; startSE() { - this.ss = new EbServerEvents({ ServerEventUrl: this.Options.ServerEventUrl, Channels: ["file-upload"] }); + //this.ss = new EbServerEvents({ ServerEventUrl: this.Options.ServerEventUrl, Channels: ["file-upload"] }); this.ss.onUploadSuccess = function (ImageRefid) { }.bind(this); From ffd3f3ee087e83305536e1374edaa0ad7f991632 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 20 Oct 2025 20:32:46 +0530 Subject: [PATCH 57/58] removed the calling of SE from Image upload service --- wwwroot/js/EbControls/EbFileUpload.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wwwroot/js/EbControls/EbFileUpload.js b/wwwroot/js/EbControls/EbFileUpload.js index 3045a6f9e..b507ef50a 100644 --- a/wwwroot/js/EbControls/EbFileUpload.js +++ b/wwwroot/js/EbControls/EbFileUpload.js @@ -764,10 +764,13 @@ class EbFileUpload extends EbFupStaticData { }; startSE() { - //this.ss = new EbServerEvents({ ServerEventUrl: this.Options.ServerEventUrl, Channels: ["file-upload"] }); + EbDebugHelper.warn("EbServerEvents is disabled"); + EbDebugHelper.trace("EbServerEvents is disabled"); + return; + /*this.ss = new EbServerEvents({ ServerEventUrl: this.Options.ServerEventUrl, Channels: ["file-upload"] }); this.ss.onUploadSuccess = function (ImageRefid) { - }.bind(this); + }.bind(this);*/ } b64toBlob(b64Data, contentType, sliceSize) { From 9d9f935596aa1313ac02ce702c1b8d93737311c0 Mon Sep 17 00:00:00 2001 From: Jithin P V Date: Mon, 20 Oct 2025 20:35:13 +0530 Subject: [PATCH 58/58] re initialised EbObjectWrapper as null --- Controllers/Eb_ObjectController.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Controllers/Eb_ObjectController.cs b/Controllers/Eb_ObjectController.cs index 74bd9f7bd..9d1311817 100644 --- a/Controllers/Eb_ObjectController.cs +++ b/Controllers/Eb_ObjectController.cs @@ -37,7 +37,8 @@ public Eb_ObjectController(IServiceClient sclient, IRedisClient redis) : base(sc [HttpPost] public IActionResult Index(string objid, int objtype, bool buildermode = true) { - EbObjectWrapper element = new EbObjectWrapper(); + EbObjectWrapper element = null; + if (ViewBag.wc == "dc") { ViewBag.al_arz_map_key = Environment.GetEnvironmentVariable(EnvironmentConstants.AL_GOOGLE_MAP_KEY); @@ -55,8 +56,11 @@ public IActionResult Index(string objid, int objtype, bool buildermode = true) if (objid != "null") { ViewBag.Obj_id = objid; + EbObjectExploreObjectResponse resultlist = ServiceClient.Get(new EbObjectExploreObjectRequest { Id = Convert.ToInt32(objid) }); - element = resultlist.Data; + + element = resultlist.Data; + if (element != null) { ViewBag.IsNew = "false";