Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set basic auth in ajax headers #3184

Merged
merged 2 commits into from
Jul 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions shared/admin/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var currentlySelectedDatabase = null;

// connection settings for the server, with sensible defaults
var connectionSettings = {
hostname: "localhost",
hostname: (window.location.hostname ? window.location.hostname: "localhost"),
port: "8086",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could pull the port here as well?

username: "",
password: "",
Expand All @@ -19,6 +19,14 @@ var connectionString = function() {
var protocol = (connectionSettings.ssl ? "https" : "http");
var host = connectionSettings.hostname + ":" + connectionSettings.port;

if (connectionSettings.username !== "") {
$.ajaxSetup({
headers: {
'Authorization': "Basic " + btoa(connectionSettings.username + ":" + connectionSettings.password)
}
});
}

return protocol + "://" + host;
}

Expand All @@ -27,7 +35,7 @@ var getSeriesFromJSON = function(data) {
return results;
}

// gets settings from the browser's localStorage and sets defaults if they aren't found
// gets settings from the browser's localStorage and sets defaults if they aren't found
var loadSettings = function() {
var cs = localStorage.getItem("connectionSettings");

Expand Down Expand Up @@ -166,7 +174,7 @@ var handleSubmit = function(e) {
}

var values = series[0].values;

if ((values == null) || (values.length == 0)) {
showQueryError("Query returned no results!");
} else {
Expand Down Expand Up @@ -242,11 +250,11 @@ var stringifyTags = function(tags) {
var DataTable = React.createClass({
render: function() {
var tables = this.props.series.map(function(series) {
return React.createElement("div", null,
React.createElement("h1", null, series.name),
React.createElement("h2", null, stringifyTags(series.tags)),
React.createElement("table", {className: "table"},
React.createElement(TableHeader, {data: series.columns}),
return React.createElement("div", null,
React.createElement("h1", null, series.name),
React.createElement("h2", null, stringifyTags(series.tags)),
React.createElement("table", {className: "table"},
React.createElement(TableHeader, {data: series.columns}),
React.createElement(TableBody, {data: series})
)
);
Expand Down Expand Up @@ -293,7 +301,7 @@ var chooseDatabase = function (databaseName) {

var getDatabases = function () {
var q = "SHOW DATABASES";

var query = $.get(connectionString() + "/query", {q: q, db: currentlySelectedDatabase}, function() {
hideDatabaseWarning();
});
Expand All @@ -320,7 +328,7 @@ var getDatabases = function () {

var series = getSeriesFromJSON(data);
var values = series[0].values;

if ((values == null) || (values.length == 0)) {
availableDatabases = [];
updateDatabaseList();
Expand Down
2 changes: 1 addition & 1 deletion statik/statik.go

Large diffs are not rendered by default.