Browse Source

fix log viewer

imwald
Silberengel 3 days ago
parent
commit
ecbc8f7adc
  1. 73
      src/components/CacheRelaysSetting/index.tsx
  2. 2
      src/components/ui/select.tsx
  3. 1
      src/i18n/locales/de.ts
  4. 1
      src/i18n/locales/en.ts

73
src/components/CacheRelaysSetting/index.tsx

@ -31,7 +31,6 @@ import { getRelayListFromEvent } from '@/lib/event-metadata'
import { showPublishingFeedback, showSimplePublishSuccess, showPublishingError } from '@/lib/publishing-feedback' import { showPublishingFeedback, showSimplePublishSuccess, showPublishingError } from '@/lib/publishing-feedback'
import { CloudUpload, Loader, Trash2, RefreshCw, Database, WrapText, Search, X, TriangleAlert, Terminal, XCircle } from 'lucide-react' import { CloudUpload, Loader, Trash2, RefreshCw, Database, WrapText, Search, X, TriangleAlert, Terminal, XCircle } from 'lucide-react'
import { Input } from '@/components/ui/input' import { Input } from '@/components/ui/input'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
import client from '@/services/client.service' import client from '@/services/client.service'
import indexedDb from '@/services/indexed-db.service' import indexedDb from '@/services/indexed-db.service'
import postEditorCache from '@/services/post-editor-cache.service' import postEditorCache from '@/services/post-editor-cache.service'
@ -61,7 +60,7 @@ export default function CacheRelaysSetting() {
const [consoleLogs, setConsoleLogs] = useState<Array<{ type: string; message: string; formattedParts?: Array<{ text: string; style?: string }>; timestamp: number }>>([]) const [consoleLogs, setConsoleLogs] = useState<Array<{ type: string; message: string; formattedParts?: Array<{ text: string; style?: string }>; timestamp: number }>>([])
const [showConsoleLogs, setShowConsoleLogs] = useState(false) const [showConsoleLogs, setShowConsoleLogs] = useState(false)
const [consoleLogSearch, setConsoleLogSearch] = useState('') const [consoleLogSearch, setConsoleLogSearch] = useState('')
const [consoleLogLevel, setConsoleLogLevel] = useState<'error' | 'warn' | 'info' | 'log' | 'all'>('error') const [consoleLogLevel, setConsoleLogLevel] = useState<'errors-warnings' | 'all'>('all')
const consoleLogRef = useRef<Array<{ type: string; message: string; formattedParts?: Array<{ text: string; style?: string }>; timestamp: number }>>([]) const consoleLogRef = useRef<Array<{ type: string; message: string; formattedParts?: Array<{ text: string; style?: string }>; timestamp: number }>>([])
const sensors = useSensors( const sensors = useSensors(
@ -523,9 +522,9 @@ export default function CacheRelaysSetting() {
const handleShowConsoleLogs = () => { const handleShowConsoleLogs = () => {
setConsoleLogs([...consoleLogRef.current]) setConsoleLogs([...consoleLogRef.current])
setShowConsoleLogs(true) setShowConsoleLogs(true)
// Reset filters when opening // Reset filters when opening – default to 'all' so user sees every entry (errors + warnings + info)
setConsoleLogSearch('') setConsoleLogSearch('')
setConsoleLogLevel('error') setConsoleLogLevel('all')
} }
const handleClearConsoleLogs = () => { const handleClearConsoleLogs = () => {
@ -538,9 +537,9 @@ export default function CacheRelaysSetting() {
const filteredConsoleLogs = useMemo(() => { const filteredConsoleLogs = useMemo(() => {
let filtered = [...consoleLogs] let filtered = [...consoleLogs]
// Filter by log level // Filter by log level: errors-warnings = error + warn only, all = everything
if (consoleLogLevel !== 'all') { if (consoleLogLevel === 'errors-warnings') {
filtered = filtered.filter(log => log.type === consoleLogLevel) filtered = filtered.filter(log => log.type === 'error' || log.type === 'warn')
} }
// Filter by search query // Filter by search query
@ -1293,18 +1292,24 @@ export default function CacheRelaysSetting() {
onChange={(e) => setConsoleLogSearch(e.target.value)} onChange={(e) => setConsoleLogSearch(e.target.value)}
className="flex-1" className="flex-1"
/> />
<Select value={consoleLogLevel} onValueChange={(value: 'error' | 'warn' | 'info' | 'log' | 'all') => setConsoleLogLevel(value)}> <div className="flex gap-1 shrink-0">
<SelectTrigger className="w-full sm:w-[140px]"> <Button
<SelectValue /> type="button"
</SelectTrigger> variant={consoleLogLevel === 'errors-warnings' ? 'secondary' : 'outline'}
<SelectContent> size="sm"
<SelectItem value="error">{t('Error')}</SelectItem> onClick={() => setConsoleLogLevel('errors-warnings')}
<SelectItem value="warn">{t('Warning')}</SelectItem> >
<SelectItem value="info">{t('Info')}</SelectItem> {t('Errors & warnings')}
<SelectItem value="log">{t('Log')}</SelectItem> </Button>
<SelectItem value="all">{t('All')}</SelectItem> <Button
</SelectContent> type="button"
</Select> variant={consoleLogLevel === 'all' ? 'secondary' : 'outline'}
size="sm"
onClick={() => setConsoleLogLevel('all')}
>
{t('All')}
</Button>
</div>
</div> </div>
</div> </div>
<div className="flex-1 overflow-auto px-4 pb-4"> <div className="flex-1 overflow-auto px-4 pb-4">
@ -1410,18 +1415,24 @@ export default function CacheRelaysSetting() {
onChange={(e) => setConsoleLogSearch(e.target.value)} onChange={(e) => setConsoleLogSearch(e.target.value)}
className="flex-1" className="flex-1"
/> />
<Select value={consoleLogLevel} onValueChange={(value: 'error' | 'warn' | 'info' | 'log' | 'all') => setConsoleLogLevel(value)}> <div className="flex gap-1 shrink-0">
<SelectTrigger className="w-full sm:w-[140px]"> <Button
<SelectValue /> type="button"
</SelectTrigger> variant={consoleLogLevel === 'errors-warnings' ? 'secondary' : 'outline'}
<SelectContent> size="sm"
<SelectItem value="error">{t('Error')}</SelectItem> onClick={() => setConsoleLogLevel('errors-warnings')}
<SelectItem value="warn">{t('Warning')}</SelectItem> >
<SelectItem value="info">{t('Info')}</SelectItem> {t('Errors & warnings')}
<SelectItem value="log">{t('Log')}</SelectItem> </Button>
<SelectItem value="all">{t('All')}</SelectItem> <Button
</SelectContent> type="button"
</Select> variant={consoleLogLevel === 'all' ? 'secondary' : 'outline'}
size="sm"
onClick={() => setConsoleLogLevel('all')}
>
{t('All')}
</Button>
</div>
</div> </div>
</div> </div>
<div className="flex-1 overflow-auto px-6 pb-4"> <div className="flex-1 overflow-auto px-6 pb-4">

2
src/components/ui/select.tsx

@ -66,7 +66,7 @@ const SelectContent = React.forwardRef<
<SelectPrimitive.Content <SelectPrimitive.Content
ref={ref} ref={ref}
className={cn( className={cn(
'relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'relative z-[110] max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
position === 'popper' && position === 'popper' &&
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1', 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
className className

1
src/i18n/locales/de.ts

@ -276,6 +276,7 @@ export default {
'Are you sure you want to reset your API key? This action cannot be undone.': 'Are you sure you want to reset your API key? This action cannot be undone.':
'Bist du sicher, dass du deinen API-Schlüssel zurücksetzen möchtest? Diese Aktion kann nicht rückgängig gemacht werden.', 'Bist du sicher, dass du deinen API-Schlüssel zurücksetzen möchtest? Diese Aktion kann nicht rückgängig gemacht werden.',
Warning: 'Warnung', Warning: 'Warnung',
'Errors & warnings': 'Fehler & Warnungen',
'Your current API key will become invalid immediately, and any applications using it will stop working until you update them with the new key.': 'Your current API key will become invalid immediately, and any applications using it will stop working until you update them with the new key.':
'Dein aktueller API-Schlüssel wird sofort ungültig, und alle Anwendungen, die ihn verwenden, werden nicht mehr funktionieren, bis du sie mit dem neuen Schlüssel aktualisierst.', 'Dein aktueller API-Schlüssel wird sofort ungültig, und alle Anwendungen, die ihn verwenden, werden nicht mehr funktionieren, bis du sie mit dem neuen Schlüssel aktualisierst.',
'Service address': 'Service-Adresse', 'Service address': 'Service-Adresse',

1
src/i18n/locales/en.ts

@ -285,6 +285,7 @@ export default {
'Are you sure you want to reset your API key? This action cannot be undone.': 'Are you sure you want to reset your API key? This action cannot be undone.':
'Are you sure you want to reset your API key? This action cannot be undone.', 'Are you sure you want to reset your API key? This action cannot be undone.',
Warning: 'Warning', Warning: 'Warning',
'Errors & warnings': 'Errors & warnings',
'Your current API key will become invalid immediately, and any applications using it will stop working until you update them with the new key.': 'Your current API key will become invalid immediately, and any applications using it will stop working until you update them with the new key.':
'Your current API key will become invalid immediately, and any applications using it will stop working until you update them with the new key.', 'Your current API key will become invalid immediately, and any applications using it will stop working until you update them with the new key.',
'Service address': 'Service address', 'Service address': 'Service address',

Loading…
Cancel
Save