Initial geladen: WP App Portal
This commit is contained in:
@@ -0,0 +1,841 @@
|
||||
/* Royal MCP Admin Styles */
|
||||
|
||||
.royal-mcp-settings .royal-mcp-settings-container {
|
||||
max-width: 1200px;
|
||||
}
|
||||
|
||||
.royal-mcp-settings .postbox {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.royal-mcp-settings .postbox-header h2 {
|
||||
margin: 0;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.royal-mcp-settings .inside {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
/* Toggle Switch */
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 50px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.switch.small {
|
||||
width: 40px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
transition: .4s;
|
||||
border-radius: 24px;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
left: 3px;
|
||||
bottom: 3px;
|
||||
background-color: white;
|
||||
transition: .4s;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.switch.small .slider:before {
|
||||
height: 14px;
|
||||
width: 14px;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
background-color: #2271b1;
|
||||
}
|
||||
|
||||
input:focus + .slider {
|
||||
box-shadow: 0 0 1px #2271b1;
|
||||
}
|
||||
|
||||
input:checked + .slider:before {
|
||||
transform: translateX(26px);
|
||||
}
|
||||
|
||||
.switch.small input:checked + .slider:before {
|
||||
transform: translateX(20px);
|
||||
}
|
||||
|
||||
/* ==========================================
|
||||
Platform Items
|
||||
========================================== */
|
||||
|
||||
#platforms-list {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.platform-item {
|
||||
background: #fff;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 15px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
|
||||
transition: box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.platform-item:hover {
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.platform-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 15px 20px;
|
||||
background: #fafafa;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.platform-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.platform-icon {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.platform-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.platform-name {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #1d2327;
|
||||
}
|
||||
|
||||
.platform-description {
|
||||
font-size: 13px;
|
||||
color: #646970;
|
||||
}
|
||||
|
||||
.platform-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.platform-actions .button {
|
||||
padding: 4px 8px;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
.platform-actions .button .dashicons {
|
||||
font-size: 18px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.platform-toggle .dashicons {
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.remove-platform:hover {
|
||||
color: #d63638;
|
||||
border-color: #d63638;
|
||||
}
|
||||
|
||||
.platform-config {
|
||||
padding: 20px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.platform-fields {
|
||||
margin: 0 0 20px 0;
|
||||
}
|
||||
|
||||
.platform-fields th {
|
||||
width: 180px;
|
||||
padding: 12px 10px 12px 0;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.platform-fields td {
|
||||
padding: 12px 10px 12px 0;
|
||||
}
|
||||
|
||||
.platform-fields .required {
|
||||
color: #d63638;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.platform-fields input[type="text"],
|
||||
.platform-fields input[type="password"],
|
||||
.platform-fields input[type="url"],
|
||||
.platform-fields select {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.platform-fields .toggle-password {
|
||||
margin-left: 5px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.platform-fields .toggle-password .dashicons {
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.platform-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-top: 15px;
|
||||
border-top: 1px solid #eee;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.platform-links {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.platform-links .button-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
text-decoration: none;
|
||||
color: #2271b1;
|
||||
}
|
||||
|
||||
.platform-links .button-link:hover {
|
||||
color: #135e96;
|
||||
}
|
||||
|
||||
.platform-links .dashicons {
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.platform-test {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.test-connection {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.test-connection .dashicons {
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.test-connection .dashicons.spin {
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.connection-status {
|
||||
font-size: 13px;
|
||||
padding: 4px 10px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.connection-status.success {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.connection-status.error {
|
||||
background: #f8d7da;
|
||||
color: #721c24;
|
||||
}
|
||||
|
||||
/* Empty State */
|
||||
.platform-empty-state {
|
||||
text-align: center;
|
||||
padding: 40px 20px;
|
||||
background: #f9f9f9;
|
||||
border: 2px dashed #ddd;
|
||||
border-radius: 8px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.platform-empty-state .empty-icon {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.platform-empty-state .empty-icon .dashicons {
|
||||
font-size: 48px;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
color: #c3c4c7;
|
||||
}
|
||||
|
||||
.platform-empty-state h3 {
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 18px;
|
||||
color: #1d2327;
|
||||
}
|
||||
|
||||
.platform-empty-state p {
|
||||
margin: 0;
|
||||
color: #646970;
|
||||
}
|
||||
|
||||
/* Add Platform Section */
|
||||
.add-platform-section {
|
||||
margin-top: 20px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
.add-platform-dropdown {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#add-platform-select {
|
||||
min-width: 280px;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
#add-platform-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
#add-platform-btn .dashicons {
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
/* ==========================================
|
||||
Legacy MCP Servers (Backward Compatibility)
|
||||
========================================== */
|
||||
|
||||
#mcp-servers-list {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.mcp-server-item {
|
||||
background: #f9f9f9;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
padding: 15px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.mcp-server-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.mcp-server-header h3 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.mcp-server-item .form-table {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.mcp-server-item .form-table th {
|
||||
width: 200px;
|
||||
padding: 10px 10px 10px 0;
|
||||
}
|
||||
|
||||
.mcp-server-item .form-table td {
|
||||
padding: 10px 10px 10px 0;
|
||||
}
|
||||
|
||||
#add-server {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* ==========================================
|
||||
API Endpoints Reference
|
||||
========================================== */
|
||||
|
||||
.api-endpoints-reference h3 {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.api-endpoints-reference h3:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.api-endpoints-reference ul {
|
||||
list-style: none;
|
||||
padding-left: 0;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.api-endpoints-reference li {
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.api-endpoints-reference li:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.api-endpoints-reference code {
|
||||
background: #f0f0f0;
|
||||
padding: 3px 8px;
|
||||
border-radius: 3px;
|
||||
font-size: 13px;
|
||||
color: #c7254e;
|
||||
min-width: 180px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* ==========================================
|
||||
Logs Page
|
||||
========================================== */
|
||||
|
||||
.royal-mcp-logs .column-timestamp {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.royal-mcp-logs .column-server {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.royal-mcp-logs .column-action {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.royal-mcp-logs .column-status {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.royal-mcp-logs .column-details {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
display: inline-block;
|
||||
padding: 4px 10px;
|
||||
border-radius: 3px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.status-badge.status-success {
|
||||
background-color: #d4edda;
|
||||
color: #155724;
|
||||
border: 1px solid #c3e6cb;
|
||||
}
|
||||
|
||||
.status-badge.status-error {
|
||||
background-color: #f8d7da;
|
||||
color: #721c24;
|
||||
border: 1px solid #f5c6cb;
|
||||
}
|
||||
|
||||
/* Log Details Modal */
|
||||
.log-modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 100000;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
background-color: rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.log-modal-content {
|
||||
background-color: #fefefe;
|
||||
margin: 5% auto;
|
||||
padding: 20px;
|
||||
border: 1px solid #888;
|
||||
width: 80%;
|
||||
max-width: 900px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.log-modal-close {
|
||||
color: #aaa;
|
||||
float: right;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.log-modal-close:hover,
|
||||
.log-modal-close:focus {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.log-details-container h3 {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.log-details-container pre {
|
||||
background: #f5f5f5;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
padding: 15px;
|
||||
overflow-x: auto;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* ==========================================
|
||||
Responsive Styles
|
||||
========================================== */
|
||||
|
||||
@media screen and (max-width: 782px) {
|
||||
.platform-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.platform-info {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.platform-actions {
|
||||
width: 100%;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.platform-footer {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.platform-links {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.platform-fields th {
|
||||
width: 100%;
|
||||
display: block;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.platform-fields td {
|
||||
display: block;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.add-platform-dropdown {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
#add-platform-select {
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.mcp-server-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.mcp-server-header .button {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.api-endpoints-reference li {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.api-endpoints-reference code {
|
||||
min-width: auto;
|
||||
}
|
||||
|
||||
.log-modal-content {
|
||||
width: 95%;
|
||||
margin: 10% auto;
|
||||
}
|
||||
}
|
||||
|
||||
/* ==========================================
|
||||
Utility Classes
|
||||
========================================== */
|
||||
|
||||
.code {
|
||||
font-family: Consolas, Monaco, monospace;
|
||||
}
|
||||
|
||||
.regular-text {
|
||||
width: 25em;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-style: italic;
|
||||
color: #646970;
|
||||
}
|
||||
|
||||
.required {
|
||||
color: #d63638;
|
||||
}
|
||||
|
||||
/* ==========================================
|
||||
Claude Connector Settings
|
||||
========================================== */
|
||||
|
||||
.connector-settings-box {
|
||||
border-left: 4px solid #6B4C9A;
|
||||
}
|
||||
|
||||
.connector-settings-box .postbox-header h2 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.connector-settings-box .beta-badge {
|
||||
background: #6B4C9A;
|
||||
color: #fff;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
padding: 2px 8px;
|
||||
border-radius: 10px;
|
||||
margin-left: 10px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.connector-intro {
|
||||
font-size: 14px;
|
||||
margin-bottom: 20px;
|
||||
font-style: normal !important;
|
||||
}
|
||||
|
||||
.connector-fields {
|
||||
background: #f9f9f9;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.connector-field {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.connector-field:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.connector-field > label {
|
||||
display: block;
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
color: #1d2327;
|
||||
}
|
||||
|
||||
.connector-field .optional {
|
||||
font-weight: 400;
|
||||
color: #646970;
|
||||
}
|
||||
|
||||
.connector-input-group {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.connector-input-group input {
|
||||
flex: 1;
|
||||
min-width: 300px;
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
.connector-input-group .button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.connector-input-group .button .dashicons {
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.connector-advanced {
|
||||
margin-top: 15px;
|
||||
padding-top: 15px;
|
||||
border-top: 1px dashed #ddd;
|
||||
}
|
||||
|
||||
.toggle-advanced {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
color: #2271b1;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.toggle-advanced:hover {
|
||||
color: #135e96;
|
||||
}
|
||||
|
||||
.toggle-advanced .dashicons {
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.toggle-advanced.open .dashicons {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.advanced-fields {
|
||||
margin-top: 15px;
|
||||
padding: 15px;
|
||||
background: #fff;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.connector-help {
|
||||
background: #fff;
|
||||
border: 1px solid #c3c4c7;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.connector-help h4 {
|
||||
margin: 0 0 15px 0;
|
||||
font-size: 14px;
|
||||
color: #1d2327;
|
||||
}
|
||||
|
||||
.connector-help ol {
|
||||
margin: 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.connector-help li {
|
||||
margin-bottom: 8px;
|
||||
color: #50575e;
|
||||
}
|
||||
|
||||
.connector-help li:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.connector-help a {
|
||||
color: #2271b1;
|
||||
}
|
||||
|
||||
.copy-btn.copied {
|
||||
background: #00a32a;
|
||||
border-color: #00a32a;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.copy-btn.copied .dashicons {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* ==========================================
|
||||
Documentation Banner
|
||||
========================================== */
|
||||
|
||||
.royal-mcp-docs-banner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
background: #e7f3ff;
|
||||
border: 1px solid #c8e1ff;
|
||||
color: #1d2327;
|
||||
padding: 12px 20px;
|
||||
border-radius: 8px;
|
||||
margin: 15px 0 20px 0;
|
||||
}
|
||||
|
||||
.royal-mcp-docs-banner .dashicons {
|
||||
font-size: 24px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
color: #2271b1;
|
||||
}
|
||||
|
||||
.royal-mcp-docs-banner span {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.royal-mcp-docs-banner .button {
|
||||
margin-left: auto;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.royal-mcp-docs-banner .button .dashicons {
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Silence is golden.
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Silence is golden.
|
||||
@@ -0,0 +1,556 @@
|
||||
jQuery(document).ready(function($) {
|
||||
'use strict';
|
||||
|
||||
// Platform index counter
|
||||
let platformIndex = $('.platform-item').length;
|
||||
|
||||
// ==========================================
|
||||
// Copy Buttons
|
||||
// ==========================================
|
||||
|
||||
// Regenerate API key confirmation
|
||||
$('#rmcp-regenerate-key').on('click', function(e) {
|
||||
if (!confirm(royalMcp.strings.confirmRegenerate)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$('#copy-api-key').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
const apiKey = $('#api_key').val();
|
||||
copyToClipboard(apiKey);
|
||||
showNotice('API key copied to clipboard!');
|
||||
});
|
||||
|
||||
$('#copy-rest-url').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
const restUrl = $(this).prev('input').val();
|
||||
copyToClipboard(restUrl);
|
||||
showNotice('REST API URL copied to clipboard!');
|
||||
});
|
||||
|
||||
// Generic copy button handler
|
||||
$(document).on('click', '.copy-btn', function(e) {
|
||||
e.preventDefault();
|
||||
const targetId = $(this).data('target');
|
||||
const $input = $('#' + targetId);
|
||||
if ($input.length) {
|
||||
copyToClipboard($input.val());
|
||||
const $btn = $(this);
|
||||
$btn.addClass('copied');
|
||||
setTimeout(function() {
|
||||
$btn.removeClass('copied');
|
||||
}, 1500);
|
||||
showNotice('Copied to clipboard!');
|
||||
}
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// Connector Settings
|
||||
// ==========================================
|
||||
|
||||
// Toggle advanced settings
|
||||
$('.toggle-advanced').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
const $btn = $(this);
|
||||
const $fields = $btn.next('.advanced-fields');
|
||||
|
||||
$btn.toggleClass('open');
|
||||
$fields.slideToggle(200);
|
||||
});
|
||||
|
||||
// Generate OAuth credentials
|
||||
$(document).on('click', '.generate-oauth', function(e) {
|
||||
e.preventDefault();
|
||||
const field = $(this).data('field');
|
||||
const $input = $('#' + field);
|
||||
|
||||
// Generate a random string
|
||||
let value;
|
||||
if (field === 'oauth_client_id') {
|
||||
value = 'wp_' + generateRandomString(24);
|
||||
} else {
|
||||
value = generateRandomString(48);
|
||||
}
|
||||
|
||||
$input.val(value);
|
||||
$(this).hide();
|
||||
showNotice('OAuth ' + (field === 'oauth_client_id' ? 'Client ID' : 'Client Secret') + ' generated. Remember to save your settings!');
|
||||
});
|
||||
|
||||
function generateRandomString(length) {
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let result = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// Platform Management
|
||||
// ==========================================
|
||||
|
||||
// Add new platform
|
||||
$('#add-platform-btn').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
const platformId = $('#add-platform-select').val();
|
||||
|
||||
if (!platformId) {
|
||||
showNotice('Please select a platform first.', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
const platform = royalMcp.platforms[platformId];
|
||||
if (!platform) {
|
||||
showNotice('Invalid platform selected.', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove empty state if present
|
||||
$('.platform-empty-state').remove();
|
||||
|
||||
// Build the platform item HTML
|
||||
const html = buildPlatformItemHtml(platform, platformIndex);
|
||||
$('#platforms-list').append(html);
|
||||
|
||||
// Expand the newly added platform
|
||||
const $newItem = $('#platforms-list .platform-item').last();
|
||||
$newItem.find('.platform-config').slideDown();
|
||||
$newItem.find('.platform-toggle .dashicons')
|
||||
.removeClass('dashicons-arrow-down-alt2')
|
||||
.addClass('dashicons-arrow-up-alt2');
|
||||
|
||||
// Reset the dropdown
|
||||
$('#add-platform-select').val('');
|
||||
|
||||
// Increment index
|
||||
platformIndex++;
|
||||
|
||||
showNotice('Platform added! Configure it and save your changes.');
|
||||
|
||||
// Show Claude connector settings if Claude/Anthropic was added
|
||||
updateClaudeConnectorVisibility();
|
||||
});
|
||||
|
||||
// Toggle platform config visibility
|
||||
$(document).on('click', '.platform-toggle', function(e) {
|
||||
e.preventDefault();
|
||||
const $item = $(this).closest('.platform-item');
|
||||
const $config = $item.find('.platform-config');
|
||||
const $icon = $(this).find('.dashicons');
|
||||
|
||||
$config.slideToggle(200);
|
||||
$icon.toggleClass('dashicons-arrow-down-alt2 dashicons-arrow-up-alt2');
|
||||
});
|
||||
|
||||
// Remove platform
|
||||
$(document).on('click', '.remove-platform', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!confirm(royalMcp.strings.confirmRemove)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const $item = $(this).closest('.platform-item');
|
||||
$item.slideUp(200, function() {
|
||||
$(this).remove();
|
||||
|
||||
// Show empty state if no platforms left
|
||||
if ($('#platforms-list .platform-item').length === 0) {
|
||||
$('#platforms-list').html(`
|
||||
<div class="platform-empty-state">
|
||||
<div class="empty-icon">
|
||||
<span class="dashicons dashicons-cloud"></span>
|
||||
</div>
|
||||
<h3>No AI Platforms Configured</h3>
|
||||
<p>Add your first AI platform to get started.</p>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
// Hide Claude connector settings if Claude/Anthropic was removed
|
||||
updateClaudeConnectorVisibility();
|
||||
});
|
||||
});
|
||||
|
||||
// Toggle password visibility
|
||||
$(document).on('click', '.toggle-password', function(e) {
|
||||
e.preventDefault();
|
||||
const $btn = $(this);
|
||||
const $input = $btn.parent().find('input[type="password"], input[type="text"]').first();
|
||||
const $icon = $btn.find('.dashicons');
|
||||
|
||||
if ($input.length === 0) return;
|
||||
|
||||
if ($input.attr('type') === 'password') {
|
||||
$input.attr('type', 'text');
|
||||
$icon.removeClass('dashicons-visibility').addClass('dashicons-hidden');
|
||||
} else {
|
||||
$input.attr('type', 'password');
|
||||
$icon.removeClass('dashicons-hidden').addClass('dashicons-visibility');
|
||||
}
|
||||
});
|
||||
|
||||
// Test connection
|
||||
$(document).on('click', '.test-connection', function(e) {
|
||||
e.preventDefault();
|
||||
const $btn = $(this);
|
||||
const $item = $btn.closest('.platform-item');
|
||||
const $status = $item.find('.connection-status');
|
||||
const platformId = $item.data('platform');
|
||||
|
||||
// Collect config from form fields
|
||||
const config = {};
|
||||
$item.find('[data-field]').each(function() {
|
||||
const field = $(this).data('field');
|
||||
config[field] = $(this).val();
|
||||
});
|
||||
|
||||
// Show loading state
|
||||
$btn.prop('disabled', true);
|
||||
$btn.find('.dashicons').addClass('spin');
|
||||
$status.removeClass('success error').text(royalMcp.strings.testing);
|
||||
|
||||
// Make AJAX request
|
||||
$.ajax({
|
||||
url: royalMcp.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'royal_mcp_test_connection',
|
||||
nonce: royalMcp.nonce,
|
||||
platform: platformId,
|
||||
config: config
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$status.addClass('success').text(response.data.message);
|
||||
} else {
|
||||
$status.addClass('error').text(response.data.message);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$status.addClass('error').text('Connection test failed');
|
||||
},
|
||||
complete: function() {
|
||||
$btn.prop('disabled', false);
|
||||
$btn.find('.dashicons').removeClass('spin');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// Helper Functions
|
||||
// ==========================================
|
||||
|
||||
function buildPlatformItemHtml(platform, index) {
|
||||
const fieldsHtml = buildFieldsHtml(platform.fields, index);
|
||||
const iconLetter = platform.label.charAt(0);
|
||||
|
||||
let linksHtml = '';
|
||||
if (platform.api_key_url) {
|
||||
linksHtml += `
|
||||
<a href="${escapeHtml(platform.api_key_url)}" target="_blank" class="button button-link">
|
||||
<span class="dashicons dashicons-external"></span>
|
||||
${royalMcp.strings.getApiKey}
|
||||
</a>
|
||||
`;
|
||||
}
|
||||
if (platform.docs_url) {
|
||||
linksHtml += `
|
||||
<a href="${escapeHtml(platform.docs_url)}" target="_blank" class="button button-link">
|
||||
<span class="dashicons dashicons-book"></span>
|
||||
${royalMcp.strings.documentation}
|
||||
</a>
|
||||
`;
|
||||
}
|
||||
|
||||
return `
|
||||
<div class="platform-item" data-index="${index}" data-platform="${escapeHtml(platform.id)}">
|
||||
<div class="platform-header">
|
||||
<div class="platform-info">
|
||||
<span class="platform-icon" style="background-color: ${escapeHtml(platform.color)}">
|
||||
${escapeHtml(iconLetter)}
|
||||
</span>
|
||||
<div class="platform-details">
|
||||
<h3 class="platform-name">${escapeHtml(platform.label)}</h3>
|
||||
<span class="platform-description">${escapeHtml(platform.description)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="platform-actions">
|
||||
<label class="switch small">
|
||||
<input type="checkbox"
|
||||
name="royal_mcp_settings[platforms][${index}][enabled]"
|
||||
value="1"
|
||||
checked>
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
<button type="button" class="button platform-toggle">
|
||||
<span class="dashicons dashicons-arrow-up-alt2"></span>
|
||||
</button>
|
||||
<button type="button" class="button remove-platform">
|
||||
<span class="dashicons dashicons-trash"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="platform-config">
|
||||
<input type="hidden"
|
||||
name="royal_mcp_settings[platforms][${index}][platform]"
|
||||
value="${escapeHtml(platform.id)}">
|
||||
|
||||
<table class="form-table platform-fields">
|
||||
${fieldsHtml}
|
||||
</table>
|
||||
|
||||
<div class="platform-footer">
|
||||
<div class="platform-links">
|
||||
${linksHtml}
|
||||
</div>
|
||||
<div class="platform-test">
|
||||
<button type="button" class="button test-connection">
|
||||
<span class="dashicons dashicons-update"></span>
|
||||
${royalMcp.strings.testConnection}
|
||||
</button>
|
||||
<span class="connection-status"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function buildFieldsHtml(fields, index) {
|
||||
let html = '';
|
||||
|
||||
for (const [fieldId, field] of Object.entries(fields)) {
|
||||
const fieldName = `royal_mcp_settings[platforms][${index}][${fieldId}]`;
|
||||
const defaultValue = field.default || '';
|
||||
const placeholder = field.placeholder || '';
|
||||
const required = field.required ? '<span class="required">*</span>' : '';
|
||||
const helpText = field.help ? `<p class="description">${escapeHtml(field.help)}</p>` : '';
|
||||
|
||||
let inputHtml = '';
|
||||
|
||||
switch (field.type) {
|
||||
case 'select':
|
||||
let optionsHtml = '';
|
||||
for (const [value, label] of Object.entries(field.options)) {
|
||||
const selected = value === defaultValue ? 'selected' : '';
|
||||
optionsHtml += `<option value="${escapeHtml(value)}" ${selected}>${escapeHtml(label)}</option>`;
|
||||
}
|
||||
inputHtml = `
|
||||
<select
|
||||
name="${escapeHtml(fieldName)}"
|
||||
id="platform-${index}-${escapeHtml(fieldId)}"
|
||||
class="regular-text"
|
||||
data-field="${escapeHtml(fieldId)}"
|
||||
>${optionsHtml}</select>
|
||||
`;
|
||||
break;
|
||||
|
||||
case 'password':
|
||||
inputHtml = `
|
||||
<input
|
||||
type="password"
|
||||
name="${escapeHtml(fieldName)}"
|
||||
id="platform-${index}-${escapeHtml(fieldId)}"
|
||||
value=""
|
||||
class="regular-text"
|
||||
placeholder="${escapeHtml(placeholder)}"
|
||||
data-field="${escapeHtml(fieldId)}"
|
||||
autocomplete="new-password"
|
||||
>
|
||||
<button type="button" class="button toggle-password" title="Show/Hide">
|
||||
<span class="dashicons dashicons-visibility"></span>
|
||||
</button>
|
||||
`;
|
||||
break;
|
||||
|
||||
case 'url':
|
||||
inputHtml = `
|
||||
<input
|
||||
type="url"
|
||||
name="${escapeHtml(fieldName)}"
|
||||
id="platform-${index}-${escapeHtml(fieldId)}"
|
||||
value="${escapeHtml(defaultValue)}"
|
||||
class="regular-text"
|
||||
placeholder="${escapeHtml(placeholder)}"
|
||||
data-field="${escapeHtml(fieldId)}"
|
||||
>
|
||||
`;
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
default:
|
||||
inputHtml = `
|
||||
<input
|
||||
type="text"
|
||||
name="${escapeHtml(fieldName)}"
|
||||
id="platform-${index}-${escapeHtml(fieldId)}"
|
||||
value="${escapeHtml(defaultValue)}"
|
||||
class="regular-text"
|
||||
placeholder="${escapeHtml(placeholder)}"
|
||||
data-field="${escapeHtml(fieldId)}"
|
||||
>
|
||||
`;
|
||||
break;
|
||||
}
|
||||
|
||||
html += `
|
||||
<tr class="platform-field platform-field-${escapeHtml(fieldId)}">
|
||||
<th scope="row">
|
||||
<label for="platform-${index}-${escapeHtml(fieldId)}">
|
||||
${escapeHtml(field.label)}
|
||||
${required}
|
||||
</label>
|
||||
</th>
|
||||
<td>
|
||||
${inputHtml}
|
||||
${helpText}
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
function copyToClipboard(text) {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(text);
|
||||
} else {
|
||||
// Fallback for older browsers
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = text;
|
||||
textarea.style.position = 'fixed';
|
||||
textarea.style.opacity = 0;
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
}
|
||||
|
||||
function showNotice(message, type = 'success') {
|
||||
const noticeClass = type === 'error' ? 'notice-error' : 'notice-success';
|
||||
const notice = $('<div class="notice ' + noticeClass + ' is-dismissible"><p>' + escapeHtml(message) + '</p></div>');
|
||||
|
||||
$('.wrap h1').after(notice);
|
||||
|
||||
setTimeout(function() {
|
||||
notice.fadeOut(function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
function escapeHtml(text) {
|
||||
if (text === null || text === undefined) return '';
|
||||
const div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
function updateClaudeConnectorVisibility() {
|
||||
// Check if any platform is Claude
|
||||
let hasClaude = false;
|
||||
$('#platforms-list .platform-item').each(function() {
|
||||
if ($(this).data('platform') === 'claude') {
|
||||
hasClaude = true;
|
||||
return false; // break
|
||||
}
|
||||
});
|
||||
|
||||
// Show or hide the Claude connector settings section
|
||||
if (hasClaude) {
|
||||
$('#claude-connector-settings').slideDown(200);
|
||||
} else {
|
||||
$('#claude-connector-settings').slideUp(200);
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// Logs Page - View Details Modal
|
||||
// ==========================================
|
||||
|
||||
$('.view-log-details').on('click', function() {
|
||||
const requestData = $(this).data('request');
|
||||
const responseData = $(this).data('response');
|
||||
|
||||
try {
|
||||
const formattedRequest = JSON.stringify(JSON.parse(requestData), null, 2);
|
||||
$('#log-request-data').text(formattedRequest);
|
||||
} catch (e) {
|
||||
$('#log-request-data').text(requestData);
|
||||
}
|
||||
|
||||
try {
|
||||
const formattedResponse = JSON.stringify(JSON.parse(responseData), null, 2);
|
||||
$('#log-response-data').text(formattedResponse);
|
||||
} catch (e) {
|
||||
$('#log-response-data').text(responseData);
|
||||
}
|
||||
|
||||
$('#log-details-modal').fadeIn();
|
||||
});
|
||||
|
||||
// Close modal
|
||||
$('.log-modal-close').on('click', function() {
|
||||
$('#log-details-modal').fadeOut();
|
||||
});
|
||||
|
||||
// Close modal on outside click
|
||||
$(window).on('click', function(e) {
|
||||
if ($(e.target).is('#log-details-modal')) {
|
||||
$('#log-details-modal').fadeOut();
|
||||
}
|
||||
});
|
||||
|
||||
// Close modal on escape key
|
||||
$(document).on('keydown', function(e) {
|
||||
if (e.key === 'Escape' && $('#log-details-modal').is(':visible')) {
|
||||
$('#log-details-modal').fadeOut();
|
||||
}
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// Legacy MCP Server Support (for backward compatibility)
|
||||
// ==========================================
|
||||
|
||||
let serverIndex = $('#mcp-servers-list .mcp-server-item').length;
|
||||
|
||||
$('#add-server').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const template = $('#mcp-server-template').html();
|
||||
if (!template) return;
|
||||
|
||||
const newServer = template.replace(/__INDEX__/g, serverIndex);
|
||||
|
||||
$('#mcp-servers-list').append(newServer);
|
||||
updateServerNumbers();
|
||||
serverIndex++;
|
||||
});
|
||||
|
||||
$(document).on('click', '.remove-server', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if ($('#mcp-servers-list .mcp-server-item').length === 1) {
|
||||
showNotice('You must have at least one server configured.', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirm('Are you sure you want to remove this server?')) {
|
||||
$(this).closest('.mcp-server-item').remove();
|
||||
updateServerNumbers();
|
||||
}
|
||||
});
|
||||
|
||||
function updateServerNumbers() {
|
||||
$('#mcp-servers-list .mcp-server-item').each(function(index) {
|
||||
$(this).find('.server-number').text(index + 1);
|
||||
});
|
||||
}
|
||||
|
||||
updateServerNumbers();
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Silence is golden.
|
||||
Reference in New Issue
Block a user