uwa_sysload 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ module UWA
4
4
  module Widget
5
5
  class SysLoad < UWA::Handler
6
6
  NAME = 'uwa_sysload'
7
- VERSION = '0.2'
7
+ VERSION = '0.3'
8
8
  COPYRIGHT = 'Copyright (C) 2007 Florent Solt'
9
9
  DESC = 'UWA System Load Monitor widget'
10
10
  AUTHOR = 'Florent Solt'
@@ -14,7 +14,12 @@ class SysLoad
14
14
  end
15
15
 
16
16
  def values
17
- @values << File.read('/proc/loadavg').split.first
17
+ if @test # set through config
18
+ @values = [ 0.5.to_f ]
19
+ 1.upto(200) { @values << @values.last.to_f + (rand(200) / 1000.to_f - 0.1.to_f)}
20
+ else
21
+ @values << File.read('/proc/loadavg').split.first
22
+ end
18
23
  count = @query['count'].to_i
19
24
  count = @values.size if count > @values.size
20
25
  @values = @values[-(count)..-1]
data/resources/bg.gif ADDED
Binary file
@@ -1,6 +1,7 @@
1
- widget.bar_width = 2
1
+ widget.bar_width = 2;
2
2
  widget.graph = widget.createElement('div');
3
3
  widget.graph.className = 'graph';
4
+ widget.graph.style.backgroundImage = 'url(' + widget.remoteUrl + 'resource/bg.gif)';
4
5
 
5
6
  widget.onLoad = function() {
6
7
  widget.setBody(widget.graph);
@@ -10,15 +11,19 @@ widget.onLoad = function() {
10
11
 
11
12
  widget.onValues = function(values) {
12
13
  widget.graph.empty();
14
+ var max_height = 100;
13
15
  for (var i = 0; i < values.length; i++) {
14
16
  var bar = widget.createElement('div');
15
17
  bar.className = 'bar';
16
- bar.style.height = values[i] * 100 + 'px';
17
- bar.style.left = i * widget.bar_width + 'px';
18
- bar.style.width = widget.bar_width + 'px';
19
- bar.style.opacity = values[i];
18
+ var height = values[i] * 100;
19
+ bar.setStyle('height', height.toFixed(0) + 'px');
20
+ max_height = height > max_height ? height : max_height;
21
+ bar.setStyle('left', i * widget.bar_width + 'px');
22
+ bar.setStyle('width', widget.bar_width + 'px');
23
+ bar.setStyle('opacity', values[i]);
20
24
  bar.appendText = '&nbsp;';
21
25
  widget.graph.appendChild(bar);
22
26
  }
27
+ widget.graph.setStyle('height', max_height.toFixed(0) + 'px');
23
28
  }
24
29
 
@@ -1,9 +1,9 @@
1
1
  .graph {
2
- height: 100px;
3
2
  margin: 0px;
4
3
  padding: 0px;
5
4
  border: 0px;
6
5
  position: relative;
6
+ background-position: bottom left;
7
7
  }
8
8
 
9
9
  .graph .bar {
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: uwa_sysload
5
5
  version: !ruby/object:Gem::Version
6
- version: "0.2"
7
- date: 2007-04-02 00:00:00 +02:00
6
+ version: "0.3"
7
+ date: 2007-04-03 00:00:00 +02:00
8
8
  summary: UWA System Load Monitor widget
9
9
  require_paths:
10
10
  - lib
@@ -31,8 +31,9 @@ authors:
31
31
  files:
32
32
  - lib/uwa_sysload/config.rb
33
33
  - lib/uwa_sysload/widget.rb
34
- - ressources/script.js
35
- - ressources/style.css
34
+ - resources/script.js
35
+ - resources/style.css
36
+ - resources/bg.gif
36
37
  test_files: []
37
38
 
38
39
  rdoc_options: []