foreman_hosts 1.1.2 → 1.1.3

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/config/routes.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
3
  namespace :foreman_hosts do
4
- match 'report_index', to: 'hosts#report_index'
4
+ #match 'report_index', to: 'hosts#report_index'
5
5
  resources :syhostmodels
6
6
  resources :syhostmodeldetails
7
7
  end
@@ -20,7 +20,7 @@ module ForemanHosts
20
20
 
21
21
  # Add permissions
22
22
  security_block :foreman_hosts do
23
- permission :view_foreman_hosts, :'foreman_hosts/hosts' => [:report_index]
23
+
24
24
 
25
25
  permission :view_foreman_syhostmodels, :'foreman_hosts/syhostmodels' => [:index, :show, :auto_complete_search]
26
26
  permission :new_foreman_syhostmodels, :'foreman_hosts/syhostmodels' => [:new, :create]
@@ -29,13 +29,13 @@ module ForemanHosts
29
29
  end
30
30
 
31
31
  # Add a new role called 'Discovery' if it doesn't exist
32
- role 'ForemanHosts', [:view_foreman_hosts, :view_foreman_syhostmodels, :new_foreman_syhostmodels, :edit_foreman_syhostmodels, :delete_foreman_syhostmodels]
32
+ role 'ForemanHosts', [:view_foreman_syhostmodels, :new_foreman_syhostmodels, :edit_foreman_syhostmodels, :delete_foreman_syhostmodels]
33
33
 
34
34
  # add menu entry
35
35
 
36
36
  sub_menu :top_menu, :export_menu, :caption=> N_('Export'), :after=> :infrastructure_menu do
37
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 }
38
+ #menu :top_menu, :level2, :caption=>N_('ExportHosts'), :url_hash => { :controller => 'foreman_hosts/hosts', :action => :report_index }
39
39
  end
40
40
  # menu :top_menu, :template,
41
41
  # url_hash: { controller: :'foreman_hosts/hosts', action: :new_action },
@@ -1,3 +1,3 @@
1
1
  module ForemanHosts
2
- VERSION = '1.1.2'
2
+ VERSION = '1.1.3'
3
3
  end
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.2
4
+ version: 1.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -90,17 +90,11 @@ files:
90
90
  - app/views/foreman_hosts/syhostmodels/_list.html.erb
91
91
  - app/views/foreman_hosts/syhostmodels/_form.html.erb
92
92
  - app/views/foreman_hosts/syhostmodels/_sub.html.erb
93
- - app/views/foreman_hosts/hosts/export.xlsx.axlsx
94
- - app/views/foreman_hosts/hosts/report_index.html.erb
95
- - app/views/foreman_hosts/hosts/hosts/new_action.html.erb
96
93
  - app/assets/javascripts/jquery.battatech.excelexport.js
97
94
  - app/assets/javascripts/application.js
98
95
  - app/overrides/dashboard/index/sample_override.html.erb.deface
99
96
  - app/controllers/foreman_hosts/syhostmodeldetails_controller.rb
100
97
  - app/controllers/foreman_hosts/syhostmodels_controller.rb
101
- - app/controllers/foreman_hosts/hosts_controller.rb
102
- - app/helpers/concerns/foreman_hosts/hosts_helper_extensions.rb
103
- - app/models/concerns/foreman_hosts/hosts_extensions.rb
104
98
  - app/models/foreman_hosts/syhostmodeldetail.rb
105
99
  - app/models/foreman_hosts/syhostmodel.rb
106
100
  - bin/foreman-hosts
@@ -1,17 +0,0 @@
1
- module ForemanHosts
2
- # Example: Plugin's HostsController inherits from Foreman's HostsController
3
- class HostsController < ::HostsController
4
- # change layout if needed
5
- #layout 'foreman_hosts/layouts/new_layout'
6
-
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
16
- end
17
- end
@@ -1,20 +0,0 @@
1
- module ForemanHosts
2
- module HostsHelperExtensions
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- # execute callbacks
7
- end
8
-
9
- # create or overwrite instance methods...
10
- def instance_method_name
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
19
- end
20
- end
@@ -1,19 +0,0 @@
1
- module ForemanHosts
2
- module HostExtensions
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- # execute callbacks
7
- end
8
-
9
- # create or overwrite instance methods...
10
- def instance_method_name
11
- end
12
-
13
- module ClassMethods
14
- # create or overwrite class methods...
15
- def class_method_name
16
- end
17
- end
18
- end
19
- end
@@ -1,130 +0,0 @@
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
@@ -1 +0,0 @@
1
- Welcome to <b>ForemanHosts</b>
@@ -1,257 +0,0 @@
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>