Base solution for your next web application

Activities of "SASIMEXICO"

Hi ZERO,

I'm trying to add a openweathermap API call into my project, then always return CORS error.

Service Proxy

export class WeatherServiceProxy { private httpClient: HttpClient;

constructor(@Inject(HttpClient) httpClient: HttpClient) {
    this.httpClient = httpClient;
}

getCurrentWeather(lat: string, lon: string, apiKey) {
    let url = 'https://api.openweathermap.org/data/2.5/weather?lat=' + lat + '&lon=' + lon + '&units=metric&APPID=' + apiKey;
    return this.httpClient.get(url);
}

}

Component Call

    this.weatherService.getCurrentWeather('41.69059766384649', '2.4914624650715758', this.openWeatherMapAPIKey)
        .subscribe(res => {
            console.log('getCurrentWeather', res);
            this.currentWeather = res;
        }, err => {
        }, () => {
            console.log('error');
        })

The call always crash for CORS

Access to XMLHttpRequest at 'https://api.openweathermap.org/data/2.5/weather?lat=41.69059766384649&lon=2.4914624650715758&units=metric&APPID=66c99a512af822a19700e0fb026aad4b' from origin 'https://gensam.dev.sasi.com.es' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

GET https://api.openweathermap.org/data/2.5/weather?lat=41.69059766384649&lon=2.4914624650715758&units=metric&APPID=66c99a512af822a19700e0fb026aad4b net::ERR_FAILED

I tried same ServiceProxy and same component into other project .NET6 + Angular NOT ZERO, then the call to openweathermap API runs perfect, already in localhost. Maybe the ZERO solution need to implement something to resolve this CORS issue? Any additional config?

In the same way, I can't use power-bi angular module for the same reason... always CORS error/issue.

Need help and solution for this issue. Thanks!

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version? 7.1.0
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .net 6

If issue related with ABP Framework

  • What is ABP Framework version? .net 6

If issue is about UI

  • Which theme are you using? default
  • What are the theme settings? default

other

DB : PostgreSQL

Npgsql version: 6.0.3

The project is starting. Only the changes to use PostgreSQL have been applied.

Exception message and stack trace:

Microsoft.EntityFrameworkCore.DbUpdateException HResult=0x80131500 Mensaje = An error occurred while saving the entity changes. See the inner exception for details. Origen = Microsoft.EntityFrameworkCore.Relational Seguimiento de la pila: en Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) en Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable1 commandBatches, IRelationalConnection connection) en Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList1 entries) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList1 entriesToSave) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(StateManager stateManager, Boolean acceptAllChangesOnSuccess) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.<>c.<SaveChanges>b__104_0(DbContext _, ValueTuple2 t) en Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess) en Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess) en Microsoft.EntityFrameworkCore.DbContext.SaveChanges() en Abp.EntityFrameworkCore.AbpDbContext.SaveChanges() en Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext3.SaveChanges() en SenerDemo.Migrations.Seed.Host.DefaultEditionCreator.CreateEditions() en C:\Toni\GitLab\sener\src\SenerDemo.EntityFrameworkCore\Migrations\Seed\Host\DefaultEditionCreator.cs: línea 31 en SenerDemo.Migrations.Seed.Host.DefaultEditionCreator.Create() en C:\Toni\GitLab\sener\src\SenerDemo.EntityFrameworkCore\Migrations\Seed\Host\DefaultEditionCreator.cs: línea 21 en SenerDemo.Migrations.Seed.Host.InitialHostDbBuilder.Create() en C:\Toni\GitLab\sener\src\SenerDemo.EntityFrameworkCore\Migrations\Seed\Host\InitialHostDbBuilder.cs: línea 16 en SenerDemo.Migrations.Seed.SeedHelper.SeedHostDb(SenerDemoDbContext context) en C:\Toni\GitLab\sener\src\SenerDemo.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs: línea 26 en SenerDemo.Migrations.Seed.SeedHelper.WithDbContext[TDbContext](IIocResolver iocResolver, Action1 contextAction) en C:\Toni\GitLab\sener\src\SenerDemo.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs: línea 42 en SenerDemo.Migrations.Seed.SeedHelper.SeedHostDb(IIocResolver iocResolver) en C:\Toni\GitLab\sener\src\SenerDemo.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs: línea 18 en SenerDemo.EntityFrameworkCore.SenerDemoEntityFrameworkCoreModule.PostInitialize() en C:\Toni\GitLab\sener\src\SenerDemo.EntityFrameworkCore\EntityFrameworkCore\SenerDemoEntityFrameworkCoreModule.cs: línea 64 en Abp.Modules.AbpModuleManager.<>c.<StartModules>b__15_2(AbpModuleInfo module) en System.Collections.Generic.List1.ForEach(Action1 action) en Abp.Modules.AbpModuleManager.StartModules() en Abp.AbpBootstrapper.Initialize()

Esta excepción se generó originalmente en esta pila de llamadas: [Código externo]

Excepción interna 1: InvalidCastException: Cannot write DateTime with Kind=Local to PostgreSQL type 'timestamp with time zone', only UTC is supported. Note that it's not possible to mix DateTimes with different Kinds in an array/range. See the Npgsql.EnableLegacyTimestampBehavior AppContext switch to enable legacy behavior.

Steps to reproduce the issue:"

I create a new solution via Abp Suite (Postgres)

Add Migration (Initial)

Run solution

I get above error.

Note:

If I put floowing code in Startup.cs error goes away. AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);

This could be considered a bug?

Regards

The MVC JQuery tutorial works fine for ASP.NET Angular but with some changes:

  1. Upgrade Swashbuckle (4 nuggets) nugget to latest.
  2. Run yarn add @elsa-workflows/elsa-workflows-studio into solution root
  3. Run yarn add @elsa-workflows/elsa-workflow-designer into solution root
  4. Run yarn add monaco-editor into solution root
  5. Go to node_modules created folder for yarn and copy 3 distribution folders
  6. Then create a Elsa folder into wwwroot and paste 3 copied foldres from node_modules
  7. Modify _Host:

`

href="/Elsa/elsa-workflows-studio/assets/images/favicon-32x32.png"

href="/Elsa/elsa-workflows-studio/assets/images/favicon-16x16.png"

href="/Elsa/elsa-workflows-studio/assets/fonts/inter/inter.css"

href="/Elsa/elsa-workflows-studio/elsa-workflows-studio.css"

src="/Elsa/monaco-editor/min/vs/loader.js"

src="/Elsa/elsa-workflows-studio/elsa-workflows-studio.esm.js"

monaco-lib-path="Elsa/monaco-editor/min"

`

Then works! Don't know why can't use what is into Elsa.Designer and need to copy manually all folders.

The MVC JQuery tutorial works fine for ASP.NET Angular but with some changes:

  1. Upgrade Swashbuckle (4 nuggets) nugget to latest.
  2. Run yarn add @elsa-workflows/elsa-workflows-studio into solution root
  3. Run yarn add @elsa-workflows/elsa-workflow-designer into solution root
  4. Run yarn add monaco-editor into solution root
  5. Go to node_modules created folder for yarn and copy 3 distribution folders
  6. Then create a Elsa folder into wwwroot and paste 3 copied foldres from node_modules
  7. Modify _Host:

`

href="/Elsa/elsa-workflows-studio/assets/images/favicon-32x32.png"

href="/Elsa/elsa-workflows-studio/assets/images/favicon-16x16.png"

href="/Elsa/elsa-workflows-studio/assets/fonts/inter/inter.css"

href="/Elsa/elsa-workflows-studio/elsa-workflows-studio.css"

src="/Elsa/monaco-editor/min/vs/loader.js"

src="/Elsa/elsa-workflows-studio/elsa-workflows-studio.esm.js"

monaco-lib-path="Elsa/monaco-editor/min"

`

Then works! Don't know why can't use what is into Elsa.Designer and need to copy manually all folders.

This not working for ASP.NET Core Angular. We are using this in Startup.cs:

using Abp.AspNetCore; using Abp.AspNetCore.Mvc.Antiforgery; using Abp.AspNetCore.SignalR.Hubs; using Abp.AspNetZeroCore.Web.Authentication.JwtBearer; using Abp.Castle.Logging.Log4Net; using Abp.Extensions; using Abp.Hangfire; using Abp.PlugIns; using Abp.Timing; using Castle.Facilities.Logging; using GenTime.AppService; using GenTime.Authorization; using GenTime.Chat; using GenTime.Configuration; using GenTime.Configure; using GenTime.EntityFrameworkCore; using GenTime.Identity; using GenTime.Schemas; using GenTime.Web.Chat.SignalR; using GenTime.Web.Common; using GenTime.Web.HealthCheck; using GenTime.Web.IdentityServer; using GenTime.Web.Swagger; using GraphQL.Server; using GraphQL.Server.Ui.Playground; using Hangfire; using HealthChecks.UI.Client; using IdentityServer4.Configuration; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.Server.Kestrel.Https; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Hosting; using Microsoft.OpenApi.Models; using Newtonsoft.Json; using Owl.reCAPTCHA; using StackExchange.Redis; using Stripe; using System; using System.IO; using System.Linq; using System.Net; using System.Reflection; using System.Threading.Tasks; using HealthChecksUISettings = HealthChecks.UI.Configuration.Settings; using ILoggerFactory = Microsoft.Extensions.Logging.ILoggerFactory; using Microsoft.Extensions.Azure; using Azure.Storage.Queues; using Azure.Storage.Blobs; using Azure.Core.Extensions; using Elsa.Persistence.EntityFramework.Core.Extensions; using Elsa.Persistence.EntityFramework.Sqlite; using Elsa; using Microsoft.AspNetCore.Mvc.Versioning; using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Mvc; using Abp.AspNetCore.Mvc.Results; using Microsoft.AspNetCore.Mvc.Filters; using Abp.Dependency; using Abp.AspNetCore.Configuration; using Abp.AspNetCore.Mvc.Results.Wrapping; using Abp.AspNetCore.Mvc.Extensions; using Abp.Reflection.Extensions; using Elsa.Server.Api.Endpoints.WorkflowDefinitions;

When swagger is enabled cause error in:

        if (WebConsts.SwaggerUiEnabled)
        {
            //Swagger - Enable this line and the related lines in Configure method to enable swagger UI
            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new OpenApiInfo() { Title = "GenTime API", Version = "v1" });
                options.DocInclusionPredicate((docName, description) => true);
                options.ParameterFilter&lt;SwaggerEnumParameterFilter&gt;();
                options.SchemaFilter&lt;SwaggerEnumSchemaFilter&gt;();
                options.OperationFilter&lt;SwaggerOperationIdFilter&gt;();
                options.OperationFilter&lt;SwaggerOperationFilter&gt;();
                options.CustomDefaultSchemaIdSelector();
            }).AddSwaggerGenNewtonsoftSupport();
        }`

ERROR: Could not load type 'Swashbuckle.AspNetCore.SwaggerGen.IDataContractResolver' from assembly 'Swashbuckle.AspNetCore.SwaggerGen, Version=6.2.1.0, Culture=neutral, PublicKeyToken=d84d99fb0135530a'.

and if swagger is disabled cause error in:

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapHub<GensecureHub>("/signalr-gensecure");

            // For Dashboard.
            endpoints.MapFallbackToPage("/_Home");

            endpoints.MapControllerRoute("defaultWithArea", "{area}/{controller=Home}/{action=Index}/{id?}");
            endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");

            if (bool.Parse(_appConfiguration["HealthChecks:HealthChecksEnabled"]))
            {
                endpoints.MapHealthChecks("/health", new HealthCheckOptions()
                {
                    Predicate = _ => true,
                    ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
                });
            }
        });
   

ERROR: Unable to load one or more of the requested types. Could not load type 'Swashbuckle.AspNetCore.SwaggerGen.IDataContractResolver' from assembly 'Swashbuckle.AspNetCore.SwaggerGen, Version=6.2.1.0, Culture=neutral, PublicKeyToken=d84d99fb0135530a'.

When you will publish a good tutorial for ASP.NET Core Angular?

Thanks!

With dashboard too?

This tutorial works for ASP.NET Core Angular? Or only MVC JQuery?

It's solved ELSA 2 in 10.4?

Once again, this just defines what widgets are avaliable for each Dashboard. What we want to do is define the default location and size of the widgets, so that by default the dashboard isn't empty when the users access it for the first time

That only defines it. We mean, creating and defining the default pages and widgets in that dashboard. For example, setting the dashboard to have by default, 5 widgets ocupying 2x2 in the gridster

Showing 11 to 20 of 81 entries