auto-claude: Merge auto-claude/006-hej-znasz-ta-aplikacje-i-te-mechanizmy-https-www-f

This commit is contained in:
Maciej Pienczyn 2026-01-08 19:49:45 +01:00
commit 6426f97831
6 changed files with 2695 additions and 1 deletions

405
app.py
View File

@ -134,6 +134,16 @@ except ImportError as e:
SEO_AUDIT_AVAILABLE = False SEO_AUDIT_AVAILABLE = False
logger.warning(f"SEO audit service not available: {e}") logger.warning(f"SEO audit service not available: {e}")
# GBP (Google Business Profile) audit service
try:
from gbp_audit_service import GBPAuditService, audit_company as gbp_audit_company, get_company_audit as gbp_get_company_audit
GBP_AUDIT_AVAILABLE = True
GBP_AUDIT_VERSION = '1.0'
except ImportError as e:
GBP_AUDIT_AVAILABLE = False
GBP_AUDIT_VERSION = None
logger.warning(f"GBP audit service not available: {e}")
# Initialize Flask app # Initialize Flask app
app = Flask(__name__) app = Flask(__name__)
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production') app.config['SECRET_KEY'] = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production')
@ -3624,6 +3634,401 @@ def admin_seo():
db.close() db.close()
# ============================================================
# GBP (GOOGLE BUSINESS PROFILE) AUDIT API
# ============================================================
@app.route('/api/gbp/audit/health')
def api_gbp_audit_health():
"""
API: Health check for GBP audit service.
Returns service status and version information.
Used by monitoring systems to verify service availability.
"""
if GBP_AUDIT_AVAILABLE:
return jsonify({
'status': 'ok',
'service': 'gbp_audit',
'version': GBP_AUDIT_VERSION,
'available': True
}), 200
else:
return jsonify({
'status': 'unavailable',
'service': 'gbp_audit',
'available': False,
'error': 'GBP audit service not loaded'
}), 503
@app.route('/api/gbp/audit', methods=['GET'])
def api_gbp_audit_get():
"""
API: Get GBP audit results for a company.
Query parameters:
- company_id: Company ID (integer) OR
- slug: Company slug (string)
Returns:
- Latest audit results with completeness score and recommendations
- 404 if company not found
- 404 if no audit exists for the company
Example: GET /api/gbp/audit?company_id=26
Example: GET /api/gbp/audit?slug=pixlab-sp-z-o-o
"""
if not GBP_AUDIT_AVAILABLE:
return jsonify({
'success': False,
'error': 'Usługa audytu GBP jest niedostępna.'
}), 503
company_id = request.args.get('company_id', type=int)
slug = request.args.get('slug')
if not company_id and not slug:
return jsonify({
'success': False,
'error': 'Podaj company_id lub slug firmy.'
}), 400
db = SessionLocal()
try:
# Find company
if company_id:
company = db.query(Company).filter_by(id=company_id, status='active').first()
else:
company = db.query(Company).filter_by(slug=slug, status='active').first()
if not company:
return jsonify({
'success': False,
'error': 'Firma nie znaleziona lub nieaktywna.'
}), 404
# Get latest audit
audit = gbp_get_company_audit(db, company.id)
if not audit:
return jsonify({
'success': False,
'error': f'Brak wyników audytu GBP dla firmy "{company.name}". Uruchom audyt używając POST /api/gbp/audit.',
'company_id': company.id,
'company_name': company.name
}), 404
# Build response
return jsonify({
'success': True,
'company_id': company.id,
'company_name': company.name,
'company_slug': company.slug,
'audit': {
'id': audit.id,
'audit_date': audit.audit_date.isoformat() if audit.audit_date else None,
'completeness_score': audit.completeness_score,
'score_category': audit.score_category,
'fields_status': audit.fields_status,
'recommendations': audit.recommendations,
'has_name': audit.has_name,
'has_address': audit.has_address,
'has_phone': audit.has_phone,
'has_website': audit.has_website,
'has_hours': audit.has_hours,
'has_categories': audit.has_categories,
'has_photos': audit.has_photos,
'has_description': audit.has_description,
'has_services': audit.has_services,
'has_reviews': audit.has_reviews,
'photo_count': audit.photo_count,
'review_count': audit.review_count,
'average_rating': float(audit.average_rating) if audit.average_rating else None,
'google_place_id': audit.google_place_id,
'audit_source': audit.audit_source,
'audit_version': audit.audit_version
}
}), 200
except Exception as e:
logger.error(f"Error fetching GBP audit: {e}")
return jsonify({
'success': False,
'error': f'Błąd podczas pobierania audytu: {str(e)}'
}), 500
finally:
db.close()
@app.route('/api/gbp/audit/<slug>')
def api_gbp_audit_by_slug(slug):
"""
API: Get GBP audit results for a company by slug.
Convenience endpoint that uses slug from URL path.
Example: GET /api/gbp/audit/pixlab-sp-z-o-o
"""
if not GBP_AUDIT_AVAILABLE:
return jsonify({
'success': False,
'error': 'Usługa audytu GBP jest niedostępna.'
}), 503
db = SessionLocal()
try:
company = db.query(Company).filter_by(slug=slug, status='active').first()
if not company:
return jsonify({
'success': False,
'error': f'Firma o slug "{slug}" nie znaleziona.'
}), 404
audit = gbp_get_company_audit(db, company.id)
if not audit:
return jsonify({
'success': False,
'error': f'Brak wyników audytu GBP dla firmy "{company.name}".',
'company_id': company.id,
'company_name': company.name
}), 404
return jsonify({
'success': True,
'company_id': company.id,
'company_name': company.name,
'company_slug': company.slug,
'audit': {
'id': audit.id,
'audit_date': audit.audit_date.isoformat() if audit.audit_date else None,
'completeness_score': audit.completeness_score,
'score_category': audit.score_category,
'fields_status': audit.fields_status,
'recommendations': audit.recommendations,
'photo_count': audit.photo_count,
'review_count': audit.review_count,
'average_rating': float(audit.average_rating) if audit.average_rating else None
}
}), 200
finally:
db.close()
@app.route('/api/gbp/audit', methods=['POST'])
@login_required
@limiter.limit("20 per hour")
def api_gbp_audit_trigger():
"""
API: Run GBP audit for a company.
This endpoint runs a completeness audit for Google Business Profile data,
checking fields like name, address, phone, website, hours, categories,
photos, description, services, and reviews.
Request JSON body:
- company_id: Company ID (integer) OR
- slug: Company slug (string)
- save: Whether to save results to database (default: true)
Returns:
- Success: Audit results with completeness score and recommendations
- Error: Error message with status code
Access:
- Members can audit their own company
- Admins can audit any company
Rate limited to 20 requests per hour per user.
"""
if not GBP_AUDIT_AVAILABLE:
return jsonify({
'success': False,
'error': 'Usługa audytu GBP jest niedostępna. Sprawdź konfigurację serwera.'
}), 503
# Parse request data
data = request.get_json()
if not data:
return jsonify({
'success': False,
'error': 'Brak danych w żądaniu. Podaj company_id lub slug.'
}), 400
company_id = data.get('company_id')
slug = data.get('slug')
save_result = data.get('save', True)
if not company_id and not slug:
return jsonify({
'success': False,
'error': 'Podaj company_id lub slug firmy do audytu.'
}), 400
db = SessionLocal()
try:
# Find company by ID or slug
if company_id:
company = db.query(Company).filter_by(id=company_id, status='active').first()
else:
company = db.query(Company).filter_by(slug=slug, status='active').first()
if not company:
return jsonify({
'success': False,
'error': 'Firma nie znaleziona lub nieaktywna.'
}), 404
# Check access: admin can audit any company, member only their own
if not current_user.is_admin:
# Check if user is associated with this company
if current_user.company_id != company.id:
return jsonify({
'success': False,
'error': 'Brak uprawnień. Możesz audytować tylko własną firmę.'
}), 403
logger.info(f"GBP audit triggered by {current_user.email} for company: {company.name} (ID: {company.id})")
try:
# Run the audit
result = gbp_audit_company(db, company.id, save=save_result)
# Build field status for response
fields_response = {}
for field_name, field_status in result.fields.items():
fields_response[field_name] = {
'status': field_status.status,
'value': str(field_status.value) if field_status.value is not None else None,
'score': field_status.score,
'max_score': field_status.max_score,
'recommendation': field_status.recommendation
}
# Determine score category
score = result.completeness_score
if score >= 90:
score_category = 'excellent'
elif score >= 70:
score_category = 'good'
elif score >= 50:
score_category = 'needs_work'
else:
score_category = 'poor'
return jsonify({
'success': True,
'message': f'Audyt GBP dla firmy "{company.name}" został zakończony pomyślnie.',
'company_id': company.id,
'company_name': company.name,
'company_slug': company.slug,
'audit_version': GBP_AUDIT_VERSION,
'triggered_by': current_user.email,
'triggered_at': datetime.now().isoformat(),
'saved': save_result,
'audit': {
'completeness_score': result.completeness_score,
'score_category': score_category,
'fields_status': fields_response,
'recommendations': result.recommendations,
'photo_count': result.photo_count,
'logo_present': result.logo_present,
'cover_photo_present': result.cover_photo_present,
'review_count': result.review_count,
'average_rating': float(result.average_rating) if result.average_rating else None,
'google_place_id': result.google_place_id
}
}), 200
except ValueError as e:
return jsonify({
'success': False,
'error': str(e),
'company_id': company.id if company else None
}), 400
except Exception as e:
logger.error(f"GBP audit error for company {company.id}: {e}")
return jsonify({
'success': False,
'error': f'Błąd podczas wykonywania audytu: {str(e)}',
'company_id': company.id,
'company_name': company.name
}), 500
finally:
db.close()
# ============================================================
# GBP AUDIT USER-FACING DASHBOARD
# ============================================================
@app.route('/audit/gbp/<slug>')
@login_required
def gbp_audit_dashboard(slug):
"""
User-facing GBP audit dashboard for a specific company.
Displays Google Business Profile completeness audit results with:
- Overall completeness score (0-100)
- Field-by-field status breakdown
- AI-generated improvement recommendations
- Historical audit data
Access control:
- Admin users can view audit for any company
- Regular users can only view audit for their own company
Args:
slug: Company slug identifier
Returns:
Rendered gbp_audit.html template with company and audit data
"""
if not GBP_AUDIT_AVAILABLE:
flash('Usługa audytu Google Business Profile jest tymczasowo niedostępna.', 'error')
return redirect(url_for('dashboard'))
db = SessionLocal()
try:
# Find company by slug
company = db.query(Company).filter_by(slug=slug, status='active').first()
if not company:
flash('Firma nie została znaleziona.', 'error')
return redirect(url_for('dashboard'))
# Access control: admin can view any company, member only their own
if not current_user.is_admin:
if current_user.company_id != company.id:
flash('Brak uprawnień. Możesz przeglądać audyt tylko własnej firmy.', 'error')
return redirect(url_for('dashboard'))
# Get latest audit for this company
audit = gbp_get_company_audit(db, company.id)
# If no audit exists, we still render the page (template handles this)
# The user can trigger an audit from the dashboard
# Determine if user can run audit (admin or company owner)
can_audit = current_user.is_admin or current_user.company_id == company.id
logger.info(f"GBP audit dashboard viewed by {current_user.email} for company: {company.name}")
return render_template('gbp_audit.html',
company=company,
audit=audit,
can_audit=can_audit,
gbp_audit_available=GBP_AUDIT_AVAILABLE,
gbp_audit_version=GBP_AUDIT_VERSION
)
finally:
db.close()
@app.route('/api/check-email', methods=['POST']) @app.route('/api/check-email', methods=['POST'])
def api_check_email(): def api_check_email():
"""API: Check if email is available""" """API: Check if email is available"""

View File

@ -13,10 +13,11 @@ Models:
- CompanyDigitalMaturity: Digital maturity scores and benchmarking - CompanyDigitalMaturity: Digital maturity scores and benchmarking
- CompanyWebsiteAnalysis: Website analysis and SEO metrics - CompanyWebsiteAnalysis: Website analysis and SEO metrics
- MaturityAssessment: Historical tracking of maturity scores - MaturityAssessment: Historical tracking of maturity scores
- GBPAudit: Google Business Profile audit results
Author: Norda Biznes Development Team Author: Norda Biznes Development Team
Created: 2025-11-23 Created: 2025-11-23
Updated: 2025-11-26 (Digital Maturity Platform - ETAP 1) Updated: 2026-01-08 (GBP Audit Tool)
""" """
import os import os
@ -1129,6 +1130,89 @@ class UserNotification(Base):
self.read_at = datetime.now() self.read_at = datetime.now()
# ============================================================
# GOOGLE BUSINESS PROFILE AUDIT
# ============================================================
class GBPAudit(Base):
"""
Google Business Profile audit results for companies.
Tracks completeness scores and provides improvement recommendations.
"""
__tablename__ = 'gbp_audits'
id = Column(Integer, primary_key=True)
company_id = Column(Integer, ForeignKey('companies.id', ondelete='CASCADE'), nullable=False, index=True)
# Audit timestamp
audit_date = Column(DateTime, default=datetime.now, nullable=False, index=True)
# Completeness scoring (0-100)
completeness_score = Column(Integer)
# Field-by-field status tracking
# Example: {"name": {"status": "complete", "value": "Company Name"}, "phone": {"status": "missing"}, ...}
fields_status = Column(JSONB)
# AI-generated recommendations
# Example: [{"priority": "high", "field": "description", "recommendation": "Add a detailed business description..."}, ...]
recommendations = Column(JSONB)
# Individual field scores (for detailed breakdown)
has_name = Column(Boolean, default=False)
has_address = Column(Boolean, default=False)
has_phone = Column(Boolean, default=False)
has_website = Column(Boolean, default=False)
has_hours = Column(Boolean, default=False)
has_categories = Column(Boolean, default=False)
has_photos = Column(Boolean, default=False)
has_description = Column(Boolean, default=False)
has_services = Column(Boolean, default=False)
has_reviews = Column(Boolean, default=False)
# Photo counts
photo_count = Column(Integer, default=0)
logo_present = Column(Boolean, default=False)
cover_photo_present = Column(Boolean, default=False)
# Review metrics
review_count = Column(Integer, default=0)
average_rating = Column(Numeric(2, 1))
# Google Place data
google_place_id = Column(String(100))
google_maps_url = Column(String(500))
# Audit metadata
audit_source = Column(String(50), default='manual') # manual, automated, api
audit_version = Column(String(20), default='1.0')
audit_errors = Column(Text)
# Timestamps
created_at = Column(DateTime, default=datetime.now)
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)
# Relationship
company = relationship('Company', backref='gbp_audits')
def __repr__(self):
return f'<GBPAudit company_id={self.company_id} score={self.completeness_score}>'
@property
def score_category(self):
"""Return score category: excellent, good, needs_work, poor"""
if self.completeness_score is None:
return 'unknown'
if self.completeness_score >= 90:
return 'excellent'
elif self.completeness_score >= 70:
return 'good'
elif self.completeness_score >= 50:
return 'needs_work'
else:
return 'poor'
# ============================================================ # ============================================================
# MEMBERSHIP FEES # MEMBERSHIP FEES
# ============================================================ # ============================================================

View File

@ -0,0 +1,216 @@
-- ============================================================
-- NordaBiz - Migration: Google Business Profile (GBP) Audit Tables
-- ============================================================
-- Created: 2026-01-08
-- Description:
-- - Creates gbp_audits table for storing GBP completeness audit results
-- - Tracks field-by-field status with JSONB for flexibility
-- - Stores AI-generated recommendations
-- - Includes indexes and helpful views
--
-- Usage:
-- PostgreSQL: psql -h localhost -U nordabiz_app -d nordabiz -f add_gbp_audit.sql
-- SQLite: Not fully supported (JSONB columns)
-- ============================================================
-- ============================================================
-- 1. MAIN GBP_AUDITS TABLE
-- ============================================================
CREATE TABLE IF NOT EXISTS gbp_audits (
id SERIAL PRIMARY KEY,
-- Company reference
company_id INTEGER NOT NULL REFERENCES companies(id) ON DELETE CASCADE,
-- Audit timestamp
audit_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
-- Completeness scoring (0-100)
completeness_score INTEGER,
-- Field-by-field status tracking (JSONB)
-- Example: {"name": {"status": "complete", "value": "Company Name"}, "phone": {"status": "missing"}, ...}
fields_status JSONB,
-- AI-generated recommendations (JSONB)
-- Example: [{"priority": "high", "field": "description", "recommendation": "Add a detailed business description..."}, ...]
recommendations JSONB,
-- Individual field completion flags
has_name BOOLEAN DEFAULT FALSE,
has_address BOOLEAN DEFAULT FALSE,
has_phone BOOLEAN DEFAULT FALSE,
has_website BOOLEAN DEFAULT FALSE,
has_hours BOOLEAN DEFAULT FALSE,
has_categories BOOLEAN DEFAULT FALSE,
has_photos BOOLEAN DEFAULT FALSE,
has_description BOOLEAN DEFAULT FALSE,
has_services BOOLEAN DEFAULT FALSE,
has_reviews BOOLEAN DEFAULT FALSE,
-- Photo metrics
photo_count INTEGER DEFAULT 0,
logo_present BOOLEAN DEFAULT FALSE,
cover_photo_present BOOLEAN DEFAULT FALSE,
-- Review metrics
review_count INTEGER DEFAULT 0,
average_rating NUMERIC(2, 1),
-- Google Place integration
google_place_id VARCHAR(100),
google_maps_url VARCHAR(500),
-- Audit metadata
audit_source VARCHAR(50) DEFAULT 'manual', -- manual, automated, api
audit_version VARCHAR(20) DEFAULT '1.0',
audit_errors TEXT,
-- Timestamps
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
COMMENT ON TABLE gbp_audits IS 'Google Business Profile completeness audit results';
COMMENT ON COLUMN gbp_audits.completeness_score IS 'Overall GBP completeness score 0-100';
COMMENT ON COLUMN gbp_audits.fields_status IS 'Field-by-field status with values as JSON';
COMMENT ON COLUMN gbp_audits.recommendations IS 'AI-generated improvement recommendations as JSON array';
COMMENT ON COLUMN gbp_audits.audit_source IS 'How audit was triggered: manual, automated, api';
COMMENT ON COLUMN gbp_audits.google_place_id IS 'Google Places API place_id for verification';
COMMENT ON COLUMN gbp_audits.google_maps_url IS 'Direct link to Google Maps listing';
-- ============================================================
-- 2. INDEXES FOR PERFORMANCE
-- ============================================================
CREATE INDEX IF NOT EXISTS idx_gbp_audits_company ON gbp_audits(company_id);
CREATE INDEX IF NOT EXISTS idx_gbp_audits_date ON gbp_audits(audit_date);
CREATE INDEX IF NOT EXISTS idx_gbp_audits_score ON gbp_audits(completeness_score);
CREATE INDEX IF NOT EXISTS idx_gbp_audits_company_date ON gbp_audits(company_id, audit_date DESC);
-- ============================================================
-- 3. UPDATE TRIGGER FOR updated_at
-- ============================================================
CREATE OR REPLACE FUNCTION gbp_audits_update_timestamp()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = CURRENT_TIMESTAMP;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS trigger_gbp_audits_update ON gbp_audits;
CREATE TRIGGER trigger_gbp_audits_update
BEFORE UPDATE ON gbp_audits
FOR EACH ROW
EXECUTE FUNCTION gbp_audits_update_timestamp();
-- ============================================================
-- 4. GBP AUDIT OVERVIEW VIEW
-- ============================================================
CREATE OR REPLACE VIEW v_company_gbp_overview AS
SELECT
c.id,
c.name,
c.slug,
c.website,
cat.name as category_name,
ga.completeness_score,
ga.has_name,
ga.has_address,
ga.has_phone,
ga.has_website,
ga.has_hours,
ga.has_categories,
ga.has_photos,
ga.has_description,
ga.has_services,
ga.has_reviews,
ga.photo_count,
ga.review_count,
ga.average_rating,
ga.google_place_id,
ga.audit_date,
ga.audit_source,
-- Score category
CASE
WHEN ga.completeness_score >= 90 THEN 'excellent'
WHEN ga.completeness_score >= 70 THEN 'good'
WHEN ga.completeness_score >= 50 THEN 'needs_work'
WHEN ga.completeness_score IS NOT NULL THEN 'poor'
ELSE 'not_audited'
END as score_category
FROM companies c
LEFT JOIN categories cat ON c.category_id = cat.id
LEFT JOIN LATERAL (
SELECT * FROM gbp_audits
WHERE company_id = c.id
ORDER BY audit_date DESC
LIMIT 1
) ga ON TRUE
ORDER BY ga.completeness_score DESC NULLS LAST;
COMMENT ON VIEW v_company_gbp_overview IS 'Latest GBP audit results per company for dashboard';
-- ============================================================
-- 5. GBP AUDIT HISTORY VIEW
-- ============================================================
CREATE OR REPLACE VIEW v_gbp_audit_history AS
SELECT
ga.id as audit_id,
c.id as company_id,
c.name as company_name,
c.slug as company_slug,
ga.completeness_score,
ga.audit_date,
ga.audit_source,
ga.audit_version,
-- Previous score for comparison
LAG(ga.completeness_score) OVER (
PARTITION BY ga.company_id
ORDER BY ga.audit_date
) as previous_score,
-- Score change
ga.completeness_score - LAG(ga.completeness_score) OVER (
PARTITION BY ga.company_id
ORDER BY ga.audit_date
) as score_change
FROM gbp_audits ga
JOIN companies c ON ga.company_id = c.id
ORDER BY ga.audit_date DESC;
COMMENT ON VIEW v_gbp_audit_history IS 'GBP audit history with score trend tracking';
-- ============================================================
-- 6. GRANTS FOR APPLICATION USER
-- ============================================================
-- Grant permissions on table
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE gbp_audits TO nordabiz_app;
-- Grant permissions on sequence
GRANT USAGE, SELECT ON SEQUENCE gbp_audits_id_seq TO nordabiz_app;
-- Grant permissions on views
GRANT SELECT ON v_company_gbp_overview TO nordabiz_app;
GRANT SELECT ON v_gbp_audit_history TO nordabiz_app;
-- ============================================================
-- MIGRATION COMPLETE
-- ============================================================
-- Verify migration (PostgreSQL only)
DO $$
BEGIN
RAISE NOTICE 'GBP Audit migration completed successfully!';
RAISE NOTICE 'Created:';
RAISE NOTICE ' - Table: gbp_audits';
RAISE NOTICE ' - Indexes: company_id, audit_date, completeness_score, company_date';
RAISE NOTICE ' - Trigger: updated_at auto-update';
RAISE NOTICE ' - Views: v_company_gbp_overview, v_gbp_audit_history';
RAISE NOTICE ' - Grants: nordabiz_app permissions';
END $$;

1065
gbp_audit_service.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -281,6 +281,10 @@
.contact-bar-item.social-tiktok { color: #000000; border-color: #000000; } .contact-bar-item.social-tiktok { color: #000000; border-color: #000000; }
.contact-bar-item.social-tiktok:hover { background: #000000; color: white; } .contact-bar-item.social-tiktok:hover { background: #000000; color: white; }
/* GBP Audit link - styled as action button */
.contact-bar-item.gbp-audit { color: #4285f4; border-color: #4285f4; background: rgba(66, 133, 244, 0.05); }
.contact-bar-item.gbp-audit:hover { background: #4285f4; color: white; }
@media (max-width: 768px) { @media (max-width: 768px) {
.contact-bar { .contact-bar {
justify-content: center; justify-content: center;
@ -483,6 +487,18 @@
<span>TikTok</span> <span>TikTok</span>
</a> </a>
{% endif %} {% endif %}
{# GBP Audit link - visible to admins (all profiles) or regular users (own company only) #}
{% if current_user.is_authenticated %}
{% if current_user.is_admin or (current_user.company_id and current_user.company_id == company.id) %}
<a href="{{ url_for('gbp_audit_dashboard', slug=company.slug) }}" class="contact-bar-item gbp-audit" title="Audyt Google Business Profile">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<span>Audyt GBP</span>
</a>
{% endif %}
{% endif %}
</div> </div>
<!-- O firmie - Single Description (prioritized sources) --> <!-- O firmie - Single Description (prioritized sources) -->

908
templates/gbp_audit.html Normal file
View File

@ -0,0 +1,908 @@
{% extends "base.html" %}
{% block title %}Audyt Google Business Profile - {{ company.name }} - Norda Biznes Hub{% endblock %}
{% block extra_css %}
<style>
.audit-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: var(--spacing-xl);
flex-wrap: wrap;
gap: var(--spacing-md);
}
.audit-header-info h1 {
font-size: var(--font-size-2xl);
color: var(--text-primary);
margin-bottom: var(--spacing-xs);
}
.audit-header-info p {
color: var(--text-secondary);
font-size: var(--font-size-sm);
}
.data-source-info {
display: inline-flex;
align-items: center;
gap: var(--spacing-xs);
margin-top: var(--spacing-sm);
padding: var(--spacing-xs) var(--spacing-sm);
background: var(--info-light, #e0f2fe);
border-radius: var(--radius);
font-size: var(--font-size-sm);
color: var(--info, #0284c7);
}
.data-source-info svg {
flex-shrink: 0;
}
.header-actions {
display: flex;
gap: var(--spacing-sm);
align-items: center;
}
/* Score Display */
.score-section {
display: grid;
grid-template-columns: auto 1fr;
gap: var(--spacing-xl);
margin-bottom: var(--spacing-xl);
background: var(--surface);
padding: var(--spacing-xl);
border-radius: var(--radius-lg);
box-shadow: var(--shadow);
}
@media (max-width: 768px) {
.score-section {
grid-template-columns: 1fr;
text-align: center;
}
}
.score-circle {
width: 180px;
height: 180px;
border-radius: 50%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
background: conic-gradient(
var(--score-color, var(--secondary)) calc(var(--score-percent, 0) * 3.6deg),
#e2e8f0 0deg
);
margin: 0 auto;
}
.score-circle::before {
content: '';
position: absolute;
width: 150px;
height: 150px;
border-radius: 50%;
background: var(--surface);
}
.score-value {
position: relative;
z-index: 1;
font-size: 3rem;
font-weight: 700;
line-height: 1;
}
.score-value.score-good { color: var(--success); }
.score-value.score-medium { color: var(--warning); }
.score-value.score-poor { color: var(--error); }
.score-label {
position: relative;
z-index: 1;
font-size: var(--font-size-sm);
color: var(--text-secondary);
margin-top: var(--spacing-xs);
}
.score-details {
display: flex;
flex-direction: column;
justify-content: center;
}
.score-category {
font-size: var(--font-size-xl);
font-weight: 600;
margin-bottom: var(--spacing-sm);
}
.score-category.excellent { color: var(--success); }
.score-category.good { color: #22c55e; }
.score-category.average { color: var(--warning); }
.score-category.poor { color: var(--error); }
.score-description {
color: var(--text-secondary);
line-height: 1.6;
margin-bottom: var(--spacing-md);
}
.audit-meta {
display: flex;
gap: var(--spacing-lg);
font-size: var(--font-size-sm);
color: var(--text-secondary);
flex-wrap: wrap;
}
.audit-meta-item {
display: flex;
align-items: center;
gap: var(--spacing-xs);
}
/* Fields Section */
.fields-section {
margin-bottom: var(--spacing-xl);
}
.section-title {
font-size: var(--font-size-xl);
font-weight: 600;
color: var(--text-primary);
margin-bottom: var(--spacing-md);
display: flex;
align-items: center;
gap: var(--spacing-sm);
}
.fields-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: var(--spacing-md);
}
.field-card {
background: var(--surface);
border-radius: var(--radius-lg);
padding: var(--spacing-md);
box-shadow: var(--shadow-sm);
border-left: 4px solid var(--border);
transition: var(--transition);
}
.field-card:hover {
box-shadow: var(--shadow);
}
.field-card.complete {
border-left-color: var(--success);
}
.field-card.partial {
border-left-color: var(--warning);
}
.field-card.missing {
border-left-color: var(--error);
}
.field-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: var(--spacing-sm);
}
.field-name {
font-weight: 600;
color: var(--text-primary);
display: flex;
align-items: center;
gap: var(--spacing-xs);
}
.field-status-badge {
font-size: 11px;
font-weight: 500;
padding: 2px 8px;
border-radius: var(--radius-sm);
text-transform: uppercase;
}
.field-status-badge.complete {
background: #dcfce7;
color: #166534;
}
.field-status-badge.partial {
background: #fef3c7;
color: #92400e;
}
.field-status-badge.missing {
background: #fee2e2;
color: #991b1b;
}
.field-value {
font-size: var(--font-size-sm);
color: var(--text-secondary);
margin-bottom: var(--spacing-sm);
word-break: break-word;
}
.field-score {
display: flex;
align-items: center;
gap: var(--spacing-sm);
}
.field-score-bar {
flex: 1;
height: 6px;
background: var(--border);
border-radius: 3px;
overflow: hidden;
}
.field-score-fill {
height: 100%;
border-radius: 3px;
transition: width 0.3s ease;
}
.field-score-fill.complete { background: var(--success); }
.field-score-fill.partial { background: var(--warning); }
.field-score-fill.missing { background: var(--error); }
.field-score-text {
font-size: var(--font-size-sm);
color: var(--text-secondary);
min-width: 60px;
text-align: right;
}
/* Recommendations Section */
.recommendations-section {
margin-bottom: var(--spacing-xl);
}
.recommendation-list {
display: flex;
flex-direction: column;
gap: var(--spacing-sm);
}
.recommendation-item {
background: var(--surface);
border-radius: var(--radius);
padding: var(--spacing-md);
box-shadow: var(--shadow-sm);
display: flex;
align-items: flex-start;
gap: var(--spacing-md);
transition: var(--transition);
}
.recommendation-item:hover {
box-shadow: var(--shadow);
}
.recommendation-priority {
flex-shrink: 0;
width: 32px;
height: 32px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.recommendation-priority.high {
background: #fee2e2;
color: var(--error);
}
.recommendation-priority.medium {
background: #fef3c7;
color: var(--warning);
}
.recommendation-priority.low {
background: #dbeafe;
color: var(--primary);
}
.recommendation-content {
flex: 1;
}
.recommendation-field {
font-weight: 600;
font-size: var(--font-size-sm);
color: var(--text-primary);
margin-bottom: var(--spacing-xs);
text-transform: capitalize;
}
.recommendation-text {
color: var(--text-secondary);
font-size: var(--font-size-sm);
line-height: 1.5;
}
.recommendation-impact {
flex-shrink: 0;
font-size: var(--font-size-sm);
color: var(--text-secondary);
display: flex;
align-items: center;
gap: var(--spacing-xs);
}
/* No Audit State */
.no-audit-state {
text-align: center;
padding: var(--spacing-2xl);
background: var(--surface);
border-radius: var(--radius-lg);
box-shadow: var(--shadow);
}
.no-audit-state svg {
width: 80px;
height: 80px;
color: var(--text-secondary);
opacity: 0.5;
margin-bottom: var(--spacing-md);
}
.no-audit-state h2 {
font-size: var(--font-size-xl);
color: var(--text-primary);
margin-bottom: var(--spacing-sm);
}
.no-audit-state p {
color: var(--text-secondary);
margin-bottom: var(--spacing-lg);
}
/* Loading State */
.loading-overlay {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.9);
z-index: 1000;
align-items: center;
justify-content: center;
flex-direction: column;
gap: var(--spacing-md);
}
.loading-overlay.active {
display: flex;
}
.loading-spinner {
width: 48px;
height: 48px;
border: 4px solid var(--border);
border-top-color: var(--primary);
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.loading-text {
color: var(--text-secondary);
font-size: var(--font-size-lg);
}
/* Legend */
.legend {
display: flex;
gap: var(--spacing-lg);
margin-bottom: var(--spacing-md);
font-size: var(--font-size-sm);
color: var(--text-secondary);
flex-wrap: wrap;
}
.legend-item {
display: flex;
align-items: center;
gap: var(--spacing-xs);
}
.legend-dot {
width: 12px;
height: 12px;
border-radius: 2px;
}
.legend-dot.complete { background: #dcfce7; border: 1px solid #166534; }
.legend-dot.partial { background: #fef3c7; border: 1px solid #92400e; }
.legend-dot.missing { background: #fee2e2; border: 1px solid #991b1b; }
/* Breadcrumb */
.breadcrumb {
display: flex;
align-items: center;
gap: var(--spacing-sm);
font-size: var(--font-size-sm);
color: var(--text-secondary);
margin-bottom: var(--spacing-md);
}
.breadcrumb a {
color: var(--primary);
text-decoration: none;
}
.breadcrumb a:hover {
text-decoration: underline;
}
.breadcrumb-separator {
color: var(--border);
}
/* Modal styles */
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: 1000;
align-items: center;
justify-content: center;
}
.modal.active {
display: flex;
}
.modal-content {
background: var(--surface);
padding: var(--spacing-xl);
border-radius: var(--radius-lg);
max-width: 480px;
width: 90%;
box-shadow: var(--shadow-lg);
animation: modalSlideIn 0.2s ease-out;
}
@keyframes modalSlideIn {
from {
opacity: 0;
transform: translateY(-20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.modal-header {
display: flex;
align-items: center;
gap: var(--spacing-md);
margin-bottom: var(--spacing-md);
}
.modal-icon {
width: 48px;
height: 48px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.modal-icon.success {
background: #dcfce7;
color: #16a34a;
}
.modal-icon.info {
background: #dbeafe;
color: #2563eb;
}
.modal-icon.warning {
background: #fef3c7;
color: #d97706;
}
.modal-title {
font-size: var(--font-size-xl);
font-weight: 600;
color: var(--text-primary);
}
.modal-body {
color: var(--text-secondary);
line-height: 1.6;
margin-bottom: var(--spacing-lg);
}
.modal-footer {
display: flex;
justify-content: flex-end;
gap: var(--spacing-sm);
}
/* Field icons */
.field-icon {
width: 16px;
height: 16px;
color: var(--text-secondary);
}
/* Responsive */
@media (max-width: 768px) {
.audit-header {
flex-direction: column;
}
.header-actions {
width: 100%;
justify-content: center;
}
.fields-grid {
grid-template-columns: 1fr;
}
.recommendation-item {
flex-direction: column;
}
.recommendation-impact {
align-self: flex-start;
}
}
</style>
{% endblock %}
{% block content %}
<!-- Breadcrumb -->
<div class="breadcrumb">
<a href="{{ url_for('index') }}">Firmy</a>
<span class="breadcrumb-separator">/</span>
<a href="{{ url_for('company_detail', company_id=company.id) }}">{{ company.name }}</a>
<span class="breadcrumb-separator">/</span>
<span>Audyt GBP</span>
</div>
<div class="audit-header">
<div class="audit-header-info">
<h1>Audyt Google Business Profile</h1>
<p>{{ company.name }}</p>
<div class="data-source-info">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<span>Analiza kompletnosci wizytowki Google dla lokalnego SEO</span>
</div>
</div>
<div class="header-actions">
<a href="{{ url_for('company_detail', company_id=company.id) }}" class="btn btn-outline btn-sm">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/>
</svg>
Profil firmy
</a>
{% if can_audit %}
<button class="btn btn-primary btn-sm" onclick="runAudit()" id="runAuditBtn">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
Uruchom audyt
</button>
{% endif %}
</div>
</div>
{% if audit %}
<!-- Score Section -->
<div class="score-section">
<div class="score-circle" style="--score-percent: {{ audit.completeness_score }}; --score-color: {% if audit.completeness_score >= 80 %}var(--success){% elif audit.completeness_score >= 50 %}var(--warning){% else %}var(--error){% endif %};">
<span class="score-value {% if audit.completeness_score >= 80 %}score-good{% elif audit.completeness_score >= 50 %}score-medium{% else %}score-poor{% endif %}">{{ audit.completeness_score }}</span>
<span class="score-label">/ 100</span>
</div>
<div class="score-details">
<div class="score-category {% if audit.completeness_score >= 90 %}excellent{% elif audit.completeness_score >= 70 %}good{% elif audit.completeness_score >= 50 %}average{% else %}poor{% endif %}">
{% if audit.completeness_score >= 90 %}
Doskonaly profil
{% elif audit.completeness_score >= 70 %}
Dobry profil
{% elif audit.completeness_score >= 50 %}
Sredni profil
{% else %}
Profil wymaga pracy
{% endif %}
</div>
<p class="score-description">
{% if audit.completeness_score >= 90 %}
Twoja wizytowka Google jest bardzo dobrze zoptymalizowana. Utrzymaj wysoki standard i monitoruj opinie klientow.
{% elif audit.completeness_score >= 70 %}
Profil jest w dobrym stanie, ale sa obszary do poprawy. Skupienie sie na rekomendacjach zwiekszy widocznosc.
{% elif audit.completeness_score >= 50 %}
Wizytowka wymaga uzupelnienia. Wdrozenie ponizszych rekomendacji znaczaco poprawi lokalne SEO.
{% else %}
Wizytowka jest niekompletna i traci potencjalnych klientow. Priorytetowo uzupelnij brakujace informacje.
{% endif %}
</p>
<div class="audit-meta">
<div class="audit-meta-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
<span>Ostatni audyt: {{ audit.audit_date.strftime('%d.%m.%Y %H:%M') if audit.audit_date else 'Brak danych' }}</span>
</div>
{% if audit.review_count %}
<div class="audit-meta-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"/>
</svg>
<span>{{ audit.review_count }} opinii{% if audit.average_rating %} ({{ audit.average_rating }}/5){% endif %}</span>
</div>
{% endif %}
</div>
</div>
</div>
<!-- Fields Section -->
<div class="fields-section">
<h2 class="section-title">
<svg width="24" height="24" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"/>
</svg>
Status pol wizytowki
</h2>
<div class="legend">
<div class="legend-item">
<div class="legend-dot complete"></div>
<span>Kompletne</span>
</div>
<div class="legend-item">
<div class="legend-dot partial"></div>
<span>Czesciowe</span>
</div>
<div class="legend-item">
<div class="legend-dot missing"></div>
<span>Brakujace</span>
</div>
</div>
<div class="fields-grid">
{% set field_icons = {
'name': '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"/>',
'address': '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"/>',
'phone': '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/>',
'website': '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"/>',
'hours': '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>',
'categories': '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"/>',
'photos': '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/>',
'description': '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h7"/>',
'services': '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>',
'reviews': '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"/>'
} %}
{% set field_names_pl = {
'name': 'Nazwa firmy',
'address': 'Adres',
'phone': 'Telefon',
'website': 'Strona WWW',
'hours': 'Godziny otwarcia',
'categories': 'Kategorie',
'photos': 'Zdjecia',
'description': 'Opis',
'services': 'Uslugi',
'reviews': 'Opinie'
} %}
{% set status_names = {
'complete': 'Kompletne',
'partial': 'Czesciowe',
'missing': 'Brakuje'
} %}
{% for field_name, field_data in audit.fields_status.items() %}
<div class="field-card {{ field_data.status }}">
<div class="field-header">
<span class="field-name">
<svg class="field-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
{{ field_icons.get(field_name, '')|safe }}
</svg>
{{ field_names_pl.get(field_name, field_name) }}
</span>
<span class="field-status-badge {{ field_data.status }}">
{{ status_names.get(field_data.status, field_data.status) }}
</span>
</div>
{% if field_data.value %}
<div class="field-value">{{ field_data.value }}</div>
{% endif %}
<div class="field-score">
<div class="field-score-bar">
<div class="field-score-fill {{ field_data.status }}" style="width: {{ (field_data.score / field_data.max_score * 100) if field_data.max_score else 0 }}%;"></div>
</div>
<span class="field-score-text">{{ field_data.score|round(1) }}/{{ field_data.max_score }}</span>
</div>
</div>
{% endfor %}
</div>
</div>
<!-- Recommendations Section -->
{% if audit.recommendations %}
<div class="recommendations-section">
<h2 class="section-title">
<svg width="24" height="24" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"/>
</svg>
Rekomendacje ({{ audit.recommendations|length }})
</h2>
<div class="recommendation-list">
{% for rec in audit.recommendations %}
<div class="recommendation-item">
<div class="recommendation-priority {{ rec.priority }}">
{% if rec.priority == 'high' %}
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
</svg>
{% elif rec.priority == 'medium' %}
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
{% else %}
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"/>
</svg>
{% endif %}
</div>
<div class="recommendation-content">
<div class="recommendation-field">{{ field_names_pl.get(rec.field, rec.field) }}</div>
<div class="recommendation-text">{{ rec.recommendation }}</div>
</div>
<div class="recommendation-impact">
<svg width="14" height="14" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"/>
</svg>
+{{ rec.impact }} pkt
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% else %}
<!-- No Audit State -->
<div class="no-audit-state">
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"/>
</svg>
<h2>Brak danych audytu</h2>
<p>Nie przeprowadzono jeszcze audytu wizytowki Google dla tej firmy. Uruchom audyt, aby sprawdzic kompletnosc profilu.</p>
{% if can_audit %}
<button class="btn btn-primary" onclick="runAudit()">
<svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
Uruchom pierwszy audyt
</button>
{% endif %}
</div>
{% endif %}
<!-- Loading Overlay -->
<div class="loading-overlay" id="loadingOverlay">
<div class="loading-spinner"></div>
<div class="loading-text">Trwa analiza wizytowki Google...</div>
</div>
<!-- Info Modal -->
<div class="modal" id="infoModal">
<div class="modal-content">
<div class="modal-header">
<div class="modal-icon info" id="modalIcon">
<svg width="24" height="24" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
</div>
<div class="modal-title" id="modalTitle">Informacja</div>
</div>
<div class="modal-body" id="modalBody">
Tresc informacji.
</div>
<div class="modal-footer">
<button class="btn btn-primary" onclick="closeInfoModal()">OK</button>
</div>
</div>
</div>
{% endblock %}
{% block extra_js %}
const csrfToken = '{{ csrf_token() }}';
const companySlug = '{{ company.slug }}';
function showLoading() {
document.getElementById('loadingOverlay').classList.add('active');
}
function hideLoading() {
document.getElementById('loadingOverlay').classList.remove('active');
}
function showInfoModal(title, body, isSuccess) {
document.getElementById('modalTitle').textContent = title;
document.getElementById('modalBody').textContent = body;
const icon = document.getElementById('modalIcon');
icon.className = 'modal-icon ' + (isSuccess ? 'success' : 'info');
document.getElementById('infoModal').classList.add('active');
}
function closeInfoModal() {
document.getElementById('infoModal').classList.remove('active');
}
document.getElementById('infoModal')?.addEventListener('click', (e) => {
if (e.target.id === 'infoModal') closeInfoModal();
});
async function runAudit() {
const btn = document.getElementById('runAuditBtn');
if (btn) {
btn.disabled = true;
}
showLoading();
try {
const response = await fetch('/api/gbp/audit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken
},
body: JSON.stringify({ slug: companySlug })
});
const data = await response.json();
hideLoading();
if (response.ok && data.success) {
showInfoModal('Audyt zakonczone', 'Audyt wizytowki Google zostal zakonczony pomyslnie. Strona zostanie odswiezona.', true);
setTimeout(() => location.reload(), 1500);
} else {
showInfoModal('Blad', data.error || 'Wystapil nieznany blad podczas audytu.', false);
if (btn) btn.disabled = false;
}
} catch (error) {
hideLoading();
showInfoModal('Blad polaczenia', 'Nie udalo sie polaczyc z serwerem: ' + error.message, false);
if (btn) btn.disabled = false;
}
}
{% endblock %}