#--
# WebROaR - Ruby Application Server - http://webroar.in/
# Copyright (C) 2009 WebROaR
#
# This file is part of WebROaR.
#
# WebROaR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# WebROaR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with WebROaR. If not, see .
#++
# Methods added to this helper will be available to all view files for the admin controller.
module AdminHelper
#This method is used to populate the rows of application data in the configuration page.
#This method is called from configuration.html.erb.
def application_list(start = 0)
i = start
list_array = Array.new
index = 1
if (@info['Application Specification'])
while(@info['Application Specification'][i] and i < start+5)
application = ApplicationSpecification.get_hash(i)
if index == 1
bg_class = "BG_dark_gray"
index = 0
else
bg_class = "BG_white"
index = 1
end
str = "
#{h(application[:name])} |
#{h(application[:resolver])} |
#{h(application[:type1])} |
#{h(application[:analytics])} |
#{h(application[:environment])} |
#{h(application[:min_worker])} |
#{h(application[:max_worker])} |
#{link_to 'Edit', :controller => 'application_specification', :action => 'edit_application_form', :id => i} |
#{link_to_remote 'Delete', {:url => {:controller => 'application_specification', :action=>'delete_application', :id => i}, :before => "show_busy_div()", :complete => "hide_busy_div(request)", :update => "dummy_div", :confirm=>DELETE_APPLICATION_ALERT_MESSAGE, :oncontextmenu => 'return false;' }} |
#{link_to_remote 'Restart', {:url => {:controller => 'application_specification', :action => 'restart_application', :id => i}, :before => "show_busy_div()", :complete => "hide_busy_div(request)", :update => "dummy_div", :confirm=>RESTART_APPLICATION_ALERT_MESSAGE, :oncontextmenu => 'return false;'}} |
"
list_array[i] = str
i += 1
end
end
return list_array.join("\n")
end
#This method is used to populate the rows of application data on the Home page.
#This method is called from home.html.erb.
def application_list_home
i = 0
list_array = Array.new
index = 1
if (@info['Application Specification'])
while(@info['Application Specification'][i])
application = ApplicationSpecification.get_hash(i)
if @apps_resource_usage[application[:name]]
cpu_usage = @apps_resource_usage[application[:name]][0].to_s
memory_usage = format("%.2f",@apps_resource_usage[application[:name]][1]/1024).to_f
else
cpu_usage = 0.0.to_s
memory_usage = 0.0.to_s
end
if index == 1
bg_class = "BG_dark_gray"
index = 0
else
bg_class = "BG_white"
index = 1
end
exception_count = get_exceptions(application[:name]).size || 0
if exception_count > 0
link_text = "Yes (#{exception_count})"
exception_td_data = "
SSL Port
#{link_to_function('Help', :onclick => 'addHelp("ssl_port");')}
|
#{ssl_port} |
#{link_to_remote 'Edit', :update => 'ssl_port_div', :url => {:action => 'add_text_box', :div_id => 'ssl_port_div'}} |
SSL Certificate Path
#{link_to_function('Help', :onclick => 'addHelp("ssl_certificate");')}
|
#{certificate} |
#{link_to_remote 'Edit', :update => 'certificate_div', :url => {:action => 'add_text_box', :div_id => 'certificate_div'}} |
Machine key path
#{link_to_function('Help', :onclick => 'addHelp("ssl_key");')}
|
#{key} |
#{link_to_remote 'Edit', :update => 'key_div', :url => {:action => 'add_text_box', :div_id => 'key_div'}} |
"
else
block = block + "#{link_to_remote 'Enable', :update => 'ssl_div', :url => {:controller => 'server_specification', :action => 'ssl_support_form', :id => 1}}"
block = block + "
"
end
block = block + "#{if flash[:ssl_errors]
render :partial => 'server_specification/ssl_support_form'
end}