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

some polish on static files and search endpoints.. #886

Merged
merged 4 commits into from
Nov 19, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<div class="col-xs-4">
<img ng-if="ctrl.searchEndpoint.searchEngine" ng-src="images/{{ ctrl.searchEndpoint.searchEngine }}-icon.png" width="32px" />
{{ ctrl.searchEndpoint.searchEngine }}
&nbsp;{{ ctrl.searchEndpoint.searchEngine | searchEngineName }}
</div>

<div class="col-xs-4">
Expand Down
40 changes: 37 additions & 3 deletions app/assets/javascripts/controllers/wizardModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ angular.module('QuepidApp')


$scope.isStaticCollapsed = true;
$scope.addedStaticQueries = false;
$scope.showSearchApiJavaScriptEditor = true;
$scope.staticContent = {
content: null,
Expand Down Expand Up @@ -155,7 +156,13 @@ angular.module('QuepidApp')

searchEndpointSvc.list()
.then(function() {
$scope.searchEndpoints = searchEndpointSvc.searchEndpoints;
$scope.searchEndpoints = searchEndpointSvc.searchEndpoints;
$scope.hasStaticEndpoints = false;
angular.forEach($scope.searchEndpoints, function(searchEndpoint) {
if (searchEndpoint.searchEngine === 'static'){
$scope.hasStaticEndpoints = true;
}
});
});

$scope.listSearchEndpoints = function() {
Expand Down Expand Up @@ -295,7 +302,9 @@ angular.module('QuepidApp')

$scope.validate = validate;
$scope.skipValidation = skipValidation;
$scope.readyToContinue = readyToContinue;
$scope.setupDefaults = setupDefaults;
$scope.linkToSearchEndpointUrl = linkToSearchEndpointUrl;
$scope.submit = submit;
$scope.reset = reset;
$scope.resetUrlValid = resetUrlValid;
Expand Down Expand Up @@ -323,7 +332,16 @@ angular.module('QuepidApp')
$scope.checkTLSForSearchEngineUrl();
}
}


function linkToSearchEndpointUrl() {
if ($scope.pendingWizardSettings.proxyRequests === true){
return caseTryNavSvc.getQuepidProxyUrl() + $scope.pendingWizardSettings.searchUrl;
}
else {
return $scope.pendingWizardSettings.searchUrl;
}
}

function resetUrlValid() {
$scope.urlValid =false;
$scope.invalidProxyApiMethod =false;
Expand All @@ -334,6 +352,21 @@ angular.module('QuepidApp')
WizardHandler.wizard().next();
}
}

function readyToContinue() {
if ($scope.validating){
return false;
}
if ($scope.pendingWizardSettings.searchEngine === 'static'){
if ($scope.addedStaticQueries){
return true;
}
else {
return false;
}
}
return true;
}

function skipValidation() {
var validator = new SettingsValidatorFactory($scope.pendingWizardSettings);
Expand Down Expand Up @@ -644,7 +677,7 @@ angular.module('QuepidApp')
$scope.pendingWizardSettings.addQueryStaticQueries = function() {
angular.forEach($scope.listOfStaticQueries, function(queryText) {
$scope.pendingWizardSettings.addQuery(queryText);
});
});
};

// pass pending settings on to be saved
Expand Down Expand Up @@ -711,6 +744,7 @@ angular.module('QuepidApp')
console.log($location.absUrl) ;
$scope.pendingWizardSettings.searchUrl = `${$location.protocol()}://${$location.host()}:${$location.port()}/api/cases/${caseTryNavSvc.getCaseNo()}/snapshots/${snapshotId}/search`;
$scope.isStaticCollapsed = false;
$scope.addedStaticQueries = true;
//var result = {
// success: true,
// message: 'Static Data imported successfully!',
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/filters/chooseScoreClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ angular.module('QuepidApp')
}
};
}
]);
]);
13 changes: 10 additions & 3 deletions app/assets/javascripts/filters/searchEngineName.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@
angular.module('QuepidApp')
.filter('searchEngineName', [
function () {
var searchEngineName = {
const searchEngineName = {
solr: 'Solr',
es: 'Elasticsearch',
os: 'OpenSearch',
vectara: 'Vectara'
vectara: 'Vectara',
static: 'Static File',
searchapi: 'Search API'
};

return function (input) {
return searchEngineName[input];
if (searchEngineName[input]){
return searchEngineName[input];
}
else {
return input;
}
};
}
]);
2 changes: 1 addition & 1 deletion app/assets/templates/views/devQueryParams.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h4 class="pull-left">Query Sandbox:</h4>
<div class="settings-tab" ng-show="qp.curTab == 'curator'">
<div class="rerunnable-settings-tab">
<p ng-if="settings.searchEngine == 'static'">
With a Static search endpoint there are tuning knobs to play with ;-(.
With a Static search endpoint there are no tuning knobs to play with ;-(.
</p>
<div ng-if="settings.searchEngine !== 'static'">
<p ng-show="settings.selectedTry.curatorVars.length == 0">
Expand Down
36 changes: 18 additions & 18 deletions app/assets/templates/views/wizardModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,22 @@ <h2>What Search Endpoint do you want to connect to?</h2>
id="searchEndpoint"
ng-if="listSearchEndpoints().length > 0"
ng-model="pendingWizardSettings.searchEndpointId"
ng-options="searchEndpoint.id as searchEndpoint.name for searchEndpoint in listSearchEndpoints()"
ng-options="searchEndpoint.id as searchEndpoint.name for searchEndpoint in listSearchEndpoints() | filter: {searchEngine: '!static'}"
ng-change="changeSearchEndpoint()"
>
</select>

<small title="Manually validates Quepid can get retrieve search results from your URL before continuing" class="pull-right"><button type="button" class="btn btn-link btn-sm" ng-click="validate(true)" ng-disabled="pendingWizardSettings.searchEndpointId == null || showTLSChangeWarning">ping it</button></small>
<p class="help-block tip" ng-if="hasStaticEndpoints">
FYI: your existing Static File endpoints are NOT sharable across cases.
</p>
</div>
<div ng-if="urlValid" class="alert alert-success">Quepid can search this! Hit 'Continue' to keep working through setup.</div>
<div class="row" style="margin-top: 50px;">

<div class="pull-right">
<button class="btn btn-primary pull-right continue" ng-click="validate()" ng-disabled="pendingWizardSettings.searchEndpointId == null">Continue</button>

<button class="btn btn-danger" ng-show="urlInvalid && !showTLSChangeWarning" ng-click="skipValidation()" ng-disabled="validating">
<span ng-hide="validating">Skip Validation</span>
</button>
Expand Down Expand Up @@ -110,40 +114,34 @@ <h2>What Search Endpoint do you want to connect to?</h2>
</span>
</div>
<div ng-if="urlInvalid && !showTLSChangeWarning" class="alert alert-danger">
Sorry, we're not getting any search results from your
<span ng-show="pendingWizardSettings.searchEngine === 'es'">Elasticsearch</span>
<span ng-show="pendingWizardSettings.searchEngine === 'os'">OpenSearch</span>
<span ng-show="pendingWizardSettings.searchEngine === 'solr'">Solr</span>
<span ng-show="pendingWizardSettings.searchEngine === 'vectara'">Vectara</span>
<span ng-show="pendingWizardSettings.searchEngine === 'static'">Static file</span>
<span ng-show="pendingWizardSettings.searchEngine === 'searchapi'">Search API</span>.

Sorry, we're not getting any search results from your {{ pendingWizardSettings.searchEngine | searchEngineName }}.

<ul ng-if="pendingWizardSettings.searchEngine === 'searchapi'">
<li>Is your Search API behind a firewall or proxy? Try accessing the <a target="_blank" href="{{pendingWizardSettings.searchUrl}}">URL directly</a> and see if you get a response</li>
<li>Is your Search API behind a firewall or proxy? Try accessing the <a target="_blank" ng-href="{{linkToSearchEndpointUrl()}}">URL directly</a> and see if you get a response</li>
<li>Do you need an API Key? If so, set one up under Advanced pane --> Custom Headers.</li>
<li>Double check if you have an ad blocker blocking your queries.</li>
<li>Use the browser <i>Network Inspector</i> to see the actual request.</li>
<li>See the <a target="_blank" href="https://github.com/o19s/quepid/wiki/Troubleshooting-SearchAPI-and-Quepid/">Troubleshooting Search API and Quepid</a> wiki page for more help!</li>
</ul>

<ul ng-if="pendingWizardSettings.searchEngine === 'es'">
<li>Is your Elasticsearch behind a firewall or proxy? Try accessing the <a target="_blank" href="{{pendingWizardSettings.searchUrl}}">URL directly</a> and see if you get a response</li>
<li>Is your Elasticsearch behind a firewall or proxy? Try accessing the <a target="_blank" ng-href="{{linkToSearchEndpointUrl()}}">URL directly</a> and see if you get a response</li>
<li>Does your Elasticsearch accept HTTP POST requests?</li>
<li>Is your Elasticsearch setup for CORS to talk to Quepid's web app (http://app.quepid.com)?</li>
<li>Do you need an API Key? If so, set one up under Advanced pane --> Custom Headers.</li>
<li>Double check if you have an ad blocker blocking your queries.</li>
<li>Use the browser <i>Network Inspector</i> to see the actual request.</li>
<li>See the <a target="_blank" href="https://github.com/o19s/quepid/wiki/Troubleshooting-Elasticsearch-and-Quepid/">Troubleshooting Elasticsearch and Quepid</a> wiki page for more help!</li>
</ul>

<ul ng-if="pendingWizardSettings.searchEngine === 'os'">
<li>Is your OpenSearch behind a firewall or proxy? Try accessing the <a target="_blank" href="{{pendingWizardSettings.searchUrl}}">URL directly</a> and see if you get a response</li>
<li>Is your OpenSearch behind a firewall or proxy? Try accessing the <a target="_blank" ng-href="{{linkToSearchEndpointUrl()}}">URL directly</a> and see if you get a response</li>
<li>Does your OpenSearch accept HTTP POST requests?</li>
<li>Is your OpenSearch setup for CORS to talk to Quepid's web app (http://app.quepid.com)?</li>
<li>Double check if you have an ad blocker blocking your queries.</li>
<li>Use the browser <i>Network Inspector</i> to see the actual request.</li>
<li>See the <a target="_blank" href="https://github.com/o19s/quepid/wiki/Troubleshooting-OpenSearch-and-Quepid/">Troubleshooting OpenSearch and Quepid</a> wiki page for more help!</li>
</ul>

<ul ng-if="pendingWizardSettings.searchEngine === 'solr'">
<li>Do you see any errors when you visit your <a target="_blank" href="{{pendingWizardSettings.searchUrl}}">Solr URL directly?</a></li>
<li>Do you see any errors when you visit your <a target="_blank" ng-href="{{linkToSearchEndpointUrl()}}">Solr URL directly?</a></li>
<li>
If you are using a version of Solr between 8.4 and 9.0, you may need to tweak the content-type being set by <code>wt=json</code>.
You can do this via the below curl command:
Expand All @@ -161,6 +159,7 @@ <h2>What Search Endpoint do you want to connect to?</h2>
</li>
<li>If Solr responds, check if you have an ad blocker blocking your queries.</li>
<li>Chrome does not accept self signed certificates on Solr, try Firefox.</li>
<li>Use the browser <i>Network Inspector</i> to see the actual request.</li>
<li>See the <a target="_blank" href="https://github.com/o19s/quepid/wiki/Troubleshooting-Solr-and-Quepid">Troubleshooting Solr and Quepid</a> wiki page for more help!</li>
</ul>

Expand Down Expand Up @@ -372,7 +371,8 @@ <h2>CSV</h2>

<div class="row" style="margin-top: 50px;">
<div class="pull-right">
<button ng-show="!showTLSChangeWarning" class="btn btn-primary pull-right continue" ng-click="validate()" ng-disabled="validating">

<button ng-show="!showTLSChangeWarning" class="btn btn-primary pull-right continue" ng-click="validate()" ng-disabled="!readyToContinue()">
<span ng-hide="validating">Continue</span>
<span ng-show="validating">Validating...</span>
</button>
Expand Down
10 changes: 7 additions & 3 deletions app/controllers/proxy_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ def fetch
end
end

data = JSON.parse(response.body)
# Process the data as needed
render json: data, status: response.status
begin
data = JSON.parse(response.body)
render json: data, status: response.status
rescue JSON::ParserError
# sometimes the API is returning plain old text, like a "Unauthorized" type message.
render plain: response.body, status: response.status
end
end

def proxy_url_params
Expand Down