foreman_statistics 0.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/foreman_statistics/trends_helper.rb +30 -20
  3. data/app/jobs/foreman_statistics/trend_counter_job.rb +23 -0
  4. data/app/models/concerns/foreman_statistics/has_many_trends.rb +9 -0
  5. data/app/models/foreman_statistics/trend.rb +3 -1
  6. data/app/views/foreman_statistics/layouts/application_react.html.erb +1 -2
  7. data/app/views/foreman_statistics/trends/_empty_data.html.erb +0 -1
  8. data/app/views/foreman_statistics/trends/_hosts.html.erb +1 -1
  9. data/app/views/foreman_statistics/trends/index.html.erb +3 -13
  10. data/app/views/foreman_statistics/trends/show.html.erb +6 -6
  11. data/app/views/foreman_statistics/trends/welcome.html.erb +1 -1
  12. data/config/jest.config.js +21 -0
  13. data/db/migrate/20210523143005_migrate_environments.rb +13 -0
  14. data/lib/foreman_statistics/engine.rb +12 -5
  15. data/lib/foreman_statistics/version.rb +1 -1
  16. data/lib/tasks/foreman_statistics_tasks.rake +3 -2
  17. data/locale/action_names.rb +5 -0
  18. data/locale/ca/LC_MESSAGES/foreman_statistics.mo +0 -0
  19. data/locale/ca/foreman_statistics.edit.po +263 -0
  20. data/locale/ca/foreman_statistics.po +202 -0
  21. data/locale/ca/foreman_statistics.po.time_stamp +0 -0
  22. data/locale/cs_CZ/LC_MESSAGES/foreman_statistics.mo +0 -0
  23. data/locale/cs_CZ/foreman_statistics.edit.po +267 -0
  24. data/locale/cs_CZ/foreman_statistics.po +206 -0
  25. data/locale/cs_CZ/foreman_statistics.po.time_stamp +0 -0
  26. data/locale/de/LC_MESSAGES/foreman_statistics.mo +0 -0
  27. data/locale/de/foreman_statistics.edit.po +271 -0
  28. data/locale/de/foreman_statistics.po +210 -0
  29. data/locale/de/foreman_statistics.po.time_stamp +0 -0
  30. data/locale/en/LC_MESSAGES/foreman_statistics.mo +0 -0
  31. data/locale/en/foreman_statistics.edit.po +258 -0
  32. data/locale/en/foreman_statistics.po +182 -3
  33. data/locale/en/foreman_statistics.po.time_stamp +0 -0
  34. data/locale/en_GB/LC_MESSAGES/foreman_statistics.mo +0 -0
  35. data/locale/en_GB/foreman_statistics.edit.po +265 -0
  36. data/locale/en_GB/foreman_statistics.po +204 -0
  37. data/locale/en_GB/foreman_statistics.po.time_stamp +0 -0
  38. data/locale/es/LC_MESSAGES/foreman_statistics.mo +0 -0
  39. data/locale/es/foreman_statistics.edit.po +269 -0
  40. data/locale/es/foreman_statistics.po +208 -0
  41. data/locale/es/foreman_statistics.po.time_stamp +0 -0
  42. data/locale/foreman_statistics.pot +265 -8
  43. data/locale/fr/LC_MESSAGES/foreman_statistics.mo +0 -0
  44. data/locale/fr/foreman_statistics.edit.po +269 -0
  45. data/locale/fr/foreman_statistics.po +208 -0
  46. data/locale/fr/foreman_statistics.po.time_stamp +0 -0
  47. data/locale/gemspec.rb +1 -1
  48. data/locale/gl/LC_MESSAGES/foreman_statistics.mo +0 -0
  49. data/locale/gl/foreman_statistics.edit.po +263 -0
  50. data/locale/gl/foreman_statistics.po +202 -0
  51. data/locale/gl/foreman_statistics.po.time_stamp +0 -0
  52. data/locale/it/LC_MESSAGES/foreman_statistics.mo +0 -0
  53. data/locale/it/foreman_statistics.edit.po +265 -0
  54. data/locale/it/foreman_statistics.po +204 -0
  55. data/locale/it/foreman_statistics.po.time_stamp +0 -0
  56. data/locale/ja/LC_MESSAGES/foreman_statistics.mo +0 -0
  57. data/locale/ja/foreman_statistics.edit.po +266 -0
  58. data/locale/ja/foreman_statistics.po +205 -0
  59. data/locale/ja/foreman_statistics.po.time_stamp +0 -0
  60. data/locale/ko/LC_MESSAGES/foreman_statistics.mo +0 -0
  61. data/locale/ko/foreman_statistics.edit.po +264 -0
  62. data/locale/ko/foreman_statistics.po +203 -0
  63. data/locale/ko/foreman_statistics.po.time_stamp +0 -0
  64. data/locale/nl_NL/LC_MESSAGES/foreman_statistics.mo +0 -0
  65. data/locale/nl_NL/foreman_statistics.edit.po +267 -0
  66. data/locale/nl_NL/foreman_statistics.po +206 -0
  67. data/locale/nl_NL/foreman_statistics.po.time_stamp +0 -0
  68. data/locale/pl/LC_MESSAGES/foreman_statistics.mo +0 -0
  69. data/locale/pl/foreman_statistics.edit.po +266 -0
  70. data/locale/pl/foreman_statistics.po +205 -0
  71. data/locale/pl/foreman_statistics.po.time_stamp +0 -0
  72. data/locale/pt_BR/LC_MESSAGES/foreman_statistics.mo +0 -0
  73. data/locale/pt_BR/foreman_statistics.edit.po +269 -0
  74. data/locale/pt_BR/foreman_statistics.po +208 -0
  75. data/locale/pt_BR/foreman_statistics.po.time_stamp +0 -0
  76. data/locale/ru/LC_MESSAGES/foreman_statistics.mo +0 -0
  77. data/locale/ru/foreman_statistics.edit.po +270 -0
  78. data/locale/ru/foreman_statistics.po +209 -0
  79. data/locale/ru/foreman_statistics.po.time_stamp +0 -0
  80. data/locale/sv_SE/LC_MESSAGES/foreman_statistics.mo +0 -0
  81. data/locale/sv_SE/foreman_statistics.edit.po +265 -0
  82. data/locale/sv_SE/foreman_statistics.po +204 -0
  83. data/locale/sv_SE/foreman_statistics.po.time_stamp +0 -0
  84. data/locale/zh_CN/LC_MESSAGES/foreman_statistics.mo +0 -0
  85. data/locale/zh_CN/foreman_statistics.edit.po +267 -0
  86. data/locale/zh_CN/foreman_statistics.po +206 -0
  87. data/locale/zh_CN/foreman_statistics.po.time_stamp +0 -0
  88. data/locale/zh_TW/LC_MESSAGES/foreman_statistics.mo +0 -0
  89. data/locale/zh_TW/foreman_statistics.edit.po +266 -0
  90. data/locale/zh_TW/foreman_statistics.po +205 -0
  91. data/locale/zh_TW/foreman_statistics.po.time_stamp +0 -0
  92. data/package.json +25 -24
  93. data/test/functional/foreman_statistics/api/v2/statistics_controller_test.rb +1 -1
  94. data/test/functional/foreman_statistics/api/v2/trends_controller_test.rb +2 -2
  95. data/test/functional/foreman_statistics/statistics_controller_test.rb +5 -7
  96. data/test/functional/foreman_statistics/trends_controller_test.rb +2 -8
  97. data/test/models/foreman_statistics/trend_counter_test.rb +1 -1
  98. data/test/models/foreman_statistics/trend_test.rb +1 -1
  99. data/test/{test_plugin_helper.rb → test_statistics_helper.rb} +0 -0
  100. data/test/unit/foreman_statistics/access_permissions_test.rb +1 -1
  101. data/test/unit/foreman_statistics/statistics_test.rb +1 -1
  102. data/test/unit/foreman_statistics_test.rb +1 -1
  103. data/test/unit/tasks/foreman_statistics_tasks_test.rb +1 -1
  104. data/webpack/src/Components/StatisticsChartsList/__snapshots__/StatisticsChartsList.test.js.snap +6 -0
  105. data/webpack/src/Router/StatisticsPage/StatisticsPageSelectors.js +2 -1
  106. data/webpack/src/Router/StatisticsPage/__tests__/StatisticsPageSelectors.test.js +4 -2
  107. data/webpack/src/Router/StatisticsPage/__tests__/__snapshots__/StatisticsPage.test.js.snap +10 -0
  108. data/webpack/src/reducers.js +4 -2
  109. metadata +81 -89
  110. data/app/models/concerns/foreman_statistics/compute_resource_decorations.rb +0 -9
  111. data/app/models/concerns/foreman_statistics/environment_decorations.rb +0 -9
  112. data/app/models/concerns/foreman_statistics/hostgroup_decorations.rb +0 -9
  113. data/app/models/concerns/foreman_statistics/model_decorations.rb +0 -9
  114. data/app/models/concerns/foreman_statistics/operatingsystem_decorations.rb +0 -9
  115. data/webpack/__mocks__/foremanReact/API.js +0 -7
  116. data/webpack/__mocks__/foremanReact/common/HOC.js +0 -24
  117. data/webpack/__mocks__/foremanReact/common/I18n.js +0 -3
  118. data/webpack/__mocks__/foremanReact/common/helpers.js +0 -1
  119. data/webpack/__mocks__/foremanReact/common/urlHelpers.js +0 -1
  120. data/webpack/__mocks__/foremanReact/components/ChartBox/index.js +0 -2
  121. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +0 -2
  122. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js +0 -10
  123. data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +0 -4
  124. data/webpack/__mocks__/foremanReact/components/Layout/LayoutActions.js +0 -2
  125. data/webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js +0 -2
  126. data/webpack/__mocks__/foremanReact/components/common/EmptyState.js +0 -5
  127. data/webpack/__mocks__/foremanReact/components/common/MessageBox.js +0 -4
  128. data/webpack/__mocks__/foremanReact/components/common/dates/LongDateTime.js +0 -5
  129. data/webpack/__mocks__/foremanReact/components/common/dates/RelativeDateTime.js +0 -3
  130. data/webpack/__mocks__/foremanReact/components/common/table.js +0 -5
  131. data/webpack/__mocks__/foremanReact/components/common/table/actionsHelpers/actionTypeCreator.js +0 -7
  132. data/webpack/__mocks__/foremanReact/constants.js +0 -24
  133. data/webpack/__mocks__/foremanReact/readme.md +0 -11
  134. data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +0 -8
  135. data/webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js +0 -10
  136. data/webpack/__mocks__/foremanReact/routes/common/PageLayout/components/ExportButton/ExportButton.js +0 -5
  137. 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: 04f2e0c985cab00b83985bacac5d7bd98c093137c29ee2079ab0efa90ed55adc
4
- data.tar.gz: a0f5a576e915cfdc64adb3fa4c6558a44aa92c8aa5cc081d3e007f3e06f6879b
3
+ metadata.gz: b95468f6ef7bf5f7cc61869bd23e46bf7a64331aa2d162962178b7c186df6f8a
4
+ data.tar.gz: 62baddb120c01c609e1e8a62d30e785a8ee12c3dcdbe4591468822d1fe464d6e
5
5
  SHA512:
6
- metadata.gz: fa78c311e2d59333e2fb2b43aaaf998805c358919450e5f8e82fdca7d38a725b16b3bbf8373e88d07784fc43c0564bc73d521cc47b20a9268f0c004bd1042055
7
- data.tar.gz: e6d653c21cbb859740aaab5ed524d583ef6d866c6e9a27e6567440047eec4b0d2df8d2fb39efe595848eb41fbc8ebd0616770d9976318ae599502c85b286fe79
6
+ metadata.gz: 455324c4b0fcb964e4db90d36da2c0ccf74323298bac57def3197af5b71e12c80cc7b835e16262cd7fa27d7bd96d15e8ca0f9ac454299835367863c3c5fb30bc
7
+ data.tar.gz: 66f4bcf63408b04889e53ed846753bd34e5e3c83ecb17fdd9694181a5aa7322ef12b68ba26378aa6a21d3b6a2ae1195a1a6c52e506e715a4f5d18a3b7db97d96
@@ -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 => range },
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
- def chart_data(trend, from = Setting[:max_trend], _to = Time.now.utc)
29
- chart_colors = ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE', '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92']
30
- values = trend.values
31
- labels = {}
32
- values.includes(:trendable).each { |v| labels[v.id] = [CGI.escapeHTML(v.to_label), trend_path(:id => v)] }
33
- values.includes(:trend_counters).where(['trend_counters.interval_end > ? or trend_counters.interval_end is null', from])
34
- .reorder('trend_counters.interval_start')
35
- .each_with_index.map do |value, idx|
36
- data = []
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
- # cut the left side of the graph
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
- # transform the timestamp values to flot format - from seconds in Ruby to milliseconds in flot
42
- data << [interval_start.to_i * 1000, counter.count]
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
- { :label => labels[value.id][0], :href => labels[value.id][1], :data => data, :color => chart_colors[idx % chart_colors.size] } unless data.empty?
46
- end.compact
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 range
59
+ def trends_range
50
60
  params['range'].empty? ? Setting[:max_trend] : params['range'].to_i
51
61
  end
52
62
  end
@@ -0,0 +1,23 @@
1
+ module ForemanStatistics
2
+ class TrendCounterJob < ApplicationJob
3
+ def perform(options = {})
4
+ start_time = Time.zone.now
5
+ ForemanStatistics::TrendImporter.update!
6
+ ensure
7
+ duration = start_time.is_a?(Time) ? Time.zone.now - start_time : 0
8
+ self.class.set(wait: [30.minutes - duration, 0].max).perform_later(options)
9
+ end
10
+
11
+ rescue_from(StandardError) do |error|
12
+ Foreman::Logging.logger('background').error(
13
+ 'Trend Counter Job: '\
14
+ "Error while creating new data #{error.message}"
15
+ )
16
+ raise error # propagate the error to the tasking system to properly report it there
17
+ end
18
+
19
+ def humanized_name
20
+ _('Trend Counter Job')
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ module ForemanStatistics
2
+ module HasManyTrends
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ has_many :trends, as: :trendable, class_name: 'ForemanStatistics::ForemanTrend', dependent: :destroy
7
+ end
8
+ end
9
+ end
@@ -25,7 +25,9 @@ module ForemanStatistics
25
25
  end
26
26
 
27
27
  def self.build_trend(trend_params = {})
28
- trend_params[:trendable_type] == 'FactName' ? FactTrend.new(trend_params) : ForemanTrend.new(trend_params)
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
@@ -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
- <div id="foremanStatisticsRoot"></div>
13
+ <%= react_component('ForemanStatistics') %>
14
14
  <% end %>
15
15
  <%= render file: "layouts/base" %>
16
- <%= mount_react_component('ForemanStatistics', '#foremanStatisticsRoot') %>
@@ -2,6 +2,5 @@
2
2
  <div class="row">
3
3
  <div class="stats-well col-md-12">
4
4
  <p><strong><%= _('No data for this trend.') %></strong></p>
5
- <div><%= (_("Is the cron job that executes %s enabled?") % "<span class='black'>foreman-rake foreman_statistics:trends:counter</span>").html_safe %></div>
6
5
  </div>
7
6
  </div>
@@ -4,7 +4,7 @@
4
4
  <% group.each do |host| %>
5
5
  <ul class="base">
6
6
  <li>
7
- <%= link_to(host, host_path(:id => host), :title => _("Show Host")) %>
7
+ <%= link_to(host, main_app.host_path(id: host), title: _("Show Host")) %>
8
8
  </li>
9
9
  </ul>
10
10
  <% end %>
@@ -1,16 +1,6 @@
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
- <% if @trends.empty? %>
6
- <%= alert :class => 'alert-info', :header => _("No trend counter defined"),
7
- :text => (_("To define trend counters, use the Add Trend Counter button.</br> To start collecting trend data, set a cron job to execute 'foreman-rake foreman_statistics:trends:counter' at least every %s minutes.") % Setting[:outofsync_interval]).html_safe %>
8
- <% end %>
9
-
10
- <% if @trends.any? and ForemanStatistics::TrendCounter.unconfigured? %>
11
- <%= alert :class => 'alert-info', :header => _("No trend counter found"),
12
- :text => (_("To start collecting trend data, set a cron job to execute <span class='black'>foreman-rake foreman_statistics:trends:counter</span> at least every %s minutes.") % Setting[:outofsync_interval]).html_safe %>
13
- <% end %>
14
4
 
15
5
  <table class="<%= table_css_classes 'table-fixed' %>">
16
6
  <thead>
@@ -33,7 +23,7 @@
33
23
  </tbody>
34
24
  </table>
35
25
  <%= will_paginate_with_info @trends %>
36
- <% unless ForemanStatistics::TrendCounter.unconfigured? %>
26
+ <% if (latest_counter_time = ForemanStatistics::TrendCounter.maximum(:created_at)) %>
37
27
  <%= _("Last update:") %>
38
- <%= date_time_relative(ForemanStatistics::TrendCounter.order(:created_at).last.created_at) %>
28
+ <%= date_time_relative(latest_counter_time) %>
39
29
  <% end %>
@@ -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="stats-well col-md-12">
6
- <h4 class="ca"><%= "#{trend_title(@trend)}" %></h4>
7
- <h6 class="ca"><%= n_("last %s day", "last %s days", range) % range %></h6>
8
- <%= flot_chart 'trend_graph','' ,_('Number of Hosts') , chart_data(@trend, range.days.ago), :class=>'statistics-chart stack', :legend => 'external' %>
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
@@ -79,13 +79,20 @@ module ForemanStatistics
79
79
  Apipie.configuration.checksum_path += ['/foreman_statistics/api/']
80
80
  end
81
81
 
82
+ initializer 'foreman_statistics.trend_counter_job' do
83
+ ::Foreman::Application.dynflow.config.on_init do |world|
84
+ TrendCounterJob.spawn_if_missing(world)
85
+ end
86
+ end
87
+
82
88
  # Include concerns in this config.to_prepare block
83
89
  config.to_prepare do
84
- ::ComputeResource.include ForemanStatistics::ComputeResourceDecorations
85
- ::Environment.include ForemanStatistics::EnvironmentDecorations
86
- ::Hostgroup.include ForemanStatistics::HostgroupDecorations
87
- ::Model.include ForemanStatistics::ModelDecorations
88
- ::Operatingsystem.include ForemanStatistics::OperatingsystemDecorations
90
+ ::ComputeResource.include ForemanStatistics::HasManyTrends
91
+ ::Hostgroup.include ForemanStatistics::HasManyTrends
92
+ ::Model.include ForemanStatistics::HasManyTrends
93
+ ::Operatingsystem.include ForemanStatistics::HasManyTrends
94
+ '::Environment'.safe_constantize&.include ForemanStatistics::HasManyTrends
95
+ 'ForemanPuppet::Environment'.safe_constantize&.include ForemanStatistics::HasManyTrends
89
96
  ::Setting.include ForemanStatistics::SettingDecorations
90
97
  ::Setting::General.prepend ForemanStatistics::GeneralSettingDecorations
91
98
  begin
@@ -1,3 +1,3 @@
1
1
  module ForemanStatistics
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
@@ -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.join(File.dirname(__FILE__), '../..', 'test')
49
- t.libs << ['test', test_dir]
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
@@ -0,0 +1,5 @@
1
+ # Autogenerated!
2
+ _('Action with sub plans')
3
+ _('Import facts')
4
+ _('Import Puppet classes')
5
+ _('Remote action:')
@@ -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 ""