Add distant links
This commit is contained in:
@@ -1,18 +1,19 @@
|
|||||||
import js from '@eslint/js'
|
import js from "@eslint/js";
|
||||||
import globals from 'globals'
|
import globals from "globals";
|
||||||
import reactHooks from 'eslint-plugin-react-hooks'
|
import reactHooks from "eslint-plugin-react-hooks";
|
||||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
import reactRefresh from "eslint-plugin-react-refresh";
|
||||||
import tseslint from 'typescript-eslint'
|
import tseslint from "typescript-eslint";
|
||||||
import { globalIgnores } from 'eslint/config'
|
import { globalIgnores } from "eslint/config";
|
||||||
|
import { SemicolonPreference } from "typescript";
|
||||||
|
|
||||||
export default tseslint.config([
|
export default tseslint.config([
|
||||||
globalIgnores(['dist']),
|
globalIgnores(["dist"]),
|
||||||
{
|
{
|
||||||
files: ['**/*.{ts,tsx}'],
|
files: ["**/*.{ts,tsx}"],
|
||||||
extends: [
|
extends: [
|
||||||
js.configs.recommended,
|
js.configs.recommended,
|
||||||
tseslint.configs.recommended,
|
tseslint.configs.recommended,
|
||||||
reactHooks.configs['recommended-latest'],
|
reactHooks.configs["recommended-latest"],
|
||||||
reactRefresh.configs.vite,
|
reactRefresh.configs.vite,
|
||||||
],
|
],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
@@ -20,4 +21,4 @@ export default tseslint.config([
|
|||||||
globals: globals.browser,
|
globals: globals.browser,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
])
|
]);
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
"name": "dashboardjs",
|
"name": "dashboardjs",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
|
"proxy": [
|
||||||
|
"http://gpao.lan",
|
||||||
|
"http://raspitipi.local:3002",
|
||||||
|
"http://192.168.3.42:3002"
|
||||||
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
22
src/App.tsx
22
src/App.tsx
@@ -1,5 +1,6 @@
|
|||||||
import type { FC } from "react";
|
import type { FC } from "react";
|
||||||
import { CastesLinks } from "./CastesLinks";
|
import { CastesLinks } from "./CastesLinks";
|
||||||
|
import { LocalLinks } from "./LocalLinks";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const links = [
|
const links = [
|
||||||
@@ -12,18 +13,33 @@ function App() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const proLinks = [
|
const proLinks = [
|
||||||
|
{
|
||||||
|
name: "ComCastes",
|
||||||
|
link: "http://comcastes.loc",
|
||||||
|
icon: "http://comcastes.loc/favicon.ico",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "GPAO",
|
name: "GPAO",
|
||||||
link: "http://gpao.loc",
|
link: "http://gpao.loc",
|
||||||
icon: "http://gpao.loc/favicon.ico",
|
icon: "http://gpao.loc/favicon.ico",
|
||||||
},
|
},
|
||||||
{ name: "Mycastes", link: "http://mycastes.loc" },
|
{
|
||||||
|
name: "API Castes",
|
||||||
|
link: "http://apicastes.loc",
|
||||||
|
icon: "http://apicastes.loc/favicon.ico",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Mycastes",
|
||||||
|
link: "http://mycastes.loc",
|
||||||
|
icon: "http://mycastes.loc/favicon.ico",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="dark:bg-slate-950 dark:text-slate-50 h-screen flex flex-col gap-10">
|
<main className="dark:bg-slate-950 dark:text-slate-50 h-screen flex flex-col gap-10">
|
||||||
<h1 className="text-center text-5xl font-semibold">Frame Work</h1>
|
<h1 className="text-center text-5xl font-semibold">Frame Work</h1>
|
||||||
<LinkGroup title="Perso" links={links} />
|
<LinkGroup title="Perso" links={links} />
|
||||||
|
<LocalLinks />
|
||||||
<LinkGroup title="Pro Dev" links={proLinks} />
|
<LinkGroup title="Pro Dev" links={proLinks} />
|
||||||
<CastesLinks />
|
<CastesLinks />
|
||||||
</main>
|
</main>
|
||||||
@@ -43,7 +59,7 @@ export const LinkGroup: FC<LinkGroupProps> = ({ title, links }) => {
|
|||||||
<h2 className="text-3xl font-semibold text-center mb-5">{title}</h2>
|
<h2 className="text-3xl font-semibold text-center mb-5">{title}</h2>
|
||||||
<ul className="flex flex-wrap gap-2 text-3xl flex-1 items-center justify-center">
|
<ul className="flex flex-wrap gap-2 text-3xl flex-1 items-center justify-center">
|
||||||
{links.map((link) => (
|
{links.map((link) => (
|
||||||
<Link link={link} />
|
<Link key={link.name} link={link} />
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -70,7 +86,7 @@ const Link: FC<LinkProps> = ({ link }) => {
|
|||||||
>
|
>
|
||||||
{link.icon ? (
|
{link.icon ? (
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<img src={link.icon} alt={link.name} className="max-h-10" />
|
<img src={link.icon} alt="" className="max-h-10" />
|
||||||
<div className="flex-1">{link.name}</div>
|
<div className="flex-1">{link.name}</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -3,7 +3,13 @@ import { LinkGroup } from "./App";
|
|||||||
|
|
||||||
export const CastesLinks = () => {
|
export const CastesLinks = () => {
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const links = [{ name: "GPAO", link: "http://gpao.lan" }];
|
const [error, setError] = useState("");
|
||||||
|
const [links, setLinks] = useState([]);
|
||||||
|
const castesLinks = [
|
||||||
|
{ name: "GPAO", link: "http://gpao.lan" },
|
||||||
|
{ name: "Penpot", link: "https://penpot.castes-industrie.fr" },
|
||||||
|
{ name: "Schema", link: "http://schemas.castes-industrie.fr/" },
|
||||||
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
testConnection();
|
testConnection();
|
||||||
@@ -11,9 +17,30 @@ export const CastesLinks = () => {
|
|||||||
|
|
||||||
const testConnection = async () => {
|
const testConnection = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch("http://gpao.lan");
|
const res = await fetch("http://gpao.lan", { method: "HEAD" });
|
||||||
|
console.log(res);
|
||||||
|
if (res.ok) {
|
||||||
|
setLinks(castesLinks);
|
||||||
|
}
|
||||||
console.log("link", res);
|
console.log("link", res);
|
||||||
} catch (error) {}
|
} catch (error: Error | NetworkError | unknown) {
|
||||||
|
console.log(error);
|
||||||
|
setError(error.response?.data.message || error.message);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
return <LinkGroup title="Castes" links={links} />;
|
return loading ? (
|
||||||
|
<div>Chargement...</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<div>Casty</div>
|
||||||
|
{error && (
|
||||||
|
<div className="text-white px-2 text-center py-1 mx-5 bg-red-500 rounded">
|
||||||
|
{error}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<LinkGroup title="Castes" links={links} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
41
src/LocalLinks.tsx
Normal file
41
src/LocalLinks.tsx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { LinkGroup } from "./App";
|
||||||
|
|
||||||
|
export const LocalLinks = () => {
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState(false);
|
||||||
|
const [links, setLinks] = useState([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
testConnection();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const testConnection = async () => {
|
||||||
|
try {
|
||||||
|
const res = await fetch(
|
||||||
|
"http://192.168.3.42:3002/api/get_links2091652955602628755",
|
||||||
|
//"http://raspitipi.local:3002/api/get_links2091652955602628755",
|
||||||
|
);
|
||||||
|
const data = await res.json();
|
||||||
|
console.log(data, res);
|
||||||
|
setLinks(data);
|
||||||
|
console.log("link", res);
|
||||||
|
} catch (_: unknown) {
|
||||||
|
setError(true);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return loading ? (
|
||||||
|
<div>Chargement...</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<LinkGroup title="Liens locaux" links={links} />
|
||||||
|
{error ? (
|
||||||
|
<div className="text-center text-red-600 -mt-5">
|
||||||
|
Liens non accessibles
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user