Permalink
Browse files

Streamcontroller react to locationchange

Our search is happening via setting the 'q' router parameter.
Currently our stream search was not reacted to it so only the default handler
cought it, performing a page search.

Now we send a message to the backend via websocket and we get back the new
search results.

Fix #1618
  • Loading branch information...
gergely-ujvari committed Oct 28, 2014
1 parent e76d1d2 commit e5ecce088ee8966651e114a90476da0769ce9ac5
Showing with 14 additions and 2 deletions.
  1. +14 −2 h/static/scripts/streamsearch.coffee
@@ -1,10 +1,10 @@
class StreamSearchController
this.inject = [
'$scope', '$rootScope', '$routeParams',
'$scope', '$location', '$rootScope', '$routeParams',
'annotator', 'queryparser', 'searchfilter', 'streamfilter'
]
constructor: (
$scope, $rootScope, $routeParams
$scope, $location, $rootScope, $routeParams
annotator, queryparser, searchfilter, streamfilter
) ->
# Clear out loaded annotations and threads
@@ -32,9 +32,21 @@ class StreamSearchController
$scope.$watch 'updater', (updater) ->
updater?.then (sock) ->
$scope.sock = sock
filter = streamfilter.getFilter()
sock.send(JSON.stringify({filter}))
$scope.$on '$locationChangeSuccess', ->
streamfilter
.resetFilter()
.setMatchPolicyIncludeAll()
.setPastDataHits(50)
$scope.search.query = $location.search()['q']
terms = searchfilter.generateFacetedFilter $scope.search.query
queryparser.populateFilter streamfilter, terms
filter = streamfilter.getFilter()
$scope.sock.send(JSON.stringify({filter}))
$scope.$on '$destroy', ->
$scope.search.query = ''

0 comments on commit e5ecce0

Please sign in to comment.