alerts-dashboard-pro / index.html
bartmango2's picture
melhore o layout da tabela html...deixe-a mais visualmente agravel.... e alterne a cord de fundo das linhas, sutilmente mas que facilite diferenciar cada linha
fae546e verified
Raw History Blame Contribute Delete
29.3 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alerts Dashboard</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.min.js"></script>
<style>
.table-container {
max-height: 500px;
overflow-y: auto;
}
.sticky-header {
position: sticky;
top: 0;
background-color: white;
z-index: 10;
}
.context-menu {
position: absolute;
background: white;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
border-radius: 6px;
z-index: 100;
display: none;
}
.context-menu-item {
padding: 8px 16px;
cursor: pointer;
transition: background 0.2s;
}
.context-menu-item:hover {
background: #f3f4f6;
}
[data-tooltip] {
position: relative;
}
[data-tooltip]:hover:after {
content: attr(data-tooltip);
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%);
background: #333;
color: white;
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
white-space: nowrap;
z-index: 100;
}
</style>
</head>
<body class="bg-gray-50">
<div id="app" class="container mx-auto px-4 py-8">
<header class="mb-8">
<h1 class="text-3xl font-bold text-gray-800">Alerts Dashboard Pro</h1>
<p class="text-gray-600">Monitor and manage your system alerts efficiently</p>
</header>
<div class="bg-white rounded-lg shadow-md p-6 mb-8">
<h2 class="text-xl font-semibold mb-4 text-gray-700">Filters</h2>
<form @submit.prevent="applyFilters" class="grid grid-cols-1 md:grid-cols-4 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Alert Status</label>
<select v-model="filters.alertStatus" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500">
<option value="">All</option>
<option value="Open">Open</option>
<option value="Closed">Closed</option>
<option value="Working">Working</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Compliance</label>
<select v-model="filters.compliance" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500">
<option value="">All</option>
<option value="USG/SI">USG/SI</option>
<option value="Non-Compliance">Non-Compliance</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Stage</label>
<select v-model="filters.stage" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500">
<option value="">All</option>
<option value="1">Stage 1</option>
<option value="2">Stage 2</option>
<option value="3">Stage 3</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Search</label>
<div class="flex">
<input v-model="filters.search" type="text" class="flex-1 px-3 py-2 border border-gray-300 rounded-l-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500" placeholder="Search alerts...">
<button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-r-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<i data-feather="search"></i>
</button>
</div>
</div>
</form>
</div>
<div class="bg-white rounded-lg shadow-md p-6 mb-8">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-700">Alerts Table</h2>
<div class="flex items-center space-x-2">
<span class="text-sm text-gray-500">Showing {{ filteredAlerts.length }} of {{ alerts.length }} alerts</span>
<button @click="exportToCSV" class="flex items-center px-3 py-1.5 text-sm bg-green-100 text-green-700 rounded hover:bg-green-200">
<i data-feather="download" class="mr-1 w-4 h-4"></i> Export
</button>
</div>
</div>
<div class="table-container">
<table class="min-w-full">
<thead class="sticky-header">
<tr class="bg-indigo-50">
<th v-for="column in columns" :key="column.key" scope="col" class="px-4 py-3 text-left text-xs font-semibold text-indigo-700 uppercase tracking-wider border-b border-indigo-100">
{{ column.label }}
</th>
</tr>
</thead>
<tbody>
<tr v-for="(alert, index) in paginatedAlerts" :key="alert.ID_FLAlerts"
@contextmenu.prevent="openContextMenu($event, alert)"
:class="['cursor-pointer', index % 2 === 0 ? 'bg-white' : 'bg-gray-50', 'hover:bg-indigo-50']">
<td class="px-4 py-3 whitespace-nowrap text-sm font-medium text-indigo-600 border-b border-indigo-50">
{{ alert.ID_FLAlerts }}
</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700 border-b border-indigo-50">
{{ alert.DT_Alert }}
</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700 border-b border-indigo-50">
{{ alert.Compliance }}
</td>
<td class="px-4 py-3 text-sm text-gray-700 border-b border-indigo-50">
<div class="max-w-xs truncate hover:text-clip" :title="alert.DS_Alert">{{ alert.DS_Alert }}</div>
</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700 border-b border-indigo-50">
{{ alert.Assigned_DBA }}
</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700 border-b border-indigo-50">
{{ alert.DT_AlertResponse }}
</td>
<td class="px-4 py-3 text-sm text-gray-700 border-b border-indigo-50">
<div class="max-w-xs truncate hover:text-clip" :title="alert.DS_ActionTaken">{{ alert.DS_ActionTaken }}</div>
</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700 border-b border-indigo-50">
{{ alert.FL_RootCauseAdressed ? 'Yes' : 'No' }}
</td>
<td class="px-4 py-3 whitespace-nowrap border-b border-indigo-50">
<span :class="`px-2 py-1 inline-flex text-xs leading-4 font-semibold rounded-full bg-${getStatusColor(alert.Alert_Status)}-100 text-${getStatusColor(alert.Alert_Status)}-800 border border-${getStatusColor(alert.Alert_Status)}-200`">
{{ alert.Alert_Status }}
</span>
</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700 border-b border-indigo-50">
{{ alert.DS_Category }}
</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700 border-b border-indigo-50">
{{ alert.DS_Server }}
</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700 border-b border-indigo-50">
<div class="flex items-center">
<i :data-feather="getSourceIcon(alert.ID_Source)" class="w-4 h-4 mr-1 text-indigo-500"></i>
{{ alert.ID_Source }}
</div>
</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700 border-b border-indigo-50">
{{ alert.ID_Stage }}
</td>
</tr>
</tbody>
</table>
</div>
<div class="flex items-center justify-between mt-4">
<div class="text-sm text-gray-500">
Page {{ currentPage }} of {{ totalPages }}
</div>
<div class="flex space-x-2">
<button @click="prevPage" :disabled="currentPage === 1" class="px-4 py-2 border rounded-md text-sm font-medium" :class="{'bg-gray-200 cursor-not-allowed': currentPage === 1, 'hover:bg-gray-100': currentPage > 1}">
Previous
</button>
<button @click="nextPage" :disabled="currentPage === totalPages" class="px-4 py-2 border rounded-md text-sm font-medium" :class="{'bg-gray-200 cursor-not-allowed': currentPage === totalPages, 'hover:bg-gray-100': currentPage < totalPages}">
Next
</button>
</div>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
<div class="bg-white rounded-lg shadow-md p-6">
<h2 class="text-xl font-semibold mb-4 text-gray-700">Alert Status Distribution</h2>
<canvas id="statusChart"></canvas>
</div>
<div class="bg-white rounded-lg shadow-md p-6">
<h2 class="text-xl font-semibold mb-4 text-gray-700">Alert Sources</h2>
<canvas id="sourceChart"></canvas>
</div>
</div>
<div class="context-menu" id="contextMenu">
<div class="context-menu-item" @click="viewDetails">
<i data-feather="eye" class="mr-2 w-4 h-4"></i> View Details
</div>
<div class="context-menu-item" @click="editAlert">
<i data-feather="edit" class="mr-2 w-4 h-4"></i> Edit Alert
</div>
<div class="context-menu-item" @click="changeStatus">
<i data-feather="refresh-cw" class="mr-2 w-4 h-4"></i> Change Status
</div>
<div class="context-menu-item text-red-500 hover:bg-red-50" @click="deleteAlert">
<i data-feather="trash-2" class="mr-2 w-4 h-4"></i> Delete Alert
</div>
</div>
</div>
<script>
const { createApp, ref, computed, onMounted } = Vue;
createApp({
setup() {
const alerts = ref([
{
ID_FLAlerts: 587008,
DT_Alert: "2025-10-03 8:11",
Compliance: "",
DS_Alert: "Foglight has generated a Warning alarm for PPOLWPQMR00003-PRD : DBSS - Process CPU Utilization",
Assigned_DBA: "Joao Paulo",
DT_AlertResponse: "2025-10-03 8:19",
DS_ActionTaken: "There are 8 jobs triggered by acct \"GSM1900\\gMSA_PSQL_PQMR$\", making CPU load for the SQL hit 72%. We are monitoring.",
FL_RootCauseAdressed: 0,
Alert_Status: "Working",
NM_RowVersion: 2,
FL_FalseAlarm: 0,
Shift: "BR/PH",
DS_Category: "CPU",
DS_Server: "PPOLWPQMR00003",
FL_Maintenance: 0,
Qty_Last7: 15,
Qty_TotalLast7: 15,
DS_Level: "Warning",
SLA: 5,
FullName: "PPOLWPQMR00003\\PRD,50107",
ID_Source: 1,
ID_Stage: 1
},
{
ID_FLAlerts: 587007,
DT_Alert: "2025-10-03 7:16",
Compliance: "",
DS_Alert: "Foglight has generated a Warning alarm for PPOLWPQMR00003-PRD : DBSS - Process CPU Utilization",
Assigned_DBA: "Joao Paulo",
DT_AlertResponse: "2025-10-03 8:19",
DS_ActionTaken: "There are 8 jobs triggered by acct \"GSM1900\\gMSA_PSQL_PQMR$\", making CPU load for the SQL hit 72%. We are monitoring.",
FL_RootCauseAdressed: 0,
Alert_Status: "Working",
NM_RowVersion: 2,
FL_FalseAlarm: 0,
Shift: "BR/PH",
DS_Category: "CPU",
DS_Server: "PPOLWPQMR00003",
FL_Maintenance: 0,
Qty_Last7: 15,
Qty_TotalLast7: 15,
DS_Level: "Warning",
SLA: 3,
FullName: "PPOLWPQMR00003\\PRD,50107",
ID_Source: 1,
ID_Stage: 1
},
{
ID_FLAlerts: 587006,
DT_Alert: "2025-10-03 6:53",
Compliance: "",
DS_Alert: "Foglight has generated a Warning alarm for PTTNWUCCE001F0 : DBSS - Process CPU Utilization",
Assigned_DBA: "Joao Paulo",
DT_AlertResponse: "2025-10-03 8:21",
DS_ActionTaken: "There were 4 UPDATE STATISTICS running at same time causing the spike. Right now there's only 2 and CPU load dropped to 28% for the SQL.",
FL_RootCauseAdressed: 0,
Alert_Status: "Closed",
NM_RowVersion: 2,
FL_FalseAlarm: 0,
Shift: "BR/PH",
DS_Category: "CPU",
DS_Server: "PTTNWUCCE001F0",
FL_Maintenance: 0,
Qty_Last7: 9,
Qty_TotalLast7: 9,
DS_Level: "Warning",
SLA: 5,
FullName: "PTTNWUCCE001F0,1433",
ID_Source: 1,
ID_Stage: 1
},
{
ID_FLAlerts: 587005,
DT_Alert: "2025-10-03 4:41",
Compliance: "",
DS_Alert: "This is a external alert: (critical). Please check the failed job : [sicm_hds_PurgeTCV]",
Assigned_DBA: "Rutika Khatavkar",
DT_AlertResponse: "2025-10-03 4:56",
DS_ActionTaken: "Executed as user: NT SERVICE\\SQLSERVERAGENT. Transaction (Process ID 209) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. the job failed due to deadlock",
FL_RootCauseAdressed: 0,
Alert_Status: "Closed",
NM_RowVersion: 2,
FL_FalseAlarm: 0,
Shift: "IND",
DS_Category: "External (Non FL)",
DS_Server: "PTTNWSSCR0000B",
FL_Maintenance: 0,
Qty_Last7: 1,
Qty_TotalLast7: 1,
DS_Level: "",
SLA: 4,
FullName: "PTTNWSSCR0000B,1433",
ID_Source: 4,
ID_Stage: 1
},
{
ID_FLAlerts: 587004,
DT_Alert: "2025-10-03 4:41",
Compliance: "",
DS_Alert: "This is a external alert: (critical). Please check the failed job : [PSQLDWH12\\STG-ServiceNOW_NDW-AR_PUBLICATION_00008-6]",
Assigned_DBA: "Soni Rani",
DT_AlertResponse: "2025-10-03 4:47",
DS_ActionTaken: "Job needs to be disabled, app team has been informed.",
FL_RootCauseAdressed: 0,
Alert_Status: "Closed",
NM_RowVersion: 2,
FL_FalseAlarm: 0,
Shift: "IND",
DS_Category: "External (Non FL)",
DS_Server: "PRDPWATTY001B",
FL_Maintenance: 0,
Qty_Last7: 7,
Qty_TotalLast7: 7,
DS_Level: "",
SLA: 4,
FullName: "PRDPWATTY001B\\ATTY01,1433",
ID_Source: 4,
ID_Stage: 1
}
]);
const columns = ref([
{ key: 'ID_FLAlerts', label: 'ID' },
{ key: 'DT_Alert', label: 'Date' },
{ key: 'Compliance', label: 'Compliance' },
{ key: 'DS_Alert', label: 'Description' },
{ key: 'Assigned_DBA', label: 'Assigned DBA' },
{ key: 'DT_AlertResponse', label: 'Response Date' },
{ key: 'DS_ActionTaken', label: 'Action Taken' },
{ key: 'FL_RootCauseAdressed', label: 'Root Cause Addressed' },
{ key: 'Alert_Status', label: 'Status' },
{ key: 'DS_Category', label: 'Category' },
{ key: 'DS_Server', label: 'Server' },
{ key: 'ID_Source', label: 'Source' },
{ key: 'ID_Stage', label: 'Stage' }
]);
const filters = ref({
alertStatus: '',
compliance: '',
stage: '',
search: ''
});
const selectedAlert = ref(null);
const currentPage = ref(1);
const itemsPerPage = 10;
const filteredAlerts = computed(() => {
return alerts.value.filter(alert => {
return (
(filters.value.alertStatus === '' || alert.Alert_Status === filters.value.alertStatus) &&
(filters.value.compliance === '' || alert.Compliance === filters.value.compliance) &&
(filters.value.stage === '' || alert.ID_Stage.toString() === filters.value.stage) &&
(filters.value.search === '' ||
Object.values(alert).some(val =>
String(val).toLowerCase().includes(filters.value.search.toLowerCase())
)
)
);
});
});
const totalPages = computed(() => {
return Math.ceil(filteredAlerts.value.length / itemsPerPage);
});
const paginatedAlerts = computed(() => {
const start = (currentPage.value - 1) * itemsPerPage;
const end = start + itemsPerPage;
return filteredAlerts.value.slice(start, end);
});
const statusChart = ref(null);
const sourceChart = ref(null);
const nextPage = () => {
if (currentPage.value < totalPages.value) {
currentPage.value++;
}
};
const prevPage = () => {
if (currentPage.value > 1) {
currentPage.value--;
}
};
const applyFilters = () => {
currentPage.value = 1;
};
const getStatusColor = (status) => {
switch(status) {
case 'Open': return 'red';
case 'Closed': return 'green';
case 'Working': return 'yellow';
default: return 'gray';
}
};
const getSourceIcon = (source) => {
switch(source) {
case 1: return 'monitor'; // Foglight
case 2: return 'cloud'; // Azure
case 3: return 'external-link'; // External
default: return 'alert-circle';
}
};
const openContextMenu = (event, alert) => {
selectedAlert.value = alert;
const menu = document.getElementById('contextMenu');
menu.style.display = 'block';
menu.style.left = `${event.clientX}px`;
menu.style.top = `${event.clientY}px`;
document.addEventListener('click', closeContextMenu);
};
const closeContextMenu = () => {
const menu = document.getElementById('contextMenu');
menu.style.display = 'none';
document.removeEventListener('click', closeContextMenu);
};
const viewDetails = () => {
alert(`Viewing details for alert #${selectedAlert.value.ID_FLAlerts}`);
closeContextMenu();
};
const editAlert = () => {
alert(`Editing alert #${selectedAlert.value.ID_FLAlerts}`);
closeContextMenu();
};
const changeStatus = () => {
alert(`Changing status for alert #${selectedAlert.value.ID_FLAlerts}`);
closeContextMenu();
};
const deleteAlert = () => {
if (confirm(`Are you sure you want to delete alert #${selectedAlert.value.ID_FLAlerts}?`)) {
alerts.value = alerts.value.filter(a => a.ID_FLAlerts !== selectedAlert.value.ID_FLAlerts);
}
closeContextMenu();
};
const exportToCSV = () => {
const csvContent = "data:text/csv;charset=utf-8,"
+ columns.value.map(c => c.label).join(",") + "\n"
+ filteredAlerts.value.map(a =>
columns.value.map(c => a[c.key]).join(",")
).join("\n");
const encodedUri = encodeURI(csvContent);
const link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "alerts_export.csv");
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
const initCharts = () => {
const statusCounts = {
Open: 0,
Closed: 0,
Working: 0
};
const sourceCounts = {
1: 0, // Foglight
2: 0, // Azure
3: 0, // External
4: 0 // Other
};
alerts.value.forEach(alert => {
statusCounts[alert.Alert_Status]++;
sourceCounts[alert.ID_Source]++;
});
// Status Chart
const statusCtx = document.getElementById('statusChart').getContext('2d');
statusChart.value = new Chart(statusCtx, {
type: 'doughnut',
data: {
labels: Object.keys(statusCounts),
datasets: [{
data: Object.values(statusCounts),
backgroundColor: [
'rgba(239, 68, 68, 0.7)', // red-500
'rgba(16, 185, 129, 0.7)', // green-500
'rgba(234, 179, 8, 0.7)' // yellow-500
],
borderColor: [
'rgba(239, 68, 68, 1)',
'rgba(16, 185, 129, 1)',
'rgba(234, 179, 8, 1)'
],
borderWidth: 1
}]
},
options: {
responsive: true,
plugins: {
legend: {
position: 'bottom',
}
}
}
});
// Source Chart
const sourceCtx = document.getElementById('sourceChart').getContext('2d');
sourceChart.value = new Chart(sourceCtx, {
type: 'bar',
data: {
labels: ['Foglight', 'Azure', 'External', 'Other'],
datasets: [{
label: 'Alert Sources',
data: Object.values(sourceCounts),
backgroundColor: [
'rgba(99, 102, 241, 0.7)', // indigo-500
'rgba(59, 130, 246, 0.7)', // blue-500
'rgba(16, 185, 129, 0.7)', // green-500
'rgba(156, 163, 175, 0.7)' // gray-400
],
borderColor: [
'rgba(99, 102, 241, 1)',
'rgba(59, 130, 246, 1)',
'rgba(16, 185, 129, 1)',
'rgba(156, 163, 175, 1)'
],
borderWidth: 1
}]
},
options: {
responsive: true,
scales: {
y: {
beginAtZero: true
}
}
}
});
};
onMounted(() => {
feather.replace();
initCharts();
});
return {
alerts,
columns,
filters,
filteredAlerts,
paginatedAlerts,
currentPage,
totalPages,
nextPage,
prevPage,
applyFilters,
getStatusColor,
getSourceIcon,
openContextMenu,
viewDetails,
editAlert,
changeStatus,
deleteAlert,
exportToCSV
};
}
}).mount('#app');
</script>
<script>feather.replace();</script>
</body>
</html>