Fix flaky //scouting:scouting_test

The test occasionally fails because of the alerts that pop up when
navigating away from the page. I've failed to make protractor deal
with the alerts in a reliable way. So this patch turns them off.
There's a special hidden checkbox that the test checks. When it's
checked, the scouting application does not display alerts. It's hacky,
but it seems to work. Rather than failing ~10 out of 1000 times, the
test now fails 0 out of 1000 times.

Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I2e920771c1605464994d7877da2bbb62a2e69d1f
diff --git a/scouting/www/app.ts b/scouting/www/app.ts
index 79c1094..18f08d4 100644
--- a/scouting/www/app.ts
+++ b/scouting/www/app.ts
@@ -1,4 +1,4 @@
-import {Component} from '@angular/core';
+import {Component, ElementRef, ViewChild} from '@angular/core';
 
 type Tab = 'Entry'|'ImportMatchList';
 
@@ -10,12 +10,16 @@
 export class App {
   tab: Tab = 'Entry';
 
+  @ViewChild("block_alerts") block_alerts: ElementRef;
+
   constructor() {
     window.addEventListener('beforeunload', (e) => {
-      // Based on https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#example
-      // This combination ensures a dialog will be shown on most browsers.
-      e.preventDefault();
-      e.returnValue = '';
+      if (!this.block_alerts.nativeElement.checked) {
+        // Based on https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#example
+        // This combination ensures a dialog will be shown on most browsers.
+        e.preventDefault();
+        e.returnValue = '';
+      }
     });
   }