Skip to content

Commit 5b66d19

Browse files
authored
Merge pull request #48 from uw-asa/develop
Update to support Mazevo - Version For Release: 3.2
2 parents 822c5c6 + c927450 commit 5b66d19

File tree

9 files changed

+315
-50
lines changed

9 files changed

+315
-50
lines changed

README.md

Lines changed: 81 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,14 @@ Note: If you're using Linux Bash for Windows, [see this guide](https://www.howto
2323

2424
Sample configuration file provided in `sample.env`
2525

26-
- `WIW_API_TOKEN=when-i-work-login-token`
27-
28-
Sets the login token for the When I Work API. Necessary to load any data from When I Work.
29-
30-
- `WIW_API_URL=https://api.wheniwork.com/2/`
31-
32-
Base URL for When I Work's API. Shouldn't change too much.
33-
34-
- `EMS_API_USER=username`
35-
36-
Username to pass to EMS for accessing the API.
37-
38-
- `EMS_API_PASS=password`
39-
40-
Password to pass to EMS for accessing the API.
41-
42-
- `EMS_API_URL=https://base.url/EMSAPI/`
43-
44-
Root URL for the EMSAPI.
45-
46-
- `NOTES_TITLE_SEPARATOR=-`
26+
#### Layout and Display Settings
4727

48-
Titles for events are in the notes for shifts in When I Work for our particular environment. This is subject to change, and thus the separator can be configured. Works in concert with `SEPARATOR_WHITESPACE`.
28+
- `DISPLAY_PX_X=1920`
29+
- `DISPLAY_PX_Y=1080`
4930

50-
- `SEPARATOR_WHITESPACE=true`
51-
52-
Configures whether or not the separator is surrounded by whitespace or not. In this example the above separator would be a dash surrounded by whitespace.
31+
Optional. Device-specific Display specification. Used when creating the display window to ensure
32+
it's the appropriate size for the attached display. Only needed if the machine cannot determine the
33+
display dimensions on it's own.
5334

5435
- `MAX_REFRESH_INTERVAL=300`
5536

@@ -63,6 +44,7 @@ Sample configuration file provided in `sample.env`
6344
- LABOR = When I Work Labor (condensed view)
6445
- EVENTS = When I Work labor events associated with an event
6546
- EMS-EVENTS = Events scheduled in EMS (regardless of labor assignment)
47+
- MZV-EVENTS = Events scheduled in Mazevo
6648

6749
When both Left and Right render modes are the same, the screen will render data across both columns (top to bottom, left to right). When the settings are different, each column will render it's data in the set column only (top-to-bottom).
6850

@@ -75,6 +57,16 @@ Sample configuration file provided in `sample.env`
7557

7658
Sets the display title in the corner of the screen. Defaults to 'Events Display'.
7759

60+
#### API Data Source: When I Work
61+
62+
- `WIW_API_TOKEN=when-i-work-login-token`
63+
64+
Sets the login token for the When I Work API. Necessary to load any data from When I Work.
65+
66+
- `WIW_API_URL=https://api.wheniwork.com/2/`
67+
68+
Base URL for When I Work's API. Shouldn't change too much.
69+
7870
- `WIW_API_LOCATION=123456`
7971

8072
API Location ID to search When I Work for shift data. Can be set to a comma-delimited list, such as `123456,234567,345678` to get shifts for multiple locations at once.
@@ -83,30 +75,82 @@ Sample configuration file provided in `sample.env`
8375

8476
How many days worth of data to query from the API each time. Defaults to 7.
8577

78+
- `LABOR_MODE_CUSTOM_NAMING=123456:Event,234567:Office`
79+
80+
Naming to differentiate When I Work locations from each other when using the 'LABOR' layout, which has shifts in a condensed form.
81+
82+
- `NOTES_TITLE_SEPARATOR=-`
83+
84+
Titles for events are in the notes for shifts in When I Work for our particular environment. This is subject to change, and thus the separator can be configured. Works in concert with `SEPARATOR_WHITESPACE`.
85+
86+
- `SEPARATOR_WHITESPACE=true`
87+
88+
Configures whether or not the separator is surrounded by whitespace or not. In this example the above separator would be a dash surrounded by whitespace.
89+
90+
#### API Data Source: EMS
91+
92+
- `EMS_API_USER=username`
93+
94+
Username to pass to EMS for accessing the API.
95+
96+
- `EMS_API_PASS=password`
97+
98+
Password to pass to EMS for accessing the API.
99+
100+
- `EMS_API_URL=https://base.url/EMSAPI/`
101+
102+
Root URL for the EMSAPI.
103+
86104
- `EMS_LOOKAHEAD_DAYS=5`
87105

88106
How many days worth of data to query from the API each time. Defaults to 7.
89107

90108
- `EMS_BUILDINGS=1,2,3,4`
91109

92-
Building IDs in EMS to gather booking / event data for.
110+
Building IDs in EMS to gather booking / event data for. Comma-separated, no whitespace.
93111

94112
- `EMS_STATUSES=2,3,4,5`
95113

96-
Status IDs in EMS to gather booking / event data for.
114+
Status IDs in EMS to gather booking / event data for. Comma-separated, no whitespace.
97115

98116
- `EMS_EVENT_TYPES=1,2,3,4,5,6,7,8,9`
99117

100-
Event Type IDs in EMS to gather booking / event data for.
118+
Event Type IDs in EMS to gather booking / event data for. Comma-separated, no whitespace.
101119

102-
- `LABOR_MODE_CUSTOM_NAMING=123456:Event,234567:Office`
103-
104-
Naming to differentiate When I Work locations from each other when using the 'LABOR' layout, which has shifts in a condensed form.
105-
106120
- `EMS_Status_ROW_HIGHLIGHT=2:#ffffff50,3:#aabbccdd`
107121

108122
Set row highlight colors (HEXA) (hex w/ alpha) associated event status ID (ID first). Applies to EMS event date list only. Separate each state setting from the color value by commas (`,`). Separate status ID and color code by colons (`:`).
109123

124+
#### API Data Source: Mazevo
125+
126+
- `MZV_API_URL=https://mazevo_public_API_URL/api/`
127+
128+
Mazevo URL to gather data from.
129+
130+
- `MZV_API_KEY=somehexstring`
131+
132+
Mazevo API Key. Generated on the Mazevo Web console.
133+
134+
- `MZV_LOOKAHEAD_DAYS=5`
135+
136+
How many days worth of data to query from the API each time. Defaults to 7.
137+
138+
- `MZV_BUILDINGS=1,2,3,4`
139+
140+
Building IDs in Mazevo to gather booking / event data for. Comma-separated, no whitespace.
141+
142+
- `MZV_STATUSES=2,3,4,5`
143+
144+
Status IDs in Mazevo to gather booking / event data for. Comma-separated, no whitespace.
145+
146+
- `MZV_EVENT_TYPES=1,2,3,4,5,6,7,8,9`
147+
148+
Event Type IDs in Mazevo to gather booking / event data for. Comma-separated, no whitespace.
149+
150+
- `MZV_ROOMS=1,24,86`
151+
152+
Room IDs from Mazevo to gather booking / event data for. Comma-separated, no whitespace.
153+
110154
## Updates
111155

112156
Dependency updates: update the base image in `Dockerfile` and update application dependencies in `package.json`.
@@ -133,21 +177,23 @@ Use Ensure files are up to date and that you are on the correct code branch. Run
133177
2. Log into the Balena console with `balena login`
134178
3. Build the image
135179

136-
> `balena build --fleet [BALENA FLEET NAME] --logs .`
180+
> `balena build --fleet [BALENA FLEET NAME] .`
137181
138182
**Note(s):** Don't forget the trailing `.` which designates the current directory as the source for the code. Substitute in the name of your fleet for `[BALENA FLEET NAME]` which corresponds to the application name on the Balena Cloud dashboard. Add `--logs` to see the complete build details. For complete CLI documentation and other options see the [Balena CLI documentation][2].
139183

140184
4. Push the built image to Balena Cloud
141185

142186
> `balena deploy [BALENA FLEET NAME]`
143187
144-
### Building with Balena Cloud
188+
### Building with Balena Cloud (Recommended)
189+
190+
This method tends to be more reliable and avoids local problems dependent on docker desktop being installed.
145191

146192
1. Open a console to the project root (where `Dockerfile.template` and `package.json` are)
147193
2. Log into the Balena console with `balena login`
148194
3. Push code to Balena's build servers and wait for the image to be deployed automatically
149195

150-
> `balena push [BALENA FLEET NAME] .`
196+
> `balena push [BALENA FLEET NAME]`
151197
152198
## Resources for Learning Electron
153199

main.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ const { getWiwSchedule } = require('./utils/fetchWiwSchedule');
7575
const getEmsSchedule = require('./utils/fetchEmsSchedule');
7676
const markupEventShiftResults = require('./utils/renderEventShifts');
7777
const markupLaborResults = require('./utils/renderLaborCondensed');
78-
const markupEventListResults = require('./utils/renderEventList');
78+
const markupEmsEventListResults = require('./utils/renderEmsEventList');
79+
const { getMazevoSchedule } = require('./utils/fetchMazevoSchedule');
80+
const markupMzvEventListResults = require('./utils/renderMazevoEventList');
7981

8082
// pull in template renderers
8183
const dualSourceTemplate = pug.compileFile('./templates/body2column-DualSource.pug');
@@ -173,7 +175,11 @@ function determineSideModeRenderFunctions(modeSetting, SETTINGS_DATA_MAPPING, AC
173175
}
174176
if (SETTINGS_DATA_MAPPING[modeSetting] === 'EMS' && modeSetting === ACCEPTABLE_SETTINGS[2]) {
175177
// set EMS events list
176-
return [getEmsSchedule, markupEventListResults];
178+
return [getEmsSchedule, markupEmsEventListResults];
179+
}
180+
if (SETTINGS_DATA_MAPPING[modeSetting] === 'MZV' && modeSetting === ACCEPTABLE_SETTINGS[3]) {
181+
// set Mazevo Events List
182+
return [getMazevoSchedule, markupMzvEventListResults];
177183
}
178184
throw new Error('Mode setting error; unable to determine mode setting from env vars.');
179185
}

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "when-i-work-events-shifts-display",
3-
"version": "3.1.1",
4-
"description": "Shift display for Events Services, pulling data from the When I Work API",
3+
"version": "3.2.0",
4+
"description": "Shift display for Events Services, pulling data from When I Work, EMS, or Mazevo",
55
"main": "main.js",
66
"scripts": {
77
"start": "electron .",
@@ -18,7 +18,8 @@
1818
"digital",
1919
"signage",
2020
"wheniwork",
21-
"ems"
21+
"ems",
22+
"mazevo"
2223
],
2324
"author": "Chase Sawyer",
2425
"license": "MIT",

preload.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ const {
1818
let renderModeSingle = true;
1919

2020
// Configure rendering mode and constants for control:
21-
// options for DISPLAY_RENDER_MODEs: "LABOR", "EVENTS", or "EMS-EVENTS"
21+
// options for DISPLAY_RENDER_MODEs: "LABOR", "EVENTS", "EMS-EVENTS", or "MZV-EVENTS"
2222
// LABOR = When I Work Labor (condensed view)
2323
// EVENTS = When I Work labor events associated with an event
2424
// EMS-EVENTS = Events scheduled in EMS (regardless of labor assignment)
25-
const ACCEPTABLE_SETTINGS = ['LABOR', 'EVENTS', 'EMS-EVENTS'];
25+
// MZV-EVENTS = Events scheduled in Mazevo (regardless of labor assignment)
26+
const ACCEPTABLE_SETTINGS = ['LABOR', 'EVENTS', 'EMS-EVENTS', 'MZV-EVENTS'];
2627
const SETTINGS_DATA_MAPPING = {
2728
LABOR: 'WIW',
2829
EVENTS: 'WIW',
2930
'EMS-EVENTS': 'EMS',
31+
'MZV-EVENTS': 'MZV',
3032
};
3133
if (DISPLAY_RENDER_MODE_LEFT !== DISPLAY_RENDER_MODE_RIGHT) {
3234
renderModeSingle = false;

static/css/content.css

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,25 @@
2424
}
2525

2626
td.time-width {
27-
/* min-width: 60px; */
27+
min-width: 72px;
28+
/* width: 80px; */
29+
}
30+
31+
td.event-title {
32+
width: 100%;
2833
}
2934

3035
td.room-code {
31-
/* min-width: 75px; */
36+
min-width: 75px;
3237
}
3338

3439
td.event-title {
3540
/* min-width: 475px; */
36-
/* max-width: 475px; */
41+
max-width: 475px;
3742
white-space: nowrap;
3843
overflow: hidden;
3944
text-overflow: ellipsis;
40-
max-width: 100%;
45+
/* max-width: 100%; */
4146
}
4247

4348
#reload-interval {

templates/eventDateCard.pug

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@ div(class='card mx-0 mx-lg-2 p-0 d-inline-block w-100 eventDateCard')
88
if event.now
99
tr(style=`background-color: ${event.highlight ? event.highlight : '#00000000'}`).fw-bold.shift-item
1010
td.d-table-cell.room-code #{event.room}
11-
div.d-block.d-lg-none #{event.bookStart}
1211
td.d-table-cell.text-truncate.event-title #{event.title}
13-
div.d-block.d-lg-none #{event.bookEnd}
1412
td.time-width.d-none.d-lg-table-cell #{event.bookStart}
1513
td.time-width.d-none.d-lg-table-cell #{event.eventStart}
1614
td.time-width.d-none.d-lg-table-cell #{event.eventEnd}
1715
td.time-width.d-none.d-lg-table-cell #{event.bookEnd}
1816
else
1917
tr(style=`background-color: ${event.highlight ? event.highlight : '#00000000'}`).shift-item
2018
td.d-table-cell.room-code #{event.room}
21-
div.d-block.d-lg-none #{event.bookStart}
2219
td.d-table-cell.text-truncate.event-title #{event.title}
23-
div.d-block.d-lg-none #{event.bookEnd}
2420
td.time-width.d-none.d-lg-table-cell #{event.bookStart}
2521
td.time-width.d-none.d-lg-table-cell #{event.eventStart}
2622
td.time-width.d-none.d-lg-table-cell #{event.eventEnd}

0 commit comments

Comments
 (0)