dbviewer 0.4.1 → 0.4.2

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.
@@ -1,8 +1,3 @@
1
- <%# sidebar content %>
2
- <% content_for :sidebar do %>
3
- <%= render 'dbviewer/shared/sidebar' %>
4
- <% end %>
5
-
6
1
  <div class="container-fluid px-0">
7
2
  <div class="row mb-3">
8
3
  <div class="col">
@@ -78,7 +73,7 @@
78
73
  <div class="card-header">
79
74
  <h5 class="card-title mb-0">Largest Tables</h5>
80
75
  </div>
81
- <div class="card-body">
76
+ <div class="card-body p-0">
82
77
  <% if @analytics[:largest_tables].any? %>
83
78
  <div class="table-responsive">
84
79
  <table class="table table-sm table-hover">
@@ -111,7 +106,7 @@
111
106
  </div>
112
107
  </div>
113
108
 
114
- <div class="col-6 mb-4">
109
+ <div class="col-md-6 mb-4">
115
110
  <div class="card shadow-sm">
116
111
  <div class="card-header d-flex justify-content-between align-items-center">
117
112
  <h5 class="card-title mb-0">Recent SQL Queries</h5>
@@ -120,55 +115,46 @@
120
115
  <% end %>
121
116
  </div>
122
117
  <div class="card-body p-0">
123
- <% begin %>
124
- <% require_dependency "dbviewer/logger" %>
125
- <% if Dbviewer.configuration.enable_query_logging %>
126
- <% queries = Dbviewer::Logger.instance.recent_queries(limit: 10) %>
127
-
128
- <% if queries.any? %>
129
- <div class="table-responsive">
130
- <table class="table table-sm table-hover mb-0">
118
+ <% if Dbviewer.configuration.enable_query_logging %>
119
+ <% if @recent_queries.any? %>
120
+ <div class="table-responsive">
121
+ <table class="table table-sm table-hover mb-0">
131
122
 
132
- <thead>
123
+ <thead>
124
+ <tr>
125
+ <th>Query</th>
126
+ <th class="text-end" style="width: 120px">Duration</th>
127
+ <th class="text-end" style="width: 180px">Time</th>
128
+ </tr>
129
+ </thead>
130
+ <tbody>
131
+ <% @recent_queries.each do |query| %>
133
132
  <tr>
134
- <th>Query</th>
135
- <th class="text-end" style="width: 120px">Duration</th>
136
- <th class="text-end" style="width: 180px">Time</th>
133
+ <td class="text-truncate" style="max-width: 500px;">
134
+ <code class="sql-query-code"><%= query[:sql] %></code>
135
+ </td>
136
+ <td class="text-end">
137
+ <span class="<%= query[:duration_ms] > 100 ? 'query-duration-slow' : 'query-duration' %>">
138
+ <%= query[:duration_ms] %> ms
139
+ </span>
140
+ </td>
141
+ <td class="text-end query-timestamp">
142
+ <small><%= query[:timestamp].strftime("%H:%M:%S") %></small>
143
+ </td>
137
144
  </tr>
138
- </thead>
139
- <tbody>
140
- <% queries.each do |query| %>
141
- <tr>
142
- <td class="text-truncate" style="max-width: 500px;">
143
- <code class="sql-query-code"><%= query[:sql] %></code>
144
- </td>
145
- <td class="text-end">
146
- <span class="<%= query[:duration_ms] > 100 ? 'query-duration-slow' : 'query-duration' %>">
147
- <%= query[:duration_ms] %> ms
148
- </span>
149
- </td>
150
- <td class="text-end query-timestamp">
151
- <small><%= query[:timestamp].strftime("%H:%M:%S") %></small>
152
- </td>
153
- </tr>
154
- <% end %>
155
- </tbody>
156
- </table>
157
- </div>
158
- <% else %>
159
- <div class="text-center my-4 empty-data-message">
160
- <p>No queries recorded yet</p>
161
- </div>
162
- <% end %>
145
+ <% end %>
146
+ </tbody>
147
+ </table>
148
+ </div>
163
149
  <% else %>
164
150
  <div class="text-center my-4 empty-data-message">
165
- <p>Query logging is disabled</p>
166
- <small class="text-muted">Enable it in the configuration to see SQL queries here</small>
151
+ <p>No queries recorded yet</p>
167
152
  </div>
168
153
  <% end %>
169
- <% rescue => e %>
154
+ <% else %>
170
155
  <div class="text-center my-4 empty-data-message">
171
- <p>Error loading query logs: <%= e.message %></p>
156
+ <p>Query logging is disabled</p>
157
+ <small class="text-muted">Enable it in the configuration to see SQL queries here</small>
172
158
  </div>
173
159
  <% end %>
174
160
  </div>
@@ -176,50 +162,3 @@
176
162
  </div>
177
163
  </div>
178
164
  </div>
179
-
180
- <script>
181
- document.addEventListener('DOMContentLoaded', function() {
182
- const searchInput = document.getElementById('tableSearch');
183
- const tablesList = document.getElementById('tablesList');
184
- const tables = tablesList ? tablesList.querySelectorAll('.list-group-item') : [];
185
-
186
- if (searchInput) {
187
- searchInput.addEventListener('keyup', function() {
188
- const query = this.value.trim().toLowerCase();
189
-
190
- Array.from(tables).forEach(function(table) {
191
- const tableName = table.textContent.trim().toLowerCase();
192
- if (tableName.includes(query)) {
193
- table.style.display = '';
194
- } else {
195
- table.style.display = 'none';
196
- }
197
- });
198
- });
199
- }
200
-
201
- // Update code blocks for the current theme
202
- function updateCodeBlockTheme() {
203
- const isDarkMode = document.documentElement.getAttribute('data-bs-theme') === 'dark';
204
- const codeBlocks = document.querySelectorAll('code.sql-query-code');
205
-
206
- codeBlocks.forEach(codeBlock => {
207
- if (isDarkMode) {
208
- codeBlock.style.backgroundColor = 'rgba(255, 255, 255, 0.1)';
209
- codeBlock.style.color = '#65cdff';
210
- } else {
211
- codeBlock.style.backgroundColor = 'rgba(0, 0, 0, 0.05)';
212
- codeBlock.style.color = '';
213
- }
214
- });
215
- }
216
-
217
- // Initial theme check
218
- updateCodeBlockTheme();
219
-
220
- // Listen for theme changes
221
- document.addEventListener('dbviewerThemeChanged', function(event) {
222
- updateCodeBlockTheme();
223
- });
224
- });
225
- </script>
@@ -1,9 +1,5 @@
1
1
  <% content_for :title, "SQL Query Logs" %>
2
2
 
3
- <% content_for :sidebar do %>
4
- <%= render 'dbviewer/shared/sidebar' %>
5
- <% end %>
6
-
7
3
  <div class="container-fluid">
8
4
  <div class="d-flex justify-content-between align-items-center mb-2">
9
5
  <h1>
@@ -2,10 +2,6 @@
2
2
  Database Tables
3
3
  <% end %>
4
4
 
5
- <% content_for :sidebar do %>
6
- <%= render 'dbviewer/shared/sidebar' %>
7
- <% end %>
8
-
9
5
  <div class="d-flex justify-content-between align-items-center mb-4">
10
6
  <h1>Database Tables</h1>
11
7
  <div>
@@ -181,10 +181,6 @@
181
181
 
182
182
  <% content_for :sidebar_active do %>active<% end %>
183
183
 
184
- <% content_for :sidebar do %>
185
- <%= render 'dbviewer/shared/sidebar' %>
186
- <% end %>
187
-
188
184
  <div class="d-flex justify-content-between align-items-center mb-4">
189
185
  <h1>Query: <%= @table_name %></h1>
190
186
  <div>