solid_web_ui 0.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.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +74 -0
  3. data/app/assets/stylesheets/solid_web_ui.css +232 -0
  4. data/app/components/solid_web_ui/ui/page_component.html.erb +15 -0
  5. data/app/components/solid_web_ui/ui/page_component.rb +22 -0
  6. data/app/components/solid_web_ui/ui/paginator_component.html.erb +21 -0
  7. data/app/components/solid_web_ui/ui/paginator_component.rb +23 -0
  8. data/app/components/solid_web_ui/ui/stat_card_component.html.erb +11 -0
  9. data/app/components/solid_web_ui/ui/stat_card_component.rb +24 -0
  10. data/app/components/solid_web_ui/ui/status_badge_component.rb +37 -0
  11. data/app/components/solid_web_ui/ui/table_component.html.erb +18 -0
  12. data/app/components/solid_web_ui/ui/table_component.rb +19 -0
  13. data/app/controllers/solid_web_ui/cable/application_controller.rb +14 -0
  14. data/app/controllers/solid_web_ui/cable/channels_controller.rb +13 -0
  15. data/app/controllers/solid_web_ui/cable/dashboard_controller.rb +13 -0
  16. data/app/controllers/solid_web_ui/cable/messages_controller.rb +18 -0
  17. data/app/controllers/solid_web_ui/cache/application_controller.rb +14 -0
  18. data/app/controllers/solid_web_ui/cache/dashboard_controller.rb +13 -0
  19. data/app/controllers/solid_web_ui/cache/entries_controller.rb +24 -0
  20. data/app/controllers/solid_web_ui/queue/application_controller.rb +17 -0
  21. data/app/controllers/solid_web_ui/queue/dashboard_controller.rb +18 -0
  22. data/app/controllers/solid_web_ui/queue/failed_executions_controller.rb +34 -0
  23. data/app/controllers/solid_web_ui/queue/jobs_controller.rb +24 -0
  24. data/app/controllers/solid_web_ui/queue/processes_controller.rb +9 -0
  25. data/app/controllers/solid_web_ui/queue/queues_controller.rb +27 -0
  26. data/app/controllers/solid_web_ui/queue/recurring_tasks_controller.rb +9 -0
  27. data/app/helpers/solid_web_ui/cable/application_helper.rb +22 -0
  28. data/app/helpers/solid_web_ui/cache/application_helper.rb +23 -0
  29. data/app/helpers/solid_web_ui/component_helper.rb +28 -0
  30. data/app/helpers/solid_web_ui/queue/application_helper.rb +38 -0
  31. data/app/views/layouts/solid_web_ui.html.erb +33 -0
  32. data/app/views/solid_web_ui/cable/channels/index.html.erb +12 -0
  33. data/app/views/solid_web_ui/cable/dashboard/index.html.erb +24 -0
  34. data/app/views/solid_web_ui/cache/dashboard/index.html.erb +15 -0
  35. data/app/views/solid_web_ui/cache/entries/index.html.erb +15 -0
  36. data/app/views/solid_web_ui/queue/dashboard/index.html.erb +13 -0
  37. data/app/views/solid_web_ui/queue/failed_executions/index.html.erb +26 -0
  38. data/app/views/solid_web_ui/queue/jobs/index.html.erb +23 -0
  39. data/app/views/solid_web_ui/queue/processes/index.html.erb +14 -0
  40. data/app/views/solid_web_ui/queue/queues/index.html.erb +25 -0
  41. data/app/views/solid_web_ui/queue/recurring_tasks/index.html.erb +17 -0
  42. data/lib/solid_web_ui/cable/engine.rb +13 -0
  43. data/lib/solid_web_ui/cable/routes.rb +7 -0
  44. data/lib/solid_web_ui/cable.rb +18 -0
  45. data/lib/solid_web_ui/cache/engine.rb +13 -0
  46. data/lib/solid_web_ui/cache/routes.rb +7 -0
  47. data/lib/solid_web_ui/cache.rb +17 -0
  48. data/lib/solid_web_ui/configurable.rb +20 -0
  49. data/lib/solid_web_ui/engine.rb +13 -0
  50. data/lib/solid_web_ui/paginator.rb +49 -0
  51. data/lib/solid_web_ui/queue/engine.rb +15 -0
  52. data/lib/solid_web_ui/queue/routes.rb +18 -0
  53. data/lib/solid_web_ui/queue.rb +19 -0
  54. data/lib/solid_web_ui/theme.rb +71 -0
  55. data/lib/solid_web_ui/version.rb +5 -0
  56. data/lib/solid_web_ui.rb +33 -0
  57. metadata +193 -0
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ SolidWebUi::Queue::Engine.routes.draw do
4
+ root to: "dashboard#index"
5
+
6
+ get "queues", to: "queues#index", as: :queues
7
+ post "queues/:name/pause", to: "queues#pause", as: :pause_queue, constraints: { name: %r{[^/]+} }
8
+ post "queues/:name/resume", to: "queues#resume", as: :resume_queue, constraints: { name: %r{[^/]+} }
9
+
10
+ get "jobs", to: "jobs#index", as: :jobs
11
+
12
+ get "failed", to: "failed_executions#index", as: :failed_executions
13
+ post "failed/:id/retry", to: "failed_executions#retry", as: :retry_failed_execution
14
+ delete "failed/:id", to: "failed_executions#discard", as: :failed_execution
15
+
16
+ get "processes", to: "processes#index", as: :processes
17
+ get "recurring_tasks", to: "recurring_tasks#index", as: :recurring_tasks
18
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "solid_queue"
4
+
5
+ module SolidWebUi
6
+ # Mountable dashboard for Solid Queue. Part of the solid_web_ui gem; mount its
7
+ # engine independently: `mount SolidWebUi::Queue::Engine => "/admin/queue"`.
8
+ module Queue
9
+ extend SolidWebUi::Configurable
10
+
11
+ config.page_title = "Solid Queue"
12
+
13
+ setting :enable_retry, default: true
14
+ setting :enable_discard, default: true
15
+ setting :enable_pause, default: true
16
+ end
17
+ end
18
+
19
+ require "solid_web_ui/queue/engine"
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidWebUi
4
+ # Design-token contract. Every visual value the components use is a CSS custom
5
+ # property `--swui-*` scoped under `.solid-web-ui`. Hosts re-theme by overriding
6
+ # token *values* (Ruby `config.theme`, or their own CSS) — the precompiled
7
+ # stylesheet never needs to be rebuilt because only the values change, not the
8
+ # utilities. Defaults read common host variables first (auto-inheritance) and
9
+ # fall back to a neutral built-in palette.
10
+ module Theme
11
+ # token key => [ css var name, default value ]
12
+ LIGHT = {
13
+ color_primary: [ "--swui-color-primary", "var(--color-primary, #4f46e5)" ],
14
+ color_primary_contrast: [ "--swui-color-primary-contrast", "var(--color-primary-contrast, #ffffff)" ],
15
+ color_bg: [ "--swui-color-bg", "var(--color-bg, #f8fafc)" ],
16
+ color_surface: [ "--swui-color-surface", "var(--color-surface, #ffffff)" ],
17
+ color_text: [ "--swui-color-text", "var(--color-text, #0f172a)" ],
18
+ color_muted: [ "--swui-color-muted", "var(--color-muted, #64748b)" ],
19
+ color_border: [ "--swui-color-border", "var(--color-border, #e2e8f0)" ],
20
+ color_success: [ "--swui-color-success", "var(--color-success, #16a34a)" ],
21
+ color_warning: [ "--swui-color-warning", "var(--color-warning, #d97706)" ],
22
+ color_danger: [ "--swui-color-danger", "var(--color-danger, #dc2626)" ],
23
+ font: [ "--swui-font", "var(--swui-host-font, ui-sans-serif, system-ui, sans-serif)" ],
24
+ radius: [ "--swui-radius", "0.5rem" ]
25
+ }.freeze
26
+
27
+ # Dark scheme only re-points the surface/text family; brand color stays.
28
+ DARK = {
29
+ color_bg: [ "--swui-color-bg", "var(--color-bg, #0b0f19)" ],
30
+ color_surface: [ "--swui-color-surface", "var(--color-surface, #151a26)" ],
31
+ color_text: [ "--swui-color-text", "var(--color-text, #e2e8f0)" ],
32
+ color_muted: [ "--swui-color-muted", "var(--color-muted, #94a3b8)" ],
33
+ color_border: [ "--swui-color-border", "var(--color-border, #273043)" ]
34
+ }.freeze
35
+
36
+ module_function
37
+
38
+ # Serialize the default token contract, with `overrides` (a theme hash) applied.
39
+ def css_vars(overrides = {})
40
+ build(LIGHT, overrides)
41
+ end
42
+
43
+ # Dark-scheme token overrides, used inside a dark selector / media query.
44
+ def dark_css_vars(overrides = {})
45
+ build(DARK, overrides)
46
+ end
47
+
48
+ def build(table, overrides)
49
+ overrides = (overrides || {}).transform_keys(&:to_sym)
50
+ table.filter_map do |key, (var_name, default)|
51
+ value = overrides.key?(key) ? sanitize(overrides[key]) : default
52
+ value = default if value.nil? || value.empty? # reject unsafe overrides → fall back
53
+ next if value.nil? || value.empty?
54
+
55
+ "#{var_name}: #{value};"
56
+ end.join(" ")
57
+ end
58
+
59
+ # Allowlist of characters valid in a CSS value (colors, lengths, var()/calc(),
60
+ # font stacks). Anything outside it means a malformed or hostile value, so we
61
+ # reject it entirely (returns nil) rather than trying to scrub it — the token
62
+ # then falls back to its safe default. This makes breaking out of
63
+ # `<style>.solid-web-ui{ … }` impossible.
64
+ SAFE_VALUE = %r{\A[\w\s#%.,()'"/-]*\z}
65
+
66
+ def sanitize(value)
67
+ str = value.to_s.strip
68
+ str.match?(SAFE_VALUE) ? str : nil
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidWebUi
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/configurable"
4
+
5
+ require "solid_web_ui/version"
6
+ require "solid_web_ui/configurable"
7
+ require "solid_web_ui/theme"
8
+ require "solid_web_ui/paginator"
9
+ require "solid_web_ui/engine"
10
+
11
+ module SolidWebUi
12
+ extend Dry::Configurable
13
+
14
+ # Theming / asset settings shared across all three dashboards.
15
+ setting :theme, default: {} # token overrides, e.g. { color_primary: "#7c3aed" }
16
+ setting :color_scheme, default: "auto" # "auto" | "light" | "dark"
17
+ setting :stylesheet, default: true # false → don't link the bundled CSS (host takes over)
18
+ setting :extra_stylesheets, default: [] # extra Propshaft stylesheet names to link after ours
19
+
20
+ # Resolve a configured controller class name to a class. Called lazily when a
21
+ # web engine's ApplicationController is autoloaded, so host initializers have
22
+ # already run and `base_controller_class` points at the host's auth controller.
23
+ def self.resolve_base_controller(class_name)
24
+ class_name.to_s.constantize
25
+ end
26
+ end
27
+
28
+ # Mountable dashboard parts. Each defines its own isolated engine
29
+ # (SolidWebUi::Queue::Engine, ::Cache::Engine, ::Cable::Engine) that the host
30
+ # mounts independently.
31
+ require "solid_web_ui/queue"
32
+ require "solid_web_ui/cache"
33
+ require "solid_web_ui/cable"
metadata ADDED
@@ -0,0 +1,193 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solid_web_ui
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anton Radushev
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rails
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '8.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '8.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: view_component
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '3.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: dry-configurable
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '1.0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: propshaft
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '1.0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: solid_queue
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '1.0'
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '1.0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: solid_cache
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '1.0'
89
+ type: :runtime
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '1.0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: solid_cable
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '1.0'
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '1.0'
110
+ description: 'A single gem with three independently mountable Rails engines (SolidWebUi::Queue/Cache/Cable::Engine)
111
+ sharing one design system: ViewComponents, a layout, design-token theming and a
112
+ dry-configurable base.'
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - README.md
118
+ - app/assets/stylesheets/solid_web_ui.css
119
+ - app/components/solid_web_ui/ui/page_component.html.erb
120
+ - app/components/solid_web_ui/ui/page_component.rb
121
+ - app/components/solid_web_ui/ui/paginator_component.html.erb
122
+ - app/components/solid_web_ui/ui/paginator_component.rb
123
+ - app/components/solid_web_ui/ui/stat_card_component.html.erb
124
+ - app/components/solid_web_ui/ui/stat_card_component.rb
125
+ - app/components/solid_web_ui/ui/status_badge_component.rb
126
+ - app/components/solid_web_ui/ui/table_component.html.erb
127
+ - app/components/solid_web_ui/ui/table_component.rb
128
+ - app/controllers/solid_web_ui/cable/application_controller.rb
129
+ - app/controllers/solid_web_ui/cable/channels_controller.rb
130
+ - app/controllers/solid_web_ui/cable/dashboard_controller.rb
131
+ - app/controllers/solid_web_ui/cable/messages_controller.rb
132
+ - app/controllers/solid_web_ui/cache/application_controller.rb
133
+ - app/controllers/solid_web_ui/cache/dashboard_controller.rb
134
+ - app/controllers/solid_web_ui/cache/entries_controller.rb
135
+ - app/controllers/solid_web_ui/queue/application_controller.rb
136
+ - app/controllers/solid_web_ui/queue/dashboard_controller.rb
137
+ - app/controllers/solid_web_ui/queue/failed_executions_controller.rb
138
+ - app/controllers/solid_web_ui/queue/jobs_controller.rb
139
+ - app/controllers/solid_web_ui/queue/processes_controller.rb
140
+ - app/controllers/solid_web_ui/queue/queues_controller.rb
141
+ - app/controllers/solid_web_ui/queue/recurring_tasks_controller.rb
142
+ - app/helpers/solid_web_ui/cable/application_helper.rb
143
+ - app/helpers/solid_web_ui/cache/application_helper.rb
144
+ - app/helpers/solid_web_ui/component_helper.rb
145
+ - app/helpers/solid_web_ui/queue/application_helper.rb
146
+ - app/views/layouts/solid_web_ui.html.erb
147
+ - app/views/solid_web_ui/cable/channels/index.html.erb
148
+ - app/views/solid_web_ui/cable/dashboard/index.html.erb
149
+ - app/views/solid_web_ui/cache/dashboard/index.html.erb
150
+ - app/views/solid_web_ui/cache/entries/index.html.erb
151
+ - app/views/solid_web_ui/queue/dashboard/index.html.erb
152
+ - app/views/solid_web_ui/queue/failed_executions/index.html.erb
153
+ - app/views/solid_web_ui/queue/jobs/index.html.erb
154
+ - app/views/solid_web_ui/queue/processes/index.html.erb
155
+ - app/views/solid_web_ui/queue/queues/index.html.erb
156
+ - app/views/solid_web_ui/queue/recurring_tasks/index.html.erb
157
+ - lib/solid_web_ui.rb
158
+ - lib/solid_web_ui/cable.rb
159
+ - lib/solid_web_ui/cable/engine.rb
160
+ - lib/solid_web_ui/cable/routes.rb
161
+ - lib/solid_web_ui/cache.rb
162
+ - lib/solid_web_ui/cache/engine.rb
163
+ - lib/solid_web_ui/cache/routes.rb
164
+ - lib/solid_web_ui/configurable.rb
165
+ - lib/solid_web_ui/engine.rb
166
+ - lib/solid_web_ui/paginator.rb
167
+ - lib/solid_web_ui/queue.rb
168
+ - lib/solid_web_ui/queue/engine.rb
169
+ - lib/solid_web_ui/queue/routes.rb
170
+ - lib/solid_web_ui/theme.rb
171
+ - lib/solid_web_ui/version.rb
172
+ homepage: https://github.com/doromones/solid-web
173
+ licenses:
174
+ - MIT
175
+ metadata: {}
176
+ rdoc_options: []
177
+ require_paths:
178
+ - lib
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '3.2'
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ requirements: []
190
+ rubygems_version: 3.6.9
191
+ specification_version: 4
192
+ summary: Web dashboards for Solid Queue, Solid Cache and Solid Cable.
193
+ test_files: []