Skip to content

Commit

Permalink
Fix urls to conform to new menu
Browse files Browse the repository at this point in the history
  • Loading branch information
almasaeed2010 committed Jan 23, 2018
1 parent f21680b commit 1393963
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 46 deletions.
2 changes: 1 addition & 1 deletion docs/custom-indices.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ these concepts, we recommend you select `standard` for tokenizer and `standard`

## Creating a new custom Index

You can create a new index by clicking on the create Index tab, or navigating to `http://[your-tripal-site-domain]/admin/tripal/extension/tripal_elasticsearch/indices_management/create`.
You can create a new index by clicking on the create Index tab, or navigating to `http://[your-tripal-site-domain]/admin/tripal/extension/tripal_elasticsearch/indices/create`.

For a custom index, you will need to:

Expand Down
2 changes: 1 addition & 1 deletion docs/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
After your database tables get indexed, you can build a search interface for them. Note that search blocks for node, entities, and genes are configured automatically and cannot be customized.
You can choose to expose all table fields or a subset of fields for searching.

The admin page for building search blocks is at `http://[your-tripal-site-domain]/admin/tripal/extension/tripal_elasticsearch/search_form_management`.
The admin page for building search blocks is at `http://[your-tripal-site-domain]/admin/tripal/extension/tripal_elasticsearch/forms`.

![search block](../images/build-search-block.png)

Expand Down
File renamed without changes.
20 changes: 10 additions & 10 deletions includes/tripal_elasticsearch.indices.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ function tripal_elasticsearch_indices_list_page() {
$exposed_text = "public";
}

$edit = l('Edit', 'admin/tripal/extension/tripal_elasticsearch/indices_management/edit/' . $index);
$delete = l('Delete', 'admin/tripal/extension/tripal_elasticsearch/indices_management/delete/' . $index);
$edit = l('Edit', 'admin/tripal/extension/tripal_elasticsearch/indices/edit/' . $index);
$delete = l('Delete', 'admin/tripal/extension/tripal_elasticsearch/indices/delete/' . $index);
$rows[] = [$index, $table, $exposed_text, $edit, $delete];
}

Expand All @@ -392,7 +392,7 @@ function tripal_elasticsearch_indices_list_page() {
'header' => ['Index Name', 'Indexed Table', 'Exposed', 'Edit', 'Delete'],
'rows' => $rows,
]);
$link = l('Create Index', 'admin/tripal/extension/tripal_elasticsearch/indices_management/create');
$link = l('Create Index', 'admin/tripal/extension/tripal_elasticsearch/indices/create');
$output .= '<p>To create a new index, click the ' . $link . ' tab above.</p>';

return $output;
Expand Down Expand Up @@ -605,7 +605,7 @@ function tripal_elasticsearch_index_edit_confirm(
}

if ($index_name == 'website' || $index_name == 'entities' || $index_name == 'gene_search_index') {
$cancel_path = 'admin/tripal/extension/tripal_elasticsearch/indices_management';
$cancel_path = 'admin/tripal/extension/tripal_elasticsearch/indices';

return confirm_form($form, 'Edit Index', $cancel_path, '', 'Submit Edits');
}
Expand Down Expand Up @@ -639,7 +639,7 @@ function tripal_elasticsearch_index_edit_confirm(
}

$description = 'Edit settings for ' . $index_name;
$cancel_path = 'admin/tripal/extension/tripal_elasticsearch/indices_management';
$cancel_path = 'admin/tripal/extension/tripal_elasticsearch/indices';

return confirm_form($form, 'Edit Index', $cancel_path, $description, 'Submit Edits');
}
Expand Down Expand Up @@ -667,7 +667,7 @@ function tripal_elasticsearch_index_edit_confirm_submit($form, &$form_state) {
// No need to delete the index, just need to update the table.
tripal_elasticsearch_update_index_table($form_state['values']);
drupal_set_message("Your index has been updated. Re-indexing is not necessary.");
drupal_goto('admin/tripal/extension/tripal_elasticsearch/indices_management');
drupal_goto('admin/tripal/extension/tripal_elasticsearch/indices');
return;
}
}
Expand Down Expand Up @@ -696,7 +696,7 @@ function tripal_elasticsearch_index_delete_confirm(
) {
$form = [];
$description = 'Are you sure you want to delete the ' . $index_name . ' index?';
$cancel_path = 'admin/tripal/extension/tripal_elasticsearch/indices_management';
$cancel_path = 'admin/tripal/extension/tripal_elasticsearch/indices';
$form['index_name'] = [
'#type' => 'hidden',
'#value' => $index_name,
Expand All @@ -715,7 +715,7 @@ function tripal_elasticsearch_index_delete_confirm_submit($form, &$form_state) {

tripal_elasticsearch_delete_index($index);
drupal_set_message('Index "' . $index . '" deleted successfully.');
drupal_goto('admin/tripal/extension/tripal_elasticsearch/indices_management');
drupal_goto('admin/tripal/extension/tripal_elasticsearch/indices');
}

/** Creates an index. Used by the create and edit index functions.
Expand Down Expand Up @@ -856,9 +856,9 @@ function tripal_elasticsearch_create_index(&$values) {

drupal_set_message("The indexing job for {$index_name} has been submitted to your CRON queue. You can view the status of your CRON jobs at {$cron_url}");
if ($index_type === 'database') {
drupal_set_message("You may create a search block for this index using the " . l('form management', 'admin/tripal/extension/tripal_elasticsearch/search_form_management') . " section.");
drupal_set_message("You may create a search block for this index using the " . l('form management', 'admin/tripal/extension/tripal_elasticsearch/forms') . " section.");
}
drupal_goto('admin/tripal/extension/tripal_elasticsearch/indices_management');
drupal_goto('admin/tripal/extension/tripal_elasticsearch/indices');
}

/**
Expand Down
File renamed without changes.
File renamed without changes.
62 changes: 33 additions & 29 deletions js/tripal_elasticsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@

this.settings = settings;

this.axios = window.axios.create({
this.axios = window.axios.create({
baseURL: '/elasticsearch/api/v1',
timeout: 20000,
headers: {
'Accept' : 'application/json',
'Accept': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
}
});
this.remotes = settings.remotes;
this.state = {
this.state = {
resultsCount: 0,
sitesCount : 0,
emptySites : [],
footerBlock : $('<div />')
sitesCount: 0,
emptySites: [],
footerBlock: $('<div />')
};

this[settings.action]();
Expand All @@ -42,9 +42,9 @@
resetState: function () {
this.state = {
resultsCount: 0,
sitesCount : 0,
emptySites : [],
footerBlock : $('<div />')
sitesCount: 0,
emptySites: [],
footerBlock: $('<div />')
};
},

Expand All @@ -61,7 +61,11 @@
}

$('#remote-host-' + remote.id).html(data.status);
$('#remote-host-' + remote.id + '-circle').addClass('is-success');
if (data.healthy) {
$('#remote-host-' + remote.id + '-circle').addClass('is-success');
} else {
$('#remote-host-' + remote.id + '-circle').addClass('is-danger');
}
}).catch(function (error) {
var response = error.response;
if (response) {
Expand Down Expand Up @@ -97,10 +101,10 @@

$('#tripal-elasticsearch-search-button').click(function (e) {
e.preventDefault();
var form = {};
var form = {};
var category = $('#tripal-elasticsearch-search-category').val();

form.terms = $('#tripal-elasticsearch-search-field').val();
form.terms = $('#tripal-elasticsearch-search-field').val();
form.category = category === 'Any Type' ? null : category;

this.pushHistory(form);
Expand Down Expand Up @@ -135,9 +139,9 @@
*/
sendSearchRequest: function (form) {
this.resetState();
var block = $('#tripal-elasticsearch-results-block');
var block = $('#tripal-elasticsearch-results-block');
var resultsBlock = $('<div />');
var statsBlock = $('<div />', {'class': 'elastic-stats-block'});
var statsBlock = $('<div />', {'class': 'elastic-stats-block'});
block.html(statsBlock);
block.append(resultsBlock);
block.append(this.state.footerBlock);
Expand All @@ -152,9 +156,9 @@

this.axios.get('/search/' + remote.id, {
params: {
terms : form.terms,
terms: form.terms,
category: form.category,
size : 2
size: 2
}
}).then(function (response) {
var data = response.data.data;
Expand Down Expand Up @@ -248,7 +252,7 @@
if (state.category || state.terms) {
var form = {
category: state.category || null,
terms : state.terms
terms: state.terms
};
this.sendSearchRequest(form);
}
Expand All @@ -262,9 +266,9 @@
*/
setupTableIndexPage: function () {
// Get page settings
var index = this.settings.index;
var index = this.settings.index;
var formSelector = '#cross-site-search-form';
var mapper = this.settings.field_mapper || {};
var mapper = this.settings.field_mapper || {};

// Set global variables
this.searchURL = index + '/search';
Expand All @@ -278,9 +282,9 @@
event.preventDefault();
}

var form = $(formSelector);
var form = $(formSelector);
var formData = this.formToObject(form);
var data = this.mapForm(formData, mapper);
var data = this.mapForm(formData, mapper);
this.tableSearch(data);
this.pushHistory(formData);
}.bind(this));
Expand All @@ -293,8 +297,8 @@
*/
initHistory: function (mapper) {
var formSelector = '#cross-site-search-form';
var data = this.mapForm(this.formToObject($(formSelector)), mapper);
var has_values = false;
var data = this.mapForm(this.formToObject($(formSelector)), mapper);
var has_values = false;
Object.keys(data).map(function (element) {
if (typeof data[element] === 'string') {
if (data[element].length > 0) {
Expand All @@ -316,11 +320,11 @@
*/
formToObject: function (form) {
var formData = form.serializeArray();
var data = {};
var data = {};

// Prepare form data
Object.keys(formData).map(function (key) {
var element = formData[key];
var element = formData[key];
data[element.name] = element.value;
});

Expand Down Expand Up @@ -370,9 +374,9 @@
*/
tableSearch: function (data) {
this.resetState();
var block = $('#tripal-elasticsearch-results-block');
var block = $('#tripal-elasticsearch-results-block');
var resultsBlock = $('<div />');
var statsBlock = $('<div />', {'class': 'elastic-stats-block'});
var statsBlock = $('<div />', {'class': 'elastic-stats-block'});
block.html(statsBlock);
block.append(resultsBlock);
block.append(this.state.footerBlock);
Expand Down Expand Up @@ -422,7 +426,7 @@
* @private
*/
_squish: function () {
var text = $(this).html();
var text = $(this).html();
var array = text.split('<br>');

if (array.length > 2) {
Expand All @@ -433,7 +437,7 @@
div.append(hidden);
div.append('<br>');
var btn = $('<button />', {
'type' : 'button',
'type': 'button',
'class': 'btn btn-secondary btn-sm'
}).html('Show More')
.click(function (e) {
Expand Down
10 changes: 5 additions & 5 deletions tripal_elasticsearch.module
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
*/

require 'tripal_elasticsearch.api.inc';
require 'tripal_elasticsearch.ws.inc';
require 'includes/tripal_elasticsearch.search_forms.form.inc';
require 'includes/search_box.form.inc';
require 'includes/tripal_elasticsearch.website_search.form.inc';
require 'includes/tripal_elasticsearch.indices.form.inc';
require 'includes/gene_search.form.inc';
require 'tripal_elasticsearch.ws.inc';
require 'includes/tuning.form.inc';
require 'includes/tripal_elasticsearch.gene_search.form.inc';
require 'includes/tripal_elasticsearch.tuning.form.inc';
require 'includes/tripal_elasticsearch.fields.inc';
require 'includes/tripal_elasticsearch.collections.form.inc';

Expand Down Expand Up @@ -65,7 +65,7 @@ function tripal_elasticsearch_menu() {
'file' => 'includes/tripal_elasticsearch.connection.form.inc',
'file_path' => drupal_get_path('module', 'tripal_elasticsearch'),
'type' => MENU_LOCAL_TASK,
'weight' => 0
'weight' => 0,
];


Expand Down

0 comments on commit 1393963

Please sign in to comment.