Showing
6 changed files
with
130 additions
and
18 deletions
... | @@ -11,7 +11,7 @@ async function route() { | ... | @@ -11,7 +11,7 @@ async function route() { |
11 | // console.log("/db/schedules_date"); | 11 | // console.log("/db/schedules_date"); |
12 | try { | 12 | try { |
13 | const queryString = ` | 13 | const queryString = ` |
14 | - SELECT sc.label, sc.type, sc.description, sc.url, sc.detail, sbj.name, us.color | 14 | + SELECT sc.label, sc.type, sc.description, sc.url, sc.detail, sbj.name, us.nickname, us.color, sc.uid |
15 | FROM schedules_date sc | 15 | FROM schedules_date sc |
16 | INNER JOIN \`user-subject\` us | 16 | INNER JOIN \`user-subject\` us |
17 | ON sc.userID = us.userID | 17 | ON sc.userID = us.userID | ... | ... |
server/routers/Schedules_time.js
0 → 100644
1 | +const express = require("express"); | ||
2 | +const mysql2 = require("mysql2/promise"); | ||
3 | +const { connectOption } = require("../libs/MySQL"); | ||
4 | +const schedules_timeRouter = express.Router(); | ||
5 | + | ||
6 | +async function route() { | ||
7 | + const connection = await mysql2.createConnection(connectOption); | ||
8 | + | ||
9 | + // (userID, date) => schedules | ||
10 | + schedules_timeRouter.get("/", async (req, res) => { | ||
11 | + // console.log("/db/schedules_time"); | ||
12 | + try { | ||
13 | + const queryString = ` | ||
14 | + SELECT sc.label, sc.type, sc.description, sc.url, sc.detail, sbj.name, us.nickname, us.color, sc.uid, sc.startTime, sc.endTime | ||
15 | + FROM schedules_time sc | ||
16 | + INNER JOIN \`user-subject\` us | ||
17 | + ON sc.userID = us.userID | ||
18 | + AND sc.subjectID = us.subjectID | ||
19 | + AND us.status = 1 | ||
20 | + INNER JOIN subjects sbj | ||
21 | + ON sc.subjectID = sbj.ID | ||
22 | + WHERE sc.date = "${req.query.date}" | ||
23 | + AND sc.userID = ${req.query.userID} | ||
24 | + AND sc.status = 1 | ||
25 | + ORDER BY sc.endTime`; | ||
26 | + const [results] = await connection.query(queryString); | ||
27 | + res.send(results); | ||
28 | + } catch (e) { | ||
29 | + console.log(e); | ||
30 | + res.end(); | ||
31 | + } | ||
32 | + }); | ||
33 | +} | ||
34 | +route(); | ||
35 | + | ||
36 | +module.exports = schedules_timeRouter; |
... | @@ -16,13 +16,20 @@ const GridItem = ({ targetDate }) => { | ... | @@ -16,13 +16,20 @@ const GridItem = ({ targetDate }) => { |
16 | useEffect(() => { | 16 | useEffect(() => { |
17 | async function loadScheduleItems() { | 17 | async function loadScheduleItems() { |
18 | const userID = await localforage.getItem("userID"); | 18 | const userID = await localforage.getItem("userID"); |
19 | - const res = await axios.get("http://localhost:3001/db/schedules_date", { | 19 | + const params = { userID, date: toYMDStr(targetDate, "-") }; |
20 | - params: { | 20 | + const { data: scdate } = await axios.get( |
21 | - userID, | 21 | + "http://localhost:3001/db/schedules_date", |
22 | - date: toYMDStr(targetDate, "-"), | 22 | + { |
23 | - }, | 23 | + params, |
24 | - }); | 24 | + } |
25 | - setSchedules(res.data); | 25 | + ); |
26 | + const { data: sctime } = await axios.get( | ||
27 | + "http://localhost:3001/db/schedules_time", | ||
28 | + { | ||
29 | + params, | ||
30 | + } | ||
31 | + ); | ||
32 | + setSchedules(scdate.concat(sctime)); | ||
26 | } | 33 | } |
27 | loadScheduleItems(); | 34 | loadScheduleItems(); |
28 | }, [targetDate]); | 35 | }, [targetDate]); | ... | ... |
... | @@ -4,13 +4,15 @@ import ecampusSymbol from "../assets/e-Campus.png"; | ... | @@ -4,13 +4,15 @@ import ecampusSymbol from "../assets/e-Campus.png"; |
4 | const ScheduleItem = ({ schedule }) => { | 4 | const ScheduleItem = ({ schedule }) => { |
5 | const { | 5 | const { |
6 | name: subjectName, | 6 | name: subjectName, |
7 | + nickname: subjectNickname, | ||
8 | + uid: scheID, | ||
7 | color: subjectColor, | 9 | color: subjectColor, |
10 | + url, | ||
8 | type, | 11 | type, |
9 | label, | 12 | label, |
10 | description, | 13 | description, |
11 | - url, | ||
12 | detail, | 14 | detail, |
13 | - startTime = null, | 15 | + startTime = null, //HHMMSS문자열 |
14 | endTime = null, | 16 | endTime = null, |
15 | } = schedule; | 17 | } = schedule; |
16 | 18 | ||
... | @@ -28,17 +30,47 @@ const ScheduleItem = ({ schedule }) => { | ... | @@ -28,17 +30,47 @@ const ScheduleItem = ({ schedule }) => { |
28 | return symbol; | 30 | return symbol; |
29 | }; | 31 | }; |
30 | 32 | ||
33 | + const click = (e) => { | ||
34 | + let target; | ||
35 | + if (e.target.className === "ScheduleItem") target = e.target; | ||
36 | + else if (e.target.classList.contains("ss")) target = e.target.offsetParent; | ||
37 | + else { | ||
38 | + if (e.target.className === "spc") | ||
39 | + e.target.offsetParent.style.display = "none"; | ||
40 | + return; | ||
41 | + } | ||
42 | + | ||
43 | + target.lastChild.style.display = "grid"; | ||
44 | + }; | ||
45 | + | ||
31 | return ( | 46 | return ( |
32 | - <div className="ScheduleItem" style={{ borderColor: "#" + subjectColor }}> | 47 | + <div |
33 | - <img className="s_symbol" src={selectSymbol()} alt="404" /> | 48 | + className="ScheduleItem" |
49 | + style={{ borderColor: "#" + subjectColor }} | ||
50 | + onClick={click} | ||
51 | + > | ||
52 | + <img className="s_symbol ss" src={selectSymbol()} alt="404" /> | ||
34 | {startTime && ( | 53 | {startTime && ( |
35 | - <span className="s_start">{startTime[0] + ":" + startTime[1]}</span> | 54 | + <span className="s_start ss">{startTime.substring(0, 5)}</span> |
36 | )} | 55 | )} |
37 | - {endTime && ( | 56 | + {endTime && <span className="s_end ss">{endTime.substring(0, 5)}</span>} |
38 | - <span className="s_end">{endTime[0] + ":" + endTime[1]}</span> | 57 | + <span className="s_slabel ss">{label}</span> |
58 | + | ||
59 | + <div className="s_popup"> | ||
60 | + <div className="spl"> | ||
61 | + <span>{subjectName}</span> | ||
62 | + {url ? ( | ||
63 | + <a href={url} target="_blank"> | ||
64 | + {label} | ||
65 | + </a> | ||
66 | + ) : ( | ||
67 | + <span>{label}</span> | ||
39 | )} | 68 | )} |
40 | - {/* <span className="s_category">{subjectName}</span> */} | 69 | + {description && <span>{description}</span>} |
41 | - <span className="s_slabel">{label}</span> | 70 | + {detail && <div dangerouslySetInnerHTML={{ __html: detail }}></div>} |
71 | + </div> | ||
72 | + <button className="spc">닫기</button> | ||
73 | + </div> | ||
42 | </div> | 74 | </div> |
43 | ); | 75 | ); |
44 | }; | 76 | }; | ... | ... |
... | @@ -52,6 +52,8 @@ button:disabled { | ... | @@ -52,6 +52,8 @@ button:disabled { |
52 | margin: 1px 0 1px 0; | 52 | margin: 1px 0 1px 0; |
53 | border: solid 3px bisque; | 53 | border: solid 3px bisque; |
54 | border-radius: 3px; | 54 | border-radius: 3px; |
55 | + cursor: pointer; | ||
56 | + position: relative; | ||
55 | } | 57 | } |
56 | 58 | ||
57 | .ScheduleItem > span { | 59 | .ScheduleItem > span { |
... | @@ -77,3 +79,38 @@ button:disabled { | ... | @@ -77,3 +79,38 @@ button:disabled { |
77 | border-radius: 3px; | 79 | border-radius: 3px; |
78 | padding: 0; | 80 | padding: 0; |
79 | } | 81 | } |
82 | + | ||
83 | +.s_popup { | ||
84 | + position: absolute; | ||
85 | + z-index: 1000; | ||
86 | + top: calc(100% + 5px); | ||
87 | + left: 20px; | ||
88 | + background: rgb(246, 246, 246); | ||
89 | + border: solid thin black; | ||
90 | + display: none; | ||
91 | + padding: 10px; | ||
92 | + cursor: auto; | ||
93 | + width: 300px; | ||
94 | +} | ||
95 | + | ||
96 | +.spl { | ||
97 | + display: flex; | ||
98 | + flex-direction: column; | ||
99 | +} | ||
100 | + | ||
101 | +.spl > * { | ||
102 | + margin-bottom: 5px; | ||
103 | +} | ||
104 | + | ||
105 | +.spl > div { | ||
106 | + background-color: white; | ||
107 | + border: solid 1px rgb(235, 235, 235); | ||
108 | +} | ||
109 | + | ||
110 | +.spc { | ||
111 | + margin-top: 2px; | ||
112 | + margin-left: calc(100% - 50px); | ||
113 | + width: 50px; | ||
114 | + height: 35px; | ||
115 | + cursor: pointer; | ||
116 | +} | ... | ... |
... | @@ -35,7 +35,7 @@ aside { | ... | @@ -35,7 +35,7 @@ aside { |
35 | /* height: 150px; | 35 | /* height: 150px; |
36 | width: 250px; */ | 36 | width: 250px; */ |
37 | /* transform: translate(-50%, -50%); */ | 37 | /* transform: translate(-50%, -50%); */ |
38 | - background: rgb(241, 241, 241); | 38 | + background: rgb(246, 246, 246); |
39 | display: none; | 39 | display: none; |
40 | border: solid thin black; | 40 | border: solid thin black; |
41 | padding: 5px; | 41 | padding: 5px; | ... | ... |
-
Please register or login to post a comment