foreman_hosts 1.1.10 → 2.0.0
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.
- data/README.md +117 -1
- data/app/controllers/foreman_hosts/hosts_controller.rb +1 -0
- data/app/controllers/foreman_hosts/syhostmodeldetails_controller.rb +83 -0
- data/app/controllers/foreman_hosts/syhostmodels_controller.rb +84 -0
- data/app/models/concerns/foreman_hosts/{hosts_extensions.rb → host_extensions.rb} +1 -1
- data/app/models/foreman_hosts/syhostmodel.rb +8 -0
- data/app/models/foreman_hosts/syhostmodeldetail.rb +5 -0
- data/app/views/foreman_hosts/hosts/export.xlsx.axlsx +130 -0
- data/app/views/foreman_hosts/hosts/new_action.html.erb +1 -0
- data/app/views/foreman_hosts/hosts/report_index.html.erb +11 -221
- data/app/views/foreman_hosts/syhostmodels/_form.html.erb +30 -0
- data/app/views/foreman_hosts/syhostmodels/_list.html.erb +41 -0
- data/app/{assets/javascripts/jquery.battatech.excelexport.js → views/foreman_hosts/syhostmodels/_report.html.erb} +79 -1
- data/app/views/foreman_hosts/syhostmodels/_sub.html.erb +37 -0
- data/app/views/foreman_hosts/syhostmodels/edit.html.erb +1 -0
- data/app/views/foreman_hosts/syhostmodels/index.html.erb +5 -0
- data/app/views/foreman_hosts/syhostmodels/new.html.erb +1 -0
- data/app/views/foreman_hosts/syhostmodels/show.html.erb +72 -0
- data/bin/foreman-hosts +1 -1
- data/config/routes.rb +7 -3
- data/db/migrate/20151015022411_create_syhostmodels.rb +10 -0
- data/db/migrate/20151015050239_create_syhostmodeldetails.rb +13 -0
- data/lib/foreman_hosts/engine.rb +15 -10
- data/lib/foreman_hosts/version.rb +1 -1
- metadata +18 -36
- data/app/assets/javascripts/application.js +0 -2
data/README.md
CHANGED
@@ -1,4 +1,120 @@
|
|
1
|
-
|
1
|
+
*** LOCAL GEMS ***
|
2
|
+
|
3
|
+
actionmailer (3.2.8)
|
4
|
+
actionpack (3.2.8)
|
5
|
+
activemodel (3.2.8)
|
6
|
+
activerecord (3.2.8)
|
7
|
+
activeresource (3.2.8)
|
8
|
+
activesupport (4.2.4, 3.2.8)
|
9
|
+
ancestry (2.0.0)
|
10
|
+
apipie-rails (0.2.6)
|
11
|
+
arel (3.0.2)
|
12
|
+
audited (3.0.0)
|
13
|
+
audited-activerecord (3.0.0)
|
14
|
+
bigdecimal (1.1.0)
|
15
|
+
builder (3.0.0)
|
16
|
+
bundler (1.3.5)
|
17
|
+
bundler_ext (0.3.0)
|
18
|
+
coffee-rails (3.2.2)
|
19
|
+
coffee-script (2.2.0)
|
20
|
+
coffee-script-source (1.3.3)
|
21
|
+
colorize (0.7.7)
|
22
|
+
deep_cloneable (2.0.2)
|
23
|
+
deface (1.0.1)
|
24
|
+
diff-lcs (1.1.3)
|
25
|
+
erubis (2.7.0)
|
26
|
+
execjs (1.4.0)
|
27
|
+
fast_gettext (0.9.2)
|
28
|
+
foreigner (1.7.1)
|
29
|
+
foreman-hosts (0.0.1)
|
30
|
+
foreman_setup (3.0.1)
|
31
|
+
friendly_id (4.0.10.1)
|
32
|
+
gettext_i18n_rails (1.2.1)
|
33
|
+
hike (1.2.1)
|
34
|
+
i18n (0.7.0, 0.6.0)
|
35
|
+
io-console (0.3)
|
36
|
+
journey (1.0.4)
|
37
|
+
json (1.8.3, 1.5.5)
|
38
|
+
ldap_fluff (0.3.5)
|
39
|
+
little-plugger (1.1.3)
|
40
|
+
logging (1.8.2)
|
41
|
+
loofah (2.0.3)
|
42
|
+
mail (2.4.4)
|
43
|
+
mime-types (1.19)
|
44
|
+
mini_portile (0.6.2)
|
45
|
+
minitest (5.8.1, 2.5.1)
|
46
|
+
multi_json (1.10.1)
|
47
|
+
net-http-persistent (2.7)
|
48
|
+
net-ldap (0.11)
|
49
|
+
netrc (0.7.7)
|
50
|
+
nokogiri (1.6.6.2)
|
51
|
+
oauth (0.4.7)
|
52
|
+
passenger (4.0.18)
|
53
|
+
pg (0.12.2)
|
54
|
+
polyglot (0.3.3)
|
55
|
+
rabl (0.11.6)
|
56
|
+
rack (1.6.4, 1.4.1)
|
57
|
+
rack-cache (1.2)
|
58
|
+
rack-jsonp (1.3.1)
|
59
|
+
rack-ssl (1.3.2)
|
60
|
+
rack-test (0.6.3, 0.6.1)
|
61
|
+
rails (3.2.8)
|
62
|
+
railties (3.2.8)
|
63
|
+
rake (0.9.2.2)
|
64
|
+
rdoc (3.9.5)
|
65
|
+
rest-client (1.6.7)
|
66
|
+
ruby2ruby (2.1.3)
|
67
|
+
ruby_parser (3.6.3)
|
68
|
+
safemode (1.2.2)
|
69
|
+
scoped_search (3.2.1)
|
70
|
+
secure_headers (1.4.1)
|
71
|
+
sexp_processor (4.4.4)
|
72
|
+
sprockets (2.12.3)
|
73
|
+
thor (0.18.1)
|
74
|
+
thread_safe (0.3.5)
|
75
|
+
tilt (1.3.3)
|
76
|
+
treetop (1.4.10)
|
77
|
+
turbolinks (2.5.3)
|
78
|
+
tzinfo (1.2.2, 0.3.33)
|
79
|
+
validates_lengths_from_database (0.4.0)
|
80
|
+
will_paginate (3.0.2)
|
81
|
+
|
82
|
+
|
83
|
+
============================================================================
|
84
|
+
Fetching: mini_portile-0.6.2.gem (100%)
|
85
|
+
Fetching: nokogiri-1.6.6.2.gem (100%)
|
86
|
+
Building native extensions. This could take a while...
|
87
|
+
Fetching: colorize-0.7.7.gem (100%)
|
88
|
+
Fetching: deface-1.0.1.gem (100%)
|
89
|
+
Fetching: foreman-hosts-0.0.1.gem (100%)
|
90
|
+
Fetching: i18n-0.7.0.gem (100%)
|
91
|
+
Fetching: json-1.8.3.gem (100%)
|
92
|
+
Building native extensions. This could take a while...
|
93
|
+
Fetching: thread_safe-0.3.5.gem (100%)
|
94
|
+
Fetching: tzinfo-1.2.2.gem (100%)
|
95
|
+
Fetching: minitest-5.8.1.gem (100%)
|
96
|
+
Fetching: activesupport-4.2.4.gem (100%)
|
97
|
+
Fetching: rack-1.6.4.gem (100%)
|
98
|
+
Fetching: rack-test-0.6.3.gem (100%)
|
99
|
+
Fetching: loofah-2.0.3.gem (100%)
|
100
|
+
Fetching: rails-html-sanitizer-1.0.2.gem (100%)
|
101
|
+
Fetching: rails-deprecated_sanitizer-1.0.3.gem (100%)
|
102
|
+
Fetching: rails-dom-testing-1.0.7.gem (100%)
|
103
|
+
Fetching: builder-3.2.2.gem (100%)
|
104
|
+
Fetching: actionview-4.2.4.gem (100%)
|
105
|
+
Fetching: actionpack-4.2.4.gem (100%)
|
106
|
+
Fetching: activemodel-4.2.4.gem (100%)
|
107
|
+
Fetching: arel-6.0.3.gem (100%)
|
108
|
+
Fetching: activerecord-4.2.4.gem (100%)
|
109
|
+
Fetching: globalid-0.3.6.gem (100%)
|
110
|
+
Fetching: activejob-4.2.4.gem (100%)
|
111
|
+
Fetching: mail-2.6.3.gem (100%)
|
112
|
+
Fetching: actionmailer-4.2.4.gem (100%)
|
113
|
+
Fetching: railties-4.2.4.gem (100%)
|
114
|
+
Fetching: sprockets-rails-2.3.3.gem (100%)
|
115
|
+
|
116
|
+
|
117
|
+
|
2
118
|
# ForemanHosts
|
3
119
|
|
4
120
|
*Introdction here*
|
@@ -0,0 +1,83 @@
|
|
1
|
+
class ForemanHosts::SyhostmodeldetailsController < ApplicationController
|
2
|
+
# GET /syhostmodeldetails
|
3
|
+
# GET /syhostmodeldetails.json
|
4
|
+
def index
|
5
|
+
@syhostmodeldetails = ForemanHosts::Syhostmodeldetail.all.paginate(:page => params[:page])
|
6
|
+
|
7
|
+
respond_to do |format|
|
8
|
+
format.html # index.html.erb
|
9
|
+
format.json { render json: @syhostmodeldetails }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /syhostmodeldetails/1
|
14
|
+
# GET /syhostmodeldetails/1.json
|
15
|
+
def show
|
16
|
+
@syhostmodeldetail = ForemanHosts::Syhostmodeldetail.find(params[:id])
|
17
|
+
|
18
|
+
respond_to do |format|
|
19
|
+
format.html # show.html.erb
|
20
|
+
format.json { render json: @syhostmodeldetail }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# GET /syhostmodeldetails/new
|
25
|
+
# GET /syhostmodeldetails/new.json
|
26
|
+
def new
|
27
|
+
@syhostmodeldetail = ForemanHosts::Syhostmodeldetail.new
|
28
|
+
respond_to do |format|
|
29
|
+
format.html # new.html.erb
|
30
|
+
format.json { render json: @syhostmodeldetail }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# GET /syhostmodeldetails/1/edit
|
35
|
+
def edit
|
36
|
+
@syhostmodeldetail = ForemanHosts::Syhostmodeldetail.find(params[:id])
|
37
|
+
end
|
38
|
+
|
39
|
+
# POST /syhostmodeldetails
|
40
|
+
# POST /syhostmodeldetails.json
|
41
|
+
def create
|
42
|
+
@syhostmodeldetail = ForemanHosts::Syhostmodeldetail.new(params[:foreman_hosts_syhostmodeldetail])
|
43
|
+
|
44
|
+
respond_to do |format|
|
45
|
+
if @syhostmodeldetail.save
|
46
|
+
format.html { redirect_to @syhostmodeldetail, notice: 'syhostmodeldetail was successfully created.' }
|
47
|
+
format.json { render json: @syhostmodeldetail, status: :created, location: @syhostmodeldetail }
|
48
|
+
else
|
49
|
+
format.html { render action: "new" }
|
50
|
+
format.json { render json: @syhostmodeldetail.errors, status: :unprocessable_entity }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# PUT /syhostmodeldetails/1
|
56
|
+
# PUT /syhostmodeldetails/1.json
|
57
|
+
def update
|
58
|
+
@syhostmodeldetail = ForemanHosts::Syhostmodeldetail.find(params[:id])
|
59
|
+
|
60
|
+
respond_to do |format|
|
61
|
+
if @syhostmodeldetail.update_attributes(params[:foreman_hosts_syhostmodeldetail])
|
62
|
+
format.html { redirect_to @syhostmodeldetail, notice: 'syhostmodeldetail was successfully updated.' }
|
63
|
+
format.json { head :no_content }
|
64
|
+
else
|
65
|
+
format.html { render action: "edit" }
|
66
|
+
format.json { render json: @syhostmodeldetail.errors, status: :unprocessable_entity }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# DELETE /syhostmodeldetails/1
|
72
|
+
# DELETE /syhostmodeldetails/1.json
|
73
|
+
def destroy
|
74
|
+
@syhostmodeldetail = ForemanHosts::Syhostmodeldetail.find(params[:id])
|
75
|
+
@syhostmodeldetail.destroy
|
76
|
+
respond_to do |format|
|
77
|
+
format.html { redirect_to foreman_hosts_syhostmodeldetails_url }
|
78
|
+
format.json { head :no_content }
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
class ForemanHosts::SyhostmodelsController < ApplicationController
|
2
|
+
# GET /syhostmodels
|
3
|
+
# GET /syhostmodels.json
|
4
|
+
def index
|
5
|
+
@syhostmodels = ForemanHosts::Syhostmodel.all.paginate(:page => params[:page])
|
6
|
+
|
7
|
+
respond_to do |format|
|
8
|
+
format.html # index.html.erb
|
9
|
+
format.json { render json: @syhostmodels }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /syhostmodels/1
|
14
|
+
# GET /syhostmodels/1.json
|
15
|
+
def show
|
16
|
+
@syhostmodel = ForemanHosts::Syhostmodel.find(params[:id])
|
17
|
+
# @syhosts = Host.all
|
18
|
+
# @syfactvalues = FactValue.all
|
19
|
+
respond_to do |format|
|
20
|
+
format.html # show.html.erb
|
21
|
+
format.json { render json: @syhostmodel }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# GET /syhostmodels/new
|
26
|
+
# GET /syhostmodels/new.json
|
27
|
+
def new
|
28
|
+
@syhostmodel = ForemanHosts::Syhostmodel.new
|
29
|
+
respond_to do |format|
|
30
|
+
format.html # new.html.erb
|
31
|
+
format.json { render json: @syhostmodel }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# GET /syhostmodels/1/edit
|
36
|
+
def edit
|
37
|
+
@syhostmodel = ForemanHosts::Syhostmodel.find(params[:id])
|
38
|
+
end
|
39
|
+
|
40
|
+
# POST /syhostmodels
|
41
|
+
# POST /syhostmodels.json
|
42
|
+
def create
|
43
|
+
@syhostmodel = ForemanHosts::Syhostmodel.new(params[:foreman_hosts_syhostmodel])
|
44
|
+
|
45
|
+
respond_to do |format|
|
46
|
+
if @syhostmodel.save
|
47
|
+
format.html { redirect_to @syhostmodel, notice: 'syhostmodel was successfully created.' }
|
48
|
+
format.json { render json: @syhostmodel, status: :created, location: @syhostmodel }
|
49
|
+
else
|
50
|
+
format.html { render action: "new" }
|
51
|
+
format.json { render json: @syhostmodel.errors, status: :unprocessable_entity }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# PUT /syhostmodels/1
|
57
|
+
# PUT /syhostmodels/1.json
|
58
|
+
def update
|
59
|
+
@syhostmodel = ForemanHosts::Syhostmodel.find(params[:id])
|
60
|
+
|
61
|
+
respond_to do |format|
|
62
|
+
if @syhostmodel.update_attributes(params[:foreman_hosts_syhostmodel])
|
63
|
+
format.html { redirect_to @syhostmodel, notice: 'syhostmodel was successfully updated.' }
|
64
|
+
format.json { head :no_content }
|
65
|
+
else
|
66
|
+
format.html { render action: "edit" }
|
67
|
+
format.json { render json: @syhostmodel.errors, status: :unprocessable_entity }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# DELETE /syhostmodels/1
|
73
|
+
# DELETE /syhostmodels/1.json
|
74
|
+
def destroy
|
75
|
+
@syhostmodel = ForemanHosts::Syhostmodel.find(params[:id])
|
76
|
+
@syhostmodel.destroy
|
77
|
+
respond_to do |format|
|
78
|
+
format.html { redirect_to foreman_hosts_syhostmodels_url }
|
79
|
+
format.json { head :no_content }
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class ForemanHosts::Syhostmodel < ActiveRecord::Base
|
2
|
+
|
3
|
+
attr_accessible :name, :remark, :syhostmodeldetails_attributes
|
4
|
+
has_many :syhostmodeldetails, class_name: "ForemanHosts::Syhostmodeldetail"
|
5
|
+
accepts_nested_attributes_for :syhostmodeldetails, reject_if: proc { |attributes| attributes['no'].blank?| attributes['status'].blank? | attributes['fact_name_id'].blank? } , allow_destroy: true
|
6
|
+
|
7
|
+
|
8
|
+
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
class ForemanHosts::Syhostmodeldetail < ActiveRecord::Base
|
2
|
+
attr_accessible :no, :status, :fact_name_id, :syhostmodel_id, :syhostmodel_type
|
3
|
+
belongs_to :foreman_hosts_syhostmodel, class_name: "ForemanHosts::Syhostmodel",foreign_key: "syhostmodel_id"
|
4
|
+
#belongs_to :fact_name, class_name: "FactName", foreign_key: "fact_name_id"
|
5
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
wb = xlsx_package.workbook
|
2
|
+
wb.add_worksheet(name: "Hosts") do |sheet|
|
3
|
+
sheet.add_row [
|
4
|
+
"name",
|
5
|
+
"last_compile",
|
6
|
+
"last_report",
|
7
|
+
"updated_at",
|
8
|
+
"created_at",
|
9
|
+
"root_pass",
|
10
|
+
"architecture_id",
|
11
|
+
"operatingsystem_id",
|
12
|
+
"environment_id",
|
13
|
+
"ptable_id",
|
14
|
+
"medium_id",
|
15
|
+
"build",
|
16
|
+
"comment",
|
17
|
+
"disk",
|
18
|
+
"installed_at",
|
19
|
+
"model_id",
|
20
|
+
"roup_id",
|
21
|
+
"owner_id",
|
22
|
+
"owner_type",
|
23
|
+
"enabled ",
|
24
|
+
"puppet_ca_proxy_id ",
|
25
|
+
"managed ",
|
26
|
+
"use_image ",
|
27
|
+
"image_file ",
|
28
|
+
"uuid ",
|
29
|
+
"compute_resource_id ",
|
30
|
+
"puppet_proxy_id ",
|
31
|
+
"certname ",
|
32
|
+
"image_id ",
|
33
|
+
"organization_id ",
|
34
|
+
"location_id ",
|
35
|
+
"type ",
|
36
|
+
"otp ",
|
37
|
+
"realm_id ",
|
38
|
+
"compute_profile_id ",
|
39
|
+
"provision_method ",
|
40
|
+
"grub_pass ",
|
41
|
+
"global_status ",
|
42
|
+
"lookup_value_matcher"
|
43
|
+
]
|
44
|
+
|
45
|
+
|
46
|
+
@hosts.each do |host|
|
47
|
+
|
48
|
+
expet_name = host.name rescue ""
|
49
|
+
expet_last_compile = host.last_compile rescue ""
|
50
|
+
expet_last_report = host.last_report rescue ""
|
51
|
+
expet_updated_at= host.updated_at rescue ""
|
52
|
+
expet_created_ate = host.created_at rescue ""
|
53
|
+
expet_root_pass = host.root_pass rescue ""
|
54
|
+
expet_architecture_id = host.architecture.name rescue ""
|
55
|
+
expet_operatingsystem_id = host.operatingsystem.name rescue ""
|
56
|
+
expet_environment_id= host.environment.name rescue ""
|
57
|
+
expet_ptable_id = host.ptable.name rescue ""
|
58
|
+
expet_medium_id = host.medium.name rescue ""
|
59
|
+
expet_build = host.build rescue ""
|
60
|
+
expet_comment = host.comment rescue ""
|
61
|
+
expetdisk = host.disk rescue ""
|
62
|
+
expet_installed_at = host.installed_at rescue ""
|
63
|
+
expet_model_id = host.model.name rescue ""
|
64
|
+
expet_hostgroup_id = host.hostgroup.name rescue ""
|
65
|
+
expet_owner_id = host.owner.name rescue ""
|
66
|
+
expet_owner_type = host.owner_type rescue ""
|
67
|
+
expet_enabled= host.enabled rescue ""
|
68
|
+
expet_puppet_ca_proxy_id = host.puppet_ca_proxy.name rescue ""
|
69
|
+
expet_managed = host.managed rescue ""
|
70
|
+
expet_use_image = host.use_image rescue ""
|
71
|
+
expet_image_file = host.image_file rescue ""
|
72
|
+
expet_uuid = host.uuid rescue ""
|
73
|
+
expet_compute_resource_id = host.compute_resource.name rescue ""
|
74
|
+
expet_puppet_proxy_id = host.puppet_proxy.name rescue ""
|
75
|
+
expet_certname = host.certname rescue ""
|
76
|
+
expet_image_id = host.image_id rescue ""
|
77
|
+
expet_organization_id = host.organization.name rescue ""
|
78
|
+
expet_location_id = host.location.name rescue ""
|
79
|
+
expet_type= host.type rescue ""
|
80
|
+
expet_otp = host.otp rescue ""
|
81
|
+
expet_realm_id = host.realm.name rescue ""
|
82
|
+
expet_compute_profile_id = host.compute_profile.name rescue ""
|
83
|
+
expet_provision_method = host.provision_method rescue ""
|
84
|
+
expet_grub_pass = host.grub_pass rescue ""
|
85
|
+
expet_global_status = host.global_status rescue ""
|
86
|
+
expet_lookup_value_matcher = host.lookup_value_matcher rescue ""
|
87
|
+
|
88
|
+
sheet.add_row [
|
89
|
+
expet_name,
|
90
|
+
expet_last_compile,
|
91
|
+
expet_last_report,
|
92
|
+
expet_updated_at= host.updated_at rescue "",
|
93
|
+
expet_created_ate,
|
94
|
+
expet_root_pass,
|
95
|
+
expet_architecture_id,
|
96
|
+
expet_operatingsystem_id,
|
97
|
+
expet_environment_id,
|
98
|
+
expet_ptable_id,
|
99
|
+
expet_medium_id,
|
100
|
+
expet_build,
|
101
|
+
expet_comment,
|
102
|
+
expetdisk,
|
103
|
+
expet_installed_at,
|
104
|
+
expet_model_id,
|
105
|
+
expet_hostgroup_id,
|
106
|
+
expet_owner_id,
|
107
|
+
expet_owner_type,
|
108
|
+
expet_enabled= host.enabled rescue "",
|
109
|
+
expet_puppet_ca_proxy_id,
|
110
|
+
expet_managed,
|
111
|
+
expet_use_image,
|
112
|
+
expet_image_file,
|
113
|
+
expet_uuid,
|
114
|
+
expet_compute_resource_id,
|
115
|
+
expet_puppet_proxy_id,
|
116
|
+
expet_certname,
|
117
|
+
expet_image_id,
|
118
|
+
expet_organization_id,
|
119
|
+
expet_location_id,
|
120
|
+
expet_type= host.type rescue "",
|
121
|
+
expet_otp,
|
122
|
+
expet_realm_id,
|
123
|
+
expet_compute_profile_id,
|
124
|
+
expet_provision_method,
|
125
|
+
expet_grub_pass,
|
126
|
+
expet_global_status,
|
127
|
+
expet_lookup_value_matcher
|
128
|
+
]
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Welcome to <b>ForemanHosts</b>
|
@@ -1,37 +1,30 @@
|
|
1
1
|
<div class="four wide right column">
|
2
2
|
<button class='btn btn-info' type='button'><a href="javascript:void(0);" class="ui green button icon mini" id="btnExport" onclick="export_excel();">Export</a></button>
|
3
|
-
|
3
|
+
|
4
4
|
</div>
|
5
5
|
<%= javascript "jquery.cookie", "host_checkbox" %>
|
6
6
|
<% title header ||= "" %>
|
7
|
-
|
8
7
|
<table class="table table-bordered table-striped table-condensed" id="tblExport">
|
9
8
|
<thead>
|
10
9
|
<tr>
|
10
|
+
<th class="ca"><%= check_box_tag "check_all", "", false, { :onclick => "toggleCheck()", :'check-title' => _("Select all items in this page"), :'uncheck-title'=> _("items selected. Uncheck to Clear") } %></th>
|
11
11
|
<th class=''><%= sort :name, :as => _('Name') %></th>
|
12
|
-
<% fact_name_no1 = 1 %>
|
13
12
|
<% @fact_names.each do |fact_name| %>
|
14
|
-
|
15
|
-
<th id="td<%= fact_name_no1 %>"><%= fact_name.name %>
|
16
|
-
<br />
|
17
|
-
<button type='button'><a href="javascript:void(0);" onclick="DeleteSignColumn(<%= fact_name_no1 %>);"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></button></th>
|
18
|
-
<% fact_name_no1 += 1 %>
|
13
|
+
<th><%= fact_name.name %></th>
|
19
14
|
<% end %>
|
15
|
+
|
20
16
|
</tr>
|
21
17
|
</thead>
|
22
18
|
<tbody>
|
23
19
|
<% @hosts.each do |host| %>
|
24
20
|
<tr>
|
21
|
+
<td class="ca">
|
22
|
+
<%= check_box_tag "host_ids[]", nil, false, :id => "host_ids_#{host.id}", :disabled => !authorized?, :class => 'host_select_boxes', :onclick => 'hostChecked(this)' %>
|
23
|
+
</td>
|
25
24
|
<td class='ellipsis'><%= name_column(host) %></td>
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
<%= FactValue.where(host_id: host.id, fact_name_id: fact_name.id).last.value rescue nil%>
|
30
|
-
</td>
|
31
|
-
<% end %>
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
<% @fact_names.each do |fact_name| %>
|
26
|
+
<td><%= get_fact_value(host, fact_name) %> </td>
|
27
|
+
<% end %>
|
35
28
|
</tr>
|
36
29
|
<% end %>
|
37
30
|
</tbody>
|
@@ -49,209 +42,6 @@
|
|
49
42
|
datatype: 'table',
|
50
43
|
returnUri: true
|
51
44
|
});
|
52
|
-
$("#btnExport").attr('download', '
|
45
|
+
$("#btnExport").attr('download', '项目工时.xlsx').attr('href', uri).attr('target', '_blank');
|
53
46
|
}
|
54
|
-
|
55
|
-
function DeleteSignColumn(tid) {
|
56
|
-
var tab = document.getElementById("tblExport");
|
57
|
-
var columnLength = tab.rows[0].cells.length;
|
58
|
-
var tr1 = tab.rows[0];
|
59
|
-
var columnId = 0;
|
60
|
-
tid= "td" + tid
|
61
|
-
for(var j=0;j<tr1.cells.length;j++)//取得第几行下面的td个数,再次循环遍历该行下面的td元素
|
62
|
-
{
|
63
|
-
var cell = tr1.cells[j];//获取某行下面的某个td元素
|
64
|
-
if (cell.id == tid) {
|
65
|
-
columnId = columnId + j;
|
66
|
-
}
|
67
|
-
}
|
68
|
-
//删除指定单元格
|
69
|
-
if (columnId > 0){
|
70
|
-
for (var i = 0; i < tab.rows.length; i++) {
|
71
|
-
tab.rows[i].deleteCell(columnId);
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
}
|
76
|
-
/*
|
77
|
-
* jQuery Client Side Excel Export Plugin Library
|
78
|
-
* http://www.battatech.com/
|
79
|
-
*
|
80
|
-
* Copyright (c) 2013 Batta Tech Private Limited
|
81
|
-
* Licensed under https://github.com/battatech/battatech_excelexport/blob/master/LICENSE.txt
|
82
|
-
*/
|
83
|
-
|
84
|
-
(function ($) {
|
85
|
-
var $defaults = {
|
86
|
-
containerid: null
|
87
|
-
, datatype: 'table'
|
88
|
-
, dataset: null
|
89
|
-
, columns: null
|
90
|
-
, returnUri: false
|
91
|
-
, worksheetName: "Sheet1"
|
92
|
-
, encoding: "utf-8"
|
93
|
-
};
|
94
|
-
|
95
|
-
var $settings = $defaults;
|
96
|
-
|
97
|
-
$.fn.battatech_excelexport = function (options) {
|
98
|
-
$settings = $.extend({}, $defaults, options);
|
99
|
-
|
100
|
-
var gridData = [];
|
101
|
-
var excelData;
|
102
|
-
|
103
|
-
return Initialize();
|
104
|
-
|
105
|
-
function Initialize() {
|
106
|
-
var type = $settings.datatype.toLowerCase();
|
107
|
-
|
108
|
-
BuildDataStructure(type);
|
109
|
-
|
110
|
-
switch (type) {
|
111
|
-
case 'table':
|
112
|
-
excelData = Export(ConvertFromTable());
|
113
|
-
break;
|
114
|
-
case 'json':
|
115
|
-
excelData = Export(ConvertDataStructureToTable());
|
116
|
-
break;
|
117
|
-
case 'xml':
|
118
|
-
excelData = Export(ConvertDataStructureToTable());
|
119
|
-
break;
|
120
|
-
case 'jqgrid':
|
121
|
-
excelData = Export(ConvertDataStructureToTable());
|
122
|
-
break;
|
123
|
-
}
|
124
|
-
|
125
|
-
if ($settings.returnUri) {
|
126
|
-
return excelData;
|
127
|
-
}
|
128
|
-
else {
|
129
|
-
window.open(excelData);
|
130
|
-
}
|
131
|
-
}
|
132
|
-
|
133
|
-
function BuildDataStructure(type) {
|
134
|
-
switch (type) {
|
135
|
-
case 'table':
|
136
|
-
break;
|
137
|
-
case 'json':
|
138
|
-
gridData = $settings.dataset;
|
139
|
-
break;
|
140
|
-
case 'xml':
|
141
|
-
$($settings.dataset).find("row").each(function (key, value) {
|
142
|
-
var item = {};
|
143
|
-
|
144
|
-
if (this.attributes != null && this.attributes.length > 0) {
|
145
|
-
$(this.attributes).each(function () {
|
146
|
-
item[this.name] = this.value;
|
147
|
-
});
|
148
|
-
|
149
|
-
gridData.push(item);
|
150
|
-
}
|
151
|
-
});
|
152
|
-
break;
|
153
|
-
case 'jqgrid':
|
154
|
-
$($settings.dataset).find("rows > row").each(function (key, value) {
|
155
|
-
var item = {};
|
156
|
-
|
157
|
-
if (this.children != null && this.children.length > 0) {
|
158
|
-
$(this.children).each(function () {
|
159
|
-
item[this.tagName] = $(this).text();
|
160
|
-
});
|
161
|
-
|
162
|
-
gridData.push(item);
|
163
|
-
}
|
164
|
-
});
|
165
|
-
break;
|
166
|
-
}
|
167
|
-
}
|
168
|
-
|
169
|
-
function ConvertFromTable() {
|
170
|
-
var result = $('<div>').append($('#' + $settings.containerid).clone()).html();
|
171
|
-
return result;
|
172
|
-
}
|
173
|
-
|
174
|
-
function ConvertDataStructureToTable() {
|
175
|
-
var result = "<table>";
|
176
|
-
|
177
|
-
result += "<thead><tr>";
|
178
|
-
$($settings.columns).each(function (key, value) {
|
179
|
-
if (this.ishidden != true) {
|
180
|
-
result += "<th";
|
181
|
-
if (this.width != null) {
|
182
|
-
result += " style='width: " + this.width + "'";
|
183
|
-
}
|
184
|
-
result += ">";
|
185
|
-
result += this.headertext;
|
186
|
-
result += "</th>";
|
187
|
-
}
|
188
|
-
});
|
189
|
-
result += "</tr></thead>";
|
190
|
-
|
191
|
-
result += "<tbody>";
|
192
|
-
$(gridData).each(function (key, value) {
|
193
|
-
result += "<tr>";
|
194
|
-
$($settings.columns).each(function (k, v) {
|
195
|
-
if (value.hasOwnProperty(this.datafield)) {
|
196
|
-
if (this.ishidden != true) {
|
197
|
-
result += "<td";
|
198
|
-
if (this.width != null) {
|
199
|
-
result += " style='width: " + this.width + "'";
|
200
|
-
}
|
201
|
-
result += ">";
|
202
|
-
result += value[this.datafield];
|
203
|
-
result += "</td>";
|
204
|
-
}
|
205
|
-
}
|
206
|
-
});
|
207
|
-
result += "</tr>";
|
208
|
-
});
|
209
|
-
result += "</tbody>";
|
210
|
-
|
211
|
-
result += "</table>";
|
212
|
-
return result;
|
213
|
-
}
|
214
|
-
|
215
|
-
function Export(htmltable) {
|
216
|
-
var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>";
|
217
|
-
excelFile += "<head>";
|
218
|
-
excelFile += '<meta http-equiv="Content-type" content="text/html;charset=' + $defaults.encoding + '" />';
|
219
|
-
excelFile += "<!--[if gte mso 9]>";
|
220
|
-
excelFile += "<xml>";
|
221
|
-
excelFile += "<x:ExcelWorkbook>";
|
222
|
-
excelFile += "<x:ExcelWorksheets>";
|
223
|
-
excelFile += "<x:ExcelWorksheet>";
|
224
|
-
excelFile += "<x:Name>";
|
225
|
-
excelFile += "{worksheet}";
|
226
|
-
excelFile += "</x:Name>";
|
227
|
-
excelFile += "<x:WorksheetOptions>";
|
228
|
-
excelFile += "<x:DisplayGridlines/>";
|
229
|
-
excelFile += "</x:WorksheetOptions>";
|
230
|
-
excelFile += "</x:ExcelWorksheet>";
|
231
|
-
excelFile += "</x:ExcelWorksheets>";
|
232
|
-
excelFile += "</x:ExcelWorkbook>";
|
233
|
-
excelFile += "</xml>";
|
234
|
-
excelFile += "<![endif]-->";
|
235
|
-
excelFile += "</head>";
|
236
|
-
excelFile += "<body>";
|
237
|
-
excelFile += htmltable.replace(/"/g, '\'');
|
238
|
-
excelFile += "</body>";
|
239
|
-
excelFile += "</html>";
|
240
|
-
|
241
|
-
var uri = "data:application/vnd.ms-excel;base64,";
|
242
|
-
var ctx = { worksheet: $settings.worksheetName, table: htmltable };
|
243
|
-
|
244
|
-
return (uri + base64(format(excelFile, ctx)));
|
245
|
-
}
|
246
|
-
|
247
|
-
function base64(s) {
|
248
|
-
return window.btoa(unescape(encodeURIComponent(s)));
|
249
|
-
}
|
250
|
-
|
251
|
-
function format(s, c) {
|
252
|
-
return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; });
|
253
|
-
}
|
254
|
-
};
|
255
|
-
})(jQuery);
|
256
|
-
|
257
47
|
</script>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%= javascript 'syhostmodels', 'syhostmodel_edit', 'syhostmodel_edit_interfaces', 'class_edit', 'compute_resource', 'lookup_keys'%>
|
2
|
+
|
3
|
+
<%= nested_form_for @syhostmodel, :html => {:data => {:id => @syhostmodel.try(:id), :submit => 'progress_bar'}} do |f| %>
|
4
|
+
<%= base_errors_for @syhostmodel %>
|
5
|
+
<div class="row clearfix">
|
6
|
+
<div class="row">
|
7
|
+
<div class="form-group col-md-12">
|
8
|
+
<label>name</label>
|
9
|
+
<%= f.text_field :name, :size => "col-md-12", placeholder: "填写name", class: "form-control" %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
<div class="row">
|
13
|
+
<div class="form-group col-md-12">
|
14
|
+
<label>remark</label>
|
15
|
+
<%= f.text_field :remark, :size => "col-md-12", placeholder: "填写remark", class: "form-control" %>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
<div class="row">
|
19
|
+
<div class="col-md-12 column">
|
20
|
+
<%#= render partial: "foreman_hosts/syhostmodels/sub", locals: { f: f, object: @syhostmodel } %>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
<div class="row">
|
24
|
+
<div class="actions">
|
25
|
+
<%= f.submit "提交", class: "btn btn-success" %>
|
26
|
+
<%= link_to '返回', foreman_hosts_syhostmodels_path, class: "btn btn-primary" %>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
<% end %>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<%= javascript "jquery.cookie" %>
|
2
|
+
<% title header ||= "" %>
|
3
|
+
<table class="table table-bordered table-striped table-condensed" >
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<th class=''>name</th>
|
7
|
+
<th class="hidden-xs">remark</th>
|
8
|
+
<th>操作</th>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
<tbody>
|
12
|
+
<% syhostmodels.each do |syhostmodel| %>
|
13
|
+
<tr>
|
14
|
+
<td class=''><%= syhostmodel.name %></td>
|
15
|
+
<td class="hidden-xs"><%= syhostmodel.remark %></td>
|
16
|
+
<td>
|
17
|
+
<%= link_to '查看', syhostmodel %>
|
18
|
+
<%= link_to '编辑', edit_foreman_hosts_syhostmodel_path(syhostmodel) %>
|
19
|
+
<%= link_to '删除', syhostmodel, method: :delete, data: { confirm: 'Are you sure?' } %>
|
20
|
+
</td>
|
21
|
+
</tr>
|
22
|
+
<% end %>
|
23
|
+
</tbody>
|
24
|
+
</table>
|
25
|
+
<div id="confirmation-modal" class="modal fade">
|
26
|
+
<div class="modal-dialog">
|
27
|
+
<div class="modal-content">
|
28
|
+
<div class="modal-header">
|
29
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
30
|
+
<h4 class="modal-title"><%= _('Please Confirm') %></h4>
|
31
|
+
</div>
|
32
|
+
<div class="modal-body">
|
33
|
+
</div>
|
34
|
+
<div class="modal-footer">
|
35
|
+
<button type="button" class="btn btn-default" data-dismiss="modal"><%= _('Cancel') %></button>
|
36
|
+
<button type="button" class="btn btn-primary" onclick="submit_modal_form()"><%= _('Submit') %></button>
|
37
|
+
</div>
|
38
|
+
</div><!-- /.modal-content -->
|
39
|
+
</div><!-- /.modal-dialog -->
|
40
|
+
</div><!-- /.modal -->
|
41
|
+
<%= will_paginate_with_info syhostmodels, :more => " - "+_("<b class='select_count'>0</b> selected") %>
|
@@ -1,4 +1,80 @@
|
|
1
|
-
|
1
|
+
<div class="four wide right column">
|
2
|
+
<button class='btn btn-info' type='button'><a href="javascript:void(0);" class="ui green button icon mini" id="btnExport" onclick="export_excel();">Export</a></button>
|
3
|
+
|
4
|
+
</div>
|
5
|
+
<%= javascript "jquery.cookie", "host_checkbox" %>
|
6
|
+
<% title header ||= "" %>
|
7
|
+
|
8
|
+
<table class="table table-bordered table-striped table-condensed" id="tblExport">
|
9
|
+
<thead>
|
10
|
+
<tr>
|
11
|
+
<th class=''><%= sort :name, :as => _('Name') %></th>
|
12
|
+
<% detail_name_no1 = 1 %>
|
13
|
+
<% details.each do |detail| %>
|
14
|
+
|
15
|
+
<th id="td<%= detail_name_no1 %>"><%#= detail.fact_name.name %>
|
16
|
+
<br />
|
17
|
+
<button type='button'><a href="javascript:void(0);" onclick="DeleteSignColumn(<%= detail_name_no1 %>);"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></button></th>
|
18
|
+
<% detail_name_no1 += 1 %>
|
19
|
+
<% end %>
|
20
|
+
</tr>
|
21
|
+
</thead>
|
22
|
+
<tbody>
|
23
|
+
<% #Host.all.each do |host| %>
|
24
|
+
<tr>
|
25
|
+
<td class='ellipsis'><%#= name_column(host) %></td>
|
26
|
+
|
27
|
+
<!-- <% #details.each do |detail| %> -->
|
28
|
+
<td>
|
29
|
+
<%#= FactValue.where(host_id: host.id, fact_name_id: detail.fact_name_id).last.value rescue nil%>
|
30
|
+
|
31
|
+
|
32
|
+
<%#= get_detail_value(host, detail_name) %>
|
33
|
+
</td>
|
34
|
+
<%# end %>
|
35
|
+
|
36
|
+
</tr>
|
37
|
+
<% end %>
|
38
|
+
</tbody>
|
39
|
+
</table>
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
<script type="text/javascript">
|
47
|
+
function export_excel(){
|
48
|
+
var uri = $("#tblExport").battatech_excelexport({
|
49
|
+
containerid: "tblExport",
|
50
|
+
datatype: 'table',
|
51
|
+
returnUri: true
|
52
|
+
});
|
53
|
+
$("#btnExport").attr('download', 'hosts.xlsx').attr('href', uri).attr('target', '_blank');
|
54
|
+
}
|
55
|
+
|
56
|
+
function DeleteSignColumn(tid) {
|
57
|
+
var tab = document.getElementById("tblExport");
|
58
|
+
var columnLength = tab.rows[0].cells.length;
|
59
|
+
var tr1 = tab.rows[0];
|
60
|
+
var columnId = 0;
|
61
|
+
tid= "td" + tid
|
62
|
+
for(var j=0;j<tr1.cells.length;j++)//取得第几行下面的td个数,再次循环遍历该行下面的td元素
|
63
|
+
{
|
64
|
+
var cell = tr1.cells[j];//获取某行下面的某个td元素
|
65
|
+
if (cell.id == tid) {
|
66
|
+
columnId = columnId + j;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
//删除指定单元格
|
70
|
+
if (columnId > 0){
|
71
|
+
for (var i = 0; i < tab.rows.length; i++) {
|
72
|
+
tab.rows[i].deleteCell(columnId);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
}
|
77
|
+
/*
|
2
78
|
* jQuery Client Side Excel Export Plugin Library
|
3
79
|
* http://www.battatech.com/
|
4
80
|
*
|
@@ -178,3 +254,5 @@
|
|
178
254
|
}
|
179
255
|
};
|
180
256
|
})(jQuery);
|
257
|
+
|
258
|
+
</script>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<div id="syhostmodeldetails">
|
2
|
+
<%= f.fields_for :syhostmodeldetails do |f| %>
|
3
|
+
<div class="row">
|
4
|
+
<div class="col-md-3 column form-group">
|
5
|
+
<label>no</label>
|
6
|
+
<%= f.text_field :no, class: "form_datetime form-control" %>
|
7
|
+
</div>
|
8
|
+
<div class="col-md-3 column form-group">
|
9
|
+
<label>status</label>
|
10
|
+
<%= f.select :status, [['please select', nil],"true", "false"], placeholder: "status", control_label: 'status', class: "col-md-3 column form-control"%>
|
11
|
+
<%#= f.text_field :status, class: "form_datetime form-control" %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div class="col-md-3 column form-group">
|
15
|
+
<label>fact_name_id</label><br />
|
16
|
+
<%#= f.select :fact_name_id, FactName.all.collect { |p| [ p.name, p.id ] }, include_blank: true , class: "col-md-3 column form-control"%>
|
17
|
+
|
18
|
+
<%#= f.text_field :fact_name_id, class: "form_datetime form-control" %>
|
19
|
+
</div>
|
20
|
+
<div class="col-md-1 column form-group">
|
21
|
+
<label>delete</label>
|
22
|
+
<%= f.link_to_remove "删除", class: "btn btn-danger" %>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
<%= f.hidden_field :syhostmodel_id, value: object.id %>
|
26
|
+
<%= f.hidden_field :syhostmodel_type, value: object.class.to_s %>
|
27
|
+
<% end %>
|
28
|
+
</div>
|
29
|
+
<div class="row">
|
30
|
+
<div class="col-md-9 column form-group">
|
31
|
+
|
32
|
+
</div>
|
33
|
+
<div class="col-md-1 column form-group">
|
34
|
+
<label></label>
|
35
|
+
<%= f.link_to_add "新增", :syhostmodeldetails, :data => { :target => "#syhostmodeldetails" }, class: "btn btn-primary" %>
|
36
|
+
</div>
|
37
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
<div class="container">
|
3
|
+
<div class="row">
|
4
|
+
<h1 class="clearfix">
|
5
|
+
<%= link_to '返回', foreman_hosts_syhostmodels_path, class: "btn btn-primary pull-right mr1" %>
|
6
|
+
<%= link_to '编辑', edit_foreman_hosts_syhostmodel_path(@syhostmodel), class: "btn btn-warning pull-right mr1" %>
|
7
|
+
</h1>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="row col-md-12">
|
11
|
+
<table class="table table-striped table-bordered">
|
12
|
+
<thead></thead>
|
13
|
+
<tbody>
|
14
|
+
<tr>
|
15
|
+
<td><strong>name</strong></td>
|
16
|
+
</tr>
|
17
|
+
<tr>
|
18
|
+
<td><%= @syhostmodel.name %></td>
|
19
|
+
</tr>
|
20
|
+
|
21
|
+
<tr>
|
22
|
+
<td><strong>remark</strong></td>
|
23
|
+
</tr>
|
24
|
+
<tr>
|
25
|
+
<td><%= @syhostmodel.remark %></td>
|
26
|
+
</tr>
|
27
|
+
</tbody>
|
28
|
+
</table>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div class="row col-md-12">
|
32
|
+
<ul class="nav nav-tabs mb1">
|
33
|
+
<li class="active"><a href="#models" data-toggle="tab">Detail</a></li>
|
34
|
+
<li><a href="#previews" data-toggle="tab">Preview</a></li>
|
35
|
+
</ul>
|
36
|
+
|
37
|
+
<div class="tab-content">
|
38
|
+
<div class="tab-pane active" id="models">
|
39
|
+
<div id="models">
|
40
|
+
|
41
|
+
<div class="panel-body">
|
42
|
+
<table class="table table-striped table-bordered models">
|
43
|
+
<thead>
|
44
|
+
<th>no</th>
|
45
|
+
<th>status</th>
|
46
|
+
<th>fact_name</th>
|
47
|
+
</thead>
|
48
|
+
<tbody>
|
49
|
+
<% @syhostmodel.syhostmodeldetails.order("no Asc").each do |syhostmodeldetail|%>
|
50
|
+
<tr class="success">
|
51
|
+
<td><%= syhostmodeldetail.no %></td>
|
52
|
+
<td><%= syhostmodeldetail.status %></td>
|
53
|
+
<td><%#= syhostmodeldetail.fact_name.name rescue nil %></td>
|
54
|
+
</tr>
|
55
|
+
<% end %>
|
56
|
+
</tbody>
|
57
|
+
</table>
|
58
|
+
</div>
|
59
|
+
|
60
|
+
|
61
|
+
</div>
|
62
|
+
</div>
|
63
|
+
<div class="tab-pane" id="previews">
|
64
|
+
<div id="previews">
|
65
|
+
<div class="panel-body">
|
66
|
+
<%#= render partial: "foreman_hosts/syhostmodels/report", locals: { details: @syhostmodel.syhostmodeldetails} %>
|
67
|
+
</div>
|
68
|
+
</div>
|
69
|
+
</div>
|
70
|
+
</div>
|
71
|
+
</div>
|
72
|
+
</div>
|
data/bin/foreman-hosts
CHANGED
@@ -2,4 +2,4 @@
|
|
2
2
|
|
3
3
|
foreman_root = "/usr/share/foreman"
|
4
4
|
require File.expand_path('./config/application', foreman_root)
|
5
|
-
|
5
|
+
ForemanUsers::Dynflow::Daemon.new.run_background(ARGV.last, :foreman_root => foreman_root)
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
+
match 'new_action', to: 'foreman_hosts/hosts#new_action'
|
3
|
+
match 'export', to: 'foreman_hosts/hosts#export'
|
4
|
+
match 'report_index', to: 'foreman_hosts/hosts#report_index'
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
+
namespace :foreman_hosts do
|
7
|
+
resources :syhostmodels
|
8
|
+
resources :syhostmodeldetails
|
9
|
+
end
|
6
10
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateSyhostmodeldetails < ActiveRecord::Migration
|
2
|
+
drop tables syhostmodeldetails if table_exists? :syhostmodeldetails
|
3
|
+
def change
|
4
|
+
create_table :syhostmodeldetails do |t|
|
5
|
+
t.integer :syhostmodel_id
|
6
|
+
t.string :syhostmodel_type
|
7
|
+
t.string :no
|
8
|
+
t.integer :fact_name_id
|
9
|
+
t.boolean :status
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/foreman_hosts/engine.rb
CHANGED
@@ -16,26 +16,31 @@ module ForemanHosts
|
|
16
16
|
|
17
17
|
initializer 'foreman_hosts.register_plugin', after: :finisher_hook do |_app|
|
18
18
|
Foreman::Plugin.register :foreman_hosts do
|
19
|
-
requires_foreman '>= 1.
|
19
|
+
requires_foreman '>= 1.9.0'
|
20
20
|
|
21
21
|
# Add permissions
|
22
22
|
security_block :foreman_hosts do
|
23
23
|
permission :view_foreman_hosts, :'foreman_hosts/hosts' => [:report_index]
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# permission :delete_foreman_syhostmodels, :'foreman_hosts/syhostmodels' => [:destroy]
|
24
|
+
permission :view_foreman_syhostmodels, :'foreman_hosts/syhostmodels' => [:index, :show]
|
25
|
+
permission :new_foreman_syhostmodels, :'foreman_hosts/syhostmodels' => [:new, :create]
|
26
|
+
permission :edit_foreman_syhostmodels, :'foreman_hosts/syhostmodels' => [:edit, :update]
|
27
|
+
permission :delete_foreman_syhostmodels, :'foreman_hosts/syhostmodels' => [:destroy]
|
29
28
|
end
|
30
29
|
|
31
30
|
# Add a new role called 'Discovery' if it doesn't exist
|
32
|
-
role 'ForemanHosts', [:view_foreman_hosts]
|
33
|
-
|
31
|
+
role 'ForemanHosts', [:view_foreman_hosts, :view_foreman_syhostmodels, :new_foreman_syhostmodels, :edit_foreman_syhostmodels, :delete_foreman_syhostmodels]
|
34
32
|
# add menu entry
|
35
33
|
|
36
34
|
sub_menu :top_menu, :export_menu, :caption=> N_('Export'), :after=> :infrastructure_menu do
|
37
|
-
|
38
|
-
menu :top_menu, :
|
35
|
+
menu :top_menu, :level1, :caption=>N_('ExportTemplates'), :url_hash => { :controller => 'foreman_hosts/syhostmodels', :action => :index }
|
36
|
+
menu :top_menu, :level2, :caption=>N_('ExportHosts'), :url_hash => { :controller => 'foreman_hosts/hosts', :action => :report_index }
|
37
|
+
# menu :top_menu, :level2, :url_hash => {:controller=> :example, :action=>:index}
|
38
|
+
# menu :top_menu, :level3, :url_hash => {:controller=> :example, :action=>:index}
|
39
|
+
# sub_menu :top_menu, :inner_level, :caption=> N_('Inner level') do
|
40
|
+
# menu :top_menu, :level41, :url_hash => {:controller=> :example, :action=>:index}
|
41
|
+
# menu :top_menu, :level42, :url_hash => {:controller=> :example, :action=>:index}
|
42
|
+
# end
|
43
|
+
# menu :top_menu, :level5, :url_hash => {:controller=> :example, :action=>:index}
|
39
44
|
end
|
40
45
|
# menu :top_menu, :template,
|
41
46
|
# url_hash: { controller: :'foreman_hosts/hosts', action: :new_action },
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_hosts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,38 +11,6 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2015-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: deface
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: nested_form
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
14
|
- !ruby/object:Gem::Dependency
|
47
15
|
name: rubocop
|
48
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,16 +53,30 @@ files:
|
|
85
53
|
- app/views/dashboard/_foreman_hosts_widget.html.erb
|
86
54
|
- app/views/foreman_hosts/layouts/layouts/new_layout.html.erb
|
87
55
|
- app/views/foreman_hosts/layouts/new_layout.html.erb
|
56
|
+
- app/views/foreman_hosts/syhostmodels/edit.html.erb
|
57
|
+
- app/views/foreman_hosts/syhostmodels/new.html.erb
|
58
|
+
- app/views/foreman_hosts/syhostmodels/_report.html.erb
|
59
|
+
- app/views/foreman_hosts/syhostmodels/show.html.erb
|
60
|
+
- app/views/foreman_hosts/syhostmodels/index.html.erb
|
61
|
+
- app/views/foreman_hosts/syhostmodels/_list.html.erb
|
62
|
+
- app/views/foreman_hosts/syhostmodels/_form.html.erb
|
63
|
+
- app/views/foreman_hosts/syhostmodels/_sub.html.erb
|
64
|
+
- app/views/foreman_hosts/hosts/export.xlsx.axlsx
|
88
65
|
- app/views/foreman_hosts/hosts/report_index.html.erb
|
89
66
|
- app/views/foreman_hosts/hosts/hosts/new_action.html.erb
|
90
|
-
- app/
|
91
|
-
- app/assets/javascripts/application.js
|
67
|
+
- app/views/foreman_hosts/hosts/new_action.html.erb
|
92
68
|
- app/overrides/dashboard/index/sample_override.html.erb.deface
|
69
|
+
- app/controllers/foreman_hosts/syhostmodeldetails_controller.rb
|
70
|
+
- app/controllers/foreman_hosts/syhostmodels_controller.rb
|
93
71
|
- app/controllers/foreman_hosts/hosts_controller.rb
|
94
72
|
- app/helpers/concerns/foreman_hosts/hosts_helper_extensions.rb
|
95
|
-
- app/models/concerns/foreman_hosts/
|
73
|
+
- app/models/concerns/foreman_hosts/host_extensions.rb
|
74
|
+
- app/models/foreman_hosts/syhostmodeldetail.rb
|
75
|
+
- app/models/foreman_hosts/syhostmodel.rb
|
96
76
|
- bin/foreman-hosts
|
97
77
|
- config/routes.rb
|
78
|
+
- db/migrate/20151015022411_create_syhostmodels.rb
|
79
|
+
- db/migrate/20151015050239_create_syhostmodeldetails.rb
|
98
80
|
- lib/tasks/foreman_hosts_tasks.rake
|
99
81
|
- lib/foreman_hosts.rb
|
100
82
|
- lib/foreman_hosts/version.rb
|