distribot-ui 0.1.0
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/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +12 -0
- data/Dockerfile +9 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +270 -0
- data/LICENSE +201 -0
- data/README.md +25 -0
- data/Rakefile +21 -0
- data/app/assets/images/.keep +0 -0
- data/app/assets/images/distribot-70x70.png +0 -0
- data/app/assets/javascripts/application.js +28 -0
- data/app/assets/javascripts/jquery.sparkline.min.js +5 -0
- data/app/assets/javascripts/signin/signin.js +30 -0
- data/app/assets/stylesheets/application.css.scss +17 -0
- data/app/controllers/admin_controller.rb +15 -0
- data/app/controllers/application_controller.rb +22 -0
- data/app/controllers/concerns/.keep +0 -0
- data/app/controllers/flow_controller.rb +64 -0
- data/app/controllers/handler_controller.rb +17 -0
- data/app/controllers/signin_controller.rb +22 -0
- data/app/controllers/worker_controller.rb +17 -0
- data/app/helpers/application_helper.rb +16 -0
- data/app/mailers/.keep +0 -0
- data/app/models/.keep +0 -0
- data/app/models/concerns/.keep +0 -0
- data/app/models/user.rb +83 -0
- data/app/views/admin/home.html.erb +14 -0
- data/app/views/flow/create.html.erb +22 -0
- data/app/views/flow/empty_list.html.erb +21 -0
- data/app/views/flow/list.html.erb +54 -0
- data/app/views/flow/show.html.erb +1 -0
- data/app/views/handler/list.html.erb +35 -0
- data/app/views/handler/show.html.erb +1 -0
- data/app/views/layouts/application.html.erb +72 -0
- data/app/views/signin/signin.html.erb +32 -0
- data/app/views/worker/list.html.erb +31 -0
- data/app/views/worker/show.html.erb +1 -0
- data/bin/bundle +3 -0
- data/bin/distribot-ui +13 -0
- data/bin/distribot-ui-restart +12 -0
- data/bin/rails +4 -0
- data/bin/rake +4 -0
- data/bin/setup +29 -0
- data/config.ru +4 -0
- data/config/application.rb +33 -0
- data/config/boot.rb +3 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +39 -0
- data/config/environments/production.rb +76 -0
- data/config/environments/test.rb +42 -0
- data/config/initializers/assets.rb +17 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/cookies_serializer.rb +3 -0
- data/config/initializers/filter_parameter_logging.rb +4 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/mime_types.rb +4 -0
- data/config/initializers/session_store.rb +3 -0
- data/config/initializers/wrap_parameters.rb +9 -0
- data/config/locales/en.yml +23 -0
- data/config/routes.rb +36 -0
- data/config/secrets.yml +22 -0
- data/db/seeds.rb +9 -0
- data/distribot-ui.gemspec +45 -0
- data/docker-compose.yml +32 -0
- data/docs/distribot-ui-screenshot.png +0 -0
- data/lib/assets/.keep +0 -0
- data/lib/distribot-ui.rb +3 -0
- data/lib/distribot-ui/command.rb +62 -0
- data/lib/distribot-ui/version.rb +4 -0
- data/lib/redis_model.rb +109 -0
- data/lib/tasks/.keep +0 -0
- data/provision/distribot-ui.sh +52 -0
- data/public/404.html +67 -0
- data/public/422.html +67 -0
- data/public/500.html +66 -0
- data/public/favicon.ico +0 -0
- data/public/robots.txt +5 -0
- data/spec/controllers/admin_controller_spec.rb +27 -0
- data/spec/controllers/flow_controller_spec.rb +87 -0
- data/spec/controllers/handler_controller_spec.rb +12 -0
- data/spec/controllers/signin_controller_spec.rb +88 -0
- data/spec/controllers/worker_controller_spec.rb +12 -0
- data/spec/factories/users.rb +7 -0
- data/spec/helpers/application_helper_spec.rb +24 -0
- data/spec/models/user_spec.rb +32 -0
- data/spec/spec_helper.rb +80 -0
- metadata +351 -0
data/lib/tasks/.keep
ADDED
File without changes
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
setup_dependencies() {
|
6
|
+
sudo apt-get -y update
|
7
|
+
sudo apt-get -y autoremove
|
8
|
+
sudo apt-get install -y \
|
9
|
+
ruby2.0 \
|
10
|
+
ruby2.0-dev \
|
11
|
+
build-essential \
|
12
|
+
git \
|
13
|
+
wget \
|
14
|
+
vim \
|
15
|
+
librabbitmq-dev \
|
16
|
+
psmisc \
|
17
|
+
curl \
|
18
|
+
libcurl4-gnutls-dev \
|
19
|
+
python
|
20
|
+
|
21
|
+
sudo ln -sf /usr/bin/ruby2.0 /usr/bin/ruby && sudo ln -sf /usr/bin/gem2.0 /usr/bin/gem
|
22
|
+
|
23
|
+
if ! gem list | grep bundler; then
|
24
|
+
sudo gem install bundler --no-ri --no-rdoc
|
25
|
+
fi
|
26
|
+
|
27
|
+
# Don't fail because we haven't added github.com's ssh key to our known_hosts:
|
28
|
+
cat <<EOF | sudo tee -a /etc/ssh/ssh_config > /dev/null
|
29
|
+
Host github.com
|
30
|
+
StrictHostKeyChecking no
|
31
|
+
EOF
|
32
|
+
}
|
33
|
+
|
34
|
+
setup_dependencies
|
35
|
+
|
36
|
+
while ! ( echo -e "443\n6379\n5672" | xargs -i nc -w 1 -zv $INFRA_HOST {} ) ; do
|
37
|
+
echo "Waiting for infra to come up..."
|
38
|
+
sleep 5
|
39
|
+
done
|
40
|
+
|
41
|
+
cd /var/www/distribot-ui
|
42
|
+
bundle
|
43
|
+
|
44
|
+
echo '
|
45
|
+
######## #### ###### ######## ######## #### ######## ####### ########
|
46
|
+
## ## ## ## ## ## ## ## ## ## ## ## ## ##
|
47
|
+
## ## ## ## ## ## ## ## ## ## ## ## ##
|
48
|
+
## ## ## ###### ## ######## ## ######## ## ## ##
|
49
|
+
## ## ## ## ## ## ## ## ## ## ## ## ##
|
50
|
+
## ## ## ## ## ## ## ## ## ## ## ## ## ##
|
51
|
+
######## #### ###### ## ## ## #### ######## ####### ##
|
52
|
+
'
|
data/public/404.html
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
data/public/422.html
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
data/public/500.html
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
data/public/favicon.ico
ADDED
File without changes
|
data/public/robots.txt
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AdminController do
|
4
|
+
describe '#home' do
|
5
|
+
context 'when signed in' do
|
6
|
+
before do
|
7
|
+
@user = FactoryGirl.create(:user)
|
8
|
+
controller.sign_in @user
|
9
|
+
get :home
|
10
|
+
end
|
11
|
+
it 'renders the correct template' do
|
12
|
+
expect(response).to render_template :home
|
13
|
+
end
|
14
|
+
end
|
15
|
+
context 'when not signed in' do
|
16
|
+
before do
|
17
|
+
get :home
|
18
|
+
end
|
19
|
+
it 'redirects to the signin page' do
|
20
|
+
expect(response).to redirect_to :signin
|
21
|
+
end
|
22
|
+
it 'sets the error message' do
|
23
|
+
expect(flash[:error]).not_to be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FlowController do
|
4
|
+
describe '#list' do
|
5
|
+
context 'when there' do
|
6
|
+
context 'are flows' do
|
7
|
+
before do
|
8
|
+
expect(Distribot::Flow).to receive(:active) do
|
9
|
+
flow = double('flow')
|
10
|
+
[ flow ]
|
11
|
+
end
|
12
|
+
get :list
|
13
|
+
end
|
14
|
+
it 'lists them' do
|
15
|
+
expect(response).to render_template :list
|
16
|
+
end
|
17
|
+
end
|
18
|
+
context 'are no flows' do
|
19
|
+
before do
|
20
|
+
expect(Distribot::Flow).to receive(:active){ [] }
|
21
|
+
get :list
|
22
|
+
end
|
23
|
+
it 'shows the empty state' do
|
24
|
+
expect(response).to render_template :empty_list
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
describe '#show' do
|
30
|
+
context 'when the flow exists' do
|
31
|
+
before do
|
32
|
+
@flow = Distribot::Flow.new(id: 'xxx')
|
33
|
+
expect(Distribot::Flow).to receive(:find).with('xxx'){ @flow }
|
34
|
+
get :show, flow_id: @flow.id
|
35
|
+
end
|
36
|
+
it 'is displayed' do
|
37
|
+
expect(response).to be_successful
|
38
|
+
expect(response).to render_template :show
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
describe '#create' do
|
43
|
+
describe 'GET' do
|
44
|
+
before do
|
45
|
+
expect(Distribot::Flow).to receive(:new)
|
46
|
+
get :create
|
47
|
+
end
|
48
|
+
it 'renders the correct template' do
|
49
|
+
expect(response).to render_template :create
|
50
|
+
end
|
51
|
+
end
|
52
|
+
describe 'POST' do
|
53
|
+
context 'when successful' do
|
54
|
+
before do
|
55
|
+
@flow = Distribot::Flow.new(id: 'xxx')
|
56
|
+
expect(Distribot::Flow).to receive(:create!){ @flow }
|
57
|
+
post :create, json: {foo: :bar}.to_json
|
58
|
+
end
|
59
|
+
it 'creates a new flow and redirects to view the new flow' do
|
60
|
+
expect(flash[:notice]).not_to be_nil
|
61
|
+
expect(response).to redirect_to show_flow_path(flow_id: @flow.id)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
context 'when creation fails' do
|
65
|
+
context 'because of bad JSON' do
|
66
|
+
before do
|
67
|
+
post :create, json: 'this is not JSON'
|
68
|
+
end
|
69
|
+
it 'says it was bad JSON, and lets the user try again' do
|
70
|
+
expect(response).to render_template :create
|
71
|
+
expect(flash[:error]).to match 'Invalid JSON'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
context 'for some other reason' do
|
75
|
+
before do
|
76
|
+
expect(Distribot::Flow).to receive(:create!){ raise "Test Error" }
|
77
|
+
post :create, json: {some_json: :that_fails}.to_json
|
78
|
+
end
|
79
|
+
it 'allows the user to try again' do
|
80
|
+
expect(response).to render_template :create
|
81
|
+
expect(flash[:error]).to match 'try again'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SigninController do
|
4
|
+
|
5
|
+
describe '#signin' do
|
6
|
+
before do
|
7
|
+
get :signin
|
8
|
+
end
|
9
|
+
it 'renders the correct template' do
|
10
|
+
expect(response).to render_template :signin
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#submit_signin' do
|
15
|
+
before do
|
16
|
+
@user = FactoryGirl.create(:user)
|
17
|
+
@form = {
|
18
|
+
email: @user.email,
|
19
|
+
password: @user.password
|
20
|
+
}
|
21
|
+
end
|
22
|
+
context 'when the email' do
|
23
|
+
context 'is valid' do
|
24
|
+
context 'and the password' do
|
25
|
+
context 'is correct' do
|
26
|
+
before do
|
27
|
+
post :submit_signin, @form
|
28
|
+
end
|
29
|
+
it 'signs the user in' do
|
30
|
+
expect(session[:user_id]).to eq @user.id
|
31
|
+
end
|
32
|
+
it 'redirects to /' do
|
33
|
+
expect(response).to redirect_to :admin_home
|
34
|
+
end
|
35
|
+
end
|
36
|
+
context 'is incorrect' do
|
37
|
+
before do
|
38
|
+
@form[:password] = 'invalid-password'
|
39
|
+
post :submit_signin, @form
|
40
|
+
end
|
41
|
+
it 'redirects back to signin page' do
|
42
|
+
expect(response).to redirect_to :signin
|
43
|
+
end
|
44
|
+
it 'sets the error message' do
|
45
|
+
expect(flash[:error]).not_to be_nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
context 'is invalid' do
|
51
|
+
before do
|
52
|
+
@form[:email] = 'invalid@invalid.com'
|
53
|
+
post :submit_signin, @form
|
54
|
+
end
|
55
|
+
it 'redirects back to signin page' do
|
56
|
+
expect(response).to redirect_to :signin
|
57
|
+
end
|
58
|
+
it 'sets the error message' do
|
59
|
+
expect(flash[:error]).not_to be_nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#signout' do
|
66
|
+
context 'when signed in' do
|
67
|
+
before do
|
68
|
+
@user = FactoryGirl.create(:user)
|
69
|
+
controller.sign_in @user
|
70
|
+
get :signout
|
71
|
+
end
|
72
|
+
it 'redirects to signin' do
|
73
|
+
expect(response).to redirect_to :signin
|
74
|
+
end
|
75
|
+
it 'removes session:user_id' do
|
76
|
+
expect(session[:user_id]).to be_nil
|
77
|
+
end
|
78
|
+
end
|
79
|
+
context 'when not signed in' do
|
80
|
+
before do
|
81
|
+
get :signout
|
82
|
+
end
|
83
|
+
it 'redirects to signin' do
|
84
|
+
expect(response).to redirect_to :signin
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|