Project

General

Profile

Download (1.27 KB) Statistics
| Branch: | Tag: | Revision:
017e1049 Ohad Levy
require 'foreman/controller/environments'

6e50fa1d Ohad Levy
class EnvironmentsController < ApplicationController
1c4e9d45 Ohad Levy
include Foreman::Controller::Environments
8104eced Ohad Levy
include Foreman::Controller::AutoCompleteSearch
bee8f73b Ohad Levy
b6e0cb16 Ohad Levy
before_filter :find_by_name, :only => %w{show edit update destroy}
0c96d0bf Ohad Levy
5f6b2196 Paul Kelly
def index
8104eced Ohad Levy
values = Environment.search_for(params[:search], :order => params[:order])
0c96d0bf Ohad Levy
respond_to do |format|
d9a2ebac Ohad Levy
format.html do
@environments = values.paginate :page => params[:page]
@counter = Host.count(:group => :environment_id, :conditions => {:environment_id => @environments})
end
8104eced Ohad Levy
format.json { render :json => values.as_json }
0c96d0bf Ohad Levy
end
5f6b2196 Paul Kelly
end

def show
0c96d0bf Ohad Levy
respond_to do |format|
format.html { invalid_request }
format.json { render :json => @environment.as_json(:include => :hosts)}
end
5f6b2196 Paul Kelly
end

def new
@environment = Environment.new
end

def create
@environment = Environment.new(params[:environment])
if @environment.save
b28fdce4 Ohad Levy
process_success
5f6b2196 Paul Kelly
else
b28fdce4 Ohad Levy
process_error
5f6b2196 Paul Kelly
end
end

def edit
end
392a9112 Paul Kelly
5f6b2196 Paul Kelly
def update
if @environment.update_attributes(params[:environment])
b28fdce4 Ohad Levy
process_success
5f6b2196 Paul Kelly
else
b28fdce4 Ohad Levy
process_error
5f6b2196 Paul Kelly
end
6e50fa1d Ohad Levy
end
5f6b2196 Paul Kelly
def destroy
if @environment.destroy
b28fdce4 Ohad Levy
process_success
5f6b2196 Paul Kelly
else
b28fdce4 Ohad Levy
process_error
5f6b2196 Paul Kelly
end
end

6e50fa1d Ohad Levy
end