Navigation Menu

Skip to content

Commit

Permalink
attempted fix for #479 so that we include the error reporting status …
Browse files Browse the repository at this point in the history
…inside the same ajaxError handler as used for logging out & redirection
  • Loading branch information
jstrachan committed Aug 14, 2013
1 parent f1165c3 commit 225d191
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
6 changes: 3 additions & 3 deletions hawtio-web/src/main/webapp/app/core/js/app.ts
@@ -1,6 +1,6 @@
module Core {

export function AppController($scope, $location, workspace, $document, pageTitle:Core.PageTitle, localStorage, userDetails, lastLocation, jolokiaUrl) {
export function AppController($scope, $location, workspace, jolokiaStatus, $document, pageTitle:Core.PageTitle, localStorage, userDetails, lastLocation, jolokiaUrl) {

if (userDetails.username === null) {
// sigh, hack
Expand All @@ -15,8 +15,8 @@ module Core {
$scope.connectionFailed = false;
$scope.connectFailure = {};

$scope.$watch('workspace.connectFailure', function () {
var failure = workspace.connectFailure;
$scope.$watch('jolokiaStatus.xhr', function () {
var failure = jolokiaStatus.xhr;
$scope.connectionFailed = failure ? true : false;
$scope.connectFailure.summaryMessage = null;
if ($scope.connectionFailed) {
Expand Down
18 changes: 13 additions & 5 deletions hawtio-web/src/main/webapp/app/core/js/corePlugin.ts
Expand Up @@ -124,6 +124,12 @@ angular.module('hawtioCore', ['bootstrap', 'ngResource', 'ui', 'ui.bootstrap.dia
return jolokiaUrl;
}).

factory('jolokiaStatus', function() {
return {
xhr: null
};
}).

factory('userDetails', function(jolokiaUrl, localStorage) {
var answer = angular.fromJson(localStorage[jolokiaUrl]);
if (!angular.isDefined(answer)) {
Expand All @@ -137,7 +143,7 @@ angular.module('hawtioCore', ['bootstrap', 'ngResource', 'ui', 'ui.bootstrap.dia

}).

factory('jolokia',($location:ng.ILocationService, localStorage, $rootScope, userDetails) => {
factory('jolokia',($location:ng.ILocationService, localStorage, jolokiaStatus, $rootScope, userDetails) => {
// TODO - Maybe have separate URLs or even jolokia instances for loading plugins vs. application stuff
// var jolokiaUrl = $location.search()['url'] || url("/jolokia");
console.log("Jolokia URL is " + jolokiaUrl);
Expand Down Expand Up @@ -185,9 +191,11 @@ angular.module('hawtioCore', ['bootstrap', 'ngResource', 'ui', 'ui.bootstrap.dia
if (xhr.status === 401 || xhr.status === 403) {
userDetails.username = null;
userDetails.password = null;
Core.$apply($rootScope);
} else {
jolokiaStatus.xhr = xhr;
}
}
Core.$apply($rootScope);
};

var jolokia = new Jolokia(jolokiaParams);
localStorage['url'] = jolokiaUrl;
Expand Down Expand Up @@ -224,8 +232,8 @@ angular.module('hawtioCore', ['bootstrap', 'ngResource', 'ui', 'ui.bootstrap.dia
var jquery:any = $;
return jquery.xml2json;
}).
factory('workspace',($location:ng.ILocationService, jmxTreeLazyLoadRegistry, $compile:ng.ICompileService, $templateCache:ng.ITemplateCacheService, localStorage:WindowLocalStorage, jolokia, $rootScope) => {
var answer = new Workspace(jolokia, jmxTreeLazyLoadRegistry, $location, $compile, $templateCache, localStorage, $rootScope);
factory('workspace',($location:ng.ILocationService, jmxTreeLazyLoadRegistry, $compile:ng.ICompileService, $templateCache:ng.ITemplateCacheService, localStorage:WindowLocalStorage, jolokia, jolokiaStatus, $rootScope) => {
var answer = new Workspace(jolokia, jolokiaStatus, jmxTreeLazyLoadRegistry, $location, $compile, $templateCache, localStorage, $rootScope);
answer.loadTree();
return answer;
}).
Expand Down
15 changes: 5 additions & 10 deletions hawtio-web/src/main/webapp/app/core/js/workspace.ts
Expand Up @@ -24,9 +24,9 @@ class Workspace {
public treeWatchRegisterHandle = null;
public treeWatcherCounter = null;
public treeElement = null;
public connectFailure = null;

constructor(public jolokia,
public jolokiaStatus,
public jmxTreeLazyLoadRegistry,
public $location,
public $compile:ng.ICompileService,
Expand All @@ -40,7 +40,8 @@ class Workspace {
* Creates a shallow copy child workspace with its own selection and location
*/
public createChildWorkspace(location): Workspace {
var child = new Workspace(this.jolokia, this.jmxTreeLazyLoadRegistry, this.$location, this.$compile, this.$templateCache, this.localStorage, this.$rootScope);
var child = new Workspace(this.jolokia, this.jolokiaStatus, this.jmxTreeLazyLoadRegistry,
this.$location, this.$compile, this.$templateCache, this.localStorage, this.$rootScope);
// lets copy across all the properties just in case
angular.forEach(this, (value, key) => child[key] = value);
child.$location = location;
Expand All @@ -58,18 +59,12 @@ class Workspace {
public loadTree() {
// Make an initial blocking call to ensure the JMX tree is populated while the
// app is initializing...
var initialLoadError = (response) => {
console.log("Initial load failed: " + response);
this.connectFailure = response;
Core.$apply(this.$rootScope);
};

//var flags = {error: initialLoadError, ajaxError: initialLoadError, maxDepth: 2};
var flags = {maxDepth: 2};
var flags = {ignoreErrors: true, maxDepth: 2};
var data = this.jolokia.list(null, onSuccess(null, flags));

if (data) {
this.connectFailure = null;
this.jolokiaStatus.xhr = null;
}
this.populateTree({
value: data
Expand Down

0 comments on commit 225d191

Please sign in to comment.