asd
This commit is contained in:
627
igy8-wp-plugin/admin/assets/css/admin.css
Normal file
627
igy8-wp-plugin/admin/assets/css/admin.css
Normal file
@@ -0,0 +1,627 @@
|
||||
/**
|
||||
* Admin Styles - IGNY8 Bridge
|
||||
* Updated with IGNY8 brand colors and modern UI
|
||||
*
|
||||
* @package Igny8Bridge
|
||||
*/
|
||||
|
||||
/* ============================================
|
||||
IGNY8 Brand Colors
|
||||
============================================ */
|
||||
:root {
|
||||
--igny8-primary: #3B82F6;
|
||||
--igny8-primary-hover: #2563EB;
|
||||
--igny8-success: #10B981;
|
||||
--igny8-warning: #F59E0B;
|
||||
--igny8-error: #EF4444;
|
||||
--igny8-purple: #8B5CF6;
|
||||
--igny8-gray: #6B7280;
|
||||
--igny8-light-gray: #F3F4F6;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Container & Layout
|
||||
============================================ */
|
||||
|
||||
.igny8-settings-container {
|
||||
max-width: 1400px;
|
||||
}
|
||||
|
||||
.igny8-settings-card {
|
||||
background: #fff;
|
||||
border: 1px solid #E5E7EB;
|
||||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
||||
padding: 24px;
|
||||
margin: 24px 0;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.igny8-settings-card h2 {
|
||||
margin-top: 0;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 2px solid var(--igny8-light-gray);
|
||||
color: #111827;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Toggle Switch
|
||||
============================================ */
|
||||
|
||||
.igny8-toggle-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.igny8-toggle-input {
|
||||
position: relative;
|
||||
width: 48px;
|
||||
height: 24px;
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
background: var(--igny8-gray);
|
||||
outline: none;
|
||||
border-radius: 24px;
|
||||
cursor: pointer;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
.igny8-toggle-input:checked {
|
||||
background: var(--igny8-success);
|
||||
}
|
||||
|
||||
.igny8-toggle-input::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
background: #fff;
|
||||
transition: 0.3s;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.igny8-toggle-input:checked::before {
|
||||
left: 26px;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Sync Operations Grid
|
||||
============================================ */
|
||||
|
||||
.igny8-sync-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: 20px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.igny8-sync-card {
|
||||
background: #fff;
|
||||
border: 2px solid #E5E7EB;
|
||||
border-radius: 12px;
|
||||
padding: 24px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.igny8-sync-card:hover {
|
||||
border-color: var(--igny8-primary);
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.igny8-sync-card-highlight {
|
||||
border-color: var(--igny8-primary);
|
||||
background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
|
||||
}
|
||||
|
||||
.igny8-sync-icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
background: var(--igny8-primary);
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 16px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.igny8-sync-card h3 {
|
||||
margin: 0 0 8px 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
.igny8-sync-description {
|
||||
font-size: 14px;
|
||||
color: #6B7280;
|
||||
line-height: 1.5;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.igny8-sync-meta {
|
||||
font-size: 12px;
|
||||
color: #9CA3AF;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.igny8-sync-time {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.igny8-sync-button {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
background: var(--igny8-primary) !important;
|
||||
border-color: var(--igny8-primary) !important;
|
||||
color: white !important;
|
||||
font-weight: 500 !important;
|
||||
border-radius: 8px !important;
|
||||
transition: all 0.2s ease !important;
|
||||
}
|
||||
|
||||
.igny8-sync-button:hover:not(:disabled) {
|
||||
background: var(--igny8-primary-hover) !important;
|
||||
border-color: var(--igny8-primary-hover) !important;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
|
||||
}
|
||||
|
||||
.igny8-sync-button:disabled {
|
||||
opacity: 0.5 !important;
|
||||
cursor: not-allowed !important;
|
||||
}
|
||||
|
||||
.button-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Statistics Cards
|
||||
============================================ */
|
||||
|
||||
.igny8-stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 20px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.igny8-stat-card {
|
||||
background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
|
||||
border: 1px solid #E5E7EB;
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.igny8-stat-card:hover {
|
||||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.igny8-stat-icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.igny8-stat-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.igny8-stat-label {
|
||||
font-size: 12px;
|
||||
color: #6B7280;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
margin-bottom: 4px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.igny8-stat-value {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: #111827;
|
||||
line-height: 1.2;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.igny8-stat-meta {
|
||||
font-size: 12px;
|
||||
color: #9CA3AF;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Semantic Summary
|
||||
============================================ */
|
||||
|
||||
.igny8-semantic-summary {
|
||||
margin-top: 24px;
|
||||
padding: 20px;
|
||||
background: linear-gradient(135deg, #F3E8FF 0%, #E9D5FF 100%);
|
||||
border-radius: 12px;
|
||||
border: 1px solid #D8B4FE;
|
||||
}
|
||||
|
||||
.igny8-semantic-summary h3 {
|
||||
margin: 0 0 16px 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #6B21A8;
|
||||
}
|
||||
|
||||
.igny8-semantic-stats {
|
||||
display: flex;
|
||||
gap: 32px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.igny8-semantic-stat {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.igny8-semantic-stat .value {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: #7C3AED;
|
||||
}
|
||||
|
||||
.igny8-semantic-stat .label {
|
||||
font-size: 12px;
|
||||
color: #8B5CF6;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Status Indicators
|
||||
============================================ */
|
||||
|
||||
.igny8-status-connected {
|
||||
color: var(--igny8-success);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.igny8-status-disconnected {
|
||||
color: var(--igny8-error);
|
||||
font-weight: 600;
|
||||
}
|
||||
/* ============================================
|
||||
API Connection Form
|
||||
============================================ */
|
||||
|
||||
.igny8-api-connection-form {
|
||||
background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
|
||||
border: 2px solid #E5E7EB;
|
||||
border-radius: 12px;
|
||||
padding: 32px;
|
||||
margin: 0 0 24px 0;
|
||||
}
|
||||
|
||||
.igny8-api-form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.igny8-api-form-group label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 600;
|
||||
color: #111827;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.igny8-api-form-group input[type="text"],
|
||||
.igny8-api-form-group input[type="password"] {
|
||||
width: 100%;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #D1D5DB;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
transition: all 0.2s ease;
|
||||
font-family: 'Courier New', monospace;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.igny8-api-form-group input[type="text"]:focus,
|
||||
.igny8-api-form-group input[type="password"]:focus {
|
||||
outline: none;
|
||||
border-color: var(--igny8-primary);
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
||||
}
|
||||
|
||||
.igny8-api-form-group input[type="text"]:disabled {
|
||||
background-color: #F3F4F6;
|
||||
color: #9CA3AF;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.igny8-api-form-description {
|
||||
font-size: 13px;
|
||||
color: #6B7280;
|
||||
margin-top: 6px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.igny8-api-form-description a {
|
||||
color: var(--igny8-primary);
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.igny8-api-form-description a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.igny8-connection-actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.igny8-connection-actions .button {
|
||||
border-radius: 8px;
|
||||
padding: 10px 20px;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.igny8-connection-actions .button-primary {
|
||||
background: var(--igny8-primary) !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.igny8-connection-actions .button-primary:hover {
|
||||
background: var(--igny8-primary-hover) !important;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
|
||||
}
|
||||
|
||||
.igny8-connection-actions .button-secondary {
|
||||
background: #E5E7EB !important;
|
||||
color: #111827 !important;
|
||||
}
|
||||
|
||||
.igny8-connection-actions .button-secondary:hover {
|
||||
background: #D1D5DB !important;
|
||||
}
|
||||
|
||||
.igny8-connection-status-display {
|
||||
padding: 20px;
|
||||
background: linear-gradient(135deg, #F9FAFB 0%, #F3F4F6 100%);
|
||||
border: 1px solid #E5E7EB;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.igny8-connection-status-display .igny8-status-label {
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: #6B7280;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.igny8-connection-status-display .igny8-status-value {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.igny8-status-indicator {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.igny8-status-indicator.connected {
|
||||
background-color: var(--igny8-success);
|
||||
}
|
||||
|
||||
.igny8-status-indicator.disconnected {
|
||||
background-color: var(--igny8-gray);
|
||||
}
|
||||
|
||||
.igny8-api-key-display {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
background-color: #F3F4F6;
|
||||
border-radius: 8px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.igny8-api-key-mask {
|
||||
font-family: 'Courier New', monospace;
|
||||
color: #6B7280;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Diagnostics
|
||||
============================================ */
|
||||
|
||||
.igny8-diagnostics-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
gap: 16px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.igny8-diagnostic-item {
|
||||
padding: 16px;
|
||||
background: linear-gradient(135deg, #F9FAFB 0%, #F3F4F6 100%);
|
||||
border: 1px solid #E5E7EB;
|
||||
border-radius: 8px;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.igny8-diagnostic-item:hover {
|
||||
border-color: var(--igny8-primary);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.igny8-diagnostic-label {
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: #6B7280;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.igny8-diagnostic-value {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
.igny8-diagnostic-item .description {
|
||||
margin: 6px 0 0;
|
||||
color: #9CA3AF;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Sync Status Messages
|
||||
============================================ */
|
||||
|
||||
.igny8-sync-status {
|
||||
margin-top: 20px;
|
||||
padding: 16px;
|
||||
border-radius: 8px;
|
||||
display: none;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.igny8-sync-status.igny8-sync-status-success {
|
||||
background-color: #D1FAE5;
|
||||
border: 1px solid #6EE7B7;
|
||||
color: #065F46;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.igny8-sync-status.igny8-sync-status-error {
|
||||
background-color: #FEE2E2;
|
||||
border: 1px solid #FCA5A5;
|
||||
color: #991B1B;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.igny8-sync-status.igny8-sync-status-loading {
|
||||
background-color: #DBEAFE;
|
||||
border: 1px solid #93C5FD;
|
||||
color: #1E40AF;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Loading States
|
||||
============================================ */
|
||||
|
||||
.igny8-loading {
|
||||
opacity: 0.6;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@keyframes igny8-spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Messages & Notifications
|
||||
============================================ */
|
||||
|
||||
.igny8-message {
|
||||
padding: 16px;
|
||||
margin: 15px 0;
|
||||
border-left: 4px solid;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.igny8-message.igny8-message-success {
|
||||
border-color: var(--igny8-success);
|
||||
background-color: #F0FDF4;
|
||||
color: #065F46;
|
||||
}
|
||||
|
||||
.igny8-message.igny8-message-error {
|
||||
border-color: var(--igny8-error);
|
||||
background-color: #FEF2F2;
|
||||
color: #991B1B;
|
||||
}
|
||||
|
||||
.igny8-message.igny8-message-info {
|
||||
border-color: var(--igny8-primary);
|
||||
background-color: #EFF6FF;
|
||||
color: #1E40AF;
|
||||
}
|
||||
|
||||
.igny8-message.igny8-message-warning {
|
||||
border-color: var(--igny8-warning);
|
||||
background-color: #FFFBEB;
|
||||
color: #92400E;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
Responsive
|
||||
============================================ */
|
||||
|
||||
@media (max-width: 782px) {
|
||||
.igny8-sync-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.igny8-stats-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.igny8-diagnostics-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.igny8-settings-card {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.igny8-sync-card {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.igny8-stat-card {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
188
igy8-wp-plugin/admin/assets/js/admin.js
Normal file
188
igy8-wp-plugin/admin/assets/js/admin.js
Normal file
@@ -0,0 +1,188 @@
|
||||
/**
|
||||
* Admin JavaScript
|
||||
*
|
||||
* @package Igny8Bridge
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
$(document).ready(function() {
|
||||
// Test connection button
|
||||
$('#igny8-test-connection').on('click', function() {
|
||||
var $button = $(this);
|
||||
var $result = $('#igny8-test-result');
|
||||
|
||||
$button.prop('disabled', true).addClass('igny8-loading');
|
||||
$result.html('<span class="igny8-loading">Testing...</span>');
|
||||
|
||||
$.ajax({
|
||||
url: igny8Admin.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'igny8_test_connection',
|
||||
nonce: igny8Admin.nonce
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$result.html('<span class="igny8-success">✓ ' + (response.data.message || 'Connection successful') + '</span>');
|
||||
} else {
|
||||
var errorMsg = response.data.message || 'Connection failed';
|
||||
var httpStatus = response.data.http_status || '';
|
||||
var fullMsg = errorMsg;
|
||||
if (httpStatus) {
|
||||
fullMsg += ' (HTTP ' + httpStatus + ')';
|
||||
}
|
||||
$result.html('<span class="igny8-error">✗ ' + fullMsg + '</span>');
|
||||
|
||||
// Log full error to console for debugging
|
||||
console.error('IGNY8 Connection Test Failed:', response.data);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
$result.html('<span class="igny8-error">✗ Request failed: ' + error + '</span>');
|
||||
console.error('IGNY8 AJAX Error:', xhr, status, error);
|
||||
},
|
||||
complete: function() {
|
||||
$button.prop('disabled', false).removeClass('igny8-loading');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Sync posts to IGNY8
|
||||
$('#igny8-sync-posts').on('click', function() {
|
||||
igny8TriggerSync('igny8_sync_posts', 'Syncing posts to IGNY8...');
|
||||
});
|
||||
|
||||
// Sync taxonomies
|
||||
$('#igny8-sync-taxonomies').on('click', function() {
|
||||
igny8TriggerSync('igny8_sync_taxonomies', 'Syncing taxonomies...');
|
||||
});
|
||||
|
||||
// Sync from IGNY8
|
||||
$('#igny8-sync-from-igny8').on('click', function() {
|
||||
igny8TriggerSync('igny8_sync_from_igny8', 'Syncing from IGNY8...');
|
||||
});
|
||||
|
||||
// Collect and send site data
|
||||
$('#igny8-collect-site-data').on('click', function() {
|
||||
igny8TriggerSync('igny8_collect_site_data', 'Collecting and sending site data...');
|
||||
});
|
||||
|
||||
// Load sync statistics
|
||||
igny8LoadStats();
|
||||
|
||||
// Handle row action links
|
||||
$(document).on('click', '.igny8-action-link', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var $link = $(this);
|
||||
var postId = $link.data('post-id');
|
||||
var action = $link.data('action');
|
||||
|
||||
if (!postId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm('Are you sure you want to ' + (action === 'send' ? 'send' : 'update') + ' this post to IGNY8?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$link.text('Processing...').prop('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: igny8Admin.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'igny8_send_to_igny8',
|
||||
post_id: postId,
|
||||
action_type: action,
|
||||
nonce: igny8Admin.nonce
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
alert(response.data.message || 'Success!');
|
||||
location.reload();
|
||||
} else {
|
||||
alert(response.data.message || 'Failed to send to IGNY8');
|
||||
$link.text(action === 'send' ? 'Send to IGNY8' : 'Update in IGNY8').prop('disabled', false);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert('Request failed');
|
||||
$link.text(action === 'send' ? 'Send to IGNY8' : 'Update in IGNY8').prop('disabled', false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Trigger sync operation
|
||||
*/
|
||||
function igny8TriggerSync(action, message) {
|
||||
var $status = $('#igny8-sync-status');
|
||||
var $button = $('#' + action.replace('igny8_', 'igny8-'));
|
||||
|
||||
$status.removeClass('igny8-sync-status-success igny8-sync-status-error')
|
||||
.addClass('igny8-sync-status-loading')
|
||||
.html('<span class="igny8-spinner"></span>' + message);
|
||||
|
||||
$button.prop('disabled', true).addClass('igny8-loading');
|
||||
|
||||
$.ajax({
|
||||
url: igny8Admin.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: action,
|
||||
nonce: igny8Admin.nonce
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$status.removeClass('igny8-sync-status-loading')
|
||||
.addClass('igny8-sync-status-success')
|
||||
.html('✓ ' + (response.data.message || 'Operation completed successfully'));
|
||||
|
||||
// Reload stats
|
||||
igny8LoadStats();
|
||||
} else {
|
||||
$status.removeClass('igny8-sync-status-loading')
|
||||
.addClass('igny8-sync-status-error')
|
||||
.html('✗ ' + (response.data.message || 'Operation failed'));
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$status.removeClass('igny8-sync-status-loading')
|
||||
.addClass('igny8-sync-status-error')
|
||||
.html('✗ Request failed');
|
||||
},
|
||||
complete: function() {
|
||||
$button.prop('disabled', false).removeClass('igny8-loading');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Load sync statistics
|
||||
*/
|
||||
function igny8LoadStats() {
|
||||
$.ajax({
|
||||
url: igny8Admin.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'igny8_get_stats',
|
||||
nonce: igny8Admin.nonce
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success && response.data) {
|
||||
if (response.data.synced_posts !== undefined) {
|
||||
$('#igny8-stat-posts').text(response.data.synced_posts);
|
||||
}
|
||||
if (response.data.last_sync) {
|
||||
$('#igny8-stat-last-sync').text(response.data.last_sync);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})(jQuery);
|
||||
|
||||
200
igy8-wp-plugin/admin/assets/js/post-editor.js
Normal file
200
igy8-wp-plugin/admin/assets/js/post-editor.js
Normal file
@@ -0,0 +1,200 @@
|
||||
/**
|
||||
* Post Editor JavaScript
|
||||
*
|
||||
* Handles AJAX interactions for Planner and Optimizer meta boxes
|
||||
*
|
||||
* @package Igny8Bridge
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
$(document).ready(function() {
|
||||
// Fetch Planner Brief
|
||||
$('#igny8-fetch-brief').on('click', function() {
|
||||
var $button = $(this);
|
||||
var $message = $('#igny8-planner-brief-message');
|
||||
var postId = $button.data('post-id');
|
||||
var taskId = $button.data('task-id');
|
||||
|
||||
$button.prop('disabled', true).text('Fetching...');
|
||||
$message.hide().removeClass('notice-success notice-error');
|
||||
|
||||
$.ajax({
|
||||
url: igny8PostEditor.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'igny8_fetch_planner_brief',
|
||||
nonce: igny8PostEditor.nonce,
|
||||
post_id: postId,
|
||||
task_id: taskId
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$message.addClass('notice notice-success inline')
|
||||
.html('<p>' + response.data.message + '</p>')
|
||||
.show();
|
||||
|
||||
// Reload page to show updated brief
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 1000);
|
||||
} else {
|
||||
$message.addClass('notice notice-error inline')
|
||||
.html('<p>' + (response.data.message || 'Failed to fetch brief') + '</p>')
|
||||
.show();
|
||||
$button.prop('disabled', false).text('Fetch Brief');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$message.addClass('notice notice-error inline')
|
||||
.html('<p>Request failed</p>')
|
||||
.show();
|
||||
$button.prop('disabled', false).text('Fetch Brief');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Refresh Planner Task
|
||||
$('#igny8-refresh-task').on('click', function() {
|
||||
var $button = $(this);
|
||||
var $message = $('#igny8-planner-brief-message');
|
||||
var postId = $button.data('post-id');
|
||||
var taskId = $button.data('task-id');
|
||||
|
||||
if (!confirm('Are you sure you want to request a refresh of this task from IGNY8 Planner?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$button.prop('disabled', true).text('Requesting...');
|
||||
$message.hide().removeClass('notice-success notice-error');
|
||||
|
||||
$.ajax({
|
||||
url: igny8PostEditor.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'igny8_refresh_planner_task',
|
||||
nonce: igny8PostEditor.nonce,
|
||||
post_id: postId,
|
||||
task_id: taskId
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$message.addClass('notice notice-success inline')
|
||||
.html('<p>' + response.data.message + '</p>')
|
||||
.show();
|
||||
} else {
|
||||
$message.addClass('notice notice-error inline')
|
||||
.html('<p>' + (response.data.message || 'Failed to request refresh') + '</p>')
|
||||
.show();
|
||||
}
|
||||
$button.prop('disabled', false).text('Request Refresh');
|
||||
},
|
||||
error: function() {
|
||||
$message.addClass('notice notice-error inline')
|
||||
.html('<p>Request failed</p>')
|
||||
.show();
|
||||
$button.prop('disabled', false).text('Request Refresh');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Create Optimizer Job
|
||||
$('#igny8-create-optimizer-job').on('click', function() {
|
||||
var $button = $(this);
|
||||
var $message = $('#igny8-optimizer-message');
|
||||
var postId = $button.data('post-id');
|
||||
var taskId = $button.data('task-id');
|
||||
|
||||
if (!confirm('Create a new optimizer job for this post?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$button.prop('disabled', true).text('Creating...');
|
||||
$message.hide().removeClass('notice-success notice-error');
|
||||
|
||||
$.ajax({
|
||||
url: igny8PostEditor.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'igny8_create_optimizer_job',
|
||||
nonce: igny8PostEditor.nonce,
|
||||
post_id: postId,
|
||||
task_id: taskId,
|
||||
job_type: 'audit',
|
||||
priority: 'normal'
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$message.addClass('notice notice-success inline')
|
||||
.html('<p>' + response.data.message + '</p>')
|
||||
.show();
|
||||
|
||||
// Reload page to show updated status
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 1000);
|
||||
} else {
|
||||
$message.addClass('notice notice-error inline')
|
||||
.html('<p>' + (response.data.message || 'Failed to create job') + '</p>')
|
||||
.show();
|
||||
$button.prop('disabled', false).text('Request Optimization');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$message.addClass('notice notice-error inline')
|
||||
.html('<p>Request failed</p>')
|
||||
.show();
|
||||
$button.prop('disabled', false).text('Request Optimization');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Check Optimizer Status
|
||||
$('#igny8-check-optimizer-status').on('click', function() {
|
||||
var $button = $(this);
|
||||
var $message = $('#igny8-optimizer-message');
|
||||
var postId = $button.data('post-id');
|
||||
var jobId = $button.data('job-id');
|
||||
|
||||
$button.prop('disabled', true).text('Checking...');
|
||||
$message.hide().removeClass('notice-success notice-error');
|
||||
|
||||
$.ajax({
|
||||
url: igny8PostEditor.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'igny8_get_optimizer_status',
|
||||
nonce: igny8PostEditor.nonce,
|
||||
post_id: postId,
|
||||
job_id: jobId
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$message.addClass('notice notice-success inline')
|
||||
.html('<p>Status: <strong>' + response.data.status + '</strong></p>')
|
||||
.show();
|
||||
|
||||
// Reload page to show updated status
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 1000);
|
||||
} else {
|
||||
$message.addClass('notice notice-error inline')
|
||||
.html('<p>' + (response.data.message || 'Failed to get status') + '</p>')
|
||||
.show();
|
||||
}
|
||||
$button.prop('disabled', false).text('Check Status');
|
||||
},
|
||||
error: function() {
|
||||
$message.addClass('notice notice-error inline')
|
||||
.html('<p>Request failed</p>')
|
||||
.show();
|
||||
$button.prop('disabled', false).text('Check Status');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
Reference in New Issue
Block a user