CiEL7 commited on
Commit
7bcacf2
·
verified ·
1 Parent(s): 493fce1

Update plugins/index.ejs

Browse files
Files changed (1) hide show
  1. plugins/index.ejs +143 -141
plugins/index.ejs CHANGED
@@ -3,224 +3,226 @@
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>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>API Plugins Dashboard</title>
7
  <style>
8
  :root {
9
  --bg: #0d1117;
10
  --card-bg: #161b22;
11
  --text: #c9d1d9;
12
  --accent: #58a6ff;
13
+ --success: #238636;
14
  --border: #30363d;
15
+ --code-bg: #010409;
16
  }
17
 
18
+ body {
19
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
20
+ background: var(--bg);
21
+ color: var(--text);
22
+ padding: 40px;
23
  margin: 0;
 
24
  }
25
 
26
+ h1 {
27
+ margin-bottom: 30px;
28
+ text-align: center;
29
+ color: var(--accent);
 
 
 
 
 
30
  }
31
 
32
+ .grid {
33
+ display: grid;
34
+ grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
35
+ gap: 25px;
36
+ max-width: 1200px;
37
+ margin: 0 auto;
38
  }
39
 
40
+ .card {
41
+ background: var(--card-bg);
42
+ padding: 24px;
43
+ border-radius: 12px;
44
+ border: 1px solid var(--border);
45
+ transition: transform 0.2s, border-color 0.2s;
46
  display: flex;
47
  flex-direction: column;
48
  }
49
 
50
+ .card:hover {
51
  border-color: var(--accent);
52
+ transform: translateY(-5px);
53
  }
54
 
55
+ .method-badge {
56
+ font-weight: bold;
57
+ color: var(--success);
58
+ background: rgba(35, 134, 54, 0.1);
59
  padding: 2px 8px;
60
+ border-radius: 6px;
61
+ font-size: 12px;
62
+ margin-right: 8px;
 
 
 
 
 
 
 
 
 
63
  }
64
 
65
+ .path {
66
+ color: var(--accent);
67
+ font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
68
  font-size: 14px;
 
 
 
69
  }
70
 
71
+ h3 { margin: 15px 0 10px 0; font-size: 1.2rem; }
72
+
73
+ small { color: #8b949e; margin-bottom: 20px; display: block; min-height: 40px; }
74
+
75
  .test-input {
76
  width: 100%;
77
+ background: var(--code-bg);
78
  border: 1px solid var(--border);
79
  color: white;
80
+ padding: 12px;
81
  border-radius: 6px;
82
+ margin-bottom: 12px;
83
  box-sizing: border-box;
84
  }
85
 
86
+ .btn-run {
87
  background: var(--success);
88
  color: white;
89
  border: none;
90
+ padding: 12px;
91
  border-radius: 6px;
92
  cursor: pointer;
93
  font-weight: bold;
94
  width: 100%;
95
+ transition: opacity 0.2s;
96
  }
97
 
98
+ .btn-run:hover { opacity: 0.9; }
 
 
99
 
100
+ .result-box {
101
+ margin-top: 20px;
102
+ background: var(--code-bg);
103
+ border-radius: 8px;
104
+ padding: 15px;
105
  display: none;
106
+ max-height: 400px;
107
  overflow-y: auto;
108
+ border: 1px solid var(--border);
109
  }
110
 
111
+ .status { font-size: 13px; margin-bottom: 10px; font-style: italic; }
112
+
113
+ pre {
114
+ font-size: 12px;
115
+ white-space: pre-wrap;
116
+ word-break: break-all;
117
  color: #d1d5da;
118
+ margin: 0;
119
  }
120
 
121
  .preview-img {
122
+ margin-top: 15px;
123
+ width: 100%;
124
+ border-radius: 8px;
125
  border: 1px solid var(--border);
126
  }
 
 
 
 
 
127
  </style>
128
  </head>
129
  <body>
130
+ <h1>API Plugins Dashboard</h1>
131
+
 
 
 
 
 
132
  <div class="grid">
133
  <% plugins.forEach((plugin, index) => { %>
134
  <div class="card">
135
  <div>
136
+ <span class="method-badge"><%= Array.isArray(plugin.method) ? plugin.method.join('/') : plugin.method %></span>
137
  <span class="path"><%= plugin.path %></span>
138
  </div>
139
 
140
+ <h3><%= plugin.name.toUpperCase().replace(/_/g, ' ') %></h3>
141
+ <small><%= plugin.description %></small>
142
+
143
+ <div class="form-container">
144
+ <% if (plugin.path.includes('ocr')) { %>
145
+ <input type="text" id="url-<%= index %>" class="test-input" placeholder="Paste image URL...">
146
+ <div style="text-align: center; margin: 5px 0; font-size: 11px; color: #8b949e;">OR</div>
147
+ <input type="file" id="file-<%= index %>" class="test-input" accept="image/*">
148
+ <% } else { %>
149
+ <input type="text" id="input-<%= index %>" class="test-input"
150
+ placeholder="<%= plugin.path.includes('bonsai') ? 'Tanya sesuatu...' : 'Masukkan prompt gambar...' %>">
151
+ <% } %>
152
 
153
+ <button class="btn-run" onclick="runTest('<%= plugin.path %>', <%= index %>)">Run Plugin</button>
154
  </div>
155
 
156
+ <div class="result-box" id="result-container-<%= index %>">
157
+ <div id="status-<%= index %>" class="status"></div>
158
  <pre id="json-<%= index %>"></pre>
159
  <div id="media-<%= index %>"></div>
160
  </div>
161
  </div>
162
  <% }) %>
163
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
+ <script>
166
+ async function runTest(path, id) {
167
+ const container = document.getElementById(`result-container-${id}`);
168
+ const status = document.getElementById(`status-${id}`);
169
+ const jsonPre = document.getElementById(`json-${id}`);
170
+ const media = document.getElementById(`media-${id}`);
171
+
172
+ // Reset UI
173
+ container.style.display = 'block';
174
+ status.innerHTML = '⏳ Processing...';
175
+ jsonPre.innerText = '';
176
+ media.innerHTML = '';
177
+
178
+ try {
179
+ let response;
180
+
181
+ // Logika khusus OCR (DeepSeek)
182
+ if (path.includes('ocr')) {
183
+ const urlVal = document.getElementById(`url-${id}`).value;
184
+ const fileInput = document.getElementById(`file-${id}`).files[0];
185
+
186
+ if (fileInput) {
187
+ // POST: Kirim file lokal
188
+ const formData = new FormData();
189
+ formData.append('file', fileInput);
190
+ response = await fetch(path, { method: 'POST', body: formData });
191
+ } else if (urlVal) {
192
+ // GET: Kirim URL gambar
193
+ response = await fetch(`${path}?image=${encodeURIComponent(urlVal)}`);
194
+ } else {
195
+ throw new Error("Pilih file atau masukkan URL gambar!");
196
+ }
197
+ }
198
+ // Logika untuk plugin lainnya
199
+ else {
200
+ const val = document.getElementById(`input-${id}`).value;
201
+ // Pilih param 'q' untuk bonsai/chat, 'prompt' untuk gen image
202
+ const param = (path.includes('bonsai') || path.includes('chat')) ? 'q' : 'prompt';
203
+ response = await fetch(`${path}?${param}=${encodeURIComponent(val)}`);
204
+ }
205
+
206
+ const data = await response.json();
207
+ status.innerHTML = response.ok ? '✅ Success' : '❌ Failed';
208
+ jsonPre.innerText = JSON.stringify(data, null, 2);
209
+
210
+ // Preview Gambar jika ada (Illustrious/NSFW)
211
+ const imgs = data.images || (data.result && Array.isArray(data.result) ? data.result : null);
212
+ if (imgs && Array.isArray(imgs)) {
213
+ imgs.forEach(url => {
214
+ const img = document.createElement('img');
215
+ img.src = url;
216
+ img.className = 'preview-img';
217
+ media.appendChild(img);
218
+ });
219
+ }
220
+
221
+ } catch (err) {
222
+ status.innerHTML = '❌ Error';
223
+ jsonPre.innerText = err.message;
224
+ }
225
  }
226
+ </script>
 
 
227
  </body>
228
  </html>