distribot-ui 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +12 -0
  5. data/Dockerfile +9 -0
  6. data/Gemfile +14 -0
  7. data/Gemfile.lock +270 -0
  8. data/LICENSE +201 -0
  9. data/README.md +25 -0
  10. data/Rakefile +21 -0
  11. data/app/assets/images/.keep +0 -0
  12. data/app/assets/images/distribot-70x70.png +0 -0
  13. data/app/assets/javascripts/application.js +28 -0
  14. data/app/assets/javascripts/jquery.sparkline.min.js +5 -0
  15. data/app/assets/javascripts/signin/signin.js +30 -0
  16. data/app/assets/stylesheets/application.css.scss +17 -0
  17. data/app/controllers/admin_controller.rb +15 -0
  18. data/app/controllers/application_controller.rb +22 -0
  19. data/app/controllers/concerns/.keep +0 -0
  20. data/app/controllers/flow_controller.rb +64 -0
  21. data/app/controllers/handler_controller.rb +17 -0
  22. data/app/controllers/signin_controller.rb +22 -0
  23. data/app/controllers/worker_controller.rb +17 -0
  24. data/app/helpers/application_helper.rb +16 -0
  25. data/app/mailers/.keep +0 -0
  26. data/app/models/.keep +0 -0
  27. data/app/models/concerns/.keep +0 -0
  28. data/app/models/user.rb +83 -0
  29. data/app/views/admin/home.html.erb +14 -0
  30. data/app/views/flow/create.html.erb +22 -0
  31. data/app/views/flow/empty_list.html.erb +21 -0
  32. data/app/views/flow/list.html.erb +54 -0
  33. data/app/views/flow/show.html.erb +1 -0
  34. data/app/views/handler/list.html.erb +35 -0
  35. data/app/views/handler/show.html.erb +1 -0
  36. data/app/views/layouts/application.html.erb +72 -0
  37. data/app/views/signin/signin.html.erb +32 -0
  38. data/app/views/worker/list.html.erb +31 -0
  39. data/app/views/worker/show.html.erb +1 -0
  40. data/bin/bundle +3 -0
  41. data/bin/distribot-ui +13 -0
  42. data/bin/distribot-ui-restart +12 -0
  43. data/bin/rails +4 -0
  44. data/bin/rake +4 -0
  45. data/bin/setup +29 -0
  46. data/config.ru +4 -0
  47. data/config/application.rb +33 -0
  48. data/config/boot.rb +3 -0
  49. data/config/environment.rb +5 -0
  50. data/config/environments/development.rb +39 -0
  51. data/config/environments/production.rb +76 -0
  52. data/config/environments/test.rb +42 -0
  53. data/config/initializers/assets.rb +17 -0
  54. data/config/initializers/backtrace_silencers.rb +7 -0
  55. data/config/initializers/cookies_serializer.rb +3 -0
  56. data/config/initializers/filter_parameter_logging.rb +4 -0
  57. data/config/initializers/inflections.rb +16 -0
  58. data/config/initializers/mime_types.rb +4 -0
  59. data/config/initializers/session_store.rb +3 -0
  60. data/config/initializers/wrap_parameters.rb +9 -0
  61. data/config/locales/en.yml +23 -0
  62. data/config/routes.rb +36 -0
  63. data/config/secrets.yml +22 -0
  64. data/db/seeds.rb +9 -0
  65. data/distribot-ui.gemspec +45 -0
  66. data/docker-compose.yml +32 -0
  67. data/docs/distribot-ui-screenshot.png +0 -0
  68. data/lib/assets/.keep +0 -0
  69. data/lib/distribot-ui.rb +3 -0
  70. data/lib/distribot-ui/command.rb +62 -0
  71. data/lib/distribot-ui/version.rb +4 -0
  72. data/lib/redis_model.rb +109 -0
  73. data/lib/tasks/.keep +0 -0
  74. data/provision/distribot-ui.sh +52 -0
  75. data/public/404.html +67 -0
  76. data/public/422.html +67 -0
  77. data/public/500.html +66 -0
  78. data/public/favicon.ico +0 -0
  79. data/public/robots.txt +5 -0
  80. data/spec/controllers/admin_controller_spec.rb +27 -0
  81. data/spec/controllers/flow_controller_spec.rb +87 -0
  82. data/spec/controllers/handler_controller_spec.rb +12 -0
  83. data/spec/controllers/signin_controller_spec.rb +88 -0
  84. data/spec/controllers/worker_controller_spec.rb +12 -0
  85. data/spec/factories/users.rb +7 -0
  86. data/spec/helpers/application_helper_spec.rb +24 -0
  87. data/spec/models/user_spec.rb +32 -0
  88. data/spec/spec_helper.rb +80 -0
  89. metadata +351 -0
@@ -0,0 +1,21 @@
1
+
2
+ <div class="ui page grid">
3
+ <div class="column">
4
+ <div class="ui icon info message">
5
+ <i class="info icon"></i>
6
+ <div class="content">
7
+ <div class="header">There are no flows yet</div>
8
+ <p>
9
+ If you had flows, this is where they'd be.
10
+ </p>
11
+ <p>
12
+ <a href="<%= create_flow_path %>" class="ui green right labeled icon button">
13
+ Create New Flow
14
+ <i class="right arrow icon"></i>
15
+ </a>
16
+ </p>
17
+ </div>
18
+ </div>
19
+
20
+ </div>
21
+ </div>
@@ -0,0 +1,54 @@
1
+
2
+ <div class="ui page grid">
3
+ <div class="column">
4
+ <div class="ui two column grid">
5
+ <div class="column">
6
+ <h2>Flows</h2>
7
+ </div>
8
+ <div class="column right aligned">
9
+ <a href="<%= create_flow_path %>" class="ui green button right labeled icon">
10
+ Create New Flow
11
+ <i class="right arrow icon"></i>
12
+ </a>
13
+ </div>
14
+ </div>
15
+ <div class="ui divider"></div>
16
+ <table class="ui very basic celled collapsed table">
17
+ <thead>
18
+ <th class="six wide">Flows ID</th>
19
+ <th class="four wide">Created</th>
20
+ <th class="six wide">Progress</th>
21
+ </thead>
22
+ <tbody>
23
+ <%
24
+ @flows.sort_by(&:created_at).reverse_each do |flow|
25
+ %>
26
+ <tr>
27
+ <td>
28
+ <a href="<%= show_flow_path(flow_id: flow.id) %>"><%= flow.id %></a>
29
+ </td>
30
+ <td>
31
+ <%= time_ago_in_words Time.at(flow.created_at) %> ago
32
+ </td>
33
+ <td>
34
+ <%
35
+ flow.phases.each do |phase|
36
+ %>
37
+ <div class="phase">
38
+ <%= phase.name %>
39
+ <% if flow.current_phase == phase.name %>
40
+ <i class="left arrow icon"></i>
41
+ <% end %>
42
+ </div>
43
+ <%
44
+ end
45
+ %>
46
+ </td>
47
+ </tr>
48
+ <%
49
+ end
50
+ %>
51
+ </tbody>
52
+ </table>
53
+ </div>
54
+ </div>
@@ -0,0 +1 @@
1
+ show.html.erb
@@ -0,0 +1,35 @@
1
+
2
+ <div class="ui page grid">
3
+ <div class="column">
4
+ <div class="ui two column grid">
5
+ <div class="column">
6
+ <h2>Handlers</h2>
7
+ </div>
8
+ <div class="column right aligned">
9
+ </div>
10
+ </div>
11
+ <div class="ui divider"></div>
12
+ <table class="ui very basic celled collapsed table">
13
+ <thead>
14
+ <th class="eight wide">Name</th>
15
+ <th class="eight wide">Version</th>
16
+ </thead>
17
+ <tbody>
18
+ <%
19
+ @handlers.sort_by(&:name).each do |handler|
20
+ %>
21
+ <tr>
22
+ <td>
23
+ <a href="<%= show_handler_path(name: handler.name, version: handler.version) %>"><%= handler.name %></a>
24
+ </td>
25
+ <td>
26
+ <%= handler.version %>
27
+ </td>
28
+ </tr>
29
+ <%
30
+ end
31
+ %>
32
+ </tbody>
33
+ </table>
34
+ </div>
35
+ </div>
@@ -0,0 +1 @@
1
+ show.html.erb
@@ -0,0 +1,72 @@
1
+ <!DOCTYPE html>
2
+ <!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
3
+ <!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
4
+ <!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
5
+ <head>
6
+ <!-- Meta -->
7
+ <meta charset="utf-8">
8
+ <title><%= @meta_title || params[:action].titlecase %> | Distribot</title>
9
+ <meta name="description" content="<%= content_for?(:meta_description) ? yield(:meta_description) : "" %>">
10
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
11
+ <meta name="author" content="">
12
+ <link rel="canonical" href="">
13
+
14
+ <!-- Favicon -->
15
+ <link rel="shortcut icon" href="/favicon.ico">
16
+
17
+ <%= csrf_meta_tags %>
18
+ <%= stylesheet_link_tag "application", :media => "all" %>
19
+ <%= stylesheet_link_tag params[:controller], :media => 'all' if Rails.application.assets.find_asset("#{params[:controller]}.css") %>
20
+ <%= javascript_include_tag "application" %>
21
+
22
+ <%= javascript_include_tag params[:controller] if Rails.application.assets.find_asset("#{params[:controller]}.js") %>
23
+ <%= javascript_include_tag "#{params[:controller]}/#{params[:action]}" if Rails.application.assets.find_asset("#{params[:controller]}/#{params[:action]}.js") %>
24
+
25
+ <%= yield(:head) %>
26
+ <%= yield(:css) %>
27
+
28
+ </head>
29
+
30
+ <body class="<%= controller_name %>" id="<%= action_name %>">
31
+
32
+ <div class="ui secondary pointing menu fixed main-nav">
33
+ <a class="brand item" href="/">
34
+ <%= image_tag 'distribot-70x70.png', class: 'ui image' %>
35
+ &nbsp;&nbsp;
36
+ Distribot
37
+ </a>
38
+ <% if signed_in? %>
39
+ <a class="item <%= active_nav(:summary) %>" href="/">Summary</a>
40
+ <a class="item <%= active_nav(:flows) %>" href="/flows">Flows</a>
41
+ <a class="item <%= active_nav(:handlers) %>" href="/handlers">Handlers</a>
42
+ <a class="item <%= active_nav(:workers) %>" href="/workers">Workers</a>
43
+ <% end %>
44
+ <% if signed_in? %>
45
+ <div id="account-menu" style="position: absolute; right: 8px; top: 12px; border-radius: 0px; white-space: nowrap">
46
+ <div class="ui image label red"><%= current_user.email %>
47
+ <a class="ui detail" href="/signout">Sign Out</a>
48
+ </div>
49
+ </div>
50
+ <% end %>
51
+ </div>
52
+
53
+
54
+ <div id="main" class="ui grid">
55
+ <div class="column">
56
+
57
+
58
+ <% if flash[:error] || flash[:notice] %>
59
+ <div class="ui page grid">
60
+ <div class="row">
61
+ <div class="column">
62
+ <%= semantic_flash %>
63
+ </div>
64
+ </div>
65
+ </div>
66
+ <% end %>
67
+ <%= yield %>
68
+ </div>
69
+ </div>
70
+
71
+ </body>
72
+ </html>
@@ -0,0 +1,32 @@
1
+
2
+ <div class="ui page stackable grid">
3
+ <div class="row">
4
+ <div class="four wide computer three wide tablet only column">
5
+ </div>
6
+ <div class="eight wide computer ten wide tablet sixteen wide mobile column">
7
+ <%= form_tag({}, method: :post, class: "ui form signin-form") do %>
8
+ <div class="ui segment top attached">
9
+ <h3>Sign In</h3>
10
+ </div>
11
+ <div class="ui attached segment">
12
+ <div class="ui required field">
13
+ <label>Email:</label>
14
+ <input type="email" name="email" class="ui input">
15
+ </div>
16
+ <div class="ui required field">
17
+ <label>Password:</label>
18
+ <input type="password" name="password" class="ui input">
19
+ </div>
20
+ <div class="ui error message"></div>
21
+ </div>
22
+ <div class="ui bottom attached segment right aligned">
23
+ <button class="ui green right labeled icon button">
24
+ Sign In
25
+ <i class="ui right arrow icon"></i>
26
+ </button>
27
+ </div>
28
+ <% end %>
29
+ <div class="four wide computer three wide tablet only column">
30
+ </div>
31
+ </div>
32
+ </div>
@@ -0,0 +1,31 @@
1
+
2
+ <div class="ui page grid">
3
+ <div class="column">
4
+ <div class="ui two column grid">
5
+ <div class="column">
6
+ <h2>Workers</h2>
7
+ </div>
8
+ <div class="column right aligned">
9
+ </div>
10
+ </div>
11
+ <div class="ui divider"></div>
12
+ <table class="ui very basic celled collapsed table">
13
+ <thead>
14
+ <th class="six wide">Name</th>
15
+ </thead>
16
+ <tbody>
17
+ <%
18
+ @workers.sort_by(&:name).each do |worker|
19
+ %>
20
+ <tr>
21
+ <td>
22
+ <a href="<%= show_worker_path(name: worker.name) %>"><%= worker.name %></a>
23
+ </td>
24
+ </tr>
25
+ <%
26
+ end
27
+ %>
28
+ </tbody>
29
+ </table>
30
+ </div>
31
+ </div>
@@ -0,0 +1 @@
1
+ show.html.erb
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "securerandom"
4
+ require "thor"
5
+
6
+ dir = File.expand_path("../../", __FILE__)
7
+ ENV["BUNDLE_GEMFILE"] ||= File.join(dir, "Gemfile.production")
8
+ ENV["SECRET_KEY_BASE"] ||= SecureRandom.hex(64)
9
+ ENV["RAILS_ENV"] ||= "production"
10
+
11
+ require File.join(dir, "lib/distribot-ui/command.rb")
12
+
13
+ DistribotUI::Command.start(ARGV)
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ pid = ARGV.shift
4
+ begin
5
+ loop do
6
+ # wait old distribot-ui process shutdown
7
+ Process.kill(0, pid.to_i)
8
+ sleep 0.1
9
+ end
10
+ rescue Errno::ESRCH
11
+ exec(*ARGV)
12
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,33 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "rails"
4
+ # Pick the frameworks you want:
5
+ require "active_model/railtie"
6
+ require "active_job/railtie"
7
+ # require "active_record/railtie"
8
+ require "action_controller/railtie"
9
+ require "action_mailer/railtie"
10
+ require "action_view/railtie"
11
+ require "sprockets/railtie"
12
+ # require "rails/test_unit/railtie"
13
+
14
+ # Require the gems listed in Gemfile, including any gems
15
+ # you've limited to :test, :development, or :production.
16
+ Bundler.require(*Rails.groups)
17
+
18
+ module DistribotUI
19
+ class Application < Rails::Application
20
+ # Settings in config/environments/* take precedence over those specified here.
21
+ # Application configuration should go into files in config/initializers
22
+ # -- all .rb files in that directory are automatically loaded.
23
+ config.autoload_paths += %W(#{config.root}/lib)
24
+
25
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
26
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
27
+ # config.time_zone = 'Central Time (US & Canada)'
28
+
29
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31
+ # config.i18n.default_locale = :de
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
+
3
+ require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,39 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+ config.web_console.whitelisted_ips = ENV['CONSOLE_WHITELIST_IPS']
9
+
10
+ # Do not eager load code on boot.
11
+ config.eager_load = false
12
+
13
+ # Show full error reports and disable caching.
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send.
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger.
21
+ config.active_support.deprecation = :log
22
+
23
+ # Debug mode disables concatenation and preprocessing of assets.
24
+ # This option may cause significant delays in view rendering with a large
25
+ # number of complex assets.
26
+ config.assets.debug = true
27
+
28
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
29
+ # yet still be able to expire them through the digest params.
30
+ config.assets.digest = true
31
+
32
+ # Adds additional error checking when serving assets at runtime.
33
+ # Checks for improperly declared sprockets dependencies.
34
+ # Raises helpful error messages.
35
+ config.assets.raise_runtime_errors = true
36
+
37
+ # Raises error for missing translations
38
+ # config.action_view.raise_on_missing_translations = true
39
+ end
@@ -0,0 +1,76 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like
20
+ # NGINX, varnish or squid.
21
+ # config.action_dispatch.rack_cache = true
22
+
23
+ # Disable serving static files from the `/public` folder by default since
24
+ # Apache or NGINX already handles this.
25
+ config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
26
+
27
+ # Compress JavaScripts and CSS.
28
+ config.assets.js_compressor = :uglifier
29
+ # config.assets.css_compressor = :sass
30
+
31
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
32
+ config.assets.compile = false
33
+
34
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35
+ # yet still be able to expire them through the digest params.
36
+ config.assets.digest = true
37
+
38
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
39
+
40
+ # Specifies the header that your server uses for sending files.
41
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
43
+
44
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
45
+ # config.force_ssl = true
46
+
47
+ # Use the lowest log level to ensure availability of diagnostic information
48
+ # when problems arise.
49
+ config.log_level = :debug
50
+
51
+ # Prepend all log lines with the following tags.
52
+ # config.log_tags = [ :subdomain, :uuid ]
53
+
54
+ # Use a different logger for distributed setups.
55
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
56
+
57
+ # Use a different cache store in production.
58
+ # config.cache_store = :mem_cache_store
59
+
60
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
61
+ # config.action_controller.asset_host = 'http://assets.example.com'
62
+
63
+ # Ignore bad email addresses and do not raise email delivery errors.
64
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
65
+ # config.action_mailer.raise_delivery_errors = false
66
+
67
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
68
+ # the I18n.default_locale when a translation cannot be found).
69
+ config.i18n.fallbacks = true
70
+
71
+ # Send deprecation notices to registered listeners.
72
+ config.active_support.deprecation = :notify
73
+
74
+ # Use default logging formatter so that PID and timestamp are not suppressed.
75
+ config.log_formatter = ::Logger::Formatter.new
76
+ end