foreman_hosts 1.1.5 → 1.1.6
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/lib/foreman_hosts/engine.rb
CHANGED
@@ -20,14 +20,14 @@ module ForemanHosts
|
|
20
20
|
|
21
21
|
# Add permissions
|
22
22
|
security_block :foreman_hosts do
|
23
|
-
permission :
|
24
|
-
permission :
|
25
|
-
permission :
|
26
|
-
permission :
|
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]
|
27
27
|
end
|
28
28
|
|
29
29
|
# Add a new role called 'Discovery' if it doesn't exist
|
30
|
-
role 'ForemanHosts', [:
|
30
|
+
role 'ForemanHosts', [:view_foreman_hosts, :new_foreman_hosts, :edit_foreman_hosts, :delete_foreman_hosts]
|
31
31
|
|
32
32
|
# add menu entry
|
33
33
|
sub_menu :top_menu, :export_menu, :caption=> N_('Export'), :after=> :infrastructure_menu do
|
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.
|
4
|
+
version: 1.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -79,8 +79,6 @@ files:
|
|
79
79
|
- app/views/foreman_hosts/syhostmodels/_sub.html.erb
|
80
80
|
- app/views/foreman_hosts/hosts/hosts/new_action.html.erb
|
81
81
|
- app/views/foreman_hosts/hosts/new_action.html.erb
|
82
|
-
- app/assets/javascripts/jquery.battatech.excelexport.js
|
83
|
-
- app/assets/javascripts/application.js
|
84
82
|
- app/overrides/dashboard/index/sample_override.html.erb.deface
|
85
83
|
- app/controllers/foreman_hosts/syhostmodeldetails_controller.rb
|
86
84
|
- app/controllers/foreman_hosts/syhostmodels_controller.rb
|
@@ -1,180 +0,0 @@
|
|
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);
|