localtower 0.4.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -46
- data/app/controllers/localtower/pages_controller.rb +28 -42
- data/app/helpers/localtower/application_helper.rb +0 -18
- data/app/views/layouts/localtower/application.html.erb +20 -79
- data/app/views/localtower/pages/_alert_no_models.html.erb +3 -0
- data/app/views/localtower/pages/migrations.html.erb +50 -120
- data/app/views/localtower/pages/models.html.erb +53 -68
- data/app/views/localtower/pages/new_migration.html.erb +103 -0
- data/app/views/localtower/pages/new_model.html.erb +87 -0
- data/config/routes.rb +8 -17
- data/lib/localtower/generators/migration.rb +53 -181
- data/lib/localtower/generators/model.rb +53 -32
- data/lib/localtower/generators/service_objects/insert_array.rb +23 -0
- data/lib/localtower/generators/service_objects/insert_defaults.rb +15 -43
- data/lib/localtower/generators/service_objects/insert_indexes.rb +80 -0
- data/lib/localtower/generators/service_objects/insert_nullable.rb +23 -0
- data/lib/localtower/status.rb +12 -7
- data/lib/localtower/tools.rb +29 -24
- data/lib/localtower/version.rb +1 -1
- data/lib/localtower.rb +0 -1
- data/public/css/app.css +0 -49
- data/public/js/app.js +216 -86
- data/public/light-bootstrap-dashboard-master/assets/css/light-bootstrap-dashboard.css +9 -35
- data/public/screenshots/v1.0.0/migrations.png +0 -0
- data/public/screenshots/v1.0.0/models.png +0 -0
- data/public/screenshots/v1.0.0/new_migration.png +0 -0
- data/public/screenshots/v1.0.0/new_model.png +0 -0
- data/public/vendor/font-awesome.min.css +4 -0
- data/public/vendor/highlight-js-default.min.css +9 -0
- data/public/vendor/highlight.min.js +1198 -0
- data/public/{js → vendor}/masonry.pkgd.min.js +0 -0
- data/spec/dummy/Gemfile +0 -3
- data/spec/dummy/Gemfile.lock +78 -95
- data/spec/dummy/app/controllers/pages_controller.rb +0 -2
- data/spec/dummy/app/models/post.rb +3 -0
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/app/views/pages/home.html.erb +0 -1
- data/spec/dummy/config/database.yml +1 -1
- data/spec/dummy/config/environments/development.rb +3 -1
- data/spec/dummy/config/puma.rb +1 -1
- data/spec/dummy/db/migrate/20230119221452_create_users.rb +14 -0
- data/spec/dummy/db/migrate/20230119221751_change_users_at1674166670.rb +7 -0
- data/spec/dummy/db/migrate/20230119222054_create_posts.rb +11 -0
- data/spec/dummy/db/migrate/20230119222106_change_posts_at1674166865.rb +5 -0
- data/spec/dummy/db/schema.rb +41 -0
- data/spec/dummy/log/development.log +16030 -10038
- data/spec/dummy/log/localtower.log +1878 -439
- data/spec/dummy/log/test.log +0 -281
- data/spec/dummy/test/index.html +38 -0
- data/spec/dummy/tmp/pids/server.pid +1 -1
- data/spec/factories/migration.rb +25 -41
- data/spec/factories/model.rb +39 -25
- data/spec/lib/localtower/generators/migration_spec.rb +36 -63
- data/spec/lib/localtower/generators/model_spec.rb +43 -34
- data/spec/lib/localtower/generators/service_objects/insert_array_spec.rb +47 -0
- data/spec/lib/localtower/generators/service_objects/insert_defaults_spec.rb +30 -35
- data/spec/lib/localtower/generators/service_objects/insert_indexes_spec.rb +90 -0
- data/spec/lib/localtower/generators/service_objects/insert_nullable_spec.rb +61 -0
- data/spec/lib/localtower/tools_spec.rb +1 -11
- data/spec/spec_helper.rb +25 -5
- metadata +38 -30
- data/app/views/localtower/pages/dashboard.html.erb +0 -67
- data/app/views/localtower/pages/logs.html.erb +0 -84
- data/app/views/localtower/pages/relations.html.erb +0 -66
- data/app/views/localtower/pages/tasks.html.erb +0 -48
- data/lib/localtower/generators/relation.rb +0 -59
- data/lib/localtower/plugins/capture.rb +0 -197
- data/lib/tasks/localtower_tasks.rake +0 -4
- data/spec/dummy/lib/playground.rb +0 -0
- data/spec/dummy/log/localtower_capture_d8979d360722798f7b6eb1a2694a3791.json +0 -1
- data/spec/lib/localtower/generators/relation_spec.rb +0 -65
@@ -1,77 +1,62 @@
|
|
1
1
|
<% content_for :title do %>Models<% end %>
|
2
|
-
|
3
2
|
<div class="row">
|
4
3
|
<div class="col-md-12">
|
5
|
-
<div class="
|
6
|
-
<div class="
|
7
|
-
<
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
<div class="row">
|
14
|
-
<div class="col-md-6">
|
15
|
-
<div class="form-group">
|
16
|
-
<label>Name of the Model</label>
|
17
|
-
<input type="text" name="models[model_name]" class="form-control">
|
18
|
-
</div>
|
19
|
-
</div>
|
20
|
-
</div>
|
21
|
-
|
22
|
-
<table class="table table-hover table-striped">
|
23
|
-
<thead>
|
24
|
-
<th>Column Name</th>
|
25
|
-
<th>Type</th>
|
26
|
-
<th>Default</th>
|
27
|
-
<th>Index?</th>
|
28
|
-
<th>Can be null?</th>
|
29
|
-
<th></th>
|
30
|
-
</thead>
|
31
|
-
|
32
|
-
<tbody data-selector="tbody">
|
33
|
-
<tr data-selector="tr">
|
34
|
-
<td>
|
35
|
-
<input type="text" name="models[attributes][][attribute_name]" class="form-control">
|
36
|
-
</td>
|
37
|
-
<td>
|
38
|
-
<%= select_tag "models[attributes][][attribute_type]", options_for_select(::Localtower::Generators::Migration::TYPES), class: "form-control" %>
|
39
|
-
</td>
|
40
|
-
<td>
|
41
|
-
<%= select_tag "models[attributes][][defaults]", options_for_select(::Localtower::Generators::Migration::DEFAULTS), include_blank: true, class: "form-control" %>
|
42
|
-
</td>
|
43
|
-
<td>
|
44
|
-
<input type="checkbox" value="true" name="models[attributes][][index]" class="form-control">
|
45
|
-
</td>
|
46
|
-
<td>
|
47
|
-
<input type="checkbox" value="true" name="models[attributes][][nullable]" class="form-control" checked>
|
48
|
-
</td>
|
49
|
-
<td>
|
50
|
-
<div class="pull-right">
|
51
|
-
<button class="btn btn-danger btn-xs pointer" data-selector="remove">Remove</button>
|
52
|
-
</div>
|
53
|
-
</td>
|
54
|
-
</tr>
|
55
|
-
</tbody>
|
56
|
-
</table>
|
57
|
-
|
58
|
-
<div class="row">
|
59
|
-
<div class="col-md-12 text-center">
|
60
|
-
<i class="pe-7s-plus pointer" data-selector="duplicate" style="font-size: 3em;"></i>
|
4
|
+
<div class="content">
|
5
|
+
<div class="">
|
6
|
+
<div class="card">
|
7
|
+
<div class="">
|
8
|
+
<% if @models.empty? %>
|
9
|
+
<%= render partial: 'alert_no_models' %>
|
10
|
+
<% end %>
|
61
11
|
</div>
|
62
12
|
</div>
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
13
|
+
<div class="grid">
|
14
|
+
<div class="grid-sizer"></div>
|
15
|
+
<% @models.each do |model| %>
|
16
|
+
<div class="grid-item text-small card">
|
17
|
+
<div class="text-center">
|
18
|
+
<h5><%= model[:name] %></h5>
|
19
|
+
</div>
|
20
|
+
<table class="table table-hover table-striped table-condensed">
|
21
|
+
<thead>
|
22
|
+
<th>Field</th>
|
23
|
+
<th>Type</th>
|
24
|
+
<th>Belongs To</th>
|
25
|
+
<th>Index?</th>
|
26
|
+
</thead>
|
27
|
+
<tbody>
|
28
|
+
<% model[:attributes_list].each do |attribute_data| %>
|
29
|
+
<tr>
|
30
|
+
<td>
|
31
|
+
<code>
|
32
|
+
<%= attribute_data["name"] %>
|
33
|
+
</code>
|
34
|
+
</td>
|
35
|
+
<td>
|
36
|
+
<%= attribute_data["type_clean"] %>
|
37
|
+
</td>
|
38
|
+
<td>
|
39
|
+
<% if attribute_data["belongs_to"] %>
|
40
|
+
<span class="label label-primary">
|
41
|
+
<%= attribute_data["belongs_to"] %>
|
42
|
+
</span>
|
43
|
+
<% end %>
|
44
|
+
</td>
|
45
|
+
<td>
|
46
|
+
<% if attribute_data["index"].any? %>
|
47
|
+
<span class="label label-success">Yes</span>
|
48
|
+
<% else %>
|
49
|
+
<span class="label label-default">No</span>
|
50
|
+
<% end %>
|
51
|
+
</td>
|
52
|
+
</tr>
|
53
|
+
<% end %>
|
54
|
+
</tbody>
|
55
|
+
</table>
|
56
|
+
</div>
|
57
|
+
<% end %>
|
58
|
+
<div class="clearfix"></div>
|
73
59
|
</div>
|
74
|
-
<% end %>
|
75
60
|
</div>
|
76
61
|
</div>
|
77
62
|
</div>
|
@@ -0,0 +1,103 @@
|
|
1
|
+
<% content_for :title do %>New Migration<% end %>
|
2
|
+
<div class="row">
|
3
|
+
<div class="col-md-12">
|
4
|
+
<div class="card">
|
5
|
+
<div class="header">
|
6
|
+
<% if @models.empty? %>
|
7
|
+
<%= render partial: 'alert_no_models' %>
|
8
|
+
<% end %>
|
9
|
+
<div class="alert alert-warning">
|
10
|
+
<span>Remember, you can always edit your migration files manually before running "rails db:migrate"</span>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
<div class="content">
|
14
|
+
<%= form_tag migrations_path, class: "form" do %>
|
15
|
+
<div class="row">
|
16
|
+
<div class="container-table" data-selector="table">
|
17
|
+
<table class="table table-hover table-striped">
|
18
|
+
<thead>
|
19
|
+
<th> <span data-selector=''>On Model</span></th>
|
20
|
+
<th> <span data-selector=''>Action</span></th>
|
21
|
+
<th> <span data-selector='belongs_to_label'>Belongs To</span></th>
|
22
|
+
<th> <span data-selector='column_label'>Column</span></th>
|
23
|
+
<th> <span data-selector='default_label'>Default</span></th>
|
24
|
+
<th> <span data-selector='new_column_name_label'>New Column Name</span></th>
|
25
|
+
<th> <span data-selector='column_type_label'>Type</span></th>
|
26
|
+
<th> <span data-selector='index_options_label'>Index Options</span></th>
|
27
|
+
<th> <span data-selector='nullable_label'>Can be null?</span></th>
|
28
|
+
<th> <span data-selector=''></span></th>
|
29
|
+
</thead>
|
30
|
+
<tbody data-selector="tbody">
|
31
|
+
<tr data-selector="tr">
|
32
|
+
<td style='width: 300px;'>
|
33
|
+
<%= select_tag "migrations[][table_name]", options_for_select(Localtower::Tools.models.collect {|p| [ p, p.table_name ] }), class: "form-control" %>
|
34
|
+
</td>
|
35
|
+
<td style='width: 220px;'>
|
36
|
+
<%= select_tag "migrations[][action]", options_for_select(::Localtower::Generators::Migration::ACTIONS), class: "form-control", "data-selector" => "action" %>
|
37
|
+
</td>
|
38
|
+
<td>
|
39
|
+
<%= select_tag "migrations[][belongs_to]", options_for_select(Localtower::Tools.models.collect {|p| [ p, p.table_name ] }), class: "form-control", "data-selector" => "belongs_to" %>
|
40
|
+
</td>
|
41
|
+
<td class="text-center">
|
42
|
+
<input type="text" name="migrations[][column]" class="form-control" data-selector="column_text">
|
43
|
+
<%= select_tag "migrations[][column_list]", options_for_select(::Localtower::Tools.all_columns), class: "form-control", include_blank: true, "data-selector" => "column_list" %>
|
44
|
+
</td>
|
45
|
+
<td>
|
46
|
+
<%= select_tag "migrations[][default]", options_for_select(::Localtower::Generators::ServiceObjects::InsertDefaults::DEFAULTS), class: "form-control", include_blank: true, "data-selector" => "default_input" %>
|
47
|
+
</td>
|
48
|
+
<td>
|
49
|
+
<input type="text" name="migrations[][new_column_name]" class="form-control" data-selector="new_column_name">
|
50
|
+
</td>
|
51
|
+
<td>
|
52
|
+
<%= select_tag "migrations[][column_type]", options_for_select(::Localtower::Generators::Migration::TYPES), class: "form-control", "data-selector" => "column_type" %>
|
53
|
+
</td>
|
54
|
+
<td>
|
55
|
+
<div data-selector="index_options">
|
56
|
+
<div class="row">
|
57
|
+
<div class="col-md-4">
|
58
|
+
index: <br>
|
59
|
+
<%= select_tag "migrations[][index][using]", options_for_select(::Localtower::Generators::ServiceObjects::InsertIndexes::USING - ['none']), class: "form-control" %>
|
60
|
+
</div>
|
61
|
+
<div class="col-md-4">
|
62
|
+
unique:
|
63
|
+
<br>
|
64
|
+
<%= select_tag "migrations[][index][unique]", options_for_select(::Localtower::Generators::ServiceObjects::InsertIndexes::UNIQUE), class: "form-control" %>
|
65
|
+
</div>
|
66
|
+
<div class="col-md-4">
|
67
|
+
algorithm
|
68
|
+
<br>
|
69
|
+
<%= select_tag "migrations[][index][algorithm]", options_for_select(::Localtower::Generators::ServiceObjects::InsertIndexes::ALGO), class: "form-control" %>
|
70
|
+
</div>
|
71
|
+
</div>
|
72
|
+
</div>
|
73
|
+
</td>
|
74
|
+
<td>
|
75
|
+
<input data-selector="nullable_input" type="checkbox" value="true" name="migrations[][nullable]" class="form-control" checked>
|
76
|
+
</td>
|
77
|
+
<td>
|
78
|
+
<div class="pull-right">
|
79
|
+
<button class="btn btn-danger btn-xs pointer" data-selector="removeLineMigration">Remove line</button>
|
80
|
+
</div>
|
81
|
+
</td>
|
82
|
+
</tr>
|
83
|
+
</tbody>
|
84
|
+
</table>
|
85
|
+
</div>
|
86
|
+
</div>
|
87
|
+
<div class="row">
|
88
|
+
<div class="col-md-12 text-center">
|
89
|
+
<i class="pe-7s-plus pointer" data-selector="duplicateLineNewMigration" style="font-size: 3em;"></i>
|
90
|
+
</div>
|
91
|
+
</div>
|
92
|
+
<div class="row">
|
93
|
+
<div class="col-md-12 text-right">
|
94
|
+
<button type="submit" value="true" class="btn btn-success btn-fill" data-selector="submitNewMigration">
|
95
|
+
Generate the migration
|
96
|
+
</button>
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
<% end %>
|
100
|
+
</div>
|
101
|
+
</div>
|
102
|
+
</div>
|
103
|
+
</div>
|
@@ -0,0 +1,87 @@
|
|
1
|
+
<% content_for :title do %>New Model<% end %>
|
2
|
+
<div class="row">
|
3
|
+
<div class="col-md-12">
|
4
|
+
<div class="card">
|
5
|
+
<div class="header">
|
6
|
+
<div class="alert alert-warning">
|
7
|
+
<span>Remember, you can always edit your migration files manually before running "rails db:migrate"</span>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<div class="content">
|
11
|
+
<%= form_tag models_path, class: "form" do %>
|
12
|
+
<div class="row">
|
13
|
+
<div class="col-md-6">
|
14
|
+
<div class="form-group">
|
15
|
+
<label>Name of the Model</label>
|
16
|
+
<input type="text" data-selector="modelName" name="model[model_name]" class="form-control">
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
<div class="row">
|
21
|
+
<table class="table table-hover table-striped">
|
22
|
+
<thead>
|
23
|
+
<th>Type</th>
|
24
|
+
<th>Column Name</th>
|
25
|
+
<th>Default</th>
|
26
|
+
<th>Index Options</th>
|
27
|
+
<th>Can be null?</th>
|
28
|
+
<th></th>
|
29
|
+
</thead>
|
30
|
+
<tbody data-selector="tbody">
|
31
|
+
<tr data-selector="tr">
|
32
|
+
<td>
|
33
|
+
<%= select_tag "model[attributes][][attribute_type]", options_for_select(::Localtower::Generators::Migration::TYPES), class: "form-control" %>
|
34
|
+
</td>
|
35
|
+
<td>
|
36
|
+
<input type="text" data-selector="attributeName" name="model[attributes][][attribute_name]" class="form-control">
|
37
|
+
</td>
|
38
|
+
<td>
|
39
|
+
<%= select_tag "model[attributes][][default]", options_for_select(::Localtower::Generators::ServiceObjects::InsertDefaults::DEFAULTS), class: "form-control" %>
|
40
|
+
</td>
|
41
|
+
<td style='min-width: 240px'>
|
42
|
+
<div class="row">
|
43
|
+
<div class="col-md-4">
|
44
|
+
index: <br>
|
45
|
+
<%= select_tag "model[attributes][][index][using]", options_for_select(::Localtower::Generators::ServiceObjects::InsertIndexes::USING), class: "form-control" %>
|
46
|
+
</div>
|
47
|
+
<div class="col-md-4">
|
48
|
+
unique:
|
49
|
+
<br>
|
50
|
+
<%= select_tag "model[attributes][][index][unique]", options_for_select(::Localtower::Generators::ServiceObjects::InsertIndexes::UNIQUE), class: "form-control" %>
|
51
|
+
</div>
|
52
|
+
<div class="col-md-4">
|
53
|
+
algorithm
|
54
|
+
<br>
|
55
|
+
<%= select_tag "model[attributes][][index][algorithm]", options_for_select(::Localtower::Generators::ServiceObjects::InsertIndexes::ALGO), class: "form-control" %>
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
</td>
|
59
|
+
<td>
|
60
|
+
<input type="checkbox" value="true" name="model[attributes][][nullable]" class="form-control" checked>
|
61
|
+
</td>
|
62
|
+
<td>
|
63
|
+
<div class="pull-right">
|
64
|
+
<button class="btn btn-danger btn-xs pointer" data-selector="removeLineModel">Remove line</button>
|
65
|
+
</div>
|
66
|
+
</td>
|
67
|
+
</tr>
|
68
|
+
</tbody>
|
69
|
+
</table>
|
70
|
+
</div>
|
71
|
+
<div class="row">
|
72
|
+
<div class="col-md-12 text-center">
|
73
|
+
<i class="pe-7s-plus pointer" data-selector="duplicateLineNewModel" style="font-size: 3em;"></i>
|
74
|
+
</div>
|
75
|
+
</div>
|
76
|
+
<div class="row">
|
77
|
+
<div class="col-md-12 text-right">
|
78
|
+
<button type="submit" value="true" class="btn btn-success btn-fill" data-selector="submitNewModel">
|
79
|
+
Generate the migration (and the model)
|
80
|
+
</button>
|
81
|
+
</div>
|
82
|
+
</div>
|
83
|
+
<% end %>
|
84
|
+
</div>
|
85
|
+
</div>
|
86
|
+
</div>
|
87
|
+
</div>
|
data/config/routes.rb
CHANGED
@@ -1,22 +1,13 @@
|
|
1
1
|
Localtower::Engine.routes.draw do
|
2
|
-
get
|
3
|
-
|
2
|
+
get 'migrations/new', to: 'pages#new_migration', as: :new_migration
|
3
|
+
get 'migrations', to: 'pages#migrations', as: :migrations
|
4
|
+
post 'migrations', to: 'pages#post_migrations'
|
4
5
|
|
5
|
-
get
|
6
|
-
|
6
|
+
get 'models/new', to: 'pages#new_model', as: :new_model
|
7
|
+
get 'models', to: 'pages#models', as: :models
|
8
|
+
post 'models', to: 'pages#post_models'
|
7
9
|
|
8
|
-
|
9
|
-
post "relations", to: "pages#post_relations"
|
10
|
+
post 'actions', to: 'pages#post_actions', as: :actions
|
10
11
|
|
11
|
-
|
12
|
-
# post "tasks", to: "pages#post_tasks"
|
13
|
-
|
14
|
-
# get ':v/:asset', to: 'pages#asset_render', as: 'asset_render', :constraints => { :v => /[^\/]*/, :asset => /[^\/]*/ }
|
15
|
-
|
16
|
-
get 'dashboard', to: 'pages#dashboard', as: 'dashboard'
|
17
|
-
get 'logs', to: 'pages#logs', as: 'logs'
|
18
|
-
get 'logs/:md5', to: 'pages#log', as: 'log'
|
19
|
-
get 'logs/:md5/:var', to: 'pages#log_var', as: 'log_var'
|
20
|
-
|
21
|
-
root :to => redirect('dashboard')
|
12
|
+
root :to => redirect('models/new')
|
22
13
|
end
|