ref: refs/heads/master
commit 263394b065ed9da2117efbc538f21ba350ce95d2
Author: Duncan Mac-Vicar P
Date: Wed Sep 9 18:14:35 2009 +0200
use defined logs in the server
---
.../status/app/controllers/status_controller.rb | 23 ++++++++++++++
.../status/app/views/status/_status_log.html.erb | 4 ++
plugins/status/app/views/status/index.html.erb | 31 ++++++++++++++++++++
3 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/plugins/status/app/controllers/status_controller.rb b/plugins/status/app/controllers/status_controller.rb
index 87d1189..b0530b3 100644
--- a/plugins/status/app/controllers/status_controller.rb
+++ b/plugins/status/app/controllers/status_controller.rb
@@ -1,6 +1,9 @@
require 'yast/service_resource'
+require 'open-uri'
class StatusController < ApplicationController
+ include ProxyLoader
+
before_filter :login_required
layout "main"
@@ -137,8 +140,28 @@ class StatusController < ApplicationController
create_data
end
+ def ajax_log_custom
+ # set the site to the view so it can load the log
+ # dynamically
+ if not params.has_key?(:id)
+ raise "Unknown log file"
+ end
+
+ lines = params[:lines] || 5
+ log_url = YaST::ServiceResource::Session.site
+ log_url = log_url.merge("logs/#{params[:id]}.txt?lines=#{lines}")
+ logger.info "requesting #{log_url}"
+ @content = open(log_url).read
+ render :partial => 'status_log'
+ end
+
def index
return unless client_permissions
+
+ log = YaST::ServiceResource.proxy_for('org.opensuse.yast.system.logs')
+ #log = load_proxy 'org.opensuse.yast.system.logs'
+ @logs = log.find(:all)
+
create_data
limits_reached
logger.debug "limits reached for #{@limits_list[:reached].inspect}"
diff --git a/plugins/status/app/views/status/_status_log.html.erb b/plugins/status/app/views/status/_status_log.html.erb
new file mode 100644
index 0000000..9eaecb8
--- /dev/null
+++ b/plugins/status/app/views/status/_status_log.html.erb
@@ -0,0 +1,4 @@
+
+<pre>
+<%= @content %>
+</pre>
diff --git a/plugins/status/app/views/status/index.html.erb b/plugins/status/app/views/status/index.html.erb
index af9b8b3..e961575 100644
--- a/plugins/status/app/views/status/index.html.erb
+++ b/plugins/status/app/views/status/index.html.erb
@@ -1,11 +1,42 @@
+
+<% content_for :head do %>
+<script type="text/javascript">
+
+function refreshLogs() {
+
+<% @logs.each do |log| %>
+ $('#log-<%= log.id %>-console').load('/status/ajax_log_custom?id=<%= log.id %>&lines=5');
+<% end %>
+}
+
+$(document).ready(function() {
+ $.ajaxSetup ({
+ cache: false
+ });
+ //$('#log-console').addClass('busy');
+ setInterval(refreshLogs, 10000); // refresh every 10 seconds
+});
+
+</script>
+<% end %>
+
<div class='plugin-icon'><img src='/images/monitoring.png'/></div>
<div class='plugin-content'>
<h2><%=_("Status")%></h2>
<h3><%= _("Events") %></h3>
+<% @logs.each do |log| %>
+<h2><%= log.description %></h2>
+
+</div>
+<% end %>
+<div id="log-console">
+</div>
+
<% column = 1 %>
<% @data_group.keys.sort.each do |key| %>
<% map = @data_group[key]%>
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org