Sha256: 09b4e881659e93715597f8804eb5417f963dbc7ab063f805fc4168b0ea4a2c39

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

<% title "SQL Editor" %>

<%= form_tag :sql_execute do %>
  <h3>Execute SQL</h3>

  <div class='row'>
    <% if @sql_query.valid? %>
      <% if @sql_query.data.is_error? %>
        <div class="large-11">
          <div class='alert-box alert'>
            <%= @sql_query.data.error.message %>
          </div>
        </div>
      <% end %>
    <% end %>

    <div class="large-11">
      <textarea name='sql' id="sql" cols="120" rows="60"><%= @sql %></textarea>
    </div>
  </div>

  <div class="row">
    <div class="large-11">
      <div class='panel execute_panel'>
        <p><span class="radius secondary label">* be careful with your SQL. You may corrupt your DB. Make sure you have DB backup if doing modifications.</span></p>
        <%= submit_tag raw("&rarr; Execute"), class: 'button small' %>
        &nbsp;
        &mdash;
        &nbsp;
        <%= link_to raw("#{fa_icon('undo')} Reset"), :sql, data: {confirm: "Are you sure?"}, confirm: "Are you sure?" %>
        &nbsp;
        &mdash;
        &nbsp;
        <a href="#" data-reveal-id="history_modal" id='history_modal_link'><%= fa_icon('bars') %> History</a></span>
        <%= render 'history' %>
      </div>
    </div>
  </div>

<% end %>

<% if @sql_query.valid? %>
  <%= render 'results', sql_query: @sql_query, sql: @sql %>
<% end %>

<script type="text/javascript">
  var editor = CodeMirror.fromTextArea($('#sql').get(0), {
      "theme": 'pastel-on-dark',
      "lineNumbers": true,
      "mode": "text/x-sql",
      "tabSize": 4,
      height: 'auto',
      extraKeys: {
        'Ctrl-Enter': function() {
          $(editor.getInputField()).parents('form').submit();
        }
      }
    });
  editor.setSize('100%', '300');
  editor.focus();
</script>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_db-0.2.1 app/views/rails_db/sql/index.html.erb
rails_db-0.2 app/views/rails_db/sql/index.html.erb
rails_db-0.1 app/views/rails_db/sql/index.html.erb