Skip to content

Commit 1f6c8e4

Browse files
authored
Merge pull request #18 from byuoitav/request-help
Request help
2 parents 185a7d6 + 1224478 commit 1f6c8e4

23 files changed

+474
-32
lines changed

handlers/handlers.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ func GetStaticElements(c echo.Context) error {
8484
return c.Stream(http.StatusOK, fileType, file)
8585
}
8686

87+
func SendHelpRequest(c echo.Context) error {
88+
89+
var request schedule.HelpReqeust
90+
if err := c.Bind(&request); err != nil {
91+
return c.String(http.StatusBadRequest, err.Error())
92+
}
93+
94+
if err := schedule.SendHelpRequest(request); err != nil {
95+
return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to send help request for device: %s", request.DeviceID))
96+
}
97+
98+
return c.JSON(http.StatusOK, fmt.Sprintf("Help request sent for device: %s", request.DeviceID))
99+
}
100+
87101
func connectionCheck() {
88102
id := localsystem.MustSystemID()
89103
deviceInfo := events.GenerateBasicDeviceInfo(id)

schedule/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type Config struct {
2525
// functionality
2626
CanCreateEvents bool `json:"canCreateEvents"`
2727
DisplayMeetingTitle bool `json:"displayMeetingTitle"`
28+
CanRequestHelp bool `json:"canRequestHelp"`
2829

2930
// how to get events - from one of our calendars (gsuite, exchange, etc.)
3031
CalendarURL string `json:"calendarURL"`

schedule/helpRequest.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package schedule
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"time"
7+
8+
"github.com/byuoitav/central-event-system/hub/base"
9+
"github.com/byuoitav/central-event-system/messenger"
10+
"github.com/byuoitav/common/v2/events"
11+
"github.com/byuoitav/device-monitoring/localsystem"
12+
)
13+
14+
type HelpReqeust struct {
15+
DeviceID string
16+
}
17+
18+
func SendHelpRequest(request HelpReqeust) error {
19+
id := localsystem.MustSystemID()
20+
deviceInfo := events.GenerateBasicDeviceInfo(id)
21+
roomInfo := events.GenerateBasicRoomInfo(deviceInfo.RoomID)
22+
messenger, err := messenger.BuildMessenger(os.Getenv("HUB_ADDRESS"), base.Messenger, 1000)
23+
if err != nil {
24+
return err
25+
}
26+
27+
if messenger != nil {
28+
messenger.SendEvent(events.Event{
29+
GeneratingSystem: id,
30+
Timestamp: time.Now(),
31+
EventTags: []string{events.DetailState},
32+
TargetDevice: deviceInfo,
33+
AffectedRoom: roomInfo,
34+
Key: "help-request",
35+
Value: "confirm",
36+
})
37+
return nil
38+
}
39+
return fmt.Errorf("messenger not set up")
40+
}

server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ func main() {
6464
// get static elements
6565
e.GET("/static/:doc", handlers.GetStaticElements)
6666

67+
// send help request
68+
e.POST("/help", handlers.SendHelpRequest)
69+
6770
// handle load balancer status check
6871
e.GET("/status", func(c echo.Context) error {
6972
return c.String(http.StatusOK, "healthy")

web/src/app/app.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ export class AppComponent {
2323

2424
getBackground() {
2525
const url = this.data.getBackground();
26-
const background = "url(" + this.data.url + ":" + this.data.port + url + ")";
26+
const background = "url(" + url + ")";
2727
this.background = this.sanitizer.bypassSecurityTrustStyle(background);
2828
}
2929

3030
getStyles() {
3131
let url = this.data.getStylesheet();
32-
const style = this.data.url + ":" + this.data.port + url;
33-
this.customStyle = this.sanitizer.bypassSecurityTrustResourceUrl(style);
32+
this.customStyle = this.sanitizer.bypassSecurityTrustResourceUrl(url);
3433
}
3534

3635
stopStyleTimer() {

web/src/app/app.module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import { KeyboardSheetComponent } from './components/keyboard-sheet/keyboard-she
3232
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
3333

3434
import { BookDialogComponent } from './components/book-dialog/book-dialog.component';
35+
import { HelpDialogComponent } from './components/help-dialog/help-dialog.component';
36+
import { ConfirmHelpDialog } from './components/help-dialog/confirm-help';
3537

3638
@NgModule({
3739
declarations: [
@@ -42,7 +44,9 @@ import { BookDialogComponent } from './components/book-dialog/book-dialog.compon
4244
SchedulePageComponent,
4345
ScheduleListComponent,
4446
KeyboardSheetComponent,
45-
BookDialogComponent
47+
BookDialogComponent,
48+
HelpDialogComponent,
49+
ConfirmHelpDialog
4650
],
4751
imports: [
4852
BrowserModule,
@@ -65,7 +69,7 @@ import { BookDialogComponent } from './components/book-dialog/book-dialog.compon
6569
FormsModule,
6670
ReactiveFormsModule
6771
],
68-
entryComponents: [KeyboardSheetComponent, BookDialogComponent],
72+
entryComponents: [KeyboardSheetComponent, BookDialogComponent, HelpDialogComponent, ConfirmHelpDialog],
6973
bootstrap: [AppComponent]
7074
})
7175
export class AppModule { }

web/src/app/components/book-page/book-page.component.html

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<span class="booking-title">Booking {{ status.roomName }} for {{day | date : "EEEE, MMM dd"}}</span>
88
</mat-toolbar>
99

10-
<mat-grid-list cols="5" rowHeight="141px">
10+
<mat-grid-list cols="5" rowHeight="117.6px">
1111
<mat-grid-tile colspan="3" rowspan="3">
1212
<mat-card class="book-window-card">
1313
<mat-card-content class="event-label">Event Title</mat-card-content>
@@ -37,13 +37,26 @@
3737
<app-time></app-time>
3838
</mat-grid-tile>
3939
<mat-grid-tile colspan="2" rowspan="1">
40-
<button mat-stroked-button class="main-button" (click)="saveEventData()">
40+
41+
</mat-grid-tile>
42+
</mat-grid-list>
43+
44+
<mat-toolbar class="footer">
45+
<mat-toolbar-row>
46+
<span class="footer-spacer-left"></span>
47+
<button mat-stroked-button class="footer-button" (click)="saveEventData()">
4148
<mat-icon svgIcon="SaveTray" class="button-icon"></mat-icon>
42-
SAVE
49+
<span>SAVE</span>
4350
</button>
44-
<button mat-stroked-button class="main-button" (click)="routeToMain()">
51+
<button mat-stroked-button class="footer-button" (click)="routeToMain()">
4552
<mat-icon svgIcon="Cancel" class="button-icon"></mat-icon>
46-
CANCEL
53+
<span>CANCEL</span>
4754
</button>
48-
</mat-grid-tile>
49-
</mat-grid-list>
55+
<div *ngIf="status.displayHelp">
56+
<button mat-stroked-button class="footer-button" (click)="requestHelp()">
57+
<mat-icon svgIcon="Help" class="help-icon"></mat-icon>
58+
<span>HELP</span>
59+
</button>
60+
</div>
61+
</mat-toolbar-row>
62+
</mat-toolbar>

web/src/app/components/book-page/book-page.component.scss

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ app-time {
4141
padding-bottom: 5px;
4242
}
4343

44-
.button-icon {
45-
padding-right: 5px;
46-
}
47-
4844
.book-window-card {
4945
background-color: var(--booking-window-background-color);
5046
height: 80%;
@@ -111,3 +107,34 @@ mat-placeholder {
111107
color: var(--booking-select-options-color);
112108
font-size: 20px;
113109
}
110+
111+
.footer {
112+
height: 70px;
113+
background-color: var(--footer-background-color);
114+
}
115+
116+
.footer-spacer-left {
117+
flex: 1 1 auto;
118+
}
119+
120+
.footer-button {
121+
background-color: var(--button-background-color);
122+
color: var(--button-text-color);
123+
border: 1px solid var(--button-border-color);
124+
margin-left: 15px;
125+
margin-right: 15px;
126+
font-size: 20px;
127+
font-style: bold;
128+
font-family: var(--button-font);
129+
padding-top: 5px;
130+
padding-bottom: 5px;
131+
}
132+
133+
.button-icon {
134+
padding-right: 10px;
135+
}
136+
137+
.help-icon {
138+
padding-right: 10px;
139+
transform: scale(1.3);
140+
}

web/src/app/components/book-page/book-page.component.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { MatBottomSheet, MatDialog } from '@angular/material';
99
import { KeyboardSheetComponent } from '../keyboard-sheet/keyboard-sheet.component';
1010
import { FormControl } from '@angular/forms';
1111
import { BookDialogComponent } from '../book-dialog/book-dialog.component';
12+
import { HelpDialogComponent } from '../help-dialog/help-dialog.component';
1213

1314
@Component({
1415
selector: 'app-book-page',
@@ -35,7 +36,7 @@ export class BookPageComponent implements OnInit {
3536
private usrIdle: UserIdleService,
3637
private bookService: BookService,
3738
private bottomSheet: MatBottomSheet,
38-
public bookDialog: MatDialog) {
39+
public dialogRef: MatDialog) {
3940

4041
this.matIconRegistry.addSvgIcon(
4142
"BackArrow",
@@ -49,6 +50,10 @@ export class BookPageComponent implements OnInit {
4950
"Cancel",
5051
this.domSanitizer.bypassSecurityTrustResourceUrl("./assets/Cancel.svg")
5152
);
53+
this.matIconRegistry.addSvgIcon(
54+
"Help",
55+
this.domSanitizer.bypassSecurityTrustResourceUrl("./assets/helpOutline.svg")
56+
);
5257

5358
this.usrIdle.startWatching();
5459
this.usrIdle.onTimerStart().subscribe();
@@ -78,6 +83,10 @@ export class BookPageComponent implements OnInit {
7883
this.router.navigate(['/']);
7984
}
8085

86+
requestHelp(): void {
87+
const dialog = this.dialogRef.open(HelpDialogComponent, {});
88+
}
89+
8190
saveEventData(): void {
8291
let bookEvent = this.getEventData();
8392
if (bookEvent != null) {
@@ -142,13 +151,13 @@ export class BookPageComponent implements OnInit {
142151
}
143152

144153
openBookDialog(event: ScheduledEvent): void {
145-
const dialogRef = this.bookDialog.open(BookDialogComponent, {
154+
const dialog = this.dialogRef.open(BookDialogComponent, {
146155
width: '400px',
147156
panelClass: 'custom-dialog-container',
148157
data: event
149158
});
150159

151-
dialogRef.afterClosed().subscribe(result => {
160+
dialog.afterClosed().subscribe(result => {
152161
console.log('Book dialog was closed');
153162
if (result == 'success') {
154163
this.routeToMain();
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
2+
import { Component, Inject } from "@angular/core";
3+
4+
@Component({
5+
selector: "confirm-help",
6+
template: `
7+
<h1 mat-dialog-title class="text">Confirm</h1>
8+
9+
<div mat-dialog-content class="text">
10+
<p *ngIf="data">Your help request has been recieved; A member of our support staff is on their way.</p>
11+
<p *ngIf="!data">Your help request failed to send; Please try again or call AV Support at 801-422-7671</p>
12+
</div>
13+
14+
<div mat-dialog-actions class="items secondary-theme">
15+
<button mat-raised-button
16+
color="warn"
17+
(click)="cancel();">OK
18+
</button>
19+
</div>
20+
`,
21+
styles: [
22+
`
23+
.text {
24+
text-align: center;
25+
font-family: var(--main-font);
26+
}
27+
28+
.items {
29+
display: flex;
30+
flex-direction: row;
31+
justify-content: center;
32+
align-items: center;
33+
}
34+
`
35+
]
36+
})
37+
export class ConfirmHelpDialog {
38+
constructor(
39+
public dialogRef: MatDialogRef<ConfirmHelpDialog>,
40+
@Inject(MAT_DIALOG_DATA) public data: boolean
41+
) {}
42+
43+
public cancel() {
44+
this.dialogRef.close();
45+
}
46+
}

0 commit comments

Comments
 (0)