Add route for environment folder and expose an API

This commit is contained in:
Grzegorz Bizon 2017-02-07 15:06:31 +01:00
parent d6ae01da55
commit 19bac884c6
2 changed files with 22 additions and 0 deletions

View file

@ -28,6 +28,24 @@ class Projects::EnvironmentsController < Projects::ApplicationController
end end
end end
def folder
@environments = project.environments
.where(environment_type: params[:id])
.with_state(params[:scope] || :available)
respond_to do |format|
format.html
format.json do
render json: {
environments: EnvironmentSerializer
.new(project: @project, user: @current_user)
.with_pagination(request, response)
.represent(@environments),
}
end
end
end
def show def show
@deployments = environment.deployments.order(id: :desc).page(params[:page]) @deployments = environment.deployments.order(id: :desc).page(params[:page])
end end

View file

@ -156,6 +156,10 @@ constraints(ProjectUrlConstrainer.new) do
get :terminal get :terminal
get '/terminal.ws/authorize', to: 'environments#terminal_websocket_authorize', constraints: { format: nil } get '/terminal.ws/authorize', to: 'environments#terminal_websocket_authorize', constraints: { format: nil }
end end
collection do
get :folder, path: 'folders/:id'
end
end end
resource :cycle_analytics, only: [:show] resource :cycle_analytics, only: [:show]