foreman_host_reports 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +619 -0
- data/README.md +545 -0
- data/app/controllers/api/v2/host_reports_controller.rb +98 -0
- data/app/controllers/concerns/foreman_host_reports/controller/parameters/host_report.rb +25 -0
- data/app/controllers/host_reports_controller.rb +46 -0
- data/app/models/concerns/foreman_host_reports/host_extensions.rb +9 -0
- data/app/models/concerns/foreman_host_reports/smart_proxy_extensions.rb +9 -0
- data/app/models/host_report.rb +85 -0
- data/app/models/report_keyword.rb +11 -0
- data/app/views/api/v2/host_reports/base.json.rabl +5 -0
- data/app/views/api/v2/host_reports/create.json.rabl +5 -0
- data/app/views/api/v2/host_reports/index.json.rabl +5 -0
- data/app/views/api/v2/host_reports/main.json.rabl +15 -0
- data/app/views/api/v2/host_reports/show.json.rabl +11 -0
- data/config/routes.rb +33 -0
- data/db/migrate/20210112183526_add_host_reports.rb +36 -0
- data/db/migrate/20210616133601_create_report_keywords.rb +12 -0
- data/lib/foreman_host_reports/engine.rb +68 -0
- data/lib/foreman_host_reports/version.rb +3 -0
- data/lib/foreman_host_reports.rb +4 -0
- data/lib/tasks/foreman_host_reports_tasks.rake +50 -0
- data/locale/Makefile +60 -0
- data/locale/en/foreman_host_reports.po +19 -0
- data/locale/foreman_host_reports.pot +19 -0
- data/locale/gemspec.rb +2 -0
- data/package.json +45 -0
- data/test/controllers/api/v2/host_reports_controller_test.rb +278 -0
- data/test/factories/foreman_host_reports_factories.rb +21 -0
- data/test/snapshots/foreman-web.json +918 -0
- data/test/test_plugin_helper.rb +11 -0
- data/test/unit/foreman_host_reports_test.rb +9 -0
- data/webpack/global_index.js +4 -0
- data/webpack/global_test_setup.js +11 -0
- data/webpack/index.js +0 -0
- data/webpack/src/Router/HostReports/Components/HostReportDeleteModal.js +50 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/FormatCell.js +53 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/FormatCell.scss +4 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/Formatters/formatCellFormatter.js +6 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/Formatters/hostReportsToShowFormatter.js +13 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/Formatters/index.js +4 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/Formatters/reportToShowFormatter.js +13 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/Formatters/statusFormatter.js +9 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/HostReportsToShowCell.js +32 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/ReportToShowCell.js +27 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/StatusCell.js +77 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/StatusCell.scss +9 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/formatImages.js +7 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/images/ansible.png +0 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/Components/images/puppet.png +0 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/HostReportsTable.js +85 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/HostReportsTableSchema.js +65 -0
- data/webpack/src/Router/HostReports/IndexPage/Components/HostReportsTable/index.js +28 -0
- data/webpack/src/Router/HostReports/IndexPage/IndexPage.js +88 -0
- data/webpack/src/Router/HostReports/IndexPage/IndexPageActions.js +55 -0
- data/webpack/src/Router/HostReports/IndexPage/IndexPageHelpers.js +50 -0
- data/webpack/src/Router/HostReports/IndexPage/IndexPageSelectors.js +86 -0
- data/webpack/src/Router/HostReports/IndexPage/constants.js +14 -0
- data/webpack/src/Router/HostReports/IndexPage/index.js +98 -0
- data/webpack/src/Router/HostReports/ShowPage/Components/HostReportMetrics/HostReportMetrics.scss +3 -0
- data/webpack/src/Router/HostReports/ShowPage/Components/HostReportMetrics/index.js +100 -0
- data/webpack/src/Router/HostReports/ShowPage/Components/ReportLogs/Ansible.js +77 -0
- data/webpack/src/Router/HostReports/ShowPage/Components/ReportLogs/Puppet.js +79 -0
- data/webpack/src/Router/HostReports/ShowPage/Components/ReportLogs/helpers.js +17 -0
- data/webpack/src/Router/HostReports/ShowPage/Components/ReportLogs/index.js +29 -0
- data/webpack/src/Router/HostReports/ShowPage/Components/ReportLogsFilter/index.js +109 -0
- data/webpack/src/Router/HostReports/ShowPage/ShowPage.js +160 -0
- data/webpack/src/Router/HostReports/ShowPage/ShowPageSelectors.js +51 -0
- data/webpack/src/Router/HostReports/ShowPage/index.js +75 -0
- data/webpack/src/Router/HostReports/constants.js +15 -0
- data/webpack/src/Router/routes.js +23 -0
- data/webpack/test_setup.js +17 -0
- metadata +133 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class HostReportsController < ::ApplicationController
|
4
|
+
include Foreman::Controller::AutoCompleteSearch
|
5
|
+
|
6
|
+
def show
|
7
|
+
@host_report = resource_scope.find(params[:id])
|
8
|
+
|
9
|
+
return not_found unless @host_report
|
10
|
+
|
11
|
+
respond_to do |format|
|
12
|
+
format.html do
|
13
|
+
render '/react/index'
|
14
|
+
end
|
15
|
+
format.json do
|
16
|
+
render json: {
|
17
|
+
host_report: {
|
18
|
+
id: @host_report.id,
|
19
|
+
body: JSON.parse(@host_report.body),
|
20
|
+
format: @host_report.format,
|
21
|
+
host: {
|
22
|
+
id: @host_report.host.id,
|
23
|
+
name: @host_report.host.name,
|
24
|
+
},
|
25
|
+
proxy: {
|
26
|
+
id: @host_report.proxy&.id,
|
27
|
+
name: @host_report.proxy&.name,
|
28
|
+
},
|
29
|
+
reported_at: @host_report.reported_at,
|
30
|
+
},
|
31
|
+
permissions: {
|
32
|
+
can_delete: authorized_for(auth_object: @host_report, authorizer: authorizer, permission: "destroy_#{controller_permission}"),
|
33
|
+
can_view: authorized_for(auth_object: @host_report, authorizer: authorizer, permission: "view_#{controller_permission}"),
|
34
|
+
},
|
35
|
+
}, status: :ok
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def resource_scope(options = {})
|
43
|
+
options[:permission] = :view_host_reports
|
44
|
+
super(options).my_reports
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
class HostReport < ApplicationRecord
|
2
|
+
include Authorizable
|
3
|
+
include ScopedSearchExtensions
|
4
|
+
|
5
|
+
delegate :logger, to: :Rails
|
6
|
+
|
7
|
+
validates_lengths_from_database
|
8
|
+
belongs_to_host
|
9
|
+
belongs_to :proxy, class_name: 'SmartProxy'
|
10
|
+
has_one :organization, through: :host
|
11
|
+
has_one :location, through: :host
|
12
|
+
|
13
|
+
validates :host_id, :reported_at, :status, presence: true
|
14
|
+
|
15
|
+
enum format: {
|
16
|
+
# plain text report (no processing)
|
17
|
+
plain: 0,
|
18
|
+
# standard report (status + logs in plain text)
|
19
|
+
puppet: 1,
|
20
|
+
ansible: 2,
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
STATUS = {
|
24
|
+
plain: %w[debug normal warning error],
|
25
|
+
}.freeze
|
26
|
+
|
27
|
+
scoped_search relation: :host, on: :name, complete_value: true, rename: :host, aliases: %i[host_name]
|
28
|
+
scoped_search relation: :proxy, on: :name, complete_value: true, rename: :proxy
|
29
|
+
scoped_search relation: :organization, on: :name, complete_value: true, rename: :organization
|
30
|
+
scoped_search relation: :location, on: :name, complete_value: true, rename: :location
|
31
|
+
scoped_search on: :reported_at, complete_value: true, default_order: :desc, rename: :reported, only_explicit: true, aliases: %i[last_report reported_at]
|
32
|
+
scoped_search on: :format, complete_value: { plain: 0, puppet: 1, ansible: 2 }
|
33
|
+
# This is to simulate has_many :report_keywords relation for scoped_search library to work
|
34
|
+
# NOTE: This won't work for any other purpose
|
35
|
+
reflections['report_keywords'] = ReportKeyword
|
36
|
+
scoped_search relation: :report_keywords, on: :name, complete_value: true, rename: :keyword, ext_method: :search_by_keyword, operators: ['=']
|
37
|
+
|
38
|
+
scope :recent, ->(*args) { where("reported_at > ?", (args.first || 1.day.ago)).order(:reported_at) }
|
39
|
+
|
40
|
+
scope :my_reports, lambda {
|
41
|
+
if !User.current.admin? || Organization.expand(Organization.current).present? || Location.expand(Location.current).present?
|
42
|
+
joins_authorized(Host, :view_hosts)
|
43
|
+
end
|
44
|
+
}
|
45
|
+
|
46
|
+
default_scope -> { order('reported_at DESC') }
|
47
|
+
|
48
|
+
# TODO: temporary until we decide what will status bitfiled be exactly
|
49
|
+
# rubocop:disable Style/RescueModifier
|
50
|
+
def status
|
51
|
+
@status ||= case format
|
52
|
+
when 'puppet'
|
53
|
+
JSON.parse(body)['metrics']['resources']['values'] rescue []
|
54
|
+
when 'ansible'
|
55
|
+
JSON.parse(body)['status'] rescue {}
|
56
|
+
else
|
57
|
+
super
|
58
|
+
end
|
59
|
+
end
|
60
|
+
# rubocop:enable Style/RescueModifier
|
61
|
+
|
62
|
+
def report_keywords
|
63
|
+
ReportKeyword.where(id: report_keyword_ids)
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.authorized_smart_proxy_features
|
67
|
+
@authorized_smart_proxy_features ||= %w[Puppet Ansible]
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.register_smart_proxy_feature(feature)
|
71
|
+
@authorized_smart_proxy_features = (authorized_smart_proxy_features + [feature]).uniq
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.unregister_smart_proxy_feature(feature)
|
75
|
+
@authorized_smart_proxy_features -= [feature]
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.search_by_keyword(_key, operator, value)
|
79
|
+
conditions = sanitize_sql_for_conditions(["report_keywords.name #{operator} ?", value_to_sql(operator, value)])
|
80
|
+
keyword_ids = ReportKeyword.where(conditions).distinct.pluck(:id)
|
81
|
+
{
|
82
|
+
conditions: sanitize_sql_for_conditions(["host_reports.report_keyword_ids @> ?", "{#{keyword_ids.join(',')}}"]),
|
83
|
+
}
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ReportKeyword < ApplicationRecord
|
2
|
+
def host_reports
|
3
|
+
HostReport.where("report_keyword_ids @> ?", "{#{id}}")
|
4
|
+
end
|
5
|
+
|
6
|
+
# This is to simulate has_many :report_keywords relation for scoped_search library to work
|
7
|
+
# NOTE: This won't work for any other purpose
|
8
|
+
def self.klass
|
9
|
+
self
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
object @host_report
|
4
|
+
|
5
|
+
extends 'api/v2/host_reports/base'
|
6
|
+
extends 'api/v2/layouts/permissions'
|
7
|
+
|
8
|
+
attributes :format, :host_id, :proxy_id, :reported_at, :status
|
9
|
+
|
10
|
+
node(:host_name) do |report|
|
11
|
+
report.host.name
|
12
|
+
end
|
13
|
+
node(:proxy_name) do |report|
|
14
|
+
report.proxy&.name
|
15
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
match '/host_reports' => 'react#index', via: :get
|
3
|
+
|
4
|
+
resources :hosts do
|
5
|
+
member do
|
6
|
+
match 'host_reports', to: 'react#index', via: :get
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
resources :host_reports, only: %i[show] do
|
11
|
+
collection do
|
12
|
+
get 'auto_complete_search'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
namespace :api, defaults: { format: 'json' } do
|
17
|
+
scope '(:apiv)', module: :v2, defaults: { apiv: 'v2' }, apiv: /v2/,
|
18
|
+
constraints: ApiConstraints.new(version: 2, default: true) do
|
19
|
+
resources :host_reports, only: %i[index show create destroy] do
|
20
|
+
collection do
|
21
|
+
get 'export'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
constraints(id: %r{[^/]+}) do
|
25
|
+
resources :hosts, only: [] do
|
26
|
+
constraints(host_id: %r{[^/]+}) do
|
27
|
+
resources :host_reports, only: %i[index]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# rubocop:disable Rails/CreateTableWithTimestamps
|
2
|
+
class AddHostReports < ActiveRecord::Migration[6.0]
|
3
|
+
def change
|
4
|
+
create_table :host_reports do |t|
|
5
|
+
# Host reference, b-tree index.
|
6
|
+
t.integer "host_id", null: false
|
7
|
+
|
8
|
+
# Smart proxy which processed and uploaded, no index.
|
9
|
+
t.integer "proxy_id"
|
10
|
+
|
11
|
+
# Explicit timestamp, replaces Rails timestamps, b-tree descending index.
|
12
|
+
t.datetime "reported_at", null: false
|
13
|
+
|
14
|
+
# Use StatusCalculator to store arbitrary amount of counters in this
|
15
|
+
# bit array (e.g. info, debug, error, fatal messages). Each report
|
16
|
+
# implementation decides how to use this bitfield. No index.
|
17
|
+
t.bigint "status"
|
18
|
+
|
19
|
+
# Report contents, usually in JSON format depending on implementation.
|
20
|
+
# Text field is by default compressed and not searchable, use
|
21
|
+
# ReportKeyword model for searching. Other formats like JSON/JSONB were
|
22
|
+
# considered but this appears to be the fastest option. No index.
|
23
|
+
t.text "body"
|
24
|
+
|
25
|
+
# Report type "enum", integer is faster and smaller than varchar.
|
26
|
+
# No index since cardinality is very low (1-3 effectively)
|
27
|
+
t.integer "format", default: 0, null: false
|
28
|
+
|
29
|
+
# Indices. Keep it at the bare minimum, this model should be optimized
|
30
|
+
# for updates not for reads.
|
31
|
+
t.index "host_id"
|
32
|
+
t.index "reported_at", order: { reported_at: :desc }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
# rubocop:enable Rails/CreateTableWithTimestamps
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# rubocop:disable Rails/CreateTableWithTimestamps
|
2
|
+
class CreateReportKeywords < ActiveRecord::Migration[6.0]
|
3
|
+
def change
|
4
|
+
create_table :report_keywords do |t|
|
5
|
+
t.string :name, null: false, index: { unique: true }
|
6
|
+
end
|
7
|
+
|
8
|
+
add_column :host_reports, :report_keyword_ids, :integer, array: true, default: []
|
9
|
+
add_index :host_reports, :report_keyword_ids, using: 'gin'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
# rubocop:enable Rails/CreateTableWithTimestamps
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module ForemanHostReports
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace ForemanHostReports
|
4
|
+
engine_name 'foreman_host_reports'
|
5
|
+
|
6
|
+
config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
|
7
|
+
config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
|
8
|
+
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
9
|
+
config.autoload_paths += Dir["#{config.root}/app/overrides"]
|
10
|
+
config.autoload_paths += Dir["#{config.root}/lib"]
|
11
|
+
|
12
|
+
# Add any db migrations
|
13
|
+
initializer 'foreman_host_reports.load_app_instance_data' do |app|
|
14
|
+
ForemanHostReports::Engine.paths['db/migrate'].existent.each do |path|
|
15
|
+
app.config.paths['db/migrate'] << path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
initializer 'foreman_host_reports.register_plugin', :before => :finisher_hook do |_app|
|
20
|
+
Foreman::Plugin.register :foreman_host_reports do
|
21
|
+
requires_foreman '>= 3.0.0'
|
22
|
+
|
23
|
+
apipie_documented_controllers ["#{ForemanHostReports::Engine.root}/app/controllers/api/v2/*.rb"]
|
24
|
+
# Add Global files for extending foreman-core components and routes
|
25
|
+
register_global_js_file 'global'
|
26
|
+
|
27
|
+
# Add permissions
|
28
|
+
security_block :foreman_host_reports do
|
29
|
+
permission :view_host_reports, { host_reports: %i[index show auto_complete_search],
|
30
|
+
'api/v2/host_reports': %i[index show export] }, resource_type: 'HostReport'
|
31
|
+
permission :create_host_reports, { 'api/v2/host_reports': [:create] }, resource_type: 'HostReport'
|
32
|
+
permission :destroy_host_reports, { 'api/v2/host_reports': [:destroy] }, resource_type: 'HostReport'
|
33
|
+
end
|
34
|
+
|
35
|
+
role 'Host reports manager', %i[view_host_reports create_host_reports destroy_host_reports]
|
36
|
+
|
37
|
+
# add menu entry
|
38
|
+
menu :top_menu, :host_reports, url: '/host_reports',
|
39
|
+
url_hash: { controller: :host_reports, action: :index },
|
40
|
+
caption: N_('Host Reports'),
|
41
|
+
parent: :monitor_menu,
|
42
|
+
before: :reports
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Include concerns in this config.to_prepare block
|
47
|
+
# rubocop:disable Style/RescueStandardError
|
48
|
+
config.to_prepare do
|
49
|
+
Host::Managed.include ForemanHostReports::HostExtensions
|
50
|
+
SmartProxy.include ForemanHostReports::HostExtensions
|
51
|
+
rescue => e
|
52
|
+
Rails.logger.warn "ForemanHostReports: skipping engine hook (#{e})"
|
53
|
+
end
|
54
|
+
# rubocop:enable Style/RescueStandardError
|
55
|
+
|
56
|
+
rake_tasks do
|
57
|
+
Rake::Task['db:seed'].enhance do
|
58
|
+
ForemanHostReports::Engine.load_seed
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
initializer 'foreman_host_reports.register_gettext', after: :load_config_initializers do |_app|
|
63
|
+
locale_dir = File.join(File.expand_path('../..', __dir__), 'locale')
|
64
|
+
locale_domain = 'foreman_host_reports'
|
65
|
+
Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
|
3
|
+
# Tasks
|
4
|
+
namespace :foreman_host_reports do
|
5
|
+
namespace :example do
|
6
|
+
desc 'Example Task'
|
7
|
+
task task: :environment do
|
8
|
+
# Task goes here
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Tests
|
14
|
+
namespace :test do
|
15
|
+
desc 'Test ForemanHostReports'
|
16
|
+
Rake::TestTask.new(:foreman_host_reports) do |t|
|
17
|
+
test_dir = File.expand_path('../../test', __dir__)
|
18
|
+
t.libs << 'test'
|
19
|
+
t.libs << test_dir
|
20
|
+
t.pattern = "#{test_dir}/**/*_test.rb"
|
21
|
+
t.verbose = true
|
22
|
+
t.warning = false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
namespace :foreman_host_reports do
|
27
|
+
# rubocop:disable Rails/RakeEnvironment, Style/RescueStandardError
|
28
|
+
task :rubocop do
|
29
|
+
begin
|
30
|
+
require 'rubocop/rake_task'
|
31
|
+
RuboCop::RakeTask.new(:rubocop_foreman_host_reports) do |task|
|
32
|
+
task.patterns = ["#{ForemanHostReports::Engine.root}/app/**/*.rb",
|
33
|
+
"#{ForemanHostReports::Engine.root}/lib/**/*.rb",
|
34
|
+
"#{ForemanHostReports::Engine.root}/test/**/*.rb"]
|
35
|
+
end
|
36
|
+
rescue
|
37
|
+
puts 'Rubocop not loaded.'
|
38
|
+
end
|
39
|
+
|
40
|
+
Rake::Task['rubocop_foreman_host_reports'].invoke
|
41
|
+
end
|
42
|
+
# rubocop:enable Rails/RakeEnvironment, Style/RescueStandardError
|
43
|
+
end
|
44
|
+
|
45
|
+
Rake::Task[:test].enhance ['test:foreman_host_reports']
|
46
|
+
|
47
|
+
load 'tasks/jenkins.rake'
|
48
|
+
if Rake::Task.task_defined?(:'jenkins:unit')
|
49
|
+
Rake::Task['jenkins:unit'].enhance ['test:foreman_host_reports', 'foreman_host_reports:rubocop']
|
50
|
+
end
|
data/locale/Makefile
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#
|
2
|
+
# Makefile for PO merging and MO generation. More info in the README.
|
3
|
+
#
|
4
|
+
# make all-mo (default) - generate MO files
|
5
|
+
# make check - check translations using translate-tool
|
6
|
+
# make tx-update - download and merge translations from Transifex
|
7
|
+
# make clean - clean everything
|
8
|
+
#
|
9
|
+
DOMAIN = foreman_host_reports
|
10
|
+
VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load(Dir.glob("../*.gemspec")[0]);puts spec.version')
|
11
|
+
POTFILE = $(DOMAIN).pot
|
12
|
+
MOFILE = $(DOMAIN).mo
|
13
|
+
POFILES = $(shell find . -name '$(DOMAIN).po')
|
14
|
+
MOFILES = $(patsubst %.po,%.mo,$(POFILES))
|
15
|
+
POXFILES = $(patsubst %.po,%.pox,$(POFILES))
|
16
|
+
EDITFILES = $(patsubst %.po,%.edit.po,$(POFILES))
|
17
|
+
|
18
|
+
%.mo: %.po
|
19
|
+
mkdir -p $(shell dirname $@)/LC_MESSAGES
|
20
|
+
msgfmt -o $(shell dirname $@)/LC_MESSAGES/$(MOFILE) $<
|
21
|
+
|
22
|
+
# Generate MO files from PO files
|
23
|
+
all-mo: $(MOFILES)
|
24
|
+
|
25
|
+
# Check for malformed strings
|
26
|
+
%.pox: %.po
|
27
|
+
msgfmt -c $<
|
28
|
+
pofilter --nofuzzy -t variables -t blank -t urls -t emails -t long -t newlines \
|
29
|
+
-t endwhitespace -t endpunc -t puncspacing -t options -t printf -t validchars --gnome $< > $@
|
30
|
+
cat $@
|
31
|
+
! grep -q msgid $@
|
32
|
+
|
33
|
+
%.edit.po:
|
34
|
+
touch $@
|
35
|
+
|
36
|
+
check: $(POXFILES)
|
37
|
+
|
38
|
+
# Unify duplicate translations
|
39
|
+
uniq-po:
|
40
|
+
for f in $(shell find ./ -name "*.po") ; do \
|
41
|
+
msguniq $$f -o $$f ; \
|
42
|
+
done
|
43
|
+
|
44
|
+
tx-pull: $(EDITFILES)
|
45
|
+
tx pull -f
|
46
|
+
for f in $(EDITFILES) ; do \
|
47
|
+
sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
|
48
|
+
done
|
49
|
+
|
50
|
+
tx-update: tx-pull
|
51
|
+
@echo
|
52
|
+
@echo Run rake plugin:gettext[$(DOMAIN)] from the Foreman installation, then make -C locale mo-files to finish
|
53
|
+
@echo
|
54
|
+
|
55
|
+
mo-files: $(MOFILES)
|
56
|
+
git add $(POFILES) $(POTFILE) ../locale/*/LC_MESSAGES
|
57
|
+
git commit -m "i18n - pulling from tx"
|
58
|
+
@echo
|
59
|
+
@echo Changes commited!
|
60
|
+
@echo
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# foreman_host_reports
|
2
|
+
#
|
3
|
+
# This file is distributed under the same license as foreman_host_reports.
|
4
|
+
#
|
5
|
+
#, fuzzy
|
6
|
+
msgid ""
|
7
|
+
msgstr ""
|
8
|
+
"Project-Id-Version: version 0.0.1\n"
|
9
|
+
"Report-Msgid-Bugs-To: \n"
|
10
|
+
"POT-Creation-Date: 2014-08-20 08:46+0100\n"
|
11
|
+
"PO-Revision-Date: 2014-08-20 08:54+0100\n"
|
12
|
+
"Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
|
13
|
+
"Language-Team: Foreman Team <foreman-dev@googlegroups.com>\n"
|
14
|
+
"Language: \n"
|
15
|
+
"MIME-Version: 1.0\n"
|
16
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
17
|
+
"Content-Transfer-Encoding: 8bit\n"
|
18
|
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
19
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# foreman_host_reports
|
2
|
+
#
|
3
|
+
# This file is distributed under the same license as foreman_host_reports.
|
4
|
+
#
|
5
|
+
#, fuzzy
|
6
|
+
msgid ""
|
7
|
+
msgstr ""
|
8
|
+
"Project-Id-Version: version 0.0.1\n"
|
9
|
+
"Report-Msgid-Bugs-To: \n"
|
10
|
+
"POT-Creation-Date: 2014-08-20 08:46+0100\n"
|
11
|
+
"PO-Revision-Date: 2014-08-20 08:46+0100\n"
|
12
|
+
"Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
|
13
|
+
"Language-Team: Foreman Team <foreman-dev@googlegroups.com>\n"
|
14
|
+
"Language: \n"
|
15
|
+
"MIME-Version: 1.0\n"
|
16
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
17
|
+
"Content-Transfer-Encoding: 8bit\n"
|
18
|
+
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
19
|
+
|
data/locale/gemspec.rb
ADDED
data/package.json
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
{
|
2
|
+
"name": "foreman_host_reports",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "Foreman plugin providing reporting feature optimized for high-performance.",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"lint": "tfm-lint --plugin -d /webpack",
|
8
|
+
"test": "tfm-test --config jest.config.js",
|
9
|
+
"test:watch": "tfm-test --plugin --watchAll",
|
10
|
+
"test:current": "tfm-test --plugin --watch",
|
11
|
+
"publish-coverage": "tfm-publish-coverage",
|
12
|
+
"stories": "tfm-stories --plugin",
|
13
|
+
"stories:build": "tfm-build-stories --plugin",
|
14
|
+
"create-react-component": "yo react-domain"
|
15
|
+
},
|
16
|
+
"repository": {
|
17
|
+
"type": "git",
|
18
|
+
"url": "git+https://github.com/theforeman/foreman_host_reports.git"
|
19
|
+
},
|
20
|
+
"bugs": {
|
21
|
+
"url": "http://projects.theforeman.org/projects/foreman_host_reports/issues"
|
22
|
+
},
|
23
|
+
"peerDependencies": {
|
24
|
+
"@theforeman/vendor": ">= 6.0.0"
|
25
|
+
},
|
26
|
+
"dependencies": {
|
27
|
+
"react-intl": "^2.8.0",
|
28
|
+
"react-json-tree": "^0.11.0"
|
29
|
+
},
|
30
|
+
"devDependencies": {
|
31
|
+
"@babel/core": "^7.7.0",
|
32
|
+
"@sheerun/mutationobserver-shim": "^0.3.3",
|
33
|
+
"@theforeman/builder": "^8.4.1",
|
34
|
+
"@theforeman/eslint-plugin-foreman": "8.4.1",
|
35
|
+
"@theforeman/find-foreman": "^8.4.1",
|
36
|
+
"@theforeman/stories": "^8.4.1",
|
37
|
+
"@theforeman/test": "^8.4.1",
|
38
|
+
"@theforeman/vendor-dev": "^8.4.1",
|
39
|
+
"babel-eslint": "^10.0.3",
|
40
|
+
"eslint": "^6.7.2",
|
41
|
+
"prettier": "^1.19.1",
|
42
|
+
"stylelint-config-standard": "^18.0.0",
|
43
|
+
"stylelint": "^9.3.0"
|
44
|
+
}
|
45
|
+
}
|