Bootstrapping of Dynamic App
Bootstrap mechanism makes it easy to integrate Dynamic App into the project.
The only thing that project need to do (in most cases) is to overwrite the boot.js file inside the compoents folder.
Structure of boot.js file
Example of boot.js for SAMO DEMO project:
// boot.js
var bootHelper = window.samo.bootHelper;
var opts = window.samo.dynamicBoot({
clientId: "demo-dynamic-client",
defaultPart: "cockpit",
defaultPage: "dashboard",
defaultLanguage: "en",
extraResources: [
bootHelper.prepareScriptResource("resources/themes/samo.js")
]
});
This should be really the only thing that you need to do to bootstrap the Danymic App.
Available options
All options that are accessible for application bootstrap.
Minimal
gatewayUrlstring required Gateway URL is used for constructing other URLs and it serves as base URL for Dynamic App to know where to ask for resources, metadata, ...
serveBaseUrlstring required URL from where the Dynamic App components are served.
clientIdstring required The GTW client ID.
extraResourcesarray Array of objects which define extra resources which should be loaded before application is bootstrapped.E.g. loading theme resource:
extraResources: [{type: "link",href: "resources/nergie/samo/themes/samo.html"}]The resources are loaded after the webcomponents so it should be safe to use custom elements in these resources.
applicationTypestring Required option indicates which application type will be bootstrapped. Enum:
dynamic-app(default)dynamic-portlet
Specific for dynamic-app
defaultPartstring Default part to be loadded. This option is related only whenapplicationTypeis set todynamic-app.
defaultPagestring Default pge to be loadded. This option is related only whenapplicationTypeis set todynamic-app.
disableSessionWatcherstring Dynamic app has implicit session warning in case of session is about to expire. This behavior can be disabled by settingdisableSessionWatcherto false. This option is related only whenapplicationTypeis set todynamic-app.
Specific for dynamic-portlet
partstring Metadata application part. This option is related only whenapplicationTypeis set todynamic-portlet.
portletstring Portlet ID. This option is related only whenapplicationTypeis set todynamic-portlet.
Common options
loadingImagestring Resource for loading logo/image.
defaultLanguagestring Default language for application.
resizeobject Definition of resize function. This is handy when placing portlet into page content so we need to dinamically resize the portlet according to other elements on page.resize: {minHeight: 400,excludeExtraHeight: 30,excludeElementsHeight: ["header<small>[role=banner]</small>","footer.wpthemeFooter"]}It takes the whole height of window and disctracts heights of elements
excludeElementsHeightfrom it. You can also exclude extra height withexcludeExtraHeightproperty or specify minimum height withminHeight.
navigationobject Navigation objest allows to map Dynamic Appnavigateevents to URLs.navigation: {routes: {"part/page": {url: "https://lighthouse.samo-asseco.com/"}}}This is handy when using portlet. e.g.: redirect to portal's home page after succesfull form submit.
showNotificationsboolean Portlet does not show any notification by default. Notifications must be explicitly enabled withshowNotifications=true. This option is related only whenapplicationTypeis set todynamic-portlet.
targetElementstring Specify element in which the application should be bootstrapped. By default the application is bootstrapped into thebodyelement.
messageTargetElementstring Specify element in which the application notification messages should be bootstrapped. By default they are bootstrapped into thebodyelement.
Offline - experimental
disableServiceWorkerboolean Options to disable service worked registration.
offlineEnabledboolean Enables offline capabilities for caching resources.
runtimeCacheStrategystring Definition of cache strategy. Enum:
networkFirstnetworkOnlycacheFirst
nGinx configuration
Dynamic App is almost in all cases served via GTW in the application and client context e.g.: /a/demo/c/demo-dynamic-client/
Accessing the dynamic app using directly GTW and this context should not make any troubles.
But projects often need to add proxy server (mostly nGinx) in fron the GTW so that only some subset of endpoints are accesible from internet.
In this case the application might be accessible on root context / and the the proxy server proxies the requests to the proper places.
Multiple GTW endpoint has to be accessed on the root context so we cannot just proxy everything to the client components endpoint /a/demo/c/demo-dynamic-client/.
One solution would be to fix the paths in the index.html file using filter:
location / {
proxy_pass http://localhost:10080/a/demo/c/demo-dynamic-client/;
}
location /a/ {
proxy_pass http://localhost:10080/a/demo/;
proxy_cookie_path /a/demo /;
}
Customers needs and infrastructure might be very complex so the nGinx configuration is very individual. Contact SAMO Support in case you need help configuring it.