This is an update to Simple PBL: useful for quick mockups, and understanding the core authentication methods and API calls available. Examples of what you can do:
- See what a custom theme will look like in a branded portal
- Demonstrate how embeded dashboards, explores and looks can fit into a portal
- Build a quick webhook or test an API call
It is NOT valid for production use, nor is it a useful reference architecture. Examples of what is missing:
- Components (e.g. React, Vue) or any other technique for building a real web application
- State management
- Data persistence
- User authentication (user details are hard coded into the config.js file)
Express PBL is based on Simple PBL – except that it is a full web application instead of a set of static files. This enables the authentication methods necessary to use the SDKs. Getting started has two major steps:
- Installation
- Configuration
- Install yarn if not already present
git clone https://github.com/ContrastingSounds/express_pbl.gitcd express_pblyarn install
Changes are required in the following places:
- On the Looker Instance
- Update default theme or add your own, at least:
- theme.js
- images in
img/directory
- Update config.js file in root directory
- (Optional) Update the html content
- Create a
startscript, based onstart.example - Download and install the cors-proxy, if you want to make client-side API calls
- Run
./startonce configured - Go to
localhost:3000
NOTE: you can have multiple themes available for demonstration, by replicating the full directory structure. Examples of this are found in the themes and confidential_example directories.
The .gitignore directory includes a confidential directory for scenarios where it is important to have commercially branded themes that must not be uploaded to the GitHub repo.
admin/embed - Set Embedded Domain Whitelist at https://<your_instance>.looker.com/admin/embed
admin/themes - Set Theme (I recommend getting rid of the grey background by quickly copying Looker theme to LookerWhite, and setting the background to #ffffff )
For simplest configuration, replace the images provided:
- favicon.ico (Standard browser tab favicon)
- image.png (340 x 150px. Used as a background image for sidebar)
- logo.png (Height approx 50px. Used for the center of the nav bar)
All icons refer to the Material Design icon set. Refer to https://materializecss.com/icons.html.
- Update baseURL and embedDomain
- Update sidebarItems: {}
- Use type: 'li' for a link to content
- Use content: '' to refer to one of the keys in your content object (also used for the display text)
- Use type: 'subheader' to create a subheader
- Use text: '' for the text you want displayed in the sidebar
- Use type: 'li' for a link to content
- Review the full config.js file, other things such as the page title can also be set
Checklist:
- Theme content has been updated, and exports.theme points to it
- Looker instance is set
- Cors proxy is set (unless client-side calls not being used)
- User is chosen from array of available users
- User definition is correct, in particular:
- Permissions granted
- Models listed
You can add more or remove pages using the navbarMenu object in theme.js. These can be used to provide explanatory text or images. The default files are intended to support:
- A 'Themes' page that enables you to switch between different themes
- A 'Client Calls' page to trigger client-side API calls
- A 'Server Calls' page to trigger server-side API calls
- A 'Cloud Native' page to explain Looker's architecture and role within a larger digital or cloud strategy
The "white" theme includes a slightly different set of HTML pages, as an example of tailoring the content to fit your mockup requirement.
cp start.example start- Update all environment variables
- Themes: Everything in /public/themes/
- Client side scripts: Add .js file to
/client_scripts, will be individually bundled by webpack - Server side webhooks: Add endpoints to
/routes/webhooks.js
- Update harded coded line
client_scripts/express_pbl.js:dashboard.updateFilters({'State': 'California'});
(Filter updates and interactivity rather limited! If you click on the logo, it's hardcoded to update a single filter value. At least the code pattern is in place...)
https://github.com/bryan-at-looker/embed-api-sdk-needs-cors-proxy
git clone https://github.com/Rob--W/cors-anywhere.gitcd cors-anywherenpm installnpm audit fix --force(optional fix the vulnerabilities)
node server.js
(note: this step is built in to the start script provided)
