more refactoring
This commit is contained in:
parent
7268d49b4a
commit
ce5d2c9fb4
10 changed files with 251 additions and 39 deletions
|
|
@ -59,6 +59,31 @@ function updateState(newState) {
|
|||
renderApp();
|
||||
}
|
||||
|
||||
function showToast(message, type = 'info') {
|
||||
const container = document.getElementById('toast-container');
|
||||
const toast = document.createElement('div');
|
||||
toast.className = `toast ${type}`;
|
||||
|
||||
const icons = {
|
||||
success: '✓',
|
||||
error: '✕',
|
||||
info: 'ℹ'
|
||||
};
|
||||
|
||||
toast.innerHTML = `
|
||||
<span class="toast-icon">${icons[type] || 'ℹ'}</span>
|
||||
<span class="toast-message">${message}</span>
|
||||
`;
|
||||
|
||||
container.appendChild(toast);
|
||||
|
||||
// Auto remove
|
||||
setTimeout(() => {
|
||||
toast.style.animation = 'fadeOut 0.3s forwards';
|
||||
setTimeout(() => toast.remove(), 300);
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
function renderApp() {
|
||||
renderTaskList();
|
||||
|
||||
|
|
@ -343,9 +368,10 @@ rerunBtn.addEventListener('click', async () => {
|
|||
state.tasks[index] = updatedTask;
|
||||
}
|
||||
selectTask(updatedTask.id);
|
||||
showToast('Task rerun successfully!', 'success');
|
||||
} catch (error) {
|
||||
console.error('Error running task:', error);
|
||||
alert('Failed to run task.');
|
||||
console.error('Failed to rerun task:', error);
|
||||
showToast('Failed to rerun task.', 'error');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -464,9 +490,10 @@ newTaskForm.addEventListener('submit', async (e) => {
|
|||
state.isEditing = false;
|
||||
selectTask(updatedTask.id);
|
||||
renderTaskList();
|
||||
showToast(state.isEditing ? 'Task updated successfully' : 'Task created successfully', 'success');
|
||||
} catch (error) {
|
||||
console.error('Error creating task:', error);
|
||||
alert('Failed to execute task. Check console.');
|
||||
console.error('Save task failed:', error);
|
||||
showToast('Failed to execute task. Check console.', 'error');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -536,8 +563,8 @@ async function handleCallback() {
|
|||
throw new Error('No access token in response');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Auth callback failed:', error);
|
||||
alert('Authentication failed.');
|
||||
console.error('Callback failed:', error);
|
||||
showToast('Authentication failed.', 'error');
|
||||
showLogin();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue