foreman_hosts 1.0.5 → 1.1.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 +1 -117
- data/app/assets/javascripts/application.js +2 -0
- data/app/assets/javascripts/jquery.battatech.excelexport.js +180 -0
- data/app/controllers/foreman_hosts/syhostmodeldetails_controller.rb +83 -0
- data/app/controllers/foreman_hosts/syhostmodels_controller.rb +83 -0
- data/app/models/foreman_hosts/syhostmodel.rb +8 -0
- data/app/models/foreman_hosts/syhostmodeldetail.rb +5 -0
- data/app/views/foreman_hosts/hosts/report_index.html.erb +188 -3
- data/app/views/foreman_hosts/syhostmodeldetails/_form.html.erb +29 -0
- data/app/views/foreman_hosts/syhostmodeldetails/_list.html.erb +43 -0
- data/app/views/foreman_hosts/syhostmodeldetails/_sygroup.html.erb +3 -0
- data/app/views/foreman_hosts/syhostmodeldetails/_sygroup_td.html.erb +7 -0
- data/app/views/foreman_hosts/syhostmodeldetails/create.js.erb +2 -0
- data/app/views/foreman_hosts/syhostmodeldetails/destroy.js.erb +1 -0
- data/app/views/foreman_hosts/syhostmodeldetails/edit.html.erb +1 -0
- data/app/views/foreman_hosts/syhostmodeldetails/edit.js.erb +3 -0
- data/app/views/foreman_hosts/syhostmodeldetails/index.html.erb +5 -0
- data/app/views/foreman_hosts/syhostmodeldetails/new.html.erb +1 -0
- data/app/views/foreman_hosts/syhostmodeldetails/new.js.erb +3 -0
- data/app/views/foreman_hosts/syhostmodeldetails/show.html.erb +28 -0
- data/app/views/foreman_hosts/syhostmodeldetails/update.js.erb +3 -0
- data/app/views/foreman_hosts/syhostmodels/_form.html.erb +30 -0
- data/app/views/foreman_hosts/syhostmodels/_list.html.erb +41 -0
- data/app/views/foreman_hosts/syhostmodels/_report.html.erb +258 -0
- 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/config/routes.rb +6 -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 +9 -10
- data/lib/foreman_hosts/version.rb +1 -1
- metadata +47 -3
- data/app/models/concerns/foreman_hosts/host_extensions.rb +0 -19
@@ -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
|
@@ -24,9 +24,13 @@
|
|
24
24
|
<tr>
|
25
25
|
<td class='ellipsis'><%= name_column(host) %></td>
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
+
|
30
34
|
|
31
35
|
</tr>
|
32
36
|
<% end %>
|
@@ -69,4 +73,185 @@
|
|
69
73
|
}
|
70
74
|
|
71
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
|
+
|
72
257
|
</script>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<%= javascript 'sygroups', 'sygroup_edit', 'sygroup_edit_interfaces', 'class_edit', 'compute_resource', 'lookup_keys'%>
|
2
|
+
|
3
|
+
<%= form_for(@sygroup, remote: true) do |f| %>
|
4
|
+
<%= base_errors_for @sygroup %>
|
5
|
+
<div class="row clearfix">
|
6
|
+
<div class="row">
|
7
|
+
<div class="form-group col-md-3">
|
8
|
+
<label>name</label>
|
9
|
+
<%= f.text_field :name, :size => "col-md-3", placeholder: "填写用户名", class: "form-control" %>
|
10
|
+
</div>
|
11
|
+
<div class="form-group col-md-3">
|
12
|
+
<label>ensure</label> <br />
|
13
|
+
<%= f.select :ensure, [['Please select an ensure', nil], 'present', 'absent', 'role'], placeholder: "ensure", control_label: 'ensure', class: "col-md-3 column form-control"%>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div class="form-group col-md-3">
|
17
|
+
<label>gid</label>
|
18
|
+
<%= f.text_field :gid, :size => "col-md-3", placeholder: "填写gid", class: "form-control" %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<div class="row">
|
22
|
+
<div class="actions">
|
23
|
+
<%= f.hidden_field :syusermodel_id, value: @sygroup.syusermodel_id %>
|
24
|
+
<%= f.submit "提交", class: "btn btn-success" %>
|
25
|
+
<%= link_to '返回', foreman_users_sygroups_path, class: "btn btn-primary" %>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
<% end %>
|
@@ -0,0 +1,43 @@
|
|
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">ensure</th>
|
8
|
+
<th class="hidden-xs">gid</th>
|
9
|
+
<th>操作</th>
|
10
|
+
</tr>
|
11
|
+
</thead>
|
12
|
+
<tbody>
|
13
|
+
<% sygroups.each do |sygroup| %>
|
14
|
+
<tr>
|
15
|
+
<td class=''><%= sygroup.name %></td>
|
16
|
+
<td class="hidden-xs"><%= sygroup.ensure %></td>
|
17
|
+
<td class="hidden-xs"><%= sygroup.gid %></td>
|
18
|
+
<td>
|
19
|
+
<%= link_to '查看', sygroup %>
|
20
|
+
<%= link_to '编辑', edit_foreman_users_sygroup_path(sygroup) %>
|
21
|
+
<%= link_to '删除', sygroup, method: :delete, data: { confirm: 'Are you sure?' } %>
|
22
|
+
</td>
|
23
|
+
</tr>
|
24
|
+
<% end %>
|
25
|
+
</tbody>
|
26
|
+
</table>
|
27
|
+
<div id="confirmation-modal" class="modal fade">
|
28
|
+
<div class="modal-dialog">
|
29
|
+
<div class="modal-content">
|
30
|
+
<div class="modal-header">
|
31
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
32
|
+
<h4 class="modal-title"><%= _('Please Confirm') %></h4>
|
33
|
+
</div>
|
34
|
+
<div class="modal-body">
|
35
|
+
</div>
|
36
|
+
<div class="modal-footer">
|
37
|
+
<button type="button" class="btn btn-default" data-dismiss="modal"><%= _('Cancel') %></button>
|
38
|
+
<button type="button" class="btn btn-primary" onclick="submit_modal_form()"><%= _('Submit') %></button>
|
39
|
+
</div>
|
40
|
+
</div><!-- /.modal-content -->
|
41
|
+
</div><!-- /.modal-dialog -->
|
42
|
+
</div><!-- /.modal -->
|
43
|
+
<%= will_paginate_with_info sygroups, :more => " - "+_("<b class='select_count'>0</b> selected") %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<td><%= sygroup.name %></td>
|
2
|
+
<td><%= sygroup.ensure %></td>
|
3
|
+
<td><%= sygroup.gid %></td>
|
4
|
+
<td>
|
5
|
+
<%= link_to '编辑', edit_foreman_users_sygroup_path(sygroup), remote: true %>
|
6
|
+
<%= link_to '删除', sygroup, method: :delete, remote: true, data: { confirm: 'Are you sure?' } %>
|
7
|
+
</td>
|
@@ -0,0 +1 @@
|
|
1
|
+
$("#sygroup-<%= @sygroup.id %>").fadeOut(200).remove();
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
<div class="container">
|
3
|
+
<div class="row">
|
4
|
+
<h1 class="clearfix">
|
5
|
+
<%= @sygroup.name %>
|
6
|
+
<%= link_to '返回', foreman_users_sygroup_path, class: "btn btn-primary pull-right mr1" %>
|
7
|
+
<%= link_to '编辑', edit_foreman_users_sygroup_path(@sygroup), class: "btn btn-warning pull-right mr1" %>
|
8
|
+
</h1>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="row col-md-12">
|
12
|
+
<table class="table table-striped table-bordered">
|
13
|
+
<thead></thead>
|
14
|
+
<tbody>
|
15
|
+
<tr>
|
16
|
+
<td><strong>name</strong></td>
|
17
|
+
<td><strong>ensure</strong></td>
|
18
|
+
<td><strong>gid</strong></td>
|
19
|
+
</tr>
|
20
|
+
<tr>
|
21
|
+
<td><%= @sygroup.name %></td>
|
22
|
+
<td><%= @sygroup.ensure %></td>
|
23
|
+
<td><%= @sygroup.gid %></td>
|
24
|
+
</tr>
|
25
|
+
</tbody>
|
26
|
+
</table>
|
27
|
+
</div>
|
28
|
+
</div>
|
@@ -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") %>
|