Skip to content
Snippets Groups Projects
Commit 4446dd20 authored by Masami  Suzuki's avatar Masami Suzuki Committed by Yas Naoi
Browse files

Issue #3088945 by yas, Masami: Add Pod list onto Node detail view

parent 60ff5938
No related branches found
No related tags found
No related merge requests found
......@@ -913,3 +913,630 @@ display:
- url.query_args
- user.permissions
tags: { }
block_for_node:
display_plugin: block
id: block_for_node
display_title: Block
position: 2
display_options:
display_extenders: { }
use_ajax: false
defaults:
use_ajax: false
arguments: false
filters: false
filter_groups: false
pager: false
fields: false
arguments:
cloud_context:
id: cloud_context
table: k8s_pod
field: cloud_context
relationship: none
group_type: group
admin_label: ''
default_action: default
exception:
value: all
title_enable: false
title: All
title_enable: false
title: ''
default_argument_type: raw
default_argument_options:
index: 2
use_alias: false
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
items_per_page: 25
override: false
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
glossary: false
limit: 0
case: none
path_case: none
transform_dash: false
break_phrase: false
entity_type: k8s_pod
entity_field: cloud_context
plugin_id: string
node_name:
id: node_name
table: k8s_pod
field: node_name
relationship: none
group_type: group
admin_label: ''
default_action: default
exception:
value: all
title_enable: false
title: All
title_enable: false
title: ''
default_argument_type: raw
default_argument_options:
index: 4
use_alias: false
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
items_per_page: 25
override: false
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: true
validate:
type: 'entity:k8s_node'
fail: empty
validate_options:
access: true
operation: view
multiple: 0
bundles: null
break_phrase: false
not: 0
entity_type: k8s_pod
entity_field: node_name
plugin_id: k8s_node_id
filters: { }
filter_groups:
operator: AND
groups:
1: AND
pager:
type: none
options:
offset: 0
fields:
namespace:
id: namespace
table: k8s_pod
field: namespace
relationship: none
group_type: group
admin_label: ''
label: Namespace
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: entity_link
settings:
target_type: k8s_namespace
field_name: name
comma_separated: false
html_generator_class: ''
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: k8s_pod
entity_field: namespace
plugin_id: field
name:
id: name
table: k8s_pod
field: name
relationship: none
group_type: group
admin_label: ''
label: Name
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: true
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: k8s_pod
entity_field: name
plugin_id: field
status:
id: status
table: k8s_pod
field: status
relationship: none
group_type: group
admin_label: ''
label: State
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: false
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: k8s_pod
entity_field: status
plugin_id: field
restarts:
id: restarts
table: k8s_pod
field: restarts
relationship: none
group_type: group
admin_label: ''
label: Restarts
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: false
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: k8s_pod
entity_field: restarts
plugin_id: field
cpu_usage:
id: cpu_usage
table: k8s_pod
field: cpu_usage
relationship: none
group_type: group
admin_label: ''
label: 'CPU (Usage)'
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: k8s_pod
entity_field: cpu_usage
plugin_id: field
memory_usage:
id: memory_usage
table: k8s_pod
field: memory_usage
relationship: none
group_type: group
admin_label: ''
label: 'Memory (Usage)'
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: memory_formatter
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: k8s_pod
entity_field: memory_usage
plugin_id: field
created:
id: created
table: k8s_pod
field: created
relationship: none
group_type: group
admin_label: ''
label: Created
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: timestamp
settings:
date_format: short
custom_date_format: ''
timezone: ''
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: k8s_pod
entity_field: created
plugin_id: field
operations:
id: operations
table: k8s_pod
field: operations
relationship: none
group_type: group
admin_label: ''
label: 'Operations links'
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
destination: false
entity_type: null
entity_field: null
plugin_id: entity_operations
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- user.permissions
tags: { }
......@@ -555,7 +555,6 @@ function k8s_update_8219() {
cloud_update_yml_definitions($files, 'k8s');
}
/**
* Add field creation_yaml to k8s_pod and k8s_deployment.
*/
......@@ -596,3 +595,10 @@ function k8s_update_8221() {
];
cloud_update_yml_definitions($files, 'k8s');
}
/**
* Add block for node in k8s pod view.
*/
function k8s_update_8222() {
cloud_update_yml_definitions(['views.view.k8s_pod.yml'], 'k8s');
}
......@@ -456,7 +456,8 @@ function k8s_entity_view_alter(array &$build, EntityInterface $entity, EntityVie
$k8s_service->setCloudContext($entity->getCloudContext());
try {
$k8s_service->getMetricsNodes();
} catch (K8sServiceException $e) {
}
catch (K8sServiceException $e) {
$metrics_enabled = FALSE;
}
}
......@@ -493,6 +494,17 @@ function k8s_entity_view_alter(array &$build, EntityInterface $entity, EntityVie
$build['#attached']['drupalSettings']['k8s']['k8s_js_refresh_interval']
= $config->get('k8s_js_refresh_interval');
}
if (isset($build['node_pods'])) {
$build['node_pods']['k8s_node_pods'] = [
'#type' => 'view',
'#name' => 'k8s_pod',
'#display_id' => 'block_for_node',
];
}
}
/**
......@@ -650,7 +662,7 @@ function k8s_server_template_field_orders($include_name = TRUE) {
function k8s_entity_bundle_field_info_alter(&$fields, EntityTypeInterface $entity_type, $bundle) {
if ($bundle === 'k8s') {
if (isset($fields['field_detail'])) {
// Use the ID as defined in the annotation of the constraint definition
// Use the ID as defined in the annotation of the constraint definition.
$fields['field_detail']->addConstraint('yaml_array_data', []);
}
}
......
......@@ -142,6 +142,12 @@ class K8sNodeViewBuilder extends CloudViewBuilder {
'open' => TRUE,
'fields' => [],
],
[
'name' => 'node_pods',
'title' => t('Pods'),
'open' => TRUE,
'fields' => [],
],
[
'name' => 'node_detail',
'title' => t('Detail'),
......@@ -196,4 +202,5 @@ class K8sNodeViewBuilder extends CloudViewBuilder {
return $build;
}
}
......@@ -27,6 +27,10 @@ class K8sPodViewsData extends EntityViewsData {
// put here.
$data['k8s_pod']['table']['base']['access query tag'] = 'k8s_entity_views_access_with_namespace';
$data['k8s_pod']['node_name']['argument'] = [
'id' => 'k8s_node_id',
];
return $data;
}
......
<?php
namespace Drupal\k8s\Plugin\views\argument;
use Drupal\views\Plugin\ViewsHandlerManager;
use Drupal\views\Plugin\views\argument\NumericArgument;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Argument handler to accept a k8s node id.
*
* @ViewsArgument("k8s_node_id")
*/
class K8sNodeId extends NumericArgument {
/**
* The join manager.
*
* @var \Drupal\views\Plugin\ViewsHandlerManager
*/
protected $joinManager;
/**
* Constructs the K8sNodeId object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\views\Plugin\ViewsHandlerManager $join_manager
* The views plugin join manager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, ViewsHandlerManager $join_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->joinManager = $join_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('plugin.manager.views.join')
);
}
/**
* {@inheritdoc}
*/
public function query($group_by = FALSE) {
$this->ensureMyTable();
if (!empty($this->options['break_phrase'])) {
$break = static::breakString($this->argument, FALSE);
$this->value = $break->value;
$this->operator = $break->operator;
}
else {
$this->value = [$this->argument];
}
$placeholder = $this->placeholder();
$null_check = empty($this->options['not']) ? '' : " OR $this->tableAlias.$this->realField IS NULL";
$definition = [
'table' => 'k8s_node',
'field' => 'name',
'left_table' => $this->tableAlias,
'left_field' => $this->realField,
];
$join = $this->joinManager->createInstance('standard', $definition);
$this->query->addTable('k8s_node', NULL, $join);
if (count($this->value) > 1) {
$operator = empty($this->options['not']) ? 'IN' : 'NOT IN';
$placeholder .= '[]';
$this->query->addWhereExpression(0, "k8s_node.id $operator($placeholder)" . $null_check, [$placeholder => $this->value]);
}
else {
$operator = empty($this->options['not']) ? '=' : '!=';
$this->query->addWhereExpression(0, "k8s_node.id $operator $placeholder" . $null_check, [$placeholder => $this->argument]);
}
}
}
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