Commit 29de3b04 authored by Eric  DEVEAUD's avatar Eric DEVEAUD

Merge branch 'master' of https://projets.pasteur.fr/git/bioweb

parents 04ecc7f7 89b9cbe6
......@@ -69,6 +69,9 @@
<li>
<a ng-href="/packages">Tools and packages</a>
</li>
<li>
<a ng-href="/pasteur">Pasteur</a>
</li>
<li>
<a ng-href="/news">News</a>
</li>
......
......@@ -40,6 +40,9 @@ angular.module('biowebEvolApp', [
resolve: {
'webOnly': function() {
return false;
},
'collection': function() {
return null;
}
},
reloadOnSearch: false
......@@ -50,6 +53,22 @@ angular.module('biowebEvolApp', [
resolve: {
'webOnly': function() {
return true;
},
'collection': function() {
return null;
}
},
reloadOnSearch: false
})
.when('/pasteur', {
templateUrl: 'views/packages.html',
controller: 'PackagesListCtrl',
resolve: {
'webOnly': function() {
return false;
},
'collection': function() {
return 'pasteur';
}
},
reloadOnSearch: false
......@@ -60,6 +79,9 @@ angular.module('biowebEvolApp', [
resolve: {
'webOnly': function() {
return false;
},
'collection': function() {
return null;
}
},
reloadOnSearch: false
......@@ -99,6 +121,7 @@ angular.module('biowebEvolApp', [
});
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!');
}).run(function(Angularytics) {
}).run(function(Angularytics, $rootScope) {
Angularytics.init();
$rootScope._ = _;
});
......@@ -6,36 +6,64 @@ angular.module('biowebEvolApp')
$rootScope.title = 'Welcome!';
$scope.routeParams = $routeParams;
$scope.searchSources = [];
var loadPackages = function(dataPromise){
$scope.packageMatches = null;
$scope.loading=true;
dataPromise.then(function(matchesNumber){
$scope.packageMatches = matchesNumber;
$scope.loading=false;
});
};
var loadWebPackages = function(dataPromise){
$scope.webPackageMatches = null;
$scope.loading=true;
dataPromise.then(function(matchesNumber){
$scope.webPackageMatches = matchesNumber;
$scope.loading=false;
});
};
var loadData = function(dataPromise){
$scope.dataMatches = null;
$scope.loading=true;
dataPromise.then(function(matchesNumber){
$scope.dataMatches = matchesNumber;
$scope.loading=false;
});
};
var loadTopics = function(dataPromise){
$scope.topicMatches = null;
$scope.loading=true;
dataPromise.then(function(matchesNumber){
$scope.topicMatches = matchesNumber;
$scope.loading=false;
// faire une liste nommée sections
// item keys are 'name' for the key
// 'label' for the human readable title
// 'subtitle' for the subtitle
// 'loader' for the loading function
// 'icon' for the icon class
$scope.sections = [
{'name': 'topics',
'label': 'Topics',
'subtitle': 'Alignment, Structure, etc.',
'loader': function(){
return Catalog.packageTopics($routeParams.search, true);
},
'icon':'fa-question-circle'
},
{'name': 'data',
'label': 'Databanks',
'subtitle': 'Banks and Genomes',
'loader': function(){
return Catalog.banks($routeParams.search, true);
},
'icon':'fa-database'
},
{'name': 'packages',
'label': 'Tools and packages',
'subtitle': 'Available software packages',
'loader': function(){
return Catalog.searchPackages($routeParams.search, $routeParams.topicId, false, true);
},
'icon':'fa-database'
},
{'name': 'web',
'label': 'Web interfaces',
'subtitle': 'Mobyle, Galaxy',
'loader': function(){
return Catalog.searchPackages($routeParams.search, $routeParams.topicId, true, true);
},
'icon':'fa-desktop'
},
{'name': 'pasteur',
'label': 'Pasteur software',
'subtitle': 'Software from the Institut Pasteur',
'loader': function(){
return Catalog.searchPackages($routeParams.search, $routeParams.topicId, true, true);
},
'icon':'fa-compass'
},
];
$scope.matches = {};
$scope.loading = {};
var load = function(){
_.map($scope.sections, function(section){
$scope.matches[section.name] = null;
$scope.loading[section.name] = true;
section.loader().promise.then(function(matchesNumber){
$scope.matches[section.name] = matchesNumber;
$scope.loading[section.name] = false;
});
});
};
$scope.$watch('routeParams', function(newVal, oldVal) {
......@@ -53,13 +81,7 @@ angular.module('biowebEvolApp')
$location.search(k, v);
}
});
loadPackages(Catalog.searchPackages($routeParams.search, $routeParams.topicId, '', true).promise);
loadWebPackages(Catalog.searchPackages($routeParams.search, $routeParams.topicId, true, true).promise);
loadData(Catalog.banks($routeParams.search, true).promise);
loadTopics(Catalog.packageTopics($routeParams.search, true).promise);
load();
}, true);
loadPackages(Catalog.searchPackages($routeParams.search, $routeParams.topicId, '', true).promise);
loadWebPackages(Catalog.searchPackages($routeParams.search, $routeParams.topicId, true, true).promise);
loadData(Catalog.banks($routeParams.search, true).promise);
loadTopics(Catalog.packageTopics($routeParams.search, true).promise);
load();
}]);
'use strict';
angular.module('biowebEvolApp')
.controller('PackagesListCtrl', function($scope, Catalog, Edam, $routeParams, $rootScope, $q, webOnly, $location, $timeout) {
.controller('PackagesListCtrl', function($scope, Catalog, Edam, $routeParams, $rootScope, $q, webOnly, collection, $location, $timeout) {
$rootScope.title = 'Tools and packages';
$scope.routeParams = $routeParams;
$scope.hasMobyleInterfaces = function(version) {
......@@ -30,7 +30,7 @@ angular.module('biowebEvolApp')
$timeout($scope.loadMore);
}
});
$q.all([Catalog.packageVersions(null, webOnly).promise, Edam.topicsList.promise]).then(function(results){
$q.all([Catalog.packageVersions(null, webOnly, collection).promise, Edam.topicsList.promise]).then(function(results){
$scope.searchSources = _.flatten(results);
});
if (webOnly) {
......@@ -73,9 +73,9 @@ angular.module('biowebEvolApp')
$location.search(k, v);
}
});
loadPackages(Catalog.searchPackages($routeParams.search, $routeParams.topicId, webOnly).promise);
loadPackages(Catalog.searchPackages($routeParams.search, $routeParams.topicId, webOnly, null, collection).promise);
}, true);
loadPackages(Catalog.searchPackages($routeParams.search, $routeParams.topicId, webOnly).promise);
loadPackages(Catalog.searchPackages($routeParams.search, $routeParams.topicId, webOnly, null, collection).promise);
if ($routeParams.topicId) {
Edam.topics().promise.then(function(edamTerms){
$rootScope.title += ' by theme > ' + edamTerms[$routeParams.topicId]['rdfs:label'];
......
......@@ -16,42 +16,59 @@ angular.module('biowebEvolApp')
return searchResults;
}
var packageVersions = function(packageId, onlyWeb){
var packageVersions = function(packageId, onlyWeb, collection){
var result = $q.defer();
var url = '/api/packageVersions';
if(packageId!=null){
url += '/'+packageId;
}
var params = {
'web': onlyWeb,
'collection': collection
}
$http({
method: 'GET',
url: url +'?web=' + onlyWeb
url: url,
params: params
}).success(function(data, status){
result.resolve(data);
});
return result;
}
var packageTopics = function(query, count){
var packageTopics = function(query, count, collection){
var searchResults = $q.defer();
query = query || '';
count = count || '';
var params = {
query: query,
count: count,
collection: collection
}
$http({
method: 'GET',
url: '/api/packageTopics?search=' + query + '&count=' + count
url: '/api/packageTopics',
params: params
}).success(function(data, status) {
searchResults.resolve(data);
});
return searchResults;
};
var searchPackages = function(query, topicId, web, count) {
var searchPackages = function(query, topicId, web, count, collection) {
var searchResults = $q.defer();
query = query || '';
topicId = topicId || '';
web = web || '';
count = count || '';
var params = {
search: query,
count: count,
topicId: topicId,
collection: collection,
web: web
}
console.log(params);
$http({
method: 'GET',
url: '/api/packages?search=' + query + '&topicId=' + topicId + '&web=' + web + '&count=' + count
url: '/api/packages',
params: params
}).success(function(data, status) {
_.map(data, function(item){
_.map(item.versions, function(packVersion) {
......
......@@ -8,15 +8,10 @@
<strong>online catalog</strong> of bioinformatics programs and databanks available at the Institut Pasteur.
</p>
</div>
<div ng-show="loading" class="ng-hide text-center container">
<div ng-show="_.any(_.values(loading))" class="ng-hide text-center container">
<i class="fa fa-spinner fa-5x fa-spin"></i>
</div>
<div class="container" ng-if="!loading && packages.length===0">
<div class="alert alert-danger text-center" >Nothing found</div>
</div>
<div class="row col-md-12" ng-if="!loading">
<div ng-show="!_.any(_.values(loading))" class="row col-md-12">
<section class="col-md-4 col-xs-12 panel panel-info" style="height: 300px; overflow-y: scroll;">
<header>
<h2><i class="fa fa-large fa-newspaper-o"></i>&nbsp;Latest news</h2>
......@@ -24,33 +19,12 @@
<news-list limit="20"></news-list>
</section>
<section class="col-md-8 col-xs-12">
<div class="col-md-6">
<a href="/topics?search={{routeParams.search}}" class="thumbnail" ng-class="routeParams.search ? (packageMatches==0 ? 'text-muted' : 'text-match') : ''">
<h2>
<i class="fa fa-large fa-question-circle"></i>&nbsp;{{topicMatches}}&nbsp;Topics</h2>
<div>Alignment, Structure, etc.</div>
</a>
</div>
<div class="col-md-6">
<a href="/data?search={{routeParams.search}}" class="thumbnail" ng-class="routeParams.search ? (packageMatches==0 ? 'text-muted' : 'text-match') : ''">
<h2>
<i class="fa fa-large fa-database"></i>&nbsp;{{dataMatches}}&nbsp;Databanks</h2>
<div>Banks and Genomes</div>
</a>
</div>
<div class="col-md-6">
<a href="/web?search={{routeParams.search}}" class="thumbnail" ng-class="routeParams.search ? (packageMatches==0 ? 'text-muted' : 'text-match') : ''">
<h2>
<i class="fa fa-large fa-desktop"></i>&nbsp;{{webPackageMatches}}&nbsp;Web interfaces</h2>
<div>Mobyle, Galaxy</div>
</a>
</div>
<div class="col-md-6">
<a href="/packages?search={{routeParams.search}}" class="thumbnail" ng-class="routeParams.search ? (packageMatches==0 ? 'text-muted' : 'text-match') : ''">
<h2>
<i class="fa fa-large fa-wrench"></i>&nbsp;{{packageMatches}}&nbsp;Tools &amp; packages</h2>
<div>List of available software packages</div>
</a>
</div>
<div class="col-md-6" ng-repeat="section in sections">
<a href="/{{section.name}}{{routeParams.search ? '?search='+routeParams.search : ''}}" class="thumbnail" ng-class="routeParams.search ? (matches[section.name]==0 ? 'text-muted' : 'text-match') : ''">
<h2>
<i class="fa fa-large {{section.icon}}"></i>&nbsp;{{matches[section.name]}}&nbsp;{{section.label}}</h2>
<div>{{section.subtitle}}</div>
</a>
</div>
</section>
</div>
No preview for this file type
No preview for this file type
{
"web": {
"host": null,
"port": 8080,
"gacode": "UA-71486402-1"
},
"db": {
"host": "localhost",
"port": 27017,
"name": "bioweb",
"serverOptions": {"ssl": false,
"sslValidate":false}
}
}
......@@ -170,6 +170,7 @@ var router = function(app) {
if(authorizedCollections.indexOf(req.params.collection)==-1){
res.sendStatus(404);
close();
return;
}
var collection = db.collection(req.params.collection);
var filter = {};
......@@ -184,6 +185,23 @@ var router = function(app) {
if (req.query.limit) {
limit = parseInt(req.query.limit);
}
if (req.query.collection){
switch (req.params.collection) {
case 'packages':
filter['collections'] = req.query.collection;
break;
case 'packageVersions':
filter['package.collections'] = req.query.collection;
break;
case 'programs':
filter['packageVersion.package.collections'] = req.query.collection;
break;
default:
res.status(422).send("Unprocessable Entity");
close();
return;
}
}
if (req.query.web=='true'){
switch (req.params.collection) {
case 'packages':
......@@ -253,6 +271,7 @@ var WebServer = function(contacts) {
app.use('/topics',staticMw);
app.use('/data',staticMw);
app.use('/web',staticMw);
app.use('/pasteur',staticMw);
app.use('/packages',staticMw);
app.use('/packages/:package_id',staticMw);
app.use('/packages/topics/:topic_id',staticMw);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment