Skip to content

Commit

Permalink
Fix #781, a little timing gremlin and add some JSDoc for the source p…
Browse files Browse the repository at this point in the history
…lugin too
  • Loading branch information
gashcrumb committed Dec 2, 2013
1 parent 1f75fed commit d14a1b1
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 13 deletions.
2 changes: 1 addition & 1 deletion hawtio-web/src/main/webapp/app/jmx/js/jmxHelpers.ts
Expand Up @@ -7,7 +7,7 @@ module Jmx {

var attributesToolBars = {};

export var lazyLoaders = null;
export var lazyLoaders = {};

export function findLazyLoadingFunction(workspace, folder) {
var factories = workspace.jmxTreeLazyLoadRegistry[folder.domain];
Expand Down
18 changes: 12 additions & 6 deletions hawtio-web/src/main/webapp/app/source/js/index.ts
@@ -1,11 +1,16 @@

/**
* @module Source
*/
module Source {

export function IndexController($scope, $location, $routeParams, workspace:Workspace, jolokia) {

$scope.pageId = Wiki.pageId($routeParams, $location);
$scope.mavenCoords = $routeParams["mavenCoords"];
var fileName = $scope.pageId;
if (fileName === '/') {
fileName = undefined;
}

$scope.loadingMessage = "Loading source code from artifacts <b>" + $scope.mavenCoords + "</b>";

Expand All @@ -20,19 +25,16 @@ module Source {
};

$scope.$watch('workspace.tree', function (newValue, oldValue) {
if (newValue === oldValue) {
return;
}
if (!$scope.git && Git.getGitMBean(workspace)) {
// lets do this asynchronously to avoid Error: $digest already in progress
//console.log("Reloading the view as we now seem to have a git mbean!");
setTimeout(updateView, 50);
setTimeout(maybeUpdateView, 50);
}
});

$scope.$on("$routeChangeSuccess", function (event, current, previous) {
// lets do this asynchronously to avoid Error: $digest already in progress
setTimeout(updateView, 50);
setTimeout(maybeUpdateView, 50);
});

function filterFileNames() {
Expand Down Expand Up @@ -90,6 +92,7 @@ module Source {
return;
}
var mbean = Source.getInsightMBean(workspace);
log.debug("In update view, mbean: ", mbean);
if (mbean) {
jolokia.execute(mbean, "getSource", $scope.mavenCoords, null, "/", {
success: viewContents,
Expand All @@ -103,5 +106,8 @@ module Source {
}
}

var maybeUpdateView = Core.throttled(updateView, 1000);
setTimeout(maybeUpdateView, 50);

}
}
5 changes: 4 additions & 1 deletion hawtio-web/src/main/webapp/app/source/js/javadoc.ts
@@ -1,3 +1,6 @@
/**
* @module Source
*/
module Source {

export function JavaDocController($scope, $location, $routeParams, workspace:Workspace, fileExtensionTypeRegistry, jolokia) {
Expand Down Expand Up @@ -45,4 +48,4 @@ module Source {
}
}
}
}
}
14 changes: 9 additions & 5 deletions hawtio-web/src/main/webapp/app/source/js/source.ts
@@ -1,3 +1,6 @@
/**
* @module Source
*/

module Source {

Expand Down Expand Up @@ -87,19 +90,16 @@ module Source {
};

$scope.$watch('workspace.tree', function (oldValue, newValue) {
if (newValue === oldValue) {
return;
}
if (!$scope.git && Git.getGitMBean(workspace)) {
// lets do this asynchronously to avoid Error: $digest already in progress
//console.log("Reloading the view as we now seem to have a git mbean!");
setTimeout(updateView, 50);
setTimeout(maybeUpdateView, 50);
}
});

$scope.$on("$routeChangeSuccess", function (event, current, previous) {
// lets do this asynchronously to avoid Error: $digest already in progress
setTimeout(updateView, 50);
setTimeout(maybeUpdateView, 50);
});

function viewContents(response) {
Expand All @@ -122,5 +122,9 @@ module Source {
});
}
}

var maybeUpdateView = Core.throttled(updateView, 1000);
setTimeout(maybeUpdateView, 50);

}
}
16 changes: 16 additions & 0 deletions hawtio-web/src/main/webapp/app/source/js/sourceHelpers.ts
@@ -1,14 +1,30 @@
/**
* @module Source
*/
module Source {

export var log:Logging.Logger = Logger.get("Source");

/**
* @method getInsightMBean
* @for Source
* @param {Core.Workspace} workspace
* @returns {*}
*/
export function getInsightMBean(workspace) {
var mavenStuff = workspace.mbeanTypesToDomain["LogQuery"] || {};
var insight = mavenStuff["org.fusesource.insight"] || {};
var mbean = insight.objectName;
return mbean;
}

/**
* @method createBreadcrumbLinks
* @for Source
* @param {String} mavenCoords
* @param {pathName} pathName
* @returns {Array}
*/
export function createBreadcrumbLinks(mavenCoords: string, pathName: string) {
var linkPrefix = "#/source/index/" + mavenCoords;
var answer = [{href: linkPrefix, name: "root"}];
Expand Down
4 changes: 4 additions & 0 deletions hawtio-web/src/main/webapp/app/source/js/sourcePlugin.ts
@@ -1,3 +1,7 @@
/**
* @module Source
* @main Source
*/
module Source {
var pluginName = 'source';
angular.module(pluginName, ['bootstrap', 'ngResource', 'hawtioCore', 'wiki']).
Expand Down

0 comments on commit d14a1b1

Please sign in to comment.