Skip to content

Commit

Permalink
Mostly working devQueryParams..!
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Sep 13, 2023
1 parent 949f6ee commit 64566f2
Show file tree
Hide file tree
Showing 18 changed files with 117 additions and 122 deletions.
Binary file added app/assets/images/vectara-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions app/assets/javascripts/controllers/mainCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ angular.module('QuepidApp')
};

var getSearchEngine = function(tryNo) {
var sett = settingsSvc.editableSettings();
if (sett.hasOwnProperty('getTry')) {
var aTry = sett.getTry(tryNo);
var settings = settingsSvc.editableSettings();
if (settings.hasOwnProperty('getTry')) {
var aTry = settings.getTry(tryNo);
if (aTry) {
return aTry.searchUrl;
}
Expand Down
25 changes: 24 additions & 1 deletion app/assets/javascripts/controllers/queryParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,22 @@ angular.module('QuepidApp')

$scope.showTLSChangeWarning = false;

$scope.searchEndpoints = searchEndpointSvc.list();
$scope.haveSearchEndpoints = false;

searchEndpointSvc.list()
.then(function() {
$scope.searchEndpoints = searchEndpointSvc.searchEndpoints;
if ($scope.searchEndpoints.length > 0) {
$scope.haveSearchEndpoints = true;
}
else {
$scope.haveSearchEndpoints = false;
}
});

$scope.listSearchEndpoints = function() {
return $scope.searchEndpoints;
};

$scope.validateSearchEngineUrl = function() {
if (!angular.isUndefined($scope.settings.searchUrl)){
Expand Down Expand Up @@ -95,6 +110,8 @@ angular.module('QuepidApp')
name: $scope.settings.selectedTry.name,
number_of_rows: $scope.settings.selectedTry.numberOfRows,
query_params: $scope.settings.selectedTry.queryParams,
search_endpoint_id: $scope.settings.selectedTry.searchEndpointId,
endpoint_name: $scope.settings.selectedTry.endpointName,
search_engine: $scope.settings.selectedTry.searchEngine,
search_url: $scope.settings.selectedTry.searchUrl,
try_number: $scope.settings.selectedTry.tryNo,
Expand All @@ -108,5 +125,11 @@ angular.module('QuepidApp')
$scope.settings.reset();
$scope.validateSearchEngineUrl();
};

$scope.changeSearchEngine2 = function() {
console.log("In changeSearchEngine2 and we don't do anything here!");
//$scope.settings.reset();
//$scope.validateSearchEngineUrl();
};
}
]);
33 changes: 23 additions & 10 deletions app/assets/javascripts/controllers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,45 @@

angular.module('QuepidApp')
.controller('SettingsCtrl', [
'$scope',
'$location',
'$scope','$location',
'flash',
'settingsSvc',
function ($scope, $location, flash, settingsSvc) {
function (
$scope, $location,
flash,
settingsSvc
) {
$scope.settingsModel = {};
$scope.pendingSettings = {
searchEngine: '',
searchUrl: '',
titleField: ''
titleField: '',
searchEndpointId: ''
};


$scope.whoami = function() {
console.log("I am settings.js");
}

$scope.settingsModel.settingsId = function() {
return settingsSvc.settingsId();
};

var reset = function() {
var currSettings = settingsSvc.editableSettings();
if ( this.searchEngine !== currSettings.searchEngine) {
currSettings = settingsSvc.pickSettingsToUse($scope.pendingSettings.searchEngine, null);
currSettings.fieldSpec = currSettings.fieldSpec + ', ' + currSettings.additionalFields.join(', ');
$scope.pendingSettings.urlFormat = currSettings.urlFormat;
if ( this.searchEndpointId !== currSettings.searchEndpointId) {
console.log("We don't do this anymore");
//currSettings = settingsSvc.pickSettingsToUse($scope.pendingSettings.searchEngine, null);
//currSettings.fieldSpec = currSettings.fieldSpec + ', ' + currSettings.additionalFields.join(', ');
//$scope.pendingSettings.urlFormat = currSettings.urlFormat;
}
this.searchEndpointId = currSettings.searchEndpointId;
this.endpointName = currSettings.endpointName;
this.searchEngine = currSettings.searchEngine;
this.apiMethod = currSettings.apiMethod;
//this.apiMethod = currSettings.apiMethod;


if (false){
if (this.searchEngine === 'solr') {
var quepidStartsWithHttps = $location.protocol() === 'https';
if (quepidStartsWithHttps === true){
Expand All @@ -42,6 +54,7 @@ angular.module('QuepidApp')
else {
this.searchUrl = currSettings.searchUrl;
}
}


this.fieldSpec = currSettings.fieldSpec;
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/factories/TryFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@
self.numberOfRows = data.number_of_rows;
self.queryParams = data.query_params;
self.searchEngine = data.search_engine;
self.searchEndpointId = data.search_endpoint_id;
self.endpointName = data.endpoint_name;
self.searchUrl = data.search_url;
self.tryNo = data.try_number;
self.endpointName = data.endpoint_name;



// transform curator vars to be more angular friendly
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/services/settingsSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ angular.module('QuepidApp')
settings.numberOfRows = tryToUse.numberOfRows;
settings.queryParams = tryToUse.queryParams;
settings.searchEngine = tryToUse.searchEngine;
settings.searchEndpointId = tryToUse.searchEndpointId;
settings.searchUrl = tryToUse.searchUrl;

// TODO: Store type in db?...
Expand Down Expand Up @@ -428,6 +429,7 @@ angular.module('QuepidApp')
payloadTry.field_spec = settingsToSave.fieldSpec;
payloadTry.number_of_rows = settingsToSave.numberOfRows;
payloadTry.query_params = settingsToSave.selectedTry.queryParams;
payloadSearchEndpoint.search_endpoint_id = settingsToSave.searchEndpointId;
payloadSearchEndpoint.search_engine = settingsToSave.searchEngine;
payloadSearchEndpoint.endpoint_url = settingsToSave.searchUrl;
payloadSearchEndpoint.api_method = settingsToSave.apiMethod;
Expand Down
153 changes: 51 additions & 102 deletions app/assets/templates/views/devQueryParams.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
<div id="queryParamsCanvas">
<!-- Query Sandbox -->
<div class="settings-tab query-sandbox" ng-show="qp.curTab == 'developer'">
<div class="rerunnable-settings-tab" id='query-params-editor'>
<p ng-if="settings.searchEngine == 'snapshot'">
With a static search endpoint there are no query settings to play with ;-(.
</p>
<div ng-if="settings.searchEngine !== 'snapshot'" class="rerunnable-settings-tab" id='query-params-editor'>
<h4 class="pull-left">Query Sandbox:</h4>
<p class="pull-right">
<a href="http://quepid.com/docs/#tuning" class="query-help" target="_blank">
Expand All @@ -19,11 +22,7 @@ <h4 class="pull-left">Query Sandbox:</h4>
</p>


<div class='clearfix'></div>

<p ng-show="settings.searchEngine == 'snapshot'">
With a static (snapshot) search endpoint there are no query settings to play with ;-(.
</p>
<div class='clearfix'></div>

<p ng-show="showQueryParamsWarning" id="query-params-warn" class="alert alert-warning" ng-bind-html="queryParamsWarning">{{ queryParamsWarning }}</p>

Expand Down Expand Up @@ -59,31 +58,32 @@ <h4 class="pull-left">Query Sandbox:</h4>
<!-- Variables -->
<div class="settings-tab" ng-show="qp.curTab == 'curator'">
<div class="rerunnable-settings-tab">
<p ng-show="settings.selectedTry.curatorVars.length == 0">
What's this tab do? Knobs allow you to fine tune your search!
Define variables in your query template with <code>##</code>, such as this boost: <code>title^##titleBoost##</code>.
Play with the values in this tab. Submit to rerun with the new values!
</p>

<p ng-show="settings.searchEngine == 'snapshot'">
With a static (snapshot) search endpoint there are no tuning knobs to play with ;-(.
</p>

<h4>Tuning Knobs</h4>

<p class="help-block tip">
Add and remove knobs from here by editing your query.
<p ng-if="settings.searchEngine == 'snapshot'">
With a static search endpoint there are tuning knobs to play with ;-(.
</p>
<div ng-repeat="curatorVar in settings.selectedTry.curatorVars">
<div ng-show="curatorVar.inQueryParams" class="slider-wrap clearfix">
<label>{{ curatorVar.name }}:</label>
<input type="number" class="slider-val" min=0 max=10000000000 ng-model="curatorVar.value" auto-grow/>
<p ng-show="curatorVar.inQueryParams != true">
This knob/dial is not currently used by the query!
</p>
<div ng-if="settings.searchEngine !== 'snapshot'">
<p ng-show="settings.selectedTry.curatorVars.length == 0">
What's this tab do? Knobs allow you to fine tune your search!
Define variables in your query template with <code>##</code>, such as this boost: <code>title^##titleBoost##</code>.
Play with the values in this tab. Submit to rerun with the new values!
</p>

<h4>Tuning Knobs</h4>

<p class="help-block tip">
Add and remove knobs from here by editing your query.
</p>
<div ng-repeat="curatorVar in settings.selectedTry.curatorVars">
<div ng-show="curatorVar.inQueryParams" class="slider-wrap clearfix">
<label>{{ curatorVar.name }}:</label>
<input type="number" class="slider-val" min=0 max=10000000000 ng-model="curatorVar.value" auto-grow/>
<p ng-show="curatorVar.inQueryParams != true">
This knob/dial is not currently used by the query!
</p>
</div>
</div>
</div>
</div> <!-- end .rerunnable-settings-tab -->
</div> <!-- end .rerunnable-settings-tab -->
</div>
</div> <!-- end .settings-tab (Variables) -->

<!-- Settings -->
Expand All @@ -95,58 +95,45 @@ <h4>Tuning Knobs</h4>
<div class="rerunnable-settings-tab">
<!-- Search Engine -->
<div class="setting-div">
<div class="dev-header" ng-click="devSettingsSearchEngine.toggle = !devSettingsSearchEngine.toggle">
Search Engine <span ng-class="{true: 'glyphicon-plus-sign', false: 'glyphicon-minus-sign'}[!devSettingsSearchEngine.toggle]" class="glyphicon"></span>
<div class="dev-header" ng-click="devSettingsSearchEndpoint.toggle = !devSettingsSearchEndpoint.toggle">
Search Endpoints <span ng-class="{true: 'glyphicon-plus-sign', false: 'glyphicon-minus-sign'}[!devSettingsSearchEndpoint.toggle]" class="glyphicon"></span>
</div>


<div class="dev-body" ng-show="devSettingsSearchEngine.toggle">
Change Search Engine:<br />
<div>
<label>
<input type="radio" value="solr" ng-model="settings.searchEngine" ng-change="changeSearchEngine()">
Solr
</label>
</div>

<div>
<label>
<input type="radio" value="es" ng-model="settings.searchEngine" ng-change="changeSearchEngine()">
Elasticsearch
</label>
</div>

<div>
<label>
<input type="radio" value="os" ng-model="settings.searchEngine" ng-change="changeSearchEngine()">
OpenSearch
</label>
</div>
<div class="dev-body" ng-show="devSettingsSearchEndpoint.toggle">
Pick Search Endpoint:<br />

settings.searchEndpointId is {{settings.searchEndpointId}}
<div>
<label>
<input type="radio" value="vectara" ng-model="settings.searchEngine" ng-change="changeSearchEngine()">
Vectara
</label>
</div>
<select
ng-model="settings.searchEndpointId"
ng-options="searchEndpoint.id as searchEndpoint.name for searchEndpoint in listSearchEndpoints()"
ng-change="changeSearchEngine2()"
class="form-control"
>
</select>
</div>
</div>
</div>
<!-- end of Search Engine -->

<!-- Search Endpoint -->
<div class="setting-div">
<div class="dev-header" ng-click="devSettingsUrl.toggle = !devSettingsUrl.toggle">
Search Endpoint <span ng-class="{true: 'glyphicon-plus-sign', false: 'glyphicon-minus-sign'}[!devSettingsUrl.toggle]" class="glyphicon"></span>
Endpoint Details <span ng-class="{true: 'glyphicon-plus-sign', false: 'glyphicon-minus-sign'}[!devSettingsUrl.toggle]" class="glyphicon"></span>
</div>

<div class="dev-body" ng-show="devSettingsUrl.toggle">
<input type="text" class="form-control" id="" placeholder="Enter Your Search Engine URL" ng-model="settings.searchUrl" ng-change="validateSearchEngineUrl()">

<p class="help-block tip">
Tip: Your URL should look like this {{settings.urlFormat}}.
<div class="dev-body" ng-show="devSettingsUrl.toggle">

<p>
Name: {{ settings.selectedTry.endpointName }}
</p>
<p>
<a ng-href="search_endpoints/" target="_self">Manage Search Endpoints</a></p>
<img ng-if="settings.selectedTry.searchEngine" ng-src="images/{{ settings.selectedTry.searchEngine }}-icon.png" width="32px" /> &nbsp; {{settings.searchUrl}}
</p>
<p>
<a ng-href="search_endpoints/{{ settings.selectedTry.searchEndpointId }}" target="_self">More</a></p>
<p>

<span ng-show="showTLSChangeWarning">
Expand Down Expand Up @@ -216,44 +203,6 @@ <h4>Tuning Knobs</h4>
</div>
</div>
<!-- end of Escape Queries -->
<!-- API Method -->
<div class="setting-div" ng-show="settings.searchEngine == 'solr'">
<div class="dev-header" ng-click="devSettingsApiMethod.toggle = !devSettingsApiMethod.toggle">
API Method <span ng-class="{true: 'glyphicon-plus-sign', false: 'glyphicon-minus-sign'}[!devSettingsApiMethod.toggle]" class="glyphicon"></span>
</div>

<div class="dev-body checkbox" ng-show="devSettingsApiMethod.toggle">
<label>
API Method
<select class="form-control ng-pristine ng-valid" ng-model="settings.apiMethod" style="margin-bottom: 10px">
<option>JSONP</option>
<option>GET</option>
</select>
</label>

<p class="pull-right">
<span class="label label-info">
<a href="#" uib-tooltip-html="'Use JSONP if you are talking directly to Solr, otherwise if you are talking to an API you can use GET.'" tooltip-placement="left">
<span class="fa fa-question-circle" aria-hidden="true"></span>
</a>
</span>
</p>
</div>
</div>
<!-- end of API Method -->


<!-- Custom Headers -->
<div class="setting-div" ng-show="settings.searchEngine !== 'solr'">
<div class="dev-header" ng-click="devSettingsHeaderToggle = !devSettingsHeaderToggle">
Advanced <span ng-class="{true: 'glyphicon-plus-sign', false: 'glyphicon-minus-sign'}[!devSettingsHeaderToggle]" class="glyphicon"></span>
</div>

<span ng-show="devSettingsHeaderToggle">
<custom-headers class="black-label" settings="settings"></custom-headers>
</span>
</div>
<!-- end of Custom Headers -->

</div> <!-- end .rerunnable-settings-tab -->
</div> <!-- end .settings-tab (Settings) -->
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# name :string(255)
# num_logins :integer
# password :string(120)
# profile_pic :string(255)
# profile_pic :string(4000)
# reset_password_sent_at :datetime
# reset_password_token :string(255)
# stored_raw_invitation_token :string(255)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class CreateSearchEndpointsFromTries < ActiveRecord::Migration[7.0]
def change
puts "Found #{Try.all.where(case_id: nil).count} tries with no Case. Any is bad!"

Try.all.each do |try|
Try.all.where(search_endpoint: nil).limit(10000).each do |try|

# Go through and find each unique set of values from all the tries,
# and create a single end point that is used by multiple tries where it
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ResizeUserProfilePicTo4000Chars < ActiveRecord::Migration[7.0]
def change
change_column :users, :profile_pic, :string, :limit => 4000
end
end
4 changes: 2 additions & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added public/images/es-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/os-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/snapshot-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/solr-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/vectara-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 64566f2

Please sign in to comment.