localtower 0.4.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +37 -46
  3. data/app/controllers/localtower/pages_controller.rb +28 -42
  4. data/app/helpers/localtower/application_helper.rb +0 -18
  5. data/app/views/layouts/localtower/application.html.erb +20 -79
  6. data/app/views/localtower/pages/_alert_no_models.html.erb +3 -0
  7. data/app/views/localtower/pages/migrations.html.erb +50 -120
  8. data/app/views/localtower/pages/models.html.erb +53 -68
  9. data/app/views/localtower/pages/new_migration.html.erb +103 -0
  10. data/app/views/localtower/pages/new_model.html.erb +87 -0
  11. data/config/routes.rb +8 -17
  12. data/lib/localtower/generators/migration.rb +53 -181
  13. data/lib/localtower/generators/model.rb +53 -32
  14. data/lib/localtower/generators/service_objects/insert_array.rb +23 -0
  15. data/lib/localtower/generators/service_objects/insert_defaults.rb +15 -43
  16. data/lib/localtower/generators/service_objects/insert_indexes.rb +80 -0
  17. data/lib/localtower/generators/service_objects/insert_nullable.rb +23 -0
  18. data/lib/localtower/status.rb +12 -7
  19. data/lib/localtower/tools.rb +29 -24
  20. data/lib/localtower/version.rb +1 -1
  21. data/lib/localtower.rb +0 -1
  22. data/public/css/app.css +0 -49
  23. data/public/js/app.js +216 -86
  24. data/public/light-bootstrap-dashboard-master/assets/css/light-bootstrap-dashboard.css +9 -35
  25. data/public/screenshots/v1.0.0/migrations.png +0 -0
  26. data/public/screenshots/v1.0.0/models.png +0 -0
  27. data/public/screenshots/v1.0.0/new_migration.png +0 -0
  28. data/public/screenshots/v1.0.0/new_model.png +0 -0
  29. data/public/vendor/font-awesome.min.css +4 -0
  30. data/public/vendor/highlight-js-default.min.css +9 -0
  31. data/public/vendor/highlight.min.js +1198 -0
  32. data/public/{js → vendor}/masonry.pkgd.min.js +0 -0
  33. data/spec/dummy/Gemfile +0 -3
  34. data/spec/dummy/Gemfile.lock +78 -95
  35. data/spec/dummy/app/controllers/pages_controller.rb +0 -2
  36. data/spec/dummy/app/models/post.rb +3 -0
  37. data/spec/dummy/app/models/user.rb +3 -0
  38. data/spec/dummy/app/views/pages/home.html.erb +0 -1
  39. data/spec/dummy/config/database.yml +1 -1
  40. data/spec/dummy/config/environments/development.rb +3 -1
  41. data/spec/dummy/config/puma.rb +1 -1
  42. data/spec/dummy/db/migrate/20230119221452_create_users.rb +14 -0
  43. data/spec/dummy/db/migrate/20230119221751_change_users_at1674166670.rb +7 -0
  44. data/spec/dummy/db/migrate/20230119222054_create_posts.rb +11 -0
  45. data/spec/dummy/db/migrate/20230119222106_change_posts_at1674166865.rb +5 -0
  46. data/spec/dummy/db/schema.rb +41 -0
  47. data/spec/dummy/log/development.log +16030 -10038
  48. data/spec/dummy/log/localtower.log +1878 -439
  49. data/spec/dummy/log/test.log +0 -281
  50. data/spec/dummy/test/index.html +38 -0
  51. data/spec/dummy/tmp/pids/server.pid +1 -1
  52. data/spec/factories/migration.rb +25 -41
  53. data/spec/factories/model.rb +39 -25
  54. data/spec/lib/localtower/generators/migration_spec.rb +36 -63
  55. data/spec/lib/localtower/generators/model_spec.rb +43 -34
  56. data/spec/lib/localtower/generators/service_objects/insert_array_spec.rb +47 -0
  57. data/spec/lib/localtower/generators/service_objects/insert_defaults_spec.rb +30 -35
  58. data/spec/lib/localtower/generators/service_objects/insert_indexes_spec.rb +90 -0
  59. data/spec/lib/localtower/generators/service_objects/insert_nullable_spec.rb +61 -0
  60. data/spec/lib/localtower/tools_spec.rb +1 -11
  61. data/spec/spec_helper.rb +25 -5
  62. metadata +38 -30
  63. data/app/views/localtower/pages/dashboard.html.erb +0 -67
  64. data/app/views/localtower/pages/logs.html.erb +0 -84
  65. data/app/views/localtower/pages/relations.html.erb +0 -66
  66. data/app/views/localtower/pages/tasks.html.erb +0 -48
  67. data/lib/localtower/generators/relation.rb +0 -59
  68. data/lib/localtower/plugins/capture.rb +0 -197
  69. data/lib/tasks/localtower_tasks.rake +0 -4
  70. data/spec/dummy/lib/playground.rb +0 -0
  71. data/spec/dummy/log/localtower_capture_d8979d360722798f7b6eb1a2694a3791.json +0 -1
  72. data/spec/lib/localtower/generators/relation_spec.rb +0 -65
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6eca3e0577b9e6f78d4982d046a3cba50519ee9eddc87367e6f04ce0abe77134
4
- data.tar.gz: 7df1c8a2b27f095c840cab877023b9920290795d4b257e8c51ce0cff5730d484
3
+ metadata.gz: 9db89fe02b54c1eb46633f4df610405c050aaf5a44bcdc22a90ffe7cbb54637b
4
+ data.tar.gz: 6738a7be7646e0c4cf0844def2b6785f659922c064cf5e7e0ac39242c6f5f7b4
5
5
  SHA512:
6
- metadata.gz: e8a389075ad641b51eddf4b41ef0a16b49ba8761c09e696edb94832e5b69896fbe051f8458110761e9767979a276e566c04fe162a6fedec6b5487158a3680802
7
- data.tar.gz: 5b05a0e034ae8c636ccc514423e4434583568440785295963da345cf30a414e4fac11462d39c8fede9e3420e913d8dd02808688e6dd19c2160f7dfd2583ffae8
6
+ metadata.gz: 2388bae27139b79e346b70fab53701f87112aca41d104fa3dcd8b2b9d3537dc9d54742c990384135cc347b50207d5023d96b699847b568731e78ed1204a3afe5
7
+ data.tar.gz: 18959e622626a9452fdc67dae321ef93f1be65e81657e66ad692f330bfe2fc47c29fb731c66adddd3d61f718c286caf70b9b0fa9e219ec616aea5acfd8aaee71
data/README.md CHANGED
@@ -4,42 +4,34 @@
4
4
 
5
5
  ## Intro
6
6
 
7
- Update in 2022, please use localtower version `>= 0.4.1`
7
+ Please use localtower version `>= 1.0.0`
8
8
  See installation process below.
9
+
9
10
  Compatibility:
10
11
  - Rails >= 5.2
11
12
  - Ruby >= 2.3
12
13
 
13
- ### See the schema
14
- ![Schema](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v0.1.6/1_schema.png)
15
-
16
14
  ### Create a model
17
- ![Models](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v0.1.6/2_models_1.png)
18
-
19
- ### Create a many to many relation
20
- ![Relations](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v0.1.6/3_relations.png)
15
+ ![New Model](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v1.0.0/new_model.png)
21
16
 
22
17
  ### Create a migration
23
- ![Migrations](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v0.1.6/4_migrations.png)
18
+ ![New Migration](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v1.0.0/new_migration.png)
19
+
20
+ ### See the Models
21
+ ![Models](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v1.0.0/models.png)
24
22
 
25
- ### Using the Capture plugin
26
- ![Capture](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v0.1.6/5_capture.png)
23
+ ### See the Migrations (and migrate)
24
+ ![Migrations](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v1.0.0/migrations.png)
27
25
 
28
26
  ## INSTALL
29
27
 
30
- Only tested with Rails 4.2 and Rails 5.1 (should work with any Rails 4.2+ application). Only tested with PostgreSQL.
28
+ Should work with any Rails 5.2+ application.
29
+ Only tested with PostgreSQL.
31
30
 
32
31
  Add to your `Gemfile` file:
33
32
  ```ruby
34
33
  group :development do
35
- gem "localtower", ">= 0.4.1"
36
- end
37
- ```
38
-
39
- If you want the latest master branch, add to your `Gemfile` file following:
40
- ```ruby
41
- group :development do
42
- gem "localtower", github: "damln/localtower"
34
+ gem "localtower"
43
35
  end
44
36
  ```
45
37
 
@@ -51,8 +43,8 @@ bundle install
51
43
  Add to your `config/routes.rb`:
52
44
  ```ruby
53
45
  MyApp::Application.routes.draw do
54
- if Rails.env.development? and defined?(Localtower)
55
- mount Localtower::Engine, at: "localtower"
46
+ if Rails.env.development?
47
+ mount Localtower::Engine, at: 'localtower'
56
48
  end
57
49
 
58
50
  # Your other routes here:
@@ -60,34 +52,32 @@ MyApp::Application.routes.draw do
60
52
  end
61
53
  ```
62
54
 
63
- ## Usage
64
-
65
- Open your browser at [http://localhost:3000/localtower](http://localhost:3000/localtower).
66
-
67
- ## Logger Usage (Capture plugin)
68
-
69
- You can put this line anywhere in your code:
55
+ /!\ IMPORTANT /!\
56
+ Change your config/environments/development.rb:
70
57
 
71
58
  ```ruby
72
- Localtower::Plugins::Capture.new(self, binding).save
73
- ```
74
-
75
- For example:
59
+ Rails.application.configure do
60
+ # This is the default:
61
+ # config.active_record.migration_error = :page_load
76
62
 
77
- ```ruby
78
- def my_method
79
- user = User.find(1)
80
- some_data = {foo: "bar"}
63
+ # Change it to:
64
+ config.active_record.migration_error = false if defined?(Localtower)
81
65
 
82
- Localtower::Plugins::Capture.new(self, binding).save
66
+ # ...
83
67
  end
84
68
  ```
85
69
 
86
- Then go to the Localtower intercave here: [http://localhost:3000/localtower/logs](http://localhost:3000/localtower/logs) and you will see the variables `user` and `some_data` in the UI.
70
+ If you know how to override this configuration in the gem instead of doing it in your app code, please open an issue and tell me your solution.
71
+
72
+ ## Usage
73
+
74
+ Open your browser at [http://localhost:3000/localtower](http://localhost:3000/localtower).
87
75
 
88
- ### Notes for the Capture plugin:
76
+ ## Roadmap
89
77
 
90
- The value for each variable will try to call `.to_json`. If you have a huge collection of models likes `@users` you will see all the collection as an Array.
78
+ - Be able to use `uuid` instead of `id` as primary when creating models.
79
+ - Realtime preview of the migration files
80
+ - Better frontend validation
91
81
 
92
82
  ## Run test
93
83
 
@@ -108,12 +98,12 @@ bundle exec rspec spec/
108
98
 
109
99
  ## Contribute
110
100
 
111
- Thanks for reporting issues, I'll do my best 💪
112
-
113
- [![Analytics](https://ga-beacon.appspot.com/UA-93841935-1/github-readme?pixel)](https://github.com/damln/localtower)
101
+ Thanks for reporting issues, I'll do my best to fix the bugs 💪
114
102
 
103
+ ![ga](https://www.google-analytics.com/collect?v=1&tid=G-1XG3EBE2DZ&cid=555&aip=1&t=event&ec=github&ea=visit&dp=readme&dt=gem)
115
104
 
116
105
  ## Deploy
106
+
117
107
  Only for official contributors.
118
108
 
119
109
  rm *.gem | gem build localtower.gemspec && gem push localtower-*.gem
@@ -123,5 +113,6 @@ Only for official contributors.
123
113
  Do not hesitate to open issues if you have troubles using the gem.
124
114
 
125
115
  - By Damian Le Nouaille Diez: https://damln.com
126
- - Link on RubyGems: https://rubygems.org/gems/localtower
127
-
116
+ - Supported by Explicit Ruby: https://explicit-ruby.run
117
+ - Link on RubyGems.org: https://rubygems.org/gems/localtower
118
+ - Stats on BestGems.org: https://bestgems.org/gems/localtower
@@ -2,25 +2,8 @@ require_dependency 'localtower/application_controller'
2
2
 
3
3
  module Localtower
4
4
  class PagesController < ApplicationController
5
-
6
- def dashboard
7
- end
8
-
9
- def logs
10
- @logs = Localtower::Plugins::Capture.new.logs
11
- end
12
-
13
- def log
14
- file_content = Localtower::Plugins::Capture.log_from_md5(clean_params['md5'])
15
-
16
- render json: file_content
17
- end
18
-
19
- def log_var
20
- file_content = Localtower::Plugins::Capture.log_from_md5(clean_params['md5'])
21
- returned = file_content["variables"].select {|i| i["event_name"] == clean_params[:var] }[0]["returned"]
22
-
23
- render json: returned
5
+ def new_migration
6
+ @models = ::Localtower::Tools.models_presented
24
7
  end
25
8
 
26
9
  def migrations
@@ -29,51 +12,54 @@ module Localtower
29
12
 
30
13
  def post_migrations
31
14
  # Because we have a list or a field, take the item from the list in priority
32
- clean_params["migrations"]["migrations"] = clean_params["migrations"]["migrations"].map do |action_line|
15
+ migrations = clean_params["migrations"].map do |action_line|
16
+ # This is used for "rename_column" action:
33
17
  action_line["new_column_type"] = action_line["column_type"]
34
18
 
35
- if action_line["column"].present?
36
- action_line["column"] = action_line["column"]
37
- end
38
-
39
19
  if action_line["column_list"].present?
40
20
  action_line["column"] = action_line["column_list"]
41
21
  end
42
22
 
43
23
  action_line.delete("column_list")
24
+ # / This is used for "rename_column" action
44
25
 
45
26
  action_line
46
27
  end
47
28
 
48
- use_generator(::Localtower::Generators::Migration, clean_params["migrations"])
29
+ use_generator(::Localtower::Generators::Migration, migrations)
30
+
49
31
  redirect_to migrations_path
50
32
  end
51
33
 
52
- def relations
53
- @need_models = ::Localtower::Tools.enought_models_for_relation?
34
+ def new_model
54
35
  end
55
36
 
56
- def post_relations
57
- use_generator(::Localtower::Generators::Relation, clean_params["relations"])
58
- redirect_to relations_path
37
+ def models
38
+ @models = ::Localtower::Tools.models_presented
59
39
  end
60
40
 
61
- # def tasks
62
- # @tasks = ['rake db:migrate RAILS_ENV=test']
63
- # end
64
-
65
- # def post_tasks
66
- # ::Localtower::Tools.perform_cmd(clean_params["task"]["name"], false)
41
+ def post_models
42
+ model = clean_params["model"]
43
+ model['attributes'] = model['attributes'].map do |attribute_line|
44
+ # Convert checkbox to ruby value:
45
+ attribute_line['nullable'] = false if attribute_line['nullable'].blank?
46
+
47
+ # Convert index hash:
48
+ if attribute_line['index']
49
+ attribute_line['index']['unique'] = true if attribute_line['index']['unique'] == 'true'
50
+ end
67
51
 
68
- # redirect_to tasks_path
69
- # end
52
+ attribute_line
53
+ end
70
54
 
71
- def models
55
+ use_generator(::Localtower::Generators::Model, model)
56
+ redirect_to migrations_path
72
57
  end
73
58
 
74
- def post_models
75
- use_generator(::Localtower::Generators::Model, clean_params["models"])
76
- redirect_to relations_path
59
+ def post_actions
60
+ cmd = ::Localtower::Tools.perform_cmd(clean_params['cmd'])
61
+ flash[:notice] = cmd if cmd['ERROR']
62
+ redirect_back fallback_location: root_path
77
63
  end
78
64
 
79
65
  private
@@ -1,25 +1,7 @@
1
1
  module Localtower
2
2
  module ApplicationHelper
3
- def subl_link_to(name, file, &block)
4
- name ||= file
5
- if block_given?
6
- str = capture(&block)
7
- else
8
- str = name
9
- end
10
-
11
- link_to str, file_link(file)
12
- end
13
-
14
3
  def file_link(file)
15
4
  "vscode://file/#{file}"
16
- # "vscode://open?url=file://#{file}&line=1"
17
- end
18
-
19
- def to_json_print(hash)
20
- # str = hash.to_json
21
- # str.gsub(/,"/, ',<br>"').gsub(/\"\:/, '": ').html_safe
22
- hash.to_json
23
5
  end
24
6
  end
25
7
  end
@@ -2,100 +2,51 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <title>Localtower - <%= yield :title %></title>
5
-
6
5
  <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
7
6
  <meta name="viewport" content="width=device-width" />
8
7
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
9
-
10
8
  <link rel="stylesheet" type="text/css" href="/light-bootstrap-dashboard-master/assets/css/bootstrap.min.css">
11
- <link rel="stylesheet" type="text/css" href="/light-bootstrap-dashboard-master/assets/css/animate.min.css">
9
+ <!-- <link rel="stylesheet" type="text/css" href="/light-bootstrap-dashboard-master/assets/css/animate.min.css"> -->
12
10
  <link rel="stylesheet" type="text/css" href="/light-bootstrap-dashboard-master/assets/css/light-bootstrap-dashboard.css">
13
-
14
11
  <!-- Fonts and icons -->
15
- <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
16
- <link href='http://fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
12
+ <link href="/vendor/font-awesome.min.css" rel="stylesheet">
17
13
  <link rel="stylesheet" type="text/css" href="/light-bootstrap-dashboard-master/assets/css/pe-icon-7-stroke.css">
18
-
14
+ <link rel="stylesheet" type="text/css" href="/vendor/highlight-js-default.min.css">
19
15
  <link rel="stylesheet" type="text/css" href="/css/app.css">
20
-
21
16
  <%= csrf_meta_tags %>
22
17
  </head>
23
-
24
18
  <body>
25
-
26
19
  <div class="wrapper">
27
20
  <div class="sidebar">
28
-
29
21
  <div class="sidebar-wrapper">
30
22
  <ul class="nav">
31
- <li class="<%= is_active_link?(dashboard_path, :inclusive) ? "active" : nil %>">
32
- <a href="<%= dashboard_path %>">
33
- <i class="pe-7s-home"></i>
34
- <p>Schema</p>
35
- </a>
36
- </li>
37
-
38
- <li class="<%= is_active_link?(models_path, :inclusive) ? "active" : nil %>">
23
+ <li class="<%= is_active_link?(models_path, :exclusive) ? "active" : nil %>">
39
24
  <a href="<%= models_path %>">
40
- <i class="pe-7s-server"></i>
41
- <p>New Model</p>
42
- </a>
43
- </li>
44
-
45
- <li class="<%= is_active_link?(relations_path, :inclusive) ? "active" : nil %>">
46
- <a href="<%= relations_path %>">
47
- <i class="pe-7s-shuffle"></i>
48
- <p>New Relation</p>
25
+ <i class="pe-7s-network"></i>
26
+ <p>Models</p>
49
27
  </a>
50
28
  </li>
51
-
52
- <li class="<%= is_active_link?(migrations_path, :inclusive) ? "active" : nil %>">
29
+ <li class="<%= is_active_link?(migrations_path, :exclusive) ? "active" : nil %>">
53
30
  <a href="<%= migrations_path %>">
54
- <i class="pe-7s-edit"></i>
55
- <p>New Migration</p>
56
- </a>
57
- </li>
58
-
59
- <li class="<%= is_active_link?(logs_path, :inclusive) ? "active" : nil %>">
60
- <a href="<%= logs_path %>">
61
- <i class="pe-7s-ticket"></i>
62
- <p>Logs</p>
31
+ <i class="pe-7s-back"></i>
32
+ <p>Migrations</p>
63
33
  </a>
64
34
  </li>
65
- </ul>
66
- </div>
67
- </div>
68
- <div class="tower-nav">
69
- <div class="<%= is_active_link?(dashboard_path, :inclusive) ? "active" : nil %>">
70
- <a class="tower-a" href="<%= dashboard_path %>">
71
- <i class="pe-7s-home"></i>
72
- <p>Schema</p>
73
- </a>
74
- </div>
75
-
76
-
77
- <div class="<%= is_active_link?(models_path, :inclusive) ? "active" : nil %>">
78
- <a class="tower-a" href="<%= models_path %>">
35
+ <li class="<%= is_active_link?(new_model_path, :inclusive) ? "active" : nil %>">
36
+ <a href="<%= new_model_path %>">
79
37
  <i class="pe-7s-server"></i>
80
38
  <p>New Model</p>
81
39
  </a>
82
- </div>
83
-
84
- <div class="<%= is_active_link?(relations_path, :inclusive) ? "active" : nil %>">
85
- <a class="tower-a" href="<%= relations_path %>">
86
- <i class="pe-7s-shuffle"></i>
87
- <p>New Relation</p>
88
- </a>
89
- </div>
90
-
91
- <div class="<%= is_active_link?(migrations_path, :inclusive) ? "active" : nil %>">
92
- <a class="tower-a" href="<%= migrations_path %>">
40
+ </li>
41
+ <li class="<%= is_active_link?(new_migration_path, :exclusive) ? "active" : nil %>">
42
+ <a href="<%= new_migration_path %>">
93
43
  <i class="pe-7s-edit"></i>
94
44
  <p>New Migration</p>
95
45
  </a>
96
- </div>
46
+ </li>
47
+ </ul>
48
+ </div>
97
49
  </div>
98
-
99
50
  <div class="main-panel">
100
51
  <div class="content">
101
52
  <div class="container-fluid">
@@ -104,12 +55,10 @@
104
55
  </div>
105
56
  </div>
106
57
  </div>
107
-
108
58
  <div class="full-message" style="display: none;">
109
-
110
59
  <div class="text-center">
111
60
  <br>
112
- <h3>Magic stuff happening.</h3>
61
+ <h3>Generating files</h3>
113
62
  <br>
114
63
  <i class="pe-7s-refresh-2 rotate"></i>
115
64
  <br>
@@ -122,19 +71,11 @@
122
71
  <code>bundle exec rails db:migrate</code>
123
72
  </p>
124
73
  </div>
125
-
126
74
  </div>
127
-
128
75
  <!-- Core JS Files -->
129
76
  <script src="/light-bootstrap-dashboard-master/assets/js/jquery-1.10.2.js" type="text/javascript"></script>
130
- <script src="/light-bootstrap-dashboard-master/assets/js/bootstrap.min.js" type="text/javascript"></script>
131
-
132
- <!-- Checkbox, Radio & Switch Plugins -->
133
- <script src="/light-bootstrap-dashboard-master/assets/js/bootstrap-checkbox-radio-switch.js"></script>
134
-
135
- <!-- Light Bootstrap Table Core javascript and methods for Demo purpose -->
136
- <script src="/light-bootstrap-dashboard-master/assets/js/light-bootstrap-dashboard.js"></script>
137
- <script src="/js/masonry.pkgd.min.js"></script>
77
+ <script src="/vendor/highlight.min.js"></script>
78
+ <script src="/vendor/masonry.pkgd.min.js"></script>
138
79
  <script src="/js/app.js"></script>
139
80
  </body>
140
81
  </html>
@@ -0,0 +1,3 @@
1
+ <div class="alert alert-danger">
2
+ You don't have any models in this app. You can create one <%= link_to 'here.', models_path, class: 'btn btn-primary btn-fill btn-xs' %>
3
+ </div>
@@ -1,131 +1,61 @@
1
1
  <% content_for :title do %>Migrations<% end %>
2
-
3
2
  <div class="row">
4
3
  <div class="col-md-12">
5
- <div class="card">
6
- <div class="header">
7
- <h4 class="title"></h4>
8
- </div>
9
-
10
- <div class="content">
11
- <%= form_tag migrations_path, class: "form" do %>
12
-
13
- <table class="table table-hover table-striped">
14
- <thead>
15
- <th> <span data-selector=''>On Model</span></th>
16
- <th> <span data-selector=''>Action</span></th>
17
- <th> <span data-selector='belongs_to_label'>Belongs To</span></th>
18
- <th> <span data-selector='column_label'>Column</span></th>
19
- <th> <span data-selector='new_column_name_label'>New Column Name</span></th>
20
- <th> <span data-selector='column_type_label'>Type</span></th>
21
- <th> <span data-selector='index_label'>Index?</span></th>
22
- <th> <span data-selector='nullable_label'>Can be null?</span></th>
23
- <th> <span data-selector=''></span></th>
24
- </thead>
25
-
26
- <tbody data-selector="tbody">
27
- <tr data-selector="tr">
28
- <td>
29
- <%= select_tag "migrations[migrations][][table_name]", options_for_select(Localtower::Tools.models.collect {|p| [ p, p.table_name ] }), class: "form-control" %>
30
- </td>
31
-
32
- <td>
33
- <%= select_tag "migrations[migrations][][action]", options_for_select(::Localtower::Generators::Migration::ACTIONS), class: "form-control", "data-selector" => "action" %>
34
- </td>
35
-
36
- <td>
37
- <%= select_tag "migrations[migrations][][belongs_to]", options_for_select(Localtower::Tools.models.collect {|p| [ p, p.table_name ] }), class: "form-control", "data-selector" => "belongs_to" %>
38
- </td>
39
-
40
- <td class="text-center">
41
- <input type="text" name="migrations[migrations][][column]" class="form-control" data-selector="column_text">
42
-
43
- <%= select_tag "migrations[migrations][][column_list]", options_for_select(::Localtower::Tools.all_columns), class: "form-control", include_blank: true, "data-selector" => "column_list", style: "display:none;" %>
44
- </td>
45
-
46
- <td>
47
- <input type="text" name="migrations[migrations][][new_column_name]" class="form-control" data-selector="new_column_name">
48
- </td>
49
-
50
- <td>
51
- <%= select_tag "migrations[migrations][][column_type]", options_for_select(::Localtower::Generators::Migration::TYPES), class: "form-control", "data-selector" => "column_type" %>
52
- </td>
53
-
54
- <td>
55
- <input type="checkbox" name="migrations[migrations][][index]" class="form-control" data-selector="index">
56
- </td>
57
-
58
- <td>
59
- <input type="checkbox" name="migrations[migrations][][nullable]" class="form-control" checked="" data-selector="nullable">
60
- </td>
61
-
62
- <td>
63
- <div class="pull-right">
64
- <button class="btn btn-danger btn-xs pointer" data-selector="remove">Remove</button>
65
- </div>
66
- </td>
67
- </tr>
68
- </tbody>
69
- </table>
70
-
71
- <div class="row">
72
- <div class="col-md-12 text-center">
73
- <i class="pe-7s-plus pointer" data-selector="duplicate" style="font-size: 3em;"></i>
74
- </div>
4
+ <div class="content">
5
+ <% if flash[:notice] %>
6
+ <div class="alert alert-info">
7
+ <span><%= flash[:notice] %></span>
75
8
  </div>
76
-
77
- <hr>
78
-
79
- <!-- multiple lines: -->
80
- <div class="row">
81
- <div class="col-md-12 text-center">
82
- <button name="migrations[run_migrate]" type="submit" value="true" class="btn btn-success" data-selector="submit">
83
- Create the migration and <b>migrate</b>
84
- </button>
85
- </div>
9
+ <% end %>
10
+ <div class="card">
11
+ <div class="header">
12
+ <% if @migrations.select {|i| i['status'] == :todo}.any? %>
13
+ <%= form_tag actions_path, class: "form" do %>
14
+ <button name="cmd" type="submit" value="rails db:migrate" class="btn btn-warning btn-fill" data-selector="submit">
15
+ Migrate Pending Migrations <code>bundle exec rails db:migrate</code>
16
+ </button>
17
+ <% end %>
18
+ <% end %>
86
19
  </div>
87
- <% end %>
88
- </div>
89
- </div>
90
-
91
- <div class="card">
92
- <div class="header">
93
- <h4 class="title">Migrations</h4>
94
- </div>
95
-
96
- <div class="content">
97
- <table class="table">
98
- <thead>
99
- <tr>
100
- <th>Name</th>
101
- <th>Date</th>
102
- <th>Status</th>
103
- </tr>
104
-
105
- </thead>
106
- <tbody>
20
+ <div class="content">
21
+ <% if @migrations.any? %>
107
22
  <% @migrations.each do |entry| %>
108
- <%
109
- klass = (entry["status"] == :done) ? "success" : "danger"
110
- %>
111
- <tr class="<%= klass %>">
112
- <td>
113
- <%= entry["name"] %>
114
- </td>
115
-
116
- <td>
117
- <%= entry["time"] %>
118
- </td>
119
-
120
- <td>
121
- <%= entry["status"] == :done ? 'done' : 'not executed' %>
122
- </td>
123
- </tr>
23
+ <div class="container-fluid">
24
+ <div class="row">
25
+ <div class="col-md-12">
26
+ <h5 style="color: <%= entry['status'] == :todo ? 'red' : 'green' %>;">
27
+ <% if entry['status'] == :todo %>
28
+ <button type="button" class="btn btn-danger btn-xs">PENDING</button>
29
+ <a href="<%= file_link(entry['file_full_path']) %>"><%= entry['name'] %></a>
30
+ <% else %>
31
+ <%= form_tag actions_path, class: "form" do %>
32
+ <button name="cmd" title="rake db:migrate:down VERSION=<%= entry['time'] %>" type="submit" value="rake db:migrate:down VERSION=<%= entry['time'] %>" class="btn btn-info btn-xs btn-fill">
33
+ ROLLBACK
34
+ </button>
35
+ <a href="<%= file_link(entry['file_full_path']) %>"><%= entry['name'] %></a>
36
+ <% end %>
37
+ <% end %>
38
+ </h5>
39
+ </div>
40
+ </div>
41
+ <div class="row">
42
+ <div class="col-md-12">
43
+ <pre><code class="language-ruby"><%= entry['content'] %></code></pre>
44
+ </div>
45
+ </div>
46
+ </div>
124
47
  <% end %>
125
- </tbody>
126
- </table>
48
+ <% else %>
49
+ <div class="card">
50
+ <div class="">
51
+ </div>
52
+ <div class="alert alert-info">
53
+ <span>No migrations found</span>
54
+ </div>
55
+ </div>
56
+ <% end %>
57
+ </div>
127
58
  </div>
128
-
129
59
  </div>
130
60
  </div>
131
61
  </div>