Change logic Vite_api_dev

This commit is contained in:
hieupq 2025-12-09 18:59:37 +07:00
parent eb4243ee5b
commit b50dd91b7a
10 changed files with 62 additions and 40 deletions

View File

@ -1,6 +1,6 @@
upstream backend { upstream backend {
server 100.66.170.15:8080; server 100.66.170.15:8080;
server 127.0.0.1:5218; server 127.0.0.1:8080;
server 172.18.10.8:8080; server 172.18.10.8:8080;
} }
server { server {
@ -25,7 +25,7 @@ server {
} }
location /api/ { location /api/ {
proxy_pass http://backend/; proxy_pass http://100.66.170.15:8080;
# Cho phép upload file lớn (vd: 200MB) # Cho phép upload file lớn (vd: 200MB)
client_max_body_size 200M; client_max_body_size 200M;

26
package-lock.json generated
View File

@ -129,6 +129,7 @@
"version": "7.28.0", "version": "7.28.0",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.0.tgz", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.0.tgz",
"integrity": "sha512-UlLAnTPrFdNGoFtbSXwcGFQBtQZJCNjaN6hQNP3UPvuNXT1i82N26KL3dZeIpNalWywr9IuQuncaAfUaS1g6sQ==", "integrity": "sha512-UlLAnTPrFdNGoFtbSXwcGFQBtQZJCNjaN6hQNP3UPvuNXT1i82N26KL3dZeIpNalWywr9IuQuncaAfUaS1g6sQ==",
"peer": true,
"dependencies": { "dependencies": {
"@ampproject/remapping": "^2.2.0", "@ampproject/remapping": "^2.2.0",
"@babel/code-frame": "^7.27.1", "@babel/code-frame": "^7.27.1",
@ -658,6 +659,7 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=18" "node": ">=18"
}, },
@ -681,6 +683,7 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=18" "node": ">=18"
} }
@ -3254,6 +3257,7 @@
"version": "1.129.8", "version": "1.129.8",
"resolved": "https://registry.npmjs.org/@tanstack/react-router/-/react-router-1.129.8.tgz", "resolved": "https://registry.npmjs.org/@tanstack/react-router/-/react-router-1.129.8.tgz",
"integrity": "sha512-d5mfM+67h3wq7aHkLjRKXD1ddbzx1YuxaEbNvW45jjZXMgaikZSVfJrZBiUWXE/nhV1sTdbMQ48JcPagvGPmYQ==", "integrity": "sha512-d5mfM+67h3wq7aHkLjRKXD1ddbzx1YuxaEbNvW45jjZXMgaikZSVfJrZBiUWXE/nhV1sTdbMQ48JcPagvGPmYQ==",
"peer": true,
"dependencies": { "dependencies": {
"@tanstack/history": "1.129.7", "@tanstack/history": "1.129.7",
"@tanstack/react-store": "^0.7.0", "@tanstack/react-store": "^0.7.0",
@ -3334,6 +3338,7 @@
"version": "1.129.8", "version": "1.129.8",
"resolved": "https://registry.npmjs.org/@tanstack/router-core/-/router-core-1.129.8.tgz", "resolved": "https://registry.npmjs.org/@tanstack/router-core/-/router-core-1.129.8.tgz",
"integrity": "sha512-Izqf5q8TzJv0DJURynitJioPJT3dPAefrzHi2wlY/Q5+7nEG41SkjYMotTX2Q9i/Pjl91lW8gERCHpksszRdRw==", "integrity": "sha512-Izqf5q8TzJv0DJURynitJioPJT3dPAefrzHi2wlY/Q5+7nEG41SkjYMotTX2Q9i/Pjl91lW8gERCHpksszRdRw==",
"peer": true,
"dependencies": { "dependencies": {
"@tanstack/history": "1.129.7", "@tanstack/history": "1.129.7",
"@tanstack/store": "^0.7.0", "@tanstack/store": "^0.7.0",
@ -3539,6 +3544,7 @@
"integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==", "integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.10.4", "@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
@ -3691,6 +3697,7 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.1.0.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.1.0.tgz",
"integrity": "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==", "integrity": "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==",
"devOptional": true, "devOptional": true,
"peer": true,
"dependencies": { "dependencies": {
"undici-types": "~7.8.0" "undici-types": "~7.8.0"
} }
@ -3701,6 +3708,7 @@
"integrity": "sha512-AwAfQ2Wa5bCx9WP8nZL2uMZWod7J7/JSplxbTmBQ5ms6QpqNYm672H0Vu9ZVKVngQ+ii4R/byguVEUZQyeg44g==", "integrity": "sha512-AwAfQ2Wa5bCx9WP8nZL2uMZWod7J7/JSplxbTmBQ5ms6QpqNYm672H0Vu9ZVKVngQ+ii4R/byguVEUZQyeg44g==",
"devOptional": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"csstype": "^3.0.2" "csstype": "^3.0.2"
} }
@ -3711,6 +3719,7 @@
"integrity": "sha512-4hOiT/dwO8Ko0gV1m/TJZYk3y0KBnY9vzDh7W+DH17b2HFSOGgdj33dhihPeuy3l0q23+4e+hoXHV6hCC4dCXw==", "integrity": "sha512-4hOiT/dwO8Ko0gV1m/TJZYk3y0KBnY9vzDh7W+DH17b2HFSOGgdj33dhihPeuy3l0q23+4e+hoXHV6hCC4dCXw==",
"devOptional": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"peer": true,
"peerDependencies": { "peerDependencies": {
"@types/react": "^19.0.0" "@types/react": "^19.0.0"
} }
@ -4152,6 +4161,7 @@
"url": "https://github.com/sponsors/ai" "url": "https://github.com/sponsors/ai"
} }
], ],
"peer": true,
"dependencies": { "dependencies": {
"caniuse-lite": "^1.0.30001726", "caniuse-lite": "^1.0.30001726",
"electron-to-chromium": "^1.5.173", "electron-to-chromium": "^1.5.173",
@ -4591,7 +4601,8 @@
"node_modules/csstype": { "node_modules/csstype": {
"version": "3.1.3", "version": "3.1.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",
"peer": true
}, },
"node_modules/data-uri-to-buffer": { "node_modules/data-uri-to-buffer": {
"version": "4.0.1", "version": "4.0.1",
@ -4987,6 +4998,7 @@
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz",
"integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==",
"peer": true,
"dependencies": { "dependencies": {
"accepts": "^2.0.0", "accepts": "^2.0.0",
"body-parser": "^2.2.0", "body-parser": "^2.2.0",
@ -5718,6 +5730,7 @@
"integrity": "sha512-Cvc9WUhxSMEo4McES3P7oK3QaXldCfNWp7pl2NNeiIFlCoLr3kfq9kb1fxftiwk1FLV7CvpvDfonxtzUDeSOPg==", "integrity": "sha512-Cvc9WUhxSMEo4McES3P7oK3QaXldCfNWp7pl2NNeiIFlCoLr3kfq9kb1fxftiwk1FLV7CvpvDfonxtzUDeSOPg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"cssstyle": "^4.2.1", "cssstyle": "^4.2.1",
"data-urls": "^5.0.0", "data-urls": "^5.0.0",
@ -6801,6 +6814,7 @@
"version": "19.1.0", "version": "19.1.0",
"resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz", "resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz",
"integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==", "integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==",
"peer": true,
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
} }
@ -6809,6 +6823,7 @@
"version": "19.1.0", "version": "19.1.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz",
"integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==", "integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==",
"peer": true,
"dependencies": { "dependencies": {
"scheduler": "^0.26.0" "scheduler": "^0.26.0"
}, },
@ -7191,6 +7206,7 @@
"version": "1.3.2", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/seroval/-/seroval-1.3.2.tgz", "resolved": "https://registry.npmjs.org/seroval/-/seroval-1.3.2.tgz",
"integrity": "sha512-RbcPH1n5cfwKrru7v7+zrZvjLurgHhGyso3HTyGtRivGWgYjbOmGuivCQaORNELjNONoK35nj28EoWul9sb1zQ==", "integrity": "sha512-RbcPH1n5cfwKrru7v7+zrZvjLurgHhGyso3HTyGtRivGWgYjbOmGuivCQaORNELjNONoK35nj28EoWul9sb1zQ==",
"peer": true,
"engines": { "engines": {
"node": ">=10" "node": ">=10"
} }
@ -7649,7 +7665,8 @@
"node_modules/tiny-invariant": { "node_modules/tiny-invariant": {
"version": "1.3.3", "version": "1.3.3",
"resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz", "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz",
"integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==" "integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==",
"peer": true
}, },
"node_modules/tiny-warning": { "node_modules/tiny-warning": {
"version": "1.0.3", "version": "1.0.3",
@ -7705,6 +7722,7 @@
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=12" "node": ">=12"
}, },
@ -7892,6 +7910,7 @@
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
"devOptional": true, "devOptional": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"peer": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
@ -8072,6 +8091,7 @@
"version": "6.4.1", "version": "6.4.1",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.4.1.tgz", "resolved": "https://registry.npmjs.org/vite/-/vite-6.4.1.tgz",
"integrity": "sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g==", "integrity": "sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g==",
"peer": true,
"dependencies": { "dependencies": {
"esbuild": "^0.25.0", "esbuild": "^0.25.0",
"fdir": "^6.4.4", "fdir": "^6.4.4",
@ -8183,6 +8203,7 @@
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=12" "node": ">=12"
}, },
@ -8516,6 +8537,7 @@
"version": "3.25.76", "version": "3.25.76",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
"integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
"peer": true,
"funding": { "funding": {
"url": "https://github.com/sponsors/colinhacks" "url": "https://github.com/sponsors/colinhacks"
} }

View File

@ -8,7 +8,7 @@ import {
import { Home, Building, AppWindow, Terminal, CircleX } from "lucide-react"; import { Home, Building, AppWindow, Terminal, CircleX } from "lucide-react";
import { Toaster } from "@/components/ui/sonner"; import { Toaster } from "@/components/ui/sonner";
import { useQueryClient } from "@tanstack/react-query"; import { useQueryClient } from "@tanstack/react-query";
import { API_ENDPOINTS, BASE_URL } from "@/config/api"; import { API_ENDPOINTS } from "@/config/api";
import { Separator } from "@/components/ui/separator"; import { Separator } from "@/components/ui/separator";
type AppLayoutProps = { type AppLayoutProps = {
@ -22,7 +22,7 @@ export default function AppLayout({ children }: AppLayoutProps) {
queryClient.prefetchQuery({ queryClient.prefetchQuery({
queryKey: ["agent-version"], queryKey: ["agent-version"],
queryFn: () => queryFn: () =>
fetch(BASE_URL + API_ENDPOINTS.APP_VERSION.GET_VERSION).then((res) => fetch(API_ENDPOINTS.APP_VERSION.GET_VERSION).then((res) =>
res.json() res.json()
), ),
staleTime: 60 * 1000, staleTime: 60 * 1000,
@ -32,7 +32,7 @@ export default function AppLayout({ children }: AppLayoutProps) {
queryClient.prefetchQuery({ queryClient.prefetchQuery({
queryKey: ["software-version"], queryKey: ["software-version"],
queryFn: () => queryFn: () =>
fetch(BASE_URL + API_ENDPOINTS.APP_VERSION.GET_SOFTWARE).then((res) => fetch(API_ENDPOINTS.APP_VERSION.GET_SOFTWARE).then((res) =>
res.json() res.json()
), ),
staleTime: 60 * 1000, staleTime: 60 * 1000,
@ -43,7 +43,7 @@ export default function AppLayout({ children }: AppLayoutProps) {
queryClient.prefetchQuery({ queryClient.prefetchQuery({
queryKey: ["room-list"], queryKey: ["room-list"],
queryFn: () => queryFn: () =>
fetch(BASE_URL + API_ENDPOINTS.DEVICE_COMM.GET_ROOM_LIST).then((res) => fetch(API_ENDPOINTS.DEVICE_COMM.GET_ROOM_LIST).then((res) =>
res.json() res.json()
), ),
staleTime: 60 * 1000, staleTime: 60 * 1000,
@ -54,7 +54,7 @@ export default function AppLayout({ children }: AppLayoutProps) {
queryClient.prefetchQuery({ queryClient.prefetchQuery({
queryKey: ["blacklist"], queryKey: ["blacklist"],
queryFn: () => queryFn: () =>
fetch(BASE_URL + API_ENDPOINTS.APP_VERSION).then((res) => fetch(API_ENDPOINTS.APP_VERSION + "").then((res) =>
res.json() res.json()
), ),
staleTime: 60 * 1000, staleTime: 60 * 1000,

View File

@ -2,7 +2,7 @@ import { createFileRoute } from "@tanstack/react-router";
import { AppManagerTemplate } from "@/template/app-manager-template"; import { AppManagerTemplate } from "@/template/app-manager-template";
import { useQueryData } from "@/hooks/useQueryData"; import { useQueryData } from "@/hooks/useQueryData";
import { useMutationData } from "@/hooks/useMutationData"; import { useMutationData } from "@/hooks/useMutationData";
import { BASE_URL, API_ENDPOINTS } from "@/config/api"; import { API_ENDPOINTS } from "@/config/api";
import { toast } from "sonner"; import { toast } from "sonner";
import type { ColumnDef } from "@tanstack/react-table"; import type { ColumnDef } from "@tanstack/react-table";
import type { AxiosProgressEvent } from "axios"; import type { AxiosProgressEvent } from "axios";
@ -17,13 +17,13 @@ function AgentsPage() {
// Lấy danh sách version // Lấy danh sách version
const { data, isLoading } = useQueryData({ const { data, isLoading } = useQueryData({
queryKey: ["agent-version"], queryKey: ["agent-version"],
url: BASE_URL + API_ENDPOINTS.APP_VERSION.GET_VERSION, url: API_ENDPOINTS.APP_VERSION.GET_VERSION,
}); });
// Lấy danh sách phòng // Lấy danh sách phòng
const { data: roomData } = useQueryData({ const { data: roomData } = useQueryData({
queryKey: ["rooms"], queryKey: ["rooms"],
url: BASE_URL + API_ENDPOINTS.DEVICE_COMM.GET_ROOM_LIST, url: API_ENDPOINTS.DEVICE_COMM.GET_ROOM_LIST,
}); });
const versionList: Version[] = Array.isArray(data) const versionList: Version[] = Array.isArray(data)
@ -33,7 +33,7 @@ function AgentsPage() {
: []; : [];
const uploadMutation = useMutationData<FormData>({ const uploadMutation = useMutationData<FormData>({
url: BASE_URL + API_ENDPOINTS.APP_VERSION.UPLOAD, url: API_ENDPOINTS.APP_VERSION.UPLOAD,
method: "POST", method: "POST",
invalidate: [["agent-version"]], invalidate: [["agent-version"]],
onSuccess: () => toast.success("Upload thành công!"), onSuccess: () => toast.success("Upload thành công!"),
@ -67,7 +67,7 @@ function AgentsPage() {
try { try {
for (const roomName of roomNames) { for (const roomName of roomNames) {
await updateMutation.mutateAsync({ await updateMutation.mutateAsync({
url: BASE_URL + API_ENDPOINTS.DEVICE_COMM.UPDATE_AGENT(roomName), url: API_ENDPOINTS.DEVICE_COMM.UPDATE_AGENT(roomName),
method: "POST", method: "POST",
data: undefined data: undefined
}); });

View File

@ -2,7 +2,7 @@ import { createFileRoute } from "@tanstack/react-router";
import { AppManagerTemplate } from "@/template/app-manager-template"; import { AppManagerTemplate } from "@/template/app-manager-template";
import { useQueryData } from "@/hooks/useQueryData"; import { useQueryData } from "@/hooks/useQueryData";
import { useMutationData } from "@/hooks/useMutationData"; import { useMutationData } from "@/hooks/useMutationData";
import { BASE_URL, API_ENDPOINTS } from "@/config/api"; import { API_ENDPOINTS } from "@/config/api";
import { toast } from "sonner"; import { toast } from "sonner";
import type { ColumnDef } from "@tanstack/react-table"; import type { ColumnDef } from "@tanstack/react-table";
import { useState } from "react"; import { useState } from "react";
@ -18,12 +18,12 @@ export const Route = createFileRoute("/_authenticated/apps/")({
function AppsComponent() { function AppsComponent() {
const { data, isLoading } = useQueryData({ const { data, isLoading } = useQueryData({
queryKey: ["software-version"], queryKey: ["software-version"],
url: BASE_URL + API_ENDPOINTS.APP_VERSION.GET_SOFTWARE, url: API_ENDPOINTS.APP_VERSION.GET_SOFTWARE,
}); });
const { data: roomData } = useQueryData({ const { data: roomData } = useQueryData({
queryKey: ["rooms"], queryKey: ["rooms"],
url: BASE_URL + API_ENDPOINTS.DEVICE_COMM.GET_ROOM_LIST, url: API_ENDPOINTS.DEVICE_COMM.GET_ROOM_LIST,
}); });
const versionList: Version[] = Array.isArray(data) const versionList: Version[] = Array.isArray(data)
@ -35,7 +35,7 @@ function AppsComponent() {
const [table, setTable] = useState<any>(); const [table, setTable] = useState<any>();
const uploadMutation = useMutationData<FormData>({ const uploadMutation = useMutationData<FormData>({
url: BASE_URL + API_ENDPOINTS.APP_VERSION.UPLOAD, url: API_ENDPOINTS.APP_VERSION.UPLOAD,
method: "POST", method: "POST",
invalidate: [["software-version"]], invalidate: [["software-version"]],
onSuccess: () => toast.success("Upload thành công!"), onSuccess: () => toast.success("Upload thành công!"),
@ -66,7 +66,7 @@ function AppsComponent() {
}); });
const deleteMutation = useMutationData<{ MsiFileIds: number[] }>({ const deleteMutation = useMutationData<{ MsiFileIds: number[] }>({
url: BASE_URL + API_ENDPOINTS.APP_VERSION.DELETE_FILES, url: API_ENDPOINTS.APP_VERSION.DELETE_FILES + "",
method: "POST", method: "POST",
invalidate: [["software-version"]], invalidate: [["software-version"]],
onSuccess: () => toast.success("Xóa phần mềm thành công!"), onSuccess: () => toast.success("Xóa phần mềm thành công!"),
@ -80,7 +80,7 @@ function AppsComponent() {
fileName: string; fileName: string;
version: string; version: string;
}>({ }>({
url: BASE_URL + API_ENDPOINTS.APP_VERSION.ADD_REQUIRED_FILE, url: API_ENDPOINTS.APP_VERSION.ADD_REQUIRED_FILE,
method: "POST", method: "POST",
invalidate: [["software-version"]], invalidate: [["software-version"]],
onSuccess: () => toast.success("Thêm file vào danh sách thành công!"), onSuccess: () => toast.success("Thêm file vào danh sách thành công!"),
@ -187,7 +187,7 @@ function AppsComponent() {
try { try {
for (const roomName of roomNames) { for (const roomName of roomNames) {
await installMutation.mutateAsync({ await installMutation.mutateAsync({
url: BASE_URL + API_ENDPOINTS.DEVICE_COMM.INSTALL_MSI(roomName), url: API_ENDPOINTS.DEVICE_COMM.INSTALL_MSI(roomName),
data: { MsiFileIds }, data: { MsiFileIds },
}); });
} }
@ -214,7 +214,7 @@ function AppsComponent() {
try { try {
for (const roomName of roomNames) { for (const roomName of roomNames) {
await downloadMutation.mutateAsync({ await downloadMutation.mutateAsync({
url: BASE_URL + API_ENDPOINTS.DEVICE_COMM.DOWNLOAD_FILES(roomName), url: API_ENDPOINTS.DEVICE_COMM.DOWNLOAD_FILES(roomName),
data: { MsiFileIds }, data: { MsiFileIds },
}); });
} }
@ -247,7 +247,7 @@ function AppsComponent() {
const { id } = row.original; const { id } = row.original;
await deleteRequiredFileMutation.mutateAsync({ await deleteRequiredFileMutation.mutateAsync({
data: { id }, data: { id },
url: BASE_URL + API_ENDPOINTS.APP_VERSION.DELETE_REQUIRED_FILE(id), url: API_ENDPOINTS.APP_VERSION.DELETE_REQUIRED_FILE(id),
}); });
} }
if (table) { if (table) {
@ -269,7 +269,7 @@ function AppsComponent() {
const { id } = row.original; const { id } = row.original;
await deleteMutation.mutateAsync({ await deleteMutation.mutateAsync({
data: { MsiFileIds: [id] }, data: { MsiFileIds: [id] },
url: BASE_URL + API_ENDPOINTS.APP_VERSION.DELETE_FILES(id), url: API_ENDPOINTS.APP_VERSION.DELETE_FILES(id),
}); });
} }
if (table) { if (table) {

View File

@ -1,4 +1,4 @@
import { API_ENDPOINTS, BASE_URL } from "@/config/api"; import { API_ENDPOINTS } from "@/config/api";
import { useMutationData } from "@/hooks/useMutationData"; import { useMutationData } from "@/hooks/useMutationData";
import { useDeleteData } from "@/hooks/useDeleteData"; import { useDeleteData } from "@/hooks/useDeleteData";
import { useQueryData } from "@/hooks/useQueryData"; import { useQueryData } from "@/hooks/useQueryData";
@ -20,13 +20,13 @@ function BlacklistComponent() {
// Lấy danh sách blacklist // Lấy danh sách blacklist
const { data, isLoading } = useQueryData({ const { data, isLoading } = useQueryData({
queryKey: ["blacklist"], queryKey: ["blacklist"],
url: BASE_URL + API_ENDPOINTS.APP_VERSION.GET_VERSION, url: API_ENDPOINTS.APP_VERSION.GET_VERSION,
}); });
// Lấy danh sách phòng // Lấy danh sách phòng
const { data: roomData } = useQueryData({ const { data: roomData } = useQueryData({
queryKey: ["rooms"], queryKey: ["rooms"],
url: BASE_URL + API_ENDPOINTS.DEVICE_COMM.GET_ROOM_LIST, url: API_ENDPOINTS.DEVICE_COMM.GET_ROOM_LIST,
}); });
const blacklist: Blacklist[] = Array.isArray(data) const blacklist: Blacklist[] = Array.isArray(data)
@ -127,7 +127,7 @@ function BlacklistComponent() {
}) => { }) => {
try { try {
await addNewBlacklistMutation.mutateAsync({ await addNewBlacklistMutation.mutateAsync({
url: BASE_URL + API_ENDPOINTS.APP_VERSION.ADD_BLACKLIST, url: API_ENDPOINTS.APP_VERSION.ADD_BLACKLIST,
method: "POST", method: "POST",
config: { headers: { "Content-Type": "application/json" } }, config: { headers: { "Content-Type": "application/json" } },
data: undefined, data: undefined,
@ -143,7 +143,7 @@ function BlacklistComponent() {
for (const blacklistId of selectedRows) { for (const blacklistId of selectedRows) {
await deleteBlacklistMutation.mutateAsync({ await deleteBlacklistMutation.mutateAsync({
url: url:
BASE_URL + API_ENDPOINTS.APP_VERSION.DELETE_BLACKLIST(blacklistId), API_ENDPOINTS.APP_VERSION.DELETE_BLACKLIST(blacklistId),
config: { headers: { "Content-Type": "application/json" } }, config: { headers: { "Content-Type": "application/json" } },
}); });
} }
@ -156,7 +156,7 @@ function BlacklistComponent() {
try { try {
for (const deviceId of targets) { for (const deviceId of targets) {
await updateDeviceMutation.mutateAsync({ await updateDeviceMutation.mutateAsync({
url: BASE_URL + API_ENDPOINTS.DEVICE_COMM.UPDATE_BLACKLIST(deviceId), url: API_ENDPOINTS.DEVICE_COMM.UPDATE_BLACKLIST(deviceId),
data: undefined, data: undefined,
}); });
toast.success(`Đã gửi cập nhật cho ${deviceId}`); toast.success(`Đã gửi cập nhật cho ${deviceId}`);

View File

@ -3,7 +3,7 @@ import { FormSubmitTemplate } from "@/template/form-submit-template";
import { ShellCommandForm } from "@/components/forms/command-form"; import { ShellCommandForm } from "@/components/forms/command-form";
import { useMutationData } from "@/hooks/useMutationData"; import { useMutationData } from "@/hooks/useMutationData";
import { useQueryData } from "@/hooks/useQueryData"; import { useQueryData } from "@/hooks/useQueryData";
import { BASE_URL, API_ENDPOINTS } from "@/config/api"; import { API_ENDPOINTS } from "@/config/api";
import { toast } from "sonner"; import { toast } from "sonner";
type SendCommandRequest = { Command: string }; type SendCommandRequest = { Command: string };
@ -18,7 +18,7 @@ function CommandPage() {
// Lấy danh sách phòng từ API // Lấy danh sách phòng từ API
const { data: roomData } = useQueryData({ const { data: roomData } = useQueryData({
queryKey: ["rooms"], queryKey: ["rooms"],
url: BASE_URL + API_ENDPOINTS.DEVICE_COMM.GET_ROOM_LIST, url: API_ENDPOINTS.DEVICE_COMM.GET_ROOM_LIST,
}); });
// Mutation gửi lệnh // Mutation gửi lệnh
@ -49,7 +49,7 @@ function CommandPage() {
rooms={roomData} rooms={roomData}
onSubmit={(roomName, command) => { onSubmit={(roomName, command) => {
sendCommandMutation.mutateAsync({ sendCommandMutation.mutateAsync({
url: BASE_URL + API_ENDPOINTS.DEVICE_COMM.SEND_COMMAND(roomName), url: API_ENDPOINTS.DEVICE_COMM.SEND_COMMAND(roomName),
data: { Command: command }, data: { Command: command },
}); });
}} }}

View File

@ -6,7 +6,7 @@ import { Button } from "@/components/ui/button";
import { useQueryData } from "@/hooks/useQueryData"; import { useQueryData } from "@/hooks/useQueryData";
import { useDeviceEvents } from "@/hooks/useDeviceEvents"; import { useDeviceEvents } from "@/hooks/useDeviceEvents";
import { useClientFolderStatus } from "@/hooks/useClientFolderStatus"; import { useClientFolderStatus } from "@/hooks/useClientFolderStatus";
import { API_ENDPOINTS, BASE_URL } from "@/config/api"; import { API_ENDPOINTS } from "@/config/api";
import { DeviceGrid } from "@/components/grids/device-grid"; import { DeviceGrid } from "@/components/grids/device-grid";
import { DeviceTable } from "@/components/tables/device-table"; import { DeviceTable } from "@/components/tables/device-table";
import { useMachineNumber } from "@/hooks/useMachineNumber"; import { useMachineNumber } from "@/hooks/useMachineNumber";
@ -32,7 +32,7 @@ function RoomDetailPage() {
const { data: devices = [] } = useQueryData({ const { data: devices = [] } = useQueryData({
queryKey: ["devices", roomName], queryKey: ["devices", roomName],
url: BASE_URL + API_ENDPOINTS.DEVICE_COMM.GET_DEVICE_FROM_ROOM(roomName), url: API_ENDPOINTS.DEVICE_COMM.GET_DEVICE_FROM_ROOM(roomName),
}); });
const parseMachineNumber = useMachineNumber(); const parseMachineNumber = useMachineNumber();
@ -41,7 +41,7 @@ function RoomDetailPage() {
try { try {
setIsCheckingFolder(true); setIsCheckingFolder(true);
const response = await fetch( const response = await fetch(
BASE_URL + API_ENDPOINTS.DEVICE_COMM.REQUEST_GET_CLIENT_FOLDER_STATUS(roomName), API_ENDPOINTS.DEVICE_COMM.REQUEST_GET_CLIENT_FOLDER_STATUS(roomName),
{ {
method: "POST", method: "POST",
} }

View File

@ -1,4 +1,4 @@
import { API_ENDPOINTS, BASE_URL } from "@/config/api"; import { API_ENDPOINTS } from "@/config/api";
import { useQueryData } from "@/hooks/useQueryData"; import { useQueryData } from "@/hooks/useQueryData";
import { useDeviceEvents } from "@/hooks/useDeviceEvents"; import { useDeviceEvents } from "@/hooks/useDeviceEvents";
import { createFileRoute, useNavigate } from "@tanstack/react-router"; import { createFileRoute, useNavigate } from "@tanstack/react-router";
@ -44,7 +44,7 @@ function RoomComponent() {
const { data: roomData = [], isLoading } = useQueryData({ const { data: roomData = [], isLoading } = useQueryData({
queryKey: ["rooms"], queryKey: ["rooms"],
url: BASE_URL + API_ENDPOINTS.DEVICE_COMM.GET_ROOM_LIST, url: API_ENDPOINTS.DEVICE_COMM.GET_ROOM_LIST,
}); });
const [sorting, setSorting] = React.useState<SortingState>([]); const [sorting, setSorting] = React.useState<SortingState>([]);

View File

@ -1,6 +1,6 @@
import axios from "axios"; import axios from "axios";
import { queryClient } from "@/main"; import { queryClient } from "@/main";
import { BASE_URL, API_ENDPOINTS } from "@/config/api"; import { API_ENDPOINTS } from "@/config/api";
import type { DeviceHealthCheck } from "@/types/device"; import type { DeviceHealthCheck } from "@/types/device";
export async function fetchDevicesFromRoom( export async function fetchDevicesFromRoom(
@ -10,7 +10,7 @@ export async function fetchDevicesFromRoom(
queryKey: ["devices-from-room", roomName], queryKey: ["devices-from-room", roomName],
queryFn: async () => { queryFn: async () => {
const response = await axios.get<DeviceHealthCheck[]>( const response = await axios.get<DeviceHealthCheck[]>(
BASE_URL + API_ENDPOINTS.DEVICE_COMM.GET_DEVICE_FROM_ROOM(roomName) API_ENDPOINTS.DEVICE_COMM.GET_DEVICE_FROM_ROOM(roomName)
); );
return response.data ?? []; return response.data ?? [];
}, },