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

Support relative path #255

Merged
merged 2 commits into from
Aug 8, 2018
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ And some additional packages (Debian / Ubuntu)

Access http://localhost:9292 by web browser.

### Run under sub path

Use `RAILS_RELATIVE_URL_ROOT` environment variable.

$ RAILS_RELATIVE_URL_ROOT=/prefix fluentd-ui start --daemonize

Access http://localhost:9292/prefix by web browser.

## Development

$ git clone https://github.com/fluent/fluentd-ui
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/aws_credential.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const AwsCredential = {
updateSection: function() {
$.ajax({
method: "GET",
url: "/api/config_definitions",
url: `${relativeUrlRoot}/api/config_definitions`,
headers: {
"X-CSRF-Token": this.token
},
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/in_tail_parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ $(document).ready(() => {

this.previewAjax = $.ajax({
method: "POST",
url: "/api/regexp_preview",
url: `${relativeUrlRoot}/api/regexp_preview`,
headers: {
"X-CSRF-Token": this.token
},
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/owned_plugin_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const OwnedPluginForm = {
updateSection: function() {
$.ajax({
method: "GET",
url: "/api/config_definitions",
url: `${relativeUrlRoot}/api/config_definitions`,
headers: {
"X-CSRF-Token": this.token
},
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/packs/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $(document).ready(() => {
},
computed: {
endpoint: function() {
return "/api/settings/" + this.id;
return `${relativeUrlRoot}/api/settings/${this.id}`;
},
token: function() {
return Rails.csrfToken();
Expand Down Expand Up @@ -115,7 +115,7 @@ $(document).ready(() => {
methods: {
update: function() {
this.loading = true;
$.getJSON("/api/settings", (data)=> {
$.getJSON(`${relativeUrlRoot}/api/settings`, (data)=> {
var sources = [];
var matches = [];
data.forEach((v)=> {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/transport_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const TransportConfig = {
}
$.ajax({
method: "GET",
url: "/api/config_definitions",
url: `${relativeUrlRoot}/api/config_definitions`,
headers: {
"X-CSRF-Token": this.token
},
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/transport_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ $(document).ready(() => {
}
$.ajax({
method: "GET",
url: "/api/config_definitions",
url: `${relativeUrlRoot}/api/config_definitions`,
headers: {
"X-CSRF-Token": this.token
},
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/packs/treeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ $(document).ready(() => {
fetchTree: function() {
var self = this;
return new Promise(function(resolve, reject) {
$.getJSON("/api/tree?path=" + self.path, resolve).fail(reject);
$.getJSON(`${relativeUrlRoot}/api/tree?path=${self.path}`, resolve).fail(reject);
}).then(function(paths){
console.log(paths);
self.paths = paths;
Expand All @@ -78,7 +78,7 @@ $(document).ready(() => {
var self = this;
this.preview = "";
new Promise(function(resolve, reject) {
$.getJSON("/api/file_preview?file=" + self.selected.path, resolve).fail(reject);
$.getJSON(`${relativeUrlRoot}/api/file_preview?file=${self.selected.path}`, resolve).fail(reject);
}).catch(function(e){
console.error(e);
}).then(function(lines){
Expand Down
3 changes: 3 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<%= javascript_pack_tag 'notification' %>
<%= content_for(:additional_javascript_pack_tag) %>
<%= csrf_meta_tags %>
<%= javascript_tag do %>
window.relativeUrlRoot = '<%= Rails.application.config.relative_url_root %>';
<% end %>
</head>
<body class="fixed-nav bg-light">
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top" id="mainNav">
Expand Down
4 changes: 3 additions & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
map Rails.application.config.relative_url_root.presence || "/" do
run Rails.application
end