Anpassung Aktivitäts-UI
Dieser Commit ist enthalten in:
@ -22,7 +22,7 @@ class ActivitySyncService:
|
||||
self.connected = False
|
||||
self.on_activities_update = None
|
||||
self.activities = []
|
||||
self.current_activity = None
|
||||
self.active_projects = [] # Changed from single current_activity to list
|
||||
|
||||
# Load settings
|
||||
self.load_settings()
|
||||
@ -143,7 +143,7 @@ class ActivitySyncService:
|
||||
logger.error(f"Error disconnecting: {e}")
|
||||
|
||||
def start_activity(self, project_name: str, project_path: str, description: str = ""):
|
||||
"""Start a new activity"""
|
||||
"""Start a new activity (adds to active projects list)"""
|
||||
logger.debug(f"start_activity called for: {project_name}")
|
||||
|
||||
if not self.connected or not self.sio:
|
||||
@ -151,15 +151,22 @@ class ActivitySyncService:
|
||||
return False
|
||||
|
||||
try:
|
||||
# Set current activity immediately
|
||||
self.current_activity = {
|
||||
# Check if project is already active
|
||||
existing = next((p for p in self.active_projects if p['projectName'] == project_name), None)
|
||||
if existing:
|
||||
logger.info(f"Project {project_name} is already active")
|
||||
return True
|
||||
|
||||
# Add to active projects list
|
||||
new_activity = {
|
||||
'projectName': project_name,
|
||||
'projectPath': project_path,
|
||||
'userId': self.user_id,
|
||||
'userName': self.user_name,
|
||||
'isActive': True
|
||||
}
|
||||
logger.debug(f"Set current_activity: {self.current_activity}")
|
||||
self.active_projects.append(new_activity)
|
||||
logger.debug(f"Added to active_projects: {new_activity}")
|
||||
|
||||
# Emit to server
|
||||
self.sio.emit('activity-start', {
|
||||
@ -172,29 +179,45 @@ class ActivitySyncService:
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to start activity: {e}")
|
||||
self.current_activity = None
|
||||
# Remove from list on failure
|
||||
self.active_projects = [p for p in self.active_projects if p['projectName'] != project_name]
|
||||
return False
|
||||
|
||||
def stop_activity(self):
|
||||
"""Stop the current activity"""
|
||||
logger.debug(f"stop_activity called, current: {self.current_activity}")
|
||||
def stop_activity(self, project_name: str = None):
|
||||
"""Stop activity for a specific project or all activities if no project specified"""
|
||||
logger.debug(f"stop_activity called for project: {project_name}")
|
||||
|
||||
if not self.connected or not self.sio:
|
||||
logger.warning("Not connected to activity server")
|
||||
return False
|
||||
|
||||
try:
|
||||
# Store project name for logging
|
||||
project_name = self.current_activity.get('projectName') if self.current_activity else 'None'
|
||||
|
||||
# Clear current activity immediately
|
||||
self.current_activity = None
|
||||
logger.debug("Cleared current_activity")
|
||||
|
||||
# Emit to server
|
||||
self.sio.emit('activity-stop')
|
||||
|
||||
logger.info(f"Stopped activity for project: {project_name}")
|
||||
if project_name:
|
||||
# Stop specific project
|
||||
activity = next((p for p in self.active_projects if p['projectName'] == project_name), None)
|
||||
if not activity:
|
||||
logger.warning(f"Project {project_name} is not in active projects")
|
||||
return False
|
||||
|
||||
# Remove from active projects
|
||||
self.active_projects = [p for p in self.active_projects if p['projectName'] != project_name]
|
||||
logger.debug(f"Removed {project_name} from active_projects")
|
||||
|
||||
# Emit to server with project name
|
||||
self.sio.emit('activity-stop', {'projectName': project_name})
|
||||
|
||||
logger.info(f"Stopped activity for project: {project_name}")
|
||||
else:
|
||||
# Stop all activities (backward compatibility)
|
||||
project_names = [p['projectName'] for p in self.active_projects]
|
||||
self.active_projects = []
|
||||
logger.debug("Cleared all active_projects")
|
||||
|
||||
# Emit to server (server should handle stopping all activities for this user)
|
||||
self.sio.emit('activity-stop')
|
||||
|
||||
logger.info(f"Stopped all activities: {project_names}")
|
||||
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to stop activity: {e}")
|
||||
@ -238,10 +261,27 @@ class ActivitySyncService:
|
||||
return activity
|
||||
return None
|
||||
|
||||
def get_current_activity(self) -> Optional[Dict]:
|
||||
"""Get current user's activity"""
|
||||
logger.debug(f"get_current_activity called, returning: {self.current_activity}")
|
||||
return self.current_activity
|
||||
def get_current_activity(self, project_name: str = None) -> Optional[Dict]:
|
||||
"""Get current user's activity for a specific project or first active project"""
|
||||
if project_name:
|
||||
# Return specific project if active
|
||||
activity = next((p for p in self.active_projects if p['projectName'] == project_name), None)
|
||||
logger.debug(f"get_current_activity for {project_name}, returning: {activity}")
|
||||
return activity
|
||||
else:
|
||||
# Return first active project for backward compatibility
|
||||
activity = self.active_projects[0] if self.active_projects else None
|
||||
logger.debug(f"get_current_activity called, returning: {activity}")
|
||||
return activity
|
||||
|
||||
def get_all_current_activities(self) -> List[Dict]:
|
||||
"""Get all current user's active projects"""
|
||||
logger.debug(f"get_all_current_activities called, returning {len(self.active_projects)} activities")
|
||||
return self.active_projects.copy()
|
||||
|
||||
def is_project_active_for_user(self, project_name: str) -> bool:
|
||||
"""Check if a specific project is active for the current user"""
|
||||
return any(p['projectName'] == project_name for p in self.active_projects)
|
||||
|
||||
def _fetch_initial_activities(self):
|
||||
"""Fetch initial activities after connection"""
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren