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-03 00:40:18 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
76aba681b27184a4c140a0e4d1031affb7089c37
76aba681
1 parent
d305ac8a
[Implement] Sync with server
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
34 deletions
package-lock.json
package.json
server/libs/E_Campus.js
server/routers/login.js
server/server.js
src/pages/Debug.js
package-lock.json
View file @
76aba68
...
...
@@ -12,6 +12,8 @@
"@testing-library/react"
:
"^13.2.0"
,
"@testing-library/user-event"
:
"^13.5.0"
,
"axios"
:
"^0.27.2"
,
"body-parser"
:
"^1.20.0"
,
"cors"
:
"^2.8.5"
,
"express"
:
"^4.18.1"
,
"fs"
:
"^0.0.1-security"
,
"localforage"
:
"^1.10.0"
,
...
...
@@ -5568,6 +5570,18 @@
"resolved"
:
"https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz"
,
"integrity"
:
"sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
},
"node_modules/cors"
:
{
"version"
:
"2.8.5"
,
"resolved"
:
"https://registry.npmjs.org/cors/-/cors-2.8.5.tgz"
,
"integrity"
:
"sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g=="
,
"dependencies"
:
{
"object-assign"
:
"^4"
,
"vary"
:
"^1"
},
"engines"
:
{
"node"
:
">= 0.10"
}
},
"node_modules/cosmiconfig"
:
{
"version"
:
"7.0.1"
,
"resolved"
:
"https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz"
,
...
...
@@ -20602,6 +20616,15 @@
"resolved"
:
"https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz"
,
"integrity"
:
"sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
},
"cors"
:
{
"version"
:
"2.8.5"
,
"resolved"
:
"https://registry.npmjs.org/cors/-/cors-2.8.5.tgz"
,
"integrity"
:
"sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g=="
,
"requires"
:
{
"object-assign"
:
"^4"
,
"vary"
:
"^1"
}
},
"cosmiconfig"
:
{
"version"
:
"7.0.1"
,
"resolved"
:
"https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz"
,
...
...
package.json
View file @
76aba68
...
...
@@ -7,6 +7,8 @@
"@testing-library/react"
:
"^13.2.0"
,
"@testing-library/user-event"
:
"^13.5.0"
,
"axios"
:
"^0.27.2"
,
"body-parser"
:
"^1.20.0"
,
"cors"
:
"^2.8.5"
,
"express"
:
"^4.18.1"
,
"fs"
:
"^0.0.1-security"
,
"localforage"
:
"^1.10.0"
,
...
...
@@ -22,7 +24,7 @@
"build"
:
"react-scripts build"
,
"test"
:
"react-scripts test"
,
"eject"
:
"react-scripts eject"
,
"server"
:
"nodemon server/server.js"
"server"
:
"nodemon
-w ./server
server/server.js"
},
"eslintConfig"
:
{
"extends"
:
[
...
...
server/libs/E_Campus.js
View file @
76aba68
...
...
@@ -39,7 +39,7 @@ async function login(id, pw) {
)
{
return
false
;
}
else
{
//
await page.goto('https://khcanvas.khu.ac.kr');
//
내 강의실
let
selector
=
"#visual > div > div.xn-main-login-container > div:nth-child(2) > div.xn-main-link-wrap.xn-main-lms-link-wrap > a"
;
await
page
.
waitForSelector
(
selector
);
...
...
@@ -50,16 +50,13 @@ async function login(id, pw) {
}
catch
(
err
)
{
console
.
log
(
err
);
}
return
result
;
}
//function that get your peed for your Ecampus calendar
async
function
getPeed
(
page
)
{
console
.
log
(
"getPeed"
);
selector
=
"#global_nav_calendar_link > div.menu-item-icon-container > svg"
;
await
page
.
waitForSelector
(
selector
);
await
page
.
click
(
selector
);
await
Promise
.
all
([
page
.
click
(
selector
),
page
.
waitForNavigation
()]
);
selector
=
"#calendar-feed > button"
;
await
page
.
waitForSelector
(
selector
);
...
...
@@ -86,7 +83,6 @@ async function getPeed(page) {
}
async
function
getSubjects
(
page
)
{
console
.
log
(
"getSubjects"
);
await
page
.
click
(
"#global_nav_courses_link > div.menu-item-icon-container > svg"
);
...
...
server/routers/login.js
0 → 100644
View file @
76aba68
const
express
=
require
(
"express"
);
const
router
=
express
.
Router
();
const
{
getPeed
,
getSubjects
,
login
}
=
require
(
"../libs/E_Campus.js"
);
router
.
post
(
"/"
,
async
(
req
,
res
)
=>
{
console
.
log
(
`listened /login
${
req
.
body
.
id
}
${
req
.
body
.
pw
}
`
);
const
page
=
await
login
(
req
.
body
.
id
,
req
.
body
.
pw
);
if
(
page
)
{
const
peed
=
await
getPeed
(
page
);
res
.
send
(
peed
);
}
else
res
.
send
(
"failed"
);
});
module
.
exports
=
router
;
server/server.js
View file @
76aba68
const
express
=
require
(
"express"
);
const
{
getPeed
,
getSubjects
,
login
}
=
require
(
"./libs/E_Campus.js
"
);
const
bodyParser
=
require
(
"body-parser
"
);
const
fs
=
require
(
"fs"
);
const
cors
=
require
(
"cors"
);
const
{
getPeed
,
getSubjects
,
login
}
=
require
(
"./libs/E_Campus.js"
);
const
loginRouter
=
require
(
"./routers/login"
);
const
app
=
express
();
const
router
=
express
.
Router
();
router
.
get
(
"/"
,
(
req
,
res
)
=>
{
console
.
log
(
req
);
res
.
header
(
"Access-Control-Allow-Origin"
,
"http://localhost:3000"
);
res
.
send
({
test
:
"Hi"
});
app
.
use
(
cors
({
origin
:
"http://localhost:3000"
,
credentials
:
true
,
})
);
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
app
.
use
(
bodyParser
.
json
());
app
.
post
(
"/"
,
(
req
,
res
)
=>
{
res
.
send
({
body
:
req
.
body
});
console
.
log
(
"listened /"
);
});
app
.
use
(
"/"
,
router
);
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
(
"/login"
,
loginRouter
);
// 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
.
listen
(
3001
,
function
()
{
console
.
log
(
"listening on 3001"
);
});
...
...
src/pages/Debug.js
View file @
76aba68
...
...
@@ -35,8 +35,13 @@ const Debug = () => {
break
;
case
"server"
:
axios
.
get
(
"http://localhost:3001/"
)
.
then
((
res
)
=>
setState
({
...
state
,
output
:
res
.
data
.
test
}));
.
post
(
"http://localhost:3001/login/"
,
{
id
:
state
.
input1
,
pw
:
state
.
input2
,
})
.
then
((
res
)
=>
{
setState
({
...
state
,
output
:
res
.
data
});
});
return
;
default
:
}
...
...
Please
register
or
login
to post a comment