diff --git a/includes/tripal_elasticsearch.connection.form.inc b/includes/tripal_elasticsearch.connection.form.inc index b680b66a..9b3fc662 100644 --- a/includes/tripal_elasticsearch.connection.form.inc +++ b/includes/tripal_elasticsearch.connection.form.inc @@ -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; } @@ -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"); } -} \ No newline at end of file +} diff --git a/includes/tripal_elasticsearch.gene_search.form.inc b/includes/tripal_elasticsearch.gene_search.form.inc index 88e8c1da..9f7caad8 100644 --- a/includes/tripal_elasticsearch.gene_search.form.inc +++ b/includes/tripal_elasticsearch.gene_search.form.inc @@ -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) { @@ -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'); } @@ -389,4 +392,4 @@ function tripal_elasticsearch_put_fasta_line($name, $sequence, array $meta = []) $line .= "\n"; return "{$line}{$sequence}\n"; -} \ No newline at end of file +} diff --git a/js/tripal_elasticsearch.js b/js/tripal_elasticsearch.js index efecb4c1..c041e48d 100644 --- a/js/tripal_elasticsearch.js +++ b/js/tripal_elasticsearch.js @@ -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', @@ -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) { @@ -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); @@ -495,4 +496,4 @@ return window.location.pathname + url; } }; -}(jQuery)); \ No newline at end of file +}(jQuery)); diff --git a/tripal_elasticsearch.ws.inc b/tripal_elasticsearch.ws.inc index 879f7afe..e134a07c 100644 --- a/tripal_elasticsearch.ws.inc +++ b/tripal_elasticsearch.ws.inc @@ -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' => [ @@ -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; @@ -466,4 +469,4 @@ function tripal_elasticsearch_get_local_server_entry() { 'description' => '', 'url' => $base_url, ]; -} \ No newline at end of file +}