Skip to content

Commit 9015f42

Browse files
wuriyantowuriyanto
authored andcommitted
dashboard: break text when overlapping
1 parent d0c4655 commit 9015f42

File tree

1 file changed

+71
-50
lines changed

1 file changed

+71
-50
lines changed

dashboard/ui/src/pages/dashboard.js

Lines changed: 71 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ function Dashboard() {
103103
backgroundColor: status === 'UP' ? '#28a745' : '#dc3545',
104104
whiteSpace: 'nowrap',
105105
animation: 'pulse 1s infinite',
106+
flexShrink: 0,
106107
});
107-
108+
109+
110+
111+
108112
const getTagsStyle = () => ({
109113
display: 'flex',
110114
flexWrap: 'wrap',
@@ -200,59 +204,76 @@ function Dashboard() {
200204
{error && <p>Error: {error}</p>}
201205
{!loading && !error && (
202206
<ul style={{ maxWidth: '800px', margin: '0 auto', padding: '0', listStyle: 'none' }}>
203-
{filteredServices.map((service, index) => (
204-
<li key={index} style={{
205-
backgroundColor: '#fff',
206-
margin: '10px 0',
207-
padding: '15px',
208-
borderRadius: '8px',
207+
{filteredServices.map((service, index) => (
208+
<li key={index} style={{
209+
backgroundColor: '#fff',
210+
margin: '10px 0',
211+
padding: '15px',
212+
borderRadius: '8px',
213+
display: 'flex',
214+
flexDirection: 'column',
215+
alignItems: 'flex-start',
216+
boxShadow: '0 2px 4px rgba(0, 0, 0, 0.5)',
217+
}}>
218+
219+
<style>{keyframes}</style>
220+
<div style={{
209221
display: 'flex',
210-
flexDirection: 'column',
211-
alignItems: 'flex-start',
212-
boxShadow: '0 2px 4px rgba(0, 0, 0, 0.5)',
222+
justifyContent: 'space-between',
223+
width: '100%',
224+
marginBottom: '10px',
225+
flexWrap: 'wrap',
213226
}}>
214-
215-
<style>{keyframes}</style>
216-
<div style={{
217-
display: 'flex',
218-
justifyContent: 'space-between',
219-
width: '100%',
220-
marginBottom: '10px',
227+
<span style={{
228+
fontSize: '18px',
229+
fontWeight: 'bold',
230+
flexGrow: 1,
231+
marginRight: '10px',
232+
wordWrap: 'break-word', // Allow breaking long words
233+
overflowWrap: 'break-word', // IE and Edge support
234+
maxWidth: 'calc(100% - 120px)', // Adjust based on status box size
221235
}}>
222-
<span style={{ fontSize: '18px', fontWeight: 'bold' }}>{service.name}</span>
223-
<span style={getStatusStyle(service.status)}>
224-
{service.status === 'UP' ? 'OK' : 'Not OK'}
225-
</span>
226-
</div>
227-
228-
{service.status === 'DOWN' && (
229-
<span style={{ fontSize: '14px', color: '#dc3545', marginBottom: '10px' }}>
230-
{service.messageDetails}
231-
</span>
232-
)}
233-
234-
<span style={{ fontSize: '13px', color: '#555' }}>
235-
<span style={{ color: '#593f03' }}>Last checked: {service.latestCheckTime}</span>
236+
{service.name}
236237
</span>
237-
{service.tags && (
238-
<div style={getTagsStyle()}>
239-
{service.tags.map((tag, tagIndex) => (
240-
<span
241-
key={tagIndex}
242-
style={{
243-
...getTagStyle(),
244-
backgroundColor: selectedTag === tag ? '#007bff' : '#fff',
245-
color: selectedTag === tag ? '#fff' : '#333',
246-
}}
247-
onClick={() => handleTagClick(tag)}>
248-
{tag}
249-
</span>
250-
))}
251-
</div>
252-
)}
253-
</li>
254-
))}
255-
</ul>
238+
<span style={getStatusStyle(service.status)}>
239+
{service.status === 'UP' ? 'OK' : 'Not OK'}
240+
</span>
241+
</div>
242+
243+
{service.status === 'DOWN' && (
244+
<span style={{
245+
fontSize: '14px',
246+
color: '#dc3545',
247+
marginBottom: '10px',
248+
wordWrap: 'break-word',
249+
overflowWrap: 'break-word',
250+
}}>
251+
{service.messageDetails}
252+
</span>
253+
)}
254+
255+
<span style={{ fontSize: '13px', color: '#555' }}>
256+
<span style={{ color: '#593f03' }}>Last checked: {service.latestCheckTime}</span>
257+
</span>
258+
{service.tags && (
259+
<div style={getTagsStyle()}>
260+
{service.tags.map((tag, tagIndex) => (
261+
<span
262+
key={tagIndex}
263+
style={{
264+
...getTagStyle(),
265+
backgroundColor: selectedTag === tag ? '#007bff' : '#fff',
266+
color: selectedTag === tag ? '#fff' : '#333',
267+
}}
268+
onClick={() => handleTagClick(tag)}>
269+
{tag}
270+
</span>
271+
))}
272+
</div>
273+
)}
274+
</li>
275+
))}
276+
</ul>
256277
)}
257278

258279
<footer style={{

0 commit comments

Comments
 (0)