rails_nexus 2.0.3 → 2.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.
@@ -13,103 +13,23 @@
13
13
  <% end %>
14
14
  </nav>
15
15
 
16
- <%# ─── Stats Overview ──────────────────────────────────────── %>
17
- <% if @stats %>
18
- <div class="rn-stats">
19
- <div class="rn-stat">
20
- <span class="rn-stat-label">Total Exceptions</span>
21
- <span class="rn-stat-value"><%= number_with_delimiter(@stats[:total]) %></span>
22
- <span class="rn-stat-change">All time</span>
23
- </div>
24
- <div class="rn-stat">
25
- <span class="rn-stat-label">This Week</span>
26
- <span class="rn-stat-value <%= 'danger' if @stats[:this_week] > 10 %>"><%= @stats[:this_week] %></span>
27
- <span class="rn-stat-change">Last 7 days</span>
28
- </div>
29
- <div class="rn-stat">
30
- <span class="rn-stat-label">Today</span>
31
- <span class="rn-stat-value <%= 'danger' if @stats[:today] > 5 %>"><%= @stats[:today] %></span>
32
- <span class="rn-stat-change <%= 'up' if @stats[:today] > @stats[:yesterday] %>">
33
- <% if @stats[:yesterday] > 0 %>
34
- <%= ((@stats[:today].to_f / [@stats[:yesterday], 1].max - 1) * 100).round %>% vs yesterday
35
- <% else %>
36
- vs yesterday
37
- <% end %>
38
- </span>
39
- </div>
40
- <div class="rn-stat">
41
- <span class="rn-stat-label">Unique Classes</span>
42
- <span class="rn-stat-value"><%= @stats[:top_classes]&.size || 0 %></span>
43
- <span class="rn-stat-change">Exception types</span>
44
- </div>
45
- </div>
46
- <% end %>
47
-
48
- <%# ─── User Impact Ranking ───────────────────────────────── %>
49
- <% begin %>
50
- <% if RailsNexus.configuration.user_impact_tracking %>
51
- <% impact_data = RailsNexus::LoggedException.user_impact_ranking(limit: 5) %>
52
- <% if impact_data.any? %>
53
- <div class="rn-card">
54
- <div class="p-4" style="border-bottom: 1px solid var(--rn-border-light)">
55
- <div class="flex items-center gap-2">
56
- <svg class="w-4 h-4" style="color: var(--rn-danger)" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
57
- <path stroke-linecap="round" stroke-linejoin="round" d="M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z" />
58
- </svg>
59
- <h2 class="text-sm font-semibold" style="color: var(--rn-text)">User Impact (Top 5)</h2>
60
- </div>
61
- <p class="text-xs mt-1" style="color: var(--rn-text-muted)">Errors ranked by unique users affected</p>
62
- </div>
63
- <div class="rn-table-wrap">
64
- <table class="rn-table">
65
- <thead>
66
- <tr>
67
- <th>Exception</th>
68
- <th>Users Affected</th>
69
- <th>Occurrences</th>
70
- <th>Last Seen</th>
71
- </tr>
72
- </thead>
73
- <tbody>
74
- <% impact_data.each do |row| %>
75
- <tr>
76
- <td>
77
- <span class="rn-badge rn-badge-danger"><%= row.exception_class %></span>
78
- <span class="text-xs ml-1" style="color: var(--rn-text-muted)"><%= row.controller_name %>#<%= row.action_name %></span>
79
- </td>
80
- <td>
81
- <span class="font-bold" style="color: var(--rn-danger)"><%= row.unique_users %></span>
82
- </td>
83
- <td>
84
- <span style="color: var(--rn-text-secondary)"><%= row.total_occurrences %></span>
85
- </td>
86
- <td>
87
- <span class="text-xs" style="color: var(--rn-text-muted)"><%= row.last_seen&.strftime("%b %d %H:%M") %></span>
88
- </td>
89
- </tr>
90
- <% end %>
91
- </tbody>
92
- </table>
93
- </div>
94
- </div>
95
- <% end %>
96
- <% end %>
97
- <% rescue => e %>
98
- <%# Silently ignore if user_id column doesn't exist yet %>
99
- <% end %>
100
-
101
- <%# ─── Filters Card ────────────────────────────────────────── %>
102
- <div class="rn-card">
103
- <%# Filter header with icon %>
104
- <div class="rn-filters" style="padding-bottom: 0.5rem">
105
- <div class="flex items-center gap-2">
16
+ <%# ─── Collapsible Filters ─────────────────────────────────── %>
17
+ <% pills = active_filter_pills %>
18
+ <section class="rn-card rn-exceptions-panel">
19
+ <div class="rn-exceptions-main" style="min-height: 400px">
20
+ <details class="rn-filter-disclosure" open>
21
+ <summary class="rn-filter-summary">
22
+ <span class="flex items-center gap-2">
106
23
  <svg class="w-4 h-4" style="color: var(--rn-text-muted)" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 01-.659 1.591l-5.432 5.432a2.25 2.25 0 00-.659 1.591v2.927a2.25 2.25 0 01-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 00-.659-1.591L3.659 7.409A2.25 2.25 0 013 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0112 3z" /></svg>
107
- <span class="text-xs font-semibold uppercase tracking-wider" style="color: var(--rn-text-muted)">Filters</span>
108
- <% if filtered? %>
109
- <%= link_to "Clear all", logged_exceptions_path(per_page: params[:per_page]), class: "ml-auto text-xs font-medium", style: "color: var(--rn-primary)" %>
24
+ <span class="text-sm font-semibold" style="color: var(--rn-text)">Filters</span>
25
+ <% if pills.any? %>
26
+ <span class="rn-filter-count"><%= pills.size %> active</span>
27
+ <% else %>
28
+ <span class="text-xs" style="color: var(--rn-text-muted)">Search and narrow exceptions</span>
110
29
  <% end %>
111
- </div>
112
- </div>
30
+ </span>
31
+ <svg class="rn-filter-chevron w-4 h-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25L12 15.75 4.5 8.25" /></svg>
32
+ </summary>
113
33
 
114
34
  <%# Filter form %>
115
35
  <%= search_form_for @q, url: query_logged_exceptions_path, data: { turbo_frame: "exceptions" } do |f| %>
@@ -215,11 +135,13 @@
215
135
 
216
136
  <div class="flex items-center gap-2">
217
137
  <%= f.submit "Apply", class: "rn-btn rn-btn-primary" %>
138
+ <% if filtered? %>
139
+ <%= link_to "Clear", logged_exceptions_path(per_page: params[:per_page]), class: "rn-btn rn-btn-ghost" %>
140
+ <% end %>
218
141
  </div>
219
142
  </div>
220
143
 
221
144
  <%# Active filter pills %>
222
- <% pills = active_filter_pills %>
223
145
  <% if pills.any? %>
224
146
  <div class="rn-filter-pills">
225
147
  <% pills.each do |pill| %>
@@ -231,11 +153,9 @@
231
153
  </div>
232
154
  <% end %>
233
155
  <% end %>
234
- </div>
156
+ </details>
235
157
 
236
158
  <%# ─── Content Area ────────────────────────────────────────── %>
237
- <div class="flex gap-4" style="min-height: 400px">
238
-
239
159
  <%# ─── Exception List ──────────────────────────────────── %>
240
160
  <div class="flex-1 min-w-0">
241
161
 
@@ -270,13 +190,15 @@
270
190
  </div>
271
191
  </div>
272
192
 
193
+ </section>
194
+
273
195
  <%# ─── Keyboard Shortcuts Dialog ───────────────────────────── %>
274
196
  <% if RailsNexus.configuration.keyboard_shortcuts %>
275
- <div class="rn-shortcuts-overlay" data-rails_nexus-target="shortcutsDialog">
197
+ <div class="rn-shortcuts-overlay" data-rails_nexus-target="shortcutsDialog" role="dialog" aria-modal="true" aria-labelledby="rn-shortcuts-title">
276
198
  <div class="rn-shortcuts">
277
199
  <div class="flex items-center justify-between mb-4">
278
- <h3>Keyboard Shortcuts</h3>
279
- <button type="button" class="rn-icon-btn" data-action="click->rails_nexus#closeShortcuts">
200
+ <h3 id="rn-shortcuts-title">Keyboard Shortcuts</h3>
201
+ <button type="button" class="rn-icon-btn" data-action="click->rails_nexus#closeShortcuts" aria-label="Close keyboard shortcuts">
280
202
  <svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg>
281
203
  </button>
282
204
  </div>
@@ -0,0 +1,140 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ════════════════════════════════════════════════════════════════════
4
+ # Backup Config Seed — Migrated from ~/Backup gem models
5
+ #
6
+ # Run with:
7
+ # rails runner db/seeds/backup_configs.rb
8
+ #
9
+ # Or from the engine:
10
+ # rails_nexus:seed_backups rake task
11
+ # ════════════════════════════════════════════════════════════════════
12
+
13
+ configs = [
14
+ {
15
+ name: "tti_daily_backup",
16
+ description: "TTI Daily MySQL Backup — skip sessions, versions, logged_exceptions",
17
+ adapter: "mysql",
18
+ database_name: "tti_erp",
19
+ host: "localhost",
20
+ port: 3306,
21
+ username: "ENV[DB_USERNAME]",
22
+ password: "ENV[DB_PASSWORD]",
23
+ skip_tables: "tti_erp.logged_exceptions,tti_erp.sessions,tti_erp.versions",
24
+
25
+ storage_path: "~/dumps",
26
+ keep_count: 365,
27
+
28
+ compress: true,
29
+ bzip2_compress: false,
30
+ encrypted: true,
31
+ encryption_password: "12upo12e064a3",
32
+ gpg_enabled: false,
33
+
34
+ rsync_enabled: true,
35
+ rsync_host: "172.16.1.232",
36
+ rsync_port: 22,
37
+ rsync_user: "estudent",
38
+ rsync_path: "tti_backups",
39
+ rsync_mirror: false,
40
+
41
+ s3_enabled: false,
42
+
43
+ archive_enabled: false,
44
+
45
+ notify_command: "bk-send",
46
+ notify_on_success: true,
47
+ notify_on_failure: true,
48
+ email_notify: false,
49
+
50
+ schedule_cron: "0 2 * * *", # daily at 2am
51
+ enabled: true
52
+ },
53
+
54
+ {
55
+ name: "tti_full_backup",
56
+ description: "TTI Full MySQL Backup — all tables, no skip",
57
+ adapter: "mysql",
58
+ database_name: "tti_erp",
59
+ host: "localhost",
60
+ port: 3306,
61
+ username: "ENV[DB_USERNAME]",
62
+ password: "ENV[DB_PASSWORD]",
63
+ skip_tables: "",
64
+
65
+ storage_path: "~/dumps",
66
+ keep_count: 10,
67
+
68
+ compress: true,
69
+ bzip2_compress: false,
70
+ encrypted: true,
71
+ encryption_password: "12upo12e064a3",
72
+ gpg_enabled: false,
73
+
74
+ rsync_enabled: false,
75
+
76
+ s3_enabled: false,
77
+
78
+ archive_enabled: false,
79
+
80
+ notify_command: "bk-send",
81
+ notify_on_success: true,
82
+ notify_on_failure: true,
83
+ email_notify: false,
84
+
85
+ schedule_cron: "0 0 * * 0", # weekly Sunday at midnight
86
+ enabled: true
87
+ },
88
+
89
+ {
90
+ name: "tti_sync_backup",
91
+ description: "TTI Sync — MySQL dump + RSync push to remote server",
92
+ adapter: "mysql",
93
+ database_name: "tti_erp",
94
+ host: "localhost",
95
+ port: 3306,
96
+ username: "ENV[DB_USERNAME]",
97
+ skip_tables: "tti_erp.logged_exceptions,tti_erp.sessions,tti_erp.versions",
98
+
99
+ storage_path: "~/dumps/sync",
100
+ keep_count: 1,
101
+
102
+ compress: true,
103
+ bzip2_compress: false,
104
+ encrypted: false,
105
+
106
+ rsync_enabled: true,
107
+ rsync_host: "198.199.121.213",
108
+ rsync_port: 22,
109
+ rsync_user: "winner2",
110
+ rsync_path: "dumps/tti",
111
+ rsync_mirror: false,
112
+
113
+ s3_enabled: false,
114
+
115
+ archive_enabled: false,
116
+
117
+ notify_command: "bk-send",
118
+ notify_on_success: true,
119
+ notify_on_failure: true,
120
+ email_notify: false,
121
+
122
+ schedule_cron: "0 3 * * *", # daily at 3am
123
+ enabled: true
124
+ }
125
+ ]
126
+
127
+ puts "Seeding #{configs.size} backup configs..."
128
+
129
+ configs.each do |attrs|
130
+ config = RailsNexus::BackupConfig.find_or_initialize_by(name: attrs[:name])
131
+ config.assign_attributes(attrs)
132
+
133
+ if config.save
134
+ puts " ✓ #{config.name} (#{config.adapter}/#{config.database_name})"
135
+ else
136
+ puts " ✗ #{config.name}: #{config.errors.full_messages.join(', ')}"
137
+ end
138
+ end
139
+
140
+ puts "Done. #{RailsNexus::BackupConfig.count} configs total."
@@ -114,7 +114,7 @@ class CreateRailsNexusTables < ActiveRecord::Migration[<%= "[#{ActiveRecord::Mig
114
114
 
115
115
  # ─── rails_nexus_backups ─────────────────────────────────────────
116
116
  create_table :rails_nexus_backups do |t|
117
- t.string :model_name, null: false
117
+ t.string :config_name, null: false
118
118
  t.string :status, null: false
119
119
  t.text :file_path
120
120
  t.bigint :file_size
@@ -125,7 +125,7 @@ class CreateRailsNexusTables < ActiveRecord::Migration[<%= "[#{ActiveRecord::Mig
125
125
  t.datetime :completed_at
126
126
  end
127
127
 
128
- add_index :rails_nexus_backups, [:model_name, :started_at]
128
+ add_index :rails_nexus_backups, [:config_name, :started_at]
129
129
  add_index :rails_nexus_backups, :status
130
130
  add_index :rails_nexus_backups, :started_at
131
131
 
@@ -139,14 +139,18 @@ class CreateRailsNexusTables < ActiveRecord::Migration[<%= "[#{ActiveRecord::Mig
139
139
  t.integer :port
140
140
  t.string :username
141
141
  t.string :password
142
- t.text :skip_tables, default: "[]"
142
+ t.string :skip_tables
143
143
 
144
144
  t.string :storage_path, null: false
145
145
  t.integer :keep_count, default: 30
146
146
 
147
147
  t.boolean :compress, default: true
148
- t.boolean :encrypt, default: false
149
- t.string :encrypt_password
148
+ t.boolean :bzip2_compress, default: false
149
+ t.boolean :encrypted, default: false
150
+ t.string :encryption_password
151
+ t.boolean :encrypt_base64, default: false
152
+ t.boolean :gpg_enabled, default: false
153
+ t.string :gpg_password
150
154
 
151
155
  t.boolean :rsync_enabled, default: false
152
156
  t.string :rsync_host
@@ -154,10 +158,32 @@ class CreateRailsNexusTables < ActiveRecord::Migration[<%= "[#{ActiveRecord::Mig
154
158
  t.string :rsync_user
155
159
  t.string :rsync_path
156
160
  t.boolean :rsync_mirror, default: false
157
-
161
+ t.boolean :rsync_archive, default: true
162
+ t.string :rsync_directories
163
+ t.string :rsync_excludes
164
+
165
+ t.string :mysql_additional_options
166
+
167
+ # S3 storage
168
+ t.boolean :s3_enabled, default: false
169
+ t.string :s3_access_key
170
+ t.string :s3_secret_key
171
+ t.string :s3_bucket
172
+ t.string :s3_region, default: "us-east-1"
173
+ t.string :s3_prefix
174
+
175
+ # Archives (file/dir backup)
176
+ t.boolean :archive_enabled, default: false
177
+ t.string :archive_paths
178
+ t.string :archive_excludes
179
+ t.boolean :split_chunks, default: false
180
+
181
+ # Notifications
158
182
  t.string :notify_command
159
183
  t.boolean :notify_on_success, default: true
160
184
  t.boolean :notify_on_failure, default: true
185
+ t.boolean :email_notify, default: false
186
+ t.string :email_to
161
187
 
162
188
  t.string :schedule_cron
163
189
  t.boolean :enabled, default: true
@@ -1,3 +1,3 @@
1
1
  module RailsNexus
2
- VERSION = "2.0.3"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -254,9 +254,9 @@ namespace :rails_nexus do
254
254
  results = RailsNexus::BackupRunner.run_all
255
255
  results.each do |r|
256
256
  if r[:success]
257
- puts "✓ #{r[:record].model_name} completed"
257
+ puts "✓ #{r[:record].config_name} completed"
258
258
  else
259
- puts "✗ #{r[:record]&.model_name || '?'} failed: #{r[:error]}"
259
+ puts "✗ #{r[:record]&.config_name || '?'} failed: #{r[:error]}"
260
260
  end
261
261
  end
262
262
  end
@@ -269,9 +269,9 @@ namespace :rails_nexus do
269
269
  else
270
270
  results.each do |r|
271
271
  if r[:success]
272
- puts "✓ #{r[:record].model_name} completed"
272
+ puts "✓ #{r[:record].config_name} completed"
273
273
  else
274
- puts "✗ #{r[:record]&.model_name || '?'} failed: #{r[:error]}"
274
+ puts "✗ #{r[:record]&.config_name || '?'} failed: #{r[:error]}"
275
275
  end
276
276
  end
277
277
  end
@@ -298,4 +298,14 @@ namespace :rails_nexus do
298
298
  end
299
299
  end
300
300
  end
301
+
302
+ desc "Seed backup configs from ~/Backup gem models"
303
+ task seed_backups: :environment do
304
+ seed_file = File.join(RailsNexus::Engine.root, "db", "seeds", "backup_configs.rb")
305
+ if File.exist?(seed_file)
306
+ load seed_file
307
+ else
308
+ puts "Seed file not found: #{seed_file}"
309
+ end
310
+ end
301
311
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_nexus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tamiru Hailu
@@ -136,6 +136,7 @@ files:
136
136
  - app/javascript/controllers/rails_nexus_theme_controller.js
137
137
  - app/javascript/rails_nexus/application.js
138
138
  - app/jobs/rails_nexus/application_job.rb
139
+ - app/jobs/rails_nexus/backup_job.rb
139
140
  - app/mailers/rails_nexus/application_mailer.rb
140
141
  - app/models/rails_nexus/application_record.rb
141
142
  - app/models/rails_nexus/backup.rb
@@ -148,6 +149,7 @@ files:
148
149
  - app/models/rails_nexus/webhook_delivery.rb
149
150
  - app/services/rails_nexus/backup_runner.rb
150
151
  - app/services/rails_nexus/backup_service.rb
152
+ - app/views/layouts/rails_nexus/_sidebar_navigation.html.erb
151
153
  - app/views/layouts/rails_nexus/application.html.erb
152
154
  - app/views/rails_nexus/analytics/index.html.erb
153
155
  - app/views/rails_nexus/backup/_form.html.erb
@@ -180,6 +182,7 @@ files:
180
182
  - config/initializers/date_formats.rb
181
183
  - config/locales/en.yml
182
184
  - config/routes.rb
185
+ - db/seeds/backup_configs.rb
183
186
  - lib/generators/rails_nexus/backup_generator.rb
184
187
  - lib/generators/rails_nexus/customize_generator.rb
185
188
  - lib/generators/rails_nexus/install_generator.rb