dbviewer 0.4.7 → 0.4.8

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: 61c23f612495654e7fba0280fd361cf872d668ea21618c74c95d05f4ea7fdb6a
4
- data.tar.gz: eeea9728edb2716f44e66eb1851767a7e77cf38c53f3ee4c676fd3d1d9e3608d
3
+ metadata.gz: 03dfb13567e8cf7a2eaf2977e421fec7a2117ff12a6462515399a4b7cfb056d1
4
+ data.tar.gz: 77ae23ada80eabbc1a5744376a96c0d5df4f20f0cb3723be4c0f9c9967994716
5
5
  SHA512:
6
- metadata.gz: 6674c2063fb577a3468ded6ffab856bcc8092f5a6fa46a28eb727f3e6a140556401c05777a7bc4ab7dd9e2a78c90b4576800db5a6b724f31d6a1e8f649cc1392
7
- data.tar.gz: 1714aa447da6c73754b4702e2114e63dca6c1dce5be4be790bd0b7ae89aa7972f9bbbfc54de588da5237f45ca69066f2fde1b50ae15017e0a52842c954ee9372
6
+ metadata.gz: 35d69706133dc764c081a6bc172dc0d99f39c2eaa7d62db9c17664c5a1fe05b78255932bd14a3f9a9542e99cb74020cb2926d69c9d21d9a339776fc4023098e9
7
+ data.tar.gz: b3a4e2029d81da79e922fb5ee0e889fc9e1f66e66129136333f6820d66dbc1dd7648da63a4ab99d3ed822e8cc64c77e9815a1c1bd34b4d0a11b208118d2eb72c
@@ -103,11 +103,9 @@ module Dbviewer
103
103
  @current_page = [ 1, params[:page].to_i ].max
104
104
  @per_page = params[:per_page] ? params[:per_page].to_i : self.class.default_per_page
105
105
  @per_page = self.class.default_per_page unless self.class.per_page_options.include?(@per_page)
106
- @order_by = params[:order_by].presence ||
107
- database_manager.primary_key(@table_name).presence ||
108
- (@columns.first ? @columns.first[:name] : nil)
106
+ @order_by = params[:order_by].presence || determine_default_order_column
109
107
  @order_direction = params[:order_direction].upcase if params[:order_direction].present?
110
- @order_direction = "ASC" unless self.class::VALID_SORT_DIRECTIONS.include?(@order_direction)
108
+ @order_direction = "DESC" unless self.class::VALID_SORT_DIRECTIONS.include?(@order_direction)
111
109
  @column_filters = params[:column_filters].presence ? params[:column_filters].to_enum.to_h : {}
112
110
  end
113
111
 
@@ -158,5 +156,23 @@ module Dbviewer
158
156
  end
159
157
  end
160
158
  end
159
+
160
+ # Determine the default order column using configurable ordering logic
161
+ def determine_default_order_column
162
+ # Get the table columns to check what's available
163
+ columns = @columns || fetch_table_columns(@table_name)
164
+ column_names = columns.map { |col| col[:name] }
165
+
166
+ # Try the configured default order column first
167
+ default_column = Dbviewer.configuration.default_order_column
168
+ return default_column if default_column && column_names.include?(default_column)
169
+
170
+ # Fall back to primary key
171
+ primary_key = database_manager.primary_key(@table_name)
172
+ return primary_key if primary_key.present?
173
+
174
+ # Final fallback to first column
175
+ columns.first ? columns.first[:name] : nil
176
+ end
161
177
  end
162
178
  end
@@ -400,73 +400,173 @@ document.addEventListener('DOMContentLoaded', function() {
400
400
  </script>
401
401
 
402
402
  <style>
403
+ /* ================================================
404
+ CSS Custom Properties (CSS Variables)
405
+ ================================================ */
406
+ :root {
407
+ /* Colors */
408
+ --dbviewer-code-bg: rgba(0, 0, 0, 0.05);
409
+ --dbviewer-code-border: rgba(0, 0, 0, 0.1);
410
+ --dbviewer-muted-color: #6c757d;
411
+ --dbviewer-success-color: #28a745;
412
+ --dbviewer-danger-color: #dc3545;
413
+ --dbviewer-warning-color: #ffc107;
414
+
415
+ /* Skeleton loader colors */
416
+ --skeleton-base-color: #f0f0f0;
417
+ --skeleton-highlight-color: #e0e0e0;
418
+
419
+ /* Typography */
420
+ --dbviewer-monospace-font: 'Courier New', Courier, monospace;
421
+ --dbviewer-code-font-size: 0.85rem;
422
+
423
+ /* Spacing and sizing */
424
+ --dbviewer-border-radius: 4px;
425
+ --dbviewer-border-radius-sm: 3px;
426
+ --dbviewer-padding-sm: 2px 4px;
427
+ }
428
+
429
+ /* ================================================
430
+ Dark Mode Support
431
+ ================================================ */
432
+ @media (prefers-color-scheme: dark) {
433
+ :root {
434
+ --dbviewer-code-bg: rgba(255, 255, 255, 0.1);
435
+ --dbviewer-code-border: rgba(255, 255, 255, 0.15);
436
+ --dbviewer-muted-color: #adb5bd;
437
+ --skeleton-base-color: #2a2a2a;
438
+ --skeleton-highlight-color: #404040;
439
+ }
440
+ }
441
+
442
+ /* Bootstrap dark mode support */
443
+ [data-bs-theme="dark"] {
444
+ --dbviewer-code-bg: rgba(255, 255, 255, 0.1);
445
+ --dbviewer-code-border: rgba(255, 255, 255, 0.15);
446
+ --dbviewer-muted-color: #adb5bd;
447
+ --skeleton-base-color: #2a2a2a;
448
+ --skeleton-highlight-color: #404040;
449
+ }
450
+
451
+ /* ================================================
452
+ SQL Query Styling
453
+ ================================================ */
403
454
  .sql-query-code {
404
- font-family: 'Courier New', Courier, monospace;
405
- font-size: 0.85rem;
406
- background-color: rgba(0, 0, 0, 0.05);
407
- padding: 2px 4px;
408
- border-radius: 3px;
455
+ font-family: var(--dbviewer-monospace-font);
456
+ font-size: var(--dbviewer-code-font-size);
457
+ background-color: var(--dbviewer-code-bg);
458
+ padding: var(--dbviewer-padding-sm);
459
+ border-radius: var(--dbviewer-border-radius-sm);
460
+ border: 1px solid var(--dbviewer-code-border);
461
+ transition: background-color 0.2s ease, border-color 0.2s ease;
409
462
  }
410
-
463
+
464
+ .sql-query-code:hover {
465
+ background-color: var(--dbviewer-code-bg);
466
+ filter: brightness(0.95);
467
+ }
468
+
469
+ /* ================================================
470
+ Query Performance Indicators
471
+ ================================================ */
411
472
  .query-duration {
412
- color: #28a745;
473
+ color: var(--dbviewer-success-color);
413
474
  font-weight: 500;
475
+ font-variant-numeric: tabular-nums;
476
+ transition: color 0.2s ease;
414
477
  }
415
478
 
416
479
  .query-duration-slow {
417
- color: #dc3545;
480
+ color: var(--dbviewer-danger-color);
418
481
  font-weight: 600;
482
+ font-variant-numeric: tabular-nums;
483
+ transition: color 0.2s ease;
419
484
  }
420
485
 
421
486
  .query-timestamp {
422
- color: #6c757d;
487
+ color: var(--dbviewer-muted-color);
488
+ font-variant-numeric: tabular-nums;
489
+ transition: color 0.2s ease;
423
490
  }
424
-
491
+
492
+ /* ================================================
493
+ Empty States and Messages
494
+ ================================================ */
425
495
  .empty-data-message {
426
- color: #6c757d;
496
+ color: var(--dbviewer-muted-color);
497
+ transition: color 0.2s ease;
427
498
  }
428
-
429
- /* Loading animations */
499
+
500
+ .empty-data-message p {
501
+ margin-bottom: 0.5rem;
502
+ font-weight: 500;
503
+ }
504
+
505
+ .empty-data-message small {
506
+ opacity: 0.8;
507
+ }
508
+
509
+ /* ================================================
510
+ Loading States
511
+ ================================================ */
430
512
  .spinner-border-sm {
431
513
  width: 1rem;
432
514
  height: 1rem;
433
515
  }
434
-
435
- /* Skeleton loader styles */
516
+
517
+ /* ================================================
518
+ Skeleton Loader System
519
+ ================================================ */
436
520
  .skeleton-loader {
437
521
  display: inline-block;
438
522
  height: 1.2em;
439
523
  width: 100%;
440
- background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 37%, #f0f0f0 63%);
524
+ background: linear-gradient(
525
+ 90deg,
526
+ var(--skeleton-base-color) 25%,
527
+ var(--skeleton-highlight-color) 37%,
528
+ var(--skeleton-base-color) 63%
529
+ );
441
530
  background-size: 400% 100%;
442
531
  animation: skeleton-loading 1.2s ease-in-out infinite;
443
- border-radius: 4px;
532
+ border-radius: var(--dbviewer-border-radius);
444
533
  }
445
- .number-loader {
534
+
535
+ /* Skeleton loader variants */
536
+ .skeleton-loader.number-loader {
446
537
  width: 2.5em;
447
538
  height: 1.5em;
448
539
  margin-bottom: 0.2em;
449
540
  }
450
- .table-cell-loader {
541
+
542
+ .skeleton-loader.table-cell-loader {
451
543
  width: 6em;
452
544
  height: 1.2em;
453
545
  }
454
- .records-loader {
546
+
547
+ .skeleton-loader.records-loader {
455
548
  width: 3em;
456
549
  height: 1.2em;
457
550
  }
458
- .query-cell-loader {
551
+
552
+ .skeleton-loader.query-cell-loader {
459
553
  width: 12em;
460
554
  height: 1.2em;
461
555
  }
462
- .duration-cell-loader {
556
+
557
+ .skeleton-loader.duration-cell-loader {
463
558
  width: 4em;
464
559
  height: 1.2em;
465
560
  }
466
- .time-cell-loader {
561
+
562
+ .skeleton-loader.time-cell-loader {
467
563
  width: 7em;
468
564
  height: 1.2em;
469
565
  }
566
+
567
+ /* ================================================
568
+ Animations
569
+ ================================================ */
470
570
  @keyframes skeleton-loading {
471
571
  0% {
472
572
  background-position: 100% 50%;
@@ -475,4 +575,58 @@ document.addEventListener('DOMContentLoaded', function() {
475
575
  background-position: 0 50%;
476
576
  }
477
577
  }
578
+
579
+ /* ================================================
580
+ Table Enhancements
581
+ ================================================ */
582
+ .table-hover tbody tr:hover .sql-query-code {
583
+ background-color: var(--dbviewer-code-bg);
584
+ filter: brightness(0.9);
585
+ }
586
+
587
+ /* ================================================
588
+ Responsive Design
589
+ ================================================ */
590
+ @media (max-width: 768px) {
591
+ .sql-query-code {
592
+ font-size: 0.75rem;
593
+ padding: 1px 3px;
594
+ }
595
+
596
+ .query-cell-loader {
597
+ width: 8em;
598
+ }
599
+
600
+ .duration-cell-loader {
601
+ width: 3em;
602
+ }
603
+
604
+ .time-cell-loader {
605
+ width: 5em;
606
+ }
607
+ }
608
+
609
+ /* ================================================
610
+ Accessibility Improvements
611
+ ================================================ */
612
+ @media (prefers-reduced-motion: reduce) {
613
+ .skeleton-loader {
614
+ animation: none;
615
+ background: var(--skeleton-base-color);
616
+ }
617
+
618
+ .sql-query-code,
619
+ .query-duration,
620
+ .query-duration-slow,
621
+ .query-timestamp,
622
+ .empty-data-message {
623
+ transition: none;
624
+ }
625
+ }
626
+
627
+ /* Focus states for better keyboard navigation */
628
+ .sql-query-code:focus-visible {
629
+ outline: 2px solid var(--dbviewer-success-color);
630
+ outline-offset: 2px;
631
+ }
478
632
  </style>
@@ -38,6 +38,9 @@ module Dbviewer
38
38
  # @example { username: 'admin', password: 'secret' }
39
39
  attr_accessor :admin_credentials
40
40
 
41
+ # Default column to order table details by (e.g., 'updated_at')
42
+ attr_accessor :default_order_column
43
+
41
44
  def initialize
42
45
  @per_page_options = [ 10, 20, 50, 100 ]
43
46
  @default_per_page = 20
@@ -51,6 +54,7 @@ module Dbviewer
51
54
  @max_memory_queries = 1000
52
55
  @enable_query_logging = true
53
56
  @admin_credentials = nil
57
+ @default_order_column = "updated_at"
54
58
  end
55
59
  end
56
60
  end
@@ -1,3 +1,3 @@
1
1
  module Dbviewer
2
- VERSION = "0.4.7"
2
+ VERSION = "0.4.8"
3
3
  end
@@ -15,4 +15,7 @@ Dbviewer.configure do |config|
15
15
 
16
16
  # Authentication options
17
17
  # config.admin_credentials = { username: "admin", password: "your_secure_password" } # Basic HTTP auth credentials
18
+
19
+ # Default table ordering options
20
+ config.default_order_column = "updated_at" # Primary column to order by
18
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbviewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wailan Tirajoh