ref: refs/heads/master
commit ea534c6fa9f7a222d7cc0c3feb35a36e539d0abd
Author: Stefan Schubert
Date: Thu Jul 9 15:08:25 2009 +0200
just a backup
---
plugins/status/README | 7 +
plugins/status/Rakefile | 47 +
.../status/app/controllers/status_controller.rb | 89 +
plugins/status/app/helpers/status_helper.rb | 7 +
plugins/status/app/models/status.rb | 4 +
plugins/status/app/views/status/index.html.erb | 41 +
plugins/status/init.rb | 1 +
plugins/status/install.rb | 1 +
plugins/status/shortcuts.yml | 9 +
plugins/status/tasks/status_tasks.rake | 4 +
plugins/status/test/status_test.rb | 8 +
plugins/status/test/test_helper.rb | 3 +
plugins/status/uninstall.rb | 1 +
webclient/app/views/layouts/main.rhtml | 2 +-
webclient/public/images/spinner.gif | Bin 0 -> 3532 bytes
webclient/public/javascripts/jquery.jqplot.js | 2990 ++++++++++++++++++++
16 files changed, 3213 insertions(+), 1 deletions(-)
diff --git a/plugins/status/README b/plugins/status/README
new file mode 100644
index 0000000..3906624
--- /dev/null
+++ b/plugins/status/README
@@ -0,0 +1,7 @@
+Status
+============
+
+Plugin for showing system information like CPU, memorry, ....
+
+
+Copyright (c) 2009 Novell, released under the MIT license
diff --git a/plugins/status/Rakefile b/plugins/status/Rakefile
new file mode 100644
index 0000000..1ea727c
--- /dev/null
+++ b/plugins/status/Rakefile
@@ -0,0 +1,47 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+require 'rake/packagetask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the status plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the status plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'Status'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+desc 'Generate tarball package'
+Rake::PackageTask.new('www', :noversion) do |p|
+ %x[rm -r package/www]
+ p.need_tar_bz2 = true
+ p.package_dir = 'package'
+ p.package_files.include('**/*')
+ p.package_files.exclude('package')
+ p.package_files.exclude('locale')
+end
+
+desc "Create mo-files for L10n"
+task :makemo do
+ require 'gettext_rails/tools'
+ GetText.create_mofiles
+end
+
+desc "Update pot/po files to match new version."
+task :updatepo do
+ require 'gettext_rails/tools'
+ GetText.update_pofiles("yast_webclient_status", Dir.glob("{app,lib}/**/*.{rb,erb,rhtml}"),
+ "yast_webclient status 1.0.0")
+end
diff --git a/plugins/status/app/controllers/status_controller.rb b/plugins/status/app/controllers/status_controller.rb
new file mode 100644
index 0000000..a4cfc7f
--- /dev/null
+++ b/plugins/status/app/controllers/status_controller.rb
@@ -0,0 +1,89 @@
+require 'yast/service_resource'
+
+class StatusController < ApplicationController
+ before_filter :login_required
+ layout "main"
+
+ private
+ def client_permissions
+ @client = YaST::ServiceResource.proxy_for('org.opensuse.yast.system.status')
+ unless @client
+ flash[:notice] = _("Invalid session, please login again.")
+ redirect_to( logout_path ) and return
+ end
+ @permissions = @client.permissions
+ end
+
+ def create_data ( tree, label)
+ data_list = []
+ tree.attributes.each do |key, branch|
+ if key.start_with? ("t_")
+ data_list << branch.to_f
+ else
+ next_label = label
+ if key != "value"
+ next_label += "/" + key
+ end
+ data_list = create_data (branch, next_label)
+ if data_list.size > 0
+ @data[next_label] = data_list
+ data_list = []
+ end
+ end
+ end
+ return data_list
+ end
+
+ # Initialize GetText and Content-Type.
+ init_gettext "yast_webclient_status"
+
+ public
+ def initialize
+ end
+
+
+ def index
+ return unless client_permissions
+ @data = {}
+ status = []
+ begin
+ till = Time.new
+# from = till - 3600
+ from = till - 60
+
+ status = @client.find(:dummy_param, :params => { :start => from.strftime("%H:%M,%m/%d/%Y"), :stop => till.strftime("%H:%M,%m/%d/%Y") })
+ rescue ActiveResource::ClientError => e
+ flash[:error] = YaST::ServiceResource.error(e)
+ end
+
+ create_data ( status, "")
+
+ #grouping graphs to memory, cpu,...
+ @data_group = {}
+ @data.each do |key, list_value|
+ key_split = key.split("/")
+ if key_split.size > 1
+ group_map = {}
+ group_map = @data_group[key_split[1]] if @data_group.has_key? (key_split[1])
+ label_name = ""
+ for i in 2..key_split.size-1 do
+ if i==2
+ label_name = key_split[i]
+ else
+ label_name += "/" + key_split[i]
+ end
+ end
+ group_map[label_name] = list_value
+ @data_group[key_split[1]] = group_map
+ else
+ logger.error "empty key: #{@key} #{list.inspect}"
+ end
+ end
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @users }
+ end
+# return unless client_status
+ end
+end
diff --git a/plugins/status/app/helpers/status_helper.rb b/plugins/status/app/helpers/status_helper.rb
new file mode 100644
index 0000000..ad1a785
--- /dev/null
+++ b/plugins/status/app/helpers/status_helper.rb
@@ -0,0 +1,7 @@
+module StatusHelper
+ def graph id, width, height, last = false
+ html = "<div id='#{id}' style='width:#{width}px;height:#{height}px;float:left'><img src='/images/spinner.gif'></div>"
+ html += "<br style='clear: both'>" if last
+ return html
+ end
+end
diff --git a/plugins/status/app/models/status.rb b/plugins/status/app/models/status.rb
new file mode 100644
index 0000000..3621ed4
--- /dev/null
+++ b/plugins/status/app/models/status.rb
@@ -0,0 +1,4 @@
+require 'yast/service_resource'
+class Status < YaST::ServiceResource::Base
+
+end
diff --git a/plugins/status/app/views/status/index.html.erb b/plugins/status/app/views/status/index.html.erb
new file mode 100644
index 0000000..e85baee
--- /dev/null
+++ b/plugins/status/app/views/status/index.html.erb
@@ -0,0 +1,41 @@
+
+<h2>Status</h2>
+
+<%= graph("test_graph1", 400, 300, false) %>
+
+<%= graph("test_graph2", 400, 300, true) %>
+
+<script type="text/javascript">
+
+
+function plotLineGraph(graph_id, graph_title, graph_data ) {
+ $.jqplot(graph_id, graph_data, {
+ title: graph_title,
+ axes: {
+ xaxis: {
+ showTicks: false
+ },
+ yaxis: {
+ showTicks: false
+ }
+ },
+
+ series:[{color:'#5FAB78'}]
+ });
+}
+
+
+
+ function getDataAndPlotLineGraph(graph_id, graph_title) {
+ $('#' + graph_id).html("");
+ plotLineGraph(graph_id, graph_title, [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]]);
+ }
+
+
+ $(function() {
+ getDataAndPlotLineGraph('test_graph1', 'testing graph' );
+ getDataAndPlotLineGraph('test_graph2', 'testing graph' );
+
+ });
+</script>
+
diff --git a/plugins/status/init.rb b/plugins/status/init.rb
new file mode 100644
index 0000000..3c19a74
--- /dev/null
+++ b/plugins/status/init.rb
@@ -0,0 +1 @@
+# Include hook code here
diff --git a/plugins/status/install.rb b/plugins/status/install.rb
new file mode 100644
index 0000000..f7732d3
--- /dev/null
+++ b/plugins/status/install.rb
@@ -0,0 +1 @@
+# Install hook code here
diff --git a/plugins/status/shortcuts.yml b/plugins/status/shortcuts.yml
new file mode 100644
index 0000000..a381312
--- /dev/null
+++ b/plugins/status/shortcuts.yml
@@ -0,0 +1,9 @@
+main:
+ icon: '/images/monitoring.png'
+ url: /status
+ groups: [ Access ]
+ tags: [ access]
+ title: Status
+ description: Show system status
+ resources: [ status ]
+
diff --git a/plugins/status/tasks/status_tasks.rake b/plugins/status/tasks/status_tasks.rake
new file mode 100644
index 0000000..0858ee8
--- /dev/null
+++ b/plugins/status/tasks/status_tasks.rake
@@ -0,0 +1,4 @@
+# desc "Explaining what the task does"
+# task :status do
+# # Task goes here
+# end
diff --git a/plugins/status/test/status_test.rb b/plugins/status/test/status_test.rb
new file mode 100644
index 0000000..8206f39
--- /dev/null
+++ b/plugins/status/test/status_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class StatusTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
diff --git a/plugins/status/test/test_helper.rb b/plugins/status/test/test_helper.rb
new file mode 100644
index 0000000..cf148b8
--- /dev/null
+++ b/plugins/status/test/test_helper.rb
@@ -0,0 +1,3 @@
+require 'rubygems'
+require 'active_support'
+require 'active_support/test_case'
\ No newline at end of file
diff --git a/plugins/status/uninstall.rb b/plugins/status/uninstall.rb
new file mode 100644
index 0000000..9738333
--- /dev/null
+++ b/plugins/status/uninstall.rb
@@ -0,0 +1 @@
+# Uninstall hook code here
diff --git a/webclient/app/views/layouts/main.rhtml b/webclient/app/views/layouts/main.rhtml
index 996eb63..1cb1251 100644
--- a/webclient/app/views/layouts/main.rhtml
+++ b/webclient/app/views/layouts/main.rhtml
@@ -8,7 +8,7 @@
<script type="text/javascript" language="javascript" charset="utf-8" src="/inc/jquery.js"></script>
<script type="text/javascript" language="javascript" charset="utf-8" src="/inc/jquery.query.js"></script>
<script type="text/javascript" language="javascript" charset="utf-8" src="/inc/jquery.timers.js"></script>
-
+ <script type="text/javascript" language="javascript" charset="utf-8" src="/javascripts/jquery.jqplot.js"></script>
<script type="text/javascript" language="javascript" charset="utf-8" src="/inc/jquery.ui.custom.js"></script>
Reply