feat: add kiosk settings UI and co-managed client filtering
- Created kiosk_settings table for configuration storage - Added API endpoints for kiosk settings (GET/POST) - Filter out co-managed clients (configurable company exclusions) - Built comprehensive settings UI at /kiosk/settings - Allow excluding specific companies from kiosk display - Configurable cycle interval, refresh interval, and RMM alert toggle - Updated dashboard link to point to settings page - Applied company exclusion filter to all ticket queries and activity feed - Default excludes Thrasher Group (ID: 29861361)
This commit is contained in:
parent
724791121a
commit
26bfd503f1
6 changed files with 478 additions and 12 deletions
|
|
@ -1,9 +1,28 @@
|
||||||
import { NextRequest, NextResponse } from 'next/server';
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
import { postgresClient } from '@/lib/services/postgres-client';
|
import { postgresClient } from '@/lib/services/postgres-client';
|
||||||
|
|
||||||
|
async function getExcludedCompanyIds(): Promise<number[]> {
|
||||||
|
try {
|
||||||
|
const result = await postgresClient.query(
|
||||||
|
`SELECT setting_value FROM kiosk_settings WHERE setting_key = 'excluded_company_ids'`
|
||||||
|
);
|
||||||
|
const value = result.rows[0]?.setting_value || '';
|
||||||
|
return value ? value.split(',').map((id: string) => parseInt(id.trim())).filter((id: number) => !isNaN(id)) : [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching excluded company IDs:', error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function GET(request: NextRequest) {
|
export async function GET(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
// Get recent ticket activity for ticker feed - exclude RMM alerts (source = 8)
|
// Get excluded company IDs (co-managed clients)
|
||||||
|
const excludedCompanyIds = await getExcludedCompanyIds();
|
||||||
|
const excludeCompanyFilter = excludedCompanyIds.length > 0
|
||||||
|
? `AND t.company_id NOT IN (${excludedCompanyIds.join(',')})`
|
||||||
|
: '';
|
||||||
|
|
||||||
|
// Get recent ticket activity for ticker feed - exclude RMM alerts (source = 8) and co-managed clients
|
||||||
const activityResult = await postgresClient.query(
|
const activityResult = await postgresClient.query(
|
||||||
`SELECT
|
`SELECT
|
||||||
t.ticket_number,
|
t.ticket_number,
|
||||||
|
|
@ -19,6 +38,7 @@ export async function GET(request: NextRequest) {
|
||||||
LEFT JOIN statuses s ON t.status = s.value
|
LEFT JOIN statuses s ON t.status = s.value
|
||||||
WHERE t.completed_date IS NULL
|
WHERE t.completed_date IS NULL
|
||||||
AND (t.source IS NULL OR t.source != 8)
|
AND (t.source IS NULL OR t.source != 8)
|
||||||
|
${excludeCompanyFilter}
|
||||||
ORDER BY t.last_activity_date DESC NULLS LAST
|
ORDER BY t.last_activity_date DESC NULLS LAST
|
||||||
LIMIT 50`
|
LIMIT 50`
|
||||||
);
|
);
|
||||||
|
|
|
||||||
74
app/api/kiosk/settings/route.ts
Normal file
74
app/api/kiosk/settings/route.ts
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
import { postgresClient } from '@/lib/services/postgres-client';
|
||||||
|
|
||||||
|
export async function GET(request: NextRequest) {
|
||||||
|
try {
|
||||||
|
const result = await postgresClient.query(
|
||||||
|
'SELECT setting_key, setting_value, description FROM kiosk_settings'
|
||||||
|
);
|
||||||
|
|
||||||
|
const settings: Record<string, any> = {};
|
||||||
|
result.rows.forEach((row: any) => {
|
||||||
|
let value = row.setting_value;
|
||||||
|
|
||||||
|
// Parse specific settings
|
||||||
|
if (row.setting_key === 'excluded_company_ids') {
|
||||||
|
value = value ? value.split(',').map((id: string) => id.trim()).filter(Boolean) : [];
|
||||||
|
} else if (row.setting_key === 'show_rmm_alerts') {
|
||||||
|
value = value === 'true';
|
||||||
|
} else if (['cycle_interval', 'refresh_interval'].includes(row.setting_key)) {
|
||||||
|
value = parseInt(value || '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
settings[row.setting_key] = value;
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json(settings);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching kiosk settings:', error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: 'Failed to fetch kiosk settings' },
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function POST(request: NextRequest) {
|
||||||
|
try {
|
||||||
|
const body = await request.json();
|
||||||
|
const { setting_key, setting_value } = body;
|
||||||
|
|
||||||
|
if (!setting_key) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: 'setting_key is required' },
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert arrays and booleans to strings for storage
|
||||||
|
let valueToStore = setting_value;
|
||||||
|
if (Array.isArray(setting_value)) {
|
||||||
|
valueToStore = setting_value.join(',');
|
||||||
|
} else if (typeof setting_value === 'boolean') {
|
||||||
|
valueToStore = setting_value.toString();
|
||||||
|
} else if (typeof setting_value === 'number') {
|
||||||
|
valueToStore = setting_value.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
await postgresClient.query(
|
||||||
|
`INSERT INTO kiosk_settings (setting_key, setting_value, updated_at)
|
||||||
|
VALUES ($1, $2, CURRENT_TIMESTAMP)
|
||||||
|
ON CONFLICT (setting_key)
|
||||||
|
DO UPDATE SET setting_value = EXCLUDED.setting_value, updated_at = CURRENT_TIMESTAMP`,
|
||||||
|
[setting_key, valueToStore]
|
||||||
|
);
|
||||||
|
|
||||||
|
return NextResponse.json({ success: true });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error updating kiosk settings:', error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: 'Failed to update kiosk settings' },
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,15 +1,35 @@
|
||||||
import { NextRequest, NextResponse } from 'next/server';
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
import { postgresClient } from '@/lib/services/postgres-client';
|
import { postgresClient } from '@/lib/services/postgres-client';
|
||||||
|
|
||||||
|
async function getExcludedCompanyIds(): Promise<number[]> {
|
||||||
|
try {
|
||||||
|
const result = await postgresClient.query(
|
||||||
|
`SELECT setting_value FROM kiosk_settings WHERE setting_key = 'excluded_company_ids'`
|
||||||
|
);
|
||||||
|
const value = result.rows[0]?.setting_value || '';
|
||||||
|
return value ? value.split(',').map((id: string) => parseInt(id.trim())).filter((id: number) => !isNaN(id)) : [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching excluded company IDs:', error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function GET(request: NextRequest) {
|
export async function GET(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
// Critical tickets (Priority 1-3) - exclude RMM alerts (source = 8)
|
// Get excluded company IDs (co-managed clients)
|
||||||
|
const excludedCompanyIds = await getExcludedCompanyIds();
|
||||||
|
const excludeCompanyFilter = excludedCompanyIds.length > 0
|
||||||
|
? `AND company_id NOT IN (${excludedCompanyIds.join(',')})`
|
||||||
|
: '';
|
||||||
|
|
||||||
|
// Critical tickets (Priority 1-3) - exclude RMM alerts (source = 8) and co-managed clients
|
||||||
const criticalTicketsResult = await postgresClient.query(
|
const criticalTicketsResult = await postgresClient.query(
|
||||||
`SELECT COUNT(*) as count
|
`SELECT COUNT(*) as count
|
||||||
FROM tickets
|
FROM tickets
|
||||||
WHERE completed_date IS NULL
|
WHERE completed_date IS NULL
|
||||||
AND priority <= 3
|
AND priority <= 3
|
||||||
AND (source IS NULL OR source != 8)`
|
AND (source IS NULL OR source != 8)
|
||||||
|
${excludeCompanyFilter}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Top 3 critical tickets
|
// Top 3 critical tickets
|
||||||
|
|
@ -20,6 +40,7 @@ export async function GET(request: NextRequest) {
|
||||||
WHERE t.completed_date IS NULL
|
WHERE t.completed_date IS NULL
|
||||||
AND t.priority <= 3
|
AND t.priority <= 3
|
||||||
AND (t.source IS NULL OR t.source != 8)
|
AND (t.source IS NULL OR t.source != 8)
|
||||||
|
${excludeCompanyFilter}
|
||||||
ORDER BY t.priority ASC, t.create_date ASC
|
ORDER BY t.priority ASC, t.create_date ASC
|
||||||
LIMIT 3`
|
LIMIT 3`
|
||||||
);
|
);
|
||||||
|
|
@ -30,7 +51,8 @@ export async function GET(request: NextRequest) {
|
||||||
FROM tickets
|
FROM tickets
|
||||||
WHERE completed_date IS NULL
|
WHERE completed_date IS NULL
|
||||||
AND status IN (21, 9, 19)
|
AND status IN (21, 9, 19)
|
||||||
AND (source IS NULL OR source != 8)`
|
AND (source IS NULL OR source != 8)
|
||||||
|
${excludeCompanyFilter}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Top 3 waiting tickets
|
// Top 3 waiting tickets
|
||||||
|
|
@ -41,6 +63,7 @@ export async function GET(request: NextRequest) {
|
||||||
WHERE t.completed_date IS NULL
|
WHERE t.completed_date IS NULL
|
||||||
AND t.status IN (21, 9, 19)
|
AND t.status IN (21, 9, 19)
|
||||||
AND (t.source IS NULL OR t.source != 8)
|
AND (t.source IS NULL OR t.source != 8)
|
||||||
|
${excludeCompanyFilter}
|
||||||
ORDER BY t.last_activity_date ASC NULLS FIRST
|
ORDER BY t.last_activity_date ASC NULLS FIRST
|
||||||
LIMIT 3`
|
LIMIT 3`
|
||||||
);
|
);
|
||||||
|
|
@ -51,7 +74,8 @@ export async function GET(request: NextRequest) {
|
||||||
FROM tickets
|
FROM tickets
|
||||||
WHERE completed_date IS NULL
|
WHERE completed_date IS NULL
|
||||||
AND last_activity_date < NOW() - INTERVAL '7 days'
|
AND last_activity_date < NOW() - INTERVAL '7 days'
|
||||||
AND (source IS NULL OR source != 8)`
|
AND (source IS NULL OR source != 8)
|
||||||
|
${excludeCompanyFilter}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Top 3 stale tickets (oldest activity first)
|
// Top 3 stale tickets (oldest activity first)
|
||||||
|
|
@ -62,6 +86,7 @@ export async function GET(request: NextRequest) {
|
||||||
WHERE t.completed_date IS NULL
|
WHERE t.completed_date IS NULL
|
||||||
AND t.last_activity_date < NOW() - INTERVAL '7 days'
|
AND t.last_activity_date < NOW() - INTERVAL '7 days'
|
||||||
AND (t.source IS NULL OR t.source != 8)
|
AND (t.source IS NULL OR t.source != 8)
|
||||||
|
${excludeCompanyFilter}
|
||||||
ORDER BY t.last_activity_date ASC NULLS FIRST
|
ORDER BY t.last_activity_date ASC NULLS FIRST
|
||||||
LIMIT 3`
|
LIMIT 3`
|
||||||
);
|
);
|
||||||
|
|
@ -72,7 +97,8 @@ export async function GET(request: NextRequest) {
|
||||||
FROM tickets
|
FROM tickets
|
||||||
WHERE completed_date IS NULL
|
WHERE completed_date IS NULL
|
||||||
AND due_date_time < NOW()
|
AND due_date_time < NOW()
|
||||||
AND (source IS NULL OR source != 8)`
|
AND (source IS NULL OR source != 8)
|
||||||
|
${excludeCompanyFilter}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Top 3 overdue tickets (most overdue first)
|
// Top 3 overdue tickets (most overdue first)
|
||||||
|
|
@ -83,6 +109,7 @@ export async function GET(request: NextRequest) {
|
||||||
WHERE t.completed_date IS NULL
|
WHERE t.completed_date IS NULL
|
||||||
AND t.due_date_time < NOW()
|
AND t.due_date_time < NOW()
|
||||||
AND (t.source IS NULL OR t.source != 8)
|
AND (t.source IS NULL OR t.source != 8)
|
||||||
|
${excludeCompanyFilter}
|
||||||
ORDER BY t.due_date_time ASC
|
ORDER BY t.due_date_time ASC
|
||||||
LIMIT 3`
|
LIMIT 3`
|
||||||
);
|
);
|
||||||
|
|
@ -92,7 +119,8 @@ export async function GET(request: NextRequest) {
|
||||||
`SELECT COUNT(*) as count
|
`SELECT COUNT(*) as count
|
||||||
FROM tickets
|
FROM tickets
|
||||||
WHERE completed_date IS NULL
|
WHERE completed_date IS NULL
|
||||||
AND (source IS NULL OR source != 8)`
|
AND (source IS NULL OR source != 8)
|
||||||
|
${excludeCompanyFilter}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Tickets closed today - exclude RMM alerts
|
// Tickets closed today - exclude RMM alerts
|
||||||
|
|
@ -100,7 +128,8 @@ export async function GET(request: NextRequest) {
|
||||||
`SELECT COUNT(*) as count
|
`SELECT COUNT(*) as count
|
||||||
FROM tickets
|
FROM tickets
|
||||||
WHERE DATE(completed_date) = CURRENT_DATE
|
WHERE DATE(completed_date) = CURRENT_DATE
|
||||||
AND (source IS NULL OR source != 8)`
|
AND (source IS NULL OR source != 8)
|
||||||
|
${excludeCompanyFilter}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Top 3 recently closed tickets
|
// Top 3 recently closed tickets
|
||||||
|
|
@ -110,6 +139,7 @@ export async function GET(request: NextRequest) {
|
||||||
LEFT JOIN companies c ON t.company_id = c.id
|
LEFT JOIN companies c ON t.company_id = c.id
|
||||||
WHERE DATE(t.completed_date) = CURRENT_DATE
|
WHERE DATE(t.completed_date) = CURRENT_DATE
|
||||||
AND (t.source IS NULL OR t.source != 8)
|
AND (t.source IS NULL OR t.source != 8)
|
||||||
|
${excludeCompanyFilter}
|
||||||
ORDER BY t.completed_date DESC
|
ORDER BY t.completed_date DESC
|
||||||
LIMIT 3`
|
LIMIT 3`
|
||||||
);
|
);
|
||||||
|
|
@ -120,7 +150,8 @@ export async function GET(request: NextRequest) {
|
||||||
FROM tickets
|
FROM tickets
|
||||||
WHERE completed_date >= NOW() - INTERVAL '30 days'
|
WHERE completed_date >= NOW() - INTERVAL '30 days'
|
||||||
AND completed_date IS NOT NULL
|
AND completed_date IS NOT NULL
|
||||||
AND (source IS NULL OR source != 8)`
|
AND (source IS NULL OR source != 8)
|
||||||
|
${excludeCompanyFilter}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Time entries this week
|
// Time entries this week
|
||||||
|
|
|
||||||
|
|
@ -103,11 +103,11 @@ export default function DashboardPage() {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Kiosk Display',
|
title: 'Kiosk Display',
|
||||||
description: 'Full-screen executive dashboard for TV display',
|
description: 'Configure and view executive dashboard for TV',
|
||||||
href: '/kiosk',
|
href: '/kiosk/settings',
|
||||||
icon: Activity,
|
icon: Activity,
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
stats: 'Live metrics display'
|
stats: 'Settings & display'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Sync Management',
|
title: 'Sync Management',
|
||||||
|
|
|
||||||
318
app/kiosk/settings/page.tsx
Normal file
318
app/kiosk/settings/page.tsx
Normal file
|
|
@ -0,0 +1,318 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { ArrowLeft, Save, Trash2 } from 'lucide-react';
|
||||||
|
|
||||||
|
interface Company {
|
||||||
|
id: number;
|
||||||
|
companyName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KioskSettings {
|
||||||
|
excluded_company_ids: number[];
|
||||||
|
cycle_interval: number;
|
||||||
|
refresh_interval: number;
|
||||||
|
show_rmm_alerts: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function KioskSettingsPage() {
|
||||||
|
const router = useRouter();
|
||||||
|
const [settings, setSettings] = useState<KioskSettings>({
|
||||||
|
excluded_company_ids: [],
|
||||||
|
cycle_interval: 7,
|
||||||
|
refresh_interval: 60,
|
||||||
|
show_rmm_alerts: false,
|
||||||
|
});
|
||||||
|
const [companies, setCompanies] = useState<Company[]>([]);
|
||||||
|
const [selectedCompanyId, setSelectedCompanyId] = useState<string>('');
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchSettings();
|
||||||
|
fetchCompanies();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const fetchSettings = async () => {
|
||||||
|
try {
|
||||||
|
const res = await fetch('/api/kiosk/settings');
|
||||||
|
if (res.ok) {
|
||||||
|
const data = await res.json();
|
||||||
|
setSettings(data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching settings:', error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchCompanies = async () => {
|
||||||
|
try {
|
||||||
|
const res = await fetch('/api/companies');
|
||||||
|
if (res.ok) {
|
||||||
|
const data = await res.json();
|
||||||
|
setCompanies(data.sort((a: Company, b: Company) =>
|
||||||
|
a.companyName.localeCompare(b.companyName)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching companies:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAddExcludedCompany = () => {
|
||||||
|
if (selectedCompanyId && !settings.excluded_company_ids.includes(parseInt(selectedCompanyId))) {
|
||||||
|
setSettings({
|
||||||
|
...settings,
|
||||||
|
excluded_company_ids: [...settings.excluded_company_ids, parseInt(selectedCompanyId)],
|
||||||
|
});
|
||||||
|
setSelectedCompanyId('');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRemoveExcludedCompany = (companyId: number) => {
|
||||||
|
setSettings({
|
||||||
|
...settings,
|
||||||
|
excluded_company_ids: settings.excluded_company_ids.filter(id => id !== companyId),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSave = async () => {
|
||||||
|
setSaving(true);
|
||||||
|
try {
|
||||||
|
// Save each setting
|
||||||
|
await Promise.all([
|
||||||
|
fetch('/api/kiosk/settings', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({
|
||||||
|
setting_key: 'excluded_company_ids',
|
||||||
|
setting_value: settings.excluded_company_ids,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
fetch('/api/kiosk/settings', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({
|
||||||
|
setting_key: 'cycle_interval',
|
||||||
|
setting_value: settings.cycle_interval,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
fetch('/api/kiosk/settings', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({
|
||||||
|
setting_key: 'refresh_interval',
|
||||||
|
setting_value: settings.refresh_interval,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
fetch('/api/kiosk/settings', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({
|
||||||
|
setting_key: 'show_rmm_alerts',
|
||||||
|
setting_value: settings.show_rmm_alerts,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
alert('Settings saved successfully!');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error saving settings:', error);
|
||||||
|
alert('Failed to save settings');
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getCompanyName = (companyId: number) => {
|
||||||
|
return companies.find(c => c.id === companyId)?.companyName || `Company ${companyId}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen bg-gray-950 text-white flex items-center justify-center">
|
||||||
|
<div className="text-xl">Loading settings...</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen bg-gray-950 text-white p-8">
|
||||||
|
<div className="max-w-4xl mx-auto">
|
||||||
|
{/* Header */}
|
||||||
|
<div className="flex items-center justify-between mb-8">
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
onClick={() => router.push('/dashboard')}
|
||||||
|
className="text-gray-400 hover:text-white"
|
||||||
|
>
|
||||||
|
<ArrowLeft className="w-5 h-5 mr-2" />
|
||||||
|
Back to Dashboard
|
||||||
|
</Button>
|
||||||
|
<h1 className="text-3xl font-bold">Kiosk Display Settings</h1>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
onClick={handleSave}
|
||||||
|
disabled={saving}
|
||||||
|
className="bg-blue-600 hover:bg-blue-700"
|
||||||
|
>
|
||||||
|
<Save className="w-5 h-5 mr-2" />
|
||||||
|
{saving ? 'Saving...' : 'Save Settings'}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-8">
|
||||||
|
{/* Excluded Companies Section */}
|
||||||
|
<div className="bg-gray-900 rounded-lg p-6 border border-gray-800">
|
||||||
|
<h2 className="text-xl font-semibold mb-4">Excluded Companies (Co-Managed Clients)</h2>
|
||||||
|
<p className="text-gray-400 mb-4">
|
||||||
|
Tickets from these companies will not appear in the kiosk display.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{/* Add Company */}
|
||||||
|
<div className="flex gap-2 mb-4">
|
||||||
|
<select
|
||||||
|
value={selectedCompanyId}
|
||||||
|
onChange={(e) => setSelectedCompanyId(e.target.value)}
|
||||||
|
className="flex-1 bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white"
|
||||||
|
>
|
||||||
|
<option value="">Select a company to exclude...</option>
|
||||||
|
{companies
|
||||||
|
.filter(c => !settings.excluded_company_ids.includes(c.id))
|
||||||
|
.map(company => (
|
||||||
|
<option key={company.id} value={company.id}>
|
||||||
|
{company.companyName}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
<Button
|
||||||
|
onClick={handleAddExcludedCompany}
|
||||||
|
disabled={!selectedCompanyId}
|
||||||
|
className="bg-blue-600 hover:bg-blue-700"
|
||||||
|
>
|
||||||
|
Add
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Excluded Companies List */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
{settings.excluded_company_ids.length === 0 ? (
|
||||||
|
<div className="text-gray-500 text-center py-4">
|
||||||
|
No companies excluded
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
settings.excluded_company_ids.map(companyId => (
|
||||||
|
<div
|
||||||
|
key={companyId}
|
||||||
|
className="flex items-center justify-between bg-gray-800 rounded px-4 py-3 border border-gray-700"
|
||||||
|
>
|
||||||
|
<span>{getCompanyName(companyId)}</span>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => handleRemoveExcludedCompany(companyId)}
|
||||||
|
className="text-red-400 hover:text-red-300 hover:bg-red-900/20"
|
||||||
|
>
|
||||||
|
<Trash2 className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Display Settings */}
|
||||||
|
<div className="bg-gray-900 rounded-lg p-6 border border-gray-800">
|
||||||
|
<h2 className="text-xl font-semibold mb-4">Display Settings</h2>
|
||||||
|
|
||||||
|
<div className="space-y-4">
|
||||||
|
{/* Cycle Interval */}
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium mb-2">
|
||||||
|
KPI Card Cycle Interval: {settings.cycle_interval} seconds
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
min="3"
|
||||||
|
max="15"
|
||||||
|
step="1"
|
||||||
|
value={settings.cycle_interval}
|
||||||
|
onChange={(e) => setSettings({ ...settings, cycle_interval: parseInt(e.target.value) })}
|
||||||
|
className="w-full"
|
||||||
|
/>
|
||||||
|
<div className="flex justify-between text-xs text-gray-500 mt-1">
|
||||||
|
<span>3s (Fast)</span>
|
||||||
|
<span>15s (Slow)</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Refresh Interval */}
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium mb-2">
|
||||||
|
Data Refresh Interval: {settings.refresh_interval} seconds
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
min="30"
|
||||||
|
max="300"
|
||||||
|
step="30"
|
||||||
|
value={settings.refresh_interval}
|
||||||
|
onChange={(e) => setSettings({ ...settings, refresh_interval: parseInt(e.target.value) })}
|
||||||
|
className="w-full"
|
||||||
|
/>
|
||||||
|
<div className="flex justify-between text-xs text-gray-500 mt-1">
|
||||||
|
<span>30s</span>
|
||||||
|
<span>5 min</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Filter Settings */}
|
||||||
|
<div className="bg-gray-900 rounded-lg p-6 border border-gray-800">
|
||||||
|
<h2 className="text-xl font-semibold mb-4">Ticket Filters</h2>
|
||||||
|
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<div className="font-medium">Show RMM Alert Tickets</div>
|
||||||
|
<div className="text-sm text-gray-400">
|
||||||
|
Include automated monitoring alerts (Veeam, WAN circuits, server alerts)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<label className="relative inline-flex items-center cursor-pointer">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={settings.show_rmm_alerts}
|
||||||
|
onChange={(e) => setSettings({ ...settings, show_rmm_alerts: e.target.checked })}
|
||||||
|
className="sr-only peer"
|
||||||
|
/>
|
||||||
|
<div className="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Preview Link */}
|
||||||
|
<div className="bg-gray-900 rounded-lg p-6 border border-gray-800">
|
||||||
|
<h2 className="text-xl font-semibold mb-4">Kiosk Display</h2>
|
||||||
|
<p className="text-gray-400 mb-4">
|
||||||
|
Open the kiosk display in full-screen mode for your TV.
|
||||||
|
</p>
|
||||||
|
<Button
|
||||||
|
onClick={() => window.open('/kiosk', '_blank')}
|
||||||
|
className="bg-blue-600 hover:bg-blue-700"
|
||||||
|
>
|
||||||
|
Open Kiosk Display
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
23
migrations/019_create_kiosk_settings.sql
Normal file
23
migrations/019_create_kiosk_settings.sql
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
-- Create kiosk_settings table to store kiosk configuration
|
||||||
|
CREATE TABLE IF NOT EXISTS kiosk_settings (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
setting_key VARCHAR(255) UNIQUE NOT NULL,
|
||||||
|
setting_value TEXT,
|
||||||
|
description TEXT,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Create index on setting_key for faster lookups
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_kiosk_settings_key ON kiosk_settings(setting_key);
|
||||||
|
|
||||||
|
-- Insert default settings
|
||||||
|
INSERT INTO kiosk_settings (setting_key, setting_value, description) VALUES
|
||||||
|
('excluded_company_ids', '29861361', 'Comma-separated list of company IDs to exclude from kiosk (co-managed clients)'),
|
||||||
|
('cycle_interval', '7', 'Default cycle interval in seconds (3-15)'),
|
||||||
|
('refresh_interval', '60', 'Data refresh interval in seconds'),
|
||||||
|
('show_rmm_alerts', 'false', 'Whether to show RMM alert tickets')
|
||||||
|
ON CONFLICT (setting_key) DO NOTHING;
|
||||||
|
|
||||||
|
-- Add comment to table
|
||||||
|
COMMENT ON TABLE kiosk_settings IS 'Configuration settings for the executive kiosk dashboard';
|
||||||
Loading…
Add table
Add a link
Reference in a new issue