Compare commits

..
1 Commits
Author SHA1 Message Date
Crowdin Bot acddd9183e New Crowdin translations by GitHub Action
Lint / Linting Checks (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
2026-08-30 00:57:15 +00:00
6 changed files with 215 additions and 252 deletions
+2 -3
View File
@@ -9,9 +9,7 @@ See the [crowdsec docs](https://docs.crowdsec.net/docs/local_api/intro/#machines
in most instances you can use the default credentials (`/etc/crowdsec/local_api_credentials.yaml`). in most instances you can use the default credentials (`/etc/crowdsec/local_api_credentials.yaml`).
!!! note !!! note
Without the `limit24h` option, the widget will fetch all alerts which is limited to 100 by the API to avoid performance issues.
`alerts` counts alerts raised by your own engine in the last 24 hours. Alerts originating from the
CrowdSec community blocklist are excluded.
Allowed fields: `["alerts", "bans"]`. Allowed fields: `["alerts", "bans"]`.
@@ -21,4 +19,5 @@ widget:
url: http://crowdsechostorip:port url: http://crowdsechostorip:port
username: localhost # machine_id in crowdsec username: localhost # machine_id in crowdsec
password: password password: password
limit24h: true # optional, limits alerts to last 24h. Default: false
``` ```
+2 -2
View File
@@ -40,8 +40,8 @@
}, },
"search": { "search": {
"placeholder": "Buscar…", "placeholder": "Buscar…",
"provider": "Motor de búsqueda: {{name}}", "provider": "Search engine: {{name}}",
"select_provider": "Seleccionar motores de búsqueda" "select_provider": "Select search engine"
}, },
"resources": { "resources": {
"cpu": "CPU", "cpu": "CPU",
+201 -201
View File
@@ -21,7 +21,7 @@
"seconds": "giây" "seconds": "giây"
}, },
"auth": { "auth": {
"signout": "Đăng xuất" "signout": "Sign out"
}, },
"widget": { "widget": {
"missing_type": "Thiếu loại Widget: {{type}}", "missing_type": "Thiếu loại Widget: {{type}}",
@@ -40,8 +40,8 @@
}, },
"search": { "search": {
"placeholder": "Tìm kiếm…", "placeholder": "Tìm kiếm…",
"provider": "Công cụ tìm kiếm: {{name}}", "provider": "Search engine: {{name}}",
"select_provider": "Chọn công cụ tìm kiếm" "select_provider": "Select search engine"
}, },
"resources": { "resources": {
"cpu": "CPU", "cpu": "CPU",
@@ -50,7 +50,7 @@
"free": "Dư", "free": "Dư",
"used": "Đã dùng", "used": "Đã dùng",
"load": "\n", "load": "\n",
"temp": "Tạm thời", "temp": "TEMP",
"max": "Tối đa", "max": "Tối đa",
"uptime": "UP" "uptime": "UP"
}, },
@@ -66,24 +66,24 @@
"wlan_devices": "Thiết bị trong mạng WLAN", "wlan_devices": "Thiết bị trong mạng WLAN",
"lan_users": "Người dùng mạng LAN", "lan_users": "Người dùng mạng LAN",
"wlan_users": "Người dùng mạng WLAN", "wlan_users": "Người dùng mạng WLAN",
"up": "Hoạt động", "up": "UP",
"down": "Không hoạt động", "down": "DOWN",
"wait": "Vui lòng chờ", "wait": "Vui lòng chờ",
"empty_data": "Trạng thái hệ thống phụ không xác định" "empty_data": "Trạng thái hệ thống phụ không xác định"
}, },
"unifi_drive": { "unifi_drive": {
"healthy": "Bình thường", "healthy": "Healthy",
"degraded": "Suy giảm", "degraded": "Degraded",
"no_data": "Không có dữ liệu" "no_data": "No storage data available"
}, },
"duplicati": { "duplicati": {
"jobs": "Tác vụ", "jobs": "Jobs",
"stored": "Đã lưu", "stored": "Stored",
"lastBackup": "Lần chạy cuối", "lastBackup": "Last Run",
"nextRun": "Lần chạy tiếp theo", "nextRun": "Next Run",
"running": "Đang chạy", "running": "Running",
"warnings": "Cảnh báo", "warnings": "Warnings",
"errors": "Lỗi" "errors": "Errors"
}, },
"docker": { "docker": {
"rx": "RX", "rx": "RX",
@@ -98,8 +98,8 @@
"starting": "Đang bắt đầu", "starting": "Đang bắt đầu",
"unhealthy": "Bất thường", "unhealthy": "Bất thường",
"not_found": "Không tìm thấy", "not_found": "Không tìm thấy",
"exited": "Đã thoát", "exited": "Exited",
"partial": "Một phần" "partial": "Partial"
}, },
"ping": { "ping": {
"error": "Lỗi", "error": "Lỗi",
@@ -120,35 +120,35 @@
"playing": "Đang chơi", "playing": "Đang chơi",
"transcoding": "Chuyển định dạng", "transcoding": "Chuyển định dạng",
"bitrate": "Bitrate", "bitrate": "Bitrate",
"no_active": "Không có luồng đang hoạt động", "no_active": "No Active Streams",
"movies": "Phim ảnh", "movies": "Phim ảnh",
"series": "Series", "series": "Series",
"episodes": "Tập", "episodes": "Episodes",
"songs": "Bài hát" "songs": "Bài hát"
}, },
"jellyfin": { "jellyfin": {
"playing": "Đang phát", "playing": "Playing",
"transcoding": "Đang chuyển mã", "transcoding": "Transcoding",
"bitrate": "Tốc độ bit", "bitrate": "Bitrate",
"no_active": "Không có luồng đang hoạt động", "no_active": "No Active Streams",
"movies": "Phim", "movies": "Movies",
"series": "Series", "series": "Series",
"episodes": "Tập", "episodes": "Episodes",
"songs": "Bài hát", "songs": "Songs",
"albums": "Album" "albums": "Albums"
}, },
"esphome": { "esphome": {
"offline": "Offline", "offline": "Offline",
"offline_alt": "Offline", "offline_alt": "Offline",
"online": "Online", "online": "Online",
"total": "Tổng cộng", "total": "Total",
"unknown": "Không xác định" "unknown": "Không xác định"
}, },
"evcc": { "evcc": {
"pv_power": "Công suất phát", "pv_power": "Production",
"battery_soc": "Pin", "battery_soc": "Pin",
"grid_power": "Lưới", "grid_power": "Lưới",
"home_power": "Công suất tiêu thụ", "home_power": "Consumption",
"charge_power": "Bộ sạc", "charge_power": "Bộ sạc",
"kilowatt": "kW" "kilowatt": "kW"
}, },
@@ -156,7 +156,7 @@
"download": "Tải xuống", "download": "Tải xuống",
"upload": "Tải lên", "upload": "Tải lên",
"leech": "", "leech": "",
"seed": "Seeder" "seed": "Seed"
}, },
"freshrss": { "freshrss": {
"subscriptions": "Đăng ký", "subscriptions": "Đăng ký",
@@ -175,115 +175,115 @@
"maxDown": "Tải xuống tối đa", "maxDown": "Tải xuống tối đa",
"maxUp": "Tải lên tối đa", "maxUp": "Tải lên tối đa",
"down": "Down", "down": "Down",
"up": "Tải lên", "up": "Up",
"received": "Đã nhận", "received": "Received",
"sent": "Đã gửi", "sent": "Sent",
"externalIPAddress": "Địa chỉ IP bên ngoài", "externalIPAddress": "Ext. IP",
"externalIPv6Address": "Địa chỉ IPv6 bên ngoài", "externalIPv6Address": "Ext. IPv6",
"externalIPv6Prefix": "Tiền tố IPv6 bên ngoài" "externalIPv6Prefix": "Ext. IPv6-Prefix"
}, },
"caddy": { "caddy": {
"upstreams": "Máy chủ backend", "upstreams": "Upstreams",
"requests": "Yêu cầu hiện tại", "requests": "Current requests",
"requests_failed": "Yêu cầu thất bại" "requests_failed": "Failed requests"
}, },
"changedetectionio": { "changedetectionio": {
"totalObserved": "Tổng số đã theo dõi", "totalObserved": "Total Observed",
"diffsDetected": "Số thay đổi đã phát hiện" "diffsDetected": "Diffs Detected"
}, },
"channelsdvrserver": { "channelsdvrserver": {
"shows": "Chương trình", "shows": "Shows",
"recordings": "Bản ghi", "recordings": "Recordings",
"scheduled": "Đã lên lịch", "scheduled": "Scheduled",
"passes": "Quy tắc ghi" "passes": "Passes"
}, },
"tautulli": { "tautulli": {
"playing": "Đang phát", "playing": "Playing",
"transcoding": "Đang chuyển mã", "transcoding": "Transcoding",
"bitrate": "Tốc độ bit", "bitrate": "Bitrate",
"no_active": "Không có luồng đang hoạt động", "no_active": "No Active Streams",
"plex_connection_error": "Kiểm tra kết nối Plex" "plex_connection_error": "Check Plex Connection"
}, },
"tracearr": { "tracearr": {
"no_active": "Không có luồng đang hoạt động", "no_active": "No Active Streams",
"streams": "Luồng", "streams": "Streams",
"transcodes": "Luồng chuyển mã", "transcodes": "Transcodes",
"directplay": "Phát trực tiếp", "directplay": "Direct Play",
"bitrate": "Tốc độ bit" "bitrate": "Bitrate"
}, },
"omada": { "omada": {
"connectedAp": "AP đã kết nối", "connectedAp": "Connected APs",
"activeUser": "Thiết bị đang hoạt động", "activeUser": "Active devices",
"alerts": "Cảnh báo", "alerts": "Alerts",
"connectedGateways": "Gateway đã kết nối", "connectedGateways": "Connected gateways",
"connectedSwitches": "Switch đã kết nối" "connectedSwitches": "Connected switches"
}, },
"nzbget": { "nzbget": {
"rate": "Tốc độ", "rate": "Rate",
"remaining": "Còn lại", "remaining": "Remaining",
"downloaded": "Đã tải" "downloaded": "Đã tải"
}, },
"plex": { "plex": {
"streams": "Luồng đang hoạt động", "streams": "Active Streams",
"albums": "Album", "albums": "Albums",
"movies": "Phim", "movies": "Movies",
"tv": "Chương trình TV" "tv": "TV Shows"
}, },
"sabnzbd": { "sabnzbd": {
"rate": "Tốc độ", "rate": "Rate",
"queue": "Hàng chờ", "queue": "Hàng chờ",
"timeleft": "Thời gian còn lại" "timeleft": "Thời gian còn lại"
}, },
"rutorrent": { "rutorrent": {
"active": "Hoạt động", "active": "Hoạt động",
"upload": "Tải lên", "upload": "Upload",
"download": "Tải xuống" "download": "Download"
}, },
"transmission": { "transmission": {
"download": "Tải xuống", "download": "Download",
"upload": "Tải lên", "upload": "Upload",
"leech": "Leecher", "leech": "Leech",
"seed": "Seeder" "seed": "Seed"
}, },
"qbittorrent": { "qbittorrent": {
"download": "Tải xuống", "download": "Download",
"upload": "Tải lên", "upload": "Upload",
"leech": "Leecher", "leech": "Leech",
"seed": "Seeder" "seed": "Seed"
}, },
"qnap": { "qnap": {
"cpuUsage": "Mức sử dụng CPU", "cpuUsage": "CPU Usage",
"memUsage": "Mức sử dụng bộ nhớ", "memUsage": "MEM Usage",
"systemTempC": "Nhiệt độ hệ thống", "systemTempC": "System Temp",
"poolUsage": "Mức sử dụng pool", "poolUsage": "Pool Usage",
"volumeUsage": "Mức sử dụng volume", "volumeUsage": "Volume Usage",
"invalid": "Không hợp lệ" "invalid": "Invalid"
}, },
"deluge": { "deluge": {
"download": "Tải xuống", "download": "Download",
"upload": "Tải lên", "upload": "Upload",
"leech": "Leecher", "leech": "Leech",
"seed": "Seeder" "seed": "Seed"
}, },
"develancacheui": { "develancacheui": {
"cachehitbytes": "Dung lượng cache hit", "cachehitbytes": "Cache Hit Bytes",
"cachemissbytes": "Dung lượng cache miss" "cachemissbytes": "Cache Miss Bytes"
}, },
"downloadstation": { "downloadstation": {
"download": "Tải xuống", "download": "Download",
"upload": "Tải lên", "upload": "Upload",
"leech": "Leecher", "leech": "Leech",
"seed": "Seeder" "seed": "Seed"
}, },
"sonarr": { "sonarr": {
"wanted": "Cần tải", "wanted": "Wanted",
"queued": "Queued", "queued": "Queued",
"series": "Phim bộ", "series": "Series",
"queue": "Queue", "queue": "Queue",
"unknown": "Unknown" "unknown": "Unknown"
}, },
"radarr": { "radarr": {
"wanted": "Cần tải", "wanted": "Wanted",
"missing": "Missing", "missing": "Missing",
"queued": "Queued", "queued": "Queued",
"movies": "Movies", "movies": "Movies",
@@ -291,12 +291,12 @@
"unknown": "Unknown" "unknown": "Unknown"
}, },
"lidarr": { "lidarr": {
"wanted": "Cần tải", "wanted": "Wanted",
"queued": "Queued", "queued": "Queued",
"artists": "Artists" "artists": "Artists"
}, },
"readarr": { "readarr": {
"wanted": "Cần tải", "wanted": "Wanted",
"queued": "Queued", "queued": "Queued",
"books": "Sách" "books": "Sách"
}, },
@@ -336,66 +336,66 @@
"latency": "Latency" "latency": "Latency"
}, },
"speedtest": { "speedtest": {
"upload": "Tải lên", "upload": "Upload",
"download": "Tải xuống", "download": "Download",
"ping": "Ping" "ping": "Ping"
}, },
"portainer": { "portainer": {
"running": "Đang chạy", "running": "Running",
"stopped": "Đã dừng", "stopped": "Stopped",
"total": "Tổng cộng" "total": "Total"
}, },
"suwayomi": { "suwayomi": {
"download": "Đã tải xuống", "download": "Downloaded",
"nondownload": "Chưa tải xuống", "nondownload": "Non-Downloaded",
"read": "Đã đọc", "read": "Read",
"unread": "Chưa đọc", "unread": "Unread",
"downloadedread": "Đã tải xuống & Đã đọc", "downloadedread": "Downloaded & Read",
"downloadedunread": "Đã tải xuống & Chưa đọc", "downloadedunread": "Downloaded & Unread",
"nondownloadedread": "Chưa tải xuống & Đã đọc", "nondownloadedread": "Non-Downloaded & Read",
"nondownloadedunread": "Chưa tải xuống & Chưa đọc" "nondownloadedunread": "Non-Downloaded & Unread"
}, },
"tailscale": { "tailscale": {
"address": "Địa chỉ", "address": "Address",
"expires": "Hết hạn", "expires": "Expires",
"never": "Không bao giờ", "never": "Never",
"user": "Người dùng", "user": "User",
"hostname": "Tên máy chủ", "hostname": "Hostname",
"name": "Tên", "name": "Name",
"client_version": "Phiên bản máy khách", "client_version": "Client Version",
"os": "Hệ điều hành", "os": "OS",
"created": "Đã tạo", "created": "Created",
"authorized": "Đã cấp quyền", "authorized": "Authorized",
"is_external": "Là bên ngoài", "is_external": "Is External",
"update_available": "Có bản cập nhật", "update_available": "Update Available",
"tags": "Thẻ", "tags": "Tags",
"last_seen": "Lần cuối nhìn thấy", "last_seen": "Last Seen",
"now": "Bây giờ", "now": "Now",
"years": "{{number}} năm", "years": "{{number}}y",
"weeks": "{{number}} tuần", "weeks": "{{number}}w",
"days": "{{number}} ngày", "days": "{{number}}d",
"hours": "{{number}} giờ", "hours": "{{number}}h",
"minutes": "{{number}} phút", "minutes": "{{number}}m",
"seconds": "{{number}} giây", "seconds": "{{number}}s",
"ago": "{{value}} trước", "ago": "{{value}} Ago",
"true": "Có", "true": "Yes",
"false": "Không" "false": "No"
}, },
"technitium": { "technitium": {
"totalQueries": "Tổng số truy vấn", "totalQueries": "Queries",
"totalNoError": "Thành công", "totalNoError": "Success",
"totalServerFailure": "Lỗi máy chủ", "totalServerFailure": "Failures",
"totalNxDomain": "NX Domain", "totalNxDomain": "NX Domains",
"totalRefused": "Bị từ chối", "totalRefused": "Refused",
"totalAuthoritative": "Authoritative", "totalAuthoritative": "Authoritative",
"totalRecursive": "Recursive", "totalRecursive": "Recursive",
"totalCached": "Được lưu trong bộ nhớ đệm", "totalCached": "Cached",
"totalBlocked": "Bị chặn", "totalBlocked": "Blocked",
"totalDropped": "Bị loại bỏ", "totalDropped": "Dropped",
"totalClients": "Số máy khách" "totalClients": "Clients"
}, },
"tdarr": { "tdarr": {
"queue": "Hàng đợi", "queue": "Queue",
"processed": "Processed", "processed": "Processed",
"errored": "Errored", "errored": "Errored",
"saved": "Saved" "saved": "Saved"
@@ -412,7 +412,7 @@
"unknown": "Unknown" "unknown": "Unknown"
}, },
"navidrome": { "navidrome": {
"nothing_streaming": "Không có luồng đang hoạt động", "nothing_streaming": "No Active Streams",
"please_wait": "Please Wait" "please_wait": "Please Wait"
}, },
"npm": { "npm": {
@@ -455,9 +455,9 @@
"domain_count": "Domains" "domain_count": "Domains"
}, },
"medusa": { "medusa": {
"wanted": "Cần tải", "wanted": "Wanted",
"queued": "Queued", "queued": "Queued",
"series": "Phim bộ" "series": "Series"
}, },
"minecraft": { "minecraft": {
"players": "Players", "players": "Players",
@@ -474,66 +474,66 @@
"users": "Users", "users": "Users",
"loginsLast24H": "Logins (24h)", "loginsLast24H": "Logins (24h)",
"failedLoginsLast24H": "Failed Logins (24h)", "failedLoginsLast24H": "Failed Logins (24h)",
"authorizationsLast24H": "Lượt ủy quyền (24 giờ)" "authorizationsLast24H": "Auths (24h)"
}, },
"proxmox": { "proxmox": {
"mem": "Bộ nhớ", "mem": "MEM",
"cpu": "CPU", "cpu": "CPU",
"lxc": "LXC", "lxc": "LXC",
"vms": "VM" "vms": "VMs"
}, },
"pulse": { "pulse": {
"nodes": "Node", "nodes": "Nodes",
"vms": "VM", "vms": "VMs",
"lxcs": "LXC" "lxcs": "LXCs"
}, },
"glances": { "glances": {
"cpu": "CPU", "cpu": "CPU",
"load": "Tải hệ thống", "load": "Load",
"wait": "Vui lòng đợi", "wait": "Please wait",
"temp": "Nhiệt độ", "temp": "TEMP",
"_temp": "Nhiệt độ", "_temp": "Temp",
"warn": "Cảnh báo", "warn": "Warn",
"uptime": "Thời gian hoạt động", "uptime": "UP",
"total": "Tổng cộng", "total": "Total",
"free": "Còn trống", "free": "Free",
"used": "Đã sử dụng", "used": "Used",
"days": "ngày", "days": "d",
"hours": "giờ", "hours": "h",
"crit": "Nghiêm trọng", "crit": "Crit",
"read": "Đọc", "read": "Read",
"write": "Ghi", "write": "Write",
"gpu": "GPU", "gpu": "GPU",
"mem": "Bộ nhớ", "mem": "Mem",
"swap": "Swap" "swap": "Swap"
}, },
"quicklaunch": { "quicklaunch": {
"bookmark": "Dấu trang", "bookmark": "Bookmark",
"service": "Dịch vụ", "service": "Service",
"search": "Tìm kiếm", "search": "Search",
"custom": "Tùy chỉnh", "custom": "Custom",
"visit": "Truy cập", "visit": "Visit",
"url": "URL", "url": "URL",
"searchsuggestion": "Gợi ý" "searchsuggestion": "Suggestion"
}, },
"wmo": { "wmo": {
"0-day": "Trời nắng", "0-day": "Sunny",
"0-night": "Trời quang", "0-night": "Clear",
"1-day": "Chủ yếu có nắng", "1-day": "Mainly Sunny",
"1-night": "Chủ yếu trời quang", "1-night": "Mainly Clear",
"2-day": "Có mây từng phần", "2-day": "Partly Cloudy",
"2-night": "Có mây từng phần", "2-night": "Partly Cloudy",
"3-day": "Nhiều mây", "3-day": "Cloudy",
"3-night": "Nhiều mây", "3-night": "Cloudy",
"45-day": "Có sương mù", "45-day": "Foggy",
"45-night": "Có sương mù", "45-night": "Foggy",
"48-day": "Có sương mù", "48-day": "Foggy",
"48-night": "Có sương mù", "48-night": "Foggy",
"51-day": "Mưa phùn nhẹ", "51-day": "Light Drizzle",
"51-night": "Mưa phùn nhẹ", "51-night": "Light Drizzle",
"53-day": "Mưa phùn", "53-day": "Drizzle",
"53-night": "Mưa phùn", "53-night": "Drizzle",
"55-day": "Mưa phùn lớn", "55-day": "Heavy Drizzle",
"55-night": "Heavy Drizzle", "55-night": "Heavy Drizzle",
"56-day": "Light Freezing Drizzle", "56-day": "Light Freezing Drizzle",
"56-night": "Light Freezing Drizzle", "56-night": "Light Freezing Drizzle",
@@ -741,14 +741,14 @@
"m": "m" "m": "m"
}, },
"atsumeru": { "atsumeru": {
"series": "Bộ truyện", "series": "Series",
"archives": "Archives", "archives": "Archives",
"chapters": "Chapters", "chapters": "Chapters",
"categories": "Categories" "categories": "Categories"
}, },
"komga": { "komga": {
"libraries": "Libraries", "libraries": "Libraries",
"series": "Bộ truyện", "series": "Series",
"books": "Books" "books": "Books"
}, },
"diskstation": { "diskstation": {
@@ -761,9 +761,9 @@
"streams": "Streams" "streams": "Streams"
}, },
"mylar": { "mylar": {
"series": "Phim bộ", "series": "Series",
"issues": "Issues", "issues": "Issues",
"wanted": "Cần tải" "wanted": "Wanted"
}, },
"photoprism": { "photoprism": {
"albums": "Albums", "albums": "Albums",
@@ -846,7 +846,7 @@
"books": "Books", "books": "Books",
"authors": "Authors", "authors": "Authors",
"categories": "Categories", "categories": "Categories",
"series": "Bộ sách" "series": "Series"
}, },
"booklore": { "booklore": {
"libraries": "Libraries", "libraries": "Libraries",
@@ -861,7 +861,7 @@
"downloadSpeed": "Speed" "downloadSpeed": "Speed"
}, },
"kavita": { "kavita": {
"seriesCount": "Số bộ truyện", "seriesCount": "Series",
"totalFiles": "Files" "totalFiles": "Files"
}, },
"azuredevops": { "azuredevops": {
@@ -1250,7 +1250,7 @@
"storage": "Storage" "storage": "Storage"
}, },
"sportarr": { "sportarr": {
"wanted": "Cần tải", "wanted": "Wanted",
"queued": "Queued", "queued": "Queued",
"leagues": "Leagues" "leagues": "Leagues"
} }
+2 -7
View File
@@ -4,19 +4,14 @@ import { useTranslation } from "next-i18next/pages";
import useWidgetAPI from "utils/proxy/use-widget-api"; import useWidgetAPI from "utils/proxy/use-widget-api";
const ALERTS_LIMIT = 500;
export default function Component({ service }) { export default function Component({ service }) {
const { t } = useTranslation(); const { t } = useTranslation();
const { widget } = service; const { widget } = service;
const { data: alerts, error: alertsError } = useWidgetAPI(widget, "alerts"); const { data: alerts, error: alertsError } = useWidgetAPI(widget, !!widget.limit24h ? "alerts24h" : "alerts");
const { data: bans, error: bansError } = useWidgetAPI(widget, "bans"); const { data: bans, error: bansError } = useWidgetAPI(widget, "bans");
const alertsCount = alerts?.length ?? 0;
const alertsValue = t("common.number", { value: alertsCount });
if (alertsError || bansError) { if (alertsError || bansError) {
return <Container service={service} error={alertsError ?? bansError} />; return <Container service={service} error={alertsError ?? bansError} />;
} }
@@ -32,7 +27,7 @@ export default function Component({ service }) {
return ( return (
<Container service={service}> <Container service={service}>
<Block label="crowdsec.alerts" value={alertsCount >= ALERTS_LIMIT ? `${alertsValue}+` : alertsValue} /> <Block label="crowdsec.alerts" value={t("common.number", { value: alerts?.length ?? 0 })} />
<Block label="crowdsec.bans" value={t("common.number", { value: bans?.length ?? 0 })} /> <Block label="crowdsec.bans" value={t("common.number", { value: bans?.length ?? 0 })} />
</Container> </Container>
); );
+3 -37
View File
@@ -17,25 +17,15 @@ describe("widgets/crowdsec/component", () => {
vi.clearAllMocks(); vi.clearAllMocks();
}); });
it("requests the alerts and bans endpoints", () => { it("selects alerts24h endpoint when limit24h is enabled", () => {
useWidgetAPI.mockImplementation(() => ({ data: undefined, error: undefined }));
renderWithProviders(<Component service={{ widget: { type: "crowdsec" } }} />, {
settings: { hideErrors: false },
});
expect(useWidgetAPI).toHaveBeenNthCalledWith(1, expect.any(Object), "alerts");
expect(useWidgetAPI).toHaveBeenNthCalledWith(2, expect.any(Object), "bans");
});
it("ignores the deprecated limit24h option", () => {
useWidgetAPI.mockImplementation(() => ({ data: undefined, error: undefined })); useWidgetAPI.mockImplementation(() => ({ data: undefined, error: undefined }));
renderWithProviders(<Component service={{ widget: { type: "crowdsec", limit24h: true } }} />, { renderWithProviders(<Component service={{ widget: { type: "crowdsec", limit24h: true } }} />, {
settings: { hideErrors: false }, settings: { hideErrors: false },
}); });
expect(useWidgetAPI).toHaveBeenNthCalledWith(1, expect.any(Object), "alerts"); expect(useWidgetAPI).toHaveBeenNthCalledWith(1, expect.any(Object), "alerts24h");
expect(useWidgetAPI).toHaveBeenNthCalledWith(2, expect.any(Object), "bans");
}); });
it("renders placeholders when both alerts and bans are missing", () => { it("renders placeholders when both alerts and bans are missing", () => {
@@ -62,28 +52,4 @@ describe("widgets/crowdsec/component", () => {
expectBlockValue(container, "crowdsec.alerts", 0); expectBlockValue(container, "crowdsec.alerts", 0);
expectBlockValue(container, "crowdsec.bans", 0); expectBlockValue(container, "crowdsec.bans", 0);
}); });
it("marks the alert count as truncated at the API limit", () => {
useWidgetAPI
.mockReturnValueOnce({ data: new Array(500).fill({}), error: undefined })
.mockReturnValueOnce({ data: [], error: undefined });
renderWithProviders(<Component service={{ widget: { type: "crowdsec" } }} />, {
settings: { hideErrors: false },
});
expect(screen.getByText("500+")).toBeInTheDocument();
});
it("does not mark the alert count below the API limit", () => {
useWidgetAPI
.mockReturnValueOnce({ data: new Array(499).fill({}), error: undefined })
.mockReturnValueOnce({ data: [], error: undefined });
const { container } = renderWithProviders(<Component service={{ widget: { type: "crowdsec" } }} />, {
settings: { hideErrors: false },
});
expectBlockValue(container, "crowdsec.alerts", 499);
});
}); });
+5 -2
View File
@@ -7,10 +7,13 @@ const widget = {
mappings: { mappings: {
alerts: { alerts: {
endpoint: "alerts?limit=500&since=24h&with_decisions=false&include_capi=false", endpoint: "alerts",
},
alerts24h: {
endpoint: "alerts?limit=0&since=24h",
}, },
bans: { bans: {
endpoint: "alerts?decision_type=ban&include_capi=false&has_active_decision=1&with_decisions=false", endpoint: "alerts?decision_type=ban&origin=crowdsec&has_active_decision=1",
}, },
}, },
}; };