adhoq 0.4.0 → 0.5.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/adhoq/application.js +1 -0
- data/app/assets/javascripts/adhoq/previewer.js.coffee +8 -0
- data/app/controllers/adhoq/current_tables_controller.rb +22 -1
- data/app/views/adhoq/queries/_current_tables_leftbar.html.slim +1 -1
- data/app/views/adhoq/queries/_form.html.slim +30 -2
- data/lib/adhoq/engine.rb +2 -0
- data/lib/adhoq/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6e80af86c7cb940f71f7e52519bfb230401a77c
|
4
|
+
data.tar.gz: 8ffc771c4e7d7dab5779ce9523a3057750baf712
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 663808146b19b9804b2190ea04b7d7f36e97087884b515fc70a34248b8e73b4ad40fadce1bfdd0ac29443ca2faecf32852e408622a8a8f8fef4f80fc23129562
|
7
|
+
data.tar.gz: 0cce243729dc884e9f2f81ac1fa33f479db7f9fb92c5e617b1251bcaa3f919798b081dc7942303e749c4456dd4200b66a6420bb0972b9d03e22bf86c9bf6908b
|
@@ -18,6 +18,14 @@ class Previewer
|
|
18
18
|
)
|
19
19
|
|
20
20
|
source: ->
|
21
|
+
# NOTE: Sometimes the textarea is empty even if the monaco editor has some contents.
|
22
|
+
# That's why the editor source is preferred.
|
23
|
+
@editorSource() || @domSource()
|
24
|
+
|
25
|
+
editorSource: ->
|
26
|
+
Adhoq.editor && Adhoq.editor.getValue()
|
27
|
+
|
28
|
+
domSource: ->
|
21
29
|
$(@el.data('source')).val()
|
22
30
|
|
23
31
|
result: ->
|
@@ -11,11 +11,32 @@ module Adhoq
|
|
11
11
|
reject {|klass| klass.abstract_class? || hidden_model_names.include?(klass.name) || klass.name.nil? }.
|
12
12
|
sort_by(&:name)
|
13
13
|
|
14
|
-
|
14
|
+
respond_to do |format|
|
15
|
+
format.html { render layout: false }
|
16
|
+
format.json { render json: tables_as_json(@ar_classes) }
|
17
|
+
end
|
15
18
|
end
|
16
19
|
|
17
20
|
private
|
18
21
|
|
22
|
+
def tables_as_json(ar_classes)
|
23
|
+
ar_classes.map {|ar_class|
|
24
|
+
{
|
25
|
+
table_name: ar_class.table_name,
|
26
|
+
columns: ar_class.columns.map {|column|
|
27
|
+
{
|
28
|
+
name: column.name,
|
29
|
+
type: column.type,
|
30
|
+
primary_key: column.name == ar_class.primary_key,
|
31
|
+
null: column.null,
|
32
|
+
limit: column.limit,
|
33
|
+
default: column.default
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
19
40
|
def eager_load_models
|
20
41
|
return unless Rails.env.development?
|
21
42
|
[Rails.application, Adhoq::Engine].each(&:eager_load!)
|
@@ -7,8 +7,20 @@
|
|
7
7
|
i.fa.fa-database.fa-pad-r
|
8
8
|
| Show tables
|
9
9
|
|
10
|
+
.clearfix
|
11
|
+
a#disable_code_editor.pull-right(href='#')
|
12
|
+
i.fa.fa-edit
|
13
|
+
| Switch to Plain Editor
|
14
|
+
|
10
15
|
.form-group
|
11
|
-
|
16
|
+
.form-control.query-editor
|
17
|
+
#query_field(
|
18
|
+
data-current-tables-path="#{current_tables_path}"
|
19
|
+
data-id="query_query"
|
20
|
+
data-name="query[query]"
|
21
|
+
data-placeholder="#{@query.persisted? ? 'Edit' : 'New'} query"
|
22
|
+
data-query="#{@query.query}"
|
23
|
+
)
|
12
24
|
|
13
25
|
.modal.fade#nameAndDesc[role='dialog']
|
14
26
|
.modal-dialog
|
@@ -85,9 +97,25 @@ ul.nav.nav-tabs[role='tablist']
|
|
85
97
|
|
86
98
|
javascript:
|
87
99
|
$(function() {
|
100
|
+
var element = document.getElementById('query_field');
|
101
|
+
|
102
|
+
Adhoq.editor = Adhoq.launchEditor(element);
|
103
|
+
Adhoq.installCompletion(element.dataset.currentTablesPath);
|
104
|
+
|
105
|
+
$('#disable_code_editor').on('click', function(e) {
|
106
|
+
e.preventDefault();
|
107
|
+
|
108
|
+
Adhoq.switchToTextareaEditor({
|
109
|
+
editor: Adhoq.editor,
|
110
|
+
element: element.parentNode,
|
111
|
+
content: Adhoq.editor.getModel().getValue()
|
112
|
+
});
|
113
|
+
|
114
|
+
e.target.remove();
|
115
|
+
});
|
116
|
+
|
88
117
|
Adhoq.enablePreview($('#preview a.js-preview-button'));
|
89
118
|
Adhoq.enablePreview($('#explain a.js-explain-button'));
|
90
119
|
|
91
120
|
Adhoq.enablePreviewKeybordShortCut($('#query_query'), '#previews .tab-pane.active a:has(".fa-refresh")')
|
92
121
|
});
|
93
|
-
|
data/lib/adhoq/engine.rb
CHANGED
data/lib/adhoq/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -13,6 +13,7 @@ Rails.backtrace_cleaner.remove_silencers!
|
|
13
13
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f }
|
14
14
|
|
15
15
|
Capybara.default_driver = :poltergeist
|
16
|
+
Capybara.default_wait_time = 30
|
16
17
|
|
17
18
|
RSpec.configure do |config|
|
18
19
|
config.expect_with :rspec do |expectations|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adhoq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyosuke MOROHASHI
|
@@ -493,9 +493,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
493
493
|
version: '0'
|
494
494
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
495
495
|
requirements:
|
496
|
-
- - "
|
496
|
+
- - ">"
|
497
497
|
- !ruby/object:Gem::Version
|
498
|
-
version:
|
498
|
+
version: 1.3.1
|
499
499
|
requirements: []
|
500
500
|
rubyforge_project:
|
501
501
|
rubygems_version: 2.5.2.2
|