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-07 20:27:58 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
acba6c538383b1a83082860e0ea434d706747e21
acba6c53
1 parent
a08399ab
Complete
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
110 additions
and
68 deletions
README.md
jsconfig.json
server/libs/MySQL.js
server/libs/test.js
server/routers/DB.js
server/routers/login.js → server/routers/Login.js
server/routers/Users.js
server/schema.sql
server/server.js
src/components/GridItem.js
src/pages/Calendar.js
src/pages/Debug.js
src/pages/Home.js
src/pages/Login.js
src/pages/Settings.js
README.md
View file @
acba6c5
...
...
@@ -17,6 +17,7 @@
```
sh
npm install
npm -g install nodemon
```
### Run
...
...
jsconfig.json
0 → 100644
View file @
acba6c5
{
"compilerOptions"
:
{
"baseUrl"
:
"src"
}
}
\ No newline at end of file
server/libs/MySQL.js
View file @
acba6c5
...
...
@@ -7,7 +7,7 @@ const [id, pw] = fs
.
readFileSync
(
"server/libs/sql.pvdata"
,
"utf8"
)
.
split
(
"\r\n"
);
const
connectOption
=
{
host
:
"
localhost
"
,
host
:
"
extended-calendar-db.cihyg6ssq3la.ap-northeast-2.rds.amazonaws.com
"
,
user
:
id
,
password
:
pw
,
database
:
"db"
,
...
...
@@ -53,11 +53,10 @@ async function jcalToSQL(jcal, userID) {
else
console
.
log
(
"unexpected scheType"
,
sche
);
}
let
result
=
await
connection
.
query
(
dateQueryString
,
[
dateSchedules
]);
console
.
log
(
`schedules_date |
${
result
}
`
);
result
=
await
connection
.
query
(
timeQueryString
,
[
timeSchedules
]);
console
.
log
(
`schedules_time |
${
result
}
`
);
let
[
result
]
=
await
connection
.
query
(
dateQueryString
,
[
dateSchedules
]);
console
.
log
(
"ICAL schedules_date | "
+
result
.
affectedRows
);
[
result
]
=
await
connection
.
query
(
timeQueryString
,
[
timeSchedules
]);
console
.
log
(
"ICAL schedules_time | "
+
result
.
affectedRows
);
connection
.
end
();
}
...
...
server/libs/test.js
View file @
acba6c5
...
...
@@ -6,12 +6,10 @@ const { login } = require("./E_Campus.js");
const
parseICal
=
require
(
"./ICal.js"
);
async
function
runrun
()
{
const
{
data
:
ical
}
=
await
axios
({
url
:
"https://khcanvas.khu.ac.kr/feeds/calendars/user_YzxoryVh1hAQTeUJRljeaYavgmw1OXEGKIzNVpnI.ics"
,
method
:
"GET"
,
responseType
:
"blob"
,
});
const
Jcal
=
parseICal
(
ical
);
console
.
log
(
Jcal
);
const
mdata
=
await
axios
.
get
(
"http://localhost:3001/db/users"
,
{
params
:{
loginID
:
"good1588"
}}
)
console
.
log
(
mdata
.
data
)
}
runrun
();
...
...
server/routers/DB.js
View file @
acba6c5
const
{
default
:
axios
}
=
require
(
"axios"
);
const
express
=
require
(
"express"
);
const
mysql2
=
require
(
"mysql2/promise"
);
const
{
connectOption
}
=
require
(
"../libs/MySQL"
);
const
parseICal
=
require
(
"../libs/ICal"
);
const
{
connectOption
,
jcalToSQL
}
=
require
(
"../libs/MySQL"
);
const
dbRouter
=
express
.
Router
();
const
schedules_dateRouter
=
require
(
"./
s
chedules_date"
);
const
schedules_dateRouter
=
require
(
"./
S
chedules_date"
);
const
schedules_repeatRouter
=
require
(
"./Schedules_repeat"
);
const
schedules_timeRouter
=
require
(
"./Schedules_time"
);
const
subjectsRouter
=
require
(
"./Subjects"
);
const
userSubjectRouter
=
require
(
"./
u
ser-subject"
);
const
userSubjectRouter
=
require
(
"./
U
ser-subject"
);
const
usersRouter
=
require
(
"./Users"
);
async
function
route
()
{
...
...
@@ -29,6 +31,24 @@ async function route() {
}
});
// (userID, peed)
dbRouter
.
put
(
"/ical"
,
async
(
req
,
res
)
=>
{
console
.
log
(
"put /db/ical"
);
try
{
const
{
data
:
ical
}
=
await
axios
({
url
:
req
.
body
.
peed
,
method
:
"GET"
,
responseType
:
"blob"
,
});
await
jcalToSQL
(
parseICal
(
ical
),
req
.
body
.
userID
);
res
.
end
();
}
catch
(
e
)
{
console
.
log
(
e
);
res
.
end
();
}
});
dbRouter
.
use
(
"/user-subject"
,
userSubjectRouter
);
dbRouter
.
use
(
"/users"
,
usersRouter
);
dbRouter
.
use
(
"/subjects"
,
subjectsRouter
);
...
...
server/routers/
l
ogin.js
→
server/routers/
L
ogin.js
View file @
acba6c5
...
...
@@ -14,19 +14,19 @@ router.post("/", async (req, res) => {
try
{
const
{
peed
,
subjects
}
=
result
;
const
resUser
=
await
axios
.
post
(
"http://
localhost
:3001/db/users"
,
{
const
resUser
=
await
axios
.
post
(
"http://
3.34.173.161
: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://
localhost
:3001/db/subjects/s"
,
"http://
3.34.173.161
:3001/db/subjects/s"
,
{
list
:
subjects
,
}
);
await
axios
.
post
(
"http://
localhost
:3001/db/user-subject/s"
,
{
await
axios
.
post
(
"http://
3.34.173.161
:3001/db/user-subject/s"
,
{
userID
,
subList
,
});
...
...
server/routers/Users.js
View file @
acba6c5
...
...
@@ -56,6 +56,21 @@ async function route() {
res
.
end
();
}
});
// (ID) => ical
usersRouter
.
get
(
"/ical"
,
async
(
req
,
res
)
=>
{
console
.
log
(
"/db/users/ical"
);
try
{
const
queryString
=
`
SELECT ical FROM users us
WHERE us.ID = '
${
req
.
query
.
ID
}
'`
;
const
[
results
]
=
await
connection
.
query
(
queryString
);
res
.
send
(
results
[
0
]);
}
catch
(
e
)
{
console
.
log
(
e
);
res
.
end
();
}
});
}
route
();
...
...
server/schema.sql
deleted
100644 → 0
View file @
a08399a
This diff is collapsed. Click to expand it.
server/server.js
View file @
acba6c5
...
...
@@ -4,24 +4,19 @@ const cors = require("cors");
const
loginRouter
=
require
(
"./routers/Login"
);
const
dbRouter
=
require
(
"./routers/DB"
);
const
path
=
require
(
"path"
);
const
app
=
express
();
app
.
use
(
cors
({
origin
:
"http://
localhost
:3000"
,
origin
:
"http://
3.34.173.161
:3000"
,
credentials
:
true
,
})
);
// app.use(bodyParser.urlencoded({ extended: false }));
// app.use(bodyParser.json());
app
.
use
(
express
.
json
());
app
.
use
(
express
.
urlencoded
({
extended
:
true
}));
app
.
post
(
"/"
,
(
req
,
res
)
=>
{
console
.
log
(
"/"
);
});
app
.
use
(
"/login"
,
loginRouter
);
app
.
use
(
"/db"
,
dbRouter
);
...
...
@@ -43,6 +38,11 @@ app.use("/db", dbRouter);
// } 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
.
listen
(
3001
,
function
()
{
console
.
log
(
"listening on 3001"
);
});
...
...
src/components/GridItem.js
View file @
acba6c5
...
...
@@ -30,15 +30,15 @@ const GridItem = ({ targetDate }) => {
day
:
targetDate
.
getDay
(),
};
const
{
data
:
scdate
}
=
await
axios
.
get
(
"http://
localhost
:3001/db/schedules_date"
,
"http://
3.34.173.161
:3001/db/schedules_date"
,
{
params
}
);
const
{
data
:
sctime
}
=
await
axios
.
get
(
"http://
localhost
:3001/db/schedules_time"
,
"http://
3.34.173.161
:3001/db/schedules_time"
,
{
params
}
);
const
{
data
:
scrpeat
}
=
await
axios
.
get
(
"http://
localhost
:3001/db/schedules_repeat"
,
"http://
3.34.173.161
:3001/db/schedules_repeat"
,
{
params
}
);
const
subs
=
await
localforage
.
getItem
(
"subjects"
);
...
...
@@ -58,7 +58,7 @@ const GridItem = ({ targetDate }) => {
const
finishSchedule
=
async
(
table
,
uid
)
=>
{
for
(
const
i
in
schedules
)
if
(
schedules
[
i
].
uid
===
uid
)
{
await
axios
.
delete
(
"http://
localhost
:3001/db/schedule"
,
{
await
axios
.
delete
(
"http://
3.34.173.161
:3001/db/schedule"
,
{
data
:
{
table
,
uid
,
...
...
@@ -81,7 +81,7 @@ const GridItem = ({ targetDate }) => {
const
table
=
state
.
startTime
||
state
.
endTime
?
"schedules_time"
:
"schedules_date"
;
const
{
data
:
sche
}
=
await
axios
.
post
(
"http://
localhost
:3001/db/"
+
table
,
"http://
3.34.173.161
:3001/db/"
+
table
,
{
userID
:
await
localforage
.
getItem
(
"userID"
),
...
state
,
...
...
src/pages/Calendar.js
View file @
acba6c5
...
...
@@ -16,7 +16,7 @@ const render = (subsObj, args) => {
case
"CHECKED"
:
sub
=
subsObj
[
args
.
subjectID
];
sub
.
status
=
!
sub
.
status
;
axios
.
put
(
"http://
localhost
:3001/db/user-subject/check"
,
{
axios
.
put
(
"http://
3.34.173.161
:3001/db/user-subject/check"
,
{
userID
:
sub
.
userID
,
subjectID
:
args
.
subjectID
,
status
:
+
sub
.
status
,
...
...
@@ -26,7 +26,7 @@ const render = (subsObj, args) => {
sub
=
subsObj
[
args
.
subjectID
];
sub
.
nickname
=
args
.
nickname
;
sub
.
color
=
args
.
color
;
axios
.
put
(
"http://
localhost
:3001/db/user-subject/modify"
,
{
axios
.
put
(
"http://
3.34.173.161
:3001/db/user-subject/modify"
,
{
userID
:
sub
.
userID
,
subjectID
:
args
.
subjectID
,
nickname
:
sub
.
nickname
,
...
...
@@ -41,7 +41,7 @@ const render = (subsObj, args) => {
};
const
Calendar
=
()
=>
{
console
.
log
(
"visit Calendar"
);
//
console.log("visit Calendar");
const
[
state
,
setState
]
=
useState
({
scope
:
"month"
,
...
...
@@ -56,7 +56,7 @@ const Calendar = () => {
// get user's subjects
const
userID
=
await
localforage
.
getItem
(
"userID"
);
const
{
data
:
subjects
}
=
await
axios
.
get
(
"http://
localhost
:3001/db/user-subject"
,
"http://
3.34.173.161
:3001/db/user-subject"
,
{
params
:
{
userID
}
}
);
await
localforage
.
setItem
(
"subjects"
,
subjects
);
...
...
src/pages/Debug.js
View file @
acba6c5
...
...
@@ -6,7 +6,7 @@ import { useNavigate } from "react-router-dom";
import
"../styles/Debug.css"
;
const
Debug
=
()
=>
{
console
.
log
(
"visit Debug"
);
//
console.log("visit Debug");
const
[
state
,
setState
]
=
useState
({
type
:
"login"
,
...
...
@@ -23,25 +23,25 @@ const Debug = () => {
};
const
handleSubmit
=
async
(
e
)
=>
{
let
result
;
switch
(
state
.
type
)
{
case
"login"
:
//result = login(state.input1, state.input2);
break
;
case
"server"
:
setState
({
...
state
,
output
:
"loading..."
});
axios
.
post
(
"http://localhost
:3001/login/"
,
{
id
:
state
.
input1
,
pw
:
state
.
input2
,
})
.
then
((
res
)
=>
{
setState
({
...
state
,
output
:
res
.
data
});
});
return
;
default
:
}
setState
({
...
state
,
output
:
result
});
//
let result;
//
switch (state.type) {
//
case "login":
//
//result = login(state.input1, state.input2);
//
break;
//
case "server":
//
setState({ ...state, output: "loading..." });
//
axios
// .post("http://3.34.173.161
:3001/login/", {
//
id: state.input1,
//
pw: state.input2,
//
})
//
.then((res) => {
//
setState({ ...state, output: res.data });
//
});
//
return;
//
default:
//
}
//
setState({ ...state, output: result });
};
const
navigate
=
useNavigate
();
...
...
src/pages/Home.js
View file @
acba6c5
...
...
@@ -3,7 +3,7 @@ import { useEffect } from "react";
import
{
useNavigate
}
from
"react-router-dom"
;
const
Home
=
()
=>
{
console
.
log
(
"visit Home"
);
//
console.log("visit Home");
const
navigate
=
useNavigate
();
useEffect
(()
=>
{
...
...
src/pages/Login.js
View file @
acba6c5
...
...
@@ -7,7 +7,7 @@ import axios from "axios";
import
cryptoJs
from
"crypto-js"
;
const
Login
=
()
=>
{
console
.
log
(
"visit Login"
);
//
console.log("visit Login");
const
[
state
,
setState
]
=
useState
({
id
:
""
,
pw
:
""
,
...
...
@@ -25,19 +25,23 @@ const Login = () => {
const
login
=
async
()
=>
{
setState
({
...
state
,
btn
:
"Login..."
});
const
{
data
:
userDBID
}
=
await
axios
.
get
(
"http://localhost:3001/db/users"
,
{
params
:
{
loginID
:
state
.
id
,
},
}
"http://3.34.173.161:3001/db/users"
,
{
params
:
{
loginID
:
state
.
id
}
}
);
if
(
userDBID
)
{
//pass crawling
//pass crawling, just ical
const
{
data
:
peed
}
=
await
axios
.
get
(
"http://3.34.173.161:3001/db/users/ical"
,
{
params
:
{
ID
:
userDBID
}
}
);
await
axios
.
put
(
"http://3.34.173.161:3001/db/ical"
,
{
userID
:
userDBID
,
peed
:
peed
.
ical
,
});
const
hashpw
=
cryptoJs
.
SHA256
(
state
.
pw
).
toString
();
const
{
data
:
isCorrectPW
}
=
await
axios
.
get
(
"http://
localhost
:3001/db/users/check"
,
"http://
3.34.173.161
:3001/db/users/check"
,
{
params
:
{
loginID
:
state
.
id
,
loginPW
:
hashpw
},
}
...
...
@@ -53,7 +57,7 @@ const Login = () => {
}
else
{
//crawling
const
{
data
:
loginResult
}
=
await
axios
.
post
(
"http://
localhost
:3001/login/"
,
"http://
3.34.173.161
:3001/login/"
,
{
id
:
state
.
id
,
pw
:
state
.
pw
,
...
...
src/pages/Settings.js
View file @
acba6c5
...
...
@@ -4,7 +4,7 @@ import { Navigate, useNavigate } from "react-router-dom";
import
"../styles/Settings.css"
;
const
Settings
=
()
=>
{
console
.
log
(
"visit Settings"
);
//
console.log("visit Settings");
const
session
=
localforage
.
getItem
(
"session"
);
...
...
Please
register
or
login
to post a comment