Compare commits

...

4 Commits

Author SHA1 Message Date
Joshua Boniface
08f00d9c62 Add editorconfig to fix issues 2025-02-28 20:38:53 -05:00
Joshua Boniface
97de6bda82 Split overview charts into discrete components 2025-02-28 20:36:12 -05:00
Joshua Boniface
9e14502bc2 Refactor nodes page, update health chart 2025-02-28 20:20:10 -05:00
Joshua Boniface
11e1e8eec4 Initial implementation of nice Nodes page 2025-02-28 19:53:44 -05:00
12 changed files with 2011 additions and 297 deletions

16
pvc-vue/.editorconfig Normal file
View File

@ -0,0 +1,16 @@
# EditorConfig helps maintain consistent coding styles across different editors
# https://editorconfig.org/
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
# Markdown files allow trailing whitespace for line breaks
[*.md]
trim_trailing_whitespace = false

View File

@ -113,6 +113,50 @@ const updateMetricsHistory = (timestamp, status) => {
data
};
});
// Track node-specific metrics
if (!metricsHistory.value.nodes) {
metricsHistory.value.nodes = {};
}
// Update metrics for each node
nodeData.value.forEach(node => {
const nodeName = node.name;
if (!metricsHistory.value.nodes[nodeName]) {
metricsHistory.value.nodes[nodeName] = {
health: { labels: [], data: [] },
cpu: { labels: [], data: [] },
memory: { labels: [], data: [] },
allocated: { labels: [], data: [] }
};
}
// Calculate node metrics
const nodeMetrics = {
health: node.health || 0,
cpu: node.load && node.cpu_count ? Math.round((node.load / node.cpu_count) * 100) : 0,
memory: node.memory?.used && node.memory?.total ? Math.round((node.memory.used / node.memory.total) * 100) : 0,
allocated: node.memory?.allocated && node.memory?.total ? Math.round((node.memory.allocated / node.memory.total) * 100) : 0
};
// Update each metric for this node
Object.keys(nodeMetrics).forEach(metric => {
const nodeLabels = [...metricsHistory.value.nodes[nodeName][metric].labels, timestamp];
const nodeData = [...metricsHistory.value.nodes[nodeName][metric].data, nodeMetrics[metric]];
// Keep only last 180 points
if (nodeLabels.length > 180) {
nodeLabels.shift();
nodeData.shift();
}
metricsHistory.value.nodes[nodeName][metric] = {
labels: nodeLabels,
data: nodeData
};
});
});
};
const updateDashboard = async () => {

View File

@ -143,72 +143,33 @@
<div v-show="sections.graphs" class="section-content-wrapper">
<div class="section-content">
<div class="graphs-row">
<!-- Health Card -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0 metric-label">Cluster Health</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">
{{ clusterData.cluster_health?.health || 0 }}%
</h4>
</div>
<div class="chart-wrapper">
<Line :data="healthChartData" :options="healthChartOptions" />
</div>
</div>
</div>
<!-- Health Chart -->
<HealthChart
title="Cluster Health"
:value="clusterHealth"
:chart-data="healthChartData"
/>
<!-- CPU Chart -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">CPU Utilization</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">
{{ metricsData.cpu.data[metricsData.cpu.data.length - 1] || 0 }}%
</h4>
</div>
<div class="chart-wrapper">
<Line :data="cpuChartData" :options="chartOptions" />
</div>
</div>
</div>
<CPUChart
title="CPU Utilization"
:value="cpuUtilization"
:chart-data="cpuChartData"
/>
<!-- Memory Chart -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Memory Utilization</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">
{{ metricsData.memory.data[metricsData.memory.data.length - 1] || 0 }}%
</h4>
</div>
<Line :data="memoryChartData" :options="chartOptions" />
</div>
</div>
<MemoryChart
title="Memory Utilization"
:value="memoryUtilization"
:chart-data="memoryChartData"
/>
<!-- Storage Chart -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Storage Utilization</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">
{{ metricsData.storage?.data[metricsData.storage?.data.length - 1] || 0 }}%
</h4>
</div>
<Line :data="storageChartData" :options="chartOptions" />
</div>
</div>
<StorageChart
title="Storage Utilization"
:value="storageUtilization"
:chart-data="storageChartData"
/>
</div>
</div>
<div class="toggle-column expanded">
@ -245,11 +206,11 @@
<div class="card-body">
<div class="messages-list">
<template v-if="displayMessages.length">
<div
v-for="(msg, idx) in displayMessages"
<div
v-for="(msg, idx) in displayMessages"
:key="idx"
:class="[
'health-message',
'health-message',
getDeltaClass(msg.health_delta, msg),
]"
>
@ -317,7 +278,7 @@
<Line :data="nodeStatesChartData" :options="statesChartOptions" />
</div>
</div>
<!-- VM States Graph -->
<div class="metric-card">
<div class="card-header">
@ -329,7 +290,7 @@
<Line :data="vmStatesChartData" :options="statesChartOptions" />
</div>
</div>
<!-- OSD States Graph -->
<div class="metric-card">
<div class="card-header">
@ -368,6 +329,10 @@ import {
Filler
} from 'chart.js';
import annotationPlugin from 'chartjs-plugin-annotation';
import CPUChart from './charts/CPUChart.vue';
import MemoryChart from './charts/MemoryChart.vue';
import StorageChart from './charts/StorageChart.vue';
import HealthChart from './charts/HealthChart.vue';
// Register Chart.js components
ChartJS.register(
@ -397,13 +362,13 @@ const props = defineProps({
const displayMessages = computed(() => {
const messages = [];
// Check if there are any health messages
if (props.clusterData.cluster_health?.messages) {
// Add all messages from the cluster health data
messages.push(...props.clusterData.cluster_health.messages);
}
// Sort messages by health delta (highest impact first)
return messages.sort((a, b) => {
// If health_delta is not available, use 0
@ -433,17 +398,17 @@ const getDeltaClass = (delta, msg) => {
if (msg && msg.id === 'Cluster is in maintenance') {
return 'delta-info';
}
// Special case for plugin error messages (the ones with 25%)
if (msg && (msg.id === 'NODE_PLUGIN_PSQL_HV3' || msg.id === 'NODE_PLUGIN_ZKPR_HV3')) {
return 'delta-high'; // These should be red
}
// Special case for "No problems" message
if (msg && msg.id === 'CLUSTER_HEALTHY') {
return 'delta-low';
}
// Handle numeric deltas
if (delta === undefined || delta === null) return '';
if (delta === 0) return 'delta-low'; // Zero delta - green like healthy messages
@ -452,59 +417,45 @@ const getDeltaClass = (delta, msg) => {
return 'delta-info';
};
const healthChartData = computed(() => {
return {
labels: props.metricsData.health.labels,
datasets: [{
data: props.metricsData.health.data,
fill: true,
segment: {
borderColor: (ctx) => {
console.log('Context:', ctx);
console.log('Maintenance data:', props.metricsData.maintenance?.data);
console.log('Available indices:', ctx.p0?.parsed?.x, ctx.p1?.parsed?.x);
const maintenanceAtPoint = props.metricsData.maintenance?.data[ctx.p0.parsed.x];
console.log('Point', ctx.p0.parsed.x, 'Maintenance:', maintenanceAtPoint);
if (maintenanceAtPoint === true) {
console.log('Using blue color for maintenance');
return 'rgba(13, 110, 253, 0.2)';
}
const value = ctx.p1.parsed.y;
console.log('Using health-based color:', value);
if (value > 90) return 'rgba(40, 167, 69, 0.2)'; // Green
if (value > 50) return 'rgba(255, 193, 7, 0.2)'; // Yellow
return 'rgba(220, 53, 69, 0.2)'; // Red
},
backgroundColor: (ctx) => {
const maintenanceAtPoint = props.metricsData.maintenance?.data[ctx.p0.parsed.x];
if (maintenanceAtPoint === true) {
return 'rgba(13, 110, 253, 0.1)';
}
const value = ctx.p1.parsed.y;
if (value > 90) return 'rgba(40, 167, 69, 0.1)'; // Green
if (value > 50) return 'rgba(255, 193, 7, 0.1)'; // Yellow
return 'rgba(220, 53, 69, 0.1)'; // Red
}
},
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)', // Light background for all points
pointBorderColor: (ctx) => {
const maintenanceAtPoint = props.metricsData.maintenance?.data[ctx.dataIndex];
if (maintenanceAtPoint === true) return 'rgba(13, 110, 253, 0.5)'; // Blue for maintenance
if (!ctx.raw) return 'rgba(0, 0, 0, 0.2)';
const value = ctx.raw;
if (value > 90) return 'rgba(40, 167, 69, 0.5)'; // Green
if (value > 50) return 'rgba(255, 193, 7, 0.5)'; // Yellow
return 'rgba(220, 53, 69, 0.5)'; // Red
},
pointBorderWidth: 1.5
}]
};
});
// Simplified chart data for the new chart components
const healthChartData = computed(() => ({
labels: props.metricsData.health.labels,
data: props.metricsData.health.data
}));
const cpuChartData = computed(() => ({
labels: props.metricsData.cpu.labels,
data: props.metricsData.cpu.data
}));
const memoryChartData = computed(() => ({
labels: props.metricsData.memory.labels,
data: props.metricsData.memory.data
}));
const storageChartData = computed(() => ({
labels: props.metricsData.storage?.labels || [],
data: props.metricsData.storage?.data || []
}));
// Current values for the charts
const clusterHealth = computed(() =>
props.clusterData.cluster_health?.health || 0
);
const cpuUtilization = computed(() =>
props.metricsData.cpu.data[props.metricsData.cpu.data.length - 1] || 0
);
const memoryUtilization = computed(() =>
props.metricsData.memory.data[props.metricsData.memory.data.length - 1] || 0
);
const storageUtilization = computed(() =>
props.metricsData.storage?.data[props.metricsData.storage?.data.length - 1] || 0
);
// Health chart options for the threshold lines
const healthChartOptions = {
responsive: true,
maintainAspectRatio: false,
@ -522,19 +473,21 @@ const healthChartOptions = {
},
annotation: {
annotations: {
warning: {
type: 'line',
yMin: 90,
yMax: 90,
borderColor: 'rgba(255, 193, 7, 0.2)',
borderWidth: 1,
},
danger: {
criticalLine: {
type: 'line',
yMin: 50,
yMax: 50,
borderColor: 'rgba(220, 53, 69, 0.2)',
borderColor: 'rgba(220, 53, 69, 0.5)',
borderWidth: 1,
borderDash: [5, 5]
},
warningLine: {
type: 'line',
yMin: 90,
yMax: 90,
borderColor: 'rgba(255, 193, 7, 0.5)',
borderWidth: 1,
borderDash: [5, 5]
}
}
}
@ -566,108 +519,11 @@ const healthChartOptions = {
}
};
const cpuChartData = computed(() => ({
labels: props.metricsData.cpu.labels,
datasets: [{
label: 'CPU',
data: props.metricsData.cpu.data,
borderColor: 'rgb(75, 192, 192)',
fill: true,
backgroundColor: 'rgba(75, 192, 192, 0.1)',
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: 'rgba(75, 192, 192, 0.5)',
pointBorderWidth: 1.5
}]
}));
const memoryChartData = computed(() => ({
labels: props.metricsData.memory.labels,
datasets: [{
label: 'Memory',
data: props.metricsData.memory.data,
borderColor: 'rgb(153, 102, 255)',
fill: true,
backgroundColor: 'rgba(153, 102, 255, 0.1)',
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: 'rgba(153, 102, 255, 0.5)',
pointBorderWidth: 1.5
}]
}));
const storageChartData = computed(() => ({
labels: props.metricsData.storage?.labels || [],
datasets: [{
label: 'Storage',
data: props.metricsData.storage?.data || [],
borderColor: 'rgb(255, 159, 64)',
fill: true,
backgroundColor: 'rgba(255, 159, 64, 0.1)',
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: 'rgba(255, 159, 64, 0.5)',
pointBorderWidth: 1.5
}]
}));
const chartOptions = {
responsive: true,
maintainAspectRatio: false,
clip: false,
resizeDelay: 0,
responsiveAnimationDuration: 0, /* Disable resize animation */
plugins: {
legend: {
display: false
},
tooltip: {
callbacks: {
label: (context) => `${context.parsed.y}%`
}
}
},
scales: {
x: {
display: false,
grid: {
display: false
}
},
y: {
display: false,
grid: {
display: false
},
min: 0,
max: 100
}
},
animation: false,
interaction: {
enabled: true,
mode: 'nearest',
intersect: false
},
onResize: (chart, size) => {
chart.resize(); /* Force resize on container change */
}
};
// Helper function to group objects by state
const groupByState = (items, stateExtractor) => {
const groups = {};
if (!items || !Array.isArray(items)) return groups;
items.forEach(item => {
const state = stateExtractor(item);
if (!groups[state]) {
@ -675,7 +531,7 @@ const groupByState = (items, stateExtractor) => {
}
groups[state].push(item);
});
return groups;
};
@ -697,7 +553,7 @@ const updateStateHistory = (newStates, historyArray, maxPoints = 20) => {
if (!newStates || Object.keys(newStates).length === 0) {
return;
}
// Check if there are any actual items in the states
const hasItems = Object.values(newStates).some(items => items && items.length > 0);
if (!hasItems) {
@ -709,7 +565,7 @@ const updateStateHistory = (newStates, historyArray, maxPoints = 20) => {
timestamp: Date.now(),
states: JSON.parse(JSON.stringify(newStates)) // Deep copy to prevent reference issues
});
// Limit history length
if (historyArray.length > maxPoints) {
historyArray.shift();
@ -722,40 +578,40 @@ const processStateHistory = (currentStateGroups, historyArray, timeLabels, color
const allStates = new Map();
const datasets = [];
const stateData = {};
// Skip processing if no history data yet
if (historyArray.length === 0) {
return [];
}
// Skip processing if current state groups are empty
if (!currentStateGroups || Object.keys(currentStateGroups).length === 0) {
return [];
}
// Initialize data structure for all time points
timeLabels.forEach((_, index) => {
stateData[index] = {};
});
// Process historical data
if (historyArray.length > 0) {
// Map history entries to time points in the chart
const historyStep = historyArray.length / timeLabels.length;
timeLabels.forEach((_, timeIndex) => {
// Find the corresponding history entry for this time point
const historyIndex = Math.min(
Math.floor(timeIndex * historyStep),
historyArray.length - 1
);
const historyEntry = historyArray[historyIndex];
if (historyEntry && historyEntry.states) {
// Record states at this time point
Object.entries(historyEntry.states).forEach(([state, items]) => {
stateData[timeIndex][state] = items.length;
// Track this state
if (!allStates.has(state)) {
allStates.set(state, {
@ -767,12 +623,12 @@ const processStateHistory = (currentStateGroups, historyArray, timeLabels, color
}
});
}
// Add current states that might not be in history yet
Object.entries(currentStateGroups).forEach(([state, items]) => {
const lastIndex = timeLabels.length - 1;
stateData[lastIndex][state] = items.length;
if (!allStates.has(state)) {
allStates.set(state, {
color: colorFunction(state),
@ -783,16 +639,16 @@ const processStateHistory = (currentStateGroups, historyArray, timeLabels, color
allStates.get(state).currentCount = items.length;
}
});
// Create datasets for Chart.js
const totalCount = Object.values(currentStateGroups)
.reduce((sum, items) => sum + items.length, 0);
// Skip if total count is 0
if (totalCount === 0) {
return [];
}
datasets.push({
label: 'Total',
data: Array(timeLabels.length).fill(totalCount),
@ -804,14 +660,14 @@ const processStateHistory = (currentStateGroups, historyArray, timeLabels, color
order: 999,
currentCount: totalCount
});
// Add a line for each state
allStates.forEach((stateInfo, state) => {
// Create data array from historical state data
const data = timeLabels.map((_, index) => {
return stateData[index][state] || 0;
});
// Skip drawing lines for states with all zero values
if (data.every(value => value === 0)) {
// Still add to legend if current count is not zero
@ -824,7 +680,7 @@ const processStateHistory = (currentStateGroups, historyArray, timeLabels, color
}
return;
}
datasets.push({
label: capitalizeState(state),
data: data,
@ -840,7 +696,7 @@ const processStateHistory = (currentStateGroups, historyArray, timeLabels, color
}
});
});
return datasets;
};
@ -861,12 +717,12 @@ const nodeStateColors = (state) => {
// Node states processing
const nodeStatesChartData = computed(() => {
const labels = props.metricsData.health.labels;
// Only process if we have history data
if (nodeStateHistory.value.length === 0) {
return { labels, datasets: [] };
}
// Process node states with history
const datasets = processStateHistory(
nodeStateGroups.value,
@ -874,7 +730,7 @@ const nodeStatesChartData = computed(() => {
labels,
nodeStateColors
);
return { labels, datasets };
});
@ -894,12 +750,12 @@ const vmStateColors = (state) => {
// VM states processing
const vmStatesChartData = computed(() => {
const labels = props.metricsData.health.labels;
// Only process if we have history data
if (vmStateHistory.value.length === 0) {
return { labels, datasets: [] };
}
// Process VM states with history
const datasets = processStateHistory(
vmStateGroups.value,
@ -907,7 +763,7 @@ const vmStatesChartData = computed(() => {
labels,
vmStateColors
);
return { labels, datasets };
});
@ -927,12 +783,12 @@ const osdStateColors = (state) => {
// OSD states processing
const osdStatesChartData = computed(() => {
const labels = props.metricsData.health.labels;
// Only process if we have history data
if (osdStateHistory.value.length === 0) {
return { labels, datasets: [] };
}
// Process OSD states with history
const datasets = processStateHistory(
osdStateGroups.value,
@ -940,7 +796,7 @@ const osdStatesChartData = computed(() => {
labels,
osdStateColors
);
return { labels, datasets };
});
@ -963,8 +819,8 @@ const statesChartOptions = {
// Custom legend labels with counts
const datasets = chart.data.datasets;
return datasets.map(dataset => ({
text: dataset.currentCount !== undefined ?
`${dataset.label}: ${dataset.currentCount}` :
text: dataset.currentCount !== undefined ?
`${dataset.label}: ${dataset.currentCount}` :
dataset.label,
fillStyle: dataset.borderColor,
strokeStyle: dataset.borderColor,
@ -1017,30 +873,30 @@ watch(() => props.clusterData, (newData) => {
if (!newData.detail) {
return;
}
// Update node state history
const nodeStates = groupByState(newData.detail?.node, (node) => {
return `${node.daemon_state}, ${node.domain_state}`;
});
// Only update if we have actual node states
if (Object.keys(nodeStates).length > 0) {
updateStateHistory(nodeStates, nodeStateHistory.value);
}
// Update VM state history
const vmStates = groupByState(newData.detail?.vm, (vm) => vm.state);
// Only update if we have actual VM states
if (Object.keys(vmStates).length > 0) {
updateStateHistory(vmStates, vmStateHistory.value);
}
// Update OSD state history
const osdStates = groupByState(newData.detail?.osd, (osd) => {
return `${osd.up}, ${osd.in}`;
});
// Only update if we have actual OSD states
if (Object.keys(osdStates).length > 0) {
updateStateHistory(osdStates, osdStateHistory.value);
@ -1055,23 +911,23 @@ onMounted(() => {
const nodeStates = groupByState(props.clusterData.detail?.node, (node) => {
return `${node.daemon_state}, ${node.domain_state}`;
});
// Only initialize if we have actual node states
if (Object.keys(nodeStates).length > 0) {
updateStateHistory(nodeStates, nodeStateHistory.value);
}
const vmStates = groupByState(props.clusterData.detail?.vm, (vm) => vm.state);
// Only initialize if we have actual VM states
if (Object.keys(vmStates).length > 0) {
updateStateHistory(vmStates, vmStateHistory.value);
}
const osdStates = groupByState(props.clusterData.detail?.osd, (osd) => {
return `${osd.up}, ${osd.in}`;
});
// Only initialize if we have actual OSD states
if (Object.keys(osdStates).length > 0) {
updateStateHistory(osdStates, osdStateHistory.value);
@ -1098,7 +954,7 @@ const showHealthDelta = (msg) => {
if (msg.id === 'CLUSTER_HEALTHY') {
return false;
}
// Show delta for all other messages that have a delta value
return msg.health_delta !== undefined && msg.health_delta !== null;
};
@ -1109,7 +965,7 @@ const getMessageId = (msg) => {
if (msg.id === 'CLUSTER_HEALTHY') {
return 'Cluster is healthy with no faults';
}
// Return the original ID for all other messages
return msg.id || 'Unknown Issue';
};
@ -1237,12 +1093,12 @@ const getMessageText = (msg) => {
.metrics-row {
grid-template-columns: repeat(4, 1fr);
}
/* 4x1 for health/utilization graphs in full width */
.graphs-row {
grid-template-columns: repeat(4, 1fr);
}
/* 3x1 for state graphs in full width */
.states-graphs-row {
grid-template-columns: repeat(3, 1fr);
@ -1253,12 +1109,12 @@ const getMessageText = (msg) => {
.metrics-row {
grid-template-columns: repeat(2, 1fr); /* 2 columns when between 800px and 1200px */
}
/* 2x2 for health/utilization graphs in medium width */
.graphs-row {
grid-template-columns: repeat(2, 1fr);
}
/* 1x3 for state graphs in medium width (vertical stack) */
.states-graphs-row {
grid-template-columns: 1fr;
@ -1269,12 +1125,12 @@ const getMessageText = (msg) => {
.metrics-row {
grid-template-columns: 1fr; /* 1 column when <= 800px */
}
/* 1x4 for health/utilization graphs in narrow width */
.graphs-row {
grid-template-columns: 1fr;
}
/* 1x3 for state graphs in narrow width */
.states-graphs-row {
grid-template-columns: 1fr;
@ -1392,8 +1248,13 @@ const getMessageText = (msg) => {
.chart-wrapper {
position: relative;
width: 100%;
height: 100%;
min-width: 0;
height: 160px;
min-height: 160px;
overflow: hidden;
border: none;
border-radius: 0;
background-color: white;
margin: 0;
}
/* Add new style for full-width messages */

View File

@ -1,12 +1,12 @@
<template>
<div>
<!-- Overlay that captures clicks outside the panel -->
<div
v-if="modelValue"
<div
v-if="modelValue"
class="config-overlay"
@click="closePanel"
></div>
<div class="config-panel" :class="{ 'open': modelValue }">
<div class="config-content" @click.stop>
<h3>Configuration</h3>

View File

@ -60,7 +60,7 @@ const formatMemory = (node) => {
if (!node.memory || typeof node.memory !== 'object') {
return { used: 'N/A', total: 'N/A', percent: 'N/A' };
}
// Convert MB to GB with 2 decimal places
const toGB = (mb) => {
if (typeof mb !== 'number' || isNaN(mb)) {
@ -68,17 +68,17 @@ const formatMemory = (node) => {
}
return (mb / 1024).toFixed(2);
};
// Extract values from the Proxy object
const memoryData = Object.assign({}, node.memory);
const used = toGB(memoryData.used);
const total = toGB(memoryData.total);
let percent = 'N/A';
if (used !== 'N/A' && total !== 'N/A' && parseFloat(total) > 0) {
percent = Math.round((parseFloat(used) / parseFloat(total)) * 100);
}
return { used, total, percent };
};
</script>

View File

@ -37,4 +37,4 @@ defineProps({
display: flex;
gap: 0.5rem;
}
</style>
</style>

View File

@ -0,0 +1,202 @@
<template>
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">{{ title }}</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">{{ value }}%</h4>
</div>
<div class="chart-wrapper">
<Line
:data="formattedChartData"
:options="chartOptions"
class="chart-cpu"
/>
</div>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue';
import { Line } from 'vue-chartjs';
import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, Filler } from 'chart.js';
// Register Chart.js components
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend,
Filler
);
const props = defineProps({
title: {
type: String,
default: 'CPU Utilization'
},
value: {
type: Number,
default: 0
},
chartData: {
type: Object,
default: () => ({ labels: [], data: [] })
}
});
const chartOptions = {
responsive: true,
maintainAspectRatio: false,
clip: false,
resizeDelay: 0,
responsiveAnimationDuration: 0,
plugins: {
legend: {
display: false
},
tooltip: {
callbacks: {
label: (context) => `${context.parsed.y}%`
}
}
},
scales: {
x: {
display: false,
grid: {
display: false
}
},
y: {
display: false,
grid: {
display: false
},
min: 0,
max: 100
}
},
animation: false,
interaction: {
enabled: true,
mode: 'nearest',
intersect: false
},
onResize: (chart, size) => {
chart.resize();
}
};
const formattedChartData = computed(() => ({
labels: props.chartData.labels || [],
datasets: [{
label: 'CPU',
data: props.chartData.data || [],
borderColor: 'rgb(75, 192, 192)',
fill: true,
backgroundColor: 'rgba(75, 192, 192, 0.1)',
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: 'rgba(75, 192, 192, 0.5)',
pointBorderWidth: 1.5
}]
}));
</script>
<style scoped>
.chart-wrapper {
position: relative;
width: 100%;
height: 160px;
min-height: 160px;
overflow: hidden;
border: none;
border-radius: 0;
background-color: white;
margin: 0;
}
.metric-percentage {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.8);
padding: 0.25rem 0.75rem;
border-radius: 0.5rem;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
z-index: 2;
}
.metric-percentage .metric-value {
font-size: 2.5rem;
font-weight: 500;
color: #333;
line-height: 1;
margin: 0;
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}
.chart-cpu {
background: white;
border: none;
}
.metric-card {
min-width: 180px;
background: white;
border: 1px solid rgba(0,0,0,0.125);
border-radius: 0.25rem;
height: 100%;
display: flex;
flex-direction: column;
min-width: 0;
width: 100%;
overflow: hidden;
}
.metric-card .card-header {
background-color: rgba(0, 0, 0, 0.03);
padding: 0.5rem;
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
height: 38px;
display: flex;
justify-content: space-between;
align-items: center;
}
.card-header h6 {
font-size: 0.95rem;
font-weight: 600;
display: flex;
justify-content: space-between;
align-items: center;
margin: 0;
}
.metric-card .card-body {
flex: 1;
padding: 0.5rem;
display: flex;
flex-direction: column;
position: relative;
width: 100%;
overflow: visible;
}
.metric-label {
color: #495057;
font-weight: 600;
}
</style>

View File

@ -0,0 +1,291 @@
<template>
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">{{ title }}</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">{{ value }}%</h4>
</div>
<div class="chart-wrapper">
<Line
:data="formattedChartData"
:options="chartOptions"
class="chart-health"
/>
</div>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue';
import { Line } from 'vue-chartjs';
import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, Filler } from 'chart.js';
import annotationPlugin from 'chartjs-plugin-annotation';
// Register Chart.js components
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend,
Filler,
annotationPlugin
);
const props = defineProps({
title: {
type: String,
default: 'Health'
},
value: {
type: Number,
default: 0
},
chartData: {
type: Object,
default: () => ({ labels: [], data: [] })
}
});
const chartOptions = {
responsive: true,
maintainAspectRatio: false,
clip: false,
resizeDelay: 0,
responsiveAnimationDuration: 0,
plugins: {
legend: {
display: false
},
tooltip: {
callbacks: {
label: (context) => `${context.parsed.y}%`
}
},
annotation: {
annotations: {
criticalLine: {
type: 'line',
yMin: 50,
yMax: 50,
borderColor: 'rgba(220, 53, 69, 0.5)',
borderWidth: 1,
borderDash: [5, 5]
},
warningLine: {
type: 'line',
yMin: 90,
yMax: 90,
borderColor: 'rgba(255, 193, 7, 0.5)',
borderWidth: 1,
borderDash: [5, 5]
}
}
}
},
scales: {
x: {
display: false,
grid: {
display: false
}
},
y: {
display: false,
grid: {
display: false
},
min: 0,
max: 100
}
},
animation: false,
interaction: {
enabled: true,
mode: 'nearest',
intersect: false
},
onResize: (chart, size) => {
chart.resize();
}
};
// Helper function to get health color based on value
const getHealthColor = (value) => {
if (value > 90) {
return {
border: 'rgba(40, 167, 69, 0.8)', // Green
background: 'rgba(40, 167, 69, 0.1)'
};
} else if (value > 50) {
return {
border: 'rgba(255, 193, 7, 0.8)', // Yellow
background: 'rgba(255, 193, 7, 0.1)'
};
} else {
return {
border: 'rgba(220, 53, 69, 0.8)', // Red
background: 'rgba(220, 53, 69, 0.1)'
};
}
};
const formattedChartData = computed(() => {
const labels = props.chartData.labels || [];
const data = props.chartData.data || [];
// For single value or empty data
if (data.length <= 1) {
const value = data.length === 1 ? data[0] : props.value;
const color = getHealthColor(value);
return {
labels: labels.length ? labels : ['Health'],
datasets: [{
label: 'Health',
data: data.length ? data : [value],
borderColor: color.border,
backgroundColor: color.background,
fill: true,
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: color.border,
pointBorderWidth: 1.5
}]
};
}
// For historical data with multiple values
return {
labels,
datasets: [{
label: 'Health',
data,
segment: {
borderColor: ctx => {
const value = ctx.p1.parsed.y;
if (value > 90) return 'rgba(40, 167, 69, 0.8)'; // Green
if (value > 50) return 'rgba(255, 193, 7, 0.8)'; // Yellow
return 'rgba(220, 53, 69, 0.8)'; // Red
},
backgroundColor: ctx => {
const value = ctx.p1.parsed.y;
if (value > 90) return 'rgba(40, 167, 69, 0.1)'; // Green
if (value > 50) return 'rgba(255, 193, 7, 0.1)'; // Yellow
return 'rgba(220, 53, 69, 0.1)'; // Red
}
},
fill: true,
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: function(context) {
const index = context.dataIndex;
const value = context.dataset.data[index];
return getHealthColor(value).border;
},
pointBorderWidth: 1.5
}]
};
});
</script>
<style scoped>
.chart-wrapper {
position: relative;
width: 100%;
height: 160px;
min-height: 160px;
overflow: hidden;
border: none;
border-radius: 0;
background-color: white;
margin: 0;
}
.metric-percentage {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.8);
padding: 0.25rem 0.75rem;
border-radius: 0.5rem;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
z-index: 2;
}
.metric-percentage .metric-value {
font-size: 2.5rem;
font-weight: 500;
color: #333;
line-height: 1;
margin: 0;
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}
.chart-health {
background: white;
border: none;
}
/* Add these styles to match the original design */
.metric-card {
min-width: 180px;
background: white;
border: 1px solid rgba(0,0,0,0.125);
border-radius: 0.25rem;
height: 100%;
display: flex;
flex-direction: column;
min-width: 0;
width: 100%;
overflow: hidden;
}
.metric-card .card-header {
background-color: rgba(0, 0, 0, 0.03);
padding: 0.5rem;
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
height: 38px;
display: flex;
justify-content: space-between;
align-items: center;
}
.card-header h6 {
font-size: 0.95rem;
font-weight: 600;
display: flex;
justify-content: space-between;
align-items: center;
margin: 0;
}
.metric-card .card-body {
flex: 1;
padding: 0.5rem;
display: flex;
flex-direction: column;
position: relative;
width: 100%;
overflow: visible;
}
.metric-label {
color: #495057;
font-weight: 600;
}
</style>

View File

@ -0,0 +1,202 @@
<template>
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">{{ title }}</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">{{ value }}%</h4>
</div>
<div class="chart-wrapper">
<Line
:data="formattedChartData"
:options="chartOptions"
class="chart-memory"
/>
</div>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue';
import { Line } from 'vue-chartjs';
import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, Filler } from 'chart.js';
// Register Chart.js components
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend,
Filler
);
const props = defineProps({
title: {
type: String,
default: 'Memory Utilization'
},
value: {
type: Number,
default: 0
},
chartData: {
type: Object,
default: () => ({ labels: [], data: [] })
}
});
const chartOptions = {
responsive: true,
maintainAspectRatio: false,
clip: false,
resizeDelay: 0,
responsiveAnimationDuration: 0,
plugins: {
legend: {
display: false
},
tooltip: {
callbacks: {
label: (context) => `${context.parsed.y}%`
}
}
},
scales: {
x: {
display: false,
grid: {
display: false
}
},
y: {
display: false,
grid: {
display: false
},
min: 0,
max: 100
}
},
animation: false,
interaction: {
enabled: true,
mode: 'nearest',
intersect: false
},
onResize: (chart, size) => {
chart.resize();
}
};
const formattedChartData = computed(() => ({
labels: props.chartData.labels || [],
datasets: [{
label: 'Memory',
data: props.chartData.data || [],
borderColor: 'rgb(153, 102, 255)',
fill: true,
backgroundColor: 'rgba(153, 102, 255, 0.1)',
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: 'rgba(153, 102, 255, 0.5)',
pointBorderWidth: 1.5
}]
}));
</script>
<style scoped>
.chart-wrapper {
position: relative;
width: 100%;
height: 160px;
min-height: 160px;
overflow: hidden;
border: none;
border-radius: 0;
background-color: white;
margin: 0;
}
.metric-percentage {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.8);
padding: 0.25rem 0.75rem;
border-radius: 0.5rem;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
z-index: 2;
}
.metric-percentage .metric-value {
font-size: 2.5rem;
font-weight: 500;
color: #333;
line-height: 1;
margin: 0;
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}
.chart-memory {
background: white;
border: none;
}
.metric-card {
min-width: 180px;
background: white;
border: 1px solid rgba(0,0,0,0.125);
border-radius: 0.25rem;
height: 100%;
display: flex;
flex-direction: column;
min-width: 0;
width: 100%;
overflow: hidden;
}
.metric-card .card-header {
background-color: rgba(0, 0, 0, 0.03);
padding: 0.5rem;
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
height: 38px;
display: flex;
justify-content: space-between;
align-items: center;
}
.card-header h6 {
font-size: 0.95rem;
font-weight: 600;
display: flex;
justify-content: space-between;
align-items: center;
margin: 0;
}
.metric-card .card-body {
flex: 1;
padding: 0.5rem;
display: flex;
flex-direction: column;
position: relative;
width: 100%;
overflow: visible;
}
.metric-label {
color: #495057;
font-weight: 600;
}
</style>

View File

@ -0,0 +1,202 @@
<template>
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">{{ title }}</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">{{ value }}%</h4>
</div>
<div class="chart-wrapper">
<Line
:data="formattedChartData"
:options="chartOptions"
class="chart-storage"
/>
</div>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue';
import { Line } from 'vue-chartjs';
import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, Filler } from 'chart.js';
// Register Chart.js components
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend,
Filler
);
const props = defineProps({
title: {
type: String,
default: 'Storage Utilization'
},
value: {
type: Number,
default: 0
},
chartData: {
type: Object,
default: () => ({ labels: [], data: [] })
}
});
const chartOptions = {
responsive: true,
maintainAspectRatio: false,
clip: false,
resizeDelay: 0,
responsiveAnimationDuration: 0,
plugins: {
legend: {
display: false
},
tooltip: {
callbacks: {
label: (context) => `${context.parsed.y}%`
}
}
},
scales: {
x: {
display: false,
grid: {
display: false
}
},
y: {
display: false,
grid: {
display: false
},
min: 0,
max: 100
}
},
animation: false,
interaction: {
enabled: true,
mode: 'nearest',
intersect: false
},
onResize: (chart, size) => {
chart.resize();
}
};
const formattedChartData = computed(() => ({
labels: props.chartData.labels || [],
datasets: [{
label: 'Storage',
data: props.chartData.data || [],
borderColor: 'rgb(255, 159, 64)',
fill: true,
backgroundColor: 'rgba(255, 159, 64, 0.1)',
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: 'rgba(255, 159, 64, 0.5)',
pointBorderWidth: 1.5
}]
}));
</script>
<style scoped>
.chart-wrapper {
position: relative;
width: 100%;
height: 160px;
min-height: 160px;
overflow: hidden;
border: none;
border-radius: 0;
background-color: white;
margin: 0;
}
.metric-percentage {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.8);
padding: 0.25rem 0.75rem;
border-radius: 0.5rem;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
z-index: 2;
}
.metric-percentage .metric-value {
font-size: 2.5rem;
font-weight: 500;
color: #333;
line-height: 1;
margin: 0;
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}
.chart-storage {
background: white;
border: none;
}
.metric-card {
min-width: 180px;
background: white;
border: 1px solid rgba(0,0,0,0.125);
border-radius: 0.25rem;
height: 100%;
display: flex;
flex-direction: column;
min-width: 0;
width: 100%;
overflow: hidden;
}
.metric-card .card-header {
background-color: rgba(0, 0, 0, 0.03);
padding: 0.5rem;
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
height: 38px;
display: flex;
justify-content: space-between;
align-items: center;
}
.card-header h6 {
font-size: 0.95rem;
font-weight: 600;
display: flex;
justify-content: space-between;
align-items: center;
margin: 0;
}
.metric-card .card-body {
flex: 1;
padding: 0.5rem;
display: flex;
flex-direction: column;
position: relative;
width: 100%;
overflow: visible;
}
.metric-label {
color: #495057;
font-weight: 600;
}
</style>

View File

@ -1,19 +1,915 @@
<template>
<div class="content-grid">
<PageTitle title="Nodes" />
<NodeStatus :nodeData="nodeData" />
<!-- Node Tabs -->
<div class="node-tabs-wrapper">
<div class="node-tabs" ref="tabsContainer">
<button
v-for="node in nodeData"
:key="node.name"
class="node-tab"
:class="{ 'active': selectedNode === node.name }"
@click="selectNode(node.name)"
>
{{ node.name }}
</button>
</div>
<!-- Tab scroll buttons -->
<button class="tab-scroll-button left" @click="scrollTabs('left')" v-show="showLeftScroll">
<i class="fas fa-chevron-left"></i>
</button>
<button class="tab-scroll-button right" @click="scrollTabs('right')" v-show="showRightScroll">
<i class="fas fa-chevron-right"></i>
</button>
</div>
<!-- Node Details -->
<div v-if="selectedNodeData" class="node-details">
<!-- Information Cards Section -->
<div class="section-container" :class="{ 'collapsed': !sections.info }">
<!-- Collapsed section indicator -->
<div v-if="!sections.info" class="section-content-wrapper">
<div class="section-content">
<div class="collapsed-section-header">
<h6 class="card-title mb-0 metric-label">Node Information</h6>
</div>
</div>
<div class="toggle-column">
<button class="section-toggle" @click="toggleSection('info')">
<i class="fas fa-chevron-down"></i>
</button>
</div>
</div>
<!-- Toggle button for expanded section -->
<div v-show="sections.info" class="section-content-wrapper">
<div class="section-content">
<div class="metrics-row">
<!-- Card 1: Daemon State -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Daemon State</span>
</h6>
</div>
<div class="card-body">
<h4 class="metric-value">{{ selectedNodeData.daemon_state || 'Unknown' }}</h4>
</div>
</div>
<!-- Card 2: Coordinator State -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Coordinator State</span>
</h6>
</div>
<div class="card-body">
<h4 class="metric-value">{{ selectedNodeData.coordinator_state || 'Unknown' }}</h4>
</div>
</div>
<!-- Card 3: Domain State -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Domain State</span>
</h6>
</div>
<div class="card-body">
<h4 class="metric-value">{{ selectedNodeData.domain_state || 'Unknown' }}</h4>
</div>
</div>
<!-- Card 4: Domains Count -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Domains Count</span>
</h6>
</div>
<div class="card-body">
<h4 class="metric-value">{{ selectedNodeData.domains_count || 0 }}</h4>
</div>
</div>
<!-- Card 5: PVC Version -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">PVC Version</span>
</h6>
</div>
<div class="card-body">
<h4 class="metric-value">{{ selectedNodeData.pvc_version || 'Unknown' }}</h4>
</div>
</div>
<!-- Card 6: Kernel Version -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Kernel Version</span>
</h6>
</div>
<div class="card-body">
<h4 class="metric-value">{{ selectedNodeData.kernel || 'Unknown' }}</h4>
</div>
</div>
<!-- Card 7: Host CPU Count -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Host CPU Count</span>
</h6>
</div>
<div class="card-body">
<h4 class="metric-value">{{ selectedNodeData.cpu_count || 0 }}</h4>
</div>
</div>
<!-- Card 8: Guest CPU Count -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Guest CPU Count</span>
</h6>
</div>
<div class="card-body">
<h4 class="metric-value">{{ selectedNodeData.vcpu?.allocated || 0 }}</h4>
</div>
</div>
</div>
</div>
<div class="toggle-column expanded">
<button class="section-toggle" @click="toggleSection('info')">
<i class="fas fa-chevron-up"></i>
</button>
</div>
</div>
</div>
<!-- Utilization Graphs Section -->
<div class="section-container" :class="{ 'collapsed': !sections.graphs }">
<!-- Collapsed section indicator -->
<div v-if="!sections.graphs" class="section-content-wrapper">
<div class="section-content">
<div class="collapsed-section-header">
<h6 class="card-title mb-0 metric-label">Health & Utilization Graphs</h6>
</div>
</div>
<div class="toggle-column">
<button class="section-toggle" @click="toggleSection('graphs')">
<i class="fas fa-chevron-down"></i>
</button>
</div>
</div>
<!-- Toggle button for expanded section -->
<div v-show="sections.graphs" class="section-content-wrapper">
<div class="section-content">
<div class="graphs-row">
<!-- Health Chart -->
<HealthChart
title="Node Health"
:value="selectedNodeData.health || 0"
:chart-data="nodeHealthChartData"
/>
<!-- CPU Utilization Chart -->
<CPUChart
title="CPU Utilization"
:value="calculateCpuUtilization(selectedNodeData)"
:chart-data="nodeCpuChartData"
/>
<!-- Memory Utilization Chart -->
<MemoryChart
title="Memory Utilization"
:value="calculateMemoryUtilization(selectedNodeData)"
:chart-data="nodeMemoryChartData"
/>
<!-- Allocated Memory Chart -->
<StorageChart
title="Allocated Memory"
:value="calculateAllocatedMemory(selectedNodeData)"
:chart-data="nodeAllocatedMemoryChartData"
/>
</div>
</div>
<div class="toggle-column expanded">
<button class="section-toggle" @click="toggleSection('graphs')">
<i class="fas fa-chevron-up"></i>
</button>
</div>
</div>
</div>
<!-- Memory Resources Section -->
<div class="section-container" :class="{ 'collapsed': !sections.resources }">
<!-- Collapsed section indicator -->
<div v-if="!sections.resources" class="section-content-wrapper">
<div class="section-content">
<div class="collapsed-section-header">
<h6 class="card-title mb-0 metric-label">Memory Resources</h6>
</div>
</div>
<div class="toggle-column">
<button class="section-toggle" @click="toggleSection('resources')">
<i class="fas fa-chevron-down"></i>
</button>
</div>
</div>
<!-- Toggle button for expanded section -->
<div v-show="sections.resources" class="section-content-wrapper">
<div class="section-content">
<div class="resources-row">
<!-- Total Memory -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Total Memory</span>
</h6>
</div>
<div class="card-body">
<h4 class="metric-value">{{ formatMemory(selectedNodeData.memory?.total) }}</h4>
</div>
</div>
<!-- Used Memory -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Used Memory</span>
</h6>
</div>
<div class="card-body">
<h4 class="metric-value">{{ formatMemory(selectedNodeData.memory?.used) }}</h4>
</div>
</div>
<!-- Free Memory -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Free Memory</span>
</h6>
</div>
<div class="card-body">
<h4 class="metric-value">{{ formatMemory(selectedNodeData.memory?.free) }}</h4>
</div>
</div>
<!-- Allocated Memory -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Allocated Memory</span>
</h6>
</div>
<div class="card-body">
<h4 class="metric-value">{{ formatMemory(selectedNodeData.memory?.allocated) }}</h4>
</div>
</div>
<!-- Provisioned Memory -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Provisioned Memory</span>
</h6>
</div>
<div class="card-body">
<h4 class="metric-value">{{ formatMemory(selectedNodeData.memory?.provisioned) }}</h4>
</div>
</div>
</div>
</div>
<div class="toggle-column expanded">
<button class="section-toggle" @click="toggleSection('resources')">
<i class="fas fa-chevron-up"></i>
</button>
</div>
</div>
</div>
</div>
<!-- No node selected message -->
<div v-else class="no-node-selected">
<p>Select a node to view details</p>
</div>
</div>
</template>
<script setup>
import NodeStatus from '../components/NodeStatus.vue';
import { ref, computed, onMounted, watch, nextTick, onUnmounted } from 'vue';
import PageTitle from '../components/PageTitle.vue';
import CPUChart from '../components/charts/CPUChart.vue';
import MemoryChart from '../components/charts/MemoryChart.vue';
import StorageChart from '../components/charts/StorageChart.vue';
import HealthChart from '../components/charts/HealthChart.vue';
defineProps({
// Implement formatBytes function directly
function formatBytes(bytes, decimals = 2) {
if (bytes === undefined || bytes === null) return 'N/A';
if (bytes === 0) return '0 B';
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
// Format memory values (similar to formatBytes but with GB as default unit)
function formatMemory(bytes) {
if (bytes === undefined || bytes === null) return 'N/A';
if (bytes === 0) return '0 GB';
// Convert to GB with 2 decimal places
const gbValue = (bytes / (1024 * 1024 * 1024)).toFixed(2);
return `${gbValue} GB`;
}
const props = defineProps({
nodeData: {
type: Array,
required: true,
default: () => []
},
metricsData: {
type: Object,
required: true,
default: () => ({})
},
clusterData: {
type: Object,
required: true,
default: () => ({})
}
});
</script>
// State for sections (expanded/collapsed)
const sections = ref({
info: true,
graphs: true,
resources: true
});
// Toggle section visibility
const toggleSection = (section) => {
sections.value[section] = !sections.value[section];
};
// State for selected node and tab scrolling
const selectedNode = ref('');
const tabsContainer = ref(null);
const showLeftScroll = ref(false);
const showRightScroll = ref(false);
// Get the selected node data
const selectedNodeData = computed(() => {
if (!selectedNode.value || !props.nodeData) return null;
return props.nodeData.find(node => node.name === selectedNode.value) || null;
});
// Select a node
const selectNode = (nodeName) => {
selectedNode.value = nodeName;
// Scroll the selected tab into view
nextTick(() => {
const activeTab = tabsContainer.value?.querySelector('.node-tab.active');
if (activeTab) {
activeTab.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });
}
// Check if scroll buttons should be shown
checkScrollButtons();
});
};
// Check if scroll buttons should be shown
const checkScrollButtons = () => {
if (!tabsContainer.value) return;
const { scrollLeft, scrollWidth, clientWidth } = tabsContainer.value;
// Show left scroll button if not at the beginning
showLeftScroll.value = scrollLeft > 0;
// Show right scroll button if not at the end
showRightScroll.value = scrollLeft + clientWidth < scrollWidth - 1; // -1 for rounding errors
};
// Scroll tabs left or right
const scrollTabs = (direction) => {
if (!tabsContainer.value) return;
const scrollAmount = tabsContainer.value.clientWidth / 2;
const currentScroll = tabsContainer.value.scrollLeft;
if (direction === 'left') {
tabsContainer.value.scrollTo({
left: Math.max(0, currentScroll - scrollAmount),
behavior: 'smooth'
});
} else {
tabsContainer.value.scrollTo({
left: currentScroll + scrollAmount,
behavior: 'smooth'
});
}
// Check scroll buttons after scrolling
setTimeout(checkScrollButtons, 300);
};
// Calculate CPU utilization (load / cpu_count * 100)
const calculateCpuUtilization = (nodeData) => {
if (!nodeData || !nodeData.load || !nodeData.cpu_count) return 0;
const utilization = (nodeData.load / nodeData.cpu_count) * 100;
return Math.round(utilization);
};
// Calculate memory utilization (memory.used / memory.total * 100)
const calculateMemoryUtilization = (nodeData) => {
if (!nodeData || !nodeData.memory || !nodeData.memory.used || !nodeData.memory.total) return 0;
const utilization = (nodeData.memory.used / nodeData.memory.total) * 100;
return Math.round(utilization);
};
// Calculate allocated memory (memory.allocated / memory.total * 100)
const calculateAllocatedMemory = (nodeData) => {
if (!nodeData || !nodeData.memory || !nodeData.memory.allocated || !nodeData.memory.total) return 0;
const utilization = (nodeData.memory.allocated / nodeData.memory.total) * 100;
return Math.round(utilization);
};
// Prepare chart data for the node
const nodeHealthChartData = computed(() => {
// Get node metrics history if available
const nodeMetrics = props.metricsData.nodes?.[selectedNodeData.value.name];
if (nodeMetrics && nodeMetrics.health && nodeMetrics.health.data.length > 0) {
return {
labels: nodeMetrics.health.labels,
data: nodeMetrics.health.data
};
}
// Fallback to current value only
return {
labels: ['Health'],
data: [selectedNodeData.value.health || 0]
};
});
const nodeCpuChartData = computed(() => {
// Get node metrics history if available
const nodeMetrics = props.metricsData.nodes?.[selectedNodeData.value.name];
if (nodeMetrics && nodeMetrics.cpu && nodeMetrics.cpu.data.length > 0) {
return {
labels: nodeMetrics.cpu.labels,
data: nodeMetrics.cpu.data
};
}
// Fallback to current value only
return {
labels: ['CPU'],
data: [calculateCpuUtilization(selectedNodeData.value)]
};
});
const nodeMemoryChartData = computed(() => {
if (!selectedNodeData.value) return { labels: [], data: [] };
// Get node metrics history if available
const nodeMetrics = props.metricsData.nodes?.[selectedNodeData.value.name];
if (nodeMetrics && nodeMetrics.memory && nodeMetrics.memory.data.length > 0) {
return {
labels: nodeMetrics.memory.labels,
data: nodeMetrics.memory.data
};
}
// Fallback to current value only
return {
labels: ['Memory'],
data: [calculateMemoryUtilization(selectedNodeData.value)]
};
});
const nodeAllocatedMemoryChartData = computed(() => {
if (!selectedNodeData.value) return { labels: [], data: [] };
// Get node metrics history if available
const nodeMetrics = props.metricsData.nodes?.[selectedNodeData.value.name];
if (nodeMetrics && nodeMetrics.allocated && nodeMetrics.allocated.data.length > 0) {
return {
labels: nodeMetrics.allocated.labels,
data: nodeMetrics.allocated.data
};
}
// Fallback to current value only
return {
labels: ['Allocated'],
data: [calculateAllocatedMemory(selectedNodeData.value)]
};
});
// Initialize the component
onMounted(() => {
// Select the first node by default if available
if (props.nodeData && props.nodeData.length > 0) {
selectNode(props.nodeData[0].name);
}
// Check if scroll buttons should be shown
window.addEventListener('resize', checkScrollButtons);
nextTick(checkScrollButtons);
});
// Watch for changes in the nodes data
watch(() => props.nodeData, () => {
// If the currently selected node no longer exists, select the first available node
if (props.nodeData && props.nodeData.length > 0 && !props.nodeData.find(node => node.name === selectedNode.value)) {
selectNode(props.nodeData[0].name);
}
// Check if scroll buttons should be shown
nextTick(checkScrollButtons);
}, { deep: true });
// Clean up event listeners
onUnmounted(() => {
window.removeEventListener('resize', checkScrollButtons);
});
</script>
<style scoped>
.content-grid {
display: flex;
flex-direction: column;
gap: 0.5rem;
width: 100%;
}
/* Node tabs styling */
.node-tabs-wrapper {
position: relative;
width: 100%;
overflow: hidden;
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
margin-bottom: 1rem;
}
.node-tabs {
display: flex;
overflow-x: auto;
scrollbar-width: none; /* Hide scrollbar for Firefox */
-ms-overflow-style: none; /* Hide scrollbar for IE and Edge */
scroll-behavior: smooth;
padding: 0 40px; /* Make room for scroll buttons */
}
.node-tabs::-webkit-scrollbar {
display: none; /* Hide scrollbar for Chrome, Safari, and Opera */
}
.node-tab {
padding: 0.5rem 1rem;
background: none;
border: none;
border-bottom: 2px solid transparent;
cursor: pointer;
white-space: nowrap;
transition: all 0.2s;
color: #495057;
}
.node-tab:hover {
background-color: rgba(0, 0, 0, 0.03);
}
.node-tab.active {
border-bottom: 2px solid #0d6efd;
color: #0d6efd;
font-weight: 600;
}
.tab-scroll-button {
position: absolute;
top: 0;
height: 100%;
width: 40px;
background: rgba(255, 255, 255, 0.9);
border: none;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
}
.tab-scroll-button.left {
left: 0;
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}
.tab-scroll-button.right {
right: 0;
box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
}
/* Node details styling */
.node-details {
display: flex;
flex-direction: column;
gap: 0.5rem;
width: 100%;
}
.no-node-selected {
display: flex;
justify-content: center;
align-items: center;
height: 200px;
background-color: rgba(0, 0, 0, 0.03);
border-radius: 0.25rem;
color: #666;
}
/* Section styling */
.section-container {
position: relative;
margin-bottom: 0.5rem;
}
.section-content-wrapper {
display: flex;
position: relative;
}
.section-content {
flex: 1;
min-width: 0;
padding-right: 40px;
}
.toggle-column {
position: absolute;
top: 4px;
right: 0;
width: 40px;
height: 30px;
z-index: 10;
padding-left: 6px;
}
.section-toggle {
background: none;
border: none;
color: #666;
cursor: pointer;
padding: 0.25rem;
border-radius: 0.25rem;
transition: all 0.2s;
width: 30px;
height: 30px;
display: flex;
align-items: center;
justify-content: center;
background-color: rgba(255, 255, 255, 0.8);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.section-toggle:hover {
background-color: rgba(0, 0, 0, 0.05);
color: #333;
}
.collapsed-section-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.5rem;
background-color: rgba(0, 0, 0, 0.03);
border: 1px solid rgba(0, 0, 0, 0.125);
border-radius: 0.25rem;
height: 38px;
width: 100%;
}
.collapsed-section-header .card-title {
margin: 0;
color: #495057;
font-size: 0.95rem;
font-weight: 600;
}
.metrics-row, .graphs-row, .resources-row {
display: grid;
gap: 0.5rem;
width: 100%;
}
/* Responsive grid layouts */
@media (min-width: 1201px) {
.metrics-row {
grid-template-columns: repeat(4, 1fr);
}
.graphs-row {
grid-template-columns: repeat(4, 1fr);
}
.resources-row {
grid-template-columns: repeat(5, 1fr);
}
}
@media (min-width: 801px) and (max-width: 1200px) {
.metrics-row {
grid-template-columns: repeat(2, 1fr);
}
.graphs-row {
grid-template-columns: repeat(2, 1fr);
}
.resources-row {
grid-template-columns: repeat(5, 1fr);
}
}
@media (max-width: 800px) {
.metrics-row, .graphs-row, .resources-row {
grid-template-columns: 1fr;
}
}
.metric-card {
min-width: 180px;
background: white;
border: 1px solid rgba(0,0,0,0.125);
border-radius: 0.25rem;
height: 100%;
display: flex;
flex-direction: column;
min-width: 0;
width: 100%;
overflow: hidden;
}
.metric-card .card-header {
background-color: rgba(0, 0, 0, 0.03);
padding: 0.5rem;
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
height: 38px;
display: flex;
justify-content: space-between;
align-items: center;
}
.card-header h6 {
font-size: 0.95rem;
font-weight: 600;
display: flex;
justify-content: space-between;
align-items: center;
margin: 0;
}
.metric-card .card-body {
flex: 1;
padding: 0.5rem;
display: flex;
flex-direction: column;
position: relative;
width: 100%;
overflow: visible;
justify-content: center;
align-items: center;
}
.metric-card .metric-value {
font-size: 1.25rem;
font-weight: bold;
color: #333;
line-height: 1;
margin: 0;
text-align: center;
white-space: nowrap;
min-width: fit-content;
}
.metric-label {
color: #495057;
font-weight: 600;
}
.metric-percentage {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.8);
padding: 0.25rem 0.75rem;
border-radius: 0.5rem;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
z-index: 2;
}
.metric-percentage .metric-value {
font-size: 2.5rem;
font-weight: 500;
color: #333;
line-height: 1;
margin: 0;
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}
.chart-wrapper {
position: relative;
width: 100%;
height: 160px;
min-height: 160px;
overflow: hidden;
border: none;
border-radius: 0;
background-color: white;
margin: 0;
}
/* Additional styles from ClusterOverview.vue */
.section-container.collapsed {
margin-bottom: 0.5rem;
}
.section-container.collapsed .section-content-wrapper {
margin-bottom: 0;
}
.toggle-column.expanded {
top: 0;
right: 0;
height: 100%;
display: flex;
align-items: flex-start;
padding-top: 4px;
}
/* Status colors */
.status-healthy { color: #28a745; }
.status-warning { color: #ffc107; }
.status-error { color: #dc3545; }
/* Health delta classes */
.delta-high {
background: rgba(220, 53, 69, 0.1);
color: #dc3545;
}
.delta-medium {
background: rgba(255, 193, 7, 0.1);
color: #d39e00;
}
.delta-low {
background: rgba(40, 167, 69, 0.1);
color: #28a745;
}
/* Chart colors */
.chart-cpu {
background: white;
border: none;
}
.chart-memory {
background: white;
border: none;
}
.chart-storage, .chart-allocated {
background: white;
border: none;
}
.chart-health {
background: white;
border: none;
}
</style>

View File

@ -1,7 +1,7 @@
<template>
<div class="content-grid">
<PageTitle title="Cluster Overview" />
<ClusterOverview
<ClusterOverview
:clusterData="clusterData"
:metricsData="metricsData"
/>
@ -24,4 +24,4 @@ defineProps({
default: () => ({})
}
});
</script>
</script>