Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cloud-3230015
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
cloud-3230015
Commits
39db8375
Commit
39db8375
authored
5 years ago
by
xiaohua guan
Committed by
Yas Naoi
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3090036
by Xiaohua Guan, yas: Add Event list onto Node detail view
parent
226818ed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/cloud_service_providers/k8s/src/Entity/K8sNodeViewBuilder.php
+56
-1
56 additions, 1 deletion
...d_service_providers/k8s/src/Entity/K8sNodeViewBuilder.php
with
56 additions
and
1 deletion
modules/cloud_service_providers/k8s/src/Entity/K8sNodeViewBuilder.php
+
56
−
1
View file @
39db8375
...
...
@@ -8,6 +8,8 @@ use Drupal\Core\Entity\EntityManagerInterface;
use
Drupal\Core\Language\LanguageManagerInterface
;
use
Drupal\Core\Theme\Registry
;
use
Drupal\Core\Entity\EntityTypeInterface
;
use
Drupal\Component\Serialization\Yaml
;
use
Drupal\k8s\Service\CostFieldsRendererInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
...
...
@@ -142,6 +144,12 @@ class K8sNodeViewBuilder extends CloudViewBuilder {
'open'
=>
TRUE
,
'fields'
=>
[],
],
[
'name'
=>
'node_conditions'
,
'title'
=>
t
(
'Conditions'
),
'open'
=>
TRUE
,
'fields'
=>
[],
],
[
'name'
=>
'node_pods'
,
'title'
=>
t
(
'Pods'
),
...
...
@@ -174,6 +182,21 @@ class K8sNodeViewBuilder extends CloudViewBuilder {
public
function
view
(
EntityInterface
$entity
,
$view_mode
=
'full'
,
$langcode
=
NULL
)
{
$build
=
parent
::
view
(
$entity
,
$view_mode
,
$langcode
);
$this
->
buildCosts
(
$entity
,
$build
);
$this
->
buildConditions
(
$entity
,
$build
);
return
$build
;
}
/**
* Build costs fields.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity.
* @param array &$build
* The build array.
*/
private
function
buildCosts
(
EntityInterface
$entity
,
array
&
$build
)
{
// Get instance type and region.
$instance_type
=
NULL
;
$region
=
NULL
;
...
...
@@ -199,8 +222,40 @@ class K8sNodeViewBuilder extends CloudViewBuilder {
}
$build
[
'costs'
][
'fields'
]
=
$cost_fields
;
}
return
$build
;
/**
* Build conditions fields.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity.
* @param array &$build
* The build array.
*/
private
function
buildConditions
(
EntityInterface
$entity
,
array
&
$build
)
{
$detail
=
Yaml
::
decode
(
$entity
->
getDetail
());
$rows
=
[];
foreach
(
$detail
[
'status'
][
'conditions'
]
as
$condition
)
{
$condition
[
'lastHeartbeatTime'
]
=
format_date
(
strtotime
(
$condition
[
'lastHeartbeatTime'
]),
'short'
);
$condition
[
'lastTransitionTime'
]
=
format_date
(
strtotime
(
$condition
[
'lastTransitionTime'
]),
'short'
);
$rows
[]
=
$condition
;
}
$table
=
[
'#theme'
=>
'table'
,
'#header'
=>
[
$this
->
t
(
'Type'
),
$this
->
t
(
'Status'
),
$this
->
t
(
'Last heartbeat time'
),
$this
->
t
(
'Last transition time'
),
$this
->
t
(
'Reason'
),
$this
->
t
(
'Message'
),
],
'#rows'
=>
$rows
,
];
$build
[
'node_conditions'
][
'fields'
][]
=
$table
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment