Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
Sir-Thom committed Dec 12, 2023
1 parent 7c6f65d commit fd3b7dd
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 167 deletions.
24 changes: 12 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="stylesheet" href="/src/styles.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Magic-Eye</title>
</head>
<body>
<nav id="titlebar"></nav>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="stylesheet" href="/src/styles.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Magic-Eye</title>
</head>
<body>
<nav id="titlebar"></nav>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
7 changes: 5 additions & 2 deletions src/components/titlebar/titlebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function Titlebar() {
const handleMenuClick = useCallback(() => {
setMenuOpen((prevMenuOpen) => !prevMenuOpen);
}, []);

useEffect(() => {
const tauriInterval = setInterval(async () => {
const isMaximized = await appWindow.isMaximized();
Expand Down Expand Up @@ -88,7 +88,10 @@ export default function Titlebar() {

return (
!fullscreen && (
<div data-tauri-drag-region className=" z-50 overflow-hidden flex top-0 justify-between items-center h-12 border-b-2 border-window-dark-500 dark:bg-[#111111] bg-window-light-50 p-2 text-text-dark w-screen fixed left-0 right-0">
<div
data-tauri-drag-region
className=" z-50 overflow-hidden flex top-0 justify-between items-center h-12 border-b-2 border-window-dark-500 dark:bg-[#111111] bg-window-light-50 p-2 text-text-dark w-screen fixed left-0 right-0"
>
<Modal isOpen={isOpen} onClose={handleClose}>
<img
className="inline-flex justify-center item-center dark:text-text-dark text-text-light m-auto h-auto ml-[3.78rem] mb-4"
Expand Down
2 changes: 0 additions & 2 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
@tailwind components;
@tailwind utilities;



@layer components {
*::-webkit-scrollbar {
width: 0px;
Expand Down
64 changes: 33 additions & 31 deletions src/utils/hooks/ServerData.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
import { useEffect, useState } from 'react';
import { invoke } from '@tauri-apps/api';
import { IServer } from '../../interfaces/IServer';
import { useEffect, useState } from "react";
import { invoke } from "@tauri-apps/api";
import { IServer } from "../../interfaces/IServer";

function useServerData() {
const [configData, setConfigData] = useState<IServer | null>(null);
const [apiIp, setApiIp] = useState<string | null>(null);
const [serverError, setServerError] = useState<string | null>(null);
const [configData, setConfigData] = useState<IServer | null>(null);
const [apiIp, setApiIp] = useState<string | null>(null);
const [serverError, setServerError] = useState<string | null>(null);

useEffect(() => {
async function fetchData() {
try {
const apiIpValue = await getApiIp();
setApiIp(apiIpValue);
setServerError(null);
useEffect(() => {
async function fetchData() {
try {
const apiIpValue = await getApiIp();
setApiIp(apiIpValue);
setServerError(null);

const serverUrl = `http://${apiIpValue}/v3/config/global/get`;
const response = await invoke('get_server_request', { url: serverUrl });
const parsedResponse: IServer = JSON.parse(response as string);
setConfigData(parsedResponse);
} catch (error) {
setServerError('Unable to connect to the server.');
}
}
const serverUrl = `http://${apiIpValue}/v3/config/global/get`;
const response = await invoke("get_server_request", {
url: serverUrl
});
const parsedResponse: IServer = JSON.parse(response as string);
setConfigData(parsedResponse);
} catch (error) {
setServerError("Unable to connect to the server.");
}
}

fetchData();
}, []);
fetchData();
}, []);

async function getApiIp() {
try {
const res = await invoke('get_api_ip');
return res.toString().replace(/^"(.*)"$/, '$1');
} catch (e) {
console.error(e);
return 'unable to get API Ip address.';
async function getApiIp() {
try {
const res = await invoke("get_api_ip");
return res.toString().replace(/^"(.*)"$/, "$1");
} catch (e) {
console.error(e);
return "unable to get API Ip address.";
}
}
}

return { configData, serverError, apiIp };
return { configData, serverError, apiIp };
}

export default useServerData;
35 changes: 16 additions & 19 deletions src/views/ServerInfoView/HlsServerInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,25 @@ import useServerData from "../../utils/hooks/ServerData";
export default function HLsConnInfo() {
const [items, setItems] = useState<any[]>([]);
const { apiIp } = useServerData();


useEffect(() => {
if (apiIp !== null) {
console.log("apiIp:", apiIp);


invoke("get_server_request", {
url: `http://${apiIp}/v3/hlsmuxers/list`,
}).then((response) => {
console.log("response:", JSON.parse(response.toString()));
response = JSON.parse(response.toString());
console.log("response:", response);
if (response && (response as { items: any[] }).items) {
setItems((response as { items: any[] }).items);
} else {
console.error("Response does not contain 'items'.");
}
});
}
}, [apiIp]);
if (apiIp !== null) {
console.log("apiIp:", apiIp);

invoke("get_server_request", {
url: `http://${apiIp}/v3/hlsmuxers/list`
}).then((response) => {
console.log("response:", JSON.parse(response.toString()));
response = JSON.parse(response.toString());
console.log("response:", response);
if (response && (response as { items: any[] }).items) {
setItems((response as { items: any[] }).items);
} else {
console.error("Response does not contain 'items'.");
}
});
}
}, [apiIp]);

return (
<motion.div
Expand Down
36 changes: 16 additions & 20 deletions src/views/ServerInfoView/RtmpServerInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,27 @@ import { invoke } from "@tauri-apps/api";
import ListView from "../../components/ListBox/listView";
import useServerData from "../../utils/hooks/ServerData";



export default function RtmpConnInfo() {
const [items, setItems] = useState<any[]>([]);
const { apiIp } = useServerData();


useEffect(() => {
if (apiIp !== null) {
console.log("apiIp:", apiIp);


invoke("get_server_request", {
url: `http://${apiIp}/v3/rtmpconns/list`,
}).then((response) => {
console.log("response:", JSON.parse(response.toString()));
response = JSON.parse(response.toString());
console.log("response:", response);
if (response && (response as { items: any[] }).items) {
setItems((response as { items: any[] }).items);
} else {
console.error("Response does not contain 'items'.");
}
});
}
if (apiIp !== null) {
console.log("apiIp:", apiIp);

invoke("get_server_request", {
url: `http://${apiIp}/v3/rtmpconns/list`
}).then((response) => {
console.log("response:", JSON.parse(response.toString()));
response = JSON.parse(response.toString());
console.log("response:", response);
if (response && (response as { items: any[] }).items) {
setItems((response as { items: any[] }).items);
} else {
console.error("Response does not contain 'items'.");
}
});
}
}, [apiIp]);

async function KickRTMPession(valueToSend: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/ServerInfoView/RtspServerInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useServerData from "../../utils/hooks/ServerData";

export default function RtspServerInfo() {
const [items, setItems] = useState<any[]>([]);
const {apiIp} = useServerData();
const { apiIp } = useServerData();
useEffect(() => {
getAllRtspSessions();
}, []);
Expand Down
Loading

0 comments on commit fd3b7dd

Please sign in to comment.