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
Production moved from on-prem VM 249 (10.22.68.249) to OVH VPS (57.128.200.27, inpi-vps-waw01). Updated ALL documentation, slash commands, memory files, architecture docs, and deploy procedures. Added |local_time Jinja filter (UTC→Europe/Warsaw) and converted 155 .strftime() calls across 71 templates so timestamps display in Polish timezone regardless of server timezone. Also includes: created_by_id tracking, abort import fix, ICS calendar fix for missing end times, Pros Poland data cleanup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
422 lines
13 KiB
HTML
422 lines
13 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}Konfiguracja FB: {{ company.name }} - Social Media{% endblock %}
|
|
|
|
{% block extra_css %}
|
|
<style>
|
|
.admin-header {
|
|
margin-bottom: var(--spacing-xl);
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
gap: var(--spacing-md);
|
|
}
|
|
|
|
.admin-header h1 {
|
|
font-size: var(--font-size-3xl);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.form-section {
|
|
background: var(--surface);
|
|
padding: var(--spacing-xl);
|
|
border-radius: var(--radius-lg);
|
|
box-shadow: var(--shadow);
|
|
max-width: 700px;
|
|
margin-bottom: var(--spacing-xl);
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: var(--spacing-lg);
|
|
}
|
|
|
|
.form-group label {
|
|
display: block;
|
|
margin-bottom: var(--spacing-xs);
|
|
font-weight: 500;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.form-group input[type="text"],
|
|
.form-group textarea {
|
|
width: 100%;
|
|
padding: var(--spacing-sm) var(--spacing-md);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-md);
|
|
font-size: var(--font-size-base);
|
|
font-family: inherit;
|
|
}
|
|
|
|
.form-group textarea {
|
|
min-height: 80px;
|
|
resize: vertical;
|
|
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
font-size: var(--font-size-sm);
|
|
}
|
|
|
|
.form-hint {
|
|
font-size: var(--font-size-sm);
|
|
color: var(--text-secondary);
|
|
margin-top: var(--spacing-xs);
|
|
}
|
|
|
|
.checkbox-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: var(--spacing-xs);
|
|
}
|
|
|
|
.checkbox-item input[type="checkbox"] {
|
|
width: 18px;
|
|
height: 18px;
|
|
}
|
|
|
|
.btn-group {
|
|
display: flex;
|
|
gap: var(--spacing-md);
|
|
margin-top: var(--spacing-xl);
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.section-title {
|
|
font-size: var(--font-size-lg);
|
|
font-weight: 600;
|
|
color: var(--text-primary);
|
|
margin-bottom: var(--spacing-md);
|
|
padding-bottom: var(--spacing-xs);
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
|
|
.oauth-section {
|
|
background: var(--background);
|
|
padding: var(--spacing-lg);
|
|
border-radius: var(--radius);
|
|
margin-bottom: var(--spacing-xl);
|
|
}
|
|
|
|
.oauth-status {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: var(--spacing-md);
|
|
margin-bottom: var(--spacing-md);
|
|
}
|
|
|
|
.oauth-status-icon {
|
|
width: 48px;
|
|
height: 48px;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 24px;
|
|
}
|
|
|
|
.oauth-status-icon.connected {
|
|
background: var(--success-bg);
|
|
color: var(--success);
|
|
}
|
|
|
|
.oauth-status-icon.disconnected {
|
|
background: var(--background);
|
|
color: var(--text-secondary);
|
|
border: 2px dashed var(--border);
|
|
}
|
|
|
|
.oauth-status-text h4 {
|
|
margin: 0;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.oauth-status-text p {
|
|
margin: var(--spacing-xs) 0 0;
|
|
font-size: var(--font-size-sm);
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.page-selector {
|
|
margin-top: var(--spacing-md);
|
|
}
|
|
|
|
.page-list {
|
|
list-style: none;
|
|
padding: 0;
|
|
margin: var(--spacing-md) 0;
|
|
}
|
|
|
|
.page-list li {
|
|
padding: var(--spacing-md);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
margin-bottom: var(--spacing-sm);
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.page-list li:hover {
|
|
border-color: var(--primary);
|
|
background: var(--primary-bg);
|
|
}
|
|
|
|
.page-list li.selected {
|
|
border-color: var(--success);
|
|
background: var(--success-bg);
|
|
}
|
|
|
|
.page-info {
|
|
flex: 1;
|
|
}
|
|
|
|
.page-info .name {
|
|
font-weight: 600;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.page-info .meta {
|
|
font-size: var(--font-size-sm);
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.config-status {
|
|
background: var(--background);
|
|
padding: var(--spacing-md);
|
|
border-radius: var(--radius);
|
|
margin-bottom: var(--spacing-lg);
|
|
font-size: var(--font-size-sm);
|
|
}
|
|
|
|
.config-status strong {
|
|
color: var(--primary);
|
|
}
|
|
|
|
.config-status .status-active {
|
|
color: var(--success);
|
|
font-weight: 600;
|
|
}
|
|
|
|
#page-loading {
|
|
display: none;
|
|
text-align: center;
|
|
padding: var(--spacing-lg);
|
|
color: var(--text-secondary);
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="container">
|
|
<div class="admin-header">
|
|
<h1>Facebook: {{ company.name }}</h1>
|
|
<a href="{{ url_for('admin.social_publisher_settings') }}" class="btn btn-secondary">Powrot do listy</a>
|
|
</div>
|
|
|
|
{% if config and config.page_id %}
|
|
<div class="config-status">
|
|
<strong>Obecna konfiguracja:</strong>
|
|
Strona: <strong>{{ config.page_name or 'Nie ustawiona' }}</strong>
|
|
| Status: {% if config.is_active %}<span class="status-active">Aktywna</span>{% else %}Nieaktywna{% endif %}
|
|
| Debug: {% if config.debug_mode %}<span style="color: var(--warning); font-weight: 600;">Wlaczony</span>{% else %}Wylaczony{% endif %}
|
|
{% if config.updated_at %}
|
|
| Ostatnia aktualizacja: {{ config.updated_at|local_time('%Y-%m-%d %H:%M') }}
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- OAuth Section -->
|
|
<div class="form-section">
|
|
<h3 class="section-title">Polaczenie z Facebook (OAuth)</h3>
|
|
|
|
<div class="oauth-section">
|
|
<div class="oauth-status">
|
|
{% if oauth_token %}
|
|
<div class="oauth-status-icon connected">✓</div>
|
|
<div class="oauth-status-text">
|
|
<h4>Polaczono z Facebook</h4>
|
|
<p>{% if oauth_token.account_name %}Strona: {{ oauth_token.account_name }}{% else %}Token aktywny{% endif %}</p>
|
|
</div>
|
|
{% else %}
|
|
<div class="oauth-status-icon disconnected">?</div>
|
|
<div class="oauth-status-text">
|
|
<h4>Brak polaczenia</h4>
|
|
<p>Polacz konto Facebook, aby publikowac posty na stronie firmowej</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% if oauth_token %}
|
|
<div style="display: flex; gap: var(--spacing-sm); flex-wrap: wrap;">
|
|
<button type="button" class="btn btn-secondary btn-small" id="btn-discover-pages">
|
|
Zmien strone FB
|
|
</button>
|
|
<button type="button" class="btn btn-error btn-small" id="btn-disconnect"
|
|
onclick="disconnectOAuth()">
|
|
Rozlacz
|
|
</button>
|
|
</div>
|
|
{% else %}
|
|
<button type="button" class="btn btn-primary" id="btn-connect-fb"
|
|
onclick="connectFacebook()">
|
|
Polacz z Facebook
|
|
</button>
|
|
{% endif %}
|
|
|
|
<!-- Page selector (hidden by default) -->
|
|
<div class="page-selector" id="page-selector" style="display: none;">
|
|
<h4>Wybierz strone Facebook:</h4>
|
|
<div id="page-loading">Ladowanie stron...</div>
|
|
<ul class="page-list" id="page-list"></ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Debug mode form -->
|
|
{% if config and config.page_id %}
|
|
<div class="form-section">
|
|
<h3 class="section-title">Ustawienia publikacji</h3>
|
|
<form method="POST">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
|
|
<div class="form-group">
|
|
<label class="checkbox-item">
|
|
<input type="checkbox" name="debug_mode"
|
|
{% if config and config.debug_mode %}checked{% endif %}>
|
|
<span>Tryb debug</span>
|
|
</label>
|
|
<p class="form-hint">W trybie debug posty sa widoczne tylko dla adminow strony FB (nie sa publiczne)</p>
|
|
</div>
|
|
|
|
<div class="btn-group">
|
|
<a href="{{ url_for('admin.social_publisher_settings') }}" class="btn btn-secondary">Anuluj</a>
|
|
<button type="submit" class="btn btn-primary">Zapisz ustawienia</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block extra_js %}
|
|
const companyId = {{ company.id }};
|
|
const csrfToken = '{{ csrf_token() }}';
|
|
|
|
async function connectFacebook() {
|
|
try {
|
|
const resp = await fetch('/api/oauth/connect/meta/facebook', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': csrfToken
|
|
}
|
|
});
|
|
if (!resp.ok && resp.headers.get('content-type')?.indexOf('json') === -1) {
|
|
alert('Blad serwera (' + resp.status + '). OAuth moze nie byc skonfigurowany.');
|
|
return;
|
|
}
|
|
const data = await resp.json();
|
|
if (data.success && data.auth_url) {
|
|
window.location.href = data.auth_url;
|
|
} else {
|
|
alert('Blad: ' + (data.error || 'Nie udalo sie zainicjowac polaczenia OAuth'));
|
|
}
|
|
} catch (err) {
|
|
alert('Blad polaczenia: ' + err.message);
|
|
}
|
|
}
|
|
|
|
async function disconnectOAuth() {
|
|
if (!confirm('Czy na pewno chcesz rozlaczyc Facebook?')) return;
|
|
|
|
try {
|
|
const resp = await fetch('/api/oauth/disconnect/meta/facebook', {
|
|
method: 'POST',
|
|
headers: { 'X-CSRFToken': csrfToken }
|
|
});
|
|
const data = await resp.json();
|
|
if (data.success) {
|
|
location.reload();
|
|
} else {
|
|
alert('Blad: ' + (data.error || 'Nie udalo sie rozlaczyc'));
|
|
}
|
|
} catch (err) {
|
|
alert('Blad polaczenia: ' + err.message);
|
|
}
|
|
}
|
|
|
|
document.getElementById('btn-discover-pages')?.addEventListener('click', discoverPages);
|
|
|
|
async function discoverPages() {
|
|
const selector = document.getElementById('page-selector');
|
|
const loading = document.getElementById('page-loading');
|
|
const list = document.getElementById('page-list');
|
|
|
|
selector.style.display = 'block';
|
|
loading.style.display = 'block';
|
|
list.innerHTML = '';
|
|
|
|
try {
|
|
const resp = await fetch('/api/oauth/meta/discover-pages', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'X-CSRFToken': csrfToken
|
|
},
|
|
body: JSON.stringify({ company_id: companyId })
|
|
});
|
|
const data = await resp.json();
|
|
loading.style.display = 'none';
|
|
|
|
if (data.success && data.pages && data.pages.length > 0) {
|
|
data.pages.forEach(page => {
|
|
const li = document.createElement('li');
|
|
li.innerHTML = `
|
|
<div class="page-info">
|
|
<div class="name">${page.name}</div>
|
|
<div class="meta">${page.category || ''} | ${(page.fan_count || 0).toLocaleString()} fanow</div>
|
|
</div>
|
|
<button class="btn btn-primary btn-small" onclick="selectPage('${page.id}', '${page.name.replace(/'/g, "\\'")}')">Wybierz</button>
|
|
`;
|
|
list.appendChild(li);
|
|
});
|
|
} else if (data.success) {
|
|
list.innerHTML = '<li style="cursor:default;">Brak stron Facebook do wyswietlenia. Upewnij sie, ze masz uprawnienia administratora strony.</li>';
|
|
} else {
|
|
list.innerHTML = '<li style="cursor:default; color: var(--error);">Blad: ' + (data.error || 'Nieznany') + '</li>';
|
|
}
|
|
} catch (err) {
|
|
loading.style.display = 'none';
|
|
list.innerHTML = '<li style="cursor:default; color: var(--error);">Blad polaczenia: ' + err.message + '</li>';
|
|
}
|
|
}
|
|
|
|
async function selectPage(pageId, pageName) {
|
|
try {
|
|
const resp = await fetch('/api/oauth/meta/select-page', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'X-CSRFToken': csrfToken
|
|
},
|
|
body: JSON.stringify({
|
|
company_id: companyId,
|
|
page_id: pageId
|
|
})
|
|
});
|
|
const data = await resp.json();
|
|
if (data.success) {
|
|
location.reload();
|
|
} else {
|
|
alert('Blad: ' + (data.error || 'Nie udalo sie wybrac strony'));
|
|
}
|
|
} catch (err) {
|
|
alert('Blad polaczenia: ' + err.message);
|
|
}
|
|
}
|
|
|
|
// Auto-discover pages if OAuth is connected but no page selected
|
|
{% if oauth_token and not (config and config.page_id) %}
|
|
document.addEventListener('DOMContentLoaded', discoverPages);
|
|
{% endif %}
|
|
{% endblock %}
|