diff --git a/app/controllers/charts_controller.rb b/app/controllers/charts_controller.rb index b1253a7..19b6457 100644 --- a/app/controllers/charts_controller.rb +++ b/app/controllers/charts_controller.rb @@ -1,5 +1,6 @@ class ChartsController < ApplicationController before_filter :require_user, :only => [:edit] + def edit # params[:id] is the windows ID @channel = current_user.channels.find(params[:channel_id]) @@ -22,7 +23,6 @@ class ChartsController < ApplicationController end def index - set_channels_menu @channel = Channel.find(params[:channel_id]) @channel_id = params[:channel_id] @@ -35,8 +35,12 @@ class ChartsController < ApplicationController check_permissions(@channel) end - def show + # show a chart with multiple series + def multiple_series + render :layout => false + end + def show # allow these parameters when creating feed querystring feed_params = ['key', 'api_key', 'apikey', 'days','start','end','round','timescale','average','median','sum','results','location','status','timezone'] @@ -66,7 +70,6 @@ class ChartsController < ApplicationController render :layout => false end - # save chart options def update @channel = Channel.find(params[:channel_id]) diff --git a/app/controllers/plugins_controller.rb b/app/controllers/plugins_controller.rb index 3dde1df..2c64c7a 100644 --- a/app/controllers/plugins_controller.rb +++ b/app/controllers/plugins_controller.rb @@ -8,13 +8,14 @@ class PluginsController < ApplicationController respond_with_error(:error_auth_required) and return if current_user.blank? || (@plugin.user_id != current_user.id) end + def new; ; end + def edit; ; end + def index @plugins = current_user.plugins - end def public_plugins - channel_id = params[:channel_id].to_i return if channel_id.nil? #private page should display all plugins @@ -24,7 +25,6 @@ class PluginsController < ApplicationController plugins.each do |plugin| plugin.make_windows channel_id, api_domain #will only make the window the first time @plugin_windows = @plugin_windows + plugin.public_dashboard_windows(channel_id) - end respond_to do |format| @@ -53,9 +53,21 @@ class PluginsController < ApplicationController def create # add plugin with defaults @plugin = Plugin.new - @plugin.html = read_file('app/views/plugins/default.html') - @plugin.css = read_file('app/views/plugins/default.css') - @plugin.js = read_file('app/views/plugins/default.js') + + # set default template + template = 'default' + + # use case statement to set template, since user input is untrusted + case params[:template] + when 'gauge' then template = 'gauge' + when 'chart' then template = 'chart' + end + + # set template dynamically + @plugin.html = read_file("app/views/plugins/templates/#{template}.html") + @plugin.css = read_file("app/views/plugins/templates/#{template}.css") + @plugin.js = read_file("app/views/plugins/templates/#{template}.js") + @plugin.user_id = current_user.id @plugin.private_flag = true @plugin.save @@ -82,7 +94,6 @@ class PluginsController < ApplicationController end def show_public - @plugin = Plugin.find(params[:id]) @output = @plugin.html.sub('%%PLUGIN_CSS%%', @plugin.css).sub('%%PLUGIN_JAVASCRIPT%%', @plugin.js) if @plugin.private? @@ -100,9 +111,6 @@ class PluginsController < ApplicationController end end - def edit - end - def update @plugin.update_attribute(:name, params[:plugin][:name]) @plugin.update_attribute(:private_flag, params[:plugin][:private_flag]) @@ -111,11 +119,9 @@ class PluginsController < ApplicationController @plugin.update_attribute(:html,params[:plugin][:html]) if @plugin.save - @plugin.update_all_windows redirect_to plugins_path and return end - end def ajax_update diff --git a/app/views/charts/multiple_series.html.erb b/app/views/charts/multiple_series.html.erb new file mode 100644 index 0000000..a216b79 --- /dev/null +++ b/app/views/charts/multiple_series.html.erb @@ -0,0 +1,136 @@ + + + + + + + + + + +
+ <%= image_tag 'ajax-loader.gif', :style => "position: absolute; margin: auto; top: 0; left: 0; right: 0; bottom: 0;" %> +
+ + + diff --git a/app/views/plugins/edit.html.erb b/app/views/plugins/edit.html.erb index dea2bac..cf3234e 100644 --- a/app/views/plugins/edit.html.erb +++ b/app/views/plugins/edit.html.erb @@ -14,7 +14,7 @@ .CodeMirror-scroll { height: 300px; } -
+