Spaces:
Paused
Paused
Download src/app.service.ts from Rasyiq03/scheffin-api: direct link, hf CLI and curl.
- Browser
- Download file 3.7 kB
-
https://huggingface.co/spaces/Rasyiq03/scheffin-api/resolve/main/src/app.service.ts
- Command line
-
hf download hf://spaces/Rasyiq03/scheffin-api/src/app.service.ts
-
curl -L -o app.service.ts https://huggingface.co/spaces/Rasyiq03/scheffin-api/resolve/main/src/app.service.ts
3.7 kB
| import { Injectable } from '@nestjs/common'; | |
| () | |
| export class AppService { | |
| getHello(): string { | |
| return `<!doctype html> | |
| <html lang="id"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <title>Dashboard - Daftar Grup</title> | |
| <style> | |
| body{font-family:Segoe UI, Roboto, Helvetica, Arial, sans-serif;max-width:1100px;margin:24px auto;padding:0 16px;color:#222} | |
| h1{font-size:24px;margin-bottom:8px} | |
| .card{background:#fff;border:1px solid #e6e6e6;padding:16px;border-radius:8px;box-shadow:0 1px 2px rgba(0,0,0,0.03)} | |
| table{width:100%;border-collapse:collapse;margin-top:12px} | |
| th,td{padding:8px;border-bottom:1px solid #eee;text-align:left} | |
| th{background:#fafafa} | |
| .small{font-size:13px;color:#666} | |
| button{padding:6px 10px;border:none;border-radius:6px;background:#0069ff;color:#fff;cursor:pointer} | |
| </style> | |
| </head> | |
| <body> | |
| <h1>Dashboard — Daftar Grup & ID</h1> | |
| <div class="card"> | |
| <div class="small">Halaman ini otomatis memuat daftar grup yang terhubung pada sesi WhatsApp.</div> | |
| <div id="status" class="small" style="margin-top:8px">Memuat...</div> | |
| <table id="groupsTable" style="display:none"> | |
| <thead> | |
| <tr><th>Nama Grup</th><th>JID / ID</th><th>Peserta</th><th>Aksi</th></tr> | |
| </thead> | |
| <tbody id="groupsBody"></tbody> | |
| </table> | |
| </div> | |
| <script> | |
| const statusEl = document.getElementById('status'); | |
| const table = document.getElementById('groupsTable'); | |
| const body = document.getElementById('groupsBody'); | |
| function renderGroups(groups){ | |
| body.innerHTML = ''; | |
| if(!groups || !groups.length){ | |
| statusEl.textContent = 'Tidak ada grup ditemukan.'; | |
| table.style.display = 'none'; | |
| return; | |
| } | |
| for(const g of groups){ | |
| const tr = document.createElement('tr'); | |
| const nameTd = document.createElement('td'); nameTd.textContent = g.name || '-'; | |
| const jidTd = document.createElement('td'); jidTd.textContent = g.jid || g.id || '-'; | |
| const pTd = document.createElement('td'); pTd.textContent = (g.participants || g.participants?.length || 0).toString(); | |
| const aTd = document.createElement('td'); | |
| const copyBtn = document.createElement('button'); copyBtn.textContent = 'Salin ID'; | |
| copyBtn.addEventListener('click', async ()=>{ try{ await navigator.clipboard.writeText(jidTd.textContent); alert('ID disalin'); }catch(e){ alert('Gagal menyalin'); }}); | |
| aTd.appendChild(copyBtn); | |
| tr.appendChild(nameTd); tr.appendChild(jidTd); tr.appendChild(pTd); tr.appendChild(aTd); | |
| body.appendChild(tr); | |
| } | |
| statusEl.textContent = 'Menampilkan ' + groups.length + ' grup.'; | |
| table.style.display = ''; | |
| } | |
| async function loadGroups(){ | |
| try{ | |
| statusEl.textContent = 'Mengambil grup dari server...'; | |
| const res = await fetch('/get/groups'); | |
| if(!res.ok) throw new Error('Server returned ' + res.status); | |
| const payload = await res.json(); | |
| if(payload && (payload.data || payload.status)){ | |
| const list = payload.data || payload; | |
| renderGroups(list); | |
| } else { | |
| statusEl.textContent = 'Respons server tidak seperti yang diharapkan.'; | |
| } | |
| }catch(err){ | |
| statusEl.textContent = 'Gagal memuat grup: ' + (err.message || err); | |
| } | |
| } | |
| // muat saat halaman siap | |
| window.addEventListener('load', ()=>{ | |
| loadGroups(); | |
| }); | |
| </script> | |
| </body> | |
| </html>`; | |
| } | |
| } | |