Skip to content

Commit 936f38c

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents f091ca2 + b766967 commit 936f38c

22 files changed

+648
-42
lines changed

Diff for: .DS_Store

10 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<div class="d-flex justify-content-center mt-5 pt-5" *ngIf="loading">
2+
<div class="spinner spinner-border"></div>
3+
</div>
4+
<button (click)="this.locationBackService.goBack()" id="backBtn" title="Go back"><i class="fas fa-arrow-left"></i> Back</button>
5+
<div id="page" *ngIf="validReport">
6+
<div id="text">
7+
<h1>:(</h1>
8+
<h2>There was an unexpected error. Please open a bug report on the project's Github page or contact one of
9+
the developers.</h2>
10+
</div>
11+
<div style="text-align: center">
12+
<a id="bugReportButton" class="btn btn-lg btn-custom" [attr.href]="bugReportUrl" target="_blank" role="button">Open a bug report on Github</a>
13+
</div>
14+
<div class="col">
15+
<h3>Stacktrace:</h3>
16+
<pre id="stacktrace">{{ currentReport.stacktrace }}</pre>
17+
</div>
18+
<div class="col">
19+
<h3>Error datetime</h3>
20+
<h4>{{ currentReport.datetime | date:'YYYY-MM-dd HH:mm:ss' }}</h4>
21+
</div>
22+
<div id="row">
23+
<div class="col">
24+
<h3>Logs:</h3>
25+
<pre class="limit" id="logs">{{ currentReport.logs }}</pre>
26+
</div>
27+
<div class="col">
28+
<h3>Config file:</h3>
29+
<pre class="limit" id="config">{{ currentReport.config | json }}</pre>
30+
</div>
31+
</div>
32+
</div>
33+
<div id="page" *ngIf="!validReport && !loading">
34+
<div id="text">
35+
<h1>:(</h1>
36+
<h2>Error report not found.</h2>
37+
</div>
38+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/* Based on https://codepen.io/xontab/pen/JrVaYR */
2+
#page {
3+
height: 100%;
4+
margin: 0 auto;
5+
width: 80%;
6+
font-size: 1.9vw;
7+
font-family: Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif;
8+
color: #fefeff;
9+
}
10+
11+
@media (min-width: 840px) {
12+
#page {
13+
font-size: 140%;
14+
width: 800px;
15+
}
16+
}
17+
18+
#text {
19+
vertical-align: middle;
20+
}
21+
22+
h1,
23+
h2,
24+
h3,
25+
h4,
26+
h5 {
27+
font-weight: normal;
28+
padding: 0;
29+
margin: 25px 0;
30+
margin-top: 0;
31+
font-weight: 300;
32+
}
33+
34+
h1 {
35+
font-size: 6.5em;
36+
margin-bottom: 10px;
37+
}
38+
39+
h2 {
40+
font-size: 1.5em;
41+
}
42+
43+
h4 {
44+
font-size: 1.4em;
45+
line-height: 1.5em;
46+
}
47+
48+
h5 {
49+
line-height: 1.1em;
50+
font-size: 1.3em;
51+
}
52+
53+
.limit {
54+
overflow-x: scroll;
55+
width: 300px;
56+
}
57+
58+
#row {
59+
display: flex;
60+
flex-direction: row;
61+
align-items: stretch;
62+
justify-content: space-between;
63+
height: 200px;
64+
}
65+
66+
.col {
67+
padding: 1em;
68+
}
69+
70+
.btn-custom {
71+
background-color: white;
72+
color: #007bff;
73+
border-color: #007bff;
74+
}
75+
76+
.btn-custom:hover {
77+
color: #fff;
78+
background-color: #0062cc;
79+
border-color: #005cbf;
80+
}
81+
82+
::-webkit-scrollbar {
83+
width: 8px;
84+
height: 8px;
85+
}
86+
87+
::-webkit-scrollbar-button {
88+
width: 0px;
89+
height: 0px;
90+
}
91+
92+
::-webkit-scrollbar-thumb {
93+
background: #e1e1e1;
94+
border: 0px none #ffffff;
95+
border-radius: 0px;
96+
}
97+
98+
::-webkit-scrollbar-thumb:hover {
99+
background: #ffffff;
100+
}
101+
102+
::-webkit-scrollbar-thumb:active {
103+
background: #ffffff;
104+
}
105+
106+
::-webkit-scrollbar-track {
107+
background: #868686;
108+
border: 0px none #ffffff;
109+
border-radius: 0px;
110+
}
111+
112+
::-webkit-scrollbar-track:hover {
113+
background: #868686;
114+
}
115+
116+
::-webkit-scrollbar-track:active {
117+
background: #727272;
118+
}
119+
120+
::-webkit-scrollbar-corner {
121+
background: transparent;
122+
}
123+
124+
#backBtn {
125+
position: absolute;
126+
z-index: 99;
127+
border: none;
128+
outline: none;
129+
background-color: #fbfbfb;
130+
color: black;
131+
padding: 10px;
132+
border-radius: 5px;
133+
font-size: 18px;
134+
top: 10px;
135+
left: 10px;
136+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { Component, OnInit, OnDestroy, AfterViewInit, Renderer2, ElementRef } from '@angular/core';
2+
import { ActivatedRoute } from '@angular/router';
3+
import { SocketService } from 'src/app/_services/socket.service';
4+
import { ErrorReport } from 'src/app/_models/ErrorReport';
5+
import { NavbarVisibilityService } from 'src/app/_services/navbar-visibility.service';
6+
import { LocationBackService } from 'src/app/_services/locationBack.service';
7+
8+
@Component({
9+
selector: 'app-error-report',
10+
templateUrl: './error-report.component.html',
11+
styleUrls: ['./error-report.component.scss']
12+
})
13+
export class ErrorReportComponent implements OnInit, OnDestroy, AfterViewInit {
14+
public currentReportId: string = "blank";
15+
public currentReport: ErrorReport = {} as ErrorReport;
16+
public loading = true;
17+
public validReport = false;
18+
public bugReportUrl = "";
19+
20+
constructor(
21+
public route: ActivatedRoute,
22+
public socketService: SocketService,
23+
public navbarVisibilityService: NavbarVisibilityService,
24+
public locationBackService: LocationBackService,
25+
private renderer: Renderer2,
26+
private el: ElementRef
27+
) {
28+
navbarVisibilityService.hideNavbar();
29+
this.route.params.subscribe((params) => {
30+
if (params.errorReportId) {
31+
this.currentReportId = params.errorReportId;
32+
}
33+
});
34+
}
35+
36+
ngAfterViewInit() {
37+
this.renderer.setStyle(
38+
this.el.nativeElement.ownerDocument.body,
39+
'background',
40+
'#3973aa'
41+
);
42+
}
43+
44+
ngOnInit() {
45+
this.socketService.getErrorReportById(this.currentReportId)
46+
.then((errorReport) => {
47+
this.currentReport = errorReport as ErrorReport;
48+
this.loading = false;
49+
this.validReport = true;
50+
let bugTitle = "[Bug] "+this.currentReport.stacktrace.split("\n")[0];
51+
this.bugReportUrl = `https://github.com/josephdadams/TallyArbiter/issues/new?labels=bug&template=bug.yaml&title=${encodeURIComponent(bugTitle)}&version=${this.socketService.version}&config=${encodeURIComponent(JSON.stringify(this.currentReport.config, null, 2))}&logs=${encodeURIComponent(this.currentReport.logs)}&stacktrace=${encodeURIComponent(this.currentReport.stacktrace)}`;
52+
console.log("Error report found:");
53+
console.log(errorReport);
54+
})
55+
.catch((response) => {
56+
this.loading = false;
57+
console.log("Error report not found");
58+
});
59+
}
60+
61+
ngOnDestroy() {
62+
this.renderer.removeStyle(
63+
this.el.nativeElement.ownerDocument.body,
64+
'background'
65+
);
66+
this.navbarVisibilityService.showNavbar();
67+
}
68+
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<div class="d-flex justify-content-center mt-5 pt-5" *ngIf="!socketService.errorReports">
2+
<div class="spinner spinner-border"></div>
3+
</div>
4+
<div *ngIf="socketService.errorReports">
5+
<div class="container mt-5">
6+
<div class="form-group" *ngIf="socketService.errorReports.length > 0">
7+
<select class='form-control col-xs-6 col-md-3' (change)="selectErrorReport($event)">
8+
<option disabled selected>-- Select an error report --</option>
9+
<option [value]="errorReport.id" *ngFor="let errorReport of socketService.errorReports">{{errorReport.datetime}}</option>
10+
</select>
11+
</div>
12+
</div>
13+
<h2 class="lead mt-5" *ngIf="socketService.errorReports.length == 0">Hurray! No error report detected.</h2>
14+
</div>

Diff for: UI/src/app/_components/error-reports-list/error-reports-list.component.scss

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
2+
import { Router } from '@angular/router';
3+
import { SocketService } from 'src/app/_services/socket.service';
4+
5+
@Component({
6+
selector: 'app-error-reports-list',
7+
templateUrl: './error-reports-list.component.html',
8+
styleUrls: ['./error-reports-list.component.scss']
9+
})
10+
export class ErrorReportsListComponent implements OnInit {
11+
constructor(
12+
private router: Router,
13+
public socketService: SocketService,
14+
) {
15+
console.log(this.socketService.errorReports);
16+
17+
}
18+
19+
public selectErrorReport(id: any) {
20+
this.router.navigate(["/", "errors", id.target.value]);
21+
}
22+
23+
ngOnInit(): void {
24+
}
25+
26+
}

Diff for: UI/src/app/_components/login/login.component.ts

+35-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
2-
import { Router } from '@angular/router';
2+
import { ActivatedRoute, Router } from '@angular/router';
33
import { AuthService, LoginResponse } from 'src/app/_services/auth.service';
44

55
@Component({
@@ -13,19 +13,50 @@ export class LoginComponent {
1313
public username = "";
1414
public password = "";
1515
private type!: "producer" | "settings";
16+
private redirectParam = "";
17+
private extraParam = "";
1618
@ViewChild("inputPassword") public inputPassword!: ElementRef;
1719

18-
constructor(private router: Router, private authService: AuthService) {
20+
constructor(
21+
public route: ActivatedRoute,
22+
private router: Router,
23+
private authService: AuthService
24+
) {
25+
this.route.params.subscribe((params) => {
26+
if (params.redirect) {
27+
this.redirectParam = params.redirect;
28+
}
29+
if (params.extraParam) {
30+
this.extraParam = params.extraParam;
31+
}
32+
});
33+
console.log(this.redirectParam);
34+
console.log(this.extraParam);
35+
switch (this.redirectParam) {
36+
case "producer":
37+
this.type = "producer";
38+
break;
39+
40+
case "errors":
41+
case "settings":
42+
this.type = "settings";
43+
break;
44+
45+
default:
46+
this.router.navigate(["/home"]);
47+
break;
48+
}
1949
}
2050

2151
login(): void {
2252
this.loading = true;
23-
this.type = this.router.url.endsWith("producer") ? "producer" : "settings";
2453
this.authService.login(this.type, this.username, this.password).then((response: LoginResponse) => {
2554
this.loginResponse = response;
2655
this.loading = false;
2756
if (response.loginOk === true) {
28-
this.router.navigate([this.type]);
57+
let navigateParams = [this.redirectParam];
58+
if(this.extraParam !== "") navigateParams.push(this.extraParam);
59+
this.router.navigate(navigateParams);
2960
}
3061
});
3162
}

Diff for: UI/src/app/_components/settings/settings.component.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, ElementRef, ViewChild } from '@angular/core';
2+
import { Router } from '@angular/router';
23
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
34
import { Confirmable } from 'src/app/_decorators/confirmable.decorator';
45
import { CloudClient } from 'src/app/_models/CloudClient';
@@ -66,14 +67,34 @@ export class SettingsComponent {
6667

6768
public newCloudKey = "";
6869

69-
constructor(private modalService: NgbModal, public socketService: SocketService) {
70+
constructor(private modalService: NgbModal, public socketService: SocketService, private router: Router) {
7071
this.socketService.joinAdmins();
7172
this.socketService.closeModals.subscribe(() => this.modalService.dismissAll());
7273
this.socketService.scrollTallyDataSubject.subscribe(() => this.scrollToBottom(this.tallyDataContainer));
7374
this.socketService.newLogsSubject.subscribe(() => {
7475
this.filterLogs();
7576
this.scrollToBottom(this.logsContainer);
7677
});
78+
this.socketService.socket.on('server_error', (id: string) => {
79+
this.show_error(id);
80+
});
81+
this.socketService.socket.on('unreaded_error_reports', (list) => {
82+
console.log(list);
83+
if(list.length > 0) {
84+
this.show_errors_list();
85+
}
86+
});
87+
this.socketService.socket.emit('get_unreaded_error_reports');
88+
}
89+
90+
@Confirmable("There was an unexpected error. Do you want to view the bug report?", false)
91+
public show_error(id: string) {
92+
this.router.navigate(['/errors', id]);
93+
}
94+
95+
@Confirmable(`There are error reports that you haven't read yet. Do you want to open the list of errors now?`, false)
96+
public show_errors_list() {
97+
this.router.navigate(['/errors']);
7798
}
7899

79100
private portInUse(portToCheck: number, sourceId: string) {

0 commit comments

Comments
 (0)