Skip to content
This repository was archived by the owner on Aug 13, 2022. It is now read-only.

Commit 816e74b

Browse files
committed
collab-xapi-macros
- Fix missing image on 4.md - Fix some typos - Add code exegesis for 5.md
1 parent f02a6b8 commit 816e74b

File tree

4 files changed

+51
-7
lines changed

4 files changed

+51
-7
lines changed

labs/collab-xapi-macros/3.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ The use-case might be environments where multiple collaboration devices are clos
9292

9393
While restoring a 'template' backup file to multiple devices is much easier than manually creating macros and in-room controls sets step-by-step on each one individually, it still requires a significant effort and is susceptible to user error. Luckily collaboration devices running CE 9.3+ registered to CUCM or TMS can be configured to automatically retrieve, verify, and install template backup files from a web server (or CUCM TFTP) on startup.
9494

95-
Complete details on how this mechanism works, its capabilities and needed configurations are available in the Administration uide for your device (see the **Maintenance** > **Backup and restore configurations and custom elements** section.)
95+
Complete details on how this mechanism works, its capabilities and needed configurations are available in the Administration Guide for your device (see the **Maintenance** > **Backup and restore configurations and custom elements** section.)
9696

9797
## Programmatic provisioning of macros / controls
9898

labs/collab-xapi-macros/4.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,6 @@ To test your device's HttpClient functionality, we will make an HTTP request via
110110
111111
If everything worked, you should see `HTTP Request successful...` in the console log:
112112
113-
![Success](assets/images/step4-httpclient-success.png)
113+
![Success](assets/images/step4-success.png)
114114
115115
**This example was pretty abstract, let's try something a little more tangible...**

labs/collab-xapi-macros/5.md

+49-5
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ Frequently, enterprises have requirements like:
1818

1919
* Meetings frequently 'run over' and it's difficult for users to extend both the room reservation and any associated Webex session - again, laptops, logins, lookup and reservation steps are a pain. Users should be able to request a room / meeting reservation easily from the Touch10 interface.
2020

21-
Solutions to these use-cases exist, but typically involve cobbling together various hardware and software components into a clunky (and expensive) 'Rube Goldberg machine' scenario - e.g. a Cisco room device withTouch10, _plus_ a Crestron/AMX codec _plus_ tablet interface, _plus_ 3rd party occupancy sensors, _plus_ an external app-server...
21+
Solutions to these use-cases exist, but typically involve cobbling together various hardware and software components into a clunky (and expensive) 'Rube Goldberg machine' scenario - e.g. a Cisco room device with a Touch10, _plus_ a Crestron/AMX codec _plus_ tablet interface, _plus_ 3rd party occupancy sensors, _plus_ an external app-server...
2222

2323
![Compelex](assets/images/step5-rube-goldberg.png)
2424

25-
The good news is that with Cisco collaboration device automation, xAPI and macros, all of the above scenarios can potentially be accomplished by creating applications that run on-board the device itself and present customized Touch10 control interfaces for user interaction!
25+
The good news is that with Cisco collaboration device automation, xAPI, and macros, all of the above scenarios can potentially be accomplished by creating applications that run on-board the device itself and present customized Touch10 control interfaces for user interaction!
2626

2727
## The solution - a 'Book Meeting Room' panel + macro
2828

2929
The sample macro + in-room-control set we will test next provides a Touch10 panel UI allowing walk-in users to reserve the room for 15/30/45 or 60 minutes, using a simple UI on the Touch10.
3030

31-
The macro will handle this UI interaction, then make an HttpClient request to a remote app server to 'book' the room, providing feedback on the success/failure of the request via an on-screen alert pop-up.
31+
The macro will handle this UI interaction, then make an HttpClient request to a remote app server to 'book' the room, and finally provide feedback on the success/failure of the request via an on-screen alert pop-up.
3232

3333
![Book](assets/images/step5-book-panel.png)
3434

@@ -43,8 +43,8 @@ Note, this sample solution will use the 'fake' cloud REST API we used previously
4343
The sample would operates like this:
4444

4545
* It is deployed by an admin as a template backup file to the room system
46-
* The user clicks **Book** to open the booking panel, selects a duration, and click **Submit**
47-
* The macro handles the submit button click, and reads the selected duration value, creating a payload object encapsulating details of the booking request (start time, end time, device name, etc.)
46+
* The user clicks **Book** to open the booking panel, selects a duration, and clicks **Submit**
47+
* The macro handles the submit button click, and reads the selected duration value creating a payload object encapsulating details of the booking request (start time, end time, device name, etc.)
4848
* An HttpClient request is made to the JSONPlaceholder cloud REST API service containing the payload data (as this is a mock service, the request will always succeed)
4949
* The HttpClient response return code is checked for success/failure and an appropriate on-screen alert message is displayed
5050

@@ -66,6 +66,50 @@ The sample would operates like this:
6666

6767
**Congrats! You've completed the lab with flying colors...**
6868

69+
## Code review
70+
71+
Let's look at some of the interesting things going on in this macro (feel free to view the macro's JavaScript code in the **Macro Editor**:)
72+
73+
* Everything happens within a big function called when an event is received from `xapi.event.on('UserInterface Extensions Widget Action', ... )`
74+
75+
* Here we examine the incoming event, and proceed only on the one we need (clicking the Book/submit button:)
76+
77+
```javascript
78+
if ((event.WidgetId == 'button_submit') && (event.Type == 'clicked'))
79+
```
80+
81+
* The next section is interesting:
82+
83+
```javascript
84+
Promise.all([
85+
xapi.status.get('UserInterface Extensions Widget 1 Value'),
86+
xapi.config.get('SystemUnit Name')
87+
]).then( ... )
88+
```
89+
90+
'Promises' are a language feature of modern JavaScript which handles asynchronous methods - commands that are called and immediately allow the app to continue, but that sometime later return with their actual results. `Promise.all()` allows you to bundle and execute multiple promise executions in parallel, to be handled all at once when all complete - here `xapi` requests to read the meeting duration group widget's value and retrieve the system's unit name
91+
92+
* An object is created collecting together the various pieces of the booking request: the start/end times (calculated from the duration value and the current time via `Date.()`), and the system name: `let payload = {...}`
93+
94+
* As in the previous step, the HTTP request is made using the `xapi.command('HttpClient Post',...)`. Note that we are using the `AllowInsecureHTTPS: 'True'` parameter previously mentioned
95+
96+
* 'Promise chaining' (using `.then()` ) is used throughout the code to link the successful completion of one command with the execution of the next one. See if you can spot the general structure of the promise chain in this sample:
97+
98+
```javascript
99+
Promise.all(...)
100+
.then(
101+
xapi.command('HttpClient Post', ... )
102+
.then(
103+
xapi.command('UserInterface Message Alert Display', ... )
104+
)
105+
.catch( ... )
106+
)
107+
```
108+
109+
What do you think the `.catch( err ... )` block does..?
110+
111+
* The final outcome of the function depends on whether the `xapi.command('HttpClient Post')` promise succeeds of fails. If success, the `.then( ... )` block executes, and an xAPI command is performed to display a popup alert interface (with a 5 second timer); if fail, the `.catch( ... )` block runs, and the `err` object containing failure details is dumped to the console log
112+
69113
## Going further
70114

71115
We've just scratched the surface of the possiblities with macros, and would certainly encourage you to learn and experiment further...

0 commit comments

Comments
 (0)