Skip to content

Commit

Permalink
Fixed problem related to display of external tool status.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils Gehlenborg committed Jan 13, 2015
1 parent dfaa5f5 commit 71ab4b5
Showing 1 changed file with 101 additions and 116 deletions.
217 changes: 101 additions & 116 deletions refinery/ui/src/js/external_tool_status.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,5 @@
angular.module('refineryExternalToolStatus', [])


.controller('ExternalToolStatusController', function(externalToolStatusService, $scope, $timeout, $log) {

(function tick() {
$scope.isSolrUp = externalToolStatusService.isSolrUp();
$scope.isCeleryUp = externalToolStatusService.isCeleryUp();
$scope.isGalaxyUp = externalToolStatusService.isGalaxyUp();

if (externalToolStatusService.getSystemStatus() === "OK") {
$scope.systemStatusOk = true;
$scope.systemStatusWarning = false;
$scope.systemStatusError = false;
$scope.systemStatusUnknown = false;
}
else if (externalToolStatusService.getSystemStatus() === "WARNING") {
$scope.systemStatusOk = false;
$scope.systemStatusWarning = true;
$scope.systemStatusError = false;
$scope.systemStatusUnknown = false;
}
else if (externalToolStatusService.getSystemStatus() === "ERROR") {
$scope.systemStatusOk = false;
$scope.systemStatusWarning = false;
$scope.systemStatusError = true;
$scope.systemStatusUnknown = false;
}
else if (externalToolStatusService.getSystemStatus() === "UNKNOWN") {
$scope.systemStatusOk = false;
$scope.systemStatusWarning = false;
$scope.systemStatusError = false;
$scope.systemStatusUnknown = true;
}

$timeout(tick, 1000);
})();
})

.directive('externaltoolstatus', function(externalToolStatusService, $log) {
return {
templateUrl: '/static/partials/external_tool_status.tpls.html',
restrict: 'A',
};
})

.factory("externalToolStatusFactory", function($resource) {
'use strict';

Expand All @@ -54,7 +10,7 @@ angular.module('refineryExternalToolStatus', [])
);
})

.service("externalToolStatusService", function(externalToolStatusFactory, $log, $timeout) {
.controller('ExternalToolStatusController', function(externalToolStatusFactory, $scope, $timeout, $log) {

var tools;

Expand All @@ -66,90 +22,119 @@ angular.module('refineryExternalToolStatus', [])
tools = undefined;
$log.error( "Error accessing external tool status API." );
});
$timeout(tick, 1000);
})();

function processResponse(objects) {
for ( var i = 0; i < objects.length; ++i ) {
tools[objects[i].name] = {};
}

for ( i = 0; i < objects.length; ++i ) {
tools[objects[i].name][objects[i].unique_instance_identifier] = objects[i].status;
}
}
function processResponse(objects) {
for ( var i = 0; i < objects.length; ++i ) {
tools[objects[i].name] = {};
}

var isSolrUp = function() {
if ( !tools ) {
return undefined;
}
if ( !tools.SOLR ) {
return false;
}
return tools.SOLR[""] === "SUCCESS";
};

var isCeleryUp = function() {
if ( !tools ) {
return undefined;
for ( i = 0; i < objects.length; ++i ) {
tools[objects[i].name][objects[i].unique_instance_identifier] = objects[i].status;
}
}
if ( !tools.CELERY ) {
return false;
}
return tools.CELERY[""] === "SUCCESS";
};

var isGalaxyUp = function() {
if ( !tools ) {
return undefined;
}
if ( !tools.GALAXY ) {
return false;
}
var isSolrUp = function() {
if ( !tools ) {
return undefined;
}
if ( !tools.SOLR ) {
return false;
}
return tools.SOLR[null] === "SUCCESS";
};

var isCeleryUp = function() {
if ( !tools ) {
return undefined;
}
if ( !tools.CELERY ) {
return false;
}
return tools.CELERY[null] === "SUCCESS";
};

var isGalaxyUp = function() {
if ( !tools ) {
return undefined;
}
if ( !tools.GALAXY ) {
return false;
}

for (var key in tools.GALAXY) {
if (tools.GALAXY.hasOwnProperty(key)) {
if (tools.GALAXY[key] !== "SUCCESS") {
return false;
}
}
}

return true;
};

for (var key in tools.GALAXY) {
if (tools.GALAXY.hasOwnProperty(key)) {
if (tools.GALAXY[key] !== "SUCCESS") {
var isGalaxyInstanceUp = function(uniqueInstanceId) {
if ( !tools ) {
return undefined;
}
if ( !tools.GALAXY ) {
return false;
}
}
}
return tools.GALAXY[uniqueInstanceId] === "SUCCESS";
};

return true;
};
var getSystemStatus = function() {
if (!tools) {
return "UNKNOWN";
}

var isGalaxyInstanceUp = function(uniqueInstanceId) {
if ( !tools ) {
return undefined;
}
if ( !tools.GALAXY ) {
return false;
}
return tools.GALAXY[uniqueInstanceId] === "SUCCESS";
};
if (!isCeleryUp()) {
return "ERROR";
}

var getSystemStatus = function() {
if (!tools) {
return "UNKNOWN";
}
if (!isSolrUp() || !isGalaxyUp()) {
return "WARNING";
}

if (!isCeleryUp()) {
return "ERROR";
}
return "OK";
};

if (!isSolrUp() || !isGalaxyUp()) {
return "WARNING";
}
$scope.isSolrUp = isSolrUp();
$scope.isCeleryUp = isCeleryUp();
$scope.isGalaxyUp = isGalaxyUp();

if (getSystemStatus() === "OK") {
$scope.systemStatusOk = true;
$scope.systemStatusWarning = false;
$scope.systemStatusError = false;
$scope.systemStatusUnknown = false;
}
else if (getSystemStatus() === "WARNING") {
$scope.systemStatusOk = false;
$scope.systemStatusWarning = true;
$scope.systemStatusError = false;
$scope.systemStatusUnknown = false;
}
else if (getSystemStatus() === "ERROR") {
$scope.systemStatusOk = false;
$scope.systemStatusWarning = false;
$scope.systemStatusError = true;
$scope.systemStatusUnknown = false;
}
else if (getSystemStatus() === "UNKNOWN") {
$scope.systemStatusOk = false;
$scope.systemStatusWarning = false;
$scope.systemStatusError = false;
$scope.systemStatusUnknown = true;
}

return "OK";
};
$timeout(tick, 1000);
})();
})

return ({
getSystemStatus: getSystemStatus,
isSolrUp: isSolrUp,
isCeleryUp: isCeleryUp,
isGalaxyUp: isGalaxyUp,
isGalaxyInstanceUp: isGalaxyInstanceUp
});
.directive('externaltoolstatus', function($log) {
return {
templateUrl: '/static/partials/external_tool_status.tpls.html',
restrict: 'A',
};
});

0 comments on commit 71ab4b5

Please sign in to comment.