apis / plugins /index.ejs
CiEL7's picture
Update plugins/index.ejs
0f74ccc verified
Raw History Blame Contribute Delete
7.56 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API DASHBOARD — SWISS EDITION</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
/* Tipografi Khas Swiss Design */
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
letter-spacing: -0.02em;
}
.swiss-border {
border-top: 4px solid black;
}
</style>
</head>
<body class="bg-[#F0F0F0] text-black antialiased p-6 md:p-12">
<header class="max-w-7xl mx-auto mb-16 border-b-2 border-black pb-4">
<h1 class="text-6xl md:text-8xl font-black uppercase leading-none tracking-tighter">
System<br>Interface
</h1>
<div class="flex justify-between items-end mt-4">
<p class="text-sm font-bold uppercase tracking-widest">Automated API Management</p>
<p class="text-sm font-mono">v4.0.26</p>
</div>
</header>
<main class="max-w-7xl mx-auto">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-0 border-l border-t border-black">
<% plugins.forEach((plugin, index) => { %>
<div class="card bg-white p-8 border-r border-b border-black flex flex-col justify-between hover:bg-black hover:text-white transition-colors duration-300 group">
<div>
<div class="flex items-center space-x-2 mb-8">
<span class="bg-black text-white group-hover:bg-white group-hover:text-black px-2 py-0.5 text-[10px] font-bold uppercase tracking-tighter">
<%= Array.isArray(plugin.method) ? plugin.method.join('/') : plugin.method %>
</span>
<span class="text-[10px] font-mono opacity-60"><%= plugin.path %></span>
</div>
<h2 class="text-3xl font-bold uppercase leading-tight mb-4 tracking-tighter">
<%= plugin.name.replace(/_/g, ' ') %>
</h2>
<p class="text-sm leading-relaxed mb-12 opacity-80 min-h-[3rem]">
<%= plugin.description %>
</p>
</div>
<div class="space-y-4">
<% if (plugin.path.includes('ocr')) { %>
<div class="space-y-2">
<input type="text" id="url-<%= index %>"
class="w-full bg-transparent border-b-2 border-black group-hover:border-white py-2 px-1 text-sm focus:outline-none placeholder:text-gray-400"
placeholder="PASTE IMAGE URL">
<div class="text-[10px] font-bold text-center">OR</div>
<label class="block cursor-pointer border-2 border-dashed border-black group-hover:border-white p-4 text-center text-[10px] font-black uppercase">
Upload Local File
<input type="file" id="file-<%= index %>" class="hidden" accept="image/*">
</label>
</div>
<% } else { %>
<input type="text" id="input-<%= index %>"
class="w-full bg-transparent border-b-2 border-black group-hover:border-white py-2 px-1 text-sm focus:outline-none placeholder:text-gray-400"
placeholder="<%= plugin.path.includes('bonsai') ? 'ASK SOMETHING...' : 'ENTER PROMPT...' %>">
<% } %>
<button onclick="runTest('<%= plugin.path %>', <%= index %>)"
class="w-full bg-black text-white group-hover:bg-white group-hover:text-black py-4 text-xs font-black uppercase tracking-[0.2em] transition-transform active:scale-95">
Execute Module
</button>
</div>
<div id="result-container-<%= index %>" class="hidden mt-8 pt-8 border-t border-black group-hover:border-white">
<div id="status-<%= index %>" class="text-[10px] font-bold uppercase mb-4 tracking-widest"></div>
<div id="media-<%= index %>" class="mb-4"></div>
<pre id="json-<%= index %>" class="text-[10px] font-mono overflow-x-auto p-4 bg-gray-100 text-black"></pre>
</div>
</div>
<% }) %>
</div>
</main>
<footer class="max-w-7xl mx-auto mt-24 border-t-4 border-black pt-4 flex justify-between text-[10px] font-black uppercase tracking-widest">
<span>RIEL AFRONIA AUGUSTUS</span>
<span>JAKARTA / 2026</span>
</footer>
<script>
async function runTest(path, id) {
const container = document.getElementById(`result-container-${id}`);
const status = document.getElementById(`status-${id}`);
const jsonPre = document.getElementById(`json-${id}`);
const media = document.getElementById(`media-${id}`);
container.classList.remove('hidden');
status.innerHTML = '⏳ LOADING_DATA...';
jsonPre.innerText = '';
media.innerHTML = '';
try {
let response;
if (path.includes('ocr')) {
const urlVal = document.getElementById(`url-${id}`).value;
const fileInput = document.getElementById(`file-${id}`).files[0];
if (fileInput) {
const formData = new FormData();
formData.append('file', fileInput);
response = await fetch(path, { method: 'POST', body: formData });
} else if (urlVal) {
response = await fetch(`${path}?image=${encodeURIComponent(urlVal)}`);
} else {
throw new Error("INPUT_REQUIRED: URL_OR_FILE");
}
} else {
const val = document.getElementById(`input-${id}`).value;
const param = (path.includes('bonsai') || path.includes('chat')) ? 'q' : 'prompt';
response = await fetch(`${path}?${param}=${encodeURIComponent(val)}`);
}
const data = await response.json();
status.innerHTML = response.ok ? '✅ STATUS_OK' : '❌ STATUS_FAILED';
jsonPre.innerText = JSON.stringify(data, null, 2);
const imgs = data.images || (data.result && Array.isArray(data.result) ? data.result : null);
if (imgs && Array.isArray(imgs)) {
imgs.forEach(url => {
const img = document.createElement('img');
img.src = url;
img.className = 'w-full grayscale hover:grayscale-0 transition-all duration-500 border border-black mb-2';
media.appendChild(img);
});
}
} catch (err) {
status.innerHTML = '❌ SYSTEM_ERROR';
jsonPre.innerText = err.message;
}
}
</script>
</body>
</html>