Skip to content
This repository has been archived by the owner on Apr 5, 2018. It is now read-only.

Commit

Permalink
Feature/default version selector (#91)
Browse files Browse the repository at this point in the history
* Autoselect default version if set for most tabs
* set workflow and tool version dropdowns based on default
* Other parts depend on the version set, so need to set them as well
  • Loading branch information
agduncan94 authored and denis-yuen committed Sep 14, 2016
1 parent 3ebee7d commit d493c4c
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 19 deletions.
35 changes: 27 additions & 8 deletions app/scripts/controllers/containerdetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,38 @@ angular.module('dockstore.ui')
$scope.validTags.push($scope.containerObj.tags[i]);
}
}
var isVersionValid = false;
var firstTag;
if($scope.validTags.length !==0){
$scope.toolTag = $scope.validTags[0].id;
$scope.toolTagName = $scope.validTags[0].name;
if ($scope.containerObj.defaultVersion === null) {
$scope.toolTag = $scope.validTags[0].id;
$scope.toolTagName = $scope.validTags[0].name;
firstTag = 0;
} else {
for (i = 0; i < $scope.validTags.length; i++) {
if ($scope.validTags[i].name === $scope.containerObj.defaultVersion) {
$scope.toolTag = $scope.validTags[i].id;
$scope.toolTagName = $scope.validTags[i].name;
firstTag = i;
isVersionValid = true;
break;
}
}
if (!isVersionValid) {
$scope.toolTag = $scope.validTags[0].id;
$scope.toolTagName = $scope.validTags[0].name;
firstTag = 0;
}
}
}
$scope.refreshDescLaunchWith(firstTag);
};

$scope.refreshDescLaunchWith = function() {
$scope.refreshDescLaunchWith = function(tagIndex) {
//get the descriptor type that is available for tool version
$scope.descAvailable = [];
for(var j=0;j<$scope.validTags[0].sourceFiles.length;j++){
var fileType = $scope.validTags[0].sourceFiles[j].type;
for(var j=0;j<$scope.validTags[tagIndex].sourceFiles.length;j++){
var fileType = $scope.validTags[tagIndex].sourceFiles[j].type;
if($scope.descAvailable.indexOf(fileType)){
if(fileType === 'DOCKSTORE_CWL' && $scope.descAvailable.indexOf('cwl') === -1){
$scope.descAvailable.push('cwl');
Expand All @@ -79,7 +100,7 @@ angular.module('dockstore.ui')
}
}
if($scope.descAvailable.length !==0){
$scope.desc = $scope.descAvailable[0];
$scope.desc = $scope.descAvailable[tagIndex];
}
};

Expand Down Expand Up @@ -611,14 +632,12 @@ angular.module('dockstore.ui')
.then(function() {
$scope.updateInfoURLs();
$scope.refreshTagLaunchWith();
$scope.refreshDescLaunchWith();
});
} else {
$scope.labelsEditMode = false;
$scope.resetContainerEditData($scope.containerObj);
$scope.updateInfoURLs();
$scope.refreshTagLaunchWith();
$scope.refreshDescLaunchWith();
}
}
});
Expand Down
27 changes: 24 additions & 3 deletions app/scripts/controllers/containerfileviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,30 @@ angular.module('dockstore.ui')
var successResult = checkSuccess(accumulator);
successResult.then(
function(){
$scope.selTagName = $scope.successContent[0].tag;
$scope.selDescriptorName = $scope.successContent[0].descriptor;
$scope.fileContent = $scope.successContent[0].content;
var isVersionValid = false;
if ($scope.successContent.length !== 0) {
if ($scope.containerObj.defaultVersion === null) {
$scope.selTagName = $scope.successContent[0].tag;
$scope.selDescriptorName = $scope.successContent[0].descriptor;
$scope.fileContent = $scope.successContent[0].content;
} else {
for (var counter = 0; counter < $scope.successContent.length; counter++) {
if ($scope.successContent[counter].tag === $scope.containerObj.defaultVersion) {
$scope.selTagName = $scope.successContent[counter].tag;
$scope.selDescriptorName = $scope.successContent[counter].descriptor;
$scope.fileContent = $scope.successContent[counter].content;
isVersionValid = true;
break;
}
}
if(!isVersionValid) {
$scope.selTagName = $scope.successContent[0].tag;
$scope.selDescriptorName = $scope.successContent[0].descriptor;
$scope.fileContent = $scope.successContent[0].content;
}
}
}

var result = $scope.fileContent;
m = [];
v = false;
Expand Down
16 changes: 15 additions & 1 deletion app/scripts/controllers/workflowdagview.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,22 @@ angular.module('dockstore.ui')
};

$scope.setDocument = function() {
var isVersionValid = false;
$scope.workflowVersions = $scope.getWorkflowVersions();
$scope.selVersionName = $scope.successContent[0];
if ($scope.workflowObj.defaultVersion === null) {
$scope.selVersionName = $scope.successContent[0];
} else {
for (var counter = 0; counter < $scope.successContent.length; counter++) {
if ($scope.successContent[counter] === $scope.workflowObj.defaultVersion) {
$scope.selVersionName = $scope.successContent[counter];
isVersionValid = true;
break;
}
}
if (!isVersionValid) {
$scope.selVersionName = $scope.successContent[0];
}
}

};

Expand Down
23 changes: 21 additions & 2 deletions app/scripts/controllers/workflowfileviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,27 @@ angular.module('dockstore.ui')
var successResult = checkSuccess(accumulator);
successResult.then(
function(r){
$scope.selVersionName = $scope.successContent[0].version;
$scope.fileContent = $scope.successContent[0].content;
var isVersionValid = false;
if ($scope.successContent.length !== 0) {
if ($scope.workflowObj.defaultVersion === null) {
$scope.selVersionName = $scope.successContent[0].version;
$scope.fileContent = $scope.successContent[0].content;
} else {
for (var counter = 0; counter < $scope.successContent.length; counter++) {
if ($scope.successContent[counter].version === $scope.workflowObj.defaultVersion) {
$scope.selVersionName = $scope.successContent[counter].version;
$scope.fileContent = $scope.successContent[counter].content;
isVersionValid = true;
break;
}
}
if (!isVersionValid) {
$scope.selVersionName = $scope.successContent[0].version;
$scope.fileContent = $scope.successContent[0].content;
}
}
}

var result = $scope.fileContent;
m = [];
v = false;
Expand Down
19 changes: 16 additions & 3 deletions app/scripts/controllers/workflowtoolsgrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ angular.module('dockstore.ui')
};

$scope.getTableContent = function(workflowId, workflowVersions) {
//this function will call the webservice to get
//this function will call the webservice to get
//the workflow and tool/task excerpt in form of json
//and return here as a promise

Expand Down Expand Up @@ -95,9 +95,22 @@ angular.module('dockstore.ui')
};

$scope.setDocument = function() {
var isVersionValid = false;
$scope.workflowVersions = $scope.getWorkflowVersions();
$scope.selVersionName = $scope.successContent[0];

if ($scope.workflowObj.defaultVersion === null) {
$scope.selVersionName = $scope.successContent[0];
} else {
for (var counter = 0; counter < $scope.successContent.length; counter++) {
if ($scope.successContent[counter] === $scope.workflowObj.defaultVersion) {
$scope.selVersionName = $scope.successContent[counter];
isVersionValid = true;
break;
}
}
if (!isVersionValid) {
$scope.selVersionName = $scope.successContent[0];
}
}
};

$scope.refreshDocument = function() {
Expand Down
7 changes: 5 additions & 2 deletions app/scripts/directives/containerdetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ angular.module('dockstore.ui')
scope.validContent = valid;
scope.checkContentValid();
scope.refreshTagLaunchWith();
scope.refreshDescLaunchWith();
});
scope.$on('returnMissing', function(event,missing){
scope.missingContent = missing;
});
scope.$on('invalidClass', function(event, invalid){
scope.invalidClass = invalid;
});

scope.$on('refreshFiles', function() {
scope.refreshTagLaunchWith();
});
}
};
});
});
1 change: 1 addition & 0 deletions app/scripts/directives/containerfileviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ angular.module('dockstore.ui')
scope.$on('refreshFiles', function() {
scope.setDocument();
scope.refreshDocument();
scope.checkDescriptor();
});
scope.$on('checkDescPageType', function() {
scope.checkDescriptor();
Expand Down

0 comments on commit d493c4c

Please sign in to comment.