Chromium Code Reviews| Index: go/src/infra/appengine/sheriff-o-matic/elements/som-app.html |
| diff --git a/go/src/infra/appengine/sheriff-o-matic/elements/som-app.html b/go/src/infra/appengine/sheriff-o-matic/elements/som-app.html |
| index d55f5ffe069032717056bef86921556891943844..09ab5cbae70a3997d8210b38956b5fc95917c2dc 100644 |
| --- a/go/src/infra/appengine/sheriff-o-matic/elements/som-app.html |
| +++ b/go/src/infra/appengine/sheriff-o-matic/elements/som-app.html |
| @@ -57,6 +57,10 @@ |
| #bugDialog, #snoozeDialog { |
| width: 300px; |
| } |
| + #fetchAlertsError { |
| + color: #ff0000; |
|
seanmccullough1
2016/08/02 00:44:30
Is #f00 equivalent?
|
| + margin: 1em; |
| + } |
| #noAlerts { |
| text-align: center; |
| font-size: 2.5em; |
| @@ -157,6 +161,7 @@ |
| <som-bug-queue id="bugQueue" bug-queue-label="[[_bugQueueLabel]]"></som-bug-queue> |
| <div id="alertsListInner"> |
| <h2>Failure Alerts (<a href="/help-som">Help?</a>)</h2> |
| + <div id="fetchAlertsError" hidden=[[!_fetchAlertsError]]>[[_fetchAlertsError]]</div> |
| <template is="dom-if" if="[[!_hideJulie]]"> |
| <div id="noAlerts"> |
| No alerts! |
| @@ -291,6 +296,7 @@ |
| type: Boolean, |
| value: false, |
| }, |
| + _fetchAlertsError: String, |
| _fetchingAlerts: { |
| type: Boolean, |
| computed: '_computeFetchingAlerts(_activeRequests)', |
| @@ -301,7 +307,7 @@ |
| }, |
| _hideJulie: { |
| type: Boolean, |
| - computed: '_computeHideJulie(_alerts, _fetchedAlerts, _fetchingAlerts, _tree)', |
| + computed: '_computeHideJulie(_alerts, _fetchedAlerts, _fetchingAlerts, _fetchAlertsError, _tree)', |
| value: function() { return true; }, |
| }, |
| _hideWebkitNotice: { |
| @@ -428,7 +434,7 @@ |
| if (pathParts.length == 2) { |
| if (pathParts[1] in this._staticPages) { |
| if (pathParts[1] === 'calendar') { |
| - // Hide rotation calendar until visited because it's really big. |
| + // Hide rotation calendar until visited because it's really big. |
| this._showRotationCalendar = true; |
| } |
| return this._staticPages[pathParts[1]].pageId; |
| @@ -492,18 +498,26 @@ |
| _alertsGroupsChanged: function(alertsGroups) { |
| if (alertsGroups.length > 0) { |
| + this._fetchAlertsError = ''; |
| this._fetchedAlerts = false; |
| this._activeRequests += alertsGroups.length; |
| - // TODO: handle webpage offline throwing an exception |
| alertsGroups.forEach((group) => { |
| let foo = fetch('/api/v1/alerts/' + group, {credentials: 'include'}).then((response) => { |
| - // TODO: handle alerts not found |
| this._activeRequests -= 1; |
| + if (response.status == 404) { |
| + this._fetchAlertsError = 'Server responded with 404: ' + group + ' not found. '; |
| + return false; |
| + } |
| return response.json(); |
| + }, (error) => { |
| + this._activeRequests -= 1; |
| + this._fetchAlertsError = 'Could not connect to the server. ' + error; |
| }).then((json) => { |
| - this.set(['_alertsData', this._alertGroupVarName(group)], json.alerts); |
| - this.set(['_alertsTimes', this._alertGroupVarName(group)], json.timestamp); |
| + if (json) { |
| + this.set(['_alertsData', this._alertGroupVarName(group)], json.alerts); |
| + this.set(['_alertsTimes', this._alertGroupVarName(group)], json.timestamp); |
| + } |
| }); |
| }); |
| } |
| @@ -560,8 +574,8 @@ |
| }, |
| - _computeHideJulie: function(alerts, fetchedAlerts, fetchingAlerts, tree) { |
| - if (fetchingAlerts || !fetchedAlerts || !alerts || tree === '') { |
| + _computeHideJulie: function(alerts, fetchedAlerts, fetchingAlerts, fetchAlertsError, tree) { |
| + if (fetchingAlerts || !fetchedAlerts || !alerts || fetchAlertsError !== '' || tree === '') { |
| return true; |
| } |
| return alerts.length > 0; |