Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
"tests"
],
"dependencies": {
"angular": "~1.3.8",
"angular-cookies": "~1.3.8",
"angular-route": "~1.3.8",
"angular-sanitize": "~1.3.8",
"angular-touch": "~1.3.8",
"angular": "^1.6.9",
"angular-cookies": "^1.6.9",
"angular-route": "^1.6.9",
"angular-sanitize": "^1.6.9",
"angular-touch": "^1.6.9",
"bootstrap": "~3.3.1",
"d3": "~3.5.3",
"d3": "^4.13.0",
"fontawesome": "~4.2.0",
"jquery": "~2.1.3"
"jquery": "^3.3.1"
}
}
30 changes: 18 additions & 12 deletions dist/ngsolr.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ app.constant('Solr', {
var f = query.createFacet('location_0_coordinate', '*');
query.addFacet(f);
query.setOption('fl', '*');
query.setOption('json.wrf', 'JSON_CALLBACK');
query.setOption('rows', '5000');
query.setOption('sort', 'title+asc');
query.setOption('wt', 'json');
Expand Down Expand Up @@ -705,10 +704,11 @@ angular
*/
$scope.handleSetPage = function(Start) {
var query = SolrSearchService.getQuery($scope.queryName);
var oldHash = query.getHash();
query.setOption('start', Start * $scope.documentsPerPage);
if ($scope.updateLocationOnChange) {
var hash = query.getHash();
$location.path(hash);
$location.path($location.path().replace(oldHash, hash));
$window.scrollTo(0, 0);
} else {
$scope.loading = true;
Expand Down Expand Up @@ -876,10 +876,11 @@ angular.module('ngSolr').controller('FacetSelectionController',
*/
$scope.remove = function(Index) {
query = SolrSearchService.getQuery($scope.target);
var oldHash = query.getHash();
query.removeFacetByIndex(Index);
// change window location
hash = query.getHash();
$location.path(hash);
$location.path($location.path().replace(oldHash, hash));
};

/**
Expand Down Expand Up @@ -996,14 +997,20 @@ angular
name = $scope.field;
// ISSUE #27 replace all space characters with * to ensure that Solr matches
// on the space value
value = '(' + $scope.items[Index].value.split(' ').join('*') + ')';
value = '(' + $scope.items[Index].value.replace(new RegExp(":", 'g'),' ').split(' ').join('*') + ')';
facet = query.createFacet(name, value);
// check to see if the selected facet is already in the list
if ($scope.facets.indexOf(facet) === -1) {
var oldHash = query.getHash();
query.addFacet(facet);
query.options.start = 0;
// change window location
hash = query.getHash();
$location.path(hash);
if (!$location.path()) {
$location.path(hash);
} else {
$location.path($location.path().replace(oldHash, hash));
}
}
// @see https://github.com/angular/angular.js/issues/1179
$event.preventDefault();
Expand Down Expand Up @@ -1036,6 +1043,7 @@ angular
if (f.field.indexOf($scope.field) > -1) {
$scope.selected = true;
s = f.value.replace(/([\(\[\)\]])+/g,'');
s = s.replace(/\*/g, ' '); // Replace stars added when searching
selected_values.push(s);
// break;
}
Expand Down Expand Up @@ -2977,13 +2985,12 @@ function SolrQuery(Url) {
*/
angular
.module('ngSolr')
.factory('SolrSearchService', ['$http','$log','$q','$rootScope',
function ($http, $log, $q, $rootScope) {
.factory('SolrSearchService', ['$http','$log','$q','$rootScope', '$sce',
function ($http, $log, $q, $rootScope, $sce) {

// the default search query
var defaultQuery = function(query) {
query.setOption('fl', '*');
query.setOption('json.wrf', 'JSON_CALLBACK');
query.setOption('rows', 10);
query.setOption('wt', 'json');
query.setUserQuery('*:*');
Expand Down Expand Up @@ -3195,7 +3202,7 @@ angular
var url = query.getSolrQueryUrl();
$log.debug('GET ' + QueryName + ': ' + url);
// execute the query
return $http.jsonp(url).then(
return $http.jsonp($sce.trustAsResourceUrl(url), {jsonpCallbackParam: 'json.wrf'}).then(
// success
function (result) {
// set query result values
Expand All @@ -3211,9 +3218,9 @@ angular
$rootScope.$broadcast(QueryName);
},
// error
function () {
function (error) {
var msg = 'Could not get search results from server';
$log.error(msg);
$log.error(msg +' -> ' + error);
// set query result values
var response = {};
response.numFound = 0;
Expand All @@ -3237,7 +3244,6 @@ angular




/**
* Utility functions used across the application.
*/
Expand Down
6 changes: 3 additions & 3 deletions dist/ngsolr.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ngsolr.min.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ <h4><%= pkg.name %></h4>
<div class="panel-body">
<ul class="items unstyled">
<li class="facet" ng-repeat="item in items">
<i class="icon-tag"></i>
<i class="fa fa-tag"></i>
<a ng-click="remove($index)">
<span class="value">{{item | prettyFacetLabel | swapFacetLabels}}</span>
</a>
Expand All @@ -119,9 +119,10 @@ <h4><%= pkg.name %></h4>
</div>
</div>

<!-- Check why ngHide is not evaluating correctly. When selected (false/true) && exclusive(false), it evaluates to true. Using false as default.-->
<div class="panel panel-default"
ng-controller="FieldFacetController"
ng-hide="selected && exclusive"
ng-hide="selected && false"
data-exclusive="false"
data-field="function"
data-source="https://data.esrc.unimelb.edu.au/solr/FACP"
Expand Down
1 change: 0 additions & 1 deletion src/ngsolr/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ app.constant('Solr', {
var f = query.createFacet('location_0_coordinate', '*');
query.addFacet(f);
query.setOption('fl', '*');
query.setOption('json.wrf', 'JSON_CALLBACK');
query.setOption('rows', '5000');
query.setOption('sort', 'title+asc');
query.setOption('wt', 'json');
Expand Down
3 changes: 2 additions & 1 deletion src/ngsolr/controllers/DocumentSearchResultsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ angular
*/
$scope.handleSetPage = function(Start) {
var query = SolrSearchService.getQuery($scope.queryName);
var oldHash = query.getHash();
query.setOption('start', Start * $scope.documentsPerPage);
if ($scope.updateLocationOnChange) {
var hash = query.getHash();
$location.path(hash);
$location.path($location.path().replace(oldHash, hash));
$window.scrollTo(0, 0);
} else {
$scope.loading = true;
Expand Down
3 changes: 2 additions & 1 deletion src/ngsolr/controllers/FacetSelectionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ angular.module('ngSolr').controller('FacetSelectionController',
*/
$scope.remove = function(Index) {
query = SolrSearchService.getQuery($scope.target);
var oldHash = query.getHash();
query.removeFacetByIndex(Index);
// change window location
hash = query.getHash();
$location.path(hash);
$location.path($location.path().replace(oldHash, hash));
};

/**
Expand Down
11 changes: 9 additions & 2 deletions src/ngsolr/controllers/FieldFacetController.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,20 @@ angular
name = $scope.field;
// ISSUE #27 replace all space characters with * to ensure that Solr matches
// on the space value
value = '(' + $scope.items[Index].value.split(' ').join('*') + ')';
value = '(' + $scope.items[Index].value.replace(new RegExp(":", 'g'),' ').split(' ').join('*') + ')';
facet = query.createFacet(name, value);
// check to see if the selected facet is already in the list
if ($scope.facets.indexOf(facet) === -1) {
var oldHash = query.getHash();
query.addFacet(facet);
query.options.start = 0;
// change window location
hash = query.getHash();
$location.path(hash);
if (!$location.path()) {
$location.path(hash);
} else {
$location.path($location.path().replace(oldHash, hash));
}
}
// @see https://github.com/angular/angular.js/issues/1179
$event.preventDefault();
Expand Down Expand Up @@ -124,6 +130,7 @@ angular
if (f.field.indexOf($scope.field) > -1) {
$scope.selected = true;
s = f.value.replace(/([\(\[\)\]])+/g,'');
s = s.replace(/\*/g, ' '); // Replace stars added when searching
selected_values.push(s);
// break;
}
Expand Down
12 changes: 5 additions & 7 deletions src/ngsolr/services/solr.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,12 @@ function SolrQuery(Url) {
*/
angular
.module('ngSolr')
.factory('SolrSearchService', ['$http','$log','$q','$rootScope',
function ($http, $log, $q, $rootScope) {
.factory('SolrSearchService', ['$http','$log','$q','$rootScope', '$sce',
function ($http, $log, $q, $rootScope, $sce) {

// the default search query
var defaultQuery = function(query) {
query.setOption('fl', '*');
query.setOption('json.wrf', 'JSON_CALLBACK');
query.setOption('rows', 10);
query.setOption('wt', 'json');
query.setUserQuery('*:*');
Expand Down Expand Up @@ -618,7 +617,7 @@ angular
var url = query.getSolrQueryUrl();
$log.debug('GET ' + QueryName + ': ' + url);
// execute the query
return $http.jsonp(url).then(
return $http.jsonp($sce.trustAsResourceUrl(url), {jsonpCallbackParam: 'json.wrf'}).then(
// success
function (result) {
// set query result values
Expand All @@ -634,9 +633,9 @@ angular
$rootScope.$broadcast(QueryName);
},
// error
function () {
function (error) {
var msg = 'Could not get search results from server';
$log.error(msg);
$log.error(msg +' -> ' + error);
// set query result values
var response = {};
response.numFound = 0;
Expand All @@ -657,4 +656,3 @@ angular
return svc;

}]);