Skip to content

Commit

Permalink
Fixup wizard handling of search endpoints. (#1012)
Browse files Browse the repository at this point in the history
* rework the two accordions to be smarter about open and close
* preserve basic auth credentials when reloading from http to https...
  • Loading branch information
epugh committed May 11, 2024
1 parent 3abdfef commit 7a22150
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 42 deletions.
38 changes: 33 additions & 5 deletions app/assets/javascripts/controllers/wizardModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ angular.module('QuepidApp')
$uibModalInstance.dismiss('cancel');
};


$scope.shouldCreateNewSearchEndpointDefaultToOpen = false;
$scope.shouldExistingSearchEndpointDefaultToOpen = false;
$scope.searchEndpoints = [];
$scope.isStaticCollapsed = true;
$scope.addedStaticQueries = false;
$scope.listOfStaticQueries = [];
Expand All @@ -39,7 +41,7 @@ angular.module('QuepidApp')
$scope.wizardSettingsModel.settingsId = function() {
return settingsSvc.settingsId();
};

searchEndpointSvc.list()
.then(function() {
$scope.searchEndpoints = searchEndpointSvc.searchEndpoints;
Expand All @@ -52,6 +54,11 @@ angular.module('QuepidApp')
});

$scope.listSearchEndpoints = function() {
// we only want the search endpoint dialgue to default to open
// if we are not reloading and have search endpoints.
if (!angular.isDefined($location.search().searchEngine)){
$scope.shouldCreateNewSearchEndpointDefaultToOpen = false;
}
return $scope.searchEndpoints;
};

Expand Down Expand Up @@ -110,6 +117,9 @@ angular.module('QuepidApp')
if (angular.isDefined($location.search().apiMethod)){
$scope.pendingWizardSettings.apiMethod = $location.search().apiMethod;
}
if (angular.isDefined($location.search().basicAuthCredential)){
$scope.pendingWizardSettings.basicAuthCredential = $location.search().basicAuthCredential;
}
$scope.reset();
};

Expand Down Expand Up @@ -182,9 +192,22 @@ angular.module('QuepidApp')

// used when you click the accordion for new search endpoint
$scope.switchToCreateNewSearchEndpoint = function() {
$scope.pendingWizardSettings.searchEndpointId = null;

$scope.pendingWizardSettings.searchEndpointId = null;
};



if (angular.isDefined($location.search().searchEngine)) {
// Changing http(s), so we should be open.
if (angular.isDefined($location.search().existingSearchEndpoint)) {
// We were on the Existing Search Endpoint
$scope.shouldExistingSearchEndpointDefaultToOpen = true;
}
else {
$scope.shouldCreateNewSearchEndpointDefaultToOpen = true;
}
}


$scope.validate = validate;
$scope.skipValidation = skipValidation;
Expand Down Expand Up @@ -417,7 +440,12 @@ angular.module('QuepidApp')
$scope.quepidUrlToSwitchTo = resultsTuple[0];
$scope.protocolToSwitchTo = resultsTuple[1];

$scope.quepidUrlToSwitchTo = $scope.quepidUrlToSwitchTo + '?searchEngine=' + $scope.pendingWizardSettings.searchEngine + '&searchUrl=' + $scope.pendingWizardSettings.searchUrl + '&showWizard=true&caseName=' + $scope.pendingWizardSettings.caseName + '&apiMethod=' + $scope.pendingWizardSettings.apiMethod;
$scope.quepidUrlToSwitchTo = `${$scope.quepidUrlToSwitchTo}?showWizard=true` +
`&searchEngine=${$scope.pendingWizardSettings.searchEngine}` +
`&searchUrl=${$scope.pendingWizardSettings.searchUrl}` +
`&caseName=${$scope.pendingWizardSettings.caseName}` +
`&apiMethod=${$scope.pendingWizardSettings.apiMethod}` +
`&basicAuthCredential=${$scope.pendingWizardSettings.basicAuthCredential}`;
}
}
}
Expand Down
80 changes: 48 additions & 32 deletions app/assets/templates/views/wizardModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,9 @@ <h2>Name Your Case!</h2>
<h2>What Search Endpoint do you want to connect to?</h2>
<div>
<uib-accordion>
<div uib-accordion-group class="panel-default" heading="Use an existing Search Endpoint" >
<div class="row">
<div class="alert alert-warning" role="alert" ng-if="listSearchEndpoints().length === 0">
You do not have any Search Endpoints created yet.
</div>
<select
id="searchEndpoint"
ng-if="listSearchEndpoints().length > 0"
ng-model="pendingWizardSettings.searchEndpointId"
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>
</div>
</div>
</div>
<div uib-accordion-group class="panel-default" heading="Create a new Search Endpoint" ng-click="switchToCreateNewSearchEndpoint()">
<div uib-accordion-group class="panel-default" heading="Create a new Search Endpoint"
is-open="shouldCreateNewSearchEndpointDefaultToOpen"
ng-click="switchToCreateNewSearchEndpoint()">
<div style="text-align: center;">
<label style="margin-right: 25px;">
<input type="radio" value="solr" ng-model="pendingWizardSettings.searchEngine" ng-change="changeSearchEngine()">
Expand Down Expand Up @@ -407,6 +378,51 @@ <h2>CSV</h2>


</div>
<div uib-accordion-group class="panel-default" heading="Use an existing Search Endpoint" is-open="shouldExistingSearchEndpointDefaultToOpen">
<div class="row">
<div class="alert alert-warning" role="alert" ng-if="listSearchEndpoints().length === 0">
You do not have any Search Endpoints created yet.
</div>
<select
id="searchEndpoint"
ng-if="listSearchEndpoints().length > 0"
ng-model="pendingWizardSettings.searchEndpointId"
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 ng-show="showTLSChangeWarning" class="alert alert-warning">
<span>
You have specified a search endpoint url that is on a different protocol ( <code>{{protocolToSwitchTo}}</code> ) than Quepid is running,
and this triggers your browser to prevent communciation with the search endpoint. Option 1: Reload Quepid to run on the correct protocol
or Option 2: Proxy the requests THROUGH the Quepid server.
</span>
</div>
<div class="row" style="margin-top: 50px;">

<div class="pull-right">
<button class="btn btn-primary pull-right continue" ng-show="!showTLSChangeWarning" 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>

<span ng-show="showTLSChangeWarning">
<a href="{{quepidUrlToSwitchTo}}&existingSearchEndpoint=true" class="btn btn-primary form-control">
<span class="glyphicon glyphicon-refresh"></span> Reload Quepid in <code>{{protocolToSwitchTo}}</code> Protocol
</a>
</span>
</div>
</div>
</div>

</uib-accordion>
<br><br><br><br>
</div>
Expand Down
7 changes: 4 additions & 3 deletions app/controllers/core_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ def populate_from_params
if params[:searchEngine].present?

search_endpoint_params = {
search_engine: params[:searchEngine],
endpoint_url: params[:searchUrl],
api_method: params[:apiMethod],
search_engine: params[:searchEngine],
endpoint_url: params[:searchUrl],
api_method: params[:apiMethod],
basic_auth_credential: params[:basicAuthCredential],

}
search_endpoint = SearchEndpoint.find_or_create_by search_endpoint_params
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
app:
container_name: quepid_app
Expand Down

0 comments on commit 7a22150

Please sign in to comment.