Andrew Kane пре 8 година
родитељ
комит
ac88df3676

+ 5 - 0
app/assets/javascripts/blazer/application.js

@@ -321,3 +321,8 @@ function showEditor() {
 
 preventBackspaceNav();
 
+function updatePreviewSelect() {
+  var dataSource = $("#query_data_source").val();
+  $("#tables").load(tablesPath + "?" + $.param({data_source: dataSource}));
+  $("#view-schema").attr("href", schemaPath + "?data_source=" + dataSource);
+}

+ 2 - 4
app/views/blazer/queries/_form.html.erb

@@ -12,17 +12,15 @@
         </div>
       </div>
       <div class="form-group text-right">
-        <div class="pull-left" style="margin-top: 6px;">
+        <div class="pull-left" style="margin-top: 9px;">
           <%= link_to "Back", :back %>
         </div>
+        <%= link_to "Schema", "#", target: "_blank", id: "view-schema", style: "margin-right: 10px;" %>
         <%= f.select :data_source, Blazer.data_sources.values.map { |ds| [ds.name, ds.id] }, {}, class: ("hide" if Blazer.data_sources.size == 1), style: "width: 140px;" %>
         <div id="tables" style="display: inline-block; width: 250px; margin-right: 10px;" class="hide">
           <%= render partial: "tables" %>
         </div>
         <script>
-          function updatePreviewSelect() {
-            $("#tables").load("<%= tables_queries_path %>?" + $.param({data_source: $("#query_data_source").val()}));
-          }
           updatePreviewSelect();
           $("#query_data_source").selectize().change(updatePreviewSelect);
         </script>

+ 2 - 0
app/views/layouts/blazer/application.html.erb

@@ -11,6 +11,8 @@
     <script>
       var runQueriesPath = <%= run_queries_path.to_json.html_safe %>;
       var cancelQueriesPath = <%= cancel_queries_path.to_json.html_safe %>;
+      var schemaPath = <%= schema_queries_path.to_json.html_safe %>;
+      var tablesPath = <%= tables_queries_path.to_json.html_safe %>;
     </script>
     <% if blazer_maps? %>
       <%= stylesheet_link_tag "https://api.mapbox.com/mapbox.js/v2.4.0/mapbox.css" %>