/wrapp

A configurable web application.

Primary LanguageJavaApache License 2.0Apache-2.0

Wrapp

There are aspects of a web application that are transversal with respect to the GUI implemented in the individual pages as:

  • Theme (css, scripts, header, footer, etc.);
  • User access (login, logout, etc.);
  • Configuration (locale, parameters, etc.);
  • Log management;
  • Menu management;
  • Auditing and monitoring (accesses, visited pages, etc.).

Wrapp is a web application that allows you to easily implement all the aspects listed above in a structured way.

With Wrapp you can WRap your web APPlication and deploy your services separately in independent modules (for example war, but also modules written in other languages).

Wrapp is configurable via the "wrapp_config.json" file in {user.home}/cfg or in resources folder.

In that you can configure:

  • "locale": language-country-variant;
  • "app": implementation of org.dew.wrapp.mgr.IAppManager;
  • "login": implementation of org.dew.wrapp.mgr.ILoginManager;
  • "menu": implementation of org.dew.wrapp.mgr.AMenuManager.

Example:

{
  "public": {
    "name": "Wrapp",
    "version": "1.0.0",
	"theme": "",
    "locale": "en"
  },
  "private": {
    "logo": "<h1 class=\"logo-name\" style=\"margin-left: -102px;\">$app.name</h1>",
    "app": "org.dew.wrapp.impl.DefaultAppManager",
    "login": "org.dew.wrapp.impl.DefaultLoginManager",
    "menu": "org.dew.wrapp.impl.DefaultMenuManager"
  }
}

In Wrapp each page is mapped by the Page object and can be called up from the URL page/{id}.

Page object has the following fields:

{
  "id": "hello",
  "title": "en=Hello page^it=Pagina di saluto^fr=Salutation^es=P�gina de saludo",
  "description": "en=Example of Wrapp page^it=Esempio di pagina Wrapp^fr=Exemple de page Wrapp^es=Ejemplo de p�gina Wrapp",
  "layout": "default",
  "modifier": "private",
  "header": "",
  "content": "",
  "footer": "",
  "script": "WuxDOM.render(new GUI.HelloWorld(), 'view-root');",
  "css": [
    "/hello/css/main.css"
  ],
  "scripts": [
    "/wrapp/wux/js/wux.min.js",
    "/hello/js/res-$language.min.js",
    "/hello/js/hello.min.js"
  ],
  "attributes": {
    "align": "center"
  }
}

The hello page has URL page/hello and the related jsp page is src/main/webapp/layouts/default.jsp (from layout).

When a module is deployed it should call the GET method wrapp/api/update?module={moduleName} of Wrapp REST API.

This call allows to append the correct timestamp to the css and imported scripts provided by that module.

As far as the menus are concerned, it is possible to define several hierarchical menus and make the items visible with respect to user authorizations.

Each menu is identified by an id and is made up of a list of MenuItem object.

Here is a sample menu.

{
  "main": [
    { "id": "app",       "text": "en=Application^it=Applicazione^fr=Application^es=Aplicaci�n", "icon": "fa-edit" },
    { "id": "app.hello", "text": "en=Hello^it=Saluto^fr=Salutation^es=saludo",                  "icon": null,     "link": "page/hello"}
  ]
}

You can implement your own org.dew.wrapp.mgr.IAppManager by loading menus and pages for example from a database or from a nosql.

REST API

Reload

Reload Web App configuration, pages and menus.

Request:
GET http://localhost:8080/wrapp/api/reload

Response:
HTTP 204 No Content

Refresh

Update reference of a module appending timestamp in css and script imports.

Request:
GET http://localhost:8080/wrapp/api/refresh?module={moduleName}

Response:
HTTP 204 No Content

No Operation

Used to keep the session active or to ping webapp.

Request:
GET http://localhost:8080/wrapp/api/nop

Response:
HTTP 204 No Content

User

Get user logged in current session.

Request:
GET http://localhost:8080/wrapp/api/user

Response:
HTTP 200 OK
Content-Type: application/json

{"userName":"test","role":"admin","tokenId":"..."}

Update

Update password of logged user.

Request:
POST http://localhost:8080/wrapp/api/update

op=oldPassowrd&np=newPasswrd

Response:
HTTP 204 No Content

Response: (if old password is incorrect, new password is invalid or user is not logged)
HTTP 403 Forbidden

Contributors