solid_litequeen 0.7.0 → 0.8.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9e57ed5cad271d83a2a34e75779abfdbd3c28cfde1c8ecb1f2d2aed1a46ce69
4
- data.tar.gz: 9dc4ed53f255a0d8f926985426ddd2eca248aa6de1c6f4398e6c0b86127c85f2
3
+ metadata.gz: f307bf9d9eb772756d40395b38cef8f0f0a9cd905e1e0caff872855d9bedf3a6
4
+ data.tar.gz: 0a0a6528451d67eede41bf3a967a87aebf78da47e07adb4ebc8fab6e20b36d12
5
5
  SHA512:
6
- metadata.gz: 919d4743f19a2ac203bcb68a192625c2bbf9854403332d6c42828075920308b5cf54fd6e1fc447b149011b84ccca28d265daecd94d65f7a461020fb6242733bd
7
- data.tar.gz: ab1380c616424ca7b3e6b246f828ff704991407a0e436409a8bace5ee5429b39486efe3d7e98a253ddf229b8f9fe73104ceafd5dd34423b9591143bf660a2e4d
6
+ metadata.gz: ed7ae24cd435790f31d182634a344202d6f5c839cfedae4d41660113d13b394168fb4426fc6916aeb02d2ba81d2e06f9c208f42608cea508d5b650dc39d67ee4
7
+ data.tar.gz: 926ec78a8f509413478913ae70fde680992dc353a362250808125c5cac7b8e3c1d69c482dc987fc9f260763a9a67f8427ed1b7645e4a70a99ba34f51d13a2ac5
@@ -5,9 +5,6 @@ module SolidLitequeen
5
5
 
6
6
  class DatabasesController < ApplicationController
7
7
  def index
8
- @databases = ActiveRecord::Base.configurations.configurations.select do |config|
9
- config.adapter == "sqlite3" && config.env_name == Rails.env && config.database.present?
10
- end
11
8
  end
12
9
 
13
10
  def show
@@ -32,6 +29,28 @@ module SolidLitequeen
32
29
  @database_id = params.expect(:database_id)
33
30
  @table_name = params.expect(:table)
34
31
 
32
+ # Create a unique key for this table's sort preferences
33
+ sort_key = "#{@database_id}_#{@table_name}_sort"
34
+
35
+ # Update session if new sort params are provided
36
+ if params[:sort_column].present?
37
+ session[sort_key] = {
38
+ sort_column: params[:sort_column].to_s,
39
+ sort_direction: (params[:sort_direction]&.upcase == "DESC" ? "DESC" : "ASC")
40
+ }.stringify_keys # Ensure all keys are strings in session
41
+ end
42
+
43
+ # Get sort preferences from session or set defaults with string keys
44
+ sort_prefs = session[sort_key]&.with_indifferent_access || {
45
+ "sort_column" => nil,
46
+ "sort_direction" => nil
47
+ }
48
+
49
+ @sort_column = sort_prefs["sort_column"]
50
+ @sort_direction = sort_prefs["sort_direction"]
51
+
52
+ # debugger
53
+
35
54
  @database_location = Base64.urlsafe_decode64(@database_id)
36
55
 
37
56
  DynamicDatabase.establish_connection(
@@ -39,7 +58,19 @@ module SolidLitequeen
39
58
  database: @database_location
40
59
  )
41
60
 
42
- @data = DynamicDatabase.connection.select_all("SELECT * FROM #{@table_name} LIMIT 50")
61
+ # Verify the sort column exists in the table to prevent SQL injection
62
+ valid_columns = DynamicDatabase.connection.columns(@table_name).map(&:name)
63
+
64
+ order_clause = if @sort_column.present? && valid_columns.include?(@sort_column)
65
+ "#{DynamicDatabase.connection.quote_column_name(@sort_column)} #{@sort_direction}"
66
+ end
67
+
68
+ sql = [ "SELECT * FROM #{@table_name}" ]
69
+ sql << "ORDER BY #{order_clause}" if order_clause
70
+ sql << "LIMIT 50"
71
+
72
+
73
+ @data = DynamicDatabase.connection.select_all(sql.join(" "))
43
74
  @row_count = row_count = DynamicDatabase.connection.select_value("SELECT COUNT(*) FROM #{@table_name}").to_i
44
75
  end
45
76
 
@@ -9,7 +9,7 @@
9
9
  <%= stylesheet_link_tag "solid_litequeen/application", media: "all", "data-turbo-track": "reload" %>
10
10
  <script src="https://unpkg.com/@tailwindcss/browser@4"></script>
11
11
  <style type="text/tailwindcss">
12
-
12
+ @plugins "form";
13
13
 
14
14
  @theme {
15
15
  --color-clifford: #da373d;
@@ -22,7 +22,7 @@
22
22
  <%= yield :head %>
23
23
  </head>
24
24
  <body class="">
25
- <header>
25
+ <header class="container mx-auto mt-4 mb-8">
26
26
  <%= render "solid_litequeen/database-selector" %>
27
27
  </header>
28
28
  <%= yield %>
@@ -21,7 +21,19 @@
21
21
  <thead class="">
22
22
  <tr class="bg-gray-100 border-b border-gray-200">
23
23
  <% @data.columns.each do |column| %>
24
- <th class="px-6 py-3 text-left text-sm font-medium text-gray-700 whitespace-nowrap"><%= column %></th>
24
+ <th class="px-6 py-3 text-left text-sm font-medium text-gray-700 whitespace-nowrap">
25
+ <%#= column %>
26
+
27
+ <%= link_to column,
28
+ database_table_rows_path(
29
+ database_id: @database_id,
30
+ table: @table_name,
31
+ sort_column: column,
32
+ sort_direction: (@sort_column == column && @sort_direction == 'DESC') ? 'ASC' : 'DESC'
33
+ ) %>
34
+ <%= '▼' if @sort_column == column && @sort_direction == 'DESC' %>
35
+ <%= '▲' if @sort_column == column && @sort_direction == 'ASC' %>
36
+ </th>
25
37
  <% end %>
26
38
  </tr>
27
39
  </thead>
@@ -1,3 +1,3 @@
1
1
  module SolidLitequeen
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_litequeen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vik Borges
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-08 00:00:00.000000000 Z
11
+ date: 2025-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails