Skip to content

Conversation

@rranjan03
Copy link
Contributor

What is this PR for?

Search notebook to handle empty result.

What type of PR is it?

Bug Fix

Todos

What is the Jira issue?

ZEPPELIN-869

How should this be tested?

  1. Try to search something which should return empty result, you should get proper message for that.
  2. search box should get cleared when clicked on any other link.

Screenshots (if appropriate)

Before:
screen shot 2016-06-09 at 3 44 53 pm

After:
screen shot 2016-06-09 at 3 34 47 pm

Questions:

  • Does the licenses files need update?No
  • Is there breaking changes for older versions?No
  • Does this needs documentation?No

@bzz
Copy link
Member

bzz commented Jun 9, 2016

@ravicodder thank you for improvement!

\cc @felizbear as an original author of search frontend for a review

@prabhjyotsingh
Copy link
Contributor

prabhjyotsingh commented Jun 10, 2016

LGTM, I noticed you are clearing search box on click of any link 👍

var routeChangeEvent = $rootScope.$on('$routeChangeStart', function (event, next, current) {
if (next.originalPath !== '/search/:searchTerm') {
angular.element('#searchTermId').val('');
routeChangeEvent();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, why do you recursively call routeChangeEvent here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felizbear by calling routeChangeEvent I am explicitly unbinding the event handler.
$routeScope.$on returns a deregistration function whose reference we are storing in routeChangeEvent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it makes sense to rename routeChangeEvent into something like unbindRouteChangeEvent? with such name no questions would arise about why it is invoked

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felizbear ya, it makes sense. Renamed routeChangeEvent to unbindRouteChangeEvent.

@heruka-urgyen
Copy link
Contributor

Also, I would recommend modify ng-disabled of search form in navbar like this:

ng-disabled="!navbar.connected || !searchTerm"

so it doesn't fire when there is an empty field

@heruka-urgyen
Copy link
Contributor

Also, I think you will have to clean up scope after you clear the search field value. To see what I mean do the following:

  1. Search for something, e.g. bankText
  2. Navigate away from the search result page (search field now is empty)
  3. Search again with the empty search field
  4. See bankText results again (expected to see an empty page or even have search field disabled like I suggested above)

@heruka-urgyen
Copy link
Contributor

Thanks for contribution by the way :)

@rranjan03
Copy link
Contributor Author

Hi @felizbear thanks for the review.
I have done the required changes, Please have a look.

…into ZEPPELIN-869

Conflicts:
	zeppelin-web/src/components/navbar/navbar.html
@heruka-urgyen
Copy link
Contributor

@ravicodder except for this remark, LGTM

$scope.isResult = true;
}

var routeChangeEvent = $rootScope.$on('$routeChangeStart', function (event, next, current) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be $scope.$on

@corneadoug
Copy link
Contributor

The searchTerm would probably be better inside the searchService instead of the $rootScope

@rranjan03
Copy link
Contributor Author

@corneadoug Thanks for the review. Done required changes, kindly review it.

…into ZEPPELIN-869

Conflicts:
	zeppelin-web/src/components/navbar/navbar.controller.js
});
};

this.searchTerm = '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to do a this.searchTerm = term.q; at the beginning of the this.search function, otherwise there is no search field when you reload the page

@corneadoug
Copy link
Contributor

@ravicodder Thank you for rebasing, I left a few more comments

@rranjan03
Copy link
Contributor Author

@corneadoug done required changes.
Please, have a look.

angular
.module('zeppelinWebApp')
.controller('SearchResultCtrl', function($scope, $routeParams, searchService) {
.controller('SearchResultCtrl', function($scope, $routeParams, searchService, $rootScope) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think now $rootScope can be removed, its unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prabhjyotsingh removed $rootScope in latest commit.

@rranjan03 rranjan03 force-pushed the ZEPPELIN-869 branch 2 times, most recently from 3f62ed6 to be51289 Compare June 14, 2016 11:37
@corneadoug
Copy link
Contributor

Merging if there is no more discussions

@asfgit asfgit closed this in 70ebd32 Jun 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants