foreman_hosts 2.0.2 → 2.0.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.
@@ -46,13 +46,6 @@
46
46
  <th>fact_name</th>
47
47
  </thead>
48
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
49
  </tbody>
57
50
  </table>
58
51
  </div>
@@ -63,7 +56,7 @@
63
56
  <div class="tab-pane" id="previews">
64
57
  <div id="previews">
65
58
  <div class="panel-body">
66
- <%#= render partial: "foreman_hosts/syhostmodels/report", locals: { details: @syhostmodel.syhostmodeldetails} %>
59
+
67
60
  </div>
68
61
  </div>
69
62
  </div>
data/config/routes.rb CHANGED
@@ -3,6 +3,5 @@ Rails.application.routes.draw do
3
3
 
4
4
  namespace :foreman_hosts do
5
5
  resources :syhostmodels
6
- resources :syhostmodeldetails
7
6
  end
8
7
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanHosts
2
- VERSION = '2.0.2'
2
+ VERSION = '2.0.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: 2.0.2
4
+ version: 2.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -55,28 +55,23 @@ files:
55
55
  - app/views/foreman_hosts/layouts/new_layout.html.erb
56
56
  - app/views/foreman_hosts/syhostmodels/edit.html.erb
57
57
  - app/views/foreman_hosts/syhostmodels/new.html.erb
58
- - app/views/foreman_hosts/syhostmodels/_report.html.erb
59
58
  - app/views/foreman_hosts/syhostmodels/show.html.erb
60
59
  - app/views/foreman_hosts/syhostmodels/index.html.erb
61
60
  - app/views/foreman_hosts/syhostmodels/_list.html.erb
62
61
  - app/views/foreman_hosts/syhostmodels/_form.html.erb
63
- - app/views/foreman_hosts/syhostmodels/_sub.html.erb
64
62
  - app/views/foreman_hosts/hosts/export.xlsx.axlsx
65
63
  - app/views/foreman_hosts/hosts/report_index.html.erb
66
64
  - app/views/foreman_hosts/hosts/hosts/new_action.html.erb
67
65
  - app/views/foreman_hosts/hosts/new_action.html.erb
68
66
  - app/overrides/dashboard/index/sample_override.html.erb.deface
69
- - app/controllers/foreman_hosts/syhostmodeldetails_controller.rb
70
67
  - app/controllers/foreman_hosts/syhostmodels_controller.rb
71
68
  - app/controllers/foreman_hosts/hosts_controller.rb
72
69
  - app/helpers/concerns/foreman_hosts/hosts_helper_extensions.rb
73
70
  - app/models/concerns/foreman_hosts/host_extensions.rb
74
- - app/models/foreman_hosts/syhostmodeldetail.rb
75
71
  - app/models/foreman_hosts/syhostmodel.rb
76
72
  - bin/foreman-hosts
77
73
  - config/routes.rb
78
74
  - db/migrate/20151015022411_create_syhostmodels.rb
79
- - db/migrate/20151015050239_create_syhostmodeldetails.rb
80
75
  - lib/tasks/foreman_hosts_tasks.rake
81
76
  - lib/foreman_hosts.rb
82
77
  - lib/foreman_hosts/version.rb
@@ -1,83 +0,0 @@
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
@@ -1,5 +0,0 @@
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
@@ -1,258 +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
- <% 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>
@@ -1,37 +0,0 @@
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>
@@ -1,13 +0,0 @@
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