Skip to content

Commit

Permalink
Merge pull request #168 from tripal/fix-base
Browse files Browse the repository at this point in the history
Fix base url issue
  • Loading branch information
almasaeed2010 committed Feb 9, 2018
2 parents ae94189 + 4d8ea33 commit 4e5ba04
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
10 changes: 8 additions & 2 deletions includes/tripal_elasticsearch.connection.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,15 @@ function elasticsearch_connection_form($form, &$form_state) {
];
}

global $base_url;

drupal_add_js(drupal_get_path('module', 'tripal_elasticsearch') . '/js/axios.min.js');
drupal_add_js(drupal_get_path('module', 'tripal_elasticsearch') . '/js/tripal_elasticsearch.js');
drupal_add_js(['remotes' => $remotes, 'action' => 'getStatus'], 'setting');
drupal_add_js([
'remotes' => $remotes,
'action' => 'getStatus',
'base' => $base_url,
], 'setting');

return $form;
}
Expand Down Expand Up @@ -365,4 +371,4 @@ function remote_edit_confirm_submit($form, &$form_state) {
drupal_set_message(t('Remote server ' . $label . ' has been edited successfully.'));
drupal_goto("admin/tripal/extension/tripal_elasticsearch");
}
}
}
5 changes: 4 additions & 1 deletion includes/tripal_elasticsearch.gene_search.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* @param $form_state
*/
function tripal_elasticsearch_gene_search_form($form, &$form_state, $local = TRUE, $organism = NULL, $url_query = []) {
global $base_url;

$constructed_url = '';
$i = 0;
foreach ($url_query as $key => $value) {
Expand Down Expand Up @@ -125,6 +127,7 @@ function tripal_elasticsearch_gene_search_form($form, &$form_state, $local = TRU
'remotes' => $remotes,
'action' => 'setupTableIndexPage',
'index' => 'gene_search_index',
'base' => $base_url,
], 'setting');
drupal_add_js(drupal_get_path('module', 'tripal_elasticsearch') . '/js/tripal_elasticsearch.js');
}
Expand Down Expand Up @@ -389,4 +392,4 @@ function tripal_elasticsearch_put_fasta_line($name, $sequence, array $meta = [])
$line .= "\n";

return "{$line}{$sequence}\n";
}
}
9 changes: 5 additions & 4 deletions js/tripal_elasticsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

this.settings = settings;

var base = settings.base;
this.axios = window.axios.create({
baseURL: '/elasticsearch/api/v1',
baseURL: base + '/elasticsearch/api/v1',
timeout: 20000,
headers: {
'Accept': 'application/json',
Expand Down Expand Up @@ -63,7 +64,8 @@
$('#remote-host-' + remote.id).html(data.status);
if (data.healthy) {
$('#remote-host-' + remote.id + '-circle').addClass('is-success');
} else {
}
else {
$('#remote-host-' + remote.id + '-circle').addClass('is-danger');
}
}).catch(function (error) {
Expand Down Expand Up @@ -380,7 +382,6 @@
block.html(statsBlock);
block.append(resultsBlock);
block.append(this.state.footerBlock);

this.remotes.map(function (remote) {
var block = this.createSiteBlock(remote);
resultsBlock.append(block);
Expand Down Expand Up @@ -495,4 +496,4 @@
return window.location.pathname + url;
}
};
}(jQuery));
}(jQuery));
5 changes: 4 additions & 1 deletion tripal_elasticsearch.ws.inc
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ function tripal_elasticsearch_api_v1_categories() {
* @return mixed
*/
function tripal_elasticsearch_cross_site_search_form($form, &$form_state) {
global $base_url;

$form['options'] = [
'#type' => 'fieldset',
'#attributes' => [
Expand Down Expand Up @@ -447,6 +449,7 @@ function tripal_elasticsearch_cross_site_search_form($form, &$form_state) {
drupal_add_js([
'remotes' => $remotes,
'action' => 'setupSearchPage',
'base' => $base_url,
], 'setting');

return $form;
Expand All @@ -466,4 +469,4 @@ function tripal_elasticsearch_get_local_server_entry() {
'description' => '',
'url' => $base_url,
];
}
}

0 comments on commit 4e5ba04

Please sign in to comment.