Serialize all needed data
This commit is contained in:
parent
234c0415e4
commit
2a40dec16d
3 changed files with 25 additions and 9 deletions
|
@ -19,7 +19,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.json do
|
format.json do
|
||||||
render json: @environments
|
render json: serialize_as_json(@environments)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -69,4 +69,14 @@ class Projects::EnvironmentsController < Projects::ApplicationController
|
||||||
def environment
|
def environment
|
||||||
@environment ||= project.environments.find(params[:id])
|
@environment ||= project.environments.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def serialize_as_json(resource)
|
||||||
|
resource.as_json(
|
||||||
|
include: {
|
||||||
|
last_deployment: {
|
||||||
|
include: [:deployable, :user]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module EnvironmentsHelper
|
module EnvironmentsHelper
|
||||||
def environments_list_data
|
def environments_list_data()
|
||||||
{
|
{
|
||||||
endpoint: namespace_project_environments_path(@project.namespace, @project)
|
endpoint: namespace_project_environments_path(@project.namespace, @project)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,23 +12,27 @@
|
||||||
%i{ "v-show" => "!open" }
|
%i{ "v-show" => "!open" }
|
||||||
= icon("caret-right")
|
= icon("caret-right")
|
||||||
|
|
||||||
{{model.name}}
|
|
||||||
|
|
||||||
%td.deployment-column
|
%td.deployment-column
|
||||||
%span{ "v-if" => "model.last_deployment && model.last_deployment.iid" }
|
%span{ "v-if" => "!isFolder && model.last_deployment && model.last_deployment.iid" }
|
||||||
{{model.last_deployment.iid}}
|
{{model.last_deployment.iid}}
|
||||||
|
|
||||||
by
|
by
|
||||||
%span{ "v-if" => "model.last_deployment.user" }
|
%span{ "v-if" => "model.last_deployment.user" }
|
||||||
{{model.last_deployment.user}}
|
{{model.last_deployment.user.name}}
|
||||||
|
|
||||||
%td
|
%td
|
||||||
column 3
|
%a{ "v-if" => "!isFolder" }
|
||||||
|
column 3
|
||||||
|
|
||||||
%td
|
%td
|
||||||
column 4
|
%a{ "v-if" => "!isFolder" }
|
||||||
|
column 3
|
||||||
|
|
||||||
%td
|
%td
|
||||||
column 5
|
%span{ "v-if" => "!isFolder && model.last_deployment" }
|
||||||
|
{{last_deployment.created_at}}
|
||||||
|
|
||||||
%td.hidden-xs
|
%td.hidden-xs
|
||||||
.pull-right
|
.pull-right
|
||||||
|
@ -55,7 +59,9 @@
|
||||||
/= user_avatar(user: "child.last_deployment.user", size: 20)
|
/= user_avatar(user: "child.last_deployment.user", size: 20)
|
||||||
|
|
||||||
%td
|
%td
|
||||||
column 3
|
%a.build-link{ "v-if" => "child.last_deployment && child.last_deployment.deployable",
|
||||||
|
":href" => "" }
|
||||||
|
{{child.last_deployment}}
|
||||||
|
|
||||||
%td
|
%td
|
||||||
column 4
|
column 4
|
||||||
|
|
Loading…
Reference in a new issue