sidekiq-belt 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 300d0c79beb050fe381ebbc075dc66f59454eda2fa01fc0fdcbb8b1945cd2140
4
- data.tar.gz: 875c38988275047a9fb6f3293aa68ac0c1d0ca0733b02025f20397b2980d295a
3
+ metadata.gz: fb4d769018b00b231892ae9852e6fd7d8c51074f6752332fa46ce6e606d68ba7
4
+ data.tar.gz: 9b05f6c1a3a505c7e6028bd6248f07ed7964a307129d7f8fc3206d96817c2b61
5
5
  SHA512:
6
- metadata.gz: b8c6e92eeea82ce664ee76a9670561173b927d699dc44cb3bd8bb762c29a95c8f73cfb63fa81a0ce2646896d8bcd4aeaf29cf9ea796a3edf690f3f139198b38e
7
- data.tar.gz: bdfc0a9b7662c086c3743e6825e0356ee79f5dd17db3fd24750e9dd8b8b6e34c0ae5589ae2a7ce01ed8d61a852d6fbd1f82c89a55547abb429a43269b442d389
6
+ metadata.gz: d7c1f6c6ef57da7f982bc3c1c2cfc8ffec1982ed0030a37f9b829fc9ff4e2dcabd1f606283d81014e668fa1063504f6b2dcf77837b45939a3654f91d5f99354b
7
+ data.tar.gz: 6cb88155712149c79268f4f0a27a49c81e60eccc890c6eed0a1a9c29b9697ff561d9730f333c16b428bbf3ca0b50a2857da1439e7b049f367b8511b3b269af3a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.4] - 2024-01-07
4
+
5
+ - Feature top label
6
+
7
+ ## [0.3.3] - 2024-06-11
8
+
9
+ - Feature list to run jobs
10
+
3
11
  ## [0.3.2] - 2024-01-07
4
12
 
5
13
  - Feature to sort periodic list by class name
data/README.md CHANGED
@@ -116,6 +116,35 @@ Sidekiq::Belt.configure do |config|
116
116
  end
117
117
  ```
118
118
 
119
+ ### Add to your web sidekiq a top label by enviroment (sidekiq)
120
+
121
+ This feature adds a little line on top of Sidekiq web that shows a configurable message.
122
+
123
+ ![Top Page Development](https://github.com/dannnylo/sidekiq-belt/assets/20794/b1e2f6c2-a257-4172-92ec-09c61511334b)
124
+ ![Top Page Production](https://github.com/dannnylo/sidekiq-belt/assets/20794/8e64d0e8-dcb2-42ee-b184-67d2f0b2cf6f)
125
+
126
+ To enable this feature, pass the `top_label` option:
127
+ ```ruby
128
+ Sidekiq::Belt.use!([:top_label])
129
+ ```
130
+
131
+ ```ruby
132
+ Sidekiq::Belt.configure do |config|
133
+ config.top_label = {
134
+ production: {
135
+ background_color: 'red',
136
+ text: 'Be carefull',
137
+ color: 'white'
138
+ },
139
+ development: {
140
+ background_color: 'green',
141
+ text: 'You are safe!',
142
+ color: 'white'
143
+ }
144
+ }
145
+ end
146
+ ```
147
+
119
148
  ## Development
120
149
 
121
150
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -3,6 +3,7 @@
3
3
  require "sidekiq"
4
4
 
5
5
  require_relative "run_job"
6
+ require_relative "top_label"
6
7
 
7
8
  module Sidekiq
8
9
  module Belt
@@ -10,6 +11,7 @@ module Sidekiq
10
11
  module Files
11
12
  def self.use!(options = [:all])
12
13
  Sidekiq::Belt::Community::RunJob.use! if should_use?(:run_job, options)
14
+ Sidekiq::Belt::Community::TopLabel.use! if should_use?(:top_label, options)
13
15
 
14
16
  true
15
17
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "sidekiq/web"
4
+ require "sidekiq/web/helpers"
5
+
6
+ module Sidekiq
7
+ module Belt
8
+ module Community
9
+ module TopLabel
10
+ def self.use!
11
+ Sidekiq::WebActionHelper.change_layout do |content|
12
+ top_label = (Sidekiq::Belt.config.top_label || {}).fetch(Sidekiq::Belt.env, {})
13
+
14
+ html = "<div class='container-fluid'
15
+ style='background: #{::Rack::Utils.escape_html(top_label.fetch(:background_color, "red"))};
16
+ text-align: center;
17
+ color: #{::Rack::Utils.escape_html(top_label.fetch(:color, "white"))};'>
18
+ &nbsp;#{::Rack::Utils.escape_html(top_label[:text].to_s)}&nbsp;
19
+ </div>"
20
+ unless top_label.empty?
21
+ content.gsub!('<div class="container-fluid">',
22
+ "#{html} <div class='container-fluid'>")
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Belt
5
- VERSION = "0.3.3"
5
+ VERSION = "0.3.4"
6
6
  end
7
7
  end
data/lib/sidekiq/belt.rb CHANGED
@@ -25,7 +25,15 @@ module Sidekiq
25
25
  end
26
26
 
27
27
  def self.config
28
- @config ||= Struct.new(:run_jobs).new([])
28
+ @config ||= Struct.new(:run_jobs, :top_label).new([], {})
29
+ end
30
+
31
+ def self.env
32
+ (Sidekiq.default_configuration[:environment] ||
33
+ ENV["APP_ENV"] ||
34
+ ENV["RAILS_ENV"] ||
35
+ ENV["RACK_ENV"] ||
36
+ "development").to_sym
29
37
  end
30
38
  end
31
39
  end
@@ -22,6 +22,23 @@ module Sidekiq
22
22
 
23
23
  super(engine, content, options)
24
24
  end
25
+
26
+ def self.change_layout(&block)
27
+ Sidekiq::Config::DEFAULTS[:layout_changes] ||= []
28
+ Sidekiq::Config::DEFAULTS[:layout_changes] << block
29
+ end
30
+
31
+ def _render
32
+ content = super
33
+
34
+ layout_changes = Sidekiq::Config::DEFAULTS[:layout_changes] || []
35
+
36
+ layout_changes.each do |content_block|
37
+ content_block.call(content)
38
+ end
39
+
40
+ content
41
+ end
25
42
  end
26
43
 
27
44
  Sidekiq::WebAction.prepend(Sidekiq::WebActionHelper)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-belt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danilo Jeremias da Silva
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-11 00:00:00.000000000 Z
11
+ date: 2024-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -43,6 +43,7 @@ files:
43
43
  - lib/sidekiq/belt.rb
44
44
  - lib/sidekiq/belt/community/files.rb
45
45
  - lib/sidekiq/belt/community/run_job.rb
46
+ - lib/sidekiq/belt/community/top_label.rb
46
47
  - lib/sidekiq/belt/community/views/run_jobs.erb
47
48
  - lib/sidekiq/belt/ent/files.rb
48
49
  - lib/sidekiq/belt/ent/periodic_pause.rb