foreman_hosts 1.1.6 → 1.1.8

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 CHANGED
@@ -1,3 +1,4 @@
1
+ # 导出host信息,可默认导出所有主机的所有信息,也可以通过定制模板导出主机信息
1
2
  # ForemanHosts
2
3
 
3
4
  *Introdction here*
@@ -0,0 +1,2 @@
1
+ //= require jquery_nested_form
2
+ //= require jquery.battatech.excelexport
@@ -0,0 +1,180 @@
1
+ /*
2
+ * jQuery Client Side Excel Export Plugin Library
3
+ * http://www.battatech.com/
4
+ *
5
+ * Copyright (c) 2013 Batta Tech Private Limited
6
+ * Licensed under https://github.com/battatech/battatech_excelexport/blob/master/LICENSE.txt
7
+ */
8
+
9
+ (function ($) {
10
+ var $defaults = {
11
+ containerid: null
12
+ , datatype: 'table'
13
+ , dataset: null
14
+ , columns: null
15
+ , returnUri: false
16
+ , worksheetName: "Sheet1"
17
+ , encoding: "utf-8"
18
+ };
19
+
20
+ var $settings = $defaults;
21
+
22
+ $.fn.battatech_excelexport = function (options) {
23
+ $settings = $.extend({}, $defaults, options);
24
+
25
+ var gridData = [];
26
+ var excelData;
27
+
28
+ return Initialize();
29
+
30
+ function Initialize() {
31
+ var type = $settings.datatype.toLowerCase();
32
+
33
+ BuildDataStructure(type);
34
+
35
+ switch (type) {
36
+ case 'table':
37
+ excelData = Export(ConvertFromTable());
38
+ break;
39
+ case 'json':
40
+ excelData = Export(ConvertDataStructureToTable());
41
+ break;
42
+ case 'xml':
43
+ excelData = Export(ConvertDataStructureToTable());
44
+ break;
45
+ case 'jqgrid':
46
+ excelData = Export(ConvertDataStructureToTable());
47
+ break;
48
+ }
49
+
50
+ if ($settings.returnUri) {
51
+ return excelData;
52
+ }
53
+ else {
54
+ window.open(excelData);
55
+ }
56
+ }
57
+
58
+ function BuildDataStructure(type) {
59
+ switch (type) {
60
+ case 'table':
61
+ break;
62
+ case 'json':
63
+ gridData = $settings.dataset;
64
+ break;
65
+ case 'xml':
66
+ $($settings.dataset).find("row").each(function (key, value) {
67
+ var item = {};
68
+
69
+ if (this.attributes != null && this.attributes.length > 0) {
70
+ $(this.attributes).each(function () {
71
+ item[this.name] = this.value;
72
+ });
73
+
74
+ gridData.push(item);
75
+ }
76
+ });
77
+ break;
78
+ case 'jqgrid':
79
+ $($settings.dataset).find("rows > row").each(function (key, value) {
80
+ var item = {};
81
+
82
+ if (this.children != null && this.children.length > 0) {
83
+ $(this.children).each(function () {
84
+ item[this.tagName] = $(this).text();
85
+ });
86
+
87
+ gridData.push(item);
88
+ }
89
+ });
90
+ break;
91
+ }
92
+ }
93
+
94
+ function ConvertFromTable() {
95
+ var result = $('<div>').append($('#' + $settings.containerid).clone()).html();
96
+ return result;
97
+ }
98
+
99
+ function ConvertDataStructureToTable() {
100
+ var result = "<table>";
101
+
102
+ result += "<thead><tr>";
103
+ $($settings.columns).each(function (key, value) {
104
+ if (this.ishidden != true) {
105
+ result += "<th";
106
+ if (this.width != null) {
107
+ result += " style='width: " + this.width + "'";
108
+ }
109
+ result += ">";
110
+ result += this.headertext;
111
+ result += "</th>";
112
+ }
113
+ });
114
+ result += "</tr></thead>";
115
+
116
+ result += "<tbody>";
117
+ $(gridData).each(function (key, value) {
118
+ result += "<tr>";
119
+ $($settings.columns).each(function (k, v) {
120
+ if (value.hasOwnProperty(this.datafield)) {
121
+ if (this.ishidden != true) {
122
+ result += "<td";
123
+ if (this.width != null) {
124
+ result += " style='width: " + this.width + "'";
125
+ }
126
+ result += ">";
127
+ result += value[this.datafield];
128
+ result += "</td>";
129
+ }
130
+ }
131
+ });
132
+ result += "</tr>";
133
+ });
134
+ result += "</tbody>";
135
+
136
+ result += "</table>";
137
+ return result;
138
+ }
139
+
140
+ function Export(htmltable) {
141
+ 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'>";
142
+ excelFile += "<head>";
143
+ excelFile += '<meta http-equiv="Content-type" content="text/html;charset=' + $defaults.encoding + '" />';
144
+ excelFile += "<!--[if gte mso 9]>";
145
+ excelFile += "<xml>";
146
+ excelFile += "<x:ExcelWorkbook>";
147
+ excelFile += "<x:ExcelWorksheets>";
148
+ excelFile += "<x:ExcelWorksheet>";
149
+ excelFile += "<x:Name>";
150
+ excelFile += "{worksheet}";
151
+ excelFile += "</x:Name>";
152
+ excelFile += "<x:WorksheetOptions>";
153
+ excelFile += "<x:DisplayGridlines/>";
154
+ excelFile += "</x:WorksheetOptions>";
155
+ excelFile += "</x:ExcelWorksheet>";
156
+ excelFile += "</x:ExcelWorksheets>";
157
+ excelFile += "</x:ExcelWorkbook>";
158
+ excelFile += "</xml>";
159
+ excelFile += "<![endif]-->";
160
+ excelFile += "</head>";
161
+ excelFile += "<body>";
162
+ excelFile += htmltable.replace(/"/g, '\'');
163
+ excelFile += "</body>";
164
+ excelFile += "</html>";
165
+
166
+ var uri = "data:application/vnd.ms-excel;base64,";
167
+ var ctx = { worksheet: $settings.worksheetName, table: htmltable };
168
+
169
+ return (uri + base64(format(excelFile, ctx)));
170
+ }
171
+
172
+ function base64(s) {
173
+ return window.btoa(unescape(encodeURIComponent(s)));
174
+ }
175
+
176
+ function format(s, c) {
177
+ return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; });
178
+ }
179
+ };
180
+ })(jQuery);
@@ -2,10 +2,16 @@ module ForemanHosts
2
2
  # Example: Plugin's HostsController inherits from Foreman's HostsController
3
3
  class HostsController < ::HostsController
4
4
  # change layout if needed
5
- # layout 'foreman_hosts/layouts/new_layout'
5
+ #layout 'foreman_hosts/layouts/new_layout'
6
6
 
7
- def new_action
8
- # automatically renders view/foreman_hosts/hosts/new_action
9
- end
7
+ def report_index
8
+ @fact_values = FactValue.all
9
+ @fact_names = FactName.all
10
+ @hosts = Host.all
11
+ respond_to do |format|
12
+ format.html # index.html.erb
13
+ format.json { render json: @hosts }
14
+ end
15
+ end
10
16
  end
11
17
  end
@@ -9,5 +9,12 @@ module ForemanHosts
9
9
  # create or overwrite instance methods...
10
10
  def instance_method_name
11
11
  end
12
+
13
+ def get_fact_value(host,name)
14
+ fact_value = FactValue.where(host_id: host.id, fact_name_id: name.id)
15
+ if fact_value.first.present?
16
+ return fact_value.first.value
17
+ end
18
+ end
12
19
  end
13
20
  end
@@ -16,4 +16,4 @@ module ForemanHosts
16
16
  end
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -1,5 +1,5 @@
1
1
  class ForemanHosts::Syhostmodeldetail < ActiveRecord::Base
2
2
  attr_accessible :no, :status, :fact_name_id, :syhostmodel_id, :syhostmodel_type
3
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"
4
+ #belongs_to :fact_name, class_name: "FactName", foreign_key: "fact_name_id"
5
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,257 @@
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
+ <% fact_name_no1 = 1 %>
13
+ <% @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 %>
19
+ <% end %>
20
+ </tr>
21
+ </thead>
22
+ <tbody>
23
+ <% @hosts.each do |host| %>
24
+ <tr>
25
+ <td class='ellipsis'><%= name_column(host) %></td>
26
+
27
+ <% @fact_names.each do |fact_name| %>
28
+ <td>
29
+ <%= FactValue.where(host_id: host.id, fact_name_id: fact_name.id).last.value rescue nil%>
30
+ </td>
31
+ <% end %>
32
+
33
+
34
+
35
+ </tr>
36
+ <% end %>
37
+ </tbody>
38
+ </table>
39
+
40
+
41
+
42
+
43
+
44
+
45
+ <script type="text/javascript">
46
+ function export_excel(){
47
+ var uri = $("#tblExport").battatech_excelexport({
48
+ containerid: "tblExport",
49
+ datatype: 'table',
50
+ returnUri: true
51
+ });
52
+ $("#btnExport").attr('download', 'hosts.xlsx').attr('href', uri).attr('target', '_blank');
53
+ }
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
+ </script>
@@ -17,7 +17,7 @@
17
17
  </div>
18
18
  <div class="row">
19
19
  <div class="col-md-12 column">
20
- <%= render partial: "foreman_hosts/syhostmodels/sub", locals: { f: f, object: @syhostmodel } %>
20
+ <%#= render partial: "foreman_hosts/syhostmodels/sub", locals: { f: f, object: @syhostmodel } %>
21
21
  </div>
22
22
  </div>
23
23
  <div class="row">
@@ -26,7 +26,7 @@
26
26
 
27
27
  <% details.each do |detail| %>
28
28
  <td>
29
- <%= FactValue.where(host_id: host.id, fact_name_id: detail.fact_name_id).last.value rescue nil%>
29
+ <%#= FactValue.where(host_id: host.id, fact_name_id: detail.fact_name_id).last.value rescue nil%>
30
30
 
31
31
 
32
32
  <%#= get_detail_value(host, detail_name) %>
@@ -13,7 +13,7 @@
13
13
 
14
14
  <div class="col-md-3 column form-group">
15
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"%>
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
17
 
18
18
  <%#= f.text_field :fact_name_id, class: "form_datetime form-control" %>
19
19
  </div>
@@ -50,7 +50,7 @@
50
50
  <tr class="success">
51
51
  <td><%= syhostmodeldetail.no %></td>
52
52
  <td><%= syhostmodeldetail.status %></td>
53
- <td><%= syhostmodeldetail.fact_name.name rescue nil %></td>
53
+ <td><%#= syhostmodeldetail.fact_name.name rescue nil %></td>
54
54
  </tr>
55
55
  <% end %>
56
56
  </tbody>
@@ -63,7 +63,7 @@
63
63
  <div class="tab-pane" id="previews">
64
64
  <div id="previews">
65
65
  <div class="panel-body">
66
- <%= render partial: "foreman_hosts/syhostmodels/report", locals: { details: @syhostmodel.syhostmodeldetails} %>
66
+ <%#= render partial: "foreman_hosts/syhostmodels/report", locals: { details: @syhostmodel.syhostmodeldetails} %>
67
67
  </div>
68
68
  </div>
69
69
  </div>
data/bin/foreman-hosts ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ foreman_root = "/usr/share/foreman"
4
+ require File.expand_path('./config/application', foreman_root)
5
+ ForemanHosts::Dynflow::Daemon.new.run_background(ARGV.last, :foreman_root => foreman_root)
data/config/routes.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  Rails.application.routes.draw do
2
+
2
3
  namespace :foreman_hosts do
4
+ match 'report_index', to: 'hosts#report_index'
3
5
  resources :syhostmodels
4
6
  resources :syhostmodeldetails
5
7
  end
@@ -20,19 +20,28 @@ module ForemanHosts
20
20
 
21
21
  # Add permissions
22
22
  security_block :foreman_hosts do
23
- permission :view_foreman_hosts, :'foreman_hosts/syhostmodels' => [:index, :show, :auto_complete_search]
24
- permission :new_foreman_hosts, :'foreman_hosts/syhostmodels' => [:new, :create]
25
- permission :edit_foreman_hosts, :'foreman_hosts/syhostmodels' => [:edit, :update]
26
- permission :delete_foreman_hosts, :'foreman_hosts/syhostmodels' => [:destroy]
23
+ permission :view_foreman_hosts, :'foreman_hosts/hosts' => [:report_index]
24
+
25
+ permission :view_foreman_syhostmodels, :'foreman_hosts/syhostmodels' => [:index, :show, :auto_complete_search]
26
+ permission :new_foreman_syhostmodels, :'foreman_hosts/syhostmodels' => [:new, :create]
27
+ permission :edit_foreman_syhostmodels, :'foreman_hosts/syhostmodels' => [:edit, :update]
28
+ permission :delete_foreman_syhostmodels, :'foreman_hosts/syhostmodels' => [:destroy]
27
29
  end
28
30
 
29
31
  # Add a new role called 'Discovery' if it doesn't exist
30
- role 'ForemanHosts', [:view_foreman_hosts, :new_foreman_hosts, :edit_foreman_hosts, :delete_foreman_hosts]
32
+ role 'ForemanHosts', [:view_foreman_hosts, :view_foreman_syhostmodels, :new_foreman_syhostmodels, :edit_foreman_syhostmodels, :delete_foreman_syhostmodels]
31
33
 
32
34
  # add menu entry
35
+
33
36
  sub_menu :top_menu, :export_menu, :caption=> N_('Export'), :after=> :infrastructure_menu do
34
37
  menu :top_menu, :level1, :caption=>N_('ExportTemplates'), :url_hash => { :controller => 'foreman_hosts/syhostmodels', :action => :index }
38
+ menu :top_menu, :level2, :caption=>N_('ExportHosts'), :url_hash => { :controller => 'foreman_hosts/hosts', :action => :report_index }
35
39
  end
40
+ # menu :top_menu, :template,
41
+ # url_hash: { controller: :'foreman_hosts/hosts', action: :new_action },
42
+ # caption: 'ForemanHosts',
43
+ # parent: :hosts_menu,
44
+ # after: :hosts
36
45
 
37
46
  # add dashboard widget
38
47
  widget 'foreman_hosts_widget', name: N_('Foreman plugin template widget'), sizex: 4, sizey: 1
@@ -76,5 +85,8 @@ module ForemanHosts
76
85
  locale_domain = 'foreman_hosts'
77
86
  Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
78
87
  end
88
+ initializer "foreman_chef.load_app_instance_data" do |app|
89
+ #app.config.paths['db/migrate'] += PluginTemplate::Engine.paths['db/migrate'].existent
90
+ end
79
91
  end
80
92
  end
@@ -1,4 +1,3 @@
1
1
  module ForemanHosts
2
- VERSION = '1.1.6'
2
+ VERSION = '1.1.8'
3
3
  end
4
-
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: 1.1.6
4
+ version: 1.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,6 +11,22 @@ 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'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: nested_form
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -77,16 +93,20 @@ files:
77
93
  - app/views/foreman_hosts/syhostmodels/_list.html.erb
78
94
  - app/views/foreman_hosts/syhostmodels/_form.html.erb
79
95
  - app/views/foreman_hosts/syhostmodels/_sub.html.erb
96
+ - app/views/foreman_hosts/hosts/export.xlsx.axlsx
97
+ - app/views/foreman_hosts/hosts/report_index.html.erb
80
98
  - app/views/foreman_hosts/hosts/hosts/new_action.html.erb
81
- - app/views/foreman_hosts/hosts/new_action.html.erb
99
+ - app/assets/javascripts/jquery.battatech.excelexport.js
100
+ - app/assets/javascripts/application.js
82
101
  - app/overrides/dashboard/index/sample_override.html.erb.deface
83
102
  - app/controllers/foreman_hosts/syhostmodeldetails_controller.rb
84
103
  - app/controllers/foreman_hosts/syhostmodels_controller.rb
85
104
  - app/controllers/foreman_hosts/hosts_controller.rb
86
105
  - app/helpers/concerns/foreman_hosts/hosts_helper_extensions.rb
87
- - app/models/syhostmodeldetail.rb
88
- - app/models/syhostmodel.rb
89
- - app/models/concerns/foreman_hosts/host_extensions.rb
106
+ - app/models/concerns/foreman_hosts/hosts_extensions.rb
107
+ - app/models/foreman_hosts/syhostmodeldetail.rb
108
+ - app/models/foreman_hosts/syhostmodel.rb
109
+ - bin/foreman-hosts
90
110
  - config/routes.rb
91
111
  - db/migrate/20151015022411_create_syhostmodels.rb
92
112
  - db/migrate/20151015050239_create_syhostmodeldetails.rb
@@ -1 +0,0 @@
1
- Welcome to <b>ForemanHosts</b>