Skip to content

Commit

Permalink
final commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aliasadolahi74 committed Oct 24, 2021
1 parent 9da587a commit 56f9964
Show file tree
Hide file tree
Showing 43 changed files with 1,196 additions and 291 deletions.
5 changes: 3 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
REACT_APP_CUSTOM_DIR = '/pcm'
REACT_APP_API_ENDPOINT = 'http://localhost/pcm'
REACT_APP_CUSTOM_DIR = ''
REACT_APP_API_ENDPOINT = 'http://localhost/'
REACT_APP_WEBSITE = 'http://tmb.co.ir'
PORT=8080
6 changes: 3 additions & 3 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REACT_APP_CUSTOM_DIR = '/pcm'
REACT_APP_API_ENDPOINT = 'http://vidapro.ir/pcm-backend'
REACT_APP_CUSTOM_DIR = ''
REACT_APP_API_ENDPOINT = 'http://api.tmb.co.ir'
REACT_APP_WEBSITE = 'http://tmb.co.ir'
PORT=8080
PORT=80
3 changes: 3 additions & 0 deletions debug.log
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@
[1203/192752.833:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1204/190124.255:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1205/022004.772:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1207/020825.100:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1208/002529.440:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1214/000424.442:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "pcm-app",
"version": "0.1.0",
"private": true,
"homepage": "http://vidapro.ir/pcm",
"homepage": "http://cloud.tmb.co.ir:8080",
"proxy": "http://cloud.tmb.co.ir:8080",
"dependencies": {
"@material-ui/core": "^4.11.1",
"@testing-library/jest-dom": "^4.2.4",
Expand All @@ -19,7 +20,6 @@
"query-string": "^6.13.7",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-meta-tags": "^1.0.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3"
},
Expand Down
Binary file removed pcm-app.zip
Binary file not shown.
9 changes: 5 additions & 4 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="viewport" content="width=1300" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
Expand All @@ -24,10 +23,12 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>سامانه تله‌متری طراحان مدار باختر</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<noscript
>شما برای کار کردن با این سامانه به جاوااسکریپت فعال نیاز دارید</noscript
>
<div id="root"></div>
<!--
This HTML file is a template.
Expand Down
21 changes: 2 additions & 19 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"short_name": "سامانه تله‌متری طراحان مدار باختر",
"name": "سامانه تله‌متری شرکت طراحان مدار باختر",
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
Expand Down
59 changes: 57 additions & 2 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,13 @@ a:hover {
.devices-box {
color: #5c5c5c;
}

.checkbox-container > div {
display: grid;
grid-template-columns: auto auto auto;
row-gap: 20px;
}

.checkbox-container > div > div {
display: grid;
grid-template-columns: 150px 50px;
row-gap: 10px;
Expand Down Expand Up @@ -594,7 +599,57 @@ a:hover {

.info-container {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-columns: 1fr 6fr;
row-gap: 20px;
width: 70%;
}

.info-container > span:nth-child(2n) {
font-weight: bold;
}

.newDeviceFormInputContainer {
display: grid;
grid-template-columns: 1fr 1fr;
}

.dashboard-table-container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-evenly;
}

.dashboard-table-container > div {
margin-bottom: 40px;
}

.dashboard-table-container .table thead th {
background-color: #008a6c;
border-color: #007e62;
}

.dashboard-table-container h6 {
white-space: pre-line;
line-height: 35px;
}

.numberOfStatisticsContainer {
border: 1px solid #008a6c;
padding: 10px 20px;
margin: 30px 30px 50px;
background: #ffffff;
display: flex;
justify-content: center;
align-items: center;
align-self: center;
border-radius: 10px;
}

.new-user-input-conatiner {
width: 50%;
display: grid;
column-gap: 20px;
row-gap: 20px;
grid-template-columns: 1fr 1fr;
}
63 changes: 50 additions & 13 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import NotFound from "./components/notFound";
import { Route, Redirect, Switch } from "react-router-dom";
import Login from "./components/login";
import { MuiThemeProvider, createMuiTheme } from "@material-ui/core";
import { MetaTags } from "react-meta-tags";
import jwtDecode from "jwt-decode";
import axios from "axios";
import config from "./config.json";
import qs from "qs";
const dir = process.env.REACT_APP_CUSTOM_DIR;

function App() {
Expand All @@ -17,22 +20,56 @@ function App() {
},
});

const token = localStorage.getItem("token");
const now = new Date().getTime();
let expireTimestamp = 0;
let routes;
try {
const decodedToken = jwtDecode(token);
expireTimestamp = decodedToken["expire"];
} catch (e) {}
if (token !== null && expireTimestamp > now) {
refreshToken(token);
routes = (
<Switch>
<Route path={`${dir}/admin`} component={AdminPanel} />
<Route path={`${dir}/not-found`} component={NotFound} />
<Route path={`${dir}/login`} component={Login} />
<Redirect from={`${dir}/`} exact to={`${dir}/login`} />
<Redirect to={`${dir}/not-found`} />
</Switch>
);
} else {
routes = (
<Switch>
<Route path={`${dir}/admin`} component={Login} />
<Route path={`${dir}/not-found`} component={NotFound} />
<Route path={`${dir}/login`} component={Login} />
<Redirect from={`${dir}/`} exact to={`${dir}/login`} />
<Redirect to={`${dir}/not-found`} />
</Switch>
);
}
return (
<MuiThemeProvider theme={theme}>
<MetaTags>
<meta name="viewport" content="width=1300" />
</MetaTags>
<div className="App">
<Switch>
<Route path={`${dir}/admin`} component={AdminPanel} />
<Route path={`${dir}/not-found`} component={NotFound} />
<Route path={`${dir}/login`} component={Login} />
<Redirect from={`${dir}/`} exact to={`${dir}/login`} />
<Redirect to={`${dir}/not-found`} />
</Switch>
</div>
<div className="App">{routes}</div>
</MuiThemeProvider>
);
}

async function refreshToken(oldToken) {
const loginOptions = {
method: "POST",
headers: { "content-type": "application/x-www-form-urlencoded" },
data: qs.stringify({ token: oldToken }),
url: `${config.apiBaseURL}/refresh-token.php`,
};
const loginInfo = await axios(loginOptions);
if (loginInfo.data.status) {
const token = loginInfo.data.body.token;
localStorage.removeItem("token");
localStorage.setItem("token", token);
}
}

export default App;
Loading

0 comments on commit 56f9964

Please sign in to comment.