Andrew Kane 8 éve
szülő
commit
886e170fa0

+ 26 - 1
app/assets/javascripts/blazer/routes.js.erb

@@ -1 +1,26 @@
-<%= JsRoutes.generate(engine: Blazer::Engine, prefix: Blazer::Engine.app.url_helpers.root_path) %>
+<%#= JsRoutes.generate(engine: Blazer::Engine, prefix: Blazer::Engine.app.url_helpers.root_path) %>
+
+// temp fix
+var Routes = {
+  run_queries_path: function() {
+    return gon.root_path + "queries/run"
+  },
+  cancel_queries_path: function() {
+    return gon.root_path + "queries/cancel"
+  },
+  schema_queries_path: function(params) {
+    return gon.root_path + "queries/schema?data_source=" + params.data_source
+  },
+  tables_queries_path: function(params) {
+    return gon.root_path + "queries/tables?data_source=" + params.data_source
+  },
+  queries_path: function() {
+    return gon.root_path + "queries"
+  },
+  query_path: function(id) {
+    return gon.root_path + "queries/" + id
+  },
+  dashboard_path: function(id) {
+    return gon.root_path + "dashboards/" + id
+  }
+}

+ 7 - 0
app/controllers/blazer/base_controller.rb

@@ -19,6 +19,7 @@ module Blazer
     if Blazer.before_action
       before_action Blazer.before_action.to_sym
     end
+    before_action :set_js_routes
 
     layout "blazer/application"
 
@@ -101,5 +102,11 @@ module Blazer
       action = resource.persisted? ? :edit : :new
       render action, status: :unprocessable_entity
     end
+
+    def set_js_routes
+      gon.push(
+        root_path: root_path
+      )
+    end
   end
 end