Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add a graph edit page with form to UI.

  • Loading branch information...
commit 11105037c49c869261adb7e404830c03d5fb4f86 1 parent 2a537ae
@echohead authored
View
5 lib/collectd-plot.rb
@@ -59,6 +59,11 @@ def rrd_reader
RRDRead.rrd_graph(opts[:host], opts[:metric], opts[:instance], 1335739560, 1335740560, opts[:value])
end
+ # form to customize a graph
+ get '/graph_edit' do
+ respond_with :graph_edit, :params, :params => params
+ end
+
# return rrd graph
get '/hosts/:h/metric/:m/instance/:i/graph' do |h, m, i|
content_type 'image/png'
View
2  lib/collectd-plot/helpers.rb
@@ -23,6 +23,8 @@ def respond_with(name, json_key, data)
when 'application/json'
content_type :json
halt data[json_key].to_json
+ when 'text/csv'
+ raise "CSV not yet implemented"
else
content_type :html
halt haml(name, :locals => data)
View
5 lib/collectd-plot/public/stylesheets/screen.css
@@ -36,7 +36,6 @@ div#header {
border-bottom: 2px solid #C5D6ED;
background-color: #3465a4;
background: -moz-linear-gradient(100% 100% 90deg, #244671, #4C94F0);
-/* background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#4C94F0), to(#244671)); */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#555555), to(#222222));
-moz-box-shadow: -7px 0 7px rgba(0,0,0,0.4);
-webkit-box-shadow: -7px 0 7px rgba(0,0,0,0.4);
@@ -285,10 +284,10 @@ div#shortcuts table th {
-webkit-border-radius: 5px;
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
- background-color: #637020;
+ background-color: #000000;
background-repeat: repeat-x;
background: -moz-linear-gradient(100% 100% 90deg, #244671, #4C94F0);
- background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#4C94F0), to(#244671));
+ background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#555555), to(#222222));
border: medium none;
color: white;
cursor: pointer;
View
1  lib/collectd-plot/rrd_read.rb
@@ -44,7 +44,6 @@ def self.rrd_data(host, metric, instance, start, stop)
def self.in_temp_file
f = Tempfile.new('collectd-plot')
-puts f.path
res = yield f.path
File.delete f.path
res
View
54 lib/collectd-plot/views/graph_edit.haml
@@ -0,0 +1,54 @@
+
+%table
+ %tbody
+ %tr
+ %td
+ %h4 Perma-link to this plot:&nbsp&nbsp
+ %td
+ %a{:href => link_to("/graph", {:host => locals[:params]['host'], :metric => locals[:params]['metric'], :instance => locals[:params]['instance']})}
+ link
+%hr
+%br
+
+%table
+ %tbody
+ %tr
+ %td
+ %a{:href => link_to("/graph_edit", {:host => locals[:params]['host'], :metric => locals[:params]['metric'], :instance => locals[:params]['instance']})}
+ %img{:src => link_to("/graph", {:host => locals[:params]['host'], :metric => locals[:params]['metric'], :instance => locals[:params]['instance']})}
+%br
+%br
+%hr
+%br
+
+%h4 Customize this plot:
+
+%form{:action => '/graph_edit', :method => 'get'}
+ %table
+ %tbody
+ %tr
+ %td
+ %label{:for => "host"} host:
+ %td
+ %input{:type => "text", :name => "host", :class => "text", :value => locals[:params][:host]}
+
+ %tr
+ %td
+ %label{:for => "metric"} metric:
+ %td
+ %input{:type => "text", :name => "metric", :class => "text", :value => locals[:params][:metric]}
+
+ %tr
+ %td
+ %label{:for => "instance"} instance:
+ %td
+ %input{:type => "text", :name => "instance", :class => "text", :value => locals[:params][:instance]}
+
+ %tr
+ %td
+ %input{:type => "submit", :value => "Update", :class => "button"}
+
+
+%br
+%br
+
View
2  lib/collectd-plot/views/metric.haml
@@ -6,5 +6,5 @@
%td
%a{:href => link_to("/hosts/#{locals[:host]}/metric/#{locals[:metric]}/instance/#{i}/graph")}= i
%td
- %a{:href => link_to("/graph", {:host => locals[:host], :metric => locals[:metric], :instance => i})}
+ %a{:href => link_to("/graph_edit", {:host => locals[:host], :metric => locals[:metric], :instance => i})}
%img{:src => link_to("/graph", {:host => locals[:host], :metric => locals[:metric], :instance => i})}
View
4 spec/spec_helper.rb
@@ -18,3 +18,7 @@ def app
def get_json(path)
get(path, {}, {'HTTP_ACCEPT' => 'application/json'})
end
+
+def get_csv(path)
+ get(path, {}, {'HTTP_ACCEPT' => 'application/csv'})
+end
Please sign in to comment.
Something went wrong with that request. Please try again.