Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- i have to integrate these angular fusion charts in my present application can any one help me
- Hi if any one could solve plz mail to this id manu_urs143@yahoo.com plz help me
- this is my present application and this is running fine and my present requirement is i have to integrate fusion charts for my application
- this was the controller code
- class BatteryPowersController < ApplicationController
- include AuthenticatedSystem
- before_filter :login_required
- layout 'sites'
- #~ before_filter :battery_power_user_required
- #~ before_filter :require_for_update, :only => [:edit_battery, :update_battery]
- #~ before_filter :require_for_create, :only => [:new_battery, :create_battery]
- #~ before_filter :require_for_delete, :only => [:delete]
- #Tower CRUD Details
- def new_battery
- @site =Site.find(params[:site_id])
- @current_user = self.current_user
- @battery_power = BatteryPower.new
- @battery_power. site = @site
- @battery_power.user = @current_user
- end
- def edit_battery
- @current_user = self.current_user
- @site = Site.find(params[:site_id])
- @battery_power = BatteryPower.find(params[:id])
- end
- def create_battery
- @current_user = self.current_user
- @site = Site.find(params[:site_id])
- @battery_power = BatteryPower.new(params[:battery_power])
- @battery_power.user = @current_user
- @battery_power.site = @site
- if@battery_power.save
- redirect_to :controller=>'map'
- flash[:notice] ='Battery & Power details created succesfully.'
- else
- render :action => 'new_battery'
- end
- end
- def update_battery
- @current_user =self.current_user
- @site =Site.find(params[:site_id])
- @battery_power = BatteryPower.find(params[:id])
- @battery_power.user = @current_user
- @battery_power.site = @site
- if @battery_power.update_attributes(params[:battery_power])
- # Tracking update
- siteupdate = SiteUpdate.new
- siteupdate.user_id=current_user.id
- siteupdate.site_id=@site.id
- siteupdate.save
- render :action => 'show_battery'
- flash[:notice] ='Battery & Power updated succesfully.'
- else
- render :action =>'update_battery_power'
- end
- end
- def show_battery
- @current_user = self.current_user
- @site = Site.find(params[:site_id])
- @battery_power = BatteryPower.find(params[:id])
- @battery_power.user = @current_user
- @battery_power.site = @site
- @recents = RecentVisitor.find_all
- @last_updates = SiteUpdate.find(:all, :conditions=>["site_id=?",@site.id],:limit=>4,:order=>"created_at DESC")
- end
- protected
- #~ def battery_power_user_required
- #~ unless current_user.instance_of?(VendorUser) && current_user.vendor && (current_user.vendor.vendor_type_id.to_i == 4)
- #~ flash[:error] = "Only battery power User can perform this action"
- #~ redirect_to :controller => :map, :action => :index and return false
- #~ end
- #~ end
- #~ def require_for_update
- #~ unless [VendorUser::DESIGNATIONS[1], VendorUser::DESIGNATIONS[2], VendorUser::DESIGNATIONS[3]].include?(current_user.designation)
- #~ flash[:error] = "Only appropriate designation can perform this action"
- #~ redirect_to :controller => :map, :action => :index
- #~ end
- #~ end
- #~ def require_for_create
- #~ unless VendorUser::DESIGNATIONS[2] == current_user.designation
- #~ flash[:error] = "Only appropriate designation can perform this action"
- #~ redirect_to :controller => :map, :action => :index
- #~ end
- #~ end
- #~ def require_for_delete
- #~ unless [VendorUser::DESIGNATIONS[1], VendorUser::DESIGNATIONS[2]].include?(current_user.designation)
- #~ flash[:error] = "Only appropriate designation can perform this action"
- #~ redirect_to :controller => :map, :action => :index
- #~ end
- #~ end
- end
- this is model code
- class BatteryPower < ActiveRecord::Base
- belongs_to :site
- belongs_to :user
- end
- This was the code in db
- class CreateBatteryPowers < ActiveRecord::Migration
- def self.up
- create_table :battery_powers do |t|
- t.column :site_id, :integer
- t.column :user_id, :integer
- t.column :battery_type, :string
- t.column :battery_ampere_capacity, :string
- t.column :battery_no_of, :string
- t.column :battery_make, :string
- t.column :battery_installation_date, :date
- t.column :battery_check_date, :date
- t.column :battery_maint_carried_date, :date
- t.column :batttery_maint_time, :time
- t.column :battery_maint_cost, :string
- t.column :battery_maint_due_date, :date
- t.column :battery_maint_remarks, :string
- t.column :battery_life, :string
- end
- end
- def self.down
- drop_table :battery_powers
- end
- end
- These were the view code for create_battery
- <td> created battery & power scuccessfully </td>
- This was the view code for edit_battery
- <%= form_tag url_for (:controller =>"battery_powers", :action =>"update_battery", :site_id => @site.id, :id => @battery_power.id), :multipart => true %>
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td align="center" valign="top"><table width="1250" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
- <tr>
- <td valign="top"><div align="center">
- <table width="1200" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td height="25"> </td>
- </tr>
- <tr>
- <td><table width="1200" border="0" align="center" cellpadding="0" cellspacing="0">
- </table></td>
- </tr>
- <tr>
- <td valign="top">
- <table width="1200" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td valign="top"><table width="1200" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td width="1050" valign="top" ><table width="1050" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td valign="top" background="/images/sitedevelopment_color.gif"><table width="1050" border="0" cellspacing="1" cellpadding="0">
- <tr>
- <td valign="top" bgcolor="#FFFFFF"><table width="1050" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td class="tabcenterbg" valign="baseline"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td><p> </p></td>
- </tr>
- <tr>
- <td valign="top"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td width="18"><img src="/images/t_topleft.gif" alt="CSIP" width="18" height="25" /></td>
- <td valign="top" background="/images/t_topcenter.gif"><div align="left"><img src="/images/batterybank.gif" alt="Battery Bank" width="102" height="25" /></div></td>
- <td width="15"><img src="/images/t_topright.gif" alt="CSIP" width="15" height="25" /></td>
- </tr>
- <tr>
- <td background="/images/t_sideleft1.gif"> </td>
- <td valign="top"><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td colspan="3"> </td>
- <td width="43"> </td>
- <td width="417"> </td>
- <td width="141"> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Type of Batteries </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_type', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Ampere Hours Capacity </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_ampere_capacity', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">No.of. Batteried </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_no_of', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Make</div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_make', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Date of Installation </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_installation_date', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Checked on Date </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_check_date', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">
- <p><span class="news_txt">Maintenance </span><br />
- Carried Out Date </p>
- </div></td>
- <td><div align="center">:</div></td>
- <td><%= date_select 'battery_power', 'battery_maint_carried_date', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">
- <p>Time</p>
- </div></td>
- <td><div align="center">:</div></td>
- <td><%= time_select 'battery_power', 'batttery_maint_time', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">
- <p>Cost</p>
- </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_maint_cost', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Next Due Date </div></td>
- <td><div align="center">:</div></td>
- <td><%= date_select 'battery_power', 'battery_maint_due_date', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Remarks</div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_maint_cost', :class=>"multiinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="20" colspan="3"> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr>
- <td height="20" colspan="3"> </td>
- <td> </td>
- <td><input type="image" src="/images/create_button.gif" alt="create" width="89" height="22" onClick="this.form.submit();" /></td>
- <td> </td>
- </tr>
- </table></td>
- <td background="/images/t_sideright1.gif"> </td>
- </tr>
- <tr>
- <td><img src="/images/t_topbottom1.gif" width="18" height="14" /></td>
- <td height="14" background="/images/t_bottomcenter1.gif"><img src="/images/t_bottomcenter.gif" alt="/images/t_sideright.gif" width="1" height="14" /></td>
- <td><img src="/images/t_toprightbottom.gif" alt="/images/t_sideright.gif" width="15" height="14" /></td>
- </tr>
- </table></td>
- </tr>
- </table>
- <br />
- <br />
- <br />
- <br />
- <br />
- <br />
- <br />
- <br />
- </td>
- </tr>
- </table></td>
- </tr>
- </table></td>
- </tr>
- </table> <p> </p></td>
- <td> </td>
- <td valign="top"><div align="right"><img src="/images/add.gif" alt="Advertisement" width="120" height="600" /></div></td>
- </tr>
- </table></td>
- </tr>
- </table></td>
- </tr>
- </table>
- </div></td>
- </tr>
- </table></td>
- </tr>
- </table>
- <%= end_form_tag %>
- This was the view code for new_battery
- <%= form_tag url_for (:controller =>"battery_powers", :action =>"create_battery", :site_id => @site.id), :multipart => true %>
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td align="center" valign="top"><table width="1250" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
- <tr>
- <td valign="top"><div align="center">
- <table width="1200" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td height="25"> </td>
- </tr>
- <tr>
- <td><table width="1200" border="0" align="center" cellpadding="0" cellspacing="0">
- </table></td>
- </tr>
- <tr>
- <td valign="top">
- <table width="1200" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td valign="top"><table width="1200" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td width="1050" valign="top" ><table width="1050" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td valign="top" background="/images/sitedevelopment_color.gif"><table width="1050" border="0" cellspacing="1" cellpadding="0">
- <tr>
- <td valign="top" bgcolor="#FFFFFF"><table width="1050" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td class="tabcenterbg" valign="baseline"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td><p> </p></td>
- </tr>
- <tr>
- <td valign="top"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td width="18"><img src="/images/t_topleft.gif" alt="CSIP" width="18" height="25" /></td>
- <td valign="top" background="/images/t_topcenter.gif"><div align="left"><img src="/images/batterybank.gif" alt="Battery Bank" width="102" height="25" /></div></td>
- <td width="15"><img src="/images/t_topright.gif" alt="CSIP" width="15" height="25" /></td>
- </tr>
- <tr>
- <td background="/images/t_sideleft1.gif"> </td>
- <td valign="top"><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td colspan="3"> </td>
- <td width="43"> </td>
- <td width="417"> </td>
- <td width="141"> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Type of Batteries </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_type', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Ampere Hours Capacity </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_ampere_capacity', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">No.of. Batteried </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_no_of', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Make</div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_make', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Date of Installation </div></td>
- <td><div align="center">:</div></td>
- <td><%= date_select 'battery_power', 'battery_installation_date', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Checked on Date </div></td>
- <td><div align="center">:</div></td>
- <td><%= date_select 'battery_power', 'battery_check_date', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">
- <p><span class="news_txt">Maintenance </span><br />
- Carried Out Date </p>
- </div></td>
- <td><div align="center">:</div></td>
- <td><%= date_select 'battery_power', 'battery_maint_carried_date', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">
- <p>Time</p>
- </div></td>
- <td><div align="center">:</div></td>
- <td><%= time_select 'battery_power', 'batttery_maint_time', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">
- <p>Cost</p>
- </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_maint_cost', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Next Due Date </div></td>
- <td><div align="center">:</div></td>
- <td><%= date_select 'battery_power', 'battery_maint_due_date', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Remarks</div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_maint_cost', :class=>"multilineinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="20" colspan="3"> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr>
- <td height="20" colspan="3"> </td>
- <td> </td>
- <td><input type="image" src="/images/create_button.gif" alt="create" width="89" height="22" onClick="this.form.submit();"/></td>
- <td> </td>
- </tr>
- </table></td>
- <td background="/images/t_sideright1.gif"> </td>
- </tr>
- <tr>
- <td><img src="/images/t_topbottom1.gif" width="18" height="14" /></td>
- <td height="14" background="/images/t_bottomcenter1.gif"><img src="/images/t_bottomcenter.gif" alt="/images/t_sideright.gif" width="1" height="14" /></td>
- <td><img src="/images/t_toprightbottom.gif" alt="/images/t_sideright.gif" width="15" height="14" /></td>
- </tr>
- </table></td>
- </tr>
- </table>
- <br />
- <br />
- <br />
- <br />
- <br />
- <br />
- <br />
- <br />
- </td>
- </tr>
- </table></td>
- </tr>
- </table></td>
- </tr>
- </table> <p> </p></td>
- <td> </td>
- <td valign="top"><div align="right"><img src="/images/add.gif" alt="Advertisement" width="120" height="600" /></div></td>
- </tr>
- </table></td>
- </tr>
- </table></td>
- </tr>
- </table>
- </div></td>
- </tr>
- </table></td>
- </tr>
- </table>
- </body>
- </html>
- <%= end_form_tag %>
- This was the view code for show_battery
- <%= form_tag url_for (:controller =>"battery_powers", :action =>"create_battery", :site_id => @site.id), :multipart => true %>
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td align="center" valign="top"><table width="1250" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
- <tr>
- <td valign="top"><div align="center">
- <table width="1200" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td height="25"> </td>
- </tr>
- <tr>
- <td><table width="1200" border="0" align="center" cellpadding="0" cellspacing="0">
- </table></td>
- </tr>
- <tr>
- <td valign="top">
- <table width="1200" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td valign="top"><table width="1200" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td width="1050" valign="top" ><table width="1050" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td valign="top" background="/images/sitedevelopment_color.gif"><table width="1050" border="0" cellspacing="1" cellpadding="0">
- <tr>
- <td valign="top" bgcolor="#FFFFFF"><table width="1050" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td class="tabcenterbg" valign="baseline"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td><p> </p></td>
- </tr>
- <tr>
- <td valign="top"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td width="18"><img src="/images/t_topleft.gif" alt="CSIP" width="18" height="25" /></td>
- <td valign="top" background="/images/t_topcenter.gif"><div align="left"><img src="/images/batterybank.gif" alt="Battery Bank" width="102" height="25" /></div></td>
- <td width="15"><img src="/images/t_topright.gif" alt="CSIP" width="15" height="25" /></td>
- </tr>
- <tr>
- <td background="/images/t_sideleft1.gif"> </td>
- <td valign="top"><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td colspan="3"> </td>
- <td width="43"> </td>
- <td width="417"> </td>
- <td width="141"> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Type of Batteries </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_type', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Ampere Hours Capacity </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_ampere_capacity', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">No.of. Batteried </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_no_of', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Make</div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_make', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Date of Installation </div></td>
- <td><div align="center">:</div></td>
- <td><%= date_select 'battery_power', 'battery_installation_date', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Checked on Date </div></td>
- <td><div align="center">:</div></td>
- <td><%= date_select 'battery_power', 'battery_check_date', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">
- <p><span class="news_txt">Maintenance </span><br />
- Carried Out Date </p>
- </div></td>
- <td><div align="center">:</div></td>
- <td><%= date_select 'battery_power', 'battery_maint_carried_date', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">
- <p>Time</p>
- </div></td>
- <td><div align="center">:</div></td>
- <td><%= time_select 'battery_power', 'batttery_maint_time', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">
- <p>Cost</p>
- </div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_maint_cost', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Next Due Date </div></td>
- <td><div align="center">:</div></td>
- <td><%= date_select 'battery_power', 'battery_maint_due_date', :class=>"newinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="35" colspan="3"><div align="left">Remarks</div></td>
- <td><div align="center">:</div></td>
- <td><%= text_field 'battery_power', 'battery_maint_cost', :class=>"multilineinput" %></td>
- <td> </td>
- </tr>
- <tr>
- <td height="20" colspan="3"> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr>
- <td height="20" colspan="3"> </td>
- <td> </td>
- <td><input type="image" src="/images/create_button.gif" alt="create" width="89" height="22" onClick="this.form.submit();"/></td>
- <td> </td>
- </tr>
- </table></td>
- <td background="/images/t_sideright1.gif"> </td>
- </tr>
- <tr>
- <td><img src="/images/t_topbottom1.gif" width="18" height="14" /></td>
- <td height="14" background="/images/t_bottomcenter1.gif"><img src="/images/t_bottomcenter.gif" alt="/images/t_sideright.gif" width="1" height="14" /></td>
- <td><img src="/images/t_toprightbottom.gif" alt="/images/t_sideright.gif" width="15" height="14" /></td>
- </tr>
- </table></td>
- </tr>
- </table>
- <br />
- <br />
- <br />
- <br />
- <br />
- <br />
- <br />
- <br />
- </td>
- </tr>
- </table></td>
- </tr>
- </table></td>
- </tr>
- </table> <p> </p></td>
- <td> </td>
- <td valign="top"><div align="right"><img src="/images/add.gif" alt="Advertisement" width="120" height="600" /></div></td>
- </tr>
- </table></td>
- </tr>
- </table></td>
- </tr>
- </table>
- </div></td>
- </tr>
- </table></td>
- </tr>
- </table>
- </body>
- </html>
- <%= end_form_tag %>
- The problem is how can i integrate these angular fusion charts in my application they have to changed dynamically as soon i give the minimum and
- maximum values to it
- This was the code i found but i was unable to integrate this in my application can any one help me
- class Fusioncharts::FcExporterController < ApplicationController
- require 'fusioncharts/exporter/error_handler'
- require 'fusioncharts/exporter/properties'
- def index
- @fc_exporter= Fusioncharts::Exporter::FcExporter.new(params)
- target=@fc_exporter.exporttargetwindow
- filename = @fc_exporter.exportfilename
- exportaction = @fc_exporter.exportaction
- is_html = exportaction.eql?("download")
- validation_result = @fc_exporter.validate # Should return true if validated, or fc_error
- if(validation_result.kind_of?(Fusioncharts::Exporter::FcError) )
- print "%%%%% WArnings"+validation_result.warnings
- print "$$$$$ Errors="+validation_result.code2message
- Fusioncharts::Exporter::ErrorHandler.set_flash_err(validation_result,flash,is_html,@fc_exporter.meta)
- # Error has occurred, quit further processing
- redirect_to :action=>'error',:target=>target
- return
- end
- logger.info "Export Action="+ exportaction
- format = @fc_exporter.exportformat
- handler =@fc_exporter.format_handler(format.upcase)
- if(handler.kind_of?(Fusioncharts::Exporter::FcError))
- Fusioncharts::Exporter::ErrorHandler.set_flash_err(handler,flash,is_html,@fc_exporter.meta)
- # Error has occurred, quit further processing
- redirect_to :action=>'error',:target=>target
- return
- end
- export_object,fc_error=handler.process_export(@fc_exporter.stream,@fc_exporter.meta,format)
- if(fc_error.kind_of?(Fusioncharts::Exporter::FcError))
- Fusioncharts::Exporter::ErrorHandler.set_flash_err(fc_error,flash,is_html,@fc_exporter.meta)
- # Error has occurred, quit further processing
- redirect_to :action=>'error',:target=>target
- return
- end
- logger.info("Processed using the Format Handler. Proceeding to download/save...")
- ext =@fc_exporter.extension(format)
- if(exportaction=="download")
- mime_type = @fc_exporter.mime_type(ext)
- logger.info("Setting mime type as "+mime_type)
- headers["content-type"]=mime_type
- if(target.downcase == "_self")
- headers["Content-Disposition"]='attachment'
- else
- headers["Content-Disposition"]='inline'
- end
- headers["filename"]=" " + filename +"."+ ext
- send_data(export_object, {:type => mime_type, :stream => true, :filename => " " + filename +"."+ ext})
- #render :content_type => 'application/octet-stream', :text => Proc.new { |response, output|
- # do something that reads data and writes it to output
- #export_object
- #}
- #~ #Testing
- #~ f = File.open("C:/"+filename+"."+ext, 'wb');
- #~ f.write export_object
- #~ f.close
- else
- # Save on server
- complete_file_path,displayPath, notice = @fc_exporter.determine_path_to_save
- handler.write_to_file(complete_file_path)
- logger.info "Saved to location on server: "+displayPath
- meta_values=Fusioncharts::Exporter::ErrorHandler.meta2qs(@fc_exporter.meta,displayPath)
- render :text=>"statusCode=1&statusMessage=successful"+notice+meta_values
- end
- end
- # This action will render the errors, shows the error.html.erb which contains flash[:notice] and flash[:error]
- # To build the error message as response, build_error_response method from Fusioncharts::Exporter::ErrorHandler is used
- def error
- target = params[:target]
- headers["Content-type"]="text/html"
- if(target.downcase == "_self")
- headers["Content-Disposition"]='attachment'
- else
- headers["Content-Disposition"]='inline'
- end
- logger.info("Rendering Error Page")
- end
- end
- this is in lib folder
- # Contains method to help build the error message
- class Fusioncharts::Exporter::ErrorHandler
- # Sets the errors in flash object. These flash messages can later be output in error view page
- # This method should ideally be called only once in the program execution. When an error occurs and the program halts and wants to show the error
- def self.set_flash_err(fc_error,flash,is_html,meta,fileName=nil)
- error_msgs = is_html ? fc_error.error2html : fc_error.error2qs
- warning_msgs= is_html ? fc_error.warnings2html : fc_error.warnings2qs
- flash[:notice]=warning_msgs
- flash[:error]=error_msgs
- separator = (is_html ? "<br>" : "&")
- meta_new = meta
- if(!fc_error.empty?)
- # This means error has occured, hence statusCode=0
- # Values for width and height are 0 in case of error. FileName is empty.
- width ="0"
- height="0"
- displayPath=""
- meta_new.update({"width"=>width,"height"=>height})
- else
- # status code =1
- flash[:error]+=separator+"statusCode=1"
- # Values for width and height in case of success. FileName is path to the file on server.
- displayPath =Fusioncharts::Exporter::Properties.HTTP_URI.gsub!(/\/$/, '') + "/" +fileName
- end
- # Whether success or failure, add file URI , width and height and DomId when status success
- flash[:error]+= is_html ? meta2html(meta_new,displayPath) : meta2qs(meta_new,displayPath)
- end
- # Builds the query string starting with & for meta values
- def self.meta2qs(meta,fileNameWithPath)
- meta_values=""
- if(!fileNameWithPath.nil?)
- meta_values+="&fileName="+fileNameWithPath
- end
- meta_values+= "&width=" +meta ["width"]
- meta_values+= "&height=" +meta ["height"]
- meta_values+= "&DOMId=" +meta ["DOMId"]
- return meta_values
- end
- def self.meta2html(meta,fileNameWithPath)
- meta_values=""
- if(!fileNameWithPath.nil?)
- meta_values="<br>fileName="+fileNameWithPath
- end
- meta_values+= "<br>width=" +meta ["width"]
- meta_values+= "<br>height=" +meta ["height"]
- meta_values+= "<br>DOMId=" +meta ["DOMId"]
- return meta_values
- end
- end
- class Fusioncharts::Exporter::ErrorMessages
- @@err_messages={"E100"=> "Insufficient Data.",
- "E101" => "Width/height not provided.",
- "E102" => "Insufficient export parameters.",
- "E400" => "Bad Request.",
- "E401"=> "Unauthorized Access.",
- "E403"=> "Access Forbidden.",
- "E404" => "Export Resource not found.",
- "E507" => "Insufficient Storage.",
- "E508" => "Server Directory does not exist.",
- "W509" => "File already exists.",
- "W510" => "Export handler's Overwrite setting is on. Trying to overwrite.",
- "E511" => "Overwrite forbidden. File cannot be overwritten."
- }
- def self.get_error_message(error_code)
- err_message = @@err_messages[error_code.to_s]
- return err_message
- end
- end
- class Fusioncharts::Exporter::FcError
- #TODO Change this to attr_accessor
- attr_reader :warn_codes,:err_code
- @@err_messages={
- "E100"=> "Insufficient Data.",
- "E101" => "Width/height not provided.",
- "E102" => "Insufficient export parameters.",
- "E400" => "Bad Request.",
- "E401"=> "Unauthorized Access.",
- "E403"=> "Access Forbidden.",
- "E404" => "Export Resource not found.",
- "E507" => "Insufficient Storage.",
- "E508" => "Server Directory does not exist.",
- "W509" => "File already exists.",
- "W510" => "Export handler's Overwrite setting is on. Trying to overwrite.",
- "E511" => "Overwrite forbidden. File cannot be overwritten.",
- "E512" => "Intelligent File Naming is Turned off",
- "W513" => " Background color not specified. Taking White (FFFFF) as default background color.",
- "E514" => " Error while creating binary data.",
- "E515" => " Problem creating the image. Please verify that RMagick is installed correctly.",
- "E516" => " Problem creating the PDF data. Please verify that Zlib is installed correctly."
- }
- def initialize(ierror_code="",warning_codes=Array.new)
- @err_code = ierror_code
- @warn_codes = warning_codes
- end
- def warning_codes
- return @warn_codes
- end
- def error_code
- return @err_code
- end
- def warnings
- warning_msgs=""
- 0.upto(@warn_codes.length-1) do |i|
- message = Fusioncharts::Exporter::FcError.warning_message(@warn_codes[i])
- if(message == nil or message.empty?)
- message = "Could not find warning message for "+ @warn_codes[i]
- end
- # This is just a warning/notice
- warning_msgs+=message
- end
- return warning_msgs
- end
- def add_warning(warning_code)
- @warn_codes << warning_code
- end
- def set_error_code(ierror_code)
- @err_code = ierror_code
- end
- #Gets the error message for a particular code, returns nil if not found
- def code2message()
- err_message = @@err_messages["E"+@err_code.to_s]
- return err_message
- end
- def empty?
- return @err_code.nil? || @err_code.empty? || @err_code==""
- end
- def no_warnings?
- return @warn_codes.empty?
- end
- def error2qs
- error_str=""
- if(@err_code==nil or @err_code.empty?)
- error_str+="&statusMessage=successful&statusCode=1"
- else
- error_str+="&statusMessage="+code2message+"&statusCode=0"
- end
- return error_str
- end
- def warnings2qs
- error_str = "¬ice="+warnings
- return error_str
- end
- def error2html
- error_str = ""
- if(@err_code==nil or @err_code.empty?)
- error_str+="<br>statusMessage=successful<br>statusCode=1"
- else
- error_str+="<br>statusMessage="+code2message+"<br>statusCode=0"
- end
- return error_str
- end
- def warnings2html
- error_str = "<br>notice="+warnings
- return error_str
- end
- def to_qs
- error_str = warnings2qs
- error_str+=error2qs
- end
- def to_html
- error_str = warnings2html
- error_str+=error2html
- end
- #Gets the error message for a particular code, returns nil if not found
- def self.code2message(err_code)
- err_message = @@err_messages[err_code.to_s]
- return err_message
- end
- def self.warning_message(warning_code)
- message = code2message("W"+warning_code)
- return message
- end
- end
- class Fusioncharts::Exporter::FcExporter
- @@default_parameter_values = {"exportfilename"=>"FusionCharts", "exportaction"=>"download", "exporttargetwindow"=>"_self", "exportformat"=>"PDF"}
- @@mime_list = {"jpg"=>"image/jpeg", "jpeg"=>"image/jpeg", "png"=>"image/png", "pdf"=>"application/pdf"}
- @@ext_list = {"jpg"=>"jpg", "jpeg"=>"jpg", "png"=>"png","pdf"=>"pdf"}
- # Can access these attributes
- attr_reader :parsed_params
- attr_reader :exportfilename,:exportaction,:exportformat,:exporttargetwindow
- attr_reader :meta
- # Note: Not providing an accessor for stream, as this will be huge data, instead defining a method
- def initialize(params)
- @params = params
- @parsed_params = parse_export_request_stream
- @exportfilename = @parsed_params['parameters']['exportfilename']
- @exportaction = @parsed_params['parameters']['exportaction']
- @exportformat = @parsed_params['parameters']['exportformat']
- @exporttargetwindow = @parsed_params['parameters']['exporttargetwindow']
- #@parsed_params['parameters']['exportcallback']='FC_Exported'
- @meta = @parsed_params['meta']
- end
- # All exceptions need to be handled in the caller
- def validate
- result=true
- validation_result=validate_parameters
- if(validation_result.kind_of?(Fusioncharts::Exporter::FcError) && !validation_result.empty?)
- return validation_result
- end
- #export_action = @parsed_params['parameters']['exportaction']
- if(!@exportaction.eql?("download"))
- validation_result=validate_for_save(@exportfilename,@exportformat.downcase)
- if(validation_result.kind_of?(Fusioncharts::Exporter::FcError) && !validation_result.empty?)
- return validation_result
- end
- end
- return result
- end
- # Check if width, height and stream parameters are in order
- def validate_parameters
- validation_result = true
- validation_error = Fusioncharts::Exporter::FcError.new
- if(@params[:meta_bgColor].nil?)
- validation_error.add_warning("513")
- validation_result =false
- end
- if(@params[:stream].nil?)
- validation_result =false
- validation_error.set_error_code("100")
- elsif(@params[:meta_width].nil? or @params[:meta_height].nil? or @params[:meta_width].eql?("0") or @params[:meta_height].eql?("0"))
- validation_result =false
- validation_error.set_error_code("101")
- end
- return validation_result ? validation_result : validation_error
- end
- # Check if server is ready for save action
- def validate_for_save(filename,extension)
- #TODO Check if SAVEPATH ends with / otherwise append /
- abs_path = File.expand_path(Fusioncharts::Exporter::Properties.SAVEPATH)
- server_save_status= Fusioncharts::Exporter::SaveHelper.check_server_save_status(abs_path,filename+"."+extension,Fusioncharts::Exporter::Properties.OVERWRITEFILE,Fusioncharts::Exporter::Properties.INTELLIGENTFILENAMING)
- return server_save_status
- end
- def parse_export_request_stream
- #String of compressed data
- #Get all export parameters
- #get width and height of the chart
- #Background color of chart
- meta_hash = {"width"=>@params[:meta_width],
- "height"=>@params[:meta_height],
- "bgColor"=>@params[:meta_bgColor],
- "DOMId"=>@params[:meta_DOMId]}
- export_data = {"stream"=>@params[:stream],
- "parameters"=>parse_params(@params[:parameters]),
- "meta"=>meta_hash}
- return export_data
- end
- def parse_params(str_params)
- params_values = bang str_params
- @@default_parameter_values.update(params_values)
- return @@default_parameter_values
- end
- def bang(parameters_str)
- delimiter_list = ["|","="]
- ret_hash = Hash.new([].freeze)
- parameters_str.split(delimiter_list[0]).each do |pairs|
- key, value = pairs.split('=',2).collect{|v| CGI::unescape(v) }
- if value!=nil && !value.empty?
- ret_hash[key.downcase] = value
- end
- end
- return ret_hash
- end
- def format_handler(str_format)
- fc_error=nil
- exporter_klass=nil
- if(Fusioncharts::Exporter::Properties.HANDLERASSOCIATIONSHASH[str_format] != nil)
- exporter_suffix = Fusioncharts::Exporter::Properties.HANDLERASSOCIATIONSHASH[str_format]
- else
- exporter_suffix = str_format
- end
- class_name_str = ((Fusioncharts::Exporter::Properties.RESOURCEPATH+Fusioncharts::Exporter::Properties.EXPORTHANDLER+ (exporter_suffix.downcase)).camelize)
- # Check if Corresponding Resource Handler Class is present
- if(class_exists?(class_name_str))
- class_name= class_name_str.constantize
- exporter_klass=class_name.new
- else
- #error_codes="E404,"
- fc_error=Fusioncharts::Exporter::FcError.new("404")
- end
- return exporter_klass==nil ? fc_error : exporter_klass
- #Object.const_get(Fusioncharts::Exporter::Properties.BASEPACKAGE).const_get(Fusioncharts::Exporter::Properties.EXPORTERPACKAGE).const_get((Fusioncharts::Exporter::Properties.EXPORTHANDLER + exporter_suffix.downcase).camelize).new
- end
- # Before calling this method, validate should have been called. This method does not validate for save again
- def determine_path_to_save
- filename = @exportfilename
- format = @exportformat
- ext=format.downcase
- notice ="¬ice="
- #logger.info "Saving to file on server"
- # Save File on server
- folder_to_save = File.expand_path(Fusioncharts::Exporter::Properties.SAVEPATH)
- #build filepath
- complete_file_path = File.join(folder_to_save,filename +"." + ext)
- #folder_to_save + '/' + filename +"." + ext
- displayFileName = filename +"." + ext
- #Check if file exists and create new filename
- if(FileTest.exists?(complete_file_path))
- notice += " File already exists."
- if( !Fusioncharts::Exporter::Properties.OVERWRITEFILE)
- notice+= " Using intelligent naming of file by adding an unique suffix to the exising name."
- # create new filename
- complete_file_path= Fusioncharts::Exporter::SaveHelper.generate_unique_filename(folder_to_save + '/' + filename ,ext)
- displayFileName=File.basename(complete_file_path)
- notice+= "The filename has changed to "+displayFileName
- end
- end
- #logger.info "Saving to location "+complete_file_path
- http_path = Fusioncharts::Exporter::Properties.HTTP_URI.gsub!(/\/$/, '')
- if(http_path==nil)
- http_path = Fusioncharts::Exporter::Properties.HTTP_URI
- end
- displayPath= File.join(http_path,displayFileName)
- return complete_file_path,displayPath,notice
- end
- def mime_type(ext)
- m_type =ext
- if(@@mime_list[ext] != nil)
- m_type = @@mime_list[ext]
- end
- return m_type
- end
- def extension(format)
- ext = format.downcase
- if(@@ext_list[ext] != nil)
- ext = @@ext_list[ext]
- end
- return ext
- end
- def stream
- return @parsed_params["stream"]
- end
- private
- def class_exists?(class_name_str)
- begin
- true if class_name_str.constantize
- rescue NameError
- false
- end
- end
- end
- =begin
- Copyright (c) 2009 Infosoft Global Private Limited
- =end
- class Fusioncharts::Exporter::FcExporterImg
- require 'fusioncharts/exporter/generator'
- #FusionCharts Exporter - IMAGE Class
- #version 2.0 [ 19 February 2009]
- # Function to handle the export process
- def process_export(stream,meta,format)
- fc_error = nil
- @image=nil
- #ext = format.downcase
- @image=nil
- begin
- image_generator = Fusioncharts::Exporter::Generator::ImageGenerator.new(stream, meta["width"].to_i, meta["height"].to_i, meta["bgColor"],format)
- @image=image_generator.get_image
- rescue Exception => e
- print "Exception occurred="+e.to_s
- fc_error= Fusioncharts::Exporter::FcError.new("515")
- end
- return @image!=nil ? @image.to_blob : @image,fc_error!=nil ? fc_error : true
- end
- def write_to_file(fileName)
- @image.write(fileName)
- end
- end
- =begin
- Copyright (c) 2009 Infosoft Global Private Limited
- =end
- class Fusioncharts::Exporter::FcExporterPdf
- require 'fusioncharts/exporter/generator'
- #FusionCharts Exporter - PDF Class
- #version 2.0 [ 05 March 2009 ] - Added error handling, restructured the code.
- #version 1.0 [ 03 March 2009] - Converted from controller to ruby class
- # Function to handle the export process
- def process_export(stream,meta,format)
- fc_error=nil
- @pdf_binary=nil
- begin
- fc_exporter = Fusioncharts::Exporter::Generator::PDFGenerator.new(stream, meta["width"].to_i, meta["height"].to_i, meta["bgColor"])
- # Parameter whether to compress the data or not
- @pdf_binary=fc_exporter.get_pdf_objects(true)
- #logger.info "PDF Binary created"
- rescue Exception => e
- print "Exception occurred="+e.to_s
- fc_error= Fusioncharts::Exporter::FcError.new("516")
- end
- return @pdf_binary,fc_error!=nil ? fc_error : true
- end
- def write_to_file(fileName)
- f = File.open(fileName, 'wb');
- f.write @pdf_binary
- f.close
- end
- end
- =begin
- Copyright (c) 2009 Infosoft Global Private Limited
- =end
- module Fusioncharts::Exporter::Generator
- class PDFGenerator
- require 'zlib'
- # attr :image_data
- # attr :width
- # attr :height
- # attr :bgcolor
- # attr :compress
- # Instance Methods
- # ----------------
- def initialize(image_data,width,height,bgcolor)
- # @image_data=image_data
- # @width=width
- # @height=height
- # @bgcolor=bgcolor
- @pages_data=[]
- @pageIndex=0
- if(image_data!=nil and width!=nil and height!=nil)
- set_bitmap_data(image_data, width, height, bgcolor)
- else
- # raise error
- end
- end
- def set_bitmap_data(imageData_FCFormat, width, height, bgcolor="ffffff")
- @pages_data[@pageIndex]= {:width=>width,:height=>height,:bgcolor=>bgcolor,:image_data=>imageData_FCFormat}
- @pageIndex = @pageIndex+1
- end
- def get_pdf_objects(compress=true)
- @compress = compress
- pdf_bytes =""
- #Store all PDF objects in this temporary string to be written to ByteArray
- str_tmp_obj=""
- xref_list=[]
- xref_index =0
- #start xref array
- xref_list[xref_index]="xref\n0 "
- xref_index+=xref_index
- xref_list[xref_index]="0000000000 65535 f \n" #Address Refenrece to obj 0
- xref_index+=xref_index
- #Build PDF objects sequentially
- #version and header
- str_tmp_obj="%PDF-1.3\n%{FC}\n"
- pdf_bytes+=str_tmp_obj
- #OBJECT 1 : info (optional)
- str_tmp_obj="1 0 obj<<\n/Author (FusionCharts)\n/Title (FusionCharts)\n/Creator (FusionCharts)\n>>\nendobj\n"
- xref_list[xref_index]=calculate_xpos(pdf_bytes.length) #refenrece to obj 1
- xref_index+=xref_index
- pdf_bytes+=str_tmp_obj
- #OBJECT 2 : Starts with Pages Catalogue
- str_tmp_obj="2 0 obj\n<< /Type /Catalog /Pages 3 0 R >>\nendobj\n"
- xref_list[xref_index]=calculate_xpos(pdf_bytes.length) #refenrece to obj 2
- xref_index+=xref_index
- pdf_bytes+=str_tmp_obj
- #OBJECT 3 : Page Tree (reference to pages of the catalogue)
- str_tmp_obj="3 0 obj\n<< /Type /Pages /Kids ["
- 0.upto(@pageIndex-1) do|i|
- str_tmp_obj+=(((i+1)*3)+1).to_s+" 0 R\n"
- end
- str_tmp_obj+="] /Count "+@pageIndex.to_s+" >>\nendobj\n"
- xref_list[xref_index]=calculate_xpos(pdf_bytes.length) #refenrece to obj 3
- xref_index+=xref_index
- pdf_bytes+=str_tmp_obj
- 0.upto(@pageIndex-1) do|itr|
- width=@pages_data[itr][:width].to_s
- height=@pages_data[itr][:height].to_s
- #OBJECT 4..7..10..n : Page config
- str_tmp_obj=(((itr+2)*3)-2).to_s+" 0 obj\n<<\n/Type /Page /Parent 3 0 R \n/MediaBox [ 0 0 "+width+" "+height+" ]\n/Resources <<\n/ProcSet [ /PDF ]\n/XObject <</R"+(itr+1).to_s+" "+((itr+2)*3).to_s+" 0 R>>\n>>\n/Contents [ "+(((itr+2)*3)-1).to_s+" 0 R ]\n>>\nendobj\n"
- xref_list[xref_index]=calculate_xpos(pdf_bytes.length) #refenrece to obj 4,7,10,13,16...
- xref_index+=xref_index
- pdf_bytes+=str_tmp_obj
- #OBJECT 5...8...11...n : Page resource object (xobject resource that transforms the image)
- xref_list[xref_index]=calculate_xpos(pdf_bytes.length) #refenrece to obj 5,8,11,14,17...
- xref_index+=xref_index
- pdf_bytes+=get_xobj_resource(itr);
- #OBJECT 6...9...12...n : Binary xobject of the page (image)
- img_BA=add_image_to_pdf(itr,@compress)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement