Toggle navigation
Toggle navigation
This project
Loading...
Sign in
HyeonJun Jeon
/
Extended-Calendar
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
HyeonJun Jeon
2022-06-10 08:37:55 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
aa9690687a46eba8caa498aafeb37b0cb3bdadc7
aa969068
1 parent
544d85df
[Style] Use env
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
105 additions
and
96 deletions
.gitignore
jsconfig.json
package-lock.json
package.json
server/libs/MySQL.js
server/libs/test.js
server/routers/Login.js
server/server.js
src/components/GridItem.js
src/components/ScheduleItem.js
src/pages/Calendar.js
src/pages/Debug.js
src/pages/Login.js
.gitignore
View file @
aa96906
...
...
@@ -22,4 +22,4 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.prettierignore
*.pvdata
.env
...
...
jsconfig.json
View file @
aa96906
{
"compilerOptions"
:
{
"baseUrl"
:
"src"
}
}
\ No newline at end of file
"compilerOptions"
:
{
"baseUrl"
:
"src"
}
}
...
...
package-lock.json
View file @
aa96906
...
...
@@ -15,6 +15,7 @@
"body-parser"
:
"^1.20.0"
,
"cors"
:
"^2.8.5"
,
"crypto-js"
:
"^4.1.1"
,
"dotenv"
:
"^16.0.1"
,
"express"
:
"^4.18.1"
,
"fs"
:
"^0.0.1-security"
,
"localforage"
:
"^1.10.0"
,
...
...
@@ -6398,11 +6399,11 @@
}
},
"node_modules/dotenv"
:
{
"version"
:
"1
0.0.0
"
,
"resolved"
:
"https://registry.npmjs.org/dotenv/-/dotenv-1
0.0.0
.tgz"
,
"integrity"
:
"sha512-
rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03
Q=="
,
"version"
:
"1
6.0.1
"
,
"resolved"
:
"https://registry.npmjs.org/dotenv/-/dotenv-1
6.0.1
.tgz"
,
"integrity"
:
"sha512-
1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsK
Q=="
,
"engines"
:
{
"node"
:
">=1
0
"
"node"
:
">=1
2
"
}
},
"node_modules/dotenv-expand"
:
{
...
...
@@ -14041,6 +14042,14 @@
}
}
},
"node_modules/react-scripts/node_modules/dotenv"
:
{
"version"
:
"10.0.0"
,
"resolved"
:
"https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz"
,
"integrity"
:
"sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q=="
,
"engines"
:
{
"node"
:
">=10"
}
},
"node_modules/readable-stream"
:
{
"version"
:
"3.6.0"
,
"resolved"
:
"https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz"
,
...
...
@@ -21350,9 +21359,9 @@
}
},
"dotenv"
:
{
"version"
:
"1
0.0.0
"
,
"resolved"
:
"https://registry.npmjs.org/dotenv/-/dotenv-1
0.0.0
.tgz"
,
"integrity"
:
"sha512-
rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03
Q=="
"version"
:
"1
6.0.1
"
,
"resolved"
:
"https://registry.npmjs.org/dotenv/-/dotenv-1
6.0.1
.tgz"
,
"integrity"
:
"sha512-
1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsK
Q=="
},
"dotenv-expand"
:
{
"version"
:
"5.1.0"
,
...
...
@@ -26761,6 +26770,13 @@
"webpack-dev-server"
:
"^4.6.0"
,
"webpack-manifest-plugin"
:
"^4.0.2"
,
"workbox-webpack-plugin"
:
"^6.4.1"
},
"dependencies"
:
{
"dotenv"
:
{
"version"
:
"10.0.0"
,
"resolved"
:
"https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz"
,
"integrity"
:
"sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q=="
}
}
},
"readable-stream"
:
{
...
...
package.json
View file @
aa96906
...
...
@@ -10,6 +10,7 @@
"body-parser"
:
"^1.20.0"
,
"cors"
:
"^2.8.5"
,
"crypto-js"
:
"^4.1.1"
,
"dotenv"
:
"^16.0.1"
,
"express"
:
"^4.18.1"
,
"fs"
:
"^0.0.1-security"
,
"localforage"
:
"^1.10.0"
,
...
...
server/libs/MySQL.js
View file @
aa96906
const
mysql2
=
require
(
"mysql2/promise"
);
const
fs
=
require
(
"fs"
);
const
[
id
,
pw
]
=
fs
.
readFileSync
(
"server/libs/sql.pvdata"
,
"utf8"
)
.
split
(
"\r\n"
);
const
connectOption
=
{
host
:
"extended-calendar-db.cihyg6ssq3la.ap-northeast-2.rds.amazonaws.com"
,
user
:
id
,
password
:
pw
,
database
:
"db"
,
require
(
"dotenv"
).
config
();
const
poolOptions
=
{
host
:
process
.
env
.
DB_HOST
,
user
:
process
.
env
.
DB_USER
,
password
:
process
.
env
.
DB_PASSWORD
,
database
:
process
.
env
.
DB_DATABASE
,
};
const
pool
=
mysql2
.
createPool
(
connectOption
);
const
pool
=
mysql2
.
createPool
(
poolOptions
);
async
function
jcalToSQL
(
jcal
,
userID
)
{
const
connection
=
await
pool
.
getConnection
(
async
(
con
)
=>
con
);
...
...
@@ -65,4 +63,4 @@ async function jcalToSQL(jcal, userID) {
// iCal의 소유주를 DB에 등록 후 userID get
// subjectID가 subjects, userID가 users에 있어야함
module
.
exports
=
{
jcalToSQL
,
connectOption
,
pool
};
module
.
exports
=
{
jcalToSQL
,
pool
};
...
...
server/libs/test.js
View file @
aa96906
...
...
@@ -5,11 +5,5 @@ const router = express.Router();
const
{
login
}
=
require
(
"./E_Campus.js"
);
const
parseICal
=
require
(
"./ICal.js"
);
async
function
runrun
()
{
const
mdata
=
await
axios
.
get
(
"http://localhost:3001/db/users"
,
{
params
:{
loginID
:
"good1588"
}}
)
console
.
log
(
mdata
.
data
)
}
async
function
runrun
()
{}
runrun
();
...
...
server/routers/Login.js
View file @
aa96906
...
...
@@ -5,6 +5,7 @@ const router = express.Router();
const
{
login
}
=
require
(
"../libs/E_Campus.js"
);
const
parseICal
=
require
(
"../libs/ICal.js"
);
const
{
jcalToSQL
}
=
require
(
"../libs/MySQL.js"
);
require
(
"dotenv"
).
config
();
// (id, pw) => failed | error | {peed, subjects, name, ID}
router
.
post
(
"/"
,
async
(
req
,
res
)
=>
{
...
...
@@ -14,22 +15,28 @@ router.post("/", async (req, res) => {
try
{
const
{
peed
,
subjects
}
=
result
;
const
resUser
=
await
axios
.
post
(
"http://3.34.173.161:3001/db/users"
,
{
loginID
:
req
.
body
.
id
,
loginPW
:
req
.
body
.
pw
,
ical
:
peed
,
});
const
resUser
=
await
axios
.
post
(
`http://
${
process
.
env
.
SERVER_IP
}
:3001/db/users`
,
{
loginID
:
req
.
body
.
id
,
loginPW
:
req
.
body
.
pw
,
ical
:
peed
,
}
);
const
userID
=
resUser
.
data
.
ID
;
const
{
data
:
subList
}
=
await
axios
.
post
(
"http://3.34.173.161:3001/db/subjects/s"
,
`http://
${
process
.
env
.
SERVER_IP
}
:3001/db/subjects/s`
,
{
list
:
subjects
,
}
);
await
axios
.
post
(
"http://3.34.173.161:3001/db/user-subject/s"
,
{
userID
,
subList
,
});
await
axios
.
post
(
`http://
${
process
.
env
.
SERVER_IP
}
:3001/db/user-subject/s`
,
{
userID
,
subList
,
}
);
const
{
data
:
ical
}
=
await
axios
({
url
:
peed
,
method
:
"GET"
,
...
...
server/server.js
View file @
aa96906
const
express
=
require
(
"express"
);
const
fs
=
require
(
"fs"
);
const
cors
=
require
(
"cors"
);
const
loginRouter
=
require
(
"./routers/Login"
);
...
...
@@ -10,7 +9,7 @@ const app = express();
app
.
use
(
cors
({
origin
:
"http://3.34.173.161:3000"
,
origin
:
`http://
${
process
.
env
.
REACT_APP_IP
}
:3000`
,
credentials
:
true
,
})
);
...
...
@@ -20,27 +19,9 @@ app.use(express.urlencoded({ extended: true }));
app
.
use
(
"/login"
,
loginRouter
);
app
.
use
(
"/db"
,
dbRouter
);
// fs.readFile("server/libs/login.pvdata", "utf8", async (err, data) => {
// if (err) {
// console.error(err);
// console.log("server/libs/login.pvdata에 ID\\nPW를 작성");
// return;
// }
// const page = await login(...data.split("\r\n"));
// if (page) {
// const feed = await getPeed(page);
// const subjects = await getSubjects(page);
// console.log({ feed, subjects });
// app.listen(3001, function () {
// console.log("listening on 3001");
// });
// } else console.log("Incorrect user ID or password.");
// });
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
"../build"
)));
app
.
get
(
"*"
,
function
(
요청
,
응답
)
{
응답
.
sendFile
(
path
.
join
(
__dirname
,
"../build/index.html"
));
app
.
get
(
"*"
,
function
(
req
,
res
)
{
res
.
sendFile
(
path
.
join
(
__dirname
,
"../build/index.html"
));
});
app
.
listen
(
3001
,
function
()
{
...
...
src/components/GridItem.js
View file @
aa96906
...
...
@@ -30,15 +30,15 @@ const GridItem = ({ targetDate }) => {
day
:
targetDate
.
getDay
(),
};
const
{
data
:
scdate
}
=
await
axios
.
get
(
"http://3.34.173.161:3001/db/schedules_date"
,
`http://
${
process
.
env
.
REACT_APP_SERVER_IP
}
:3001/db/schedules_date`
,
{
params
}
);
const
{
data
:
sctime
}
=
await
axios
.
get
(
"http://3.34.173.161:3001/db/schedules_time"
,
`http://
${
process
.
env
.
REACT_APP_SERVER_IP
}
:3001/db/schedules_time`
,
{
params
}
);
const
{
data
:
scrpeat
}
=
await
axios
.
get
(
"http://3.34.173.161:3001/db/schedules_repeat"
,
`http://
${
process
.
env
.
REACT_APP_SERVER_IP
}
:3001/db/schedules_repeat`
,
{
params
}
);
const
subs
=
await
localforage
.
getItem
(
"subjects"
);
...
...
@@ -58,13 +58,16 @@ const GridItem = ({ targetDate }) => {
const
finishSchedule
=
async
(
table
,
uid
)
=>
{
for
(
const
i
in
schedules
)
if
(
schedules
[
i
].
uid
===
uid
)
{
await
axios
.
delete
(
"http://3.34.173.161:3001/db/schedule"
,
{
data
:
{
table
,
uid
,
userID
:
await
localforage
.
getItem
(
"userID"
),
},
});
await
axios
.
delete
(
`http://
${
process
.
env
.
REACT_APP_SERVER_IP
}
:3001/db/schedule`
,
{
data
:
{
table
,
uid
,
userID
:
await
localforage
.
getItem
(
"userID"
),
},
}
);
schedules
.
splice
(
i
,
1
);
setSchedules
(
schedules
);
}
...
...
@@ -81,7 +84,7 @@ const GridItem = ({ targetDate }) => {
const
table
=
state
.
startTime
||
state
.
endTime
?
"schedules_time"
:
"schedules_date"
;
const
{
data
:
sche
}
=
await
axios
.
post
(
"http://3.34.173.161:3001/db/"
+
table
,
`http://
${
process
.
env
.
REACT_APP_SERVER_IP
}
:3001/db/`
+
table
,
{
userID
:
await
localforage
.
getItem
(
"userID"
),
...
state
,
...
...
src/components/ScheduleItem.js
View file @
aa96906
...
...
@@ -75,7 +75,7 @@ const ScheduleItem = ({ schedule, finish }) => {
<
div
className
=
"spl"
>
<
span
>
{
subjectName
}
<
/span
>
{
url
?
(
<
a
href
=
{
url
}
target
=
"_blank"
>
<
a
href
=
{
url
}
target
=
"_blank"
rel
=
"noreferrer"
>
{
label
}
<
/a
>
)
:
(
...
...
src/pages/Calendar.js
View file @
aa96906
...
...
@@ -19,22 +19,28 @@ const render = (subsObj, args) => {
case
"CHECKED"
:
sub
=
subsObj
[
args
.
subjectID
];
sub
.
status
=
!
sub
.
status
;
axios
.
put
(
"http://3.34.173.161:3001/db/user-subject/check"
,
{
userID
:
sub
.
userID
,
subjectID
:
args
.
subjectID
,
status
:
+
sub
.
status
,
});
axios
.
put
(
`http://
${
process
.
env
.
REACT_APP_SERVER_IP
}
:3001/db/user-subject/check`
,
{
userID
:
sub
.
userID
,
subjectID
:
args
.
subjectID
,
status
:
+
sub
.
status
,
}
);
return
{
...
subsObj
,
[
args
.
subjectID
]:
sub
};
case
"MODIFY"
:
sub
=
subsObj
[
args
.
subjectID
];
sub
.
nickname
=
args
.
nickname
;
sub
.
color
=
args
.
color
;
axios
.
put
(
"http://3.34.173.161:3001/db/user-subject/modify"
,
{
userID
:
sub
.
userID
,
subjectID
:
args
.
subjectID
,
nickname
:
sub
.
nickname
,
color
:
sub
.
color
,
});
axios
.
put
(
`http://
${
process
.
env
.
REACT_APP_SERVER_IP
}
:3001/db/user-subject/modify`
,
{
userID
:
sub
.
userID
,
subjectID
:
args
.
subjectID
,
nickname
:
sub
.
nickname
,
color
:
sub
.
color
,
}
);
return
{
...
subsObj
,
[
args
.
subjectID
]:
sub
};
case
"INIT"
:
return
args
.
subsObj
;
...
...
@@ -59,7 +65,7 @@ const Calendar = () => {
// get user's subjects
const
userID
=
await
localforage
.
getItem
(
"userID"
);
const
{
data
:
subjects
}
=
await
axios
.
get
(
"http://3.34.173.161:3001/db/user-subject"
,
`http://
${
process
.
env
.
REACT_APP_SERVER_IP
}
:3001/db/user-subject`
,
{
params
:
{
userID
}
}
);
await
localforage
.
setItem
(
"subjects"
,
subjects
);
...
...
src/pages/Debug.js
View file @
aa96906
import
axios
from
"axios"
;
//
import axios from "axios";
import
{
useState
}
from
"react"
;
import
{
useNavigate
}
from
"react-router-dom"
;
//import { login } from "../libs/E_Campus";
...
...
@@ -31,7 +31,7 @@ const Debug = () => {
// case "server":
// setState({ ...state, output: "loading..." });
// axios
// .post(
"http://3.34.173.161:3001/login/"
, {
// .post(
`http://${process.env.REACT_APP_SERVER_IP}:3001/login/`
, {
// id: state.input1,
// pw: state.input2,
// })
...
...
src/pages/Login.js
View file @
aa96906
...
...
@@ -25,23 +25,26 @@ const Login = () => {
const
login
=
async
()
=>
{
setState
({
...
state
,
btn
:
"Login..."
});
const
{
data
:
userDBID
}
=
await
axios
.
get
(
"http://3.34.173.161:3001/db/users"
,
`http://
${
process
.
env
.
REACT_APP_SERVER_IP
}
:3001/db/users`
,
{
params
:
{
loginID
:
state
.
id
}
}
);
if
(
userDBID
)
{
//pass crawling, just ical
const
{
data
:
peed
}
=
await
axios
.
get
(
"http://3.34.173.161:3001/db/users/ical"
,
`http://
${
process
.
env
.
REACT_APP_SERVER_IP
}
:3001/db/users/ical`
,
{
params
:
{
ID
:
userDBID
}
}
);
await
axios
.
put
(
"http://3.34.173.161:3001/db/ical"
,
{
userID
:
userDBID
,
peed
:
peed
.
ical
,
});
await
axios
.
put
(
`http://
${
process
.
env
.
REACT_APP_SERVER_IP
}
:3001/db/ical`
,
{
userID
:
userDBID
,
peed
:
peed
.
ical
,
}
);
const
hashpw
=
cryptoJs
.
SHA256
(
state
.
pw
).
toString
();
const
{
data
:
isCorrectPW
}
=
await
axios
.
get
(
"http://3.34.173.161:3001/db/users/check"
,
`http://
${
process
.
env
.
REACT_APP_SERVER_IP
}
:3001/db/users/check`
,
{
params
:
{
loginID
:
state
.
id
,
loginPW
:
hashpw
},
}
...
...
@@ -57,7 +60,7 @@ const Login = () => {
}
else
{
//crawling
const
{
data
:
loginResult
}
=
await
axios
.
post
(
"http://3.34.173.161:3001/login/"
,
`http://
${
process
.
env
.
REACT_APP_SERVER_IP
}
:3001/login/`
,
{
id
:
state
.
id
,
pw
:
state
.
pw
,
...
...
Please
register
or
login
to post a comment