CiEL7 commited on
Commit
6fee014
·
verified ·
1 Parent(s): 3850789

Update plugins/index.ejs

Browse files
Files changed (1) hide show
  1. plugins/index.ejs +225 -31
plugins/index.ejs CHANGED
@@ -1,32 +1,226 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>My API Dashboard</title>
7
- <style>
8
- body { font-family: sans-serif; background: #121212; color: #eee; padding: 40px; }
9
- .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
10
- .card { background: #1e1e1e; padding: 20px; border-radius: 12px; border: 1px solid #333; }
11
- .method { font-weight: bold; color: #00ff88; margin-right: 8px; }
12
- .path { color: #00bfff; font-family: monospace; }
13
- a { text-decoration: none; color: inherit; }
14
- .card:hover { border-color: #00bfff; }
15
- h1 { margin-bottom: 30px; }
16
- </style>
17
- </head>
18
- <body>
19
- <h1>API Plugins Dashboard</h1>
20
- <div class="grid">
21
- <% plugins.forEach(plugin => { %>
22
- <a href="<%= plugin.path %>" target="_blank">
23
- <div class="card">
24
- <h3><%= plugin.name.toUpperCase() %></h3>
25
- <p><span class="method"><%= plugin.method %></span> <span class="path"><%= plugin.path %></span></p>
26
- <small><%= plugin.description %></small>
27
- </div>
28
- </a>
29
- <% }) %>
30
- </div>
31
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>API Management Dashboard</title>
7
+ <style>
8
+ :root {
9
+ --bg: #0d1117;
10
+ --card-bg: #161b22;
11
+ --text: #c9d1d9;
12
+ --accent: #58a6ff;
13
+ --success: #3fb950;
14
+ --border: #30363d;
15
+ }
16
+
17
+ body {
18
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
19
+ background-color: var(--bg);
20
+ color: var(--text);
21
+ margin: 0;
22
+ padding: 20px;
23
+ }
24
+
25
+ .container {
26
+ max-width: 1200px;
27
+ margin: 0 auto;
28
+ }
29
+
30
+ header {
31
+ border-bottom: 1px solid var(--border);
32
+ margin-bottom: 30px;
33
+ padding-bottom: 10px;
34
+ }
35
+
36
+ .grid {
37
+ display: grid;
38
+ grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
39
+ gap: 20px;
40
+ }
41
+
42
+ .card {
43
+ background: var(--card-bg);
44
+ border: 1px solid var(--border);
45
+ border-radius: 8px;
46
+ padding: 20px;
47
+ display: flex;
48
+ flex-direction: column;
49
+ }
50
+
51
+ .card:hover {
52
+ border-color: var(--accent);
53
+ }
54
+
55
+ .badge {
56
+ font-size: 12px;
57
+ padding: 2px 8px;
58
+ border-radius: 12px;
59
+ font-weight: bold;
60
+ text-transform: uppercase;
61
+ background: rgba(88, 166, 255, 0.1);
62
+ color: var(--accent);
63
+ }
64
+
65
+ .path {
66
+ font-family: monospace;
67
+ color: #79c0ff;
68
+ display: block;
69
+ margin: 10px 0;
70
+ }
71
+
72
+ .description {
73
+ font-size: 14px;
74
+ color: #8b949e;
75
+ margin-bottom: 20px;
76
+ min-height: 40px;
77
+ }
78
+
79
+ .test-input {
80
+ width: 100%;
81
+ background: #0d1117;
82
+ border: 1px solid var(--border);
83
+ color: white;
84
+ padding: 10px;
85
+ border-radius: 6px;
86
+ margin-bottom: 10px;
87
+ box-sizing: border-box;
88
+ }
89
+
90
+ .btn-test {
91
+ background: var(--success);
92
+ color: white;
93
+ border: none;
94
+ padding: 10px;
95
+ border-radius: 6px;
96
+ cursor: pointer;
97
+ font-weight: bold;
98
+ width: 100%;
99
+ }
100
+
101
+ .btn-test:hover {
102
+ filter: brightness(1.1);
103
+ }
104
+
105
+ .result-container {
106
+ margin-top: 15px;
107
+ background: #010409;
108
+ border-radius: 6px;
109
+ padding: 10px;
110
+ display: none;
111
+ max-height: 300px;
112
+ overflow-y: auto;
113
+ border-left: 4px solid var(--accent);
114
+ }
115
+
116
+ pre {
117
+ font-size: 12px;
118
+ margin: 0;
119
+ white-space: pre-wrap;
120
+ word-break: break-all;
121
+ color: #d1d5da;
122
+ }
123
+
124
+ .preview-img {
125
+ margin-top: 10px;
126
+ max-width: 100%;
127
+ border-radius: 4px;
128
+ border: 1px solid var(--border);
129
+ }
130
+
131
+ .loading {
132
+ font-style: italic;
133
+ color: #8b949e;
134
+ }
135
+ </style>
136
+ </head>
137
+ <body>
138
+
139
+ <div class="container">
140
+ <header>
141
+ <h1>System API Dashboard</h1>
142
+ <p>Endpoint otomatis dari folder <code>/plugins</code></p>
143
+ </header>
144
+
145
+ <div class="grid">
146
+ <% plugins.forEach((plugin, index) => { %>
147
+ <div class="card">
148
+ <div>
149
+ <span class="badge"><%= plugin.method %></span>
150
+ <span class="path"><%= plugin.path %></span>
151
+ </div>
152
+
153
+ <h3><%= plugin.name.replace(/_/g, ' ') %></h3>
154
+ <p class="description"><%= plugin.description %></p>
155
+
156
+ <div class="test-form">
157
+ <input type="text"
158
+ id="input-<%= index %>"
159
+ class="test-input"
160
+ placeholder="<%= plugin.path.includes('ocr') ? 'Path/URL Gambar...' : 'Masukkan Prompt/Pertanyaan...' %>">
161
+
162
+ <button class="btn-test" onclick="executePlugin('<%= plugin.path %>', <%= index %>)">Run Plugin</button>
163
+ </div>
164
+
165
+ <div class="result-container" id="res-container-<%= index %>">
166
+ <div id="status-<%= index %>" class="loading"></div>
167
+ <pre id="json-<%= index %>"></pre>
168
+ <div id="media-<%= index %>"></div>
169
+ </div>
170
+ </div>
171
+ <% }) %>
172
+ </div>
173
+ </div>
174
+
175
+ <script>
176
+ async function executePlugin(path, id) {
177
+ const input = document.getElementById(`input-${id}`).value;
178
+ const container = document.getElementById(`res-container-${id}`);
179
+ const status = document.getElementById(`status-${id}`);
180
+ const jsonPre = document.getElementById(`json-${id}`);
181
+ const media = document.getElementById(`media-${id}`);
182
+
183
+ // Reset UI
184
+ container.style.display = 'block';
185
+ status.innerText = '🔄 Processing request...';
186
+ jsonPre.innerText = '';
187
+ media.innerHTML = '';
188
+
189
+ try {
190
+ // Logika penentuan query param
191
+ let param = 'prompt';
192
+ if (path.includes('bonsai') || path.includes('chat')) param = 'q';
193
+ if (path.includes('ocr')) param = 'image';
194
+
195
+ const response = await fetch(`${path}?${param}=${encodeURIComponent(input)}`);
196
+ const result = await response.json();
197
+
198
+ status.innerText = '✅ Completed';
199
+ jsonPre.innerText = JSON.stringify(result, null, 2);
200
+
201
+ // Render Gambar jika ada di response
202
+ const imageUrls = result.images || (result.result && Array.isArray(result.result) ? result.result : null);
203
+
204
+ if (imageUrls && Array.isArray(imageUrls)) {
205
+ imageUrls.forEach(url => {
206
+ const img = document.createElement('img');
207
+ img.src = url;
208
+ img.className = 'preview-img';
209
+ media.appendChild(img);
210
+ });
211
+ } else if (typeof result.result === 'string' && result.result.startsWith('http')) {
212
+ const img = document.createElement('img');
213
+ img.src = result.result;
214
+ img.className = 'preview-img';
215
+ media.appendChild(img);
216
+ }
217
+
218
+ } catch (err) {
219
+ status.innerText = '❌ Error';
220
+ jsonPre.innerText = err.message;
221
+ }
222
+ }
223
+ </script>
224
+
225
+ </body>
226
  </html>