Hybris with Angular frontend - sap-commerce-cloud

In hybris projects that use angular in the frontend, we are create angular components and add a proxy like this one to do the mapping and call the service:
{
"/hybris/*": {
"target": "<sap-nw-gateway-host>:<sap-nw-gateway-port>",
"secure": false,
"logLevel" : “info”
}
}
My question is:
How do we manage these components on the hybris side? On the cms cockpit, for instance.
Thanks in advance,
Jookje

We use the 'Spartacus' Framework in our project to communicate with Hybris BE. (I add this as a comment). Without going to deep in detail, it is about creating FlexComponents in Hybris CMS BE. Here is an example:
INSERT_UPDATE CMSFlexComponent; $contentCV[unique = true]; uid[unique = true]; name ; flexType ; &componentRef
; ; SiteLogoComponent ; Site LogoComponent ; xxxLogoComponent ; SiteLogoComponent

Related

How do I add the explorer to GraphiQL using 'flask-graphql'?

I am serving GraphiQL using flask-graphql but do not see any way to enable GraphiQL's "explorer" without using Node.JS. Is there a way to enable the explorer for a Python (flask-graphql) backend?
Node.js is not required, but React is since both graphiql and graphiql-explorer are React components. flask-graphql just renders an HTML page with a script that renders the GraphiQL interface using React as shown here.
You should be able to provide your own template for rendering this page when creating your GraphQLView via the graphiql_template option as shown here.
Copy and paste the existing template, then add the script tag for the library:
<script src="//cdn.jsdelivr.net/npm/graphiql-explorer#0.4.6/graphiqlExplorer.min.js"></script>
And implement the component as shown here. Since you're not transpiling this code, you won't be able to use JSX, so you'll need to do something like...
React.createElement(
"div",
{ className: "graphiql-container" },
React.createElement(
GraphiQLExplorer,
{ /* props here */ },
),
React.createElement(
GraphiQL,
{ /* props here */ },
)
)
Someone asked on the flask-graphql repo how to do it and I provided the initial template setup to get the explorer with some minor styles over that: Enabling "explorer" at Flask-graphql.

nopCommerce store with a custom plugin web deploy issue

NopCommerce version: 3.9
I've designed a web store using NopCommerce 3.9. Any code I added is in a plugin.
The store uses a front page that can be found in the plugin. It relies on a route called 'home' in a RouteProvider class in the plugin. It does not complain about that route, instead it complains about a route named 'RegisterVendor' found in the same file. Here are both routes
routes.MapRoute("home",
"",
new { controller = "AoiVendorsHome", action = "Index" },
new[] { "Nop.Plugin.Other.AoiVendors.Controllers" });
routes.MapRoute("RegisterVendor",
"register/designer",
new { controller = "AoiExchange", action = "RegisterVendor" },
new[] { "Nop.Plugin.Other.AoiVendors.Controllers" });
The plugin installs properly and everything works exactly as expected on my local machine.
The problem is after deploying to the web it can't find the route. Here is a imgur link, follow it to see the error
Restarting the server fixes the error for a while, but it does eventually come back. It also comes back any time I redeploy without restarting the server afterwards.
Does anyone have any ideas?
Thank You.
The "HomePage" route of nopCommerce is registred this way
//home page
routes.MapLocalizedRoute("HomePage",
"",
new { controller = "Home", action = "Index" },
new[] { "Nop.Web.Controllers" });
Check your load order: If your registration does not hit first, remove nopCommerce "HomePage" route and add yours or add yours first using the Priority property of IRouteProvider.
MVC uses the route that first matches the request.
Regarding the deployment problem, make sure your plugin is deployed to ~/Plugins/{yourPluginFolder} and not the bin folder of Nop.Web. Plugin in ~/bin folder can be loaded but without guarantee.
I was able to fix the issue by selecting the 'Remove additional files at destination' checkbox under file publish options on the settings tab in the publish popup dialog in visual studio. I imagine an older file was not being overwritten and was causing problems.

Serving static resources from external directories

What should be the correct way to serve images, or any other static resources like css and javascript, from a directory existing outside of the application?
I used to achieve this very easily in Spring MVC applications by using the mvc:resources element in xml configuration, or by extending WebMvcConfigurerAdapter and adding the respective resource handlers in Java configuration, then specifying the file system path where the resources were stored.
Having in mind that, as far as I can tell, jhipster doesn't use Spring MVC how could I achieve this functionality?
I tried configuring Spring MVC in jhipster but introducing the dispatcherServlet only caused the application to break (as expected, right?), and I'm still getting the hang of Angular so I'm not sure if the solution is that way.
Thanks in advance.
UPDATE:
Added my solution below.
For dev just place the file in /src/main/webapp/yourdir/ and it should be served (assuming it's a public static resource). For production, you'd need to add it to the static filter in config/WebConfigurer.java:
/**
* Initializes the static resources production Filter.
*/
private void initStaticResourcesProductionFilter(ServletContext servletContext,
EnumSet<DispatcherType> disps) {
log.debug("Registering static resources production Filter");
FilterRegistration.Dynamic staticResourcesProductionFilter =
servletContext.addFilter("staticResourcesProductionFilter",
new StaticResourcesProductionFilter());
staticResourcesProductionFilter.addMappingForUrlPatterns(disps, true, "/");
staticResourcesProductionFilter.addMappingForUrlPatterns(disps, true, "/index.html");
staticResourcesProductionFilter.addMappingForUrlPatterns(disps, true, "/images/*");
staticResourcesProductionFilter.addMappingForUrlPatterns(disps, true, "/fonts/*");
staticResourcesProductionFilter.addMappingForUrlPatterns(disps, true, "/scripts/*");
staticResourcesProductionFilter.addMappingForUrlPatterns(disps, true, "/styles/*");
staticResourcesProductionFilter.addMappingForUrlPatterns(disps, true, "/views/*");
staticResourcesProductionFilter.setAsyncSupported(true);
}
Thanks to the magic of Spring Boot, now I know you can configure MVC related stuff by extending WebMvcConfigurerAdapter. So I created my own configuration class that overrides the corresponding method, in this case addResourceHandlers and it works like a charm.
Just note that the #EnableWebMvc is NOT needed, otherwise you will mess with JHipster front end.

Setting up Web.config to work Side-by-Side with ASP.NET MVC 4 - Location Tag not resolving value "api"

I checked out Run servicestack side by side with another web framework.
When I add the location tag the "api" is unresolved...what do I need to do to get the location tag to be aware of "api"?
Firstly make sure you follow the README.txt instructions for running ServiceStack in ASP.NET MVC.
ServiceStack automatically infers the handler path based on the <location> tag, if there's more than one or it has some other issue inferring, it can be explicitly set in Config.ServiceStackHandlerFactoryPath, e.g:
SetConfig(new EndpointHostConfig {
ServiceStackHandlerFactoryPath = "api",
});

mvc3 on iis6 , only home page works , routes gives 404

I've deployed a MVC3 application to a win2003 server with .Net4.0 installed . I've configured wildcard mapping for application as described here . Also i did it before for other mvc3 applications on the same server before . I'm sure that the IIS configurations of both mvc3 applications are same.
When i hit the default home page of the default route, it works, but other controllers and actions gives 404. I can't figure out a way for 2 days . Any help will be great.
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new {controller = "Home", action = "Index", id = UrlParameter.Optional} // Parameter defaults );
Make sure that ASP.NET 4.0 is properly registered with IIS 6.0
c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
and that it is enabled:
Verify below items in IIS
Home Directory tab -> Configuration. Under Wildcard application maps,
1.the entry aspnet_isapi.dll has been added
2."verify file exists" checkbox should be in unchecked state

Resources