sql-jarvis 2.0.6 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17e9fc90e06d4ce4b4697388ffcc1cc7354344eda424f8eb325d3a05e1ecbae9
4
- data.tar.gz: 5777e0cf364e307cc5914d1753bf8f7d0d2ebb8c9a3541c982085969d275343f
3
+ metadata.gz: 9773e38d1a1c2c0c16a2b29975123204eb42159922b81e5144c9ed585b27a573
4
+ data.tar.gz: 1038744af4afa79645d42630a4788d6012f99ee4d3bab734f6905898495446f4
5
5
  SHA512:
6
- metadata.gz: 61685abff8d8f41652123b2d65eda3be1b652433c74b574b03112b254ca711e88bf34f18e4e84381c06ca99ac20b129e8f400f232023a70fbb44025b7191df58
7
- data.tar.gz: f31e00ff500173fdeac4c5a8c2b884567d11171102ae9943aa2258bc6768009bcd31884c579df07dcaec638519802ab63e9848baa4cc95c96e399e859e909e6d
6
+ metadata.gz: 4e4d6bb6cbbb890522bc157f6edb6873ac140203ed0c11eb0094d4d12132fd1a51b3e7cbf311a6dd99c42f3cdc6df926a7052a38d2fe9940011aa6bdfae4c669
7
+ data.tar.gz: 0e6250d227218b5929ad30dd6ef27827dd74bb26995789a809a485da512b61aade48996b5694cc3729bb24a43e833ce8ee99e5f3011be145578ec495999e2e72
@@ -233,3 +233,7 @@ h2 {
233
233
  .schema-table {
234
234
  max-width: 500px;
235
235
  }
236
+
237
+ ul#proTip li {
238
+ display: none;
239
+ }
@@ -1,7 +1,7 @@
1
1
  module Blazer
2
2
  class QueriesController < BaseController
3
3
  before_action :set_query, only: [:show, :edit, :update, :destroy, :refresh]
4
- before_action :set_data_source, only: [:tables, :docs, :schema, :cancel, :columns]
4
+ before_action :set_data_source, only: [:new, :edit, :tables, :docs, :schema, :cancel, :columns]
5
5
  before_action :set_assignees, only: [:new, :create, :show, :edit, :update, :destroy, :refresh]
6
6
 
7
7
  def home
@@ -39,6 +39,9 @@ module Blazer
39
39
  )
40
40
  if params[:fork_query_id]
41
41
  @query.statement ||= Blazer::Query.find(params[:fork_query_id]).try(:statement)
42
+ else
43
+ statement_from_cache = Rails.cache.read [:jarvis, blazer_user, request.url.parameterize]
44
+ @query.statement ||= statement_from_cache
42
45
  end
43
46
  end
44
47
 
@@ -71,6 +74,13 @@ module Blazer
71
74
  end
72
75
 
73
76
  def edit
77
+ statement_from_cache = Rails.cache.read [:jarvis, blazer_user, request.url.parameterize]
78
+ @query.statement = statement_from_cache
79
+ end
80
+
81
+ def backup
82
+ Rails.cache.write [:jarvis, blazer_user, request.referrer.parameterize], params[:sql_query]
83
+ render json: { success: true }, status: 200
74
84
  end
75
85
 
76
86
  def run
@@ -15,7 +15,6 @@
15
15
  <div class="form-group text-right" style="margin-bottom: 8px;">
16
16
  <div class="pull-left" style="margin-top: 8px;">
17
17
  <%= link_to "Back", :back %>
18
- <a :href="docsPath" target="_blank" style="margin-left: 40px;">Docs</a>
19
18
  <a :href="schemaPath" target="_blank" style="margin-left: 40px;">Schema</a>
20
19
  </div>
21
20
 
@@ -62,6 +61,8 @@
62
61
  </div>
63
62
  <% end %>
64
63
  <% end %>
64
+ <hr>
65
+ <%= render partial: "tips" %>
65
66
  </div>
66
67
  </div>
67
68
  <% end %>
@@ -305,8 +306,32 @@
305
306
  }
306
307
  })
307
308
 
309
+ function backupSQL() {
310
+ $.ajax({
311
+ url: "<%= backup_queries_path %>",
312
+ method: 'POST',
313
+ data: {
314
+ sql_query: $('#query_statement').val()
315
+ }
316
+ })
317
+ }
318
+
308
319
  $(document).ready(function() {
309
320
  $('#query_assignee_ids').select2();
321
+ setInterval(function() {
322
+ var lastVersion = $('#query_statement').val();
323
+ if (localStorage.getItem('lastVersion') !== lastVersion) {
324
+ localStorage.setItem('lastVersion', lastVersion);
325
+ }
326
+ }, 10000);
327
+ });
328
+
329
+ $(document).keydown(function(event) {
330
+ if ((event.ctrlKey || event.metaKey) && event.which == 83) {
331
+ backupSQL();
332
+ event.preventDefault();
333
+ return false;
334
+ }
310
335
  });
311
336
 
312
337
  </script>
@@ -0,0 +1,69 @@
1
+ <small class='text-muted'>
2
+ <h5>
3
+ <i class="far fa-lightbulb"></i>
4
+ ProTip!
5
+ <%= link_to 'more...', docs_queries_path, target: :_blank, style: "float: right; font-weight: 200" %>
6
+ </h5>
7
+ <ul class='list-unstyled' id='proTip'>
8
+ <li>
9
+ <strong>Command + S</strong> to backup your SQL string.
10
+ </li>
11
+ <li>
12
+ Set column name to <strong>*_date</strong> to format DateTime to <strong><%= Time.current.strftime('%Y/%m/%d') %></strong>
13
+ </li>
14
+ <li>
15
+ Set column name to <strong>*_time</strong> to format DateTime to <strong><%= Time.current.strftime('%H:%M') %></strong>
16
+ </li>
17
+
18
+ <% if @data_source.smart_variables.any? %>
19
+ <% @data_source.smart_variables.keys.each do |key| %>
20
+ <li>
21
+ <strong><i class="fas fa-caret-square-down"></i></strong>
22
+ Use <code>{<%= key %>}</code> to get a dropdown of values.
23
+ </li>
24
+ <% end %>
25
+ <li>
26
+ <strong><i class="fas fa-caret-square-down"></i></strong>
27
+ Use <code>{start_time}</code> and <code>{end_time}</code> for a date range selector.
28
+ </li>
29
+ <li>
30
+ <strong><i class="fas fa-caret-square-down"></i></strong>
31
+ End a variable name with <code>_at</code> for a date selector.
32
+ </li>
33
+ <% end %>
34
+
35
+ <li>
36
+ <strong><i class="fas fa-chart-line"></i> Chart:</strong>
37
+ 2+ columns - timestamp, numeric(s)</li>
38
+ <li>
39
+ <strong><i class="fas fa-chart-line"></i> Chart:</strong>
40
+ 3 columns - timestamp, string, numeric
41
+ </li>
42
+ <li>
43
+ <strong><i class="far fa-chart-bar"></i> Chart:</strong>
44
+ 2+ columns - string, numeric(s)
45
+ </li>
46
+ <li>
47
+ <strong><i class="far fa-chart-bar"></i> Chart:</strong>
48
+ 3 columns - string, string, numeric
49
+ </li>
50
+ <li>
51
+ <strong>Scatter Chart:</strong>
52
+ 2 columns - both numeric
53
+ </li>
54
+ <li>
55
+ <strong><i class="fas fa-chart-pie"></i> Chart:</strong>
56
+ 2 columns - string, numeric - and last column named <code>pie</code>
57
+ </li>
58
+ <li>
59
+ <strong><i class="fas fa-globe-americas"></i> Chart:</strong>
60
+ Named <code>latitude</code> and <code>longitude</code>, or <code>lat</code> and <code>lon</code>, or <code>lat</code> and <code>lng</code>
61
+ </li>
62
+ <ul>
63
+ </small>
64
+
65
+ <script>
66
+ var itemCount = $('ul#proTip li').length;
67
+ var showIndex = Math.floor(Math.random() * Math.floor(itemCount)) + 1;
68
+ $("ul#proTip li:nth-child(" + showIndex + ")").show();
69
+ </script>
@@ -10,6 +10,7 @@
10
10
  <script>
11
11
  <%= blazer_js_var "rootPath", root_path %>
12
12
  </script>
13
+ <script defer src="https://use.fontawesome.com/releases/v5.8.2/js/all.js" integrity="sha384-DJ25uNYET2XCl5ZF++U8eNxPWqcKohUUBUpKGlNLMchM7q4Wjg2CUpjHLaL8yYPH" crossorigin="anonymous"></script>
13
14
  <% if blazer_maps? %>
14
15
  <%= stylesheet_link_tag "https://api.mapbox.com/mapbox.js/v3.1.1/mapbox.css", integrity: "sha384-o8tecBIfqi9yU5yYK2Ne/9A9hlOGFV9MBvCpmemvJH1XxqOe6h8Bl4mLxMi6PgjG", crossorigin: "anonymous" %>
15
16
  <%= javascript_include_tag "https://api.mapbox.com/mapbox.js/v3.1.1/mapbox.js", integrity: "sha384-j81LqvtvYigFzGSUgAoFijpvoq4yGoCJSOXI9DFaUEpenR029MBE3E/X5Gr+WdO0", crossorigin: "anonymous" %>
data/config/routes.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  Blazer::Engine.routes.draw do
2
2
  resources :queries do
3
+ post :refresh, on: :member
3
4
  post :run, on: :collection # err on the side of caution
4
5
  post :cancel, on: :collection
5
- post :refresh, on: :member
6
+ post :backup, on: :collection
6
7
  get :tables, on: :collection
7
8
  get :columns, on: :collection
8
9
  get :schema, on: :collection
@@ -17,5 +18,5 @@ Blazer::Engine.routes.draw do
17
18
  post :refresh, on: :member
18
19
  end
19
20
 
20
- root to: "queries#home"
21
+ root to: 'queries#home'
21
22
  end
@@ -1,3 +1,3 @@
1
1
  module Blazer
2
- VERSION = '2.0.6'
2
+ VERSION = '2.0.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sql-jarvis
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-19 00:00:00.000000000 Z
11
+ date: 2019-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -211,6 +211,7 @@ files:
211
211
  - app/views/blazer/dashboards/new.html.erb
212
212
  - app/views/blazer/dashboards/show.html.erb
213
213
  - app/views/blazer/queries/_form.html.erb
214
+ - app/views/blazer/queries/_tips.html.erb
214
215
  - app/views/blazer/queries/docs.html.erb
215
216
  - app/views/blazer/queries/edit.html.erb
216
217
  - app/views/blazer/queries/home.html.erb
@@ -263,7 +264,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
264
  - !ruby/object:Gem::Version
264
265
  version: '0'
265
266
  requirements: []
266
- rubygems_version: 3.0.3
267
+ rubyforge_project:
268
+ rubygems_version: 2.7.7
267
269
  signing_key:
268
270
  specification_version: 4
269
271
  summary: Fork from ankane! Explore your data with SQL. Easily create charts and dashboards,