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

Commit

Permalink
Finished implementing faceted search
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Apr 18, 2016
1 parent 46d84d4 commit e970e6c
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 13 deletions.
65 changes: 55 additions & 10 deletions lib/client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ angular.module("roarmap-h2020-view", ["ngRoute"])
templateUrl: "partials/institution.html",
controller: "InstitutionController",
})
.when("/by/:facet", {
templateUrl: "partials/by.html",
controller: "ByController",
.when("/by/type", {
templateUrl: "partials/by_type.html",
controller: "ByTypeController",
})
.when("/by/country", {
templateUrl: "partials/by_country.html",
controller: "ByCountryController",
})
.otherwise({
redirectTo: "/search",
Expand Down Expand Up @@ -84,7 +88,7 @@ angular.module("roarmap-h2020-view", ["ngRoute"])
};
})

.controller("SearchController", function ($scope, $http, roarmapSearch) {
.controller("SearchController", function ($scope, roarmapSearch) {
$scope.g = {
terms: "",
result: roarmapSearch.getCurrentSearch(),
Expand All @@ -101,7 +105,7 @@ angular.module("roarmap-h2020-view", ["ngRoute"])
})

.controller("InstitutionController",
function ($scope, $http, $routeParams, roarmapLoader) {
function ($scope, $routeParams, roarmapLoader) {
$scope.g = {
selected: null,
};
Expand All @@ -112,7 +116,6 @@ angular.module("roarmap-h2020-view", ["ngRoute"])
// TODO: consider implementing a map if speed becomes a problem
for (i = 0; i < institutions.length; ++i) {
if (institutions[i].eprintid === ($routeParams.eprintid | 0)) {
console.log(institutions[i]);
$scope.g.selected = institutions[i];
$scope.g.selected.nexa = rules.apply(institutions[i]);
var total = 0.0;
Expand All @@ -133,10 +136,52 @@ angular.module("roarmap-h2020-view", ["ngRoute"])
});
})

.controller("ByController",
function ($scope, $http, $routeParams, roarmapLoader) {
.controller("ByTypeController", function ($scope, roarmapLoader) {
$scope.g = {
tree: null
aggregate: null,
view: {},
};
console.log($routeParams);

roarmapLoader(function (error, institutions) {
if (error) {
throw error;
}
$scope.g.aggregate = {};
$scope.g.view = {};
institutions.forEach(function (e) {
var k = e.policymaker_type;
if (!$scope.g.aggregate[k]) {
$scope.g.aggregate[k] = [];
}
$scope.g.aggregate[k].push(e);
});
});
})

.controller("ByCountryController", function ($scope, roarmapLoader) {
$scope.g = {
aggregate: null,
view: {},
};

roarmapLoader(function (error, institutions) {
if (error) {
throw error;
}
$scope.g.view = {};
var p = {};
institutions.forEach(function (e) {
if (!p[e.country_names[0]]) {
p[e.country_names[0]] = {};
}
if (!p[e.country_names[0]][e.country_names[1]]) {
p[e.country_names[0]][e.country_names[1]] = {};
}
if (!p[e.country_names[0]][e.country_names[1]][e.country_names[2]]) {
p[e.country_names[0]][e.country_names[1]][e.country_names[2]] = [];
}
p[e.country_names[0]][e.country_names[1]][e.country_names[2]].push(e);
});
$scope.g.aggregate = p;
});
});
2 changes: 0 additions & 2 deletions static/partials/by.html

This file was deleted.

18 changes: 18 additions & 0 deletions static/partials/by_country.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div ng-controller="ByCountryController">
<div ng-show="g.aggregate">
<ul ng-repeat="(k, v) in g.aggregate">
<li>{{k}}</li>
<ul ng-repeat="(k1, v1) in v">
<li>{{k1}}</li>
<ul ng-repeat="(k2, v2) in v1">
<li>{{k2}}</li>
<ul ng-repeat="inst in v2">
<li>
<a href="#/institutions/{{inst.eprintid}}">{{inst.title}}</a>
</li>
</ul>
</ul>
</ul>
</ul>
</div>
</div>
14 changes: 14 additions & 0 deletions static/partials/by_type.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div ng-controller="ByTypeController">

<div ng-show="g.aggregate">
<ul ng-repeat="(k, v) in g.aggregate">
<li>{{k}}</li>
<ul>
<li ng-repeat="elem in v">
<a href="#/institutions/{{elem.eprintid}}">{{elem.title}}</a>
</li>
</ul>
</ul>
</div>

</div>
2 changes: 1 addition & 1 deletion static/partials/institution.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div ng-show="g.selected">

<p>[<a href="/">&lt;&lt;</a>] <b>{{g.selected.title}}</b>
<p><b>{{g.selected.title}}</b>
({{g.selected.policymaker_type}})<br />
Last Modified: {{g.selected.lastmod}}<br />

Expand Down

0 comments on commit e970e6c

Please sign in to comment.