Skip to content
Snippets Groups Projects
Commit 39db8375 authored by xiaohua guan's avatar xiaohua guan Committed by Yas Naoi
Browse files

Issue #3090036 by Xiaohua Guan, yas: Add Event list onto Node detail view

parent 226818ed
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,8 @@ use Drupal\Core\Entity\EntityManagerInterface; ...@@ -8,6 +8,8 @@ use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Theme\Registry; use Drupal\Core\Theme\Registry;
use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Component\Serialization\Yaml;
use Drupal\k8s\Service\CostFieldsRendererInterface; use Drupal\k8s\Service\CostFieldsRendererInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -142,6 +144,12 @@ class K8sNodeViewBuilder extends CloudViewBuilder { ...@@ -142,6 +144,12 @@ class K8sNodeViewBuilder extends CloudViewBuilder {
'open' => TRUE, 'open' => TRUE,
'fields' => [], 'fields' => [],
], ],
[
'name' => 'node_conditions',
'title' => t('Conditions'),
'open' => TRUE,
'fields' => [],
],
[ [
'name' => 'node_pods', 'name' => 'node_pods',
'title' => t('Pods'), 'title' => t('Pods'),
...@@ -174,6 +182,21 @@ class K8sNodeViewBuilder extends CloudViewBuilder { ...@@ -174,6 +182,21 @@ class K8sNodeViewBuilder extends CloudViewBuilder {
public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
$build = parent::view($entity, $view_mode, $langcode); $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. // Get instance type and region.
$instance_type = NULL; $instance_type = NULL;
$region = NULL; $region = NULL;
...@@ -199,8 +222,40 @@ class K8sNodeViewBuilder extends CloudViewBuilder { ...@@ -199,8 +222,40 @@ class K8sNodeViewBuilder extends CloudViewBuilder {
} }
$build['costs']['fields'] = $cost_fields; $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;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment