arcgis web appbuilder: creating new themes · controller widget •this sidebar controller widget...

52
ArcGIS Web AppBuilder: Creating New Themes Yiwei Ma

Upload: others

Post on 29-May-2020

18 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

ArcGIS Web AppBuilder: Creating New

ThemesYiwei Ma

Page 2: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Yiwei (E-WAY) Ma

About Me

Page 3: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Web AppBuilder (WAB) Themes

Page 4: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Web AppBuilder Themes

Billboard Box Dart Foldable

Jewelry Box Launchpad Plateau Tab

+Custom

Page 5: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Major Components In A WAB Theme

• Layout

• Panel

• Style

• Widget

Read more…

Page 6: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

What Composes a WAB Theme?

• Layout

• Panel

• Style

• Widget

+

-

Page 7: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

What Composes a WAB Theme?

• Layout

• Panel

• Style

• Widget

+

-widget

widget

Page 8: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

What Composes a WAB Theme?

• Layout

• Panel

• Style

• Widget

+

-widget

widget

Page 9: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

What Composes a WAB Theme?

• Layout

• Panel

• Style

• Widget

+

-widget

widget

Page 10: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Let’s Create A New Theme

Page 11: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Mockup

Page 12: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Mockup UI Break Down

Page 13: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Some Good-To-Haves

Page 14: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

STEP 1: Create Theme Folder

Structure

Page 15: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Minimum Required File Structure

1 MyTheme

1 images

icon.png

1 layouts

1 default

config.json

icon.png

1 nls

strings.js

1 styles

1 default

style.css

common.css

main.js

manifest.json

Page 16: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

USE DEMOTHEME TO START

• DemoTheme contains all components needed to create a new theme

• Location: client\stemapp\themes\DemoTheme

Page 17: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Update manifest.json

"name": ”SidebarTheme",

"label": "This is my theme, and it’s awesome",

"platform": "HTML",

"layouts": [{. . .}],

"panels": [{. . . }],

"styles": [{. . .}],

"widgets": [{. . .}],

"version": ”2.3",

"wabVersion": “2.3",

"author": "Esri Professional Services",

"description": "",

"copyright": "",

"license": "http://www.apache.org/licenses/LICENSE-2.0"

1 SidebarTheme

0 images

0 layouts

0 nls

0 panels

0 styles

0 widgets

common.css

main.js

manifest.json

Need to match

Page 18: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read
Page 19: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Step 2: Update Layout

Page 20: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Remove Unused Widgets

• For example, the following widgets will not be used in Sidebar Theme, remove them from

"widgets" under "widgetOnScreen" :

- "widgets/Scalebar/Widget”

- "widgets/HomeButton/Widget”

- "widgets/Coordinate/Widget”

- "widgets/BasemapGallery/Widget"

Read more on widgetOnScreen

Page 21: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Add More Widget(s)

• Add the Search widget to the widgetOnScreen:

This will display the widget by default,

Instead of wrapping it in an icon

Page 22: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Reposition Widget(Controller)

Page 23: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Reposition Panel (in widgetPool)

Page 24: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Reposition Map

Page 25: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read
Page 26: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Step 3: Controller Widget

Page 27: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Controller Widget

• This Sidebar Controller widget will be able to:

- Read app config and display app logo, and user

information

- Read widget configs and display their icons

- Open the first widget defined in the “widgetPool” or the

widget with “openAtStart” turned on

- Switch different widgets and open one at a time in the

panel widget when a widget icon is clicked

More on app config, and widget config

appConfig

Page 28: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Controller Widget

• Create a folder call widgets

• Copy the CustomWidgetTemplate folder from ~/client/stemapp/widgets/samplewidgets

• Rename it to SidebarController

• Open manifest.json:

- make sure these properties are set as follows:

- "inPanel": false,

- "isController": true,

-

- "isThemeWidget": true

Read more...

It is a controller instead of a default

WAB widget

So it does not need a panel to display

It is a theme specific widget

Page 29: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Add HTML Template

• Add the following code to Widget.html:

Read more on creating widgets with Dojo Toolkit

Page 30: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Add Controller widget to the layout

• Open the layout config.json and add the controller to the placeholder defined in the

“Layout” session:

Page 31: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read
Page 32: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Add App Logo

• Use “this.appConfig.logo” to get the url of the app logo image and populate it on the UI:

Page 33: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Add User Thumbnail

• Use “jimu/portalUtils” class to read a user’s information from the Portal:

Page 34: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Read And Add Widget Icons

• Use “this.getAllConfigs();” to get the configs for all widgets defined in the “widgetPool”,

and then loop through to add their icons to the UI:

Read more on widgetPool

Page 35: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read
Page 36: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Step 4: Panel Widget

Page 37: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Panel Widget

• This Panel widget will be able to:

- Show the name of the opened widget in the header section

- Display the dom node of the widget in its content section

• We will modify on top of the SimpleBorderPanel

Page 38: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Panel Widget

• Rename the folder name of SimpleBorderPanel to something else. e.g.:

SimpleHeaderPanel

• Update panel information in manifest.json:

• update the panel path in layouts/default/config.json:

Page 39: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Add HTML Template

• Add an HTML template named Panel.html in panels/SimpleHeaderPanel, and add two

html elements for header and content:

Page 40: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Work On Panel.js

• Since we added an HTML template, the following dependencies need to be added in the

"define" area in Panel.js:

• Use this.config to read current widget’s configuration settings to add the header:

Page 41: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Work On Panel.js

• No need to add code to read and add a widget to the containerNode. This is all taken

care of by JIMU’s BaseWidgetPanel class, which the Panel widget inherits.

Page 42: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read
Page 43: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Step 5: Style

Page 44: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

What Makes Up The WAB UI?

Dojo dijits ArcGIS API widgets

Jimu widgets

WAB UI

Page 45: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

How UI Libraries Work In WAB:

Dojo dijits: claro.css

ArcGIS API for JavaScript: esri.css

Jimu: jimu.css, jimu-override.css, etc.

Theme: common.css, style.css

Page 46: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

common.css

• Effective on ALL styles within the same theme

• Use common.css to apply the basic style rules such as:

- Typography

- Icons

- Normalization

- Spacings

- Overrides of Dojo dijits and ArcGIS API widgets

Page 47: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

styleFolder/style.css

• Effective ONLY when it is selected

• Use style.css to update color themes

Page 48: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read
Page 49: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read
Page 50: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Useful Resources

WAB Theme Concepts

https://developers.arcgis.com/web-appbuilder/guide/concepts.htm

Detailed online tutorial on creating a WAB theme:

https://developers.arcgis.com/web-appbuilder/sample-code/create-a-new-theme.htm

Source Code of the SidebarTheme:

Download on GeoNet

Web AppBuilder on GeoNet:

https://geonet.esri.com/community/gis/web-gis/web-appbuilder

Page 51: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read

Q&A

Page 52: ArcGIS Web AppBuilder: Creating New Themes · Controller Widget •This Sidebar Controller widget will be able to:-Read app config and display app logo, and user information-Read