killbill-kpm 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +2 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/application.js +24 -0
- data/app/assets/javascripts/kpm/kpm.js +7 -0
- data/app/assets/stylesheets/application.css +19 -0
- data/app/assets/stylesheets/bootstrap_and_overrides.css +17 -0
- data/app/assets/stylesheets/kpm/kpm.css +6 -0
- data/app/controllers/kpm/engine_controller.rb +29 -0
- data/app/controllers/kpm/nodes_info_controller.rb +108 -0
- data/app/controllers/kpm/plugins_controller.rb +19 -0
- data/app/helpers/kpm/application_helper.rb +4 -0
- data/app/views/kpm/layouts/kpm_application.html.erb +31 -0
- data/app/views/kpm/nodes_info/_logs_table.html.erb +43 -0
- data/app/views/kpm/nodes_info/_nodes_table.html.erb +68 -0
- data/app/views/kpm/nodes_info/index.html.erb +68 -0
- data/app/views/kpm/nodes_info/index.js.erb +4 -0
- data/app/views/kpm/plugins/_form.html.erb +37 -0
- data/app/views/kpm/plugins/_plugins_table.html.erb +48 -0
- data/app/views/kpm/plugins/index.html.erb +18 -0
- data/config/routes.rb +17 -0
- data/lib/kpm/client.rb +31 -0
- data/lib/kpm/engine.rb +23 -0
- data/lib/kpm/version.rb +3 -0
- data/lib/kpm.rb +24 -0
- data/lib/tasks/kpm_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +32 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +23 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/killbill_client.rb +3 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/kpm_test.rb +7 -0
- data/test/test_helper.rb +21 -0
- metadata +439 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 20d17e6da1d71d8b41c2ea5a37b7dabaed466278
|
4
|
+
data.tar.gz: 6705bf69263cdb0f5eadb2ef994cb483e7feaca0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 25c2c60b034b8c79a029db0211fa9ab1fdfcae7fe18babf1fbbe2b0eb4edfc5c5ce9364ee359f30a439139515d7d3adb457c9dfd1850fb6e1e5b9eb560c539e8
|
7
|
+
data.tar.gz: 2f806a617173e7576e531e05f8232023196efb6700ce6e28a4ef4ce1727870e4e445831e6d8a1b5322d8b1c4ea3fa233755b0e9da8541f772cf361d4e0dfd971
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 The Billing Project, LLC
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'KPM'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,24 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require js-routes
|
14
|
+
//= require moment
|
15
|
+
//= require spin
|
16
|
+
//= require jquery
|
17
|
+
//= require jquery_ujs
|
18
|
+
//= require twitter/bootstrap
|
19
|
+
//= require dataTables/jquery.dataTables
|
20
|
+
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
|
21
|
+
//= require d3
|
22
|
+
//= require bootstrap-datepicker
|
23
|
+
//= require jquery.spin
|
24
|
+
//= require kpm/kpm
|
@@ -0,0 +1,7 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require_tree .
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_self
|
14
|
+
*= require bootstrap-datepicker3
|
15
|
+
*= require dataTables/jquery.dataTables
|
16
|
+
*= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
|
17
|
+
*= require bootstrap_and_overrides
|
18
|
+
*= require kpm/kpm
|
19
|
+
*/
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/*
|
2
|
+
*= require twitter-bootstrap-static/bootstrap
|
3
|
+
*
|
4
|
+
* Use Font Awesome icons (default)
|
5
|
+
* To use Glyphicons sprites instead of Font Awesome, replace with "require twitter-bootstrap-static/sprites"
|
6
|
+
*= require twitter-bootstrap-static/fontawesome
|
7
|
+
*/
|
8
|
+
|
9
|
+
/* Override Bootstrap 3 font locations */
|
10
|
+
@font-face {
|
11
|
+
font-family: 'Glyphicons Halflings';
|
12
|
+
src: url('../assets/glyphicons-halflings-regular.eot');
|
13
|
+
src: url('../assets/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
|
14
|
+
url('../assets/glyphicons-halflings-regular.woff') format('woff'),
|
15
|
+
url('../assets/glyphicons-halflings-regular.ttf') format('truetype'),
|
16
|
+
url('../assets/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
|
17
|
+
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_tree .
|
6
|
+
*/
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module KPM
|
2
|
+
class EngineController < ApplicationController
|
3
|
+
|
4
|
+
layout :get_layout
|
5
|
+
|
6
|
+
def get_layout
|
7
|
+
layout ||= KPM.config[:layout]
|
8
|
+
end
|
9
|
+
|
10
|
+
def current_tenant_user
|
11
|
+
# If the rails application on which that engine is mounted defines such method (Devise), we extract the current user,
|
12
|
+
# if not we default to nil, and serve our static mock configuration
|
13
|
+
user = current_user if respond_to?(:current_user)
|
14
|
+
KPM.current_tenant_user.call(session, user)
|
15
|
+
end
|
16
|
+
|
17
|
+
def options_for_klient
|
18
|
+
user = current_tenant_user
|
19
|
+
{
|
20
|
+
:username => user[:username],
|
21
|
+
:password => user[:password],
|
22
|
+
:session_id => user[:session_id],
|
23
|
+
:api_key => user[:api_key],
|
24
|
+
:api_secret => user[:api_secret]
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'kpm/client'
|
2
|
+
|
3
|
+
module KPM
|
4
|
+
class NodesInfoController < EngineController
|
5
|
+
|
6
|
+
def index
|
7
|
+
@nodes_info = ::KillBillClient::Model::NodesInfo.nodes_info(options_for_klient)
|
8
|
+
|
9
|
+
# For convenience, put pure OSGI bundles at the bottom
|
10
|
+
@nodes_info.each do |node_info|
|
11
|
+
next if node_info.plugins_info.nil?
|
12
|
+
node_info.plugins_info.sort! do |a, b|
|
13
|
+
if osgi_bundle?(a) && !osgi_bundle?(b)
|
14
|
+
1
|
15
|
+
elsif !osgi_bundle?(a) && osgi_bundle?(b)
|
16
|
+
-1
|
17
|
+
else
|
18
|
+
a.plugin_name <=> b.plugin_name
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
@logs = ::Killbill::KPM::KPMClient.get_osgi_logs(options_for_klient).reverse
|
24
|
+
|
25
|
+
respond_to do |format|
|
26
|
+
format.html
|
27
|
+
format.js
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def install_plugin
|
32
|
+
command_properties = [
|
33
|
+
build_node_command_property('forceDownload', params[:force_download] == '1')
|
34
|
+
]
|
35
|
+
trigger_node_plugin_command('INSTALL_PLUGIN', command_properties)
|
36
|
+
|
37
|
+
redirect_to :action => :index
|
38
|
+
end
|
39
|
+
|
40
|
+
def install_plugin_from_fs
|
41
|
+
::Killbill::KPM::KPMClient.install_plugin(params.require(:name),
|
42
|
+
params.require(:version),
|
43
|
+
params.require(:type),
|
44
|
+
params.require(:plugin).original_filename,
|
45
|
+
params.require(:plugin).read,
|
46
|
+
options_for_klient)
|
47
|
+
|
48
|
+
redirect_to :action => :index
|
49
|
+
end
|
50
|
+
|
51
|
+
def uninstall_plugin
|
52
|
+
trigger_node_plugin_command('UNINSTALL_PLUGIN')
|
53
|
+
render :nothing => true
|
54
|
+
end
|
55
|
+
|
56
|
+
def start_plugin
|
57
|
+
trigger_node_plugin_command('START_PLUGIN')
|
58
|
+
render :nothing => true
|
59
|
+
end
|
60
|
+
|
61
|
+
def stop_plugin
|
62
|
+
trigger_node_plugin_command('STOP_PLUGIN')
|
63
|
+
render :nothing => true
|
64
|
+
end
|
65
|
+
|
66
|
+
def restart_plugin
|
67
|
+
trigger_node_plugin_command('RESTART_PLUGIN')
|
68
|
+
render :nothing => true
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def trigger_node_plugin_command(command_type, command_properties=[], plugin_name=nil, plugin_version=nil)
|
74
|
+
command_properties << build_node_command_property('pluginName', plugin_name || params.require(:plugin_name))
|
75
|
+
command_properties << build_node_command_property('pluginVersion', plugin_version || params[:plugin_version])
|
76
|
+
|
77
|
+
trigger_node_command(command_type, command_properties)
|
78
|
+
end
|
79
|
+
|
80
|
+
def trigger_node_command(command_type, command_properties=[])
|
81
|
+
node_command = ::KillBillClient::Model::NodeCommandAttributes.new
|
82
|
+
node_command.system_command_type = true
|
83
|
+
node_command.node_command_type = command_type
|
84
|
+
node_command.node_command_properties = command_properties
|
85
|
+
|
86
|
+
# TODO Can we actually use node_name?
|
87
|
+
local_node_only = false
|
88
|
+
|
89
|
+
::KillBillClient::Model::NodesInfo.trigger_node_command(node_command,
|
90
|
+
local_node_only,
|
91
|
+
options_for_klient[:username],
|
92
|
+
params[:reason],
|
93
|
+
params[:comment],
|
94
|
+
options_for_klient)
|
95
|
+
end
|
96
|
+
|
97
|
+
def build_node_command_property(key, value)
|
98
|
+
property = ::KillBillClient::Model::NodeCommandPropertyAttributes.new
|
99
|
+
property.key = key
|
100
|
+
property.value = value
|
101
|
+
property
|
102
|
+
end
|
103
|
+
|
104
|
+
def osgi_bundle?(plugin_info)
|
105
|
+
plugin_info.version.blank? || plugin_info.plugin_name.starts_with?('org.apache.felix.') || plugin_info.plugin_name.starts_with?('org.kill-bill.billing.killbill-platform-')
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'kpm/client'
|
2
|
+
|
3
|
+
module KPM
|
4
|
+
class PluginsController < EngineController
|
5
|
+
|
6
|
+
def index
|
7
|
+
begin
|
8
|
+
plugins = ::Killbill::KPM::KPMClient.get_available_plugins(true, options_for_klient)
|
9
|
+
rescue => e
|
10
|
+
# No connectivity, GitHub down, ...
|
11
|
+
Rails.logger.warn("Unable to get latest plugins, trying built-in directory: #{e.inspect}")
|
12
|
+
plugins = ::Killbill::KPM::KPMClient.get_available_plugins(false, options_for_klient)
|
13
|
+
end
|
14
|
+
|
15
|
+
@plugins = Hash[plugins.sort]
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>KPM</title>
|
5
|
+
<%= yield :scripts %>
|
6
|
+
<%= stylesheet_link_tag 'application', :media => 'all' %>
|
7
|
+
<%= javascript_include_tag 'application' %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
</head>
|
10
|
+
<div class="container-fluid">
|
11
|
+
<%- # :alert used by devise -%>
|
12
|
+
<% [:error, :alert].each do |key| %>
|
13
|
+
<% if flash[key] %>
|
14
|
+
<div class="row">
|
15
|
+
<div class="col-md-10 col-md-offset-2">
|
16
|
+
<div class="alert alert-error"><%= flash[key] %></div>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
21
|
+
<% if flash[:notice] %>
|
22
|
+
<div class="row">
|
23
|
+
<div class="col-md-10 col-md-offset-2">
|
24
|
+
<div class="alert alert-info"><%= flash[:notice] %></div>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
28
|
+
<%= yield %>
|
29
|
+
</div>
|
30
|
+
</body>
|
31
|
+
</html>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<table id="logs-table" class="table table-condensed table-striped mobile-data">
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th>Time</th>
|
5
|
+
<th>Name</th>
|
6
|
+
<th>Level</th>
|
7
|
+
<th>Message</th>
|
8
|
+
</tr>
|
9
|
+
</thead>
|
10
|
+
<tbody>
|
11
|
+
<% logs.each do |log| %>
|
12
|
+
<tr>
|
13
|
+
<td>
|
14
|
+
<% unless log['time'].blank? %>
|
15
|
+
<%= DateTime.strptime(log['time'].to_s, '%Q').strftime('%Y-%m-%d %H:%M:%S') %>
|
16
|
+
<% end %>
|
17
|
+
</td>
|
18
|
+
<td><%= log['name'] %></td>
|
19
|
+
<td>
|
20
|
+
<% if log['level'] == 'ERROR' %>
|
21
|
+
<span class="label label-danger"><%= log['level'] %></span>
|
22
|
+
<% elsif log['level'] == 'WARNING' %>
|
23
|
+
<span class="label label-warning"><%= log['level'] %></span>
|
24
|
+
<% else %>
|
25
|
+
<span class="label label-success"><%= log['level'] %></span>
|
26
|
+
<% end %>
|
27
|
+
</td>
|
28
|
+
<td><pre><%= log['message'] %></pre></td>
|
29
|
+
</tr>
|
30
|
+
<% end %>
|
31
|
+
</tbody>
|
32
|
+
</table>
|
33
|
+
|
34
|
+
<%= javascript_tag do %>
|
35
|
+
$(document).ready(function() {
|
36
|
+
$('#logs-table').dataTable({
|
37
|
+
"dom": "<'row'r>t<'row'<'col-md-6'i><'col-md-6'p>>",
|
38
|
+
"pagingType": "full_numbers",
|
39
|
+
"pageLength": 50,
|
40
|
+
"ordering": false
|
41
|
+
});
|
42
|
+
});
|
43
|
+
<% end %>
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<table id="nodes-table" class="table table-condensed table-striped mobile-data">
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th>Node name</th>
|
5
|
+
<th>Boot time</th>
|
6
|
+
<th>Updated date</th>
|
7
|
+
<th>Kill Bill version</th>
|
8
|
+
<th>Dependencies</th>
|
9
|
+
<th>Plugins</th>
|
10
|
+
</tr>
|
11
|
+
</thead>
|
12
|
+
<tbody>
|
13
|
+
<% nodes_info.each do |node_info| %>
|
14
|
+
<tr>
|
15
|
+
<td><%= node_info.node_name %></td>
|
16
|
+
<td>
|
17
|
+
<% unless node_info.boot_time.blank? %>
|
18
|
+
<%= time_ago_in_words(DateTime.parse(node_info.boot_time)) %> ago
|
19
|
+
<% end %>
|
20
|
+
</td>
|
21
|
+
<td>
|
22
|
+
<% unless node_info.last_updated_date.blank? %>
|
23
|
+
<%= time_ago_in_words(DateTime.parse(node_info.last_updated_date)) %> ago
|
24
|
+
<% end %>
|
25
|
+
</td>
|
26
|
+
<td><%= node_info.kb_version %></td>
|
27
|
+
<td>
|
28
|
+
<ul>
|
29
|
+
<li>API: <%= node_info.api_version %></li>
|
30
|
+
<li>Plugin API: <%= node_info.plugin_api_version %></li>
|
31
|
+
<li>Platform: <%= node_info.platform_version %></li>
|
32
|
+
<li>Commons: <%= node_info.common_version %></li>
|
33
|
+
</ul>
|
34
|
+
</td>
|
35
|
+
<td>
|
36
|
+
<% unless (node_info.plugins_info || []).empty? %>
|
37
|
+
<ul>
|
38
|
+
<% node_info.plugins_info.each do |plugin_info| %>
|
39
|
+
<li>
|
40
|
+
<%= plugin_info.plugin_name %> <%= plugin_info.version %> <span class="label label-<%= plugin_info.state == 'RUNNING' ? 'success' : (plugin_info.state == 'INSTALLED' ? 'warning' : 'danger') %>"><%= plugin_info.state %></span>
|
41
|
+
<% if plugin_info.state == 'RUNNING' %>
|
42
|
+
<%= link_to '<i class="fa fa-pause"></i>'.html_safe, plugin_stop_path(:plugin_name => plugin_info.plugin_name, :plugin_version => plugin_info.version), :method => :post, :title => 'Stop', :remote => true, :class => 'plugin-link' %>
|
43
|
+
<%= link_to '<i class="fa fa-refresh"></i>'.html_safe, plugin_restart_path(:plugin_name => plugin_info.plugin_name, :plugin_version => plugin_info.version), :method => :post, :title => 'Restart', :remote => true, :class => 'plugin-link' %>
|
44
|
+
<% elsif plugin_info.state == 'INSTALLED' || plugin_info.state == 'STOPPED' %>
|
45
|
+
<%= link_to '<i class="fa fa-play"></i>'.html_safe, plugin_start_path(:plugin_name => plugin_info.plugin_name, :plugin_version => plugin_info.version), :method => :post, :title => 'Start', :remote => true, :class => 'plugin-link' %>
|
46
|
+
<% end %>
|
47
|
+
<% unless plugin_info.version.nil? %>
|
48
|
+
<%= link_to '<i class="fa fa-eject"></i>'.html_safe, plugin_uninstall_path(:plugin_name => plugin_info.plugin_name, :plugin_version => plugin_info.version), :method => :post, :title => 'Uninstall', :remote => true, :class => 'plugin-link' %>
|
49
|
+
<% end %>
|
50
|
+
</li>
|
51
|
+
<% end %>
|
52
|
+
</ul>
|
53
|
+
<% end %>
|
54
|
+
</td>
|
55
|
+
</tr>
|
56
|
+
<% end %>
|
57
|
+
</tbody>
|
58
|
+
</table>
|
59
|
+
|
60
|
+
<%= javascript_tag do %>
|
61
|
+
$(document).ready(function() {
|
62
|
+
$('#nodes-table').dataTable({
|
63
|
+
"dom": "t",
|
64
|
+
"paging": false,
|
65
|
+
"ordering": false
|
66
|
+
});
|
67
|
+
});
|
68
|
+
<% end %>
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<div class="search">
|
2
|
+
|
3
|
+
<div class="column-block">
|
4
|
+
|
5
|
+
<h1>Configured instances</h1>
|
6
|
+
|
7
|
+
<div id="nodes-table-wrapper">
|
8
|
+
<%= render :partial => 'kpm/nodes_info/nodes_table', :locals => {:nodes_info => @nodes_info} %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="column-block">
|
14
|
+
|
15
|
+
<h1><%= link_to 'Install new plugin', plugins_path %></h1>
|
16
|
+
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="column-block">
|
20
|
+
|
21
|
+
<h1>Logs</h1>
|
22
|
+
|
23
|
+
<div id="logs-table-wrapper">
|
24
|
+
<%= render :partial => 'kpm/nodes_info/logs_table', :locals => {:logs => @logs} %>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
</div>
|
28
|
+
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<%= javascript_tag do %>
|
32
|
+
$(document).ready(function() {
|
33
|
+
scheduleRefresh();
|
34
|
+
});
|
35
|
+
|
36
|
+
function scheduleRefresh() {
|
37
|
+
var timer = setTimeout(refreshAll, 1500);
|
38
|
+
|
39
|
+
// Stop refreshing when user clicks through logs
|
40
|
+
$('#logs-table_wrapper a').one('click', function() {
|
41
|
+
clearTimeout(timer);
|
42
|
+
});
|
43
|
+
|
44
|
+
$('.plugin-link').one('ajax:beforeSend', function() {
|
45
|
+
// Disable the refresh
|
46
|
+
clearTimeout(timer);
|
47
|
+
|
48
|
+
// Prevent other clicks
|
49
|
+
$('.plugin-link').removeAttr('data-remote')
|
50
|
+
.removeAttr('data-method')
|
51
|
+
.removeAttr('href')
|
52
|
+
|
53
|
+
// Spin
|
54
|
+
$(this).children().addClass('fa-spin');
|
55
|
+
});
|
56
|
+
|
57
|
+
$('.plugin-link').one('ajax:complete', function() {
|
58
|
+
// Delay a bit, to give time for the plugin state to change before the next refresh
|
59
|
+
setTimeout(refreshAll, 6000);
|
60
|
+
});
|
61
|
+
}
|
62
|
+
|
63
|
+
function refreshAll() {
|
64
|
+
$.ajax({
|
65
|
+
url: "<%= nodes_info_index_path(:format => :js) %>"
|
66
|
+
});
|
67
|
+
}
|
68
|
+
<% end %>
|
@@ -0,0 +1,4 @@
|
|
1
|
+
$('#nodes-table-wrapper').html("<%= escape_javascript(render :partial => 'kpm/nodes_info/nodes_table', :locals => {:nodes_info => @nodes_info}) %>");
|
2
|
+
$('#logs-table-wrapper').html("<%= escape_javascript(render :partial => 'kpm/nodes_info/logs_table', :locals => {:logs => @logs}) %>");
|
3
|
+
|
4
|
+
scheduleRefresh();
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<%= form_tag plugin_install_from_fs_path, :multipart => true, :class => 'form-horizontal' do %>
|
2
|
+
<div class="form-group">
|
3
|
+
<%= label_tag :name, 'Name', :class => 'col-sm-2 control-label' %>
|
4
|
+
<div class="col-sm-9">
|
5
|
+
<%= text_field_tag :name, '', :class => 'form-control', :placeholder => 'Plugin name' %>
|
6
|
+
</div>
|
7
|
+
</div>
|
8
|
+
<div class="form-group">
|
9
|
+
<%= label_tag :name, 'Version', :class => 'col-sm-2 control-label' %>
|
10
|
+
<div class="col-sm-9">
|
11
|
+
<%= text_field_tag :version, '', :class => 'form-control', :placeholder => 'Plugin version' %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
<div class='form-group'>
|
15
|
+
<div class="col-sm-offset-2 col-sm-10">
|
16
|
+
<% %w(java ruby).each do |type| %>
|
17
|
+
<div class="checkbox">
|
18
|
+
<%= label_tag :type do %>
|
19
|
+
<%= radio_button_tag :type, type, (type == 'java') %>
|
20
|
+
<%= type %>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
23
|
+
<% end %>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
<div class="form-group">
|
27
|
+
<%= label_tag :plugin, 'Plugin', :class => 'col-sm-2 control-label' %>
|
28
|
+
<div class="col-sm-10">
|
29
|
+
<%= file_field_tag 'plugin', :class => 'form-control' %>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
<div class="form-group">
|
33
|
+
<div class="col-sm-offset-2 col-sm-10">
|
34
|
+
<%= submit_tag 'Install', :class => 'btn btn-default' %>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
<% end %>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<table id="plugins-table" class="table table-condensed table-striped mobile-data">
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th>Name</th>
|
5
|
+
<th>Type</th>
|
6
|
+
<th>Versions</th>
|
7
|
+
<th>Required configuration</th>
|
8
|
+
<th></th>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
<tbody>
|
12
|
+
<% plugins.each do |name, details| %>
|
13
|
+
<tr>
|
14
|
+
<td><%= name %></td>
|
15
|
+
<td><%= details['type'] %></td>
|
16
|
+
<td>
|
17
|
+
<% unless details['versions'].nil? %>
|
18
|
+
<ul>
|
19
|
+
<% details['versions'].each do |kb_version, plugin_version| %>
|
20
|
+
<li><%= kb_version %>: <%= plugin_version %></li>
|
21
|
+
<% end %>
|
22
|
+
</ul>
|
23
|
+
<% end %>
|
24
|
+
</td>
|
25
|
+
<td>
|
26
|
+
<% unless (details['require'] || []).empty? %>
|
27
|
+
<ul>
|
28
|
+
<% details['require'].each do |property| %>
|
29
|
+
<li><%= property %></li>
|
30
|
+
<% end %>
|
31
|
+
</ul>
|
32
|
+
<% end %>
|
33
|
+
</td>
|
34
|
+
<td><%= link_to '<i class="fa fa-cloud-download"></i>'.html_safe, plugin_install_path(:plugin_name => name), :method => :post, :title => 'Install' %></td>
|
35
|
+
</tr>
|
36
|
+
<% end %>
|
37
|
+
</tbody>
|
38
|
+
</table>
|
39
|
+
|
40
|
+
<%= javascript_tag do %>
|
41
|
+
$(document).ready(function() {
|
42
|
+
$('#plugins-table').dataTable({
|
43
|
+
"dom": "t",
|
44
|
+
"paging": false,
|
45
|
+
"ordering": false
|
46
|
+
});
|
47
|
+
});
|
48
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div class="search">
|
2
|
+
|
3
|
+
<div class="column-block">
|
4
|
+
|
5
|
+
<h1>Available plugins</h1>
|
6
|
+
|
7
|
+
<%= render :partial => 'kpm/plugins/plugins_table', :locals => {:plugins => @plugins} %>
|
8
|
+
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="column-block">
|
12
|
+
|
13
|
+
<h1>Upload plugin</h1>
|
14
|
+
<%= render 'form' %>
|
15
|
+
|
16
|
+
</div>
|
17
|
+
|
18
|
+
</div>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
KPM::Engine.routes.draw do
|
2
|
+
|
3
|
+
root to: 'nodes_info#index'
|
4
|
+
|
5
|
+
resources :nodes_info, :only => [:index]
|
6
|
+
resources :plugins, :only => [:index]
|
7
|
+
|
8
|
+
scope '/nodes_info' do
|
9
|
+
match '/plugin/install' => 'nodes_info#install_plugin', :via => :post, :as => 'plugin_install'
|
10
|
+
match '/plugin/install_from_fs' => 'nodes_info#install_plugin_from_fs', :via => :post, :as => 'plugin_install_from_fs'
|
11
|
+
match '/plugin/uninstall' => 'nodes_info#uninstall_plugin', :via => :post, :as => 'plugin_uninstall'
|
12
|
+
match '/plugin/start' => 'nodes_info#start_plugin', :via => :post, :as => 'plugin_start'
|
13
|
+
match '/plugin/stop' => 'nodes_info#stop_plugin', :via => :post, :as => 'plugin_stop'
|
14
|
+
match '/plugin/restart' => 'nodes_info#restart_plugin', :via => :post, :as => 'plugin_restart'
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|