web47core 3.2.3.45 → 3.2.3.46
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 +4 -4
- data/app/controllers/status_controller.rb +5 -4
- data/app/helpers/svg_icon_helper.rb +28 -16
- data/app/views/status/index.html.haml +1 -3
- data/lib/web47core/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5cb60aaf9b363d9d95a53e02cd2875e60b79f26344d64e08f6ba2ab8dce88e28
|
|
4
|
+
data.tar.gz: 383b9f556359a6578d06ea3b319c0382016e6638d2c914da04684d34a7c9d933
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 670ea6d949445923fe1a9ec0f0a9b27d48a9ad6a73ac5dd3050088e1adc13fc9393f7d67991826db3587a864319b112700c8bfd2fa761bcf47437c17c63810ff
|
|
7
|
+
data.tar.gz: 4565290e61d30d10a39be0584e7b6fe200fe76edfbf769f42e6e0c4af3544218a4be89b7049d6fe4d66237cca637f09e27511b184ef1827baa00d6abfa0fd5e7
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# Return the status of the server
|
|
5
5
|
#
|
|
6
6
|
class StatusController < ActionController::Base
|
|
7
|
+
helper SvgIconHelper
|
|
7
8
|
protect_from_forgery with: :exception
|
|
8
9
|
#
|
|
9
10
|
# Main (and only) page
|
|
@@ -40,11 +41,11 @@ class StatusController < ActionController::Base
|
|
|
40
41
|
def ui_decorators(components)
|
|
41
42
|
components.each do |key, values|
|
|
42
43
|
if values[:success]
|
|
43
|
-
components[key][:icon_name] = '
|
|
44
|
-
components[key][:icon_color] =
|
|
44
|
+
components[key][:icon_name] = 'circle-check'
|
|
45
|
+
components[key][:icon_color] = :green
|
|
45
46
|
else
|
|
46
|
-
components[key][:icon_name] = '
|
|
47
|
-
components[key][:icon_color] =
|
|
47
|
+
components[key][:icon_name] = 'circle-x'
|
|
48
|
+
components[key][:icon_color] = :red
|
|
48
49
|
end
|
|
49
50
|
end
|
|
50
51
|
end
|
|
@@ -3,33 +3,25 @@
|
|
|
3
3
|
module SvgIconHelper
|
|
4
4
|
# @abstract Render the appropriate icon based on the name and type
|
|
5
5
|
# @return [View]
|
|
6
|
-
def svg_icon(name, size: 24, type: :outline, classes: [], color: 'currentColor', stroke_width: 2)
|
|
6
|
+
def svg_icon(name, size: 24, type: :outline, classes: [], color: 'currentColor', stroke_width: 2, cached: true)
|
|
7
7
|
return if name.blank?
|
|
8
8
|
|
|
9
|
+
unless cached
|
|
10
|
+
return fetch_svg_icon(name, size: size, type: type, classes: classes, color: color, stroke_width: stroke_width,
|
|
11
|
+
cached: false)
|
|
12
|
+
end
|
|
13
|
+
|
|
9
14
|
key = ['svg_icon', name, size.to_s, type.to_s, classes.to_s, color, stroke_width.to_s].join(':')
|
|
10
15
|
Rails.cache.fetch(key, expires_in: 15.minutes) do
|
|
11
16
|
fetch_svg_icon(name, size: size, type: type, classes: classes, color: color, stroke_width: stroke_width)
|
|
12
17
|
end
|
|
13
18
|
end
|
|
14
19
|
|
|
15
|
-
def fetch_svg_icon(name, size: 24, type: :outline, classes: [], color: 'currentColor', stroke_width: 2)
|
|
20
|
+
def fetch_svg_icon(name, size: 24, type: :outline, classes: [], color: 'currentColor', stroke_width: 2, cached: true)
|
|
16
21
|
return if name.blank?
|
|
17
22
|
|
|
18
23
|
classes = classes.compact.flatten.join(' ')
|
|
19
|
-
|
|
20
|
-
(partial, stroke) = Rails.cache.fetch(key, expires_in: 15.minutes) do
|
|
21
|
-
preferred_path = if I18n.exists?("nav.icons.#{name}")
|
|
22
|
-
"icons/#{I18n.t("nav.icons.#{name}")}"
|
|
23
|
-
else
|
|
24
|
-
"icons/#{type}/#{name}"
|
|
25
|
-
end
|
|
26
|
-
outline_path = "icons/outline/#{name}"
|
|
27
|
-
filled_path = "icons/filled/#{name}"
|
|
28
|
-
|
|
29
|
-
[preferred_path, outline_path, filled_path].collect do |path|
|
|
30
|
-
[preferred_path, color] if lookup_context.exists?(path, [], true)
|
|
31
|
-
end.compact.first
|
|
32
|
-
end
|
|
24
|
+
partial, stroke = icon_partial(name, type, color, cached: cached)
|
|
33
25
|
if partial.blank?
|
|
34
26
|
partial = 'icons/outline/bug'
|
|
35
27
|
stroke = 'red'
|
|
@@ -42,6 +34,7 @@ module SvgIconHelper
|
|
|
42
34
|
class: classes,
|
|
43
35
|
fill: 'none',
|
|
44
36
|
stroke: stroke,
|
|
37
|
+
style: "color: #{stroke}",
|
|
45
38
|
'stroke-width': stroke_width,
|
|
46
39
|
'stroke-linecap': 'round',
|
|
47
40
|
'stroke-linejoin': 'round',
|
|
@@ -65,4 +58,23 @@ module SvgIconHelper
|
|
|
65
58
|
render 'icons/outline/bug'
|
|
66
59
|
end
|
|
67
60
|
end
|
|
61
|
+
|
|
62
|
+
def icon_partial(name, type, color, cached:)
|
|
63
|
+
lookup = lambda do
|
|
64
|
+
preferred_path = if I18n.exists?("nav.icons.#{name}")
|
|
65
|
+
"icons/#{I18n.t("nav.icons.#{name}")}"
|
|
66
|
+
else
|
|
67
|
+
"icons/#{type}/#{name}"
|
|
68
|
+
end
|
|
69
|
+
outline_path = "icons/outline/#{name}"
|
|
70
|
+
filled_path = "icons/filled/#{name}"
|
|
71
|
+
|
|
72
|
+
[preferred_path, outline_path, filled_path].collect do |path|
|
|
73
|
+
[preferred_path, color] if lookup_context.exists?(path, [], true)
|
|
74
|
+
end.compact.first
|
|
75
|
+
end
|
|
76
|
+
return lookup.call unless cached
|
|
77
|
+
|
|
78
|
+
Rails.cache.fetch("icon_partial_path:#{name}:#{type}", expires_in: 15.minutes, &lookup)
|
|
79
|
+
end
|
|
68
80
|
end
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
%meta{ name: 'apple-mobile-web-app-capable', content: 'yes'}
|
|
7
7
|
%meta{ name: 'apple-mobile-web-app-status-bar-style', content: 'black'}
|
|
8
8
|
= stylesheet_link_tag 'https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css'
|
|
9
|
-
= stylesheet_link_tag 'https://fonts.googleapis.com/icon?family=Material+Icons'
|
|
10
9
|
%title="#{Rails.env} Status"
|
|
11
10
|
%body{ style: 'background-color: #006064;'}
|
|
12
11
|
%header
|
|
@@ -32,7 +31,6 @@
|
|
|
32
31
|
%td
|
|
33
32
|
%h4.flow-text=key.to_s.titleize
|
|
34
33
|
%td.center
|
|
35
|
-
|
|
36
|
-
= value[:icon_name]
|
|
34
|
+
= svg_icon(value[:icon_name], size: 32, color: value[:icon_color], cached: false)
|
|
37
35
|
%td.center.hide-on-small-only
|
|
38
36
|
%h4.flow-text.large=value[:message]
|
data/lib/web47core/version.rb
CHANGED