feat: add logo background toggle (dark/light) for companies
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Adds a per-company setting to display logos on dark background, useful for logos with white text or light-colored elements. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5e3feb94fe
commit
858eafcb97
@ -682,6 +682,37 @@ def api_fetch_company_logo(company_id):
|
||||
db.close()
|
||||
|
||||
|
||||
# ============================================================
|
||||
# LOGO BACKGROUND TOGGLE
|
||||
# ============================================================
|
||||
|
||||
@bp.route('/company/<int:company_id>/toggle-logo-bg', methods=['POST'])
|
||||
@login_required
|
||||
def api_toggle_logo_bg(company_id):
|
||||
"""Toggle dark/light background preference for company logo."""
|
||||
if not current_user.is_admin:
|
||||
return jsonify({'success': False, 'error': 'Brak uprawnień'}), 403
|
||||
|
||||
db = SessionLocal()
|
||||
try:
|
||||
company = db.query(Company).filter_by(id=company_id).first()
|
||||
if not company:
|
||||
return jsonify({'success': False, 'error': 'Firma nie znaleziona'}), 404
|
||||
|
||||
company.logo_dark_bg = not company.logo_dark_bg
|
||||
db.commit()
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'dark_bg': company.logo_dark_bg
|
||||
})
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
# ============================================================
|
||||
# AI ENRICHMENT HELPER FUNCTIONS
|
||||
# ============================================================
|
||||
|
||||
@ -804,6 +804,9 @@ class Company(Base):
|
||||
# Admin notes (internal, not visible to users)
|
||||
admin_notes = Column(Text)
|
||||
|
||||
# Logo display preference
|
||||
logo_dark_bg = Column(Boolean, default=False) # True = show logo on dark background
|
||||
|
||||
# Data source tracking
|
||||
data_source = Column(String(100))
|
||||
data_quality_score = Column(Integer)
|
||||
|
||||
3
database/migrations/063_company_logo_dark_bg.sql
Normal file
3
database/migrations/063_company_logo_dark_bg.sql
Normal file
@ -0,0 +1,3 @@
|
||||
-- Migration 063: Add logo_dark_bg flag to companies
|
||||
-- Allows admin to mark companies whose logo looks better on dark background
|
||||
ALTER TABLE companies ADD COLUMN IF NOT EXISTS logo_dark_bg BOOLEAN DEFAULT FALSE;
|
||||
@ -172,6 +172,11 @@
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.logo-box.dark-bg {
|
||||
background: #1a1a2e;
|
||||
border-color: #2d2d44;
|
||||
}
|
||||
|
||||
.logo-box img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@ -581,7 +586,7 @@
|
||||
<div class="section">
|
||||
<h2>Dane firmy</h2>
|
||||
<div class="info-header">
|
||||
<div class="logo-box">
|
||||
<div class="logo-box {{ 'dark-bg' if company.logo_dark_bg else '' }}">
|
||||
{% if enrichment.logo.path %}
|
||||
<img src="{{ enrichment.logo.path }}" alt="Logo {{ company.name }}">
|
||||
{% else %}
|
||||
@ -797,6 +802,12 @@
|
||||
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/></svg>
|
||||
Szukaj logo
|
||||
</button>
|
||||
{% if enrichment.logo.done %}
|
||||
<button id="btn-toggle-bg" class="btn-action" onclick="toggleLogoBg()" style="margin-top: var(--spacing-sm);">
|
||||
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"/></svg>
|
||||
<span id="toggle-bg-label">{{ 'Jasne tło' if company.logo_dark_bg else 'Ciemne tło' }}</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
<div id="logo-candidates" class="logo-candidates" style="display:none;"></div>
|
||||
</div>
|
||||
</div>
|
||||
@ -882,6 +893,30 @@
|
||||
return runEnrichAction(btn, '/api/company/{{ company.id }}/enrich-registry', {});
|
||||
}
|
||||
|
||||
function toggleLogoBg() {
|
||||
var btn = document.getElementById('btn-toggle-bg');
|
||||
btn.disabled = true;
|
||||
fetch('/api/company/{{ company.id }}/toggle-logo-bg', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json', 'X-CSRFToken': csrfToken},
|
||||
})
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(data) {
|
||||
if (data.success) {
|
||||
var logoBox = document.querySelector('.logo-box');
|
||||
var label = document.getElementById('toggle-bg-label');
|
||||
if (data.dark_bg) {
|
||||
logoBox.classList.add('dark-bg');
|
||||
label.textContent = 'Jasne tło';
|
||||
} else {
|
||||
logoBox.classList.remove('dark-bg');
|
||||
label.textContent = 'Ciemne tło';
|
||||
}
|
||||
}
|
||||
})
|
||||
.finally(function() { btn.disabled = false; });
|
||||
}
|
||||
|
||||
function fetchLogo() {
|
||||
var btn = document.getElementById('btn-logo');
|
||||
var original = btn.innerHTML;
|
||||
|
||||
@ -35,6 +35,10 @@
|
||||
margin-bottom: var(--spacing-md);
|
||||
}
|
||||
|
||||
.company-logo-header.dark-bg {
|
||||
background: #1a1a2e;
|
||||
}
|
||||
|
||||
.company-logo-header img {
|
||||
max-width: 90%;
|
||||
max-height: 90%;
|
||||
@ -866,7 +870,7 @@
|
||||
</div>
|
||||
|
||||
<div class="company-header">
|
||||
<div class="company-logo-header">
|
||||
<div class="company-logo-header {{ 'dark-bg' if company.logo_dark_bg else '' }}">
|
||||
<img src="{{ url_for('static', filename='img/companies/' ~ company.slug ~ '.webp') }}"
|
||||
alt="{{ company.name }}"
|
||||
onerror="if(!this.dataset.triedSvg){this.dataset.triedSvg='1';this.src=this.src.replace('.webp','.svg')}else{this.parentElement.style.display='none'}">
|
||||
|
||||
@ -701,6 +701,10 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.company-logo.dark-bg {
|
||||
background: #1a1a2e;
|
||||
}
|
||||
|
||||
.company-logo img {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
@ -1087,7 +1091,7 @@
|
||||
<div class="companies-grid" id="companiesGrid">
|
||||
{% for company in companies %}
|
||||
<div class="company-card" data-category="{{ company.category.slug if company.category else 'brak' }}" data-animate="fadeInUp" data-animate-delay="{{ (loop.index0 % 6) + 1 }}">
|
||||
<a href="{{ url_for('company_detail', company_id=company.id) }}" class="company-logo">
|
||||
<a href="{{ url_for('company_detail', company_id=company.id) }}" class="company-logo {{ 'dark-bg' if company.logo_dark_bg else '' }}">
|
||||
<img src="{{ url_for('static', filename='img/companies/' ~ company.slug ~ '.webp') }}"
|
||||
alt="{{ company.name }}"
|
||||
onerror="if(!this.dataset.triedSvg){this.dataset.triedSvg='1';this.src=this.src.replace('.webp','.svg')}else{this.parentElement.style.display='none'}">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user