wow, chrome-extension MUCH improved - websockets
This commit is contained in:
@@ -56,6 +56,29 @@ function History() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleExport = async (sessionId, format) => {
|
||||
try {
|
||||
const response = await api.get(`/sessions/${sessionId}/export?format=${format}`, {
|
||||
responseType: 'blob'
|
||||
});
|
||||
|
||||
// Create download link
|
||||
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', `session-${sessionId}.${format === 'json' ? 'json' : 'txt'}`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.parentNode.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
|
||||
success(`Session exported as ${format.toUpperCase()}`);
|
||||
} catch (err) {
|
||||
console.error('Failed to export session', err);
|
||||
error('Failed to export session');
|
||||
}
|
||||
};
|
||||
|
||||
const loadSessionGames = async (sessionId, silent = false) => {
|
||||
try {
|
||||
const response = await api.get(`/sessions/${sessionId}/games`);
|
||||
@@ -227,14 +250,32 @@ function History() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{isAuthenticated && sessions.find(s => s.id === selectedSession)?.is_active === 1 && (
|
||||
<button
|
||||
onClick={() => setShowChatImport(true)}
|
||||
className="bg-indigo-600 dark:bg-indigo-700 text-white px-4 py-2 rounded-lg hover:bg-indigo-700 dark:hover:bg-indigo-800 transition text-sm sm:text-base w-full sm:w-auto"
|
||||
>
|
||||
Import Chat Log
|
||||
</button>
|
||||
)}
|
||||
<div className="flex flex-col sm:flex-row gap-2">
|
||||
{isAuthenticated && sessions.find(s => s.id === selectedSession)?.is_active === 1 && (
|
||||
<button
|
||||
onClick={() => setShowChatImport(true)}
|
||||
className="bg-indigo-600 dark:bg-indigo-700 text-white px-4 py-2 rounded-lg hover:bg-indigo-700 dark:hover:bg-indigo-800 transition text-sm sm:text-base w-full sm:w-auto"
|
||||
>
|
||||
Import Chat Log
|
||||
</button>
|
||||
)}
|
||||
{isAuthenticated && (
|
||||
<>
|
||||
<button
|
||||
onClick={() => handleExport(selectedSession, 'txt')}
|
||||
className="bg-gray-600 dark:bg-gray-700 text-white px-4 py-2 rounded-lg hover:bg-gray-700 dark:hover:bg-gray-800 transition text-sm sm:text-base w-full sm:w-auto"
|
||||
>
|
||||
Export as Text
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleExport(selectedSession, 'json')}
|
||||
className="bg-gray-600 dark:bg-gray-700 text-white px-4 py-2 rounded-lg hover:bg-gray-700 dark:hover:bg-gray-800 transition text-sm sm:text-base w-full sm:w-auto"
|
||||
>
|
||||
Export as JSON
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{showChatImport && (
|
||||
|
||||
Reference in New Issue
Block a user