mirror of
https://github.com/cmur2/openvpn-status-web.git
synced 2024-12-22 22:54:24 +01:00
Use a status object
This commit is contained in:
parent
cd6e41fcfa
commit
438931f8a6
@ -7,9 +7,9 @@ require 'yaml'
|
|||||||
require 'rack'
|
require 'rack'
|
||||||
require 'metriks'
|
require 'metriks'
|
||||||
|
|
||||||
|
require 'openvpn-status-web/status'
|
||||||
require 'openvpn-status-web/parser/v1'
|
require 'openvpn-status-web/parser/v1'
|
||||||
require 'openvpn-status-web/int_patch'
|
require 'openvpn-status-web/int_patch'
|
||||||
require 'openvpn-status-web/status'
|
|
||||||
require 'openvpn-status-web/version'
|
require 'openvpn-status-web/version'
|
||||||
|
|
||||||
module OpenVPNStatusWeb
|
module OpenVPNStatusWeb
|
||||||
@ -37,7 +37,7 @@ module OpenVPNStatusWeb
|
|||||||
main_tmpl = read_template(File.join(File.dirname(__FILE__), 'openvpn-status-web/main.html.erb'))
|
main_tmpl = read_template(File.join(File.dirname(__FILE__), 'openvpn-status-web/main.html.erb'))
|
||||||
# variables for template
|
# variables for template
|
||||||
name = @name
|
name = @name
|
||||||
client_list, routing_table, global_stats = read_status_log(@file)
|
status = read_status_log(@file)
|
||||||
|
|
||||||
html = main_tmpl.result(binding)
|
html = main_tmpl.result(binding)
|
||||||
[200, {"Content-Type" => "text/html"}, [html]]
|
[200, {"Content-Type" => "text/html"}, [html]]
|
||||||
|
@ -55,7 +55,7 @@ thead {
|
|||||||
<td class="last">Connected Since</td>
|
<td class="last">Connected Since</td>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% client_list.each do |client| %>
|
<% status.client_list.each do |client| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="first"><%= client[0] %></td>
|
<td class="first"><%= client[0] %></td>
|
||||||
<td class="middle"><%= client[1] %></td>
|
<td class="middle"><%= client[1] %></td>
|
||||||
@ -78,7 +78,7 @@ thead {
|
|||||||
<td class="last">Last Ref</td>
|
<td class="last">Last Ref</td>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% routing_table.each do |e| %>
|
<% status.routing_table.each do |e| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="first"><%= e[0] %></td>
|
<td class="first"><%= e[0] %></td>
|
||||||
<td class="middle"><%= e[1] %></td>
|
<td class="middle"><%= e[1] %></td>
|
||||||
@ -94,7 +94,7 @@ thead {
|
|||||||
<div>
|
<div>
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% global_stats.each do |e| %>
|
<% status.global_stats.each do |e| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= e[0] %>:</td>
|
<td><%= e[0] %>:</td>
|
||||||
<td><%= e[1] %></td>
|
<td><%= e[1] %></td>
|
||||||
|
@ -21,7 +21,11 @@ module OpenVPNStatusWeb
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
[client_list[2..-1], routing_table[1..-1], global_stats]
|
status = Status.new
|
||||||
|
status.client_list = client_list[2..-1]
|
||||||
|
status.routing_table = routing_table[1..-1]
|
||||||
|
status.global_stats = global_stats
|
||||||
|
status
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
module OpenVPNStatusWeb
|
||||||
|
class Status
|
||||||
|
attr_accessor :client_list
|
||||||
|
attr_accessor :routing_table
|
||||||
|
attr_accessor :global_stats
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user