Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Send the journal priority filter to the API

Juan Denisc7ea877d88cb
diff --git a/frontend/scripts/terminal-logs-browser.mjs b/frontend/scripts/terminal-logs-browser.mjs
index b3dc0707..b146f184 100644
--- a/frontend/scripts/terminal-logs-browser.mjs
+++ b/frontend/scripts/terminal-logs-browser.mjs
@@ -21,7 +21,7 @@ window.testApi={
getLogFiles:()=>Promise.resolve({logs:[{path:'/var/log/syslog',name:'syslog',size:10}]}),
readLog:(p,n)=>log('read',p,n),
searchLog:(p,q,n)=>log('search',p,q,n),
- getJournalLogs:(u,n)=>log('journal',u,n),
+ getJournalLogs:(u,n,pr)=>log('journal',u,n,pr),
};
const tab=new URLSearchParams(location.search).get('tab');
createRoot(document.getElementById('root')).render(
@@ -101,6 +101,13 @@ try {
return c[1] === 'nginx' && c[2] === 1000;
});
console.log('PASS picking a unit and a line count fetch the journal with the NEW values');
+
+ // The priority filter was decorative: its value never reached the API.
+ await page.getByText('Error', { exact: true }).first().click();
+ await page.waitForFunction(() => window.calls.filter(x => x[0] === 'journal').at(-1)[3] === '3');
+ const journalCall = await page.evaluate(() => window.calls.filter(x => x[0] === 'journal').at(-1));
+ assert.deepEqual(journalCall.slice(1), ['nginx', 1000, '3']);
+ console.log('PASS the priority filter is sent with the unit and line count');
assert.deepEqual(errors, []);
} finally {
await browser?.close();
diff --git a/frontend/src/pages/Terminal.jsx b/frontend/src/pages/Terminal.jsx
index 9761e982..1a0302c8 100644
--- a/frontend/src/pages/Terminal.jsx
+++ b/frontend/src/pages/Terminal.jsx
@@ -538,6 +538,7 @@ const JournalTab = () => {
async function loadJournalLogs(showSpinner = true, overrides = {}) {
const lines = overrides.lineCount ?? lineCount;
const selectedUnit = overrides.unit ?? unit;
+ const level = overrides.priority ?? priority;
if (isRemote && !REMOTE_JOURNAL_SUPPORTED.has('read')) {
setLogContent('');
setSource('');
@@ -548,7 +549,7 @@ const JournalTab = () => {
if (showSpinner) setLoading(true);
setUnavailable(false);
try {
- const data = await api.getJournalLogs(selectedUnit || null, lines);
+ const data = await api.getJournalLogs(selectedUnit || null, lines, level);
setLogContent(data.lines?.join('\n') || '');
setSource(data.source || '');
setSourceLabel(data.source_label || '');
@@ -728,7 +729,7 @@ const JournalTab = () => {
<SharedButton variant="unstyled" type="button"
key={opt.value}
className={`lv-file lv-file--compact ${priority === opt.value ? 'active' : ''}`}
- onClick={() => { setPriority(opt.value); setTimeout(loadJournalLogs, 0); }}
+ onClick={() => { setPriority(opt.value); loadJournalLogs(true, { priority: opt.value }); }}
>
<span className="lv-file-dot" style={{ background: priorityColor(opt.value) }} />
<span className="lv-file-name">{opt.label}</span>
diff --git a/frontend/src/services/api/system.js b/frontend/src/services/api/system.js
index ebb4ea10..9901d6cb 100644
--- a/frontend/src/services/api/system.js
+++ b/frontend/src/services/api/system.js
@@ -260,9 +260,10 @@ export async function getAppLogs(appName, type = 'access', lines = 100) {
return this.request(`/logs/app/${appName}?type=${encodeURIComponent(type)}&lines=${encodeURIComponent(lines)}`);
}
-export async function getJournalLogs(unit, lines = 100) {
+export async function getJournalLogs(unit, lines = 100, priority = '') {
const params = new URLSearchParams({ lines });
if (unit) params.append('unit', unit);
+ if (priority) params.append('priority', priority);
return this.request(`/logs/journal?${params}`);
}