Skip to content
Snippets Groups Projects

Issue #3225644: Fix K8s Project Cost Comparison and K8s Namespace Cost Comparison sort together with same sort keys

Closed Issue #3225644: Fix K8s Project Cost Comparison and K8s Namespace Cost Comparison sort together with same sort keys
Closed Masami Suzuki requested to merge issue/cloud-3225644:3225644-fix-table-sort-issue into 4.x
Files
3
@@ -225,24 +225,28 @@ class K8sNamespaceCostsBlock extends K8sBaseBlock {
}
$headers = [];
$header_data = [];
if (!empty($cloud_project)) {
$headers['k8s_cluster'] = [
'data' => $this->t('K8s Cluster'),
'field' => 'k8s_cluster',
];
$header_data['k8s_cluster'] = $this->t('K8s Cluster');
}
$headers += [
['data' => $this->t('Namespace'), 'field' => 'namespace'],
['data' => $this->t('Total Costs ($)'), 'field' => 'costs'],
['data' => $this->t('CPU (Usage)'), 'field' => 'cpu_usage'],
['data' => $this->t('Memory (Usage)'), 'field' => 'memory_usage'],
['data' => $this->t('Pods Allocation'), 'field' => 'pod_usage'],
$header_data += [
'namespace' => $this->t('Namespace'),
'costs' => $this->t('Total Costs ($)'),
'cpu_usage' => $this->t('CPU (Usage)'),
'memory_usage' => $this->t('Memory (Usage)'),
'pod_usage' => $this->t('Pods Allocation'),
];
$sort = $this->request->get('sort');
$order = $this->request->get('order');
foreach ($header_data ?: [] as $key => $data) {
$headers[$data->__toString()] = [
'data' => $data,
'field' => $key,
];
}
$sort = !empty($params['sort']) ? $params['sort'] : '';
$order = !empty($params['order']) ? $params['order'] : '';
$order_field = NULL;
foreach ($headers ?: [] as $header) {
@@ -307,9 +311,12 @@ class K8sNamespaceCostsBlock extends K8sBaseBlock {
}
$table = [
'#type' => 'table',
'#theme' => 'table__k8s_costs',
'#header' => $headers,
'#rows' => $current_rows_chunk,
'#attributes' => [
'block_id' => $block_id,
],
];
$build['k8s_namespace_costs'] = [
Loading