Class | ApplicationSpecificationController |
In: |
app/controllers/application_specification_controller.rb
|
Parent: | ApplicationController |
This action is to add the details of an application specification in the WebROaR config file. The data for an application specification is supplied as a hash from a add application specification form.
# File app/controllers/application_specification_controller.rb, line 49 49: def add_application 50: @application_specification = ApplicationSpecification.new(params[:application_specification]) 51: @analytics = %w{Disabled Enabled} if @application_specification.type1 == "Rails" 52: @analytics = %w{Disabled} if @application_specification.type1 != "Rails" 53: if @application_specification.save 54: @application_specification.write 55: app_name = params[:application_specification][:name] 56: #reply, err_obj = App.start(app_name) 57: reply, err_log = App.start(app_name) 58: # reply = nil indicate success 59: #if(err_obj) 60: # logger.warn err_obj 61: # logger.warn err_obj.backtrace 62: #end 63: flash[:server_message] = "Application '#{app_name}' started successfully." if reply == nil 64: set_error(reply, err_log) 65: render :js => "<script>self.top.location='#{configuration_path}'</script>" 66: else 67: render :partial => 'application_specification_form', :locals => {:type => 'Add'} 68: end 69: end
this action is to open a add application_specification form for adding a new application in the WebROaR config file.
This function also adds the default data to the application_specification form.
# File app/controllers/application_specification_controller.rb, line 28 28: def add_application_form 29: application_specification = ApplicationSpecification.get_hash 30: @analytics = %w{Disabled Enabled} 31: @application_specification = ApplicationSpecification.new(application_specification) 32: end
This action is to delete the application specification from the WebROaR config file.
This method requires the id of the application specification to be deleted.
# File app/controllers/application_specification_controller.rb, line 73 73: def delete_application 74: application_name = params[:id] 75: application_id = ApplicationSpecification.get_application_id_from_name(application_name) 76: app_name = ApplicationSpecification.delete(application_id) 77: reply, err_log = App.stop(app_name) 78: # reply = nil indicate success 79: flash[:server_message] = "Application '#{app_name}' deleted successfully." if reply == nil 80: set_error(reply, err_log) 81: render :js => "<script>self.top.location='#{configuration_path}'</script>" 82: end
The action save the changes made in the application specification via edit application specification form.
# File app/controllers/application_specification_controller.rb, line 85 85: def edit_application 86: @application_specification = ApplicationSpecification.new(params[:application_specification]) 87: @analytics = %w{Disabled Enabled} if @application_specification.type1 == "Rails" 88: @analytics = %w{Disabled} if @application_specification.type1 != "Rails" 89: if @application_specification.save 90: app_name = params[:id] 91: application_id = ApplicationSpecification.get_application_id_from_name(app_name) 92: @application_specification.update(application_id) 93: app_name = params[:application_specification][:name] 94: reply, err_log = App.restart(app_name) 95: # reply = nil indicate success 96: flash[:server_message] = "Application '#{app_name}' restarted successfully." if reply == nil 97: set_error(reply, err_log) 98: render :js => "<script>self.top.location='#{configuration_path}'</script>" 99: else 100: render :partial => 'application_specification_form', :locals => {:type => 'Edit'} 101: end 102: end
This action is used to open a edit application specification details form. This function retrives the values from the config file and then populate them in the edit application specification form.
# File app/controllers/application_specification_controller.rb, line 36 36: def edit_application_form 37: application_name = params[:id] 38: if !application_name.nil? 39: application_id = ApplicationSpecification.get_application_id_from_name(application_name) 40: application_specification = ApplicationSpecification.get_hash(application_id) 41: @application_specification = ApplicationSpecification.new(application_specification) 42: @analytics = %w{Disabled Enabled} if @application_specification.type1 == "Rails" 43: @analytics = %w{Disabled} if @application_specification.type1 != "Rails" 44: end 45: end
This method is to restart the application.
# File app/controllers/application_specification_controller.rb, line 105 105: def restart_application 106: sleep(2) 107: info= YAML::load_file(CONFIG_FILE_PATH) rescue nil 108: app_name = params[:id] 109: reply, err_log = App.restart(app_name) 110: # reply = nil indicate success 111: flash[:server_message] = "Application '#{app_name}' restarted successfully." if reply == nil 112: set_error(reply, err_log) 113: render :js => "<script>self.top.location='#{configuration_path}'</script>" 114: end