From 1e163e3e29227a02a53ba0844ef64d5e85f5dce6 Mon Sep 17 00:00:00 2001
From: Rama Priyanto
Date: Tue, 7 Apr 2026 16:53:35 +0700
Subject: [PATCH] new url websocket
---
app/dashboard/etle/page.tsx | 40 ++++++++++++++++++-------------------
components/socket.tsx | 4 ++--
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/app/dashboard/etle/page.tsx b/app/dashboard/etle/page.tsx
index c2a56cf..9db9aa5 100644
--- a/app/dashboard/etle/page.tsx
+++ b/app/dashboard/etle/page.tsx
@@ -18,18 +18,10 @@ import Image from "next/image"
import { useEffect, useState } from "react"
import { socket } from "@/components/socket"
-const dummy = [
- { url: "/sample-1.jpg" },
- { url: "/sample-2.jpg" },
- { url: "/sample-3.jpg" },
- { url: "/sample-4.jpg" },
- { url: "/sample-1.jpg" },
- { url: "/sample-2.jpg" },
- { url: "/sample-3.jpg" },
- { url: "/sample-4.jpg" },
- { url: "/sample-1.jpg" },
-]
-
+interface historyType {
+ img: string
+ plate: string
+}
const stream_dummy = [
"/app/static/uploads/ds1.mp4",
"/app/static/uploads/ds2.mp4",
@@ -43,7 +35,7 @@ export default function Etle() {
const [imageSrc, setImageSrc] = useState("")
const [plate, setPlate] = useState("")
const [confidence, setConfidence] = useState(null)
- const [history, setHistory] = useState([])
+ const [history, setHistory] = useState([])
const startDetection = (index: number) => {
const stream = stream_dummy[index]
@@ -69,7 +61,7 @@ export default function Etle() {
socket.on("video_frame", (data) => {
const thumb = `data:image/jpeg;base64,${data.frame}`
setImageSrc(thumb)
- setHistory((prev) => [thumb, ...prev].slice(0, 20))
+ // setHistory((prev) => [thumb, ...prev].slice(0, 20))
})
socket.on("plate_detected", (data) => {
@@ -77,7 +69,14 @@ export default function Etle() {
setConfidence(data.confidence ?? null)
const thumb = `data:image/jpeg;base64,${data.frame_thumb}`
- setHistory((prev) => [thumb, ...prev].slice(0, 20))
+ setHistory((prev) => {
+ // cek apakah plate sudah pernah ada
+ const exists = prev.some((item) => item.plate === data.plate_text)
+
+ if (exists) return prev // skip kalau duplicate
+
+ return [{ img: thumb, plate: data.plate_text }, ...prev]
+ })
})
// socket.on("detection_stopped", (data) => {
@@ -139,7 +138,7 @@ export default function Etle() {
-
+
@@ -152,19 +151,20 @@ export default function Etle() {
{history.map((item, index) => (
))}
- {history.map((img, index) => (
+ {/* {history.map((img, index) => (
-

+
- ))}
+ ))} */}
diff --git a/components/socket.tsx b/components/socket.tsx
index 39271ff..2b6c18d 100644
--- a/components/socket.tsx
+++ b/components/socket.tsx
@@ -1,7 +1,7 @@
import { io, Socket } from "socket.io-client"
-const URL = "https://plate.koronyo.online"
-// const URL = "http://kubik.koroniyo.online:7272/"
+// const URL = "https://plate.koronyo.online"
+const URL = "https://plate-mtx.koronyo.online/"
export const socket: Socket = io(URL, {
autoConnect: false,