diff --git a/app/scripts/controllers/workflowdagview.js b/app/scripts/controllers/workflowdagview.js index c6df08b..7875029 100644 --- a/app/scripts/controllers/workflowdagview.js +++ b/app/scripts/controllers/workflowdagview.js @@ -18,6 +18,7 @@ angular.module('dockstore.ui') var cy; $scope.successContent = []; $scope.missingTool = false; + $scope.notFound = false; $scope.getWorkflowVersions = function() { var sortedVersionObjs = $scope.workflowObj.workflowVersions; @@ -40,20 +41,22 @@ angular.module('dockstore.ui') }; $scope.nodesAndEdges = function(workflowId, workflowVersions) { - var workflowVersionId; - if (workflowVersions.length == 0) { - return null; - } - for (var i = 0; i < workflowVersions.length; i++) { - if (workflowVersions[i].name === $scope.selVersionName) { - if (workflowVersions[i].valid) { - workflowVersionId = workflowVersions[i].id; - break; - } else { - return null; + var workflowVersionId; + if (workflowVersions.length == 0) { + return null; + } + + for (var i = 0; i < workflowVersions.length; i++) { + if (workflowVersions[i].name === $scope.selVersionName) { + if (workflowVersions[i].valid) { + workflowVersionId = workflowVersions[i].id; + break; + } else { + return null; + } } } - } + return WorkflowService.getWorkflowDag(workflowId, workflowVersionId) .then( function(dagJson) { @@ -63,6 +66,16 @@ angular.module('dockstore.ui') function(response) { return $q.reject(response); }); + + }; + + $scope.checkVersion = function() { + $scope.successContent = []; + for(var i=0;i<$scope.workflowObj.workflowVersions.length;i++){ + if($scope.workflowObj.workflowVersions[i].valid){ + $scope.successContent.push($scope.workflowObj.workflowVersions[i].name); + } + } }; $scope.filterVersion = function(element) { @@ -79,13 +92,32 @@ angular.module('dockstore.ui') $scope.setDocument = function() { $scope.workflowVersions = $scope.getWorkflowVersions(); - $scope.selVersionName = $scope.workflowVersions[0]; + $scope.selVersionName = $scope.successContent[0]; }; $scope.refreshDocument = function() { $scope.dagJson = $scope.nodesAndEdges($scope.workflowObj.id, $scope.workflowObj.workflowVersions); + //$scope.dagJson is a promise returned by the web service from nodesAndEdges function if ($scope.dagJson !== null){ + $scope.dagJson.then( + function(s){ + if(s.nodes.length === 0 && s.edges.length === 0){ + //DAG has no nodes and edges even though file is valid + //some inputs needed from file are missing from Github repo + $scope.missingTool = true; + }else{ + //DAG has nodes and edges + $scope.missingTool = false; + } + $scope.notFound = false; + }, + function(e){ + console.log("dagJSON error"); + $scope.notFound = true; + $scope.missingTool = false; + } + ); cy = window.cy = cytoscape({ container: document.getElementById('cy'), @@ -134,6 +166,7 @@ angular.module('dockstore.ui') } } }); + } else { cy = window.cy = null; } diff --git a/app/scripts/controllers/workflowdetails.js b/app/scripts/controllers/workflowdetails.js index 93c6d2d..8616ed4 100644 --- a/app/scripts/controllers/workflowdetails.js +++ b/app/scripts/controllers/workflowdetails.js @@ -34,6 +34,7 @@ angular.module('dockstore.ui') }; $scope.openDAG = function() { + $scope.$broadcast('checkVersion'); $scope.$broadcast('refreshFiles'); }; diff --git a/app/scripts/directives/workflowdagview.js b/app/scripts/directives/workflowdagview.js index 6689409..c55ca57 100644 --- a/app/scripts/directives/workflowdagview.js +++ b/app/scripts/directives/workflowdagview.js @@ -17,7 +17,10 @@ angular.module('dockstore.ui') templateUrl: 'templates/workflowdagview.html', link: function postLink(scope, element, attrs) { scope.$watch('workflowObj.path', function(newValue, oldValue) { - if (newValue) scope.setDocument(); + if (newValue) { + scope.checkVersion(); + scope.setDocument(); + } }); scope.$watchGroup( ['selVersionName', 'workflowObj.id'], @@ -28,6 +31,9 @@ angular.module('dockstore.ui') scope.setDocument(); scope.refreshDocument(); }); + scope.$on('checkVersion', function(event){ + scope.checkVersion(); + }); } }; diff --git a/app/templates/workflowdagview.html b/app/templates/workflowdagview.html index 0d218fd..f21ede3 100644 --- a/app/templates/workflowdagview.html +++ b/app/templates/workflowdagview.html @@ -5,21 +5,25 @@ Workflow Version: -