Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fallback if searchresult contains error on initial query #359

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
45 changes: 40 additions & 5 deletions js/fulltextsearch.v1.searchbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,31 @@ var searchbox = {

var self = this;

// we remove old search
var search_form = $('FORM.searchbox');
if (search_form.length > 0) {
search_form.remove();
}
var testquery={
providers: settings.searchProviderId,
search: "testsearch",
page: curr.page,
options: null,
size: 20
};

$.ajax({
method: 'GET',
url: OC.generateUrl('/apps/fulltextsearch/v1/search'),
data: {
request: JSON.stringify(testquery)
}
}).done(function (res) {
if (_.has(res, 'error')) {
console.log("there was an error with the search! Contact admin.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
console.log("there was an error with the search! Contact admin.");
console.log("there was an error with the search! Contact an admin.");

self.removeNewSearchbox();
return;
}
self.removeOldSearchbox();
}).fail(function () {
console.log("the searchrequest failed! Reload page.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
console.log("the searchrequest failed! Reload page.");
console.log("the search request failed! Reload the page.");

self.removeNewSearchbox();
});

var divHeaderRight = $('DIV.header-right');
var divFullTextSearch = $('<div>', {id: 'fulltextsearch'});
Expand Down Expand Up @@ -86,6 +106,21 @@ var searchbox = {

},

removeOldSearchbox: function () {
// we remove old search
var search_form = $('FORM.searchbox');
if (search_form.length > 0) {
search_form.remove();
}
},

removeNewSearchbox: function () {
$('#fulltextsearch').remove();
var search_form = $('FORM.searchbox');
console.log(search_form);
search_form[0].title="There is an error with the fulltextsearch! Using normal search";
},


generateFullTextSearchIcon: function () {
var className = 'icon-fulltextsearch';
Expand Down