activeadmin-sqlpage 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/activeadmin-sqlpage.gemspec +25 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/activeadmin/sqlpage/version.rb +5 -0
- data/lib/activeadmin/sqlpage.rb +76 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 20c0e65ad665b0eec9eb76281aec3d65dd88a530
|
4
|
+
data.tar.gz: 73b043843a67fc6fe9eb67cc4b3adc3dbef12719
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8fb0c72b2d6d0f12b33f3e753974e7ebef60f721b98c4cc0c8f29000771250a84306c58ab66208c224915231decddef0f6572fec215e459e1810b6ec5f03af9f
|
7
|
+
data.tar.gz: 39cb10dd3404c01ccf068383e92d0d0e24406cc308eb7ad1329526630e727c7856e227d27970d735a5365e0ddd91b3fcd0386480728139361ff0a4efc66d65c0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016-present Serguei Okladnikov <oklaspec@gmail.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# ActiveAdmin::SqlPage
|
2
|
+
|
3
|
+
The SQL active admin page
|
4
|
+
|
5
|
+
Add page to your ActiveAdmin panel that allow execute SQL requests and show result in table
|
6
|
+
|
7
|
+
[![Version](http://img.shields.io/gem/v/activeadmin-sqlpage.svg)](https://rubygems.org/gems/activeadmin-sqlpage)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'activeadmin-sqlpage'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install activeadmin-sqlpage
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
To add SQL Page to your active admin place this peace of code for example to `app/admin/sql.rb`:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
ActiveAdmin::SqlPage::register
|
31
|
+
```
|
32
|
+
Be carefull to execute sql requests. It may upset the consistent of your database. It is recomented to enable this page for worked project where only advanced user may have access to execute sql.
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/oklas/activeadmin-sqlpage.
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
42
|
+
## Copyright
|
43
|
+
|
44
|
+
Copyright (c) 2016-present Serguei Okladnikov <oklaspec@gmail.com>
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'activeadmin/sqlpage/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "activeadmin-sqlpage"
|
8
|
+
spec.version = ActiveAdmin::SqlPage::VERSION
|
9
|
+
spec.authors = ["Serguei Okladnikov"]
|
10
|
+
spec.email = ["oklaspec@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{The SQL active admin page}
|
13
|
+
spec.description = %q{Add page to your ActiveAdmin panel that allow execute SQL requests and show result in table}
|
14
|
+
spec.homepage = "http://github.com/oklas/activeadmin-sqlpage"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "activeadmin/sqlpage"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require "activeadmin/sqlpage/version"
|
2
|
+
|
3
|
+
module ActiveAdmin
|
4
|
+
module SqlPage
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def register
|
8
|
+
ActiveAdmin.register_page "SQL" do
|
9
|
+
|
10
|
+
|
11
|
+
menu priority: 1, label: "SQL"
|
12
|
+
|
13
|
+
content title: "SQL" do
|
14
|
+
|
15
|
+
columns do
|
16
|
+
column do
|
17
|
+
|
18
|
+
form action: admin_sql_query_path, method: :post do |f|
|
19
|
+
div class: :table_tools do
|
20
|
+
input type: :hidden,
|
21
|
+
name: :authenticity_token,
|
22
|
+
value: form_authenticity_token
|
23
|
+
|
24
|
+
textarea name: :sql do
|
25
|
+
params[:sql]
|
26
|
+
end
|
27
|
+
|
28
|
+
button :submit
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
unless params[:sql].nil?
|
33
|
+
|
34
|
+
begin
|
35
|
+
result = ActiveRecord::Base.connection.exec_query( params[:sql] )
|
36
|
+
rescue Exception => e
|
37
|
+
result = ActiveRecord::Result.new( [:error], [[e.message]] )
|
38
|
+
end
|
39
|
+
|
40
|
+
table class: 'index_table index' do
|
41
|
+
thead do
|
42
|
+
tr do
|
43
|
+
result.columns.each do |name|
|
44
|
+
th name, class: :col
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
tbody do
|
49
|
+
result.rows.each_with_index do |col,i|
|
50
|
+
tr class: (0==i%2?'odd':'even') do
|
51
|
+
col.each do |val|
|
52
|
+
td val, class: :col
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
page_action :query, method: :post do
|
67
|
+
render action: :index, layout: false
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activeadmin-sqlpage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Serguei Okladnikov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Add page to your ActiveAdmin panel that allow execute SQL requests and
|
56
|
+
show result in table
|
57
|
+
email:
|
58
|
+
- oklaspec@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- activeadmin-sqlpage.gemspec
|
71
|
+
- bin/console
|
72
|
+
- bin/setup
|
73
|
+
- lib/activeadmin/sqlpage.rb
|
74
|
+
- lib/activeadmin/sqlpage/version.rb
|
75
|
+
homepage: http://github.com/oklas/activeadmin-sqlpage
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.4.8
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: The SQL active admin page
|
99
|
+
test_files: []
|