Bug 1088204 - Warn the user when server revision has changed (#1901) r=wlach

This commit is contained in:
KWierso 2016-12-01 12:03:09 -08:00 коммит произвёл GitHub
Родитель 35848a065f
Коммит b6f411d8cd
5 изменённых файлов: 83 добавлений и 6 удалений

Просмотреть файл

@ -78,3 +78,12 @@
.field-filter-placeholder a {
cursor: pointer;
}
/*
* Update notification panel
*/
.update-alert-panel {
border-radius: 0px;
margin-bottom: 0px;
}

Просмотреть файл

@ -39,6 +39,7 @@
src="'partials/main/thGlobalTopNavPanel.html'">
</ng-include>
</div>
<ng-include src="'partials/main/thTreeherderUpdateBar.html'"></ng-include>
<div id="th-global-content" class="th-global-content"
ng-click="clearJobOnClick($event)">
<span class="th-view-content" ng-cloak>

Просмотреть файл

@ -1,27 +1,81 @@
"use strict";
treeherderApp.controller('MainCtrl', [
'$scope', '$rootScope', '$routeParams', '$location', '$timeout',
'$scope', '$rootScope', '$routeParams', '$location', '$timeout', '$q',
'ThLog', 'ThRepositoryModel', 'thPinboard', 'thTabs', '$document',
'thClassificationTypes', 'thEvents', '$interval', '$window',
'thClassificationTypes', 'thEvents', '$interval', '$window', 'thNotify',
'ThExclusionProfileModel', 'thJobFilters', 'ThResultSetStore',
'thDefaultRepo', 'thJobNavSelectors', 'thTitleSuffixLimit',
'thDefaultRepo', 'thJobNavSelectors', 'thTitleSuffixLimit', '$http',
function MainController(
$scope, $rootScope, $routeParams, $location, $timeout,
$scope, $rootScope, $routeParams, $location, $timeout, $q,
ThLog, ThRepositoryModel, thPinboard, thTabs, $document,
thClassificationTypes, thEvents, $interval, $window,
thClassificationTypes, thEvents, $interval, $window, thNotify,
ThExclusionProfileModel, thJobFilters, ThResultSetStore,
thDefaultRepo, thJobNavSelectors, thTitleSuffixLimit) {
thDefaultRepo, thJobNavSelectors, thTitleSuffixLimit, $http) {
var $log = new ThLog("MainCtrl");
// Query String param for selected job
var QS_SELECTED_JOB = "selectedJob";
/*
* revisionPollInterval: How often we check revision.txt for changes
* revisionPollDelayedInterval: Aggressively notify about revision changes after this delay
*/
var revisionPollInterval = 1000 * 60 * 5;
var revisionPollDelayedInterval = 1000 * 60 * 60;
$rootScope.serverChanged = false;
$rootScope.serverChangedDelayed = false;
// Ensure user is available on initial page load
$rootScope.user = {};
thClassificationTypes.load();
var checkServerRevision = function() {
return $q(function(resolve, reject) {
$http({
method: 'GET',
url: '/revision.txt'
}).then(function successCallback(response) {
resolve(response.data);
}, function errorCallback(response) {
reject("Error loading revision.txt: " + response.statusText);
});
});
};
$scope.updateButtonClick = function() {
if (window.confirm("Reload the page to pick up Treeherder updates?")) {
window.location.reload(true);
}
};
// Only set up the revision polling interval if revision.txt exists on page load
checkServerRevision().then(function(revision) {
$rootScope.serverRev = revision;
$interval(function() {
checkServerRevision().then(function(revision) {
if ($rootScope.serverChanged) {
if (Date.now() - $rootScope.serverChangedTimestamp > revisionPollDelayedInterval) {
$rootScope.serverChangedDelayed = true;
}
}
// This request returns the treeherder git revision running on the server
// If this differs from the version chosen during the UI page load, show a warning
// Update $rootScope.serverRev so this warning is only shown once per server-side change
if ($rootScope.serverRev && $rootScope.serverRev !== revision) {
$rootScope.serverRev = revision;
if ($rootScope.serverChanged === false) {
$rootScope.serverChanged = true;
$rootScope.serverChangedTimestamp = Date.now();
}
}
});
}, revisionPollInterval);
}, function(reason) {
$log.log(reason);
});
$rootScope.getWindowTitle = function() {
var ufc = $scope.getAllUnclassifiedFailureCount($rootScope.repoName);
var params = $location.search();

Просмотреть файл

@ -0,0 +1,6 @@
<!-- Show this when the Treeherder server has updated -->
<div class="alert alert-info update-alert-panel" ng-show="serverChangedDelayed" ng-cloak>
<i class="fa fa-info-circle" aria-hidden="true"></i>
Treeherder has updated. To pick up the changes, you can reload the page
<button ng-click="updateButtonClick()" class="btn btn-xs btn-danger">Reload</button>
</div>

Просмотреть файл

@ -4,6 +4,13 @@
<span>
<form role="search" class="form-inline">
<span class="btn btn-sm btn-view-nav nav-menu-btn"
ng-show="serverChanged" ng-cloak
ng-click="updateButtonClick()"
id="revisionChangedLabel"
title="New version of Treeherder has been deployed. Reload to pick up changes.">
<span class="fa fa-exclamation-circle" />&nbsp;Treeherder update available
</span>
<!--Unclassified Failures Button-->
<span class="btn btn-sm"
title="Loaded failures / Toggle filtering for unclassified failures"