pencil 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.rb CHANGED
@@ -1 +1 @@
1
- PENCIL_VERSION = "0.2.8"
1
+ PENCIL_VERSION = "0.2.9"
data/examples/pencil.yml CHANGED
@@ -13,7 +13,7 @@
13
13
  :margin: 5
14
14
  :thickness: 2
15
15
 
16
- :refresh_rate: false
16
+ :refresh_rate: 60
17
17
  :host_sort: "sensible"
18
18
  :quantum: 30 # map requests to 30 second intervals
19
19
  :date_format: "%X %x" # strftime
data/lib/dash.rb CHANGED
@@ -133,13 +133,11 @@ module Dash
133
133
  erb :host
134
134
  end
135
135
 
136
- # fixme make sure not to save shitty values for :start, :duration
137
- # remove stime, etime
138
- # there is definitely something wrong here
139
- # disallow saving from, until
136
+ # fixme make sure not to save shitty values for :start
140
137
  get '/saveprefs' do
141
138
  puts 'saving prefs'
142
- params.each do |k,v|
139
+ params.each do |k ,v|
140
+ next if [:etime, :stime, :duration].member?(k.to_sym)
143
141
  session[k] = v unless v.empty?
144
142
  end
145
143
  redirect URI.parse(request.referrer).path
data/lib/helpers.rb CHANGED
@@ -132,7 +132,8 @@ module Dash::Helpers
132
132
  session.merge(opts).delete_if { |k,v| static_opts.member?(k) || v.empty? }
133
133
  end
134
134
 
135
- def cluster_switcher
135
+ def cluster_switcher(clusters)
136
+ @clusters = clusters
136
137
  erb :'partials/cluster_switcher', :layout => false
137
138
  end
138
139
 
@@ -25,6 +25,7 @@ module Dash::Models
25
25
  @graphs << g if g
26
26
  end
27
27
 
28
+ @valid_hosts_table = {} # cache calls to get_valid_hosts
28
29
  end
29
30
 
30
31
  def clusters
@@ -45,12 +46,15 @@ module Dash::Models
45
46
  end
46
47
 
47
48
  def get_valid_hosts(graph, cluster=nil)
49
+ if @valid_hosts_table[[graph, cluster]]
50
+ return @valid_hosts_table[[graph, cluster]]
51
+ end
52
+
48
53
  clusters = Set.new
49
54
  if cluster
50
55
  hosts = Host.find_by_cluster(cluster)
51
56
  else
52
57
  hosts = Host.all
53
- hosts.each { |h| clusters << h.cluster }
54
58
  end
55
59
 
56
60
  # filter by what matches the graph definition
@@ -63,6 +67,7 @@ module Dash::Models
63
67
 
64
68
  hosts.each { |h| clusters << h.cluster }
65
69
 
70
+ @valid_hosts_table[[graph, cluster]] = [hosts, clusters]
66
71
  return hosts, clusters
67
72
  end
68
73
 
@@ -1,6 +1,6 @@
1
1
  <% hosts = @dash.get_valid_hosts(@zoom, @cluster)[0].sort %>
2
2
 
3
- <%= cluster_switcher %>
3
+ <%= cluster_switcher(@dash.clusters) %>
4
4
  <%= graph_switcher %>
5
5
  <%= graph_uplink %>
6
6
  <br>
@@ -1,4 +1,4 @@
1
- <%= cluster_switcher %>
1
+ <%= cluster_switcher(@dash.clusters) %>
2
2
  <%= dash_switcher %>
3
3
  <%= dash_uplink %>
4
4
  <br>
@@ -1,6 +1,6 @@
1
1
  <% hosts, clusters = @dash.get_valid_hosts(@zoom) %>
2
2
 
3
- <%= cluster_switcher %>
3
+ <%= cluster_switcher(@dash.clusters) %>
4
4
  <%= graph_switcher %>
5
5
  <%= graph_uplink %>
6
6
  <br>
@@ -1,6 +1,6 @@
1
1
  <% clusters = @dash.clusters %>
2
2
 
3
- <%= cluster_switcher %>
3
+ <%= cluster_switcher(clusters) %>
4
4
  <%= dash_switcher %>
5
5
  <%= dash_uplink %>
6
6
  <br>
data/lib/views/layout.erb CHANGED
@@ -33,7 +33,9 @@
33
33
  <% end %>
34
34
  Dashboards: (<%= @cluster %>)
35
35
  <br>
36
- <% @dashboards.sort.each do |dash| %>
36
+ <% @dashboards.select do |d|
37
+ @cluster == "global" || d.clusters.member?(@cluster)
38
+ end.sort.each do |dash| %>
37
39
  <li><a href="<%= dash_link(dash, @cluster) %>"><%= dash["title"] %></a></li>
38
40
  <% end %>
39
41
  <br>
@@ -1,5 +1,5 @@
1
1
  clusters:
2
- <%= settings.config.clusters.sort.collect do |c|
2
+ <%= @clusters.sort.collect do |c|
3
3
  sub = append_query_string(request.path.sub(@cluster, c))
4
4
  @cluster == c ? "#{c}" : "<a href=\"#{sub}\">#{c}</a>"
5
5
  end.join(" ") %>
@@ -1,6 +1,8 @@
1
1
  <span class="graphtitle">
2
2
  dashboards:
3
- <%= @dashboards.sort.collect do |d|
3
+ <%= @dashboards.select do |d|
4
+ @cluster == "global" || d.clusters.member?(@cluster)
5
+ end.sort.collect do |d|
4
6
  # this works unless you have a cluster with the same name as a dashboard
5
7
  sub = append_query_string(request.path.sub(@dash.name, d.name))
6
8
  @dash == d ? "#{d}" : "<a href=\"#{sub}\">#{d}</a>"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pencil
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 8
10
- version: 0.2.8
9
+ - 9
10
+ version: 0.2.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pete Fritchman
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-08-16 00:00:00 Z
19
+ date: 2011-08-17 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: mongrel