This commit is contained in:
2022-02-17 14:01:07 +01:00
commit d13bee1395
30 changed files with 11302 additions and 0 deletions

3
.babel.rc Normal file
View File

@@ -0,0 +1,3 @@
{
"presets": ["next/babel"]
}

3
.babelrc Normal file
View File

@@ -0,0 +1,3 @@
{
"presets": ["next/babel"]
}

3
.eslintrc.json Normal file
View File

@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}

44
.gitignore vendored Normal file
View File

@@ -0,0 +1,44 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
/out2/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
# vercel
.vercel
.htaccess
# other
.env
a.py
*.txt
*.dxf
/public/*.dxf
/pages/api/auth/*

34
README.md Normal file
View File

@@ -0,0 +1,34 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

9
ecosystem.config.js Normal file
View File

@@ -0,0 +1,9 @@
module.exports = {
apps : [{
name:'kroj',
script: 'npm',
args:'start',
watch: ['pages'],
ignore_watch : ['public', 'P.txt']
}]
};

BIN
lscache/.cacheman.lock Normal file

Binary file not shown.

BIN
lscache/.cacheman.shm Normal file

Binary file not shown.

4
next.config.js Normal file
View File

@@ -0,0 +1,4 @@
module.exports = {
reactStrictMode: true,
}

10649
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

27
package.json Normal file
View File

@@ -0,0 +1,27 @@
{
"name": "wastpol",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"export": "next build && next export",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@supercharge/request-ip": "^1.1.2",
"child_process": "^1.0.2",
"next": "12.0.7",
"next-auth": "^4.2.1",
"nodemailer": "^6.7.2",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"autoprefixer": "^10.4.0",
"eslint": "8.4.1",
"eslint-config-next": "12.0.7",
"postcss": "^8.4.5",
"tailwindcss": "^3.0.7"
}
}

15
pages/_app.js Normal file
View File

@@ -0,0 +1,15 @@
import '../styles/globals.css'
import { SessionProvider } from "next-auth/react"
function MyApp({
Component,
pageProps: { session, ...pageProps },
}) {
return (
<SessionProvider session={session}>
<Component {...pageProps} />
</SessionProvider>
)
}
export default MyApp

24
pages/api/contact.js Normal file
View File

@@ -0,0 +1,24 @@
export default function (req, res) {
let nodemailer = require("nodemailer");
const transporter = nodemailer.createTransport({
port: 465,
host: "",
auth: {
user: "",
pass: "",
},
secure: true,
});
const mailData = {
from: "",
to: "",
subject: `Message From ${req.body.name}`,
text: req.body.message,
html: <div>{req.body.message}</div>,
};
transporter.sendMail(mailData, function (err, info) {
if (err) console.log(err);
else console.log(info);
});
console.log(req.body);
}

22
pages/api/hello.js Normal file
View File

@@ -0,0 +1,22 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
let len = 123; //
let przekroj = 35; //
let threephase = 2; //
let resistance = len / (przekroj * 35);
let moc = threephase * 7;
let wsp = 0.59; ///
let kom = 0;
let wspplus = moc * wsp + kom;
let Uodc = (wspplus / (3 * 230)) * 1000;
let spadek = Uodc * resistance;
console.log(spadek);
let a = [
1, 0.59, 0.45, 0.38, 0.34, 0.31, 0.29, 0.27, 0.26, 0.25, 0.232, 0.217, 0.208,
0.193, 0.183, 0.175, 0.168, 0.161, 0.155, 0.15, 0.145, 0.141, 0.137, 0.133,
0.13, 0.127, 0.124, 0.121, 0.119, 0.117, 0.115, 0.113, 0.111, 0.109, 0.107,
0.105, 0.104, 0.103, 0.101, 0.1, 0.1,
];

38
pages/api/spawn.js Normal file
View File

@@ -0,0 +1,38 @@
import { spawn } from "child_process";
export default function (req, res) {
console.log("spawnin");
//console.log(req.body);
//file
let textData = req.body.profil;
let replacedData = textData.replace("<22>", "o").replace("<22>", "e");
console.log(replacedData);
var fs = require("fs");
fs.writeFile("P.txt", replacedData, function (err) {
if (err) {
return console.error(err);
}
});
//py
const python = spawn("python3", ["a.py"]);
let dataToSend;
python.stdout.on("data", function (data) {
console.log("Pipe data from python script ...");
dataToSend = data.toString();
//console.log(dataToSend)
});
python.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
});
// in close event we are sure that stream from child process is closed
python.on("close", (code) => {
console.log(`child process close all stdio with code ${code}`);
// send data to browser
console.log(dataToSend);
console.log("done");
res.send("dataToSend");
});
}

97
pages/index.js Normal file
View File

@@ -0,0 +1,97 @@
import Head from "next/head";
import styles from "../styles/Home.module.css";
import Header from "./templates/header";
import Nav from "./templates/nav";
import Content from "./templates/content";
import Footer from "./templates/footer";
import { useState } from "react";
import { useSession, signIn, signOut } from "next-auth/react";
export default function Home() {
const { data: session } = useSession();
const [profil, setProfil] = useState();
const py = (e, profil) => {
e.preventDefault();
fetch("/api/spawn", {
method: "POST",
headers: {
Accept: "application/json, text/plain, */*",
"Content-Type": "application/json",
},
body: JSON.stringify({ profil: profil }),
}).then((res) => {
console.log("data from api: ", res);
document.getElementById("down").click();
});
};
if (session) {
return (
<div className={styles.container}>
<Head>
<title>Wastpol</title>
<meta name="description" content="Wastpol" />
<link rel="icon" href="/icon.png" />
</Head>
<div className="flex justify-between">
<Nav />
<div className="flex">
<h3 className="px-3 py-2 place-self-end">
Zalogowano jako {session.user.email}
</h3>
<button
onClick={() => signOut()}
className="p-2 bg-slate-200 rounded-md place-self-end"
>
Wyloguj
</button>
</div>
</div>
<main className={styles.main}>
<Header />
<textarea
id="profil"
className="bg-gray-100 h-96 w-96"
onChange={(e) => {
console.log(e.target.value);
setProfil(e.target.value);
}}
></textarea>
<button
onClick={(e) => {
py(e, profil);
}}
>
Generuj
</button>
<a href="test.dxf" download="test.dxf" id="down">
{" "}
</a>
</main>
<Footer />
</div>
);
}
return (
<div className="grid place-items-center h-screen">
<Head>
<title>Wastpol</title>
<meta name="description" content="Wastpol" />
<link rel="icon" href="/icon.png" />
</Head>
<div className="flex justify-center">
<h2 className="p-2">Nie zalogowano</h2>
<br></br>
<button
onClick={() => signIn()}
className="p-2 bg-slate-200 rounded-md"
>
Zaloguj
</button>
</div>
</div>
);
}

74
pages/kontakt.js Normal file
View File

@@ -0,0 +1,74 @@
import Head from "next/head";
import styles from "../styles/Home.module.css";
import Header from "./templates/header";
import Nav from "./templates/nav";
import Content from "./templates/content";
import Footer from "./templates/footer";
import { useState } from "react";
export default function Kontakt() {
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [message, setMessage] = useState("");
const [submitted, setSubmitted] = useState(false);
const handleSubmit = (e) => {
e.preventDefault()
console.log('Sending')
let data = {
name,
email,
message
}
fetch('/api/contact', {
method: 'POST',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
}).then((res) => {
console.log('Response received')
if (res.status === 200) {
console.log('Response succeeded!')
setSubmitted(true)
setName('')
setEmail('')
setBody('')
}
})
}
return (
<div className={styles.container}>
<Head>
<title>Wastpol</title>
<meta name="description" content="Wastpol" />
<link rel="icon" href="/icon.png" />
</Head>
<Nav />
<main className={styles.main}>
<div className={styles.container}>
<form className={styles.main}>
<formGroup className={styles.inputGroup}>
<label htmlFor="name">Imię</label>
<input type="text" name="name" onChange={(e)=>{setName(e.target.value)}} className={styles.inputField} />
</formGroup>
<formGroup className={styles.inputGroup}>
<label htmlFor="email">Email</label>
<input type="email" name="email" onChange={(e)=>{setEmail(e.target.value)}} className={styles.inputField} />
</formGroup>
<formGroup className={styles.inputGroup}>
<label htmlFor="message">Wiadomość</label>
<input type="text" name="message" onChange={(e)=>{setMessage(e.target.value)}} className={styles.inputField} />
</formGroup>
<input type="submit" onClick={(e)=>{handleSubmit(e)}} />
</form>
</div>
</main>
<Footer />
</div>
);
}

35
pages/onas.js Normal file
View File

@@ -0,0 +1,35 @@
import Head from "next/head";
import styles from "../styles/Home.module.css";
import Header from "./templates/header";
import Nav from "./templates/nav";
import Content from "./templates/content";
import Footer from "./templates/footer";
export default function Onas() {
return (
<div className={styles.container}>
<Head>
<title>Wastpol</title>
<meta name="description" content="Wastpol" />
<link rel="icon" href="/icon.png" />
</Head>
<Nav />
<main className={styles.main}>
<p className="font-bold">
Głównym profilem działalności firmy jest projektowanie instalacji
elektrycznych oraz nadzór. Świadczymy również usługi w zakresie
audytów instalacji elektrycznych, umożliwiających wskazanie
konkretnych rozwiązań technicznych.
</p>
<p>
Jako projektanci posiadający wieloletnie doświadczenie, potwierdzone
odpowiednimi uprawnieniami, możemy Państwu zapewnić wykonywanie
projektów na najwyższym poziomie technicznym i w zadowalających
terminach realizacji.
</p>
</main>
<Footer />
</div>
);
}

View File

@@ -0,0 +1,33 @@
import styles from "../../styles/Home.module.css";
export default function Content() {
return (
<div>
<p className={styles.description}>
Lokalizacja
<br />
<b>Nowy Sącz, Aleje Wolności 6</b>
</p>
<p className={styles.description}>
Telefon kontaktowy
<br />
<b>
<a href="tel:+48504066513">+48 504 066 513</a>
</b>
<br />
<b>
<a href="tel:184420244">18 442 02 44</a>
</b>
</p>
<p className={styles.description}>
Adres email
<br />
<b>
<a href="mailto:biuro@wastpol.pl">biuro@wastpol.pl</a>
</b>
</p>
</div>
);
}

View File

@@ -0,0 +1,9 @@
import styles from "../../styles/Home.module.css";
export default function Footer() {
return (
<div>
<p></p>
</div>
);
}

View File

@@ -0,0 +1,9 @@
import styles from "../../styles/Home.module.css";
export default function Header() {
return (
<div>
<h1 className="text-3xl p-6">Generuj profil przekroju terenu</h1>
</div>
);
}

19
pages/templates/nav.js Normal file
View File

@@ -0,0 +1,19 @@
import Link from "next/link";
export default function Nav() {
return (
<div className="flex">
<Link href="/">
<h2 className="px-2 place-self-center">
<img src="logo.png" className="h-12" />
</h2>
</Link>
<Link href="/onas">
<h3 className="px-3 py-2 place-self-end">O nas</h3>
</Link>
<Link href="/kontakt">
<h3 className="px-3 py-2 place-self-end">Kontakt</h3>
</Link>
</div>
);
}

6
postcss.config.js Normal file
View File

@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
public/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

BIN
public/icon_4x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
public/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

116
styles/Home.module.css Normal file
View File

@@ -0,0 +1,116 @@
.container {
padding: 0 2rem;
}
.main {
min-height: 100vh;
padding: 4rem 0;
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.footer {
display: flex;
flex: 1;
padding: 2rem 0;
border-top: 1px solid #eaeaea;
justify-content: center;
align-items: center;
}
.footer a {
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
}
.title a {
color: #0070f3;
text-decoration: none;
}
.title a:hover,
.title a:focus,
.title a:active {
text-decoration: underline;
}
.title {
margin: 0;
line-height: 1.15;
font-size: 4rem;
}
.title,
.description {
text-align: center;
}
.description {
margin: 4rem 0;
line-height: 1.5;
font-size: 1.5rem;
}
.code {
background: #fafafa;
border-radius: 5px;
padding: 0.75rem;
font-size: 1.1rem;
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
Bitstream Vera Sans Mono, Courier New, monospace;
}
.grid {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
max-width: 800px;
}
.card {
margin: 1rem;
padding: 1.5rem;
text-align: left;
color: inherit;
text-decoration: none;
border: 1px solid #eaeaea;
border-radius: 10px;
transition: color 0.15s ease, border-color 0.15s ease;
max-width: 300px;
}
.card:hover,
.card:focus,
.card:active {
color: #0070f3;
border-color: #0070f3;
}
.card h2 {
margin: 0 0 1rem 0;
font-size: 1.5rem;
}
.card p {
margin: 0;
font-size: 1.25rem;
line-height: 1.5;
}
.logo {
height: 1em;
margin-left: 0.5rem;
}
@media (max-width: 600px) {
.grid {
width: 100%;
flex-direction: column;
}
}

19
styles/globals.css Normal file
View File

@@ -0,0 +1,19 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
}
a {
color: inherit;
text-decoration: none;
}
* {
box-sizing: border-box;
}

10
tailwind.config.js Normal file
View File

@@ -0,0 +1,10 @@
module.exports = {
content: [
"./pages/**/*.{js,ts,jsx,tsx}",
"./components/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}