foreman_statistics 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/foreman_statistics/api/v2/statistics_controller.rb +8 -6
- data/app/helpers/foreman_statistics/trends_helper.rb +30 -20
- data/app/models/concerns/foreman_statistics/has_many_trends.rb +9 -0
- data/app/models/foreman_statistics/trend.rb +3 -1
- data/app/services/foreman_statistics/statistics/count_hosts.rb +25 -1
- data/app/services/foreman_statistics/statistics/count_puppet_classes.rb +1 -1
- data/app/services/foreman_statistics/statistics.rb +4 -2
- data/app/views/foreman_statistics/layouts/application_react.html.erb +1 -2
- data/app/views/foreman_statistics/trends/_hosts.html.erb +1 -1
- data/app/views/foreman_statistics/trends/index.html.erb +1 -2
- data/app/views/foreman_statistics/trends/show.html.erb +6 -6
- data/app/views/foreman_statistics/trends/welcome.html.erb +1 -1
- data/config/jest.config.js +21 -0
- data/db/migrate/20210523143005_migrate_environments.rb +13 -0
- data/lib/foreman_statistics/engine.rb +17 -13
- data/lib/foreman_statistics/version.rb +1 -1
- data/lib/tasks/foreman_statistics_tasks.rake +3 -2
- data/locale/action_names.rb +5 -0
- data/locale/ca/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/ca/foreman_statistics.edit.po +263 -0
- data/locale/ca/foreman_statistics.po +202 -0
- data/locale/ca/foreman_statistics.po.time_stamp +0 -0
- data/locale/cs_CZ/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/cs_CZ/foreman_statistics.edit.po +267 -0
- data/locale/cs_CZ/foreman_statistics.po +206 -0
- data/locale/cs_CZ/foreman_statistics.po.time_stamp +0 -0
- data/locale/de/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/de/foreman_statistics.edit.po +271 -0
- data/locale/de/foreman_statistics.po +210 -0
- data/locale/de/foreman_statistics.po.time_stamp +0 -0
- data/locale/en/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/en/foreman_statistics.edit.po +258 -0
- data/locale/en/foreman_statistics.po +182 -3
- data/locale/en/foreman_statistics.po.time_stamp +0 -0
- data/locale/en_GB/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/en_GB/foreman_statistics.edit.po +265 -0
- data/locale/en_GB/foreman_statistics.po +204 -0
- data/locale/en_GB/foreman_statistics.po.time_stamp +0 -0
- data/locale/es/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/es/foreman_statistics.edit.po +269 -0
- data/locale/es/foreman_statistics.po +208 -0
- data/locale/es/foreman_statistics.po.time_stamp +0 -0
- data/locale/foreman_statistics.pot +265 -8
- data/locale/fr/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/fr/foreman_statistics.edit.po +269 -0
- data/locale/fr/foreman_statistics.po +208 -0
- data/locale/fr/foreman_statistics.po.time_stamp +0 -0
- data/locale/gemspec.rb +1 -1
- data/locale/gl/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/gl/foreman_statistics.edit.po +263 -0
- data/locale/gl/foreman_statistics.po +202 -0
- data/locale/gl/foreman_statistics.po.time_stamp +0 -0
- data/locale/it/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/it/foreman_statistics.edit.po +265 -0
- data/locale/it/foreman_statistics.po +204 -0
- data/locale/it/foreman_statistics.po.time_stamp +0 -0
- data/locale/ja/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/ja/foreman_statistics.edit.po +266 -0
- data/locale/ja/foreman_statistics.po +205 -0
- data/locale/ja/foreman_statistics.po.time_stamp +0 -0
- data/locale/ko/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/ko/foreman_statistics.edit.po +264 -0
- data/locale/ko/foreman_statistics.po +203 -0
- data/locale/ko/foreman_statistics.po.time_stamp +0 -0
- data/locale/nl_NL/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/nl_NL/foreman_statistics.edit.po +267 -0
- data/locale/nl_NL/foreman_statistics.po +206 -0
- data/locale/nl_NL/foreman_statistics.po.time_stamp +0 -0
- data/locale/pl/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/pl/foreman_statistics.edit.po +266 -0
- data/locale/pl/foreman_statistics.po +205 -0
- data/locale/pl/foreman_statistics.po.time_stamp +0 -0
- data/locale/pt_BR/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/pt_BR/foreman_statistics.edit.po +269 -0
- data/locale/pt_BR/foreman_statistics.po +208 -0
- data/locale/pt_BR/foreman_statistics.po.time_stamp +0 -0
- data/locale/ru/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/ru/foreman_statistics.edit.po +270 -0
- data/locale/ru/foreman_statistics.po +209 -0
- data/locale/ru/foreman_statistics.po.time_stamp +0 -0
- data/locale/sv_SE/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/sv_SE/foreman_statistics.edit.po +265 -0
- data/locale/sv_SE/foreman_statistics.po +204 -0
- data/locale/sv_SE/foreman_statistics.po.time_stamp +0 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/zh_CN/foreman_statistics.edit.po +267 -0
- data/locale/zh_CN/foreman_statistics.po +206 -0
- data/locale/zh_CN/foreman_statistics.po.time_stamp +0 -0
- data/locale/zh_TW/LC_MESSAGES/foreman_statistics.mo +0 -0
- data/locale/zh_TW/foreman_statistics.edit.po +266 -0
- data/locale/zh_TW/foreman_statistics.po +205 -0
- data/locale/zh_TW/foreman_statistics.po.time_stamp +0 -0
- data/package.json +25 -24
- data/test/functional/foreman_statistics/api/v2/statistics_controller_test.rb +1 -1
- data/test/functional/foreman_statistics/api/v2/trends_controller_test.rb +2 -2
- data/test/functional/foreman_statistics/statistics_controller_test.rb +5 -7
- data/test/functional/foreman_statistics/trends_controller_test.rb +2 -9
- data/test/models/foreman_statistics/trend_counter_test.rb +1 -1
- data/test/models/foreman_statistics/trend_test.rb +1 -1
- data/test/{test_plugin_helper.rb → test_statistics_helper.rb} +0 -0
- data/test/unit/foreman_statistics/access_permissions_test.rb +1 -1
- data/test/unit/foreman_statistics/statistics_test.rb +12 -8
- data/test/unit/foreman_statistics_test.rb +1 -1
- data/test/unit/tasks/foreman_statistics_tasks_test.rb +1 -1
- data/webpack/src/Components/StatisticsChartsList/__snapshots__/StatisticsChartsList.test.js.snap +6 -0
- data/webpack/src/Router/StatisticsPage/__tests__/__snapshots__/StatisticsPage.test.js.snap +10 -0
- metadata +83 -94
- data/app/models/concerns/foreman_statistics/compute_resource_decorations.rb +0 -9
- data/app/models/concerns/foreman_statistics/environment_decorations.rb +0 -9
- data/app/models/concerns/foreman_statistics/general_setting_decorations.rb +0 -17
- data/app/models/concerns/foreman_statistics/hostgroup_decorations.rb +0 -9
- data/app/models/concerns/foreman_statistics/model_decorations.rb +0 -9
- data/app/models/concerns/foreman_statistics/operatingsystem_decorations.rb +0 -9
- data/app/models/concerns/foreman_statistics/setting_decorations.rb +0 -9
- data/webpack/__mocks__/foremanReact/API.js +0 -7
- data/webpack/__mocks__/foremanReact/common/HOC.js +0 -24
- data/webpack/__mocks__/foremanReact/common/I18n.js +0 -3
- data/webpack/__mocks__/foremanReact/common/helpers.js +0 -1
- data/webpack/__mocks__/foremanReact/common/urlHelpers.js +0 -1
- data/webpack/__mocks__/foremanReact/components/ChartBox/index.js +0 -2
- data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +0 -2
- data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js +0 -10
- data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +0 -4
- data/webpack/__mocks__/foremanReact/components/Layout/LayoutActions.js +0 -2
- data/webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js +0 -2
- data/webpack/__mocks__/foremanReact/components/common/EmptyState.js +0 -5
- data/webpack/__mocks__/foremanReact/components/common/MessageBox.js +0 -4
- data/webpack/__mocks__/foremanReact/components/common/dates/LongDateTime.js +0 -5
- data/webpack/__mocks__/foremanReact/components/common/dates/RelativeDateTime.js +0 -3
- data/webpack/__mocks__/foremanReact/components/common/table/actionsHelpers/actionTypeCreator.js +0 -7
- data/webpack/__mocks__/foremanReact/components/common/table.js +0 -5
- data/webpack/__mocks__/foremanReact/constants.js +0 -24
- data/webpack/__mocks__/foremanReact/readme.md +0 -11
- data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +0 -8
- data/webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js +0 -10
- data/webpack/__mocks__/foremanReact/routes/common/PageLayout/components/ExportButton/ExportButton.js +0 -5
- data/webpack/__mocks__/foremanReact/routes/common/reducerHOC/withDataReducer.js +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebe6e6bb3aad64251f7d191f3bc2cfcd6adca51bdffcb85901957a9074cff7e3
|
4
|
+
data.tar.gz: d4f425260d58b12cc0888a1b20cea07a4294f1a19cdcd0979ca6a7f2b4927797
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 379d5362616632051dc1e6ac7e9b0919898cf59e5d90ddc4f832876469a6c52ae25a2b4e8aa8f71c409d969b873739342c517b53ad28b286fe6568beeae041af
|
7
|
+
data.tar.gz: 255b4e780195c26a59bdf7fff704df68a6ee0bdea94b0859857d91f5147562490eefa97032724bc14a3c6e2ba862574970ae71360573aa7a422e0c1f8c73d26f
|
@@ -11,10 +11,12 @@ module ForemanStatistics
|
|
11
11
|
|
12
12
|
api :GET, '/statistics/', N_('Get statistics')
|
13
13
|
def index
|
14
|
-
@os_count =
|
15
|
-
@arch_count =
|
16
|
-
|
17
|
-
|
14
|
+
@os_count = Statistics::CountHosts.new(count_by: :operatingsystem)
|
15
|
+
@arch_count = Statistics::CountHosts.new(count_by: :architecture)
|
16
|
+
if defined?(ForemanPuppet)
|
17
|
+
@env_count = Statistics::CountHosts.new(count_by: :environment)
|
18
|
+
@klass_count = Statistics::CountPuppetClasses.new(id: :puppetclass)
|
19
|
+
end
|
18
20
|
@cpu_count = FactValue.authorized(:view_facts).my_facts.count_each 'processorcount'
|
19
21
|
@model_count = FactValue.authorized(:view_facts).my_facts.count_each 'manufacturer'
|
20
22
|
@mem_size = FactValue.authorized(:view_facts).my_facts.mem_average 'memorysize'
|
@@ -23,8 +25,8 @@ module ForemanStatistics
|
|
23
25
|
@swap_free = FactValue.authorized(:view_facts).my_facts.mem_average 'swapfree'
|
24
26
|
@mem_totsize = FactValue.authorized(:view_facts).my_facts.mem_sum 'memorysize'
|
25
27
|
@mem_totfree = FactValue.authorized(:view_facts).my_facts.mem_sum 'memoryfree'
|
26
|
-
render :json => { :os_count => @os_count, :arch_count => @arch_count, :swap_size => @swap_size,
|
27
|
-
:env_count => @env_count, :klass_count => @klass_count, :cpu_count => @cpu_count,
|
28
|
+
render :json => { :os_count => @os_count.calculate, :arch_count => @arch_count.calculate, :swap_size => @swap_size,
|
29
|
+
:env_count => @env_count&.calculate, :klass_count => @klass_count&.calculate, :cpu_count => @cpu_count,
|
28
30
|
:model_count => @model_count, :mem_size => @mem_size, :mem_free => @mem_free,
|
29
31
|
:swap_free => @swap_free, :mem_totsize => @mem_totsize, :mem_totfree => @mem_totfree }
|
30
32
|
end
|
@@ -3,16 +3,18 @@ module ForemanStatistics
|
|
3
3
|
include ::CommonParametersHelper
|
4
4
|
|
5
5
|
def trendable_types
|
6
|
-
options = { _('Environment') => 'Environment', _('Operating system') => 'Operatingsystem',
|
7
|
-
_('Model') => 'Model', _('Facts') => 'FactName', _('Host group') => 'Hostgroup', _('Compute resource') => 'ComputeResource' }
|
8
6
|
existing = ForemanTrend.types.pluck(:trendable_type)
|
7
|
+
options = {}
|
8
|
+
options = { _('Environment') => 'ForemanPuppet::Environment' } if Foreman::Plugin.find(:foreman_puppet)
|
9
|
+
options.merge!({ _('Operating system') => 'Operatingsystem', _('Model') => 'Model', _('Facts') => 'FactName',
|
10
|
+
_('Host group') => 'Hostgroup', _('Compute resource') => 'ComputeResource' })
|
9
11
|
options.delete_if { |_k, v| existing.include?(v) }
|
10
12
|
end
|
11
13
|
|
12
14
|
def trend_days_filter(trend)
|
13
15
|
form_tag trend, :id => 'days_filter', :method => :get, :class => 'form form-inline' do
|
14
16
|
content_tag(:span, (_('Trend of the last %s days.') %
|
15
|
-
select(nil, 'range', 1..Setting[:max_trend], { :selected =>
|
17
|
+
select(nil, 'range', 1..Setting[:max_trend], { :selected => trends_range },
|
16
18
|
{ :onchange => "$('#days_filter').submit();$(this).attr('disabled','disabled');;" })).html_safe)
|
17
19
|
end
|
18
20
|
end
|
@@ -25,28 +27,36 @@ module ForemanStatistics
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
30
|
+
##
|
31
|
+
# Returns data in format:
|
32
|
+
#
|
33
|
+
# [
|
34
|
+
# [time, <time_int>, <time_int>],
|
35
|
+
# [trend_val1, <host_count>, <host_count>],
|
36
|
+
# [trend_val2, 5, 2],
|
37
|
+
# [trend_valx, 213, 3]
|
38
|
+
# ]
|
39
|
+
def trend_chart_data(trend, from = Setting[:max_trend])
|
40
|
+
data = {}
|
41
|
+
names = {}
|
42
|
+
trend.values.preload(:trendable).each { |value| names[value.id] = CGI.escapeHTML(value.to_label) }
|
43
|
+
trend.values.preload(:trend_counters).joins(:trend_counters)
|
44
|
+
.where(['trend_counters.interval_end > ? or trend_counters.interval_end is null', from])
|
45
|
+
.reorder('trend_counters.interval_start')
|
46
|
+
.each do |value|
|
37
47
|
value.trend_counters.each do |counter|
|
38
|
-
|
39
|
-
interval_start = (counter.interval_start || from) > from ? counter.interval_start : from
|
48
|
+
current_data = data[counter.interval_start.to_i] ||= {}
|
40
49
|
next_timestamp = counter.try(:interval_end) || Time.now.utc
|
41
|
-
|
42
|
-
|
43
|
-
data << [next_timestamp.to_i * 1000 - 1, counter.count]
|
50
|
+
next_data = data[next_timestamp.to_i] ||= {}
|
51
|
+
current_data[value.id] = next_data[value.id] = counter.count
|
44
52
|
end
|
45
|
-
|
46
|
-
|
53
|
+
end
|
54
|
+
times = data.keys.sort
|
55
|
+
result = names.map { |id, label| [label].concat(times.map { |time| data[time][id].to_f }) }
|
56
|
+
result.unshift(['time'].concat(times))
|
47
57
|
end
|
48
58
|
|
49
|
-
def
|
59
|
+
def trends_range
|
50
60
|
params['range'].empty? ? Setting[:max_trend] : params['range'].to_i
|
51
61
|
end
|
52
62
|
end
|
@@ -25,7 +25,9 @@ module ForemanStatistics
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.build_trend(trend_params = {})
|
28
|
-
|
28
|
+
params = trend_params.dup
|
29
|
+
params[:trendable_type] = 'ForemanPuppet::Environment' if params[:trendable_type] == 'Environment'
|
30
|
+
params[:trendable_type] == 'FactName' ? FactTrend.new(params) : ForemanTrend.new(params)
|
29
31
|
end
|
30
32
|
|
31
33
|
private
|
@@ -2,7 +2,31 @@ module ForemanStatistics
|
|
2
2
|
module Statistics
|
3
3
|
class CountHosts < Base
|
4
4
|
def calculate
|
5
|
-
Host.authorized(:view_hosts, Host)
|
5
|
+
count_distribution(Host.authorized(:view_hosts, Host), count_by)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def count_distribution(scope, association)
|
11
|
+
case association.to_sym
|
12
|
+
when :environment
|
13
|
+
klass = ForemanPuppet::Environment
|
14
|
+
scope = scope.joins(:puppet)
|
15
|
+
grouping = ForemanPuppet::HostPuppetFacet.arel_table[:environment_id]
|
16
|
+
else
|
17
|
+
klass = association.to_s.camelize.constantize
|
18
|
+
grouping = Host::Managed.arel_table["#{association}_id"]
|
19
|
+
end
|
20
|
+
|
21
|
+
output = []
|
22
|
+
data = scope.reorder('').group(grouping).count
|
23
|
+
associations = klass.find_by(id: data.keys)
|
24
|
+
data.each do |k, v|
|
25
|
+
output << { label: associations.detect { |a| a.id == k }.to_label, data: v } unless v.zero?
|
26
|
+
rescue StandardError
|
27
|
+
logger.info "skipped #{k} as it has has no label"
|
28
|
+
end
|
29
|
+
output
|
6
30
|
end
|
7
31
|
end
|
8
32
|
end
|
@@ -4,17 +4,19 @@ module ForemanStatistics
|
|
4
4
|
charts = [
|
5
5
|
CountHosts.new(:count_by => :operatingsystem, :title => 'OS Distribution', :search => 'os_title=~VAL~', :organization_id => org_id, :location_id => loc_id),
|
6
6
|
CountHosts.new(:count_by => :architecture, :title => _('Architecture Distribution'), :search => 'facts.architecture=~VAL~', :organization_id => org_id, :location_id => loc_id),
|
7
|
-
CountHosts.new(:count_by => :environment, :title => _('Environment Distribution'), :search => 'environment=~VAL~', :organization_id => org_id, :location_id => loc_id),
|
8
7
|
CountHosts.new(:count_by => :hostgroup, :title => _('Host Group Distribution'), :search => 'hostgroup_title=~VAL~', :organization_id => org_id, :location_id => loc_id),
|
9
8
|
CountHosts.new(:count_by => :compute_resource, :title => _('Compute Resource Distribution'), :search => 'compute_resource=~VAL~', :organization_id => org_id, :location_id => loc_id),
|
10
9
|
CountFacts.new(:count_by => :processorcount, :unit => Nn_('%s core', '%s cores'), :title => _('Number of CPUs'), :search => 'facts.processorcount=~VAL1~', :organization_id => org_id, :location_id => loc_id),
|
11
10
|
CountFacts.new(:count_by => :manufacturer, :title => _('Hardware'), :search => 'facts.manufacturer~~VAL~', :organization_id => org_id, :location_id => loc_id),
|
12
11
|
CountNumericalFactPair.new(:count_by => :memory, :title => _('Average Memory Usage'), :organization_id => org_id, :location_id => loc_id),
|
13
12
|
CountNumericalFactPair.new(:count_by => :swap, :title => _('Average Swap Usage'), :organization_id => org_id, :location_id => loc_id),
|
14
|
-
CountPuppetClasses.new(:id => :puppetclass, :title => _('Class Distribution'), :search => 'class=~VAL1~', :organization_id => org_id, :location_id => loc_id),
|
15
13
|
CountHosts.new(:count_by => :location, :title => _('Location Distribution'), :search => 'location=~VAL~', :organization_id => org_id, :location_id => loc_id),
|
16
14
|
CountHosts.new(:count_by => :organization, :title => _('Organization Distribution'), :search => 'organization=~VAL~', :organization_id => org_id, :location_id => loc_id)
|
17
15
|
]
|
16
|
+
if defined?(ForemanPuppet)
|
17
|
+
charts << CountHosts.new(:count_by => :environment, :title => _('Environment Distribution'), :search => 'environment=~VAL~', :organization_id => org_id, :location_id => loc_id)
|
18
|
+
charts << CountPuppetClasses.new(:id => :puppetclass, :title => _('Class Distribution'), :search => 'class=~VAL1~', :organization_id => org_id, :location_id => loc_id)
|
19
|
+
end
|
18
20
|
charts
|
19
21
|
end
|
20
22
|
end
|
@@ -10,7 +10,6 @@
|
|
10
10
|
<%= notifications %>
|
11
11
|
<div id="organization-id" data-id="<%= Organization.current.id if Organization.current %>" ></div>
|
12
12
|
<div id="user-id" data-id="<%= User.current.id if User.current %>" ></div>
|
13
|
-
|
13
|
+
<%= react_component('ForemanStatistics') %>
|
14
14
|
<% end %>
|
15
15
|
<%= render file: "layouts/base" %>
|
16
|
-
<%= mount_react_component('ForemanStatistics', '#foremanStatisticsRoot') %>
|
@@ -1,6 +1,5 @@
|
|
1
|
-
<%= javascript 'charts' %>
|
2
1
|
<% title _("Trends") %>
|
3
|
-
<% title_actions new_link(_("Add Trend Counter")),
|
2
|
+
<% title_actions new_link(_("Add Trend Counter"), engine: foreman_statistics),
|
4
3
|
documentation_button('4.1.3Trends') %>
|
5
4
|
|
6
5
|
<table class="<%= table_css_classes 'table-fixed' %>">
|
@@ -1,14 +1,14 @@
|
|
1
|
-
<%= javascript 'charts' %>
|
2
1
|
<% title(_("Trends for %s") % trend_title(@trend)) %>
|
3
2
|
<% content_for(:search_bar) { trend_days_filter(@trend) } %>
|
4
3
|
<div class="row">
|
5
|
-
<div class="
|
6
|
-
<
|
7
|
-
|
8
|
-
|
4
|
+
<div class="col-md-12">
|
5
|
+
<div class="stats-well trends-chart">
|
6
|
+
<h4 class="ca"><%= "#{trend_title(@trend)}" %></h4>
|
7
|
+
<h6 class="ca"><%= n_("last %s day", "last %s days", trends_range) % trends_range %></h6>
|
8
|
+
<%= react_component('AreaChart', yAxisLabel: _('Number of Hosts'), data: trend_chart_data(@trend, trends_range.days.ago), searchUrl: trend_path(id: '~VAL~')) %>
|
9
|
+
</div>
|
9
10
|
</div>
|
10
11
|
</div>
|
11
|
-
<div id="legendContainer"></div>
|
12
12
|
<table class="table">
|
13
13
|
<% unless @trend.fact_value.nil? %>
|
14
14
|
<thead>
|
@@ -7,6 +7,6 @@
|
|
7
7
|
<p><%= _("Trends in Foreman allow you to track changes in your infrastructure over time. It allows you to track both Foreman related information and to any fact. The Trend pages give a graph of how the number of hosts with that value have changed over time, and list the current hosts.") %></p>
|
8
8
|
<p><%= link_to _('Learn more about this in the documentation.'), documentation_url("4.1.3Trends")%></p>
|
9
9
|
<div class="blank-slate-pf-main-action">
|
10
|
-
<%= new_link(_("Add Trend Counter"), :class => 'btn-lg') %>
|
10
|
+
<%= new_link(_("Add Trend Counter"), { engine: foreman_statistics }, :class => 'btn-lg') %>
|
11
11
|
</div>
|
12
12
|
</div>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
const tfmConfig = require('@theforeman/test/src/pluginConfig');
|
2
|
+
|
3
|
+
// Find where foreman is located
|
4
|
+
const { foremanRelativePath, foremanLocation } = require('@theforeman/find-foreman');
|
5
|
+
const foremanReactRelative = 'webpack/assets/javascripts/react_app';
|
6
|
+
const foremanFull = foremanLocation();
|
7
|
+
const foremanReactFull = foremanRelativePath(foremanReactRelative);
|
8
|
+
|
9
|
+
// Find correct path to foremanReact so we do not have to mock it in tests
|
10
|
+
tfmConfig.moduleNameMapper['^foremanReact(.*)$'] = `${foremanReactFull}/$1`;
|
11
|
+
|
12
|
+
// Do not use default resolver
|
13
|
+
tfmConfig.resolver = null;
|
14
|
+
// Specify module dirs instead
|
15
|
+
tfmConfig.moduleDirectories = [
|
16
|
+
`${foremanFull}/node_modules`,
|
17
|
+
`${foremanFull}/node_modules/@theforeman/vendor-core/node_modules`,
|
18
|
+
'node_modules',
|
19
|
+
]
|
20
|
+
|
21
|
+
module.exports = tfmConfig;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class MigrateEnvironments < ActiveRecord::Migration[6.0]
|
2
|
+
class FakeTrend < ApplicationRecord
|
3
|
+
self.table_name = 'trends'
|
4
|
+
end
|
5
|
+
|
6
|
+
def up
|
7
|
+
FakeTrend.where(trendable_type: 'Environment').update_all(trendable_type: 'ForemanPuppet::Environment')
|
8
|
+
end
|
9
|
+
|
10
|
+
def down
|
11
|
+
FakeTrend.where(trendable_type: 'ForemanPuppet::Environment').update_all(trendable_type: 'Environment')
|
12
|
+
end
|
13
|
+
end
|
@@ -19,7 +19,7 @@ module ForemanStatistics
|
|
19
19
|
|
20
20
|
initializer 'foreman_statistics.register_plugin', :before => :finisher_hook do |_app|
|
21
21
|
Foreman::Plugin.register :foreman_statistics do
|
22
|
-
requires_foreman '>=
|
22
|
+
requires_foreman '>= 3.1.0'
|
23
23
|
|
24
24
|
# ==== Core cleanups
|
25
25
|
# TODO: clean up when this gets removed from core
|
@@ -70,6 +70,17 @@ module ForemanStatistics
|
|
70
70
|
:engine => ForemanStatistics::Engine, :parent => :monitor_menu, :after => :trends,
|
71
71
|
:url_hash => { :controller => 'foreman_statistics/statistics', :action => :index }
|
72
72
|
}
|
73
|
+
|
74
|
+
settings do
|
75
|
+
category(:general) do
|
76
|
+
setting('max_trend',
|
77
|
+
type: :integer,
|
78
|
+
default: 30,
|
79
|
+
description: N_('Max days for Trends graphs'),
|
80
|
+
full_name: N_('Max trends'),
|
81
|
+
validate: { numericality: { greater_than: 0 } })
|
82
|
+
end
|
83
|
+
end
|
73
84
|
end
|
74
85
|
end
|
75
86
|
|
@@ -87,18 +98,11 @@ module ForemanStatistics
|
|
87
98
|
|
88
99
|
# Include concerns in this config.to_prepare block
|
89
100
|
config.to_prepare do
|
90
|
-
::ComputeResource.include ForemanStatistics::
|
91
|
-
::
|
92
|
-
::
|
93
|
-
::
|
94
|
-
::
|
95
|
-
::Setting.include ForemanStatistics::SettingDecorations
|
96
|
-
::Setting::General.prepend ForemanStatistics::GeneralSettingDecorations
|
97
|
-
begin
|
98
|
-
::Setting::General.load_defaults
|
99
|
-
rescue ActiveRecord::NoDatabaseError => e
|
100
|
-
Rails.logger.warn e
|
101
|
-
end
|
101
|
+
::ComputeResource.include ForemanStatistics::HasManyTrends
|
102
|
+
::Hostgroup.include ForemanStatistics::HasManyTrends
|
103
|
+
::Model.include ForemanStatistics::HasManyTrends
|
104
|
+
::Operatingsystem.include ForemanStatistics::HasManyTrends
|
105
|
+
'ForemanPuppet::Environment'.safe_constantize&.include ForemanStatistics::HasManyTrends
|
102
106
|
end
|
103
107
|
|
104
108
|
rake_tasks do
|
@@ -45,8 +45,9 @@ end
|
|
45
45
|
namespace :test do
|
46
46
|
desc 'Test ForemanStatistics'
|
47
47
|
Rake::TestTask.new(:foreman_statistics) do |t|
|
48
|
-
test_dir = File.
|
49
|
-
t.libs <<
|
48
|
+
test_dir = File.expand_path('../../test', __dir__)
|
49
|
+
t.libs << 'test'
|
50
|
+
t.libs << test_dir
|
50
51
|
t.pattern = "#{test_dir}/**/*_test.rb"
|
51
52
|
t.verbose = true
|
52
53
|
t.warning = false
|
Binary file
|
@@ -0,0 +1,263 @@
|
|
1
|
+
# SOME DESCRIPTIVE TITLE.
|
2
|
+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
3
|
+
# This file is distributed under the same license as the foreman_statistics package.
|
4
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
5
|
+
#
|
6
|
+
# Translators:
|
7
|
+
# Robert Antoni Buj Gelonch <rbuj@fedoraproject.org>, 2021
|
8
|
+
#
|
9
|
+
msgid ""
|
10
|
+
msgstr ""
|
11
|
+
"Project-Id-Version: foreman_statistics 1.1.1\n"
|
12
|
+
"Report-Msgid-Bugs-To: \n"
|
13
|
+
"POT-Creation-Date: 2021-02-04 02:22+0100\n"
|
14
|
+
"PO-Revision-Date: 2021-02-03 22:59+0000\n"
|
15
|
+
"Last-Translator: Robert Antoni Buj Gelonch <rbuj@fedoraproject.org>, 2021\n"
|
16
|
+
"Language-Team: Catalan (https://www.transifex.com/foreman/teams/114/ca/)\n"
|
17
|
+
"MIME-Version: 1.0\n"
|
18
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
19
|
+
"Content-Transfer-Encoding: 8bit\n"
|
20
|
+
"Language: ca\n"
|
21
|
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
22
|
+
|
23
|
+
#: ../app/controllers/foreman_statistics/api/v2/statistics_controller.rb:12
|
24
|
+
msgid "Get statistics"
|
25
|
+
msgstr "Obtén les estadístiques"
|
26
|
+
|
27
|
+
#: ../app/controllers/foreman_statistics/api/v2/trends_controller.rb:20
|
28
|
+
msgid "List of trends counters"
|
29
|
+
msgstr ""
|
30
|
+
|
31
|
+
#: ../app/controllers/foreman_statistics/api/v2/trends_controller.rb:25
|
32
|
+
msgid "Show a trend"
|
33
|
+
msgstr ""
|
34
|
+
|
35
|
+
#: ../app/controllers/foreman_statistics/api/v2/trends_controller.rb:29
|
36
|
+
msgid "Create a trend counter"
|
37
|
+
msgstr ""
|
38
|
+
|
39
|
+
#: ../app/controllers/foreman_statistics/api/v2/trends_controller.rb:42
|
40
|
+
msgid "Delete a trend counter"
|
41
|
+
msgstr ""
|
42
|
+
|
43
|
+
#: ../app/helpers/foreman_statistics/trends_helper.rb:6
|
44
|
+
msgid "Environment"
|
45
|
+
msgstr "Entorn"
|
46
|
+
|
47
|
+
#: ../app/helpers/foreman_statistics/trends_helper.rb:6
|
48
|
+
msgid "Operating system"
|
49
|
+
msgstr "Sistema operatiu"
|
50
|
+
|
51
|
+
#: ../app/helpers/foreman_statistics/trends_helper.rb:7
|
52
|
+
msgid "Model"
|
53
|
+
msgstr "Model"
|
54
|
+
|
55
|
+
#: ../app/helpers/foreman_statistics/trends_helper.rb:7
|
56
|
+
msgid "Facts"
|
57
|
+
msgstr "Objectes d'interès"
|
58
|
+
|
59
|
+
#: ../app/helpers/foreman_statistics/trends_helper.rb:7
|
60
|
+
msgid "Host group"
|
61
|
+
msgstr "Grup d'amfitrions"
|
62
|
+
|
63
|
+
#: ../app/helpers/foreman_statistics/trends_helper.rb:7
|
64
|
+
msgid "Compute resource"
|
65
|
+
msgstr "Recurs computacional"
|
66
|
+
|
67
|
+
#: ../app/helpers/foreman_statistics/trends_helper.rb:14
|
68
|
+
msgid "Trend of the last %s days."
|
69
|
+
msgstr ""
|
70
|
+
|
71
|
+
#: ../app/jobs/foreman_statistics/trend_counter_job.rb:20
|
72
|
+
msgid "Trend Counter Job"
|
73
|
+
msgstr ""
|
74
|
+
|
75
|
+
#: ../app/models/concerns/foreman_statistics/general_setting_decorations.rb:12
|
76
|
+
msgid "Max days for Trends graphs"
|
77
|
+
msgstr "Nombre màxim de dies per als gràfics de les tendències"
|
78
|
+
|
79
|
+
#: ../app/models/concerns/foreman_statistics/general_setting_decorations.rb:12
|
80
|
+
msgid "Max trends"
|
81
|
+
msgstr "Tendències màx."
|
82
|
+
|
83
|
+
#: ../app/services/foreman_statistics/statistics.rb:6
|
84
|
+
msgid "Architecture Distribution"
|
85
|
+
msgstr "Distribució de l'arquitectura"
|
86
|
+
|
87
|
+
#: ../app/services/foreman_statistics/statistics.rb:7
|
88
|
+
msgid "Environment Distribution"
|
89
|
+
msgstr ""
|
90
|
+
|
91
|
+
#: ../app/services/foreman_statistics/statistics.rb:8
|
92
|
+
msgid "Host Group Distribution"
|
93
|
+
msgstr ""
|
94
|
+
|
95
|
+
#: ../app/services/foreman_statistics/statistics.rb:9
|
96
|
+
msgid "Compute Resource Distribution"
|
97
|
+
msgstr ""
|
98
|
+
|
99
|
+
#: ../app/services/foreman_statistics/statistics.rb:10
|
100
|
+
msgid "Number of CPUs"
|
101
|
+
msgstr "Nombre de CPU"
|
102
|
+
|
103
|
+
#: ../app/services/foreman_statistics/statistics.rb:11
|
104
|
+
msgid "Hardware"
|
105
|
+
msgstr "Maquinari"
|
106
|
+
|
107
|
+
#: ../app/services/foreman_statistics/statistics.rb:12
|
108
|
+
msgid "Average Memory Usage"
|
109
|
+
msgstr ""
|
110
|
+
|
111
|
+
#: ../app/services/foreman_statistics/statistics.rb:13
|
112
|
+
msgid "Average Swap Usage"
|
113
|
+
msgstr ""
|
114
|
+
|
115
|
+
#: ../app/services/foreman_statistics/statistics.rb:14
|
116
|
+
msgid "Class Distribution"
|
117
|
+
msgstr "Distribució de la classe"
|
118
|
+
|
119
|
+
#: ../app/services/foreman_statistics/statistics.rb:15
|
120
|
+
msgid "Location Distribution"
|
121
|
+
msgstr ""
|
122
|
+
|
123
|
+
#: ../app/services/foreman_statistics/statistics.rb:16
|
124
|
+
msgid "Organization Distribution"
|
125
|
+
msgstr ""
|
126
|
+
|
127
|
+
#: ../app/services/foreman_statistics/statistics/count_numerical_fact_pair.rb:22
|
128
|
+
msgid "free memory"
|
129
|
+
msgstr "memòria lliure"
|
130
|
+
|
131
|
+
#: ../app/services/foreman_statistics/statistics/count_numerical_fact_pair.rb:26
|
132
|
+
msgid "used memory"
|
133
|
+
msgstr "memòria utilitzada"
|
134
|
+
|
135
|
+
#: ../app/views/foreman_statistics/trends/_empty_data.html.erb:1 ../app/views/foreman_statistics/trends/show.html.erb:2
|
136
|
+
msgid "Trends for %s"
|
137
|
+
msgstr "Tendències per %s"
|
138
|
+
|
139
|
+
#: ../app/views/foreman_statistics/trends/_empty_data.html.erb:4
|
140
|
+
msgid "No data for this trend."
|
141
|
+
msgstr "No hi ha dades per aquesta tendència."
|
142
|
+
|
143
|
+
#: ../app/views/foreman_statistics/trends/_form.html.erb:4
|
144
|
+
msgid "Please Select"
|
145
|
+
msgstr "Si us plau, seleccioneu"
|
146
|
+
|
147
|
+
#: ../app/views/foreman_statistics/trends/_hosts.html.erb:7
|
148
|
+
msgid "Show Host"
|
149
|
+
msgstr "Mosta l'amfitrió"
|
150
|
+
|
151
|
+
#: ../app/views/foreman_statistics/trends/edit.html.erb:1
|
152
|
+
msgid "Edit Trend %s"
|
153
|
+
msgstr "Edita la tendència %s"
|
154
|
+
|
155
|
+
#: ../app/views/foreman_statistics/trends/edit.html.erb:8
|
156
|
+
msgid "Fact Name"
|
157
|
+
msgstr "Nom de l'objecte d'interès"
|
158
|
+
|
159
|
+
#: ../app/views/foreman_statistics/trends/edit.html.erb:9 ../app/views/foreman_statistics/trends/edit.html.erb:30
|
160
|
+
msgid "Display Name"
|
161
|
+
msgstr ""
|
162
|
+
|
163
|
+
#: ../app/views/foreman_statistics/trends/edit.html.erb:43
|
164
|
+
msgid "Cancel"
|
165
|
+
msgstr "Cancel·la"
|
166
|
+
|
167
|
+
#: ../app/views/foreman_statistics/trends/edit.html.erb:44
|
168
|
+
msgid "Submit"
|
169
|
+
msgstr "Envia"
|
170
|
+
|
171
|
+
#: ../app/views/foreman_statistics/trends/index.html.erb:2 ../app/views/foreman_statistics/trends/welcome.html.erb:1 ../app/views/foreman_statistics/trends/welcome.html.erb:6 ../lib/foreman_statistics/engine.rb:63
|
172
|
+
msgid "Trends"
|
173
|
+
msgstr "Tendències"
|
174
|
+
|
175
|
+
#: ../app/views/foreman_statistics/trends/index.html.erb:3 ../app/views/foreman_statistics/trends/welcome.html.erb:10
|
176
|
+
msgid "Add Trend Counter"
|
177
|
+
msgstr ""
|
178
|
+
|
179
|
+
#: ../app/views/foreman_statistics/trends/index.html.erb:9
|
180
|
+
msgid "Name"
|
181
|
+
msgstr "Nom"
|
182
|
+
|
183
|
+
#: ../app/views/foreman_statistics/trends/index.html.erb:10
|
184
|
+
msgid "Action"
|
185
|
+
msgstr "Acció"
|
186
|
+
|
187
|
+
#: ../app/views/foreman_statistics/trends/index.html.erb:16
|
188
|
+
msgid "Show Trends"
|
189
|
+
msgstr "Mostra les tendències"
|
190
|
+
|
191
|
+
#: ../app/views/foreman_statistics/trends/index.html.erb:19
|
192
|
+
msgid "Edit"
|
193
|
+
msgstr "Edita"
|
194
|
+
|
195
|
+
#: ../app/views/foreman_statistics/trends/index.html.erb:20
|
196
|
+
msgid "Delete all the trend history for %s?"
|
197
|
+
msgstr ""
|
198
|
+
|
199
|
+
#: ../app/views/foreman_statistics/trends/index.html.erb:28
|
200
|
+
msgid "Last update:"
|
201
|
+
msgstr ""
|
202
|
+
|
203
|
+
#: ../app/views/foreman_statistics/trends/new.html.erb:1
|
204
|
+
msgid "Create Trend"
|
205
|
+
msgstr "Crea una tendència"
|
206
|
+
|
207
|
+
#: ../app/views/foreman_statistics/trends/show.html.erb:7
|
208
|
+
msgid "last %s day"
|
209
|
+
msgid_plural "last %s days"
|
210
|
+
msgstr[0] ""
|
211
|
+
msgstr[1] ""
|
212
|
+
|
213
|
+
#: ../app/views/foreman_statistics/trends/show.html.erb:8
|
214
|
+
msgid "Number of Hosts"
|
215
|
+
msgstr "Nombre d'amfitrions"
|
216
|
+
|
217
|
+
#: ../app/views/foreman_statistics/trends/show.html.erb:16
|
218
|
+
msgid "Hosts"
|
219
|
+
msgstr "Amfitrions"
|
220
|
+
|
221
|
+
#: ../app/views/foreman_statistics/trends/welcome.html.erb:7
|
222
|
+
msgid "Trends in Foreman allow you to track changes in your infrastructure over time. It allows you to track both Foreman related information and to any fact. The Trend pages give a graph of how the number of hosts with that value have changed over time, and list the current hosts."
|
223
|
+
msgstr ""
|
224
|
+
|
225
|
+
#: ../app/views/foreman_statistics/trends/welcome.html.erb:8
|
226
|
+
msgid "Learn more about this in the documentation."
|
227
|
+
msgstr "Obteniu més informació sobre això a la documentació."
|
228
|
+
|
229
|
+
#: ../lib/foreman_statistics/engine.rb:69 ../webpack/src/Router/StatisticsPage/StatisticsPage.js:8
|
230
|
+
msgid "Statistics"
|
231
|
+
msgstr "Estadístiques"
|
232
|
+
|
233
|
+
#: ../webpack/src/Components/StatisticsChartsList/index.js:14
|
234
|
+
msgid "No data available"
|
235
|
+
msgstr "Sense dades disponibles"
|
236
|
+
|
237
|
+
#: ../webpack/src/Components/StatisticsChartsList/index.js:15
|
238
|
+
msgid "Expand the chart"
|
239
|
+
msgstr "Expandeix la gràfica"
|
240
|
+
|
241
|
+
#: ../webpack/src/Router/StatisticsPage/Statistics/Statistics.js:13
|
242
|
+
msgid "No Charts To Load"
|
243
|
+
msgstr ""
|
244
|
+
|
245
|
+
#: action_names.rb:2
|
246
|
+
msgid "Action with sub plans"
|
247
|
+
msgstr ""
|
248
|
+
|
249
|
+
#: action_names.rb:3
|
250
|
+
msgid "Import facts"
|
251
|
+
msgstr ""
|
252
|
+
|
253
|
+
#: action_names.rb:4
|
254
|
+
msgid "Import Puppet classes"
|
255
|
+
msgstr ""
|
256
|
+
|
257
|
+
#: action_names.rb:5
|
258
|
+
msgid "Remote action:"
|
259
|
+
msgstr ""
|
260
|
+
|
261
|
+
#: gemspec.rb:2
|
262
|
+
msgid "Statistics and Trends for Foreman gives users overview of their infrastructure."
|
263
|
+
msgstr ""
|