Skip to content

Commit f314469

Browse files
committed
#364 support base_uri,usename,password url parameters
1 parent 781124d commit f314469

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

src/_site/controllers.js

+8-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
1-
// fetch settings
2-
var settings = {};
3-
$.ajax({
4-
type: 'GET',
5-
url: './sql_external_settings.json',
6-
dataType: 'json',
7-
async: false
8-
}).done(function (data) {
9-
try {
10-
Object.keys(data).forEach(function (setting) {
11-
settings[setting] = data[setting];
12-
});
13-
} catch (error) {
14-
throw {message: 'Error processing external settings', body: data};
15-
}
16-
}).fail(function (error) {
17-
throw {message: 'Error fetching external settings from file', body: error};
18-
});
1+
// settings
2+
var settings = location.search.substring(1).split("&").reduce(function (r, p) {
3+
r[decodeURIComponent(p.split("=")[0])] = decodeURIComponent(p.split("=")[1]);
4+
return r;
5+
}, {});
196

207
var elasticsearchSqlApp = angular.module('elasticsearchSqlApp', ["ngAnimate", "ngSanitize"]);
218

@@ -417,6 +404,9 @@ function updateWithScrollIfNeeded (query) {
417404
if(url == undefined) {
418405
if (settings['base_uri']) {
419406
url = settings['base_uri'];
407+
if (url.indexOf('http://') !== 0 && url.indexOf('https://') !== 0) {
408+
url = 'http://' + url;
409+
}
420410
} else if (location.protocol == "file") {
421411
url = "http://localhost:9200"
422412
}

src/_site/sql_external_settings.json

-5
This file was deleted.

0 commit comments

Comments
 (0)