From 63ec8721646a3e9eb7920bc6eed6e891bc03b1dc Mon Sep 17 00:00:00 2001 From: Juho Salli Date: Wed, 18 Dec 2019 22:57:45 +0200 Subject: [PATCH] Toimii --- gatsby-config.js | 6 +- src/components/layout.js | 4 +- src/pages/index.js | 115 ++++++++++++++++++++++++++++++++++----- 3 files changed, 105 insertions(+), 20 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index 999bd3d..2c35adb 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -1,8 +1,8 @@ module.exports = { siteMetadata: { - title: `Gatsby Default Starter`, - description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`, - author: `@gatsbyjs`, + title: `Generoi Bokxi IP`, + description: ``, + author: `@juhosa`, }, plugins: [ `gatsby-plugin-react-helmet`, diff --git a/src/components/layout.js b/src/components/layout.js index 8d55987..3f469dc 100644 --- a/src/components/layout.js +++ b/src/components/layout.js @@ -36,9 +36,9 @@ const Layout = ({ children }) => { >
{children}
diff --git a/src/pages/index.js b/src/pages/index.js index 7eb6257..6a844d4 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -1,21 +1,106 @@ -import React from "react" -import { Link } from "gatsby" +import React, { useState, useEffect } from "react" import Layout from "../components/layout" -import Image from "../components/image" import SEO from "../components/seo" -const IndexPage = () => ( - - -

Hi people

-

Welcome to your new Gatsby site.

-

Now go build something great.

-
- -
- Go to page 2 -
-) +const IndexPage = () => { + const [osat, setOsat] = useState({ loppu: "", verkko: "vlan" }) + const [ip, setIp] = useState("") + + useEffect(() => { + console.log("doip") + // console.log({ osat }) + setIp("") + if (osat.loppu === "" || osat.loppu.length !== 4) return + + let ekanumero = "" + let loppu = osat.loppu + let verkko = osat.verkko + + if (verkko === "vlan") { + const lopuneka = loppu.slice(0, 1) + ekanumero = lopuneka + } else if (verkko === "vlan2") { + const lopuneka = loppu.slice(0, 1) + ekanumero = lopuneka === "2" ? "6" : "7" + } + + let loppuosa = "" + for (let i of loppu.slice(1)) { + if (i !== "0") { + loppuosa += i + } + } + + setIp(`10.22${ekanumero}.${loppuosa}.x`) + }, [osat.verkko, osat.loppu]) + + return ( + + + + + Verkko + +
+ +
+ + +
+ + + Tunnuksen/verkon loppuosa (neljä viimeistä merkkiä) + +
+ { + setOsat({ loppu: ev.target.value, verkko: osat.verkko }) + }} + /> + +
+ + IP + +
+ {ip !== "" ? `${ip} (valitse x väliltä 2-254)` : "10.22x.xxx.xxx"} +
+ + + Default gateway + +
+ {ip !== "" ? `${ip} (x on 1)` : "10.22x.xxx.1"} +
+
+ ) +} export default IndexPage