foreman_hosts 2.0.4.7 → 2.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/concerns/foreman_hosts/{host_extensions.rb → hosts_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/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 +10 -11
- data/lib/foreman_hosts/version.rb +1 -1
- metadata +47 -2
@@ -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") %>
|
@@ -0,0 +1,258 @@
|
|
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
|
+
/*
|
78
|
+
* jQuery Client Side Excel Export Plugin Library
|
79
|
+
* http://www.battatech.com/
|
80
|
+
*
|
81
|
+
* Copyright (c) 2013 Batta Tech Private Limited
|
82
|
+
* Licensed under https://github.com/battatech/battatech_excelexport/blob/master/LICENSE.txt
|
83
|
+
*/
|
84
|
+
|
85
|
+
(function ($) {
|
86
|
+
var $defaults = {
|
87
|
+
containerid: null
|
88
|
+
, datatype: 'table'
|
89
|
+
, dataset: null
|
90
|
+
, columns: null
|
91
|
+
, returnUri: false
|
92
|
+
, worksheetName: "Sheet1"
|
93
|
+
, encoding: "utf-8"
|
94
|
+
};
|
95
|
+
|
96
|
+
var $settings = $defaults;
|
97
|
+
|
98
|
+
$.fn.battatech_excelexport = function (options) {
|
99
|
+
$settings = $.extend({}, $defaults, options);
|
100
|
+
|
101
|
+
var gridData = [];
|
102
|
+
var excelData;
|
103
|
+
|
104
|
+
return Initialize();
|
105
|
+
|
106
|
+
function Initialize() {
|
107
|
+
var type = $settings.datatype.toLowerCase();
|
108
|
+
|
109
|
+
BuildDataStructure(type);
|
110
|
+
|
111
|
+
switch (type) {
|
112
|
+
case 'table':
|
113
|
+
excelData = Export(ConvertFromTable());
|
114
|
+
break;
|
115
|
+
case 'json':
|
116
|
+
excelData = Export(ConvertDataStructureToTable());
|
117
|
+
break;
|
118
|
+
case 'xml':
|
119
|
+
excelData = Export(ConvertDataStructureToTable());
|
120
|
+
break;
|
121
|
+
case 'jqgrid':
|
122
|
+
excelData = Export(ConvertDataStructureToTable());
|
123
|
+
break;
|
124
|
+
}
|
125
|
+
|
126
|
+
if ($settings.returnUri) {
|
127
|
+
return excelData;
|
128
|
+
}
|
129
|
+
else {
|
130
|
+
window.open(excelData);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
function BuildDataStructure(type) {
|
135
|
+
switch (type) {
|
136
|
+
case 'table':
|
137
|
+
break;
|
138
|
+
case 'json':
|
139
|
+
gridData = $settings.dataset;
|
140
|
+
break;
|
141
|
+
case 'xml':
|
142
|
+
$($settings.dataset).find("row").each(function (key, value) {
|
143
|
+
var item = {};
|
144
|
+
|
145
|
+
if (this.attributes != null && this.attributes.length > 0) {
|
146
|
+
$(this.attributes).each(function () {
|
147
|
+
item[this.name] = this.value;
|
148
|
+
});
|
149
|
+
|
150
|
+
gridData.push(item);
|
151
|
+
}
|
152
|
+
});
|
153
|
+
break;
|
154
|
+
case 'jqgrid':
|
155
|
+
$($settings.dataset).find("rows > row").each(function (key, value) {
|
156
|
+
var item = {};
|
157
|
+
|
158
|
+
if (this.children != null && this.children.length > 0) {
|
159
|
+
$(this.children).each(function () {
|
160
|
+
item[this.tagName] = $(this).text();
|
161
|
+
});
|
162
|
+
|
163
|
+
gridData.push(item);
|
164
|
+
}
|
165
|
+
});
|
166
|
+
break;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
function ConvertFromTable() {
|
171
|
+
var result = $('<div>').append($('#' + $settings.containerid).clone()).html();
|
172
|
+
return result;
|
173
|
+
}
|
174
|
+
|
175
|
+
function ConvertDataStructureToTable() {
|
176
|
+
var result = "<table>";
|
177
|
+
|
178
|
+
result += "<thead><tr>";
|
179
|
+
$($settings.columns).each(function (key, value) {
|
180
|
+
if (this.ishidden != true) {
|
181
|
+
result += "<th";
|
182
|
+
if (this.width != null) {
|
183
|
+
result += " style='width: " + this.width + "'";
|
184
|
+
}
|
185
|
+
result += ">";
|
186
|
+
result += this.headertext;
|
187
|
+
result += "</th>";
|
188
|
+
}
|
189
|
+
});
|
190
|
+
result += "</tr></thead>";
|
191
|
+
|
192
|
+
result += "<tbody>";
|
193
|
+
$(gridData).each(function (key, value) {
|
194
|
+
result += "<tr>";
|
195
|
+
$($settings.columns).each(function (k, v) {
|
196
|
+
if (value.hasOwnProperty(this.datafield)) {
|
197
|
+
if (this.ishidden != true) {
|
198
|
+
result += "<td";
|
199
|
+
if (this.width != null) {
|
200
|
+
result += " style='width: " + this.width + "'";
|
201
|
+
}
|
202
|
+
result += ">";
|
203
|
+
result += value[this.datafield];
|
204
|
+
result += "</td>";
|
205
|
+
}
|
206
|
+
}
|
207
|
+
});
|
208
|
+
result += "</tr>";
|
209
|
+
});
|
210
|
+
result += "</tbody>";
|
211
|
+
|
212
|
+
result += "</table>";
|
213
|
+
return result;
|
214
|
+
}
|
215
|
+
|
216
|
+
function Export(htmltable) {
|
217
|
+
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'>";
|
218
|
+
excelFile += "<head>";
|
219
|
+
excelFile += '<meta http-equiv="Content-type" content="text/html;charset=' + $defaults.encoding + '" />';
|
220
|
+
excelFile += "<!--[if gte mso 9]>";
|
221
|
+
excelFile += "<xml>";
|
222
|
+
excelFile += "<x:ExcelWorkbook>";
|
223
|
+
excelFile += "<x:ExcelWorksheets>";
|
224
|
+
excelFile += "<x:ExcelWorksheet>";
|
225
|
+
excelFile += "<x:Name>";
|
226
|
+
excelFile += "{worksheet}";
|
227
|
+
excelFile += "</x:Name>";
|
228
|
+
excelFile += "<x:WorksheetOptions>";
|
229
|
+
excelFile += "<x:DisplayGridlines/>";
|
230
|
+
excelFile += "</x:WorksheetOptions>";
|
231
|
+
excelFile += "</x:ExcelWorksheet>";
|
232
|
+
excelFile += "</x:ExcelWorksheets>";
|
233
|
+
excelFile += "</x:ExcelWorkbook>";
|
234
|
+
excelFile += "</xml>";
|
235
|
+
excelFile += "<![endif]-->";
|
236
|
+
excelFile += "</head>";
|
237
|
+
excelFile += "<body>";
|
238
|
+
excelFile += htmltable.replace(/"/g, '\'');
|
239
|
+
excelFile += "</body>";
|
240
|
+
excelFile += "</html>";
|
241
|
+
|
242
|
+
var uri = "data:application/vnd.ms-excel;base64,";
|
243
|
+
var ctx = { worksheet: $settings.worksheetName, table: htmltable };
|
244
|
+
|
245
|
+
return (uri + base64(format(excelFile, ctx)));
|
246
|
+
}
|
247
|
+
|
248
|
+
function base64(s) {
|
249
|
+
return window.btoa(unescape(encodeURIComponent(s)));
|
250
|
+
}
|
251
|
+
|
252
|
+
function format(s, c) {
|
253
|
+
return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; });
|
254
|
+
}
|
255
|
+
};
|
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/config/routes.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
|
3
|
+
namespace :foreman_hosts do
|
4
|
+
match 'report_index', to: 'hosts#report_index'
|
5
|
+
resources :syhostmodels
|
6
|
+
resources :syhostmodeldetails
|
7
|
+
end
|
5
8
|
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
|