Core views
public/views/ holds the views the XYZ API ships. They are the core templates of the view API.[1]
| File | Template keys | Served by |
|---|---|---|
_default.html | default_view | /, ${DIR}/, /view |
_login.html | login_view, register_view, password_reset_view | /api/user/login, /api/user/register |
_user.html | user_admin_view | /api/user/admin for admins |
Behaviour
The default view is the map application: a control panel with layers, gazetteer and locations, the map with a button column, and a tab view below the map for dataviews. It is the reference for a custom view.
The login view shows the login form for login_view and the register form otherwise, with a language dropdown. The msg param shows a message, eg. after a failed login.[2]
The user admin view lists the ACL users in a Tabulator table loaded from a CDN. It does not use the MAPP libraries.[3]
Flow
The default view script runs in this order:[4]
mapp.utils.mobile(765)sets the width for the mobile layout./api/user/cookierefreshes the cookie and setsmapp.user, orfalsewithout an ACL. User properties stored in the browser's IndexedDB are merged in.mapp.languageis thelanguageURL param, the user's language oren; other languages load their dictionary. See language.- The resize handlers and the
tabviewTabview are created. /api/workspace/localeslists the locales. ThelocaleURL param, the first listed locale orlocaleis loaded from/api/workspace/locale?locale=…&layers=true. A failure shows theno_localesdialog.- An object
localeof the user is merged into the locale. AuserlocaleURL param replaces it with a locale stored for the user. locale.syncPluginsdefaults tozoomBtn,admin,login, and thelocaleURL param is set.mapp.Mapviewis created withhooks: true,loadPlugins: true,scrollWheelZoom, the control panel, the#mapButtoncolumn and the attribution. This loads and runs the locale plugins.[5]mapview.addLayer(locale.layers), then the layers listview, the gazetteer panel iflocale.gazetteeris set, and the locations listview.mapview.interactions.highlight()starts selection on hover and click.- Each
locationshook (layer!id) is selected withmapp.location.get. - With a user and
locale.idle,mapp.ui.utils.idleLogoutlogs out after the idle time.
Where to change
- Layout, panels and start-up order:
public/views/_default.html. - To change the default view for one deployment, add a
default_viewtemplate to the workspace instead of editing the file; see custom views. - Login and register forms:
apps/ui/lib/elements/loginForm.mjsandregisterForm.mjs; the page:public/views/_login.html.
Tests
apps/ui/tests/default.spec.mjs opens the default view with a test locale: the libraries load, the layers panel lists the locale layers, and locale and z are set as URL params.
Pitfalls
- Buttons of the
zoomBtn,fullscreenand other ui plugins are added tomapview.mapButton. A view without that element gets no buttons, and no error. - The default view supports nested locales through the locales dropdown. A
localeURL param of nested keys is comma separated, eg.UK,London. - The user admin view reads
only; it has no.