mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-04-27 07:50:29 -05:00
d230a41e8a
- Improve web interface layout for better user-friendliness and mobile responsiveness * Update CSS variables for consistent spacing and component sizing * Enhance card layouts with improved padding, borders, and shadows * Optimize button and form element dimensions for better touch targets * Add hover effects and animations for improved user interaction * Implement responsive grid system with mobile-first approach - Refactor mobile JavaScript to prevent duplicate initialization * Consolidate mobile enhancements into dedicated utility classes * Add initialization guards to prevent double loading * Implement MobileUtils and MobileNavigation classes * Remove duplicate event listeners and mobile enhancements - Fix circular import issue in logo handling * Replace problematic 'from app import app' with Flask's current_app * Add error handling for cases where current_app is unavailable * Improve logo path resolution with fallback mechanisms * Fix settings model to use proper Flask context - Clean up template code and remove duplication * Remove duplicate mobile enhancements from base template * Clean up dashboard template JavaScript * Centralize all mobile functionality in mobile.js * Add proper error handling and debugging - Update CSS variables and spacing system * Introduce --section-spacing and --card-spacing variables * Add mobile-specific spacing variables * Improve border-radius and shadow consistency * Enhance typography and visual hierarchy This commit resolves the double loading issue and logo import errors while significantly improving the overall user experience and mobile responsiveness of the web interface.
70 lines
2.0 KiB
Python
70 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Time Tracker Application Entry Point
|
|
"""
|
|
|
|
import os
|
|
from app import create_app, db
|
|
from app.models import User, Project, TimeEntry, Task, Settings, Invoice, InvoiceItem
|
|
|
|
app = create_app()
|
|
|
|
@app.shell_context_processor
|
|
def make_shell_context():
|
|
"""Add database models to Flask shell context"""
|
|
return {
|
|
'db': db,
|
|
'User': User,
|
|
'Project': Project,
|
|
'TimeEntry': TimeEntry,
|
|
'Task': Task,
|
|
'Settings': Settings,
|
|
'Invoice': Invoice,
|
|
'InvoiceItem': InvoiceItem
|
|
}
|
|
|
|
@app.cli.command()
|
|
def init_db():
|
|
"""Initialize the database with tables and default data"""
|
|
from app.models import Settings, User
|
|
|
|
# Create all tables
|
|
db.create_all()
|
|
|
|
# Initialize settings if they don't exist
|
|
if not Settings.query.first():
|
|
settings = Settings()
|
|
db.session.add(settings)
|
|
db.session.commit()
|
|
print("Database initialized with default settings")
|
|
|
|
# Create admin user if it doesn't exist
|
|
admin_username = os.getenv('ADMIN_USERNAMES', 'admin').split(',')[0]
|
|
if not User.query.filter_by(username=admin_username).first():
|
|
admin_user = User(username=admin_username, role='admin')
|
|
db.session.add(admin_user)
|
|
db.session.commit()
|
|
print(f"Created admin user: {admin_username}")
|
|
|
|
print("Database initialization complete!")
|
|
|
|
@app.cli.command()
|
|
def create_admin():
|
|
"""Create an admin user"""
|
|
username = input("Enter admin username: ").strip()
|
|
if not username:
|
|
print("Username cannot be empty")
|
|
return
|
|
|
|
if User.query.filter_by(username=username).first():
|
|
print(f"User {username} already exists")
|
|
return
|
|
|
|
user = User(username=username, role='admin')
|
|
db.session.add(user)
|
|
db.session.commit()
|
|
print(f"Created admin user: {username}")
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host='0.0.0.0', port=8080, debug=os.getenv('FLASK_DEBUG', 'false').lower() == 'true')
|