KuRRe8 commited on
Commit
d4a6e3d
·
verified ·
1 Parent(s): b1de5af

做一个用于故障预警的网页,最上面是一个传感器指标的折线图,放一些虚拟的数据,并且在outlier点标注出来。下面是一个表格,也放一些虚拟的数据。要求美观,必要时候可以借鉴echats

Browse files
Files changed (4) hide show
  1. README.md +8 -5
  2. index.html +116 -19
  3. script.js +147 -0
  4. style.css +53 -18
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Faulty Whistle Sensor Vigilante
3
- emoji: 🏆
4
- colorFrom: blue
5
- colorTo: indigo
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: Faulty Whistle - Sensor Vigilante
3
+ colorFrom: green
4
+ colorTo: purple
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://huggingface.co/deepsite).
index.html CHANGED
@@ -1,19 +1,116 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Faulty Whistle - Sensor Monitoring</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
10
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
11
+ <script src="https://unpkg.com/feather-icons"></script>
12
+ </head>
13
+ <body class="bg-gray-50">
14
+ <div class="min-h-screen flex flex-col">
15
+ <!-- Header -->
16
+ <header class="bg-indigo-600 text-white shadow-lg">
17
+ <div class="container mx-auto px-4 py-6">
18
+ <div class="flex justify-between items-center">
19
+ <div class="flex items-center space-x-3">
20
+ <i data-feather="alert-triangle" class="w-8 h-8"></i>
21
+ <h1 class="text-2xl font-bold">Faulty Whistle</h1>
22
+ </div>
23
+ <div class="flex items-center space-x-4">
24
+ <span class="bg-indigo-500 px-3 py-1 rounded-full text-sm">Live Monitoring</span>
25
+ <button class="bg-white text-indigo-600 px-4 py-2 rounded-lg font-medium hover:bg-indigo-50 transition">
26
+ <i data-feather="bell" class="inline mr-2"></i> Alerts
27
+ </button>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ </header>
32
+
33
+ <!-- Main Content -->
34
+ <main class="flex-grow container mx-auto px-4 py-8">
35
+ <!-- Chart Section -->
36
+ <section class="mb-12 bg-white rounded-xl shadow-md overflow-hidden">
37
+ <div class="p-6 border-b border-gray-200">
38
+ <h2 class="text-xl font-semibold text-gray-800 flex items-center">
39
+ <i data-feather="activity" class="mr-2 text-indigo-500"></i>
40
+ Sensor Metrics Overview
41
+ </h2>
42
+ <p class="text-gray-500 mt-1">Real-time monitoring with anomaly detection</p>
43
+ </div>
44
+ <div id="chartContainer" class="w-full h-96 p-4"></div>
45
+ </section>
46
+
47
+ <!-- Table Section -->
48
+ <section class="bg-white rounded-xl shadow-md overflow-hidden">
49
+ <div class="p-6 border-b border-gray-200">
50
+ <h2 class="text-xl font-semibold text-gray-800 flex items-center">
51
+ <i data-feather="database" class="mr-2 text-indigo-500"></i>
52
+ Recent Anomalies
53
+ </h2>
54
+ <p class="text-gray-500 mt-1">Last 24 hours of detected issues</p>
55
+ </div>
56
+ <div class="overflow-x-auto">
57
+ <table class="min-w-full divide-y divide-gray-200">
58
+ <thead class="bg-gray-50">
59
+ <tr>
60
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Sensor ID</th>
61
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Metric</th>
62
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Value</th>
63
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Threshold</th>
64
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Timestamp</th>
65
+ <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
66
+ </tr>
67
+ </thead>
68
+ <tbody class="bg-white divide-y divide-gray-200" id="anomalyTable">
69
+ <!-- Table rows will be populated by JavaScript -->
70
+ </tbody>
71
+ </table>
72
+ </div>
73
+ <div class="px-6 py-4 bg-gray-50 border-t border-gray-200 flex items-center justify-between">
74
+ <div class="text-sm text-gray-500">
75
+ Showing <span class="font-medium">1</span> to <span class="font-medium">5</span> of <span class="font-medium">12</span> anomalies
76
+ </div>
77
+ <div class="flex space-x-2">
78
+ <button class="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">
79
+ Previous
80
+ </button>
81
+ <button class="px-3 py-1 border border-indigo-500 rounded-md text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700">
82
+ Next
83
+ </button>
84
+ </div>
85
+ </div>
86
+ </section>
87
+ </main>
88
+
89
+ <!-- Footer -->
90
+ <footer class="bg-gray-800 text-white py-6">
91
+ <div class="container mx-auto px-4">
92
+ <div class="flex flex-col md:flex-row justify-between items-center">
93
+ <div class="mb-4 md:mb-0">
94
+ <p class="text-gray-300">© 2023 Faulty Whistle Monitoring System</p>
95
+ </div>
96
+ <div class="flex space-x-6">
97
+ <a href="#" class="text-gray-300 hover:text-white transition">
98
+ <i data-feather="github"></i>
99
+ </a>
100
+ <a href="#" class="text-gray-300 hover:text-white transition">
101
+ <i data-feather="twitter"></i>
102
+ </a>
103
+ <a href="#" class="text-gray-300 hover:text-white transition">
104
+ <i data-feather="linkedin"></i>
105
+ </a>
106
+ </div>
107
+ </div>
108
+ </div>
109
+ </footer>
110
+ </div>
111
+
112
+ <script src="script.js"></script>
113
+ <script>feather.replace();</script>
114
+ <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
115
+ </body>
116
+ </html>
script.js ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener('DOMContentLoaded', function() {
2
+ // Initialize chart
3
+ const chartDom = document.getElementById('chartContainer');
4
+ const myChart = echarts.init(chartDom);
5
+
6
+ // Generate sample data with outliers
7
+ const hours = Array.from({length: 24}, (_, i) => `${i}:00`);
8
+ const temperatureData = Array.from({length: 24}, () => Math.floor(Math.random() * 10) + 20);
9
+ // Add some outliers
10
+ temperatureData[5] = 35;
11
+ temperatureData[12] = 5;
12
+ temperatureData[18] = 38;
13
+
14
+ const markPoints = [
15
+ { name: 'High Temp', value: '35°C', xAxis: 5, yAxis: 35, itemStyle: { color: '#ef4444' } },
16
+ { name: 'Low Temp', value: '5°C', xAxis: 12, yAxis: 5, itemStyle: { color: '#3b82f6' } },
17
+ { name: 'High Temp', value: '38°C', xAxis: 18, yAxis: 38, itemStyle: { color: '#ef4444' } }
18
+ ];
19
+
20
+ // Chart configuration
21
+ const option = {
22
+ tooltip: {
23
+ trigger: 'axis',
24
+ formatter: '{b}<br/>{a0}: {c0}°C'
25
+ },
26
+ legend: {
27
+ data: ['Temperature'],
28
+ right: 10,
29
+ top: 0
30
+ },
31
+ grid: {
32
+ left: '3%',
33
+ right: '4%',
34
+ bottom: '3%',
35
+ containLabel: true
36
+ },
37
+ xAxis: {
38
+ type: 'category',
39
+ boundaryGap: false,
40
+ data: hours,
41
+ axisLine: {
42
+ lineStyle: {
43
+ color: '#9ca3af'
44
+ }
45
+ },
46
+ axisLabel: {
47
+ color: '#6b7280'
48
+ }
49
+ },
50
+ yAxis: {
51
+ type: 'value',
52
+ name: 'Temperature (°C)',
53
+ axisLine: {
54
+ show: true,
55
+ lineStyle: {
56
+ color: '#9ca3af'
57
+ }
58
+ },
59
+ axisLabel: {
60
+ color: '#6b7280',
61
+ formatter: '{value}°C'
62
+ },
63
+ splitLine: {
64
+ lineStyle: {
65
+ color: '#e5e7eb'
66
+ }
67
+ }
68
+ },
69
+ series: [
70
+ {
71
+ name: 'Temperature',
72
+ type: 'line',
73
+ data: temperatureData,
74
+ smooth: true,
75
+ lineStyle: {
76
+ width: 3,
77
+ color: '#6366f1'
78
+ },
79
+ itemStyle: {
80
+ color: '#6366f1'
81
+ },
82
+ areaStyle: {
83
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
84
+ { offset: 0, color: 'rgba(99, 102, 241, 0.3)' },
85
+ { offset: 1, color: 'rgba(99, 102, 241, 0.1)' }
86
+ ])
87
+ },
88
+ markPoint: {
89
+ data: markPoints,
90
+ symbol: 'circle',
91
+ symbolSize: 10,
92
+ label: {
93
+ show: true,
94
+ formatter: '{b}',
95
+ position: 'top',
96
+ color: '#fff',
97
+ backgroundColor: 'rgba(0,0,0,0.7)',
98
+ padding: [3, 5],
99
+ borderRadius: 4
100
+ }
101
+ }
102
+ }
103
+ ]
104
+ };
105
+
106
+ myChart.setOption(option);
107
+
108
+ // Handle window resize
109
+ window.addEventListener('resize', function() {
110
+ myChart.resize();
111
+ });
112
+
113
+ // Populate table with sample data
114
+ const anomalyData = [
115
+ { id: 'S-001', metric: 'Temperature', value: '35°C', threshold: '30°C', timestamp: '2023-06-15 05:12:34', status: 'critical' },
116
+ { id: 'S-002', metric: 'Pressure', value: '12.5 bar', threshold: '10 bar', timestamp: '2023-06-15 08:45:21', status: 'warning' },
117
+ { id: 'S-003', metric: 'Vibration', value: '0.85 mm/s', threshold: '0.5 mm/s', timestamp: '2023-06-15 11:23:56', status: 'warning' },
118
+ { id: 'S-001', metric: 'Temperature', value: '5°C', threshold: '10°C', timestamp: '2023-06-15 12:34:12', status: 'critical' },
119
+ { id: 'S-004', metric: 'Humidity', value: '92%', threshold: '85%', timestamp: '2023-06-15 18:05:43', status: 'warning' }
120
+ ];
121
+
122
+ const tableBody = document.getElementById('anomalyTable');
123
+
124
+ anomalyData.forEach(item => {
125
+ const row = document.createElement('tr');
126
+
127
+ let statusClass = 'status-warning';
128
+ let statusText = 'Warning';
129
+ if (item.status === 'critical') {
130
+ statusClass = 'status-critical';
131
+ statusText = 'Critical';
132
+ }
133
+
134
+ row.innerHTML = `
135
+ <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${item.id}</td>
136
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.metric}</td>
137
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 font-semibold">${item.value}</td>
138
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.threshold}</td>
139
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.timestamp}</td>
140
+ <td class="px-6 py-4 whitespace-nowrap">
141
+ <span class="${statusClass}">${statusText}</span>
142
+ </td>
143
+ `;
144
+
145
+ tableBody.appendChild(row);
146
+ });
147
+ });
style.css CHANGED
@@ -1,28 +1,63 @@
 
 
 
1
  body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
 
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
28
  }
 
 
 
 
 
1
+ /* Custom styles that complement Tailwind */
2
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
3
+
4
  body {
5
+ font-family: 'Inter', sans-serif;
6
+ }
7
+
8
+ /* Custom scrollbar */
9
+ ::-webkit-scrollbar {
10
+ width: 8px;
11
+ height: 8px;
12
+ }
13
+
14
+ ::-webkit-scrollbar-track {
15
+ background: #f1f1f1;
16
+ border-radius: 10px;
17
+ }
18
+
19
+ ::-webkit-scrollbar-thumb {
20
+ background: #888;
21
+ border-radius: 10px;
22
+ }
23
+
24
+ ::-webkit-scrollbar-thumb:hover {
25
+ background: #555;
26
+ }
27
+
28
+ /* Chart container responsive behavior */
29
+ #chartContainer {
30
+ min-height: 400px;
31
+ }
32
+
33
+ @media (max-width: 768px) {
34
+ #chartContainer {
35
+ height: 300px;
36
+ }
37
+ }
38
+
39
+ /* Table row hover effect */
40
+ tbody tr {
41
+ transition: background-color 0.2s ease;
42
  }
43
 
44
+ tbody tr:hover {
45
+ background-color: #f9fafb;
 
46
  }
47
 
48
+ /* Status badges */
49
+ .status-badge {
50
+ @apply inline-flex items-center px-3 py-1 rounded-full text-xs font-medium;
 
 
51
  }
52
 
53
+ .status-critical {
54
+ @apply bg-red-100 text-red-800;
 
 
 
 
55
  }
56
 
57
+ .status-warning {
58
+ @apply bg-yellow-100 text-yellow-800;
59
  }
60
+
61
+ .status-normal {
62
+ @apply bg-green-100 text-green-800;
63
+ }