From fc48b77c8c03ed381bb67dc6c84a6775053e90b7 Mon Sep 17 00:00:00 2001 From: Han Kyuhyun Date: Thu, 21 Sep 2023 09:47:05 +0900 Subject: [PATCH 01/11] Add history front page. Signed-off-by: June Saehwan Co-authored-by: Han Kyuhyun Co-authored-by: ByunJeongHeum Co-authored-by: jongmin Lee --- frontend/public/image/png/Stroke.png | Bin 0 -> 1630 bytes frontend/public/image/svg/LeftArrow.svg | 3 + frontend/public/image/svg/OptionBoxStroke.svg | 17 + frontend/public/image/svg/RightArrow.svg | 3 + .../public/image/svg/historyMyOptionLine.svg | 3 + frontend/src/App.jsx | 3 + frontend/src/css/History_style.css | 207 ++++++++++ frontend/src/css/Home_style.css | 24 ++ frontend/src/css/User_style.css | 27 +- frontend/src/pages/History.jsx | 368 ++++++++++++++++++ frontend/src/pages/Home.jsx | 12 +- frontend/src/pages/User.jsx | 8 + 12 files changed, 670 insertions(+), 5 deletions(-) create mode 100644 frontend/public/image/png/Stroke.png create mode 100644 frontend/public/image/svg/LeftArrow.svg create mode 100644 frontend/public/image/svg/OptionBoxStroke.svg create mode 100644 frontend/public/image/svg/RightArrow.svg create mode 100644 frontend/public/image/svg/historyMyOptionLine.svg create mode 100644 frontend/src/css/History_style.css create mode 100644 frontend/src/pages/History.jsx diff --git a/frontend/public/image/png/Stroke.png b/frontend/public/image/png/Stroke.png new file mode 100644 index 0000000000000000000000000000000000000000..c79854352969f79c731cd61292b8b1d0d33e5a81 GIT binary patch literal 1630 zcmeAS@N?(olHy`uVBq!ia0y~yV7UTh&*ESMl8K?BZ9s~%z$3Dlfq`2Xgc%uT&5-~K zG8PB9J29*~C-V}>VM%xNb!1@J*w6hZk(Ggg^|PmoV@L(#+q(}7AGt{!e|S{%g5wje z1}-Mq30w-YFaJ<)UW0tVu&4a6 zK}_2I`_u2{m9N<@ciKGh?d=8M(tFeAo6SC}x`Yv^<{p*EipK z{<7p(frZSe3L8C;86PgrJ^$Q0M7r(a`l_GqyUTgAUaxy?cK-bNBq@;eo=b~v<(Oq# zU#(j`eRp=i@2JvyQ$b*};h?yUVjYLmepyK}8i$S~0=2ZkgA!;j1+u)QoS zrXVf{M;3?@5CFvzgMz{eke?hJ0+@kRL&E~FOBfx&Rx^!i91R>`vKUP{)Xp6upv*R3 zort^_6<{3-&c-`(CE8A3YPxmddo3tYGUWX>Uokf-;Pv*~xe)&C_uq4G_P$DtdH(ug zfyDXepCJXo{f`wo-@ku9UR8C!Y{lHyf8wTo{uu)@pyB_Pv~3YOw_YY&$L#;KbM@4> z-oG6~z{P<0^%-HeBfB$im%V>?_5J*|#ELm*)28d@fV6#>XlrXb_1dW{mdKI;Vst02{1|tpET3 literal 0 HcmV?d00001 diff --git a/frontend/public/image/svg/LeftArrow.svg b/frontend/public/image/svg/LeftArrow.svg new file mode 100644 index 00000000..3c586ad8 --- /dev/null +++ b/frontend/public/image/svg/LeftArrow.svg @@ -0,0 +1,3 @@ + + + diff --git a/frontend/public/image/svg/OptionBoxStroke.svg b/frontend/public/image/svg/OptionBoxStroke.svg new file mode 100644 index 00000000..44a2b0ff --- /dev/null +++ b/frontend/public/image/svg/OptionBoxStroke.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/frontend/public/image/svg/RightArrow.svg b/frontend/public/image/svg/RightArrow.svg new file mode 100644 index 00000000..4c98ff10 --- /dev/null +++ b/frontend/public/image/svg/RightArrow.svg @@ -0,0 +1,3 @@ + + + diff --git a/frontend/public/image/svg/historyMyOptionLine.svg b/frontend/public/image/svg/historyMyOptionLine.svg new file mode 100644 index 00000000..07d73ade --- /dev/null +++ b/frontend/public/image/svg/historyMyOptionLine.svg @@ -0,0 +1,3 @@ + + + diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index bb4f2cf6..55856c5a 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -10,6 +10,7 @@ import { BrowserRouter, Routes, Route } from "react-router-dom"; import Home from './pages/Home'; import Login from './pages/Login'; import User from './pages/User'; +import History from './pages/History'; function App() { return ( @@ -20,6 +21,8 @@ function App() { } /> } /> } /> + } /> + } /> diff --git a/frontend/src/css/History_style.css b/frontend/src/css/History_style.css new file mode 100644 index 00000000..a9293e8a --- /dev/null +++ b/frontend/src/css/History_style.css @@ -0,0 +1,207 @@ +/** + * Copyright 2023 kyudori, Basaeng, hwan5180, quswjdgma83 + * + * Use of this source code is governed by a MIT license that can be + * found in the LICENSE file. + */ + + .home { + background-color: #ffffff; + display: flex; + flex-direction: row; + justify-content: center; + width: 100%; + } + + .home .div { + background-color: #ffffff; + border: 1px none; + height: 1080px; + position: relative; + width: 1920px; + } + + .home .LPVS-info { + height: 896px; + left: 593px; + position: absolute; + top: 140px; + width: 1273px; + } + + .home .overlap-group { + background-color: #000000ba; + height: 800px; + position: relative; + width: 1265px; + top: -10px; + } + + .home .user-guide { + color: #ffffff; + font-family: "Inter-Medium", Helvetica; + font-size: 24px; + font-weight: 400; + left: 42px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 15px; + width: 1195px; + } + + .home .text-wrapper { + font-weight: 500; + } + + .home .span { + font-family: "Inter-Regular", Helvetica; + } + + .home .LPVS-logo { + height: 885px; + left: 15px; + position: absolute; + top: 125px; + width: 574px; + } + + .home .LPVS-github { + height: 407px; + left: 30px; + object-fit: cover; + position: absolute; + top: 400px; + width: 472px; + } + + .home .license-explain { + color: #00057b; + font-family: "Inter-Bold", Helvetica; + font-size: 60px; + font-weight: 700; + left: 56px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 80px; + } + + .home .text-wrapper-2 { + color: #80808275; + font-family: "Inter-Bold", Helvetica; + font-size: 70px; + font-weight: 700; + left: 56px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: -10px; + white-space: nowrap; + width: 217px; + } + + .home .menubar-top { + height: 101px; + left: 39px; + position: absolute; + top: 8px; + width: 1842px; + } + + .home .menu-line { + background-color: #0057b8; + height: 3px; + left: 0; + position: absolute; + top: 98px; + width: 1842px; + } + + .home .menu { + height: 43px; + left: 1270px; + position: absolute; + top: 37px; + width: 578px; + } + + .home .overlap { + height: 43px; + left: 302px; + position: absolute; + top: 0; + width: 272px; + } + + .home .profile { + height: 43px; + left: 136px; + position: absolute; + top: 0; + width: 135px; + } + + .home .overlap-group-2 { + background-color: #d9d9d9; + border-radius: 50px; + height: 43px; + position: relative; + width: 133px; + } + + .home .image { + height: 31px; + left: 11px; + object-fit: cover; + position: absolute; + top: 7px; + width: 35px; + } + + .home .text-wrapper-3 { + color: #000000; + font-family: "Inter-SemiBold", Helvetica; + font-size: 20px; + font-weight: 600; + left: 56px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 8px; + white-space: nowrap; + width: 71px; + } + + .home .text-wrapper-7 { + color: #000000; + font-family: "Inter-Regular", Helvetica; + font-size: 30px; + font-weight: 400; + left: 320px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 3px; + white-space: nowrap; + width: 104px; + } + + .home .profile-border { + background-color: #d9d9d9; + height: 3px; + left: 104px; + position: absolute; + top: 20px; + transform: rotate(-90deg); + width: 40px; + } + + .home .LPVS { + height: 96px; + left: 0; + object-fit: cover; + position: absolute; + top: 0; + width: 229px; + } \ No newline at end of file diff --git a/frontend/src/css/Home_style.css b/frontend/src/css/Home_style.css index bff757a7..ab11e0a8 100644 --- a/frontend/src/css/Home_style.css +++ b/frontend/src/css/Home_style.css @@ -173,6 +173,30 @@ width: 71px; } +.home .text-wrapper-7 { + color: #000000; + font-family: "Inter-Regular", Helvetica; + font-size: 30px; + font-weight: 400; + left: 320px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 3px; + white-space: nowrap; + width: 104px; +} + +.home .profile-border { + background-color: #d9d9d9; + height: 3px; + left: 104px; + position: absolute; + top: 20px; + transform: rotate(-90deg); + width: 40px; +} + .home .LPVS { height: 96px; left: 0; diff --git a/frontend/src/css/User_style.css b/frontend/src/css/User_style.css index f2d7dbf6..0d7fe5e9 100644 --- a/frontend/src/css/User_style.css +++ b/frontend/src/css/User_style.css @@ -220,7 +220,6 @@ white-space: nowrap; } - .user .admit-rect-2 { border: 1px solid; border-color: #000000; @@ -377,8 +376,6 @@ /* click effect eliminate border */ } - - .user .github-ID-box { height: 50px; left: 0; @@ -535,6 +532,30 @@ width: 150px; } + .user .text-wrapper-18 { + color: #000000; + font-family: "Inter-Regular", Helvetica; + font-size: 30px; + font-weight: 400; + left: 320px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 3px; + white-space: nowrap; + width: 104px; + } + + .user .profile-border { + background-color: #d9d9d9; + height: 3px; + left: 104px; + position: absolute; + top: 20px; + transform: rotate(-90deg); + width: 40px; + } + .user .LPVS { height: 96px; left: 0; diff --git a/frontend/src/pages/History.jsx b/frontend/src/pages/History.jsx new file mode 100644 index 00000000..657bcdd3 --- /dev/null +++ b/frontend/src/pages/History.jsx @@ -0,0 +1,368 @@ +/** + * Copyright 2023 kyudori, Basaeng, hwan5180, quswjdgma83 + * + * Use of this source code is governed by a MIT license that can be + * found in the LICENSE file. + */ + +import {React,useEffect, useState} from "react"; +import { Link, useParams, useLocation } from "react-router-dom"; +import { useNavigate } from "react-router-dom"; +import "../css/History_style.css"; +import axios from 'axios'; + +export const History= () => { + + const { type, name } = useParams(); + const [ lpvsHistories, setlpvsHistories ] = useState(); + const navigate = useNavigate(); + + const location = useLocation(); + const queryParams = new URLSearchParams(location.search); + const page = queryParams.get('page') || 0; + + + const [isLoggedIn, setIsLoggedIn] = useState(false); + const [username, setUsername] = useState(""); + + useEffect(() => { + axios.get("/login/check") + .then((loginresponse) => { + if (loginresponse.data.isLoggedIn) { + setIsLoggedIn(loginresponse.data.isLoggedIn); + axios.get("/user/info") + .then((userInfoResponse) => { + setUsername(userInfoResponse.data); + }) + .catch((error) => { + console.log("Error fetching user info:", error); + navigate("/login"); + }); + } else { + navigate("/login"); + } + }) + .catch((error) => { + console.log("Error checking login status:", error); + navigate("/login"); + }); + }, []); + + useEffect(() => { + axios + .get(`/history/${type}/${name}?page=${page}`) + .then((response) => { + console.log(response.data) + setlpvsHistories(response.data); + }) + .catch((error) => { + console.log(error); + const userChoice = window.confirm("Please enter the Organization information on the User page."); + if (userChoice) { + navigate('/user/info'); + } else { + navigate(`/history/send/${username?.nickname}?page=0`); + } + }); + }, [type, name, page]); + + const handlePageChange = (pageNumber) => { + navigate(`/history/${type}/${name}?page=${pageNumber}`); + }; + + const [isHistoriesEmpty, setIsHistoriesEmpty] = useState(false); + console.log(lpvsHistories?.lpvsHistories?.length) + useEffect(() => { + if (lpvsHistories?.lpvsHistories?.length === 0) { + setIsHistoriesEmpty(true); + } else { + setIsHistoriesEmpty(false); + } + }, [lpvsHistories, page]); + + console.log(lpvsHistories) + + const navigateToOrg = () => { + if (!username?.organization || username?.organization.trim() === "") { + window.alert("Please enter the Organization information on the User page."); + } else { + navigate(`/history/org/${username?.organization}?page=0`); + } + }; + const navigateToOwn = () => { + navigate(`/history/own/${username?.nickname}?page=0`); + }; + const navigateToSend = () => { + navigate(`/history/send/${username?.nickname}?page=0`); + }; + + + const [pageCount,setPageCount] = useState(1); + const [currentPage, setCurrentPage] = useState(1); + + useEffect(()=> { + setPageCount(Math.ceil(lpvsHistories?.count/5)) + }, [lpvsHistories?.count, currentPage]); + + console.log(pageCount); + + const check_page_plus =()=> { + if(currentPage <= pageCount) { + console.log(currentPage) + return setCurrentPage(currentPage+5); + } + else { + return + } + } + console.log(page); + console.log(currentPage); + const check_page_minus =(page)=> { + if(page <=4) { + return setCurrentPage(currentPage) + } + else { + return setCurrentPage(currentPage-5); + } + } + + const trueOrFalse =(a)=> { + if(a <= pageCount) { + return true; + } + else { + return false; + } + } + + const status_check=(a)=> { + if(a) { + return 'Issue-Detected'; + } + else { + return 'Scan-completed'; + } + } + console.log(lpvsHistories?.lpvsHistories[0]?.status) + + if (!lpvsHistories) { + return
Loading...
; + } + + const pageArrow=(page)=> { + if(page<=5) { + return false; + } + } + console.log(isHistoriesEmpty) + return ( +
+
+
+
+ +
+
+
+ {type === "send" ? +
My Pull Request
+ : +
My Pull Request
} +
+
+
+
+ {type === "own" ? +
My Repo PR
+ : +
My Repo PR
} +
+
+
+
+ {type === "org" ? +
My Org PR
+ : +
My Org PR
} +
+
+
+ +
+ My option line +
My Option
+
+
+
+
+
+ { + if (page > 4) { + check_page_minus(); + handlePageChange(currentPage - 2); + }}} style={{ cursor: "pointer" }} /> + {trueOrFalse(currentPage) &&
handlePageChange(currentPage-1)}>{currentPage}
} + {trueOrFalse(currentPage+1) &&
handlePageChange(currentPage)}>{currentPage+1}
} + {trueOrFalse(currentPage+2) &&
handlePageChange(currentPage+1)}>{currentPage+2}
} + {trueOrFalse(currentPage+3) &&
handlePageChange(currentPage+2)}>{currentPage+3}
} + {trueOrFalse(currentPage+4) &&
handlePageChange(currentPage+3)}>{currentPage+4}
} + {trueOrFalse(currentPage+5) ? {check_page_plus(); handlePageChange(currentPage + 4); }}style={{ cursor: "pointer" }}/> + : + } +
+
+
+
+ {lpvsHistories.lpvsHistories[4]?.status !== undefined ? ( + +
+
+ +
+ {lpvsHistories.lpvsHistories[4]?.repositoryName} +
+
+
+ {status_check(lpvsHistories.lpvsHistories[4]?.hasIssue)} +
+
+
+
+
{lpvsHistories.lpvsHistories[4]?.pullNumber}
+
+
+
+
+
+ +
{lpvsHistories.lpvsHistories[4]?.url}
+
{lpvsHistories.lpvsHistories[4]?.scanDate}
+
+
): null} + + {lpvsHistories.lpvsHistories[3]?.status !== undefined ? ( + +
+
+
+ {lpvsHistories.lpvsHistories[3]?.repositoryName} +
+
+
{status_check(lpvsHistories.lpvsHistories[3]?.hasIssue)}
+
+
+
+
+
{lpvsHistories.lpvsHistories[3]?.pullNumber}
+
+
+ +
+
+
{lpvsHistories.lpvsHistories[3]?.url}
+
{lpvsHistories.lpvsHistories[3]?.scanDate}
+
+
+ ): null} + + {lpvsHistories.lpvsHistories[2]?.status !== undefined ? ( + +
+
+
+ {lpvsHistories.lpvsHistories[2]?.repositoryName} +
+
+
{status_check(lpvsHistories.lpvsHistories[2]?.hasIssue)}
+
+
+
+
+
{lpvsHistories.lpvsHistories[2]?.pullNumber}
+
+
+
+
+
{lpvsHistories.lpvsHistories[2]?.url}
+
{lpvsHistories.lpvsHistories[2]?.scanDate}
+
+
+ + ): null} + + + {lpvsHistories.lpvsHistories[1]?.status !== undefined ? ( + +
+
+
+ {lpvsHistories.lpvsHistories[1]?.repositoryName} +
+
+
{status_check(lpvsHistories.lpvsHistories[1]?.hasIssue)}
+
+
+
+
+
{lpvsHistories.lpvsHistories[1]?.pullNumber}
+
+
+
+
+
{lpvsHistories.lpvsHistories[1]?.url}
+
{lpvsHistories.lpvsHistories[1]?.scanDate}
+
+
+ + ) : null} + {lpvsHistories.lpvsHistories[0]?.status !== undefined ? ( + +
+
+
+ {lpvsHistories.lpvsHistories[0]?.repositoryName} +
+
+
{status_check(lpvsHistories.lpvsHistories[0]?.hasIssue)}
+
+
+
+
+
{lpvsHistories.lpvsHistories[0]?.pullNumber}
+
+
+
+
+
{lpvsHistories.lpvsHistories[0]?.url}
+
{lpvsHistories.lpvsHistories[0]?.scanDate}
+
+
+ + ): null} + +
+
+
+
+
+
+
+
+
+ Image +
{username.name}
+
+
+
+
History
+ + Lpvs + +
+
+
+
+ ); +}; + +export default History; diff --git a/frontend/src/pages/Home.jsx b/frontend/src/pages/Home.jsx index d68d2982..57e098b3 100644 --- a/frontend/src/pages/Home.jsx +++ b/frontend/src/pages/Home.jsx @@ -87,8 +87,9 @@ export const Home = () => {
-
-
+ {isLoggedIn ? ( +
+ ): null}
img
@@ -117,6 +118,13 @@ export const Home = () => {
+
+ {isLoggedIn ? ( + + History + + ) : null} +
img diff --git a/frontend/src/pages/User.jsx b/frontend/src/pages/User.jsx index c85b7f80..344b9e61 100644 --- a/frontend/src/pages/User.jsx +++ b/frontend/src/pages/User.jsx @@ -275,6 +275,14 @@ export const User = () => {
+
+ + History + +
Date: Thu, 21 Sep 2023 10:27:02 +0900 Subject: [PATCH 02/11] Add History backend logic. Signed-off-by: jongmin Lee Co-authored-by: Han Kyuhyun Co-authored-by: ByunJeongHeum Co-authored-by: June Saehwan --- .../lpvs/controller/LPVSWebController.java | 44 ++++++++++++++++++- .../java/com/lpvs/entity/LPVSPullRequest.java | 6 +++ .../lpvs/entity/history/HistoryEntity.java | 20 +++++++++ .../entity/history/HistoryPageEntity.java | 18 ++++++++ .../com/lpvs/entity/history/LPVSHistory.java | 25 +++++++++++ .../lpvs/exception/PageControllerAdvice.java | 7 +++ .../lpvs/exception/WrongAccessException.java | 15 +++++++ .../LPVSDetectedLicenseRepository.java | 5 +++ .../repository/LPVSPullRequestRepository.java | 14 ++++++ .../lpvs/service/LPVSLoginCheckService.java | 34 ++++++++++++++ .../com/lpvs/entity/LPVSPullRequestTest.java | 6 ++- 11 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/lpvs/entity/history/HistoryEntity.java create mode 100644 src/main/java/com/lpvs/entity/history/HistoryPageEntity.java create mode 100644 src/main/java/com/lpvs/entity/history/LPVSHistory.java create mode 100644 src/main/java/com/lpvs/exception/WrongAccessException.java diff --git a/src/main/java/com/lpvs/controller/LPVSWebController.java b/src/main/java/com/lpvs/controller/LPVSWebController.java index 2e17b7c8..c2071ab3 100644 --- a/src/main/java/com/lpvs/controller/LPVSWebController.java +++ b/src/main/java/com/lpvs/controller/LPVSWebController.java @@ -9,19 +9,30 @@ import com.lpvs.entity.LPVSLoginMember; import com.lpvs.entity.LPVSMember; +import com.lpvs.entity.LPVSPullRequest; +import com.lpvs.entity.history.HistoryEntity; +import com.lpvs.entity.history.HistoryPageEntity; +import com.lpvs.entity.history.LPVSHistory; import com.lpvs.repository.LPVSDetectedLicenseRepository; import com.lpvs.repository.LPVSLicenseRepository; import com.lpvs.repository.LPVSMemberRepository; import com.lpvs.repository.LPVSPullRequestRepository; import com.lpvs.service.LPVSLoginCheckService; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.web.servlet.error.ErrorController; import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.web.PageableDefault; import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; +import java.sql.Timestamp; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; import java.util.Map; @Controller @@ -77,6 +88,37 @@ public ResponseEntity postSettingTest(@RequestBody Map prPage = historyPageEntity.getPrPage(); + Long count = historyPageEntity.getCount(); + + List lpvsHistories = new ArrayList<>(); + List lpvsPullRequests = prPage.getContent(); + + for (LPVSPullRequest pr : lpvsPullRequests) { + String[] pullNumberTemp = pr.getPullRequestUrl().split("/"); + LocalDateTime localDateTime = new Timestamp(pr.getDate().getTime()).toLocalDateTime(); + String formattingDateTime = lpvsLoginCheckService.dateTimeFormatting(localDateTime); + + Boolean hasIssue = detectedLicenseRepository.existsIssue(pr); + + lpvsHistories.add(new LPVSHistory(formattingDateTime, pr.getRepositoryName(), pr.getId(), + pr.getPullRequestUrl(), pr.getStatus(), pr.getSender(), + pullNumberTemp[pullNumberTemp.length-2] + "/" + + pullNumberTemp[pullNumberTemp.length-1], hasIssue)); + } + + HistoryEntity historyEntity = new HistoryEntity(lpvsHistories, count); + return historyEntity; + } + @GetMapping("error") public String redirect(){ return "index.html"; diff --git a/src/main/java/com/lpvs/entity/LPVSPullRequest.java b/src/main/java/com/lpvs/entity/LPVSPullRequest.java index 39a98a3f..73e401f5 100644 --- a/src/main/java/com/lpvs/entity/LPVSPullRequest.java +++ b/src/main/java/com/lpvs/entity/LPVSPullRequest.java @@ -45,6 +45,12 @@ public class LPVSPullRequest implements Serializable { @Column(name = "status") private String status; + @Column(name = "sender") + private String sender; + + @Column(name = "owner") + private String owner; + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/com/lpvs/entity/history/HistoryEntity.java b/src/main/java/com/lpvs/entity/history/HistoryEntity.java new file mode 100644 index 00000000..437f91d9 --- /dev/null +++ b/src/main/java/com/lpvs/entity/history/HistoryEntity.java @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved. + * + * Use of this source code is governed by a MIT license that can be + * found in the LICENSE file. + */ + +package com.lpvs.entity.history; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.List; + +@Getter +@AllArgsConstructor +public class HistoryEntity { + private List lpvsHistories; + private Long count; +} diff --git a/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java b/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java new file mode 100644 index 00000000..26ee2b54 --- /dev/null +++ b/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved. + * + * Use of this source code is governed by a MIT license that can be + * found in the LICENSE file. + */ + +package com.lpvs.entity.history; +import com.lpvs.entity.LPVSPullRequest; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.data.domain.Page; + +@Getter @AllArgsConstructor +public class HistoryPageEntity { + private Page prPage; + private Long count; +} diff --git a/src/main/java/com/lpvs/entity/history/LPVSHistory.java b/src/main/java/com/lpvs/entity/history/LPVSHistory.java new file mode 100644 index 00000000..98fb1310 --- /dev/null +++ b/src/main/java/com/lpvs/entity/history/LPVSHistory.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved. + * + * Use of this source code is governed by a MIT license that can be + * found in the LICENSE file. + */ + +package com.lpvs.entity.history; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@Getter @Setter @AllArgsConstructor +public class LPVSHistory { + private String scanDate; //pr + private String repositoryName; //pr + private Long pullRequestId; //pr + private String url; // pr + private String status; //pr + private String sender; + + private String pullNumber; // pull/number + private Boolean hasIssue; +} diff --git a/src/main/java/com/lpvs/exception/PageControllerAdvice.java b/src/main/java/com/lpvs/exception/PageControllerAdvice.java index a97a365e..2010a19a 100644 --- a/src/main/java/com/lpvs/exception/PageControllerAdvice.java +++ b/src/main/java/com/lpvs/exception/PageControllerAdvice.java @@ -26,6 +26,13 @@ public ResponseEntity loginFailedHandle(LoginFailedException e) { return new ResponseEntity<>(errorResponse, HttpStatus.UNAUTHORIZED); } + @ExceptionHandler(WrongAccessException.class) + public ResponseEntity wrongAccessHandle(WrongAccessException e) { + log.error("wrongAccess"); + errorResponse = new ErrorResponse(e.getMessage(), HttpStatus.FORBIDDEN.name(), HttpStatus.FORBIDDEN.value()); + return new ResponseEntity<>(errorResponse, HttpStatus.FORBIDDEN); + } + @ExceptionHandler(IllegalArgumentException.class) public ResponseEntity handleSQLException(IllegalArgumentException e) { log.error("duplicated key exception" + e.getMessage()); diff --git a/src/main/java/com/lpvs/exception/WrongAccessException.java b/src/main/java/com/lpvs/exception/WrongAccessException.java new file mode 100644 index 00000000..3044343f --- /dev/null +++ b/src/main/java/com/lpvs/exception/WrongAccessException.java @@ -0,0 +1,15 @@ +/** + * Copyright 2023 Basaeng, kyudori, hwan5180, quswjdgma83 + * + * Use of this source code is governed by a MIT license that can be + * found in the LICENSE file. + */ + +package com.lpvs.exception; + +public class WrongAccessException extends RuntimeException { + + public WrongAccessException(String message) { + super(message); + } +} diff --git a/src/main/java/com/lpvs/repository/LPVSDetectedLicenseRepository.java b/src/main/java/com/lpvs/repository/LPVSDetectedLicenseRepository.java index 3a9cdea6..b3b13d63 100644 --- a/src/main/java/com/lpvs/repository/LPVSDetectedLicenseRepository.java +++ b/src/main/java/com/lpvs/repository/LPVSDetectedLicenseRepository.java @@ -8,7 +8,12 @@ package com.lpvs.repository; import com.lpvs.entity.LPVSDetectedLicense; +import com.lpvs.entity.LPVSPullRequest; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; public interface LPVSDetectedLicenseRepository extends JpaRepository { + @Query(value = "select count(dl)>0 from LPVSDetectedLicense dl where dl.issue = True and dl.pullRequest = :pr") + Boolean existsIssue(@Param("pr") LPVSPullRequest pr); } diff --git a/src/main/java/com/lpvs/repository/LPVSPullRequestRepository.java b/src/main/java/com/lpvs/repository/LPVSPullRequestRepository.java index 56388514..98cec974 100644 --- a/src/main/java/com/lpvs/repository/LPVSPullRequestRepository.java +++ b/src/main/java/com/lpvs/repository/LPVSPullRequestRepository.java @@ -8,12 +8,26 @@ package com.lpvs.repository; import com.lpvs.entity.LPVSPullRequest; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import java.util.Date; public interface LPVSPullRequestRepository extends JpaRepository { @Query(value = "SELECT now();", nativeQuery = true) Date getNow(); + @Query(value = "select pr from LPVSPullRequest pr where pr.repositoryName like :name%") + Page findPullRequestByNameLike(@Param("name") String name, Pageable pageable); + + @Query(value = "select count(*) from LPVSPullRequest pr where pr.repositoryName like :name%") + Long CountByPullRequestWhereNameLike(@Param("name") String name); + + @Query(value = "select pr from LPVSPullRequest pr where pr.sender = :name") + Page findBySender(@Param("name") String name, Pageable pageable); + + @Query(value = "select count(*) from LPVSPullRequest pr where pr.sender = :name") + Long CountBySender(@Param("name") String name); } diff --git a/src/main/java/com/lpvs/service/LPVSLoginCheckService.java b/src/main/java/com/lpvs/service/LPVSLoginCheckService.java index bb6adab5..06310bf2 100644 --- a/src/main/java/com/lpvs/service/LPVSLoginCheckService.java +++ b/src/main/java/com/lpvs/service/LPVSLoginCheckService.java @@ -8,14 +8,21 @@ package com.lpvs.service; import com.lpvs.entity.LPVSMember; +import com.lpvs.entity.LPVSPullRequest; +import com.lpvs.entity.history.HistoryPageEntity; import com.lpvs.exception.LoginFailedException; +import com.lpvs.exception.WrongAccessException; import com.lpvs.repository.LPVSMemberRepository; import com.lpvs.repository.LPVSPullRequestRepository; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.security.core.Authentication; import org.springframework.security.oauth2.core.user.OAuth2User; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Map; import java.util.Optional; @@ -64,4 +71,31 @@ public LPVSMember getMemberFromMemberMap(Authentication authentication) { return newMember; } } + public HistoryPageEntity pathCheck(String type, String name, + Pageable pageable, Authentication authentication) { + + loginVerification(authentication); + LPVSMember findMember = getMemberFromMemberMap(authentication); + String findNickName = findMember.getNickname(); + String findOrganization = findMember.getOrganization(); + Page prPage; + Long count; + + if ((type.equals("own") && findNickName.equals(name)) || + (type.equals("org") && findOrganization.equals(name))) { + prPage = lpvsPullRequestRepository.findPullRequestByNameLike(name + "/", pageable); + count = lpvsPullRequestRepository.CountByPullRequestWhereNameLike(name + "/"); + } else if (type.equals("send") && findNickName.equals(name)) { + prPage = lpvsPullRequestRepository.findBySender(name, pageable); + count = lpvsPullRequestRepository.CountBySender(name); + } else { + throw new WrongAccessException("WrongAccessException"); + } + + return new HistoryPageEntity(prPage, count); + } + + public String dateTimeFormatting(LocalDateTime localDateTime) { + return localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + } } diff --git a/src/test/java/com/lpvs/entity/LPVSPullRequestTest.java b/src/test/java/com/lpvs/entity/LPVSPullRequestTest.java index 0ee2feb0..66eb923a 100644 --- a/src/test/java/com/lpvs/entity/LPVSPullRequestTest.java +++ b/src/test/java/com/lpvs/entity/LPVSPullRequestTest.java @@ -25,6 +25,8 @@ public class LPVSPullRequestTest { final String pullRequestUrl = "pulRequestUrl"; final String pullRequestFilesUrl = "pullRequestFileUrl"; final String status = "status"; + final String sender = "user"; + final String owner = "user"; @BeforeEach void setUp() { @@ -34,7 +36,9 @@ void setUp() { repositoryName, pullRequestUrl, pullRequestFilesUrl, - status); + status, + sender, + owner); } @Test From 7a4f64ed57733b9827780bd9c3c467646290a834 Mon Sep 17 00:00:00 2001 From: Han Kyuhyun Date: Thu, 21 Sep 2023 14:49:09 +0900 Subject: [PATCH 03/11] Correcting front-end errors. Signed-off-by: Han Kyuhyun Co-authored-by: ByunJeongHeum Co-authored-by: June Saehwan Co-authored-by: jongmin Lee --- frontend/src/App.jsx | 1 - frontend/src/css/History_style.css | 1198 ++++++++++++++--- frontend/src/pages/History.jsx | 36 +- frontend/src/pages/User.jsx | 12 + .../entity/history/HistoryPageEntity.java | 1 + .../com/lpvs/entity/history/LPVSHistory.java | 1 - .../repository/LPVSPullRequestRepository.java | 1 + 7 files changed, 1032 insertions(+), 218 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 55856c5a..a4d1e2a8 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -21,7 +21,6 @@ function App() { } /> } /> } /> - } /> } />
diff --git a/frontend/src/css/History_style.css b/frontend/src/css/History_style.css index a9293e8a..8b833f6a 100644 --- a/frontend/src/css/History_style.css +++ b/frontend/src/css/History_style.css @@ -5,203 +5,1001 @@ * found in the LICENSE file. */ - .home { - background-color: #ffffff; - display: flex; - flex-direction: row; - justify-content: center; - width: 100%; - } - - .home .div { - background-color: #ffffff; - border: 1px none; - height: 1080px; - position: relative; - width: 1920px; - } - - .home .LPVS-info { - height: 896px; - left: 593px; - position: absolute; - top: 140px; - width: 1273px; - } - - .home .overlap-group { - background-color: #000000ba; - height: 800px; - position: relative; - width: 1265px; - top: -10px; - } - - .home .user-guide { - color: #ffffff; - font-family: "Inter-Medium", Helvetica; - font-size: 24px; - font-weight: 400; - left: 42px; - letter-spacing: 0; - line-height: normal; - position: absolute; - top: 15px; - width: 1195px; - } - - .home .text-wrapper { - font-weight: 500; - } - - .home .span { - font-family: "Inter-Regular", Helvetica; - } - - .home .LPVS-logo { - height: 885px; - left: 15px; - position: absolute; - top: 125px; - width: 574px; - } - - .home .LPVS-github { - height: 407px; - left: 30px; - object-fit: cover; - position: absolute; - top: 400px; - width: 472px; - } - - .home .license-explain { - color: #00057b; - font-family: "Inter-Bold", Helvetica; - font-size: 60px; - font-weight: 700; - left: 56px; - letter-spacing: 0; - line-height: normal; - position: absolute; - top: 80px; - } - - .home .text-wrapper-2 { - color: #80808275; - font-family: "Inter-Bold", Helvetica; - font-size: 70px; - font-weight: 700; - left: 56px; - letter-spacing: 0; - line-height: normal; - position: absolute; - top: -10px; - white-space: nowrap; - width: 217px; - } - - .home .menubar-top { - height: 101px; - left: 39px; - position: absolute; - top: 8px; - width: 1842px; - } - - .home .menu-line { - background-color: #0057b8; - height: 3px; - left: 0; - position: absolute; - top: 98px; - width: 1842px; - } - - .home .menu { - height: 43px; - left: 1270px; - position: absolute; - top: 37px; - width: 578px; - } - - .home .overlap { - height: 43px; - left: 302px; - position: absolute; - top: 0; - width: 272px; - } - - .home .profile { - height: 43px; - left: 136px; - position: absolute; - top: 0; - width: 135px; - } - - .home .overlap-group-2 { - background-color: #d9d9d9; - border-radius: 50px; - height: 43px; - position: relative; - width: 133px; - } - - .home .image { - height: 31px; - left: 11px; - object-fit: cover; - position: absolute; - top: 7px; - width: 35px; - } - - .home .text-wrapper-3 { - color: #000000; - font-family: "Inter-SemiBold", Helvetica; - font-size: 20px; - font-weight: 600; - left: 56px; - letter-spacing: 0; - line-height: normal; - position: absolute; - top: 8px; - white-space: nowrap; - width: 71px; - } - - .home .text-wrapper-7 { - color: #000000; - font-family: "Inter-Regular", Helvetica; - font-size: 30px; - font-weight: 400; - left: 320px; - letter-spacing: 0; - line-height: normal; - position: absolute; - top: 3px; - white-space: nowrap; - width: 104px; - } - - .home .profile-border { - background-color: #d9d9d9; - height: 3px; - left: 104px; - position: absolute; - top: 20px; - transform: rotate(-90deg); - width: 40px; - } - - .home .LPVS { - height: 96px; - left: 0; - object-fit: cover; - position: absolute; - top: 0; - width: 229px; - } \ No newline at end of file + .history-send { + background-color: #ffffff; + display: flex; + flex-direction: row; + justify-content: center; + width: 100%; + position: relative; +} + +.history-send .div { + background-color: #ffffff; + border: 1px none; + height: 1080px; + position: relative; + width: 1920px; +} + +.history-send .overlap { + background-image: url(../../public/image/svg/OptionBoxStroke.svg); + background-size: 100% 100%; + height: 882px; + left: 34px; + position: absolute; + top: 133px; + width: 572px; + border-radius: 30px; + box-shadow: 0px 4px 4px #00000040, 2px 2px 2px 1px gray; + border: 1px solid gray; +} + +.history-send .option-menu { + height: 853px; + left: 41px; + position: relative; + top: 13px; + width: 482px; +} + +.history-send .button { + height: 773px; + left: 0; + position: absolute; + top: 80px; + width: 482px; +} + +.history-send .my-pull-request { + height: 255px; + left: 0; + position: absolute; + top: 0; + width: 484px; + cursor: pointer; + transition: background-color 0.3s; +} + +.history-send .my-pull-request:active, +.history-send .my-pull-request:focus { + background-color: #f0f0f0; + transform: translateY(4px) +} + +.history-send .overlap-group { + background-color: #ffffff; + border-radius: 30px; + box-shadow: 0px 4px 4px #00000040; + height: 255px; + position: relative; + width: 482px; + box-shadow: 0px 4px 4px #00000040, 2px 2px 2px 1px gray; + border: 1px solid gray; +} + +.history-send .text-wrapper { + color: black; + font-family: "Inter-Bold", Helvetica; + font-size: 40px; + font-weight: 700; + left: 84px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 104px; + white-space: nowrap; +} + +.history-send .text-wrapper-gray { + color: #0057B8; + font-family: "Inter-Bold", Helvetica; + font-size: 40px; + font-weight: 700; + left: 84px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 104px; + white-space: nowrap; +} + +.history-send .my-repo-pr-button { + height: 255px; + left: 0; + position: absolute; + top: 259px; + width: 484px; + cursor: pointer; + transition: background-color 0.3s; +} + +.history-send .my-repo-pr-button:active, +.history-send .my-repo-pr-button:focus { + background-color: #f0f0f0; + transform: translateY(4px) +} + +.history-send .my-repo-PR { + color: #000000; + font-family: "Inter-Bold", Helvetica; + font-size: 40px; + font-weight: 700; + left: 121px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 107px; + white-space: nowrap; +} + +.history-send .my-repo-PR-gray { + color: #0057B8; + font-family: "Inter-Bold", Helvetica; + font-size: 40px; + font-weight: 700; + left: 121px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 107px; + white-space: nowrap; +} + +.history-send .my-org-PR-button { + height: 255px; + left: 0; + position: absolute; + top: 518px; + width: 484px; + cursor: pointer; + transition: background-color 0.3s +} + +.history-send .my-org-PR-button:active, +.history-send .my-org-PR-button:focus { + background-color: #f0f0f0; + transform: translateY(4px) +} + +.history-send .text-wrapper-2 { + color: #000000; + font-family: "Inter-Bold", Helvetica; + font-size: 40px; + font-weight: 700; + left: 140px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 97px; + white-space: nowrap; +} + +.history-send .text-wrapper-2-gray { + color: #0057B8; + font-family: "Inter-Bold", Helvetica; + font-size: 40px; + font-weight: 700; + left: 140px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 97px; + white-space: nowrap; +} + +.history-send .my-option-header { + height: 61px; + left: 0; + position: absolute; + top: 0; + width: 484px; +} + +.history-send .my-option-line { + left: 0; + position: absolute; + top: 58px; + width: 100%; +} + +.history-send .my-option-line svg { + width: 100%; + height: 2px; + display: block; +} + + +.history-send .text-wrapper-3 { + color: #000000; + font-family: "Inter-Bold", Helvetica; + font-size: 40px; + font-weight: 700; + left: 10px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 0; + white-space: nowrap; +} + +.history-send .page-move-tool-bar { + height: 30px; + left: 845px; + position: absolute; + top: 1027px; + width: 286px; +} + +.history-send .page-number { + align-items: flex-start; + display: inline-flex; + gap: 33px; + left: 35px; + position: absolute; + top: 0; +} + +.history-send .text-wrapper-4 { + color: #000000; + font-family: "Inter-Bold", Helvetica; + font-size: 25px; + font-weight: 700; + letter-spacing: 0; + line-height: normal; + margin-top: -1px; + position: relative; + width: 13px; + cursor: pointer; +} + +.history-send .text-wrapper-4-blue { + color: #0057B8; + font-family: "Inter-Bold", Helvetica; + font-size: 25px; + font-weight: 700; + letter-spacing: 0; + line-height: normal; + margin-top: -1px; + position: relative; + width: 13px; + cursor: pointer; +} + +.history-send .text-wrapper-5 { + color: #000000; + font-family: "Inter-SemiBold", Helvetica; + font-size: 25px; + font-weight: 600; + letter-spacing: 0; + line-height: normal; + margin-top: -1px; + position: relative; + width: 16px; + cursor: pointer; +} + +.history-send .text-wrapper-6 { + color: #000000; + font-family: "Inter-SemiBold", Helvetica; + font-size: 25px; + font-weight: 600; + letter-spacing: 0; + line-height: normal; + margin-top: -1px; + position: relative; + width: 17px; + cursor: pointer; +} + +.history-send .right-arrow { + height: 22px; + left: 275px; + position: absolute; + top: 4px; + width: 13px; + cursor: pointer; +} + +.history-send .left-arrow { + height: 22px; + left: -2px; + position: absolute; + top: 4px; + width: 13px; + cursor: pointer; +} + +.history-send .overlap-2 { + height: 882px; + left: 635px; + position: absolute; + top: 134px; + width: 1236px; +} + +.history-send .history-box { + height: 882px; + left: 0; + position: absolute; + top: 0; + width: 1236px; +} + +.history-send .history { + height: 158px; + left: 0; + position: absolute; + top: 724px; + width: 1242px; +} + +.history-send .overlap-3 { + background-image: url(../../public/image/png/Stroke.png); + background-size: 100% 100%; + height: 166px; + left: -4px; + position: relative; + width: 1244px; +} + +.history-send .text-wrapper-7 { + color: #000000; + font-family: "Inter-Bold", Helvetica; + font-size: 25px; + font-weight: 700; + left: 29px; + letter-spacing: 0; + line-height: normal; + position: relative; + top: 15px; + display: inline-block; +} + +.text-wrapper-7-container { + position: relative; +} + +.history-send .text-wrapper-8 { + color: #000000; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 29px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 65px; + white-space: nowrap; + + +} + +.history-send .text-wrapper-8 ::after { + content: counter(name); +} + +.history-send .text-wrapper-9 { + color: #000000; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 29px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 105px; + white-space: nowrap; +} + +.history-send .prid { + height: 26px; + left: calc(100% + 20px); + position: absolute; + top: 4px; + width: 77px; +} + +.history-send .div-wrapper { + background-color: #d9d9d9; + border-radius: 15px; + height: 26px; + position: absolute; + left: 0px; + width: 75px; +} + +.history-send .text-wrapper-10 { + color: #000000; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 50%; + transform: translateX(-50%); + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 2px; + white-space: nowrap; +} + +.history-send .status-scan-error { + height: 27px; + left: calc(100% + 20px); + position: absolute; + top: 1px; + width: 187px; +} + +.history-send .overlap-wrapper { + height: 158px; + left: 0; + position: absolute; + top: 543px; + width: 1242px; +} + +.history-send .overlap-4 { + background-image: url(../../public/image/png/Stroke.png); + background-size: 100% 100%; + height: 166px; + left: -4px; + position: relative; + width: 1244px; +} + +.history-send .text-wrapper-11 { + color: #000000; + font-family: "Inter-Bold", Helvetica; + font-size: 25px; + font-weight: 700; + left: 29px; + letter-spacing: 0; + line-height: normal; + position: relative; + top: 15px; + display: inline-block; +} + +.history-send .p { + color: transparent; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 29px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 65px; + width: 1150px; + white-space: nowrap; +} + +.history-send .span { + color: #000000; +} + +.history-send .text-wrapper-12 { + color: #0057b8; +} + +.history-send .overlap-group-wrapper { + height: 26px; + left: calc(100% + 20px); + position: absolute; + top: 4px; + width: 77px; +} + +.history-send .text-wrapper-13 { + color: #000000; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 50%; + transform: translateX(-50%); + white-space: nowrap; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 2px; +} + +.history-send .status-issue { + height: 27px; + left: calc(100% + 20px); + position: absolute; + top: 0px; + width: 187px; +} + +.history-send .overlap-5 { + border-radius: 5px; + height: 27px; + position: relative; + width: 300px; +} + +.history-send .text-wrapper-14 { + color: #ff0000; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 18px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 1px; + width: 100%; +} + +.history-send .history-2 { + height: 158px; + left: 0; + position: absolute; + top: 362px; + width: 1242px; +} + +.history-send .overlap-6 { + background-image: url(../../public/image/png/Stroke.png); + background-size: 100% 100%; + height: 166px; + left: -4px; + position: relative; + width: 1244px; +} + +.history-send .text-wrapper-15 { + color: #000000; + font-family: "Inter-Bold", Helvetica; + font-size: 25px; + font-weight: 700; + left: 29px; + letter-spacing: 0; + line-height: normal; + position: relative; + top: 15px; + display: inline-block; +} + +.history-send .prid-2 { + height: 26px; + left: calc(100% + 20px); + position: absolute; + top: 4px; + width: 77px; +} + +.history-send .text-wrapper-16 { + color: #000000; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 50%; + transform: translateX(-50%); + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 2px; + white-space: nowrap; +} + +.history-send .status-scan { + height: 27px; + left: calc(100% + 20px); + position: absolute; + top: 0px; + width: 187px; +} + +.history-send .issue-detected { + color: #0000ff; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 10px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 1px; + width: 161px; +} + +.history-send .history-3 { + height: 158px; + left: 0; + position: absolute; + top: 181px; + width: 1242px; +} + +.history-send .overlap-7 { + background-image: url(../../public/image/png/Stroke.png); + background-size: 100% 100%; + height: 166px; + left: -4px; + position: relative; + width: 1244px; +} + +.history-send .text-wrapper-17 { + color: #000000; + font-family: "Inter-Bold", Helvetica; + font-size: 25px; + font-weight: 700; + left: 29px; + letter-spacing: 0; + line-height: normal; + position: relative; + top: 15px; + display: inline-block; +} + +.history-send .prid-3 { + height: 26px; + left: calc(100% + 20px); + position: absolute; + top: 4px; + width: 77px; +} + +.history-send .text-wrapper-18 { + color: #000000; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 50%; + transform: translateX(-50%); + white-space: nowrap; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 2px; +} + +.history-send .status-scan-2 { + height: 27px; + left: calc(100% + 20px); + position: absolute; + top: 0px; + width: 187px; +} + +.history-send .overlap-8 { + height: 28px; + position: relative; + width: 185px; +} + +.history-send .history-4 { + height: 158px; + left: 0; + position: absolute; + top: 0; + width: 1242px; +} + +.history-send .overlap-9 { + background-image: url(../../public/image/png/Stroke.png); + background-size: 100% 100%; + height: 166px; + left: -4px; + position: relative; + width: 1244px; +} + +.history-send .text-wrapper-19 { + color: #000000; + font-family: "Inter-Bold", Helvetica; + font-size: 25px; + font-weight: 700; + left: 29px; + letter-spacing: 0; + line-height: normal; + position: relative; + top: 16px; + display: inline-block; +} + +.history-send .https-github-com-kim { + color: transparent; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 28px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 65px; + width: 800px; +} + +.history-send .prid-4 { + height: 26px; + left: calc(100% + 20px); + position: absolute; + top: 4px; + width: 77px; +} + +.history-send .text-wrapper-20 { + color: #000000; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 50%; + transform: translateX(-50%); + white-space: nowrap; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 2px; +} + +.history-send .status-issue-2 { + height: 27px; + left: calc(100% + 20px); + position: absolute; + top: 0px; + width: 187px; +} + + +.history-send .text-wrapper-21 { + color: #d60000cf; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 44px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 2px; + white-space: nowrap; + width: 100% +} + +.history-send .menubar-top { + height: 101px; + left: 39px; + position: absolute; + top: 8px; + width: 1842px; +} + +.history-send .menu-line { + background-color: #000000; + height: 3px; + left: 0; + position: absolute; + top: 98px; + width: 1842px; +} + +.history-send .menu { + height: 96px; + left: 0; + position: absolute; + top: 0; + width: 1848px; +} + +.history-send .overlap-11 { + height: 43px; + left: 1572px; + position: absolute; + top: 37px; + width: 272px; +} + +.history-send .profile-border { + background-color: #d9d9d9; + height: 3px; + left: 104px; + position: absolute; + top: 20px; + transform: rotate(-90deg); + width: 40px; +} + +.history-send .text-wrapper-22 { + color: #000000; + font-family: "Inter-Regular", Helvetica; + font-size: 30px; + font-weight: 400; + left: 1590px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 40px; + width: 115px; +} + +.history-send .profile { + height: 43px; + left: 136px; + position: absolute; + top: 0; + width: 135px; +} + +.history-send .overlap-group-2 { + background-color: #d9d9d9; + border-radius: 50px; + height: 43px; + position: relative; + width: 133px; +} + +.history-send .image { + height: 31px; + left: 11px; + object-fit: cover; + position: absolute; + top: 6px; + width: 35px; +} + +.history-send .text-wrapper-23 { + color: #000000; + font-family: "Inter-SemiBold", Helvetica; + font-size: 20px; + font-weight: 600; + left: 56px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 10px; + white-space: nowrap; + width: 71px; +} + +.history-send .LPVS { + height: 96px; + left: 0; + object-fit: cover; + position: absolute; + top: 0; + width: 229px; +} + +.history-send .complete { + color: rgba(0, 0, 255, 1); + font-family: Tahoma, Geneva, sans-serif; + font-size: 20px; + font-weight: 500; + letter-spacing: 0; + line-height: normal; + top: 0px; + white-space: nowrap; + width: 100%; + margin-left: 10px; + position: static; + z-index: 1; +} + +.history-send .text-wrapper-998 { + color: #000000; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + letter-spacing: 0; + line-height: normal; + top: 0; + width: 100%; + margin-left: 10px; + position: static; + right: 0; +} + +.history-send .status-label { + background-color: #ff000054; + border: 1px solid; + border-color: #ff0000; + border-radius: 5px; + height: 27px; + left: 0; + position: absolute; + top: 0; + width: 185px; +} + +.history-send .status-label-2 { + background-color: #0000ff42; + border: 1px solid; + border-color: #0000ff; + border-radius: 5px; + height: 27px; + left: 0; + position: absolute; + top: 0; + width: 185px; +} + +.history-send .status-label-3 { + background-color: rgba(255, 245, 16, 0.5); + border: 1px solid; + border-color: #F9EF00; + border-radius: 5px; + height: 27px; + width: 185px; + z-index: 1; + position: relative; +} + + +.history-send .Issue-Detected { + background-color: #ff000054; + border: 2px solid; + border-color: #ff0000; + border-radius: 5px; + height: 27px; + left: 0; + position: absolute; + top: 0; + width: 185px; +} + +.history-send .Scan-completed { + background-color: #0000ff42; + border: 2px solid; + border-color: #0000ff; + border-radius: 5px; + height: 27px; + left: 0; + position: absolute; + top: 0; + width: 185px; +} + +.history-send .Scan-Error { + background-color: rgba(255, 245, 16, 0.5); + border: 2px solid; + border-color: #3F4311; + border-radius: 5px; + height: 27px; + left: 0; + top: 0; + width: 185px; + z-index: 1; +} + +.history-send .Scan-Error-text { + color: #ff0000 !important; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 45px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 3px; + width: 100%; +} + +.history-send .Scan-completed-text { + color: #0000ff !important; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 21px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 3px; + width: 161px; +} + +.history-send .Issue-Detected-text { + color: #ff0000 !important; + font-family: "Inter-Medium", Helvetica; + font-size: 20px; + font-weight: 500; + left: 26px; + letter-spacing: 0; + line-height: normal; + position: absolute; + top: 3px; + width: 100%; +} diff --git a/frontend/src/pages/History.jsx b/frontend/src/pages/History.jsx index 657bcdd3..8be2e77e 100644 --- a/frontend/src/pages/History.jsx +++ b/frontend/src/pages/History.jsx @@ -6,10 +6,10 @@ */ import {React,useEffect, useState} from "react"; +import axios from 'axios'; import { Link, useParams, useLocation } from "react-router-dom"; import { useNavigate } from "react-router-dom"; import "../css/History_style.css"; -import axios from 'axios'; export const History= () => { @@ -34,16 +34,16 @@ export const History= () => { .then((userInfoResponse) => { setUsername(userInfoResponse.data); }) - .catch((error) => { - console.log("Error fetching user info:", error); + .catch(function(error) { + console.log(error.toJSON()); navigate("/login"); }); } else { navigate("/login"); } }) - .catch((error) => { - console.log("Error checking login status:", error); + .catch(function(error) { + console.log(error.toJSON()); navigate("/login"); }); }, []); @@ -55,11 +55,11 @@ export const History= () => { console.log(response.data) setlpvsHistories(response.data); }) - .catch((error) => { - console.log(error); - const userChoice = window.confirm("Please enter the Organization information on the User page."); + .catch(function(error) { + console.log(error.toJSON()); + const userChoice = window.confirm("Please enter the GitHub ID on the User page."); if (userChoice) { - navigate('/user/info'); + navigate('/user/setting'); } else { navigate(`/history/send/${username?.nickname}?page=0`); } @@ -96,7 +96,6 @@ export const History= () => { navigate(`/history/send/${username?.nickname}?page=0`); }; - const [pageCount,setPageCount] = useState(1); const [currentPage, setCurrentPage] = useState(1); @@ -290,7 +289,6 @@ export const History= () => { ): null} - {lpvsHistories.lpvsHistories[1]?.status !== undefined ? (
@@ -350,14 +348,20 @@ export const History= () => {
Image -
{username.name}
+
{username.name}
-
History
- - Lpvs - +
+ History + +
+ + img +
diff --git a/frontend/src/pages/User.jsx b/frontend/src/pages/User.jsx index 344b9e61..414e8c1c 100644 --- a/frontend/src/pages/User.jsx +++ b/frontend/src/pages/User.jsx @@ -109,6 +109,17 @@ export const User = () => { })); }; + const handleHistoryLinkClick = (event) => { + event.preventDefault(); + + if (!userInfo?.nickname) { + alert('To use service, You must enter a GitHub ID.'); + navigate('/user/setting'); + } else { + navigate(`/history/send/${userInfo.nickname}`); + } + }; + const handleLogoClick = (event) => { event.preventDefault(); @@ -255,6 +266,7 @@ export const User = () => {
+
Image diff --git a/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java b/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java index 26ee2b54..5b6c8c89 100644 --- a/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java +++ b/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java @@ -6,6 +6,7 @@ */ package com.lpvs.entity.history; + import com.lpvs.entity.LPVSPullRequest; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/lpvs/entity/history/LPVSHistory.java b/src/main/java/com/lpvs/entity/history/LPVSHistory.java index 98fb1310..837259ca 100644 --- a/src/main/java/com/lpvs/entity/history/LPVSHistory.java +++ b/src/main/java/com/lpvs/entity/history/LPVSHistory.java @@ -19,7 +19,6 @@ public class LPVSHistory { private String url; // pr private String status; //pr private String sender; - private String pullNumber; // pull/number private Boolean hasIssue; } diff --git a/src/main/java/com/lpvs/repository/LPVSPullRequestRepository.java b/src/main/java/com/lpvs/repository/LPVSPullRequestRepository.java index 98cec974..a2c17afb 100644 --- a/src/main/java/com/lpvs/repository/LPVSPullRequestRepository.java +++ b/src/main/java/com/lpvs/repository/LPVSPullRequestRepository.java @@ -19,6 +19,7 @@ public interface LPVSPullRequestRepository extends JpaRepository { @Query(value = "SELECT now();", nativeQuery = true) Date getNow(); + @Query(value = "select pr from LPVSPullRequest pr where pr.repositoryName like :name%") Page findPullRequestByNameLike(@Param("name") String name, Pageable pageable); From f3259421dacaa253ec78ab9b85799da9944022b2 Mon Sep 17 00:00:00 2001 From: jongmin Lee Date: Thu, 21 Sep 2023 23:47:19 +0900 Subject: [PATCH 04/11] Correcting back-end errors Signed-off-by: jongmin Lee Co-authored-by: Han Kyuhyun Co-authored-by: ByunJeongHeum Co-authored-by: June Saehwan --- src/main/java/com/lpvs/entity/LPVSQueue.java | 6 ++++++ src/main/java/com/lpvs/service/LPVSQueueService.java | 2 ++ src/main/java/com/lpvs/util/LPVSWebhookUtil.java | 3 +++ 3 files changed, 11 insertions(+) diff --git a/src/main/java/com/lpvs/entity/LPVSQueue.java b/src/main/java/com/lpvs/entity/LPVSQueue.java index abea0c4f..f94b18b9 100644 --- a/src/main/java/com/lpvs/entity/LPVSQueue.java +++ b/src/main/java/com/lpvs/entity/LPVSQueue.java @@ -57,6 +57,12 @@ public class LPVSQueue implements Serializable { @Column(name = "commit_sha", columnDefinition = "LONGTEXT") private String headCommitSHA; + @Column(name = "sender") + private String sender; + + @Column(name = "owner") + private String owner; + @Transient private String repositoryLicense; diff --git a/src/main/java/com/lpvs/service/LPVSQueueService.java b/src/main/java/com/lpvs/service/LPVSQueueService.java index b1df41bd..b1ae319d 100644 --- a/src/main/java/com/lpvs/service/LPVSQueueService.java +++ b/src/main/java/com/lpvs/service/LPVSQueueService.java @@ -97,6 +97,8 @@ public void checkForQueue() throws InterruptedException { pullRequest.setRepositoryName(LPVSWebhookUtil.getRepositoryOrganization(webhook) + "/" + LPVSWebhookUtil.getRepositoryName(webhook)); pullRequest.setDate(webhook.getDate()); pullRequest.setStatus(LPVSPullRequestStatus.NO_ACCESS.toString()); + pullRequest.setSender(webhook.getSender()); + pullRequest.setOwner(webhook.getOwner()); pullRequest = lpvsPullRequestRepository.saveAndFlush(pullRequest); if (webhook.getUserId().equals("GitHub hook")) { diff --git a/src/main/java/com/lpvs/util/LPVSWebhookUtil.java b/src/main/java/com/lpvs/util/LPVSWebhookUtil.java index d237b471..fcf96530 100644 --- a/src/main/java/com/lpvs/util/LPVSWebhookUtil.java +++ b/src/main/java/com/lpvs/util/LPVSWebhookUtil.java @@ -38,6 +38,9 @@ public static LPVSQueue getGitHubWebhookConfig(String payload) { webhookConfig.setHeadCommitSHA(json.getAsJsonObject("pull_request") .getAsJsonObject("head") .get("sha").getAsString()); + + webhookConfig.setSender(json.getAsJsonObject("sender").get("login").getAsString()); + webhookConfig.setOwner(json.getAsJsonObject("pull_request").getAsJsonObject("head").getAsJsonObject("repo").getAsJsonObject("owner").get("login").getAsString()); webhookConfig.setAttempts(0); return webhookConfig; } From a0407539abc0089dca197ab8a3d44322e2a3a29b Mon Sep 17 00:00:00 2001 From: jongmin Lee Date: Sat, 23 Sep 2023 15:56:04 +0900 Subject: [PATCH 05/11] Fix history page error Signed-off-by: jongmin Lee Co-authored-by: Han Kyuhyun Co-authored-by: ByunJeongHeum Co-authored-by: June Saehwan --- src/main/java/com/lpvs/service/LPVSQueueService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/lpvs/service/LPVSQueueService.java b/src/main/java/com/lpvs/service/LPVSQueueService.java index b1ae319d..86040a66 100644 --- a/src/main/java/com/lpvs/service/LPVSQueueService.java +++ b/src/main/java/com/lpvs/service/LPVSQueueService.java @@ -138,6 +138,8 @@ public void processWebHook(LPVSQueue webhookConfig) throws IOException { pullRequest.setRepositoryName(LPVSWebhookUtil.getRepositoryOrganization(webhookConfig) + "/" + LPVSWebhookUtil.getRepositoryName(webhookConfig)); pullRequest.setDate(webhookConfig.getDate()); pullRequest.setStatus(LPVSPullRequestStatus.SCANNING.toString()); + pullRequest.setSender(webhookConfig.getSender()); + pullRequest.setOwner(webhookConfig.getOwner()); pullRequest = lpvsPullRequestRepository.saveAndFlush(pullRequest); log.debug("ID: " + pullRequest.getId() + " " + pullRequest.toString()); From 5fe5dedde7b04e8db993939fd45df1d15ccffb14 Mon Sep 17 00:00:00 2001 From: Han Kyuhyun Date: Sat, 23 Sep 2023 22:56:55 +0900 Subject: [PATCH 06/11] Update Test files Signed-off-by: Han Kyuhyun Co-authored-by: ByunJeongHeum Co-authored-by: June Saehwan Co-authored-by: jongmin Lee --- .../GitHubWebhooksControllerTest.java | 6 ++++++ .../java/com/lpvs/util/WebHookUtilTest.java | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/lpvs/controller/GitHubWebhooksControllerTest.java b/src/test/java/com/lpvs/controller/GitHubWebhooksControllerTest.java index 254a9e81..55c29424 100644 --- a/src/test/java/com/lpvs/controller/GitHubWebhooksControllerTest.java +++ b/src/test/java/com/lpvs/controller/GitHubWebhooksControllerTest.java @@ -78,6 +78,9 @@ public void okTest() { "\"html_url\": \"https://github.com/Samsung/LPVS/pull/18\", " + "\"head\": {" + "\"repo\": {" + + "\"owner\": {" + + "\"login\": \"Samsung\"" + + "}," + "\"fork\": true, " + "\"html_url\": \"https://github.com/o-kopysov/LPVS/tree/utests\"" + "}, " + @@ -85,6 +88,9 @@ public void okTest() { "\"ref\": \"o-kopysov:utests\"" + "}, " + "\"url\": \"https://api.github.com/repos/Samsung/LPVS/pulls/18\"" + + "}," + + "\"sender\": {" + + "\"login\": \"o-kopysov\"" + "}" + "}"; diff --git a/src/test/java/com/lpvs/util/WebHookUtilTest.java b/src/test/java/com/lpvs/util/WebHookUtilTest.java index 1cdfa3b0..4077baa7 100644 --- a/src/test/java/com/lpvs/util/WebHookUtilTest.java +++ b/src/test/java/com/lpvs/util/WebHookUtilTest.java @@ -36,13 +36,19 @@ void setUp() { "\"html_url\": \"https://github.com/Samsung/LPVS/pull/18\", " + "\"head\": {" + "\"repo\": {" + - "\"fork\": true, " + + "\"owner\": {" + + "\"login\": \"Samsung\"" + + "}," + + "\"fork\": true, " + "\"html_url\": \"https://github.com/o-kopysov/LPVS/tree/utests\"" + "}, " + "\"sha\": \"edde69ecb8e8a88dde09fa9789e2c9cab7cf7cf9\", " + "\"ref\": \"o-kopysov:utests\"" + "}, " + "\"url\": \"https://api.github.com/repos/Samsung/LPVS/pulls/18\"" + + "}," + + "\"sender\": {" + + "\"login\": \"o-kopysov\"" + "}" + "}"; @@ -53,6 +59,8 @@ void setUp() { expected.setPullRequestAPIUrl("https://api.github.com/repos/Samsung/LPVS/pulls/18"); expected.setRepositoryUrl("https://github.com/Samsung/LPVS"); expected.setUserId("GitHub hook"); + expected.setSender("o-kopysov"); + expected.setOwner("Samsung"); expected.setHeadCommitSHA("edde69ecb8e8a88dde09fa9789e2c9cab7cf7cf9"); expected.setAttempts(0); } @@ -84,6 +92,9 @@ void setUp() { "\"html_url\": \"https://github.com/Samsung/LPVS/pull/18\", " + "\"head\": {" + "\"repo\": {" + + "\"owner\": {" + + "\"login\": \"Samsung\"" + + "}," + "\"fork\": false, " + "\"html_url\": \"https://github.com/o-kopysov/LPVS/tree/utests\"" + "}, " + @@ -91,6 +102,9 @@ void setUp() { "\"ref\": \"o-kopysov:utests\"" + "}, " + "\"url\": \"https://api.github.com/repos/Samsung/LPVS/pulls/18\"" + + "}," + + "\"sender\": {" + + "\"login\": \"o-kopysov\"" + "}" + "}"; @@ -101,6 +115,8 @@ void setUp() { expected.setPullRequestAPIUrl("https://api.github.com/repos/Samsung/LPVS/pulls/18"); expected.setRepositoryUrl("https://github.com/Samsung/LPVS"); expected.setUserId("GitHub hook"); + expected.setSender("o-kopysov"); + expected.setOwner("Samsung"); expected.setHeadCommitSHA("edde69ecb8e8a88dde09fa9789e2c9cab7cf7cf9"); expected.setAttempts(0); } From 066fb0e904bf90ad33ead67055d9743c282dec61 Mon Sep 17 00:00:00 2001 From: Han Kyuhyun Date: Sun, 24 Sep 2023 15:19:18 +0900 Subject: [PATCH 07/11] Edit indentation in the test file Signed-off-by: Han Kyuhyun Co-authored-by: ByunJeongHeum Co-authored-by: June Saehwan Co-authored-by: jongmin Lee --- src/test/java/com/lpvs/util/WebHookUtilTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/lpvs/util/WebHookUtilTest.java b/src/test/java/com/lpvs/util/WebHookUtilTest.java index 4077baa7..605af324 100644 --- a/src/test/java/com/lpvs/util/WebHookUtilTest.java +++ b/src/test/java/com/lpvs/util/WebHookUtilTest.java @@ -39,7 +39,7 @@ void setUp() { "\"owner\": {" + "\"login\": \"Samsung\"" + "}," + - "\"fork\": true, " + + "\"fork\": true, " + "\"html_url\": \"https://github.com/o-kopysov/LPVS/tree/utests\"" + "}, " + "\"sha\": \"edde69ecb8e8a88dde09fa9789e2c9cab7cf7cf9\", " + From 67858fb424c15558479adc234a3b775771b3cce8 Mon Sep 17 00:00:00 2001 From: Han Kyuhyun Date: Sun, 24 Sep 2023 19:00:20 +0900 Subject: [PATCH 08/11] Edit Home.jsx indentation Signed-off-by: Han Kyuhyun Co-authored-by: ByunJeongHeum Co-authored-by: June Saehwan Co-authored-by: jongmin Lee --- frontend/src/pages/Home.jsx | 218 +++++++++++++++++------------------- 1 file changed, 104 insertions(+), 114 deletions(-) diff --git a/frontend/src/pages/Home.jsx b/frontend/src/pages/Home.jsx index 57e098b3..86e19771 100644 --- a/frontend/src/pages/Home.jsx +++ b/frontend/src/pages/Home.jsx @@ -11,128 +11,118 @@ import { Link } from "react-router-dom"; import "../css/Home_style.css"; export const LPVS_SERVER = process.env.REACT_APP_LPVS_SERVER; + export const Home = () => { - const [isLoggedIn, setIsLoggedIn] = useState(false); - const [username, setUsername] = useState(""); + const [isLoggedIn, setIsLoggedIn] = useState(false); + const [username, setUsername] = useState(""); - useEffect(() => { - axios.get("/login/check") - .then((loginresponse) => { - if (loginresponse.data.isLoggedIn) { - setIsLoggedIn(loginresponse.data.isLoggedIn); - axios.get("/user/info").then((userInfoResponse) => { - setUsername(userInfoResponse.data); - }); - } - }) - .catch(function(error) { - console.log(error.toJSON()); - }); - }, []); + useEffect(() => { + axios.get("/login/check") + .then((loginresponse) => { + if (loginresponse.data.isLoggedIn) { + setIsLoggedIn(loginresponse.data.isLoggedIn); + axios.get("/user/info").then((userInfoResponse) => { + setUsername(userInfoResponse.data); + }); + } + }) + .catch(function(error) { + console.log(error.toJSON()); + }); + }, []); - function truncateName(name) { - if (/[\u3131-\u314e\u314f-\u3163\uac00-\ud7a3]/g.test(name)) { - return name.length > 3 ? `${name.substring(0, 3)}.` : name; - } else { - return name.length > 5 ? `${name.substring(0, 5)}.` : name; + function truncateName(name) { + if (/[\u3131-\u314e\u314f-\u3163\uac00-\ud7a3]/g.test(name)) { + return name.length > 3 ? `${name.substring(0, 3)}.` : name; + } else { + return name.length > 5 ? `${name.substring(0, 5)}.` : name; + } } - } - return ( -
-
-
-
-
-

Welcome to the License Pre-Validation Service (LPVS).

-

Usage Procedure

-
    -
  1. Sign up and Login to the service.
  2. -
  3. Go to user information page, enter your GitHub ID (required) and Organization Name (optional), then click the "Admit" button.
  4. -
  5. Login to GitHub using the GitHub ID you entered in step 2.
  6. -
  7. To configure the repository for license validation, follow these steps:
  8. -
      -
    1. Go to the repository you want to validation.
    2. -
    3. Navigate to Settings -{">"} Webhooks -{">"} Add Webhooks.
    4. -
    5. Enter 'http://{"<"}IP where LPVS is running:7896/webhooks{">"}' in the Payload URL field.
    6. -
    7. Select 'application/json' for Content Type.
    8. -
    9. Enter 'LPVS' in the Secret field.
    10. -
    11. Under "Which events would you like to trigger this webhook?", select 'Let me select individual events.' and check only the 'Pull Request' option.
    12. -
    13. Click the green 'Add webhook' button.
    14. -
    -
  9. After completing the webhook setup for the repository, create a Pull Request on that repository to see the results of license validation.
  10. -
-

Important Notes

-
    -
  • If you enter a GitHub ID that is already used by someone else in your user information, it will not be reflected.
  • -
  • This service is only available for Public Repository.
  • -
  • Webhook settings are mandatory for using this service.
  • -
-
-
-
-
- - img - -
- License
- Pre
- Validation
- Service -
-
About
-
-
-
-
-
- {isLoggedIn ? ( -
- ): null}
-
- img -
- {isLoggedIn ? ( - - - {username?.name ? ( -
{truncateName(username.name)}
- ) : ( -
Loading...
- )} - -
- ) : ( - - Login - - )} -
+ return ( +
+
+
+
+
+

Welcome to the License Pre-Validation Service (LPVS).

+

Usage Procedure

+
    +
  1. Sign up and Login to the service.
  2. +
  3. Go to user information page, enter your GitHub ID (required) and Organization Name (optional), then click the "Admit" button.
  4. +
  5. Login to GitHub using the GitHub ID you entered in step 2.
  6. +
  7. To configure the repository for license validation, follow these steps:
  8. +
      +
    1. Go to the repository you want to validation.
    2. +
    3. Navigate to Settings -{">"} Webhooks -{">"} Add Webhooks.
    4. +
    5. Enter 'http://{"<"}IP where LPVS is running:7896/webhooks{">"}' in the Payload URL field.
    6. +
    7. Select 'application/json' for Content Type.
    8. +
    9. Enter 'LPVS' in the Secret field.
    10. +
    11. Under "Which events would you like to trigger this webhook?", select 'Let me select individual events.' and check only the 'Pull Request' option.
    12. +
    13. Click the green 'Add webhook' button.
    14. +
    +
  9. After completing the webhook setup for the repository, create a Pull Request on that repository to see the results of license validation.
  10. +
+

Important Notes

+
    +
  • If you enter a GitHub ID that is already used by someone else in your user information, it will not be reflected.
  • +
  • This service is only available for Public Repository.
  • +
  • Webhook settings are mandatory for using this service.
  • +
+
+
+
+
+ + img + +
+ License
+ Pre
+ Validation
+ Service +
+
About
+
+
+
+
+
+ {isLoggedIn ?
: null} +
+
+ img +
+ {isLoggedIn ? ( + + + {username?.name ?
{truncateName(username.name)}
:
Loading...
} + +
+ ) : ( + + Login + + )} +
+
+
+
+
+ {isLoggedIn ? ( + + History + + ) : null} +
+
+ + img +
-
-
- {isLoggedIn ? ( - - History - - ) : null} -
-
- - img -
-
-
- ); + ); }; export default Home; From 7943e7679d06a4af3482ad01dba554dcb7d5daa9 Mon Sep 17 00:00:00 2001 From: jongmin Lee Date: Sun, 1 Oct 2023 22:57:20 +0900 Subject: [PATCH 09/11] Fix HistoryPage Errors Signed-off-by: jongmin Lee Co-authored-by: Han Kyuhyun Co-authored-by: ByunJeongHeum Co-authored-by: June Saehwan --- src/main/java/com/lpvs/auth/OAuthService.java | 1 + .../lpvs/controller/LPVSWebController.java | 12 ++++-- src/main/java/com/lpvs/entity/LPVSMember.java | 5 --- .../java/com/lpvs/entity/LPVSPullRequest.java | 9 ++-- src/main/java/com/lpvs/entity/LPVSQueue.java | 10 +++-- .../com/lpvs/entity/result/LPVSResult.java | 23 ++++++++++ .../lpvs/entity/result/LPVSResultFile.java | 17 ++++++++ .../lpvs/entity/result/LPVSResultInfo.java | 18 ++++++++ .../LPVSDetectedLicenseRepository.java | 13 ++++++ .../repository/LPVSLicenseRepository.java | 1 + .../repository/LPVSPullRequestRepository.java | 14 +++++++ .../lpvs/service/LPVSLoginCheckService.java | 42 ++++++++++++------- .../com/lpvs/service/LPVSQueueService.java | 6 ++- .../java/com/lpvs/util/LPVSWebhookUtil.java | 3 +- 14 files changed, 139 insertions(+), 35 deletions(-) create mode 100644 src/main/java/com/lpvs/entity/result/LPVSResult.java create mode 100644 src/main/java/com/lpvs/entity/result/LPVSResultFile.java create mode 100644 src/main/java/com/lpvs/entity/result/LPVSResultInfo.java diff --git a/src/main/java/com/lpvs/auth/OAuthService.java b/src/main/java/com/lpvs/auth/OAuthService.java index a6de9045..dab0c394 100644 --- a/src/main/java/com/lpvs/auth/OAuthService.java +++ b/src/main/java/com/lpvs/auth/OAuthService.java @@ -45,6 +45,7 @@ public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2Authentic MemberProfile memberProfile = OAuthAttributes.extract(registrationId, attributes); memberProfile.setProvider(registrationId); + saveOrUpdate(memberProfile); Map customAttribute = customAttribute(attributes, userNameAttributeName, memberProfile, registrationId); diff --git a/src/main/java/com/lpvs/controller/LPVSWebController.java b/src/main/java/com/lpvs/controller/LPVSWebController.java index c2071ab3..da4e3124 100644 --- a/src/main/java/com/lpvs/controller/LPVSWebController.java +++ b/src/main/java/com/lpvs/controller/LPVSWebController.java @@ -7,17 +7,19 @@ package com.lpvs.controller; -import com.lpvs.entity.LPVSLoginMember; -import com.lpvs.entity.LPVSMember; -import com.lpvs.entity.LPVSPullRequest; +import com.lpvs.entity.*; import com.lpvs.entity.history.HistoryEntity; import com.lpvs.entity.history.HistoryPageEntity; import com.lpvs.entity.history.LPVSHistory; +import com.lpvs.entity.result.LPVSResult; +import com.lpvs.entity.result.LPVSResultFile; +import com.lpvs.entity.result.LPVSResultInfo; import com.lpvs.repository.LPVSDetectedLicenseRepository; import com.lpvs.repository.LPVSLicenseRepository; import com.lpvs.repository.LPVSMemberRepository; import com.lpvs.repository.LPVSPullRequestRepository; import com.lpvs.service.LPVSLoginCheckService; +import lombok.extern.slf4j.Slf4j; import org.springframework.boot.web.servlet.error.ErrorController; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.data.domain.Page; @@ -32,10 +34,12 @@ import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @Controller +@Slf4j public class LPVSWebController implements ErrorController { private LPVSMemberRepository memberRepository; private LPVSDetectedLicenseRepository detectedLicenseRepository; @@ -65,7 +69,7 @@ public LPVSMember personalInfoSettings(Authentication authentication) { public LPVSLoginMember loginMember(Authentication authentication) { Map oauthLoginMemberMap = lpvsLoginCheckService.getOauthLoginMemberMap(authentication); boolean isLoggedIn = oauthLoginMemberMap == null || oauthLoginMemberMap.isEmpty(); - + log.info("{}", oauthLoginMemberMap); if (!isLoggedIn) { LPVSMember findMember = lpvsLoginCheckService.getMemberFromMemberMap(authentication); return new LPVSLoginMember(!isLoggedIn, findMember); diff --git a/src/main/java/com/lpvs/entity/LPVSMember.java b/src/main/java/com/lpvs/entity/LPVSMember.java index e4690ee6..68eab363 100644 --- a/src/main/java/com/lpvs/entity/LPVSMember.java +++ b/src/main/java/com/lpvs/entity/LPVSMember.java @@ -63,9 +63,4 @@ public void setOrganization(String organization) { this.organization = organization; } - public void setJoin(String name, String email, String provider) { - this.name = name; - this.email = email; - this.provider = provider; - } } diff --git a/src/main/java/com/lpvs/entity/LPVSPullRequest.java b/src/main/java/com/lpvs/entity/LPVSPullRequest.java index 73e401f5..9179416c 100644 --- a/src/main/java/com/lpvs/entity/LPVSPullRequest.java +++ b/src/main/java/com/lpvs/entity/LPVSPullRequest.java @@ -45,12 +45,15 @@ public class LPVSPullRequest implements Serializable { @Column(name = "status") private String status; + @Column(name = "pull_request_head") + private String pullRequestHead; + + @Column(name = "pull_request_base") + private String pullRequestBase; + @Column(name = "sender") private String sender; - @Column(name = "owner") - private String owner; - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/com/lpvs/entity/LPVSQueue.java b/src/main/java/com/lpvs/entity/LPVSQueue.java index f94b18b9..688e7b7c 100644 --- a/src/main/java/com/lpvs/entity/LPVSQueue.java +++ b/src/main/java/com/lpvs/entity/LPVSQueue.java @@ -57,12 +57,14 @@ public class LPVSQueue implements Serializable { @Column(name = "commit_sha", columnDefinition = "LONGTEXT") private String headCommitSHA; - @Column(name = "sender") - private String sender; + @Column(name = "pull_request_head") + private String pullRequestHead; - @Column(name = "owner") - private String owner; + @Column(name = "pull_request_base") + private String pullRequestBase; + @Column(name = "sender") + private String sender; @Transient private String repositoryLicense; diff --git a/src/main/java/com/lpvs/entity/result/LPVSResult.java b/src/main/java/com/lpvs/entity/result/LPVSResult.java new file mode 100644 index 00000000..9656643b --- /dev/null +++ b/src/main/java/com/lpvs/entity/result/LPVSResult.java @@ -0,0 +1,23 @@ +package com.lpvs.entity.result; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; +import java.util.Map; + +@Setter +@Getter +@AllArgsConstructor +public class LPVSResult { + private List lpvsResultFileList; + private LPVSResultInfo lpvsResultInfo; + private Long count; + + private Map licenseCountMap; + + private String pullNumber; + + private Boolean hasIssue; +} diff --git a/src/main/java/com/lpvs/entity/result/LPVSResultFile.java b/src/main/java/com/lpvs/entity/result/LPVSResultFile.java new file mode 100644 index 00000000..3904be97 --- /dev/null +++ b/src/main/java/com/lpvs/entity/result/LPVSResultFile.java @@ -0,0 +1,17 @@ +package com.lpvs.entity.result; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter @AllArgsConstructor +public class LPVSResultFile { + + private Long id; //dl.id + private String path; //dl.file_path + private String componentFileUrl; //dl + private String matchLine; //dl + private String matchValue; //dl + + private String status; //license.licenseUsage + private String licenseSpdx; //license +} diff --git a/src/main/java/com/lpvs/entity/result/LPVSResultInfo.java b/src/main/java/com/lpvs/entity/result/LPVSResultInfo.java new file mode 100644 index 00000000..a8f0be45 --- /dev/null +++ b/src/main/java/com/lpvs/entity/result/LPVSResultInfo.java @@ -0,0 +1,18 @@ +package com.lpvs.entity.result; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +import java.util.Date; +import java.util.List; + +@Getter @Setter @AllArgsConstructor +public class LPVSResultInfo { + + private Long id; //pr.id + private Date scanDate; //pr + private String repositoryName; //pr + private String status; //pr + private List detectedLicenses; +} diff --git a/src/main/java/com/lpvs/repository/LPVSDetectedLicenseRepository.java b/src/main/java/com/lpvs/repository/LPVSDetectedLicenseRepository.java index b3b13d63..da713c58 100644 --- a/src/main/java/com/lpvs/repository/LPVSDetectedLicenseRepository.java +++ b/src/main/java/com/lpvs/repository/LPVSDetectedLicenseRepository.java @@ -8,12 +8,25 @@ package com.lpvs.repository; import com.lpvs.entity.LPVSDetectedLicense; +import com.lpvs.entity.LPVSLicense; import com.lpvs.entity.LPVSPullRequest; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import java.util.List; + public interface LPVSDetectedLicenseRepository extends JpaRepository { @Query(value = "select count(dl)>0 from LPVSDetectedLicense dl where dl.issue = True and dl.pullRequest = :pr") Boolean existsIssue(@Param("pr") LPVSPullRequest pr); + + List findByPullRequest(LPVSPullRequest lpvsPullRequest); + Page findByPullRequest(LPVSPullRequest lpvsPullRequest, Pageable pageable); + + + @Query(value = "select count(*) from LPVSDetectedLicense dl where dl.pullRequest = :pr and dl.license is not null") + Long CountByDetectedLicenseWherePullRequestId(@Param("pr") LPVSPullRequest pr); + } diff --git a/src/main/java/com/lpvs/repository/LPVSLicenseRepository.java b/src/main/java/com/lpvs/repository/LPVSLicenseRepository.java index b99580e6..6f0680aa 100644 --- a/src/main/java/com/lpvs/repository/LPVSLicenseRepository.java +++ b/src/main/java/com/lpvs/repository/LPVSLicenseRepository.java @@ -26,4 +26,5 @@ public interface LPVSLicenseRepository extends CrudRepository @Query(value = "SELECT * FROM licenses WHERE licenses.license_alternative_names LIKE %:licenseName% ORDER BY id DESC LIMIT 1", nativeQuery = true) LPVSLicense searchByAlternativeLicenseNames(@Param("licenseName") String licenseName); + } diff --git a/src/main/java/com/lpvs/repository/LPVSPullRequestRepository.java b/src/main/java/com/lpvs/repository/LPVSPullRequestRepository.java index a2c17afb..d0b0c375 100644 --- a/src/main/java/com/lpvs/repository/LPVSPullRequestRepository.java +++ b/src/main/java/com/lpvs/repository/LPVSPullRequestRepository.java @@ -31,4 +31,18 @@ public interface LPVSPullRequestRepository extends JpaRepository findByPullRequestBase(@Param("name") String name, Pageable pageable); + + @Query(value = "select count(*) from LPVSPullRequest pr where pr.pullRequestBase = :name") + Long CountByPullRequestBase(@Param("name") String name); + + @Query(value = "select pr from LPVSPullRequest pr where pr.sender = :name or pr.pullRequestHead = :name") + Page findBySenderOrPullRequestHead(@Param("name") String name, Pageable pageable); + + @Query(value = "select count(*) from LPVSPullRequest pr where pr.sender = :name or pr.pullRequestHead = :name") + Long CountBySenderOrPullRequestHead(@Param("name") String name); + + } diff --git a/src/main/java/com/lpvs/service/LPVSLoginCheckService.java b/src/main/java/com/lpvs/service/LPVSLoginCheckService.java index 06310bf2..3cbbac55 100644 --- a/src/main/java/com/lpvs/service/LPVSLoginCheckService.java +++ b/src/main/java/com/lpvs/service/LPVSLoginCheckService.java @@ -53,26 +53,36 @@ public void loginVerification(Authentication authentication) { } } - @Transactional public LPVSMember getMemberFromMemberMap(Authentication authentication) { Map memberMap = getOauthLoginMemberMap(authentication); - String name = (String) memberMap.get("name"); String email = (String) memberMap.get("email"); String provider = (String) memberMap.get("provider"); - Optional findMemberOptional = memberRepository.findByEmailAndProvider(email, provider); + LPVSMember findMember = memberRepository.findByEmailAndProvider(email, provider).get(); - if (findMemberOptional.isPresent()) { - return findMemberOptional.get(); - } else { - LPVSMember newMember = new LPVSMember(); - newMember.setJoin(name, email, provider); - memberRepository.save(newMember); - return newMember; - } + return findMember; } + +// @Transactional +// public LPVSMember getMemberFromMemberMap(Authentication authentication) { +// Map memberMap = getOauthLoginMemberMap(authentication); +// String name = (String) memberMap.get("name"); +// String email = (String) memberMap.get("email"); +// String provider = (String) memberMap.get("provider"); +// +// Optional findMemberOptional = memberRepository.findByEmailAndProvider(email, provider); +// +// if (findMemberOptional.isPresent()) { +// return findMemberOptional.get(); +// } else { +// LPVSMember newMember = new LPVSMember(); +// newMember.setJoin(name, email, provider); +// memberRepository.save(newMember); +// return newMember; +// } +// } public HistoryPageEntity pathCheck(String type, String name, - Pageable pageable, Authentication authentication) { + Pageable pageable, Authentication authentication) { loginVerification(authentication); LPVSMember findMember = getMemberFromMemberMap(authentication); @@ -83,11 +93,11 @@ public HistoryPageEntity pathCheck(String type, String name, if ((type.equals("own") && findNickName.equals(name)) || (type.equals("org") && findOrganization.equals(name))) { - prPage = lpvsPullRequestRepository.findPullRequestByNameLike(name + "/", pageable); - count = lpvsPullRequestRepository.CountByPullRequestWhereNameLike(name + "/"); + prPage = lpvsPullRequestRepository.findByPullRequestBase(name, pageable); + count = lpvsPullRequestRepository.CountByPullRequestBase(name); } else if (type.equals("send") && findNickName.equals(name)) { - prPage = lpvsPullRequestRepository.findBySender(name, pageable); - count = lpvsPullRequestRepository.CountBySender(name); + prPage = lpvsPullRequestRepository.findBySenderOrPullRequestHead(name, pageable); + count = lpvsPullRequestRepository.CountBySenderOrPullRequestHead(name); } else { throw new WrongAccessException("WrongAccessException"); } diff --git a/src/main/java/com/lpvs/service/LPVSQueueService.java b/src/main/java/com/lpvs/service/LPVSQueueService.java index 86040a66..c9c27661 100644 --- a/src/main/java/com/lpvs/service/LPVSQueueService.java +++ b/src/main/java/com/lpvs/service/LPVSQueueService.java @@ -97,8 +97,9 @@ public void checkForQueue() throws InterruptedException { pullRequest.setRepositoryName(LPVSWebhookUtil.getRepositoryOrganization(webhook) + "/" + LPVSWebhookUtil.getRepositoryName(webhook)); pullRequest.setDate(webhook.getDate()); pullRequest.setStatus(LPVSPullRequestStatus.NO_ACCESS.toString()); + pullRequest.setPullRequestHead(webhook.getPullRequestHead()); + pullRequest.setPullRequestBase(webhook.getPullRequestBase()); pullRequest.setSender(webhook.getSender()); - pullRequest.setOwner(webhook.getOwner()); pullRequest = lpvsPullRequestRepository.saveAndFlush(pullRequest); if (webhook.getUserId().equals("GitHub hook")) { @@ -138,8 +139,9 @@ public void processWebHook(LPVSQueue webhookConfig) throws IOException { pullRequest.setRepositoryName(LPVSWebhookUtil.getRepositoryOrganization(webhookConfig) + "/" + LPVSWebhookUtil.getRepositoryName(webhookConfig)); pullRequest.setDate(webhookConfig.getDate()); pullRequest.setStatus(LPVSPullRequestStatus.SCANNING.toString()); + pullRequest.setPullRequestHead(webhookConfig.getPullRequestHead()); + pullRequest.setPullRequestBase(webhookConfig.getPullRequestBase()); pullRequest.setSender(webhookConfig.getSender()); - pullRequest.setOwner(webhookConfig.getOwner()); pullRequest = lpvsPullRequestRepository.saveAndFlush(pullRequest); log.debug("ID: " + pullRequest.getId() + " " + pullRequest.toString()); diff --git a/src/main/java/com/lpvs/util/LPVSWebhookUtil.java b/src/main/java/com/lpvs/util/LPVSWebhookUtil.java index fcf96530..35451bc0 100644 --- a/src/main/java/com/lpvs/util/LPVSWebhookUtil.java +++ b/src/main/java/com/lpvs/util/LPVSWebhookUtil.java @@ -39,8 +39,9 @@ public static LPVSQueue getGitHubWebhookConfig(String payload) { .getAsJsonObject("head") .get("sha").getAsString()); + webhookConfig.setPullRequestBase(json.getAsJsonObject("pull_request").getAsJsonObject("base").getAsJsonObject("repo").getAsJsonObject("owner").get("login").getAsString()); + webhookConfig.setPullRequestHead(json.getAsJsonObject("pull_request").getAsJsonObject("head").getAsJsonObject("repo").getAsJsonObject("owner").get("login").getAsString()); webhookConfig.setSender(json.getAsJsonObject("sender").get("login").getAsString()); - webhookConfig.setOwner(json.getAsJsonObject("pull_request").getAsJsonObject("head").getAsJsonObject("repo").getAsJsonObject("owner").get("login").getAsString()); webhookConfig.setAttempts(0); return webhookConfig; } From 47a74d75171a915adf426f33f42a6596b4f52168 Mon Sep 17 00:00:00 2001 From: Han Kyuhyun Date: Tue, 3 Oct 2023 23:56:46 +0900 Subject: [PATCH 10/11] Update Test File, db_dump, header. Signed-off-by: Han Kyuhyun Co-authored-by: ByunJeongHeum Co-authored-by: June Saehwan Co-authored-by: jongmin Lee --- .../lpvs/controller/LPVSWebController.java | 1 - .../lpvs/entity/history/HistoryEntity.java | 2 +- .../entity/history/HistoryPageEntity.java | 2 +- .../com/lpvs/entity/history/LPVSHistory.java | 2 +- .../lpvs/entity/result/LPVSResultFile.java | 10 +++---- .../lpvs/entity/result/LPVSResultInfo.java | 8 +++--- .../lpvs/service/LPVSLoginCheckService.java | 20 -------------- src/main/resources/database_dump.sql | 3 +++ .../GitHubWebhooksControllerTest.java | 11 ++++++-- .../com/lpvs/entity/LPVSPullRequestTest.java | 9 ++++--- .../java/com/lpvs/util/WebHookUtilTest.java | 26 +++++++++++++++---- 11 files changed, 51 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/lpvs/controller/LPVSWebController.java b/src/main/java/com/lpvs/controller/LPVSWebController.java index da4e3124..4de264ed 100644 --- a/src/main/java/com/lpvs/controller/LPVSWebController.java +++ b/src/main/java/com/lpvs/controller/LPVSWebController.java @@ -69,7 +69,6 @@ public LPVSMember personalInfoSettings(Authentication authentication) { public LPVSLoginMember loginMember(Authentication authentication) { Map oauthLoginMemberMap = lpvsLoginCheckService.getOauthLoginMemberMap(authentication); boolean isLoggedIn = oauthLoginMemberMap == null || oauthLoginMemberMap.isEmpty(); - log.info("{}", oauthLoginMemberMap); if (!isLoggedIn) { LPVSMember findMember = lpvsLoginCheckService.getMemberFromMemberMap(authentication); return new LPVSLoginMember(!isLoggedIn, findMember); diff --git a/src/main/java/com/lpvs/entity/history/HistoryEntity.java b/src/main/java/com/lpvs/entity/history/HistoryEntity.java index 437f91d9..c66623be 100644 --- a/src/main/java/com/lpvs/entity/history/HistoryEntity.java +++ b/src/main/java/com/lpvs/entity/history/HistoryEntity.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. * * Use of this source code is governed by a MIT license that can be * found in the LICENSE file. diff --git a/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java b/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java index 5b6c8c89..6a561b31 100644 --- a/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java +++ b/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. * * Use of this source code is governed by a MIT license that can be * found in the LICENSE file. diff --git a/src/main/java/com/lpvs/entity/history/LPVSHistory.java b/src/main/java/com/lpvs/entity/history/LPVSHistory.java index 837259ca..0412eb7f 100644 --- a/src/main/java/com/lpvs/entity/history/LPVSHistory.java +++ b/src/main/java/com/lpvs/entity/history/LPVSHistory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. * * Use of this source code is governed by a MIT license that can be * found in the LICENSE file. diff --git a/src/main/java/com/lpvs/entity/result/LPVSResultFile.java b/src/main/java/com/lpvs/entity/result/LPVSResultFile.java index 3904be97..f93f4a85 100644 --- a/src/main/java/com/lpvs/entity/result/LPVSResultFile.java +++ b/src/main/java/com/lpvs/entity/result/LPVSResultFile.java @@ -6,11 +6,11 @@ @Getter @AllArgsConstructor public class LPVSResultFile { - private Long id; //dl.id - private String path; //dl.file_path - private String componentFileUrl; //dl - private String matchLine; //dl - private String matchValue; //dl + private Long id; + private String path; + private String componentFileUrl; + private String matchLine; + private String matchValue; private String status; //license.licenseUsage private String licenseSpdx; //license diff --git a/src/main/java/com/lpvs/entity/result/LPVSResultInfo.java b/src/main/java/com/lpvs/entity/result/LPVSResultInfo.java index a8f0be45..1380957c 100644 --- a/src/main/java/com/lpvs/entity/result/LPVSResultInfo.java +++ b/src/main/java/com/lpvs/entity/result/LPVSResultInfo.java @@ -10,9 +10,9 @@ @Getter @Setter @AllArgsConstructor public class LPVSResultInfo { - private Long id; //pr.id - private Date scanDate; //pr - private String repositoryName; //pr - private String status; //pr + private Long id; + private Date scanDate; + private String repositoryName; + private String status; private List detectedLicenses; } diff --git a/src/main/java/com/lpvs/service/LPVSLoginCheckService.java b/src/main/java/com/lpvs/service/LPVSLoginCheckService.java index 3cbbac55..24a299db 100644 --- a/src/main/java/com/lpvs/service/LPVSLoginCheckService.java +++ b/src/main/java/com/lpvs/service/LPVSLoginCheckService.java @@ -19,12 +19,10 @@ import org.springframework.security.core.Authentication; import org.springframework.security.oauth2.core.user.OAuth2User; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Map; -import java.util.Optional; @Service public class LPVSLoginCheckService { @@ -63,24 +61,6 @@ public LPVSMember getMemberFromMemberMap(Authentication authentication) { return findMember; } -// @Transactional -// public LPVSMember getMemberFromMemberMap(Authentication authentication) { -// Map memberMap = getOauthLoginMemberMap(authentication); -// String name = (String) memberMap.get("name"); -// String email = (String) memberMap.get("email"); -// String provider = (String) memberMap.get("provider"); -// -// Optional findMemberOptional = memberRepository.findByEmailAndProvider(email, provider); -// -// if (findMemberOptional.isPresent()) { -// return findMemberOptional.get(); -// } else { -// LPVSMember newMember = new LPVSMember(); -// newMember.setJoin(name, email, provider); -// memberRepository.save(newMember); -// return newMember; -// } -// } public HistoryPageEntity pathCheck(String type, String name, Pageable pageable, Authentication authentication) { diff --git a/src/main/resources/database_dump.sql b/src/main/resources/database_dump.sql index f03ed74c..ad61453e 100644 --- a/src/main/resources/database_dump.sql +++ b/src/main/resources/database_dump.sql @@ -90,6 +90,9 @@ CREATE TABLE `pull_requests` ( `url` longtext NOT NULL, `diff_url` longtext, `status` varchar(255) DEFAULT NULL, + `pull_request_head` varchar(255) NOT NULL, + `pull_request_base` varchar(255) NOT NULL, + `sender` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/src/test/java/com/lpvs/controller/GitHubWebhooksControllerTest.java b/src/test/java/com/lpvs/controller/GitHubWebhooksControllerTest.java index 55c29424..039981ab 100644 --- a/src/test/java/com/lpvs/controller/GitHubWebhooksControllerTest.java +++ b/src/test/java/com/lpvs/controller/GitHubWebhooksControllerTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. * * Use of this source code is governed by a MIT license that can be * found in the LICENSE file. @@ -76,10 +76,17 @@ public void okTest() { "}, " + "\"pull_request\": {" + "\"html_url\": \"https://github.com/Samsung/LPVS/pull/18\", " + - "\"head\": {" + + "\"base\": {" + "\"repo\": {" + "\"owner\": {" + "\"login\": \"Samsung\"" + + "}" + + "}" + + "}," + + "\"head\": {" + + "\"repo\": {" + + "\"owner\": {" + + "\"login\": \"o-kopysov\"" + "}," + "\"fork\": true, " + "\"html_url\": \"https://github.com/o-kopysov/LPVS/tree/utests\"" + diff --git a/src/test/java/com/lpvs/entity/LPVSPullRequestTest.java b/src/test/java/com/lpvs/entity/LPVSPullRequestTest.java index 66eb923a..a9fdf7e1 100644 --- a/src/test/java/com/lpvs/entity/LPVSPullRequestTest.java +++ b/src/test/java/com/lpvs/entity/LPVSPullRequestTest.java @@ -25,8 +25,10 @@ public class LPVSPullRequestTest { final String pullRequestUrl = "pulRequestUrl"; final String pullRequestFilesUrl = "pullRequestFileUrl"; final String status = "status"; + final String pullRequestBase = "user"; + final String pullRequestHead = "user"; final String sender = "user"; - final String owner = "user"; + @BeforeEach void setUp() { @@ -37,8 +39,9 @@ void setUp() { pullRequestUrl, pullRequestFilesUrl, status, - sender, - owner); + pullRequestBase, + pullRequestHead, + sender); } @Test diff --git a/src/test/java/com/lpvs/util/WebHookUtilTest.java b/src/test/java/com/lpvs/util/WebHookUtilTest.java index 605af324..6ce62140 100644 --- a/src/test/java/com/lpvs/util/WebHookUtilTest.java +++ b/src/test/java/com/lpvs/util/WebHookUtilTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2022, Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. * * Use of this source code is governed by a MIT license that can be * found in the LICENSE file. @@ -34,10 +34,17 @@ void setUp() { "}, " + "\"pull_request\": {" + "\"html_url\": \"https://github.com/Samsung/LPVS/pull/18\", " + - "\"head\": {" + + "\"base\": {" + "\"repo\": {" + "\"owner\": {" + "\"login\": \"Samsung\"" + + "}" + + "}" + + "}, " + + "\"head\": {" + + "\"repo\": {" + + "\"owner\": {" + + "\"login\": \"o-kopysov\"" + "}," + "\"fork\": true, " + "\"html_url\": \"https://github.com/o-kopysov/LPVS/tree/utests\"" + @@ -59,8 +66,9 @@ void setUp() { expected.setPullRequestAPIUrl("https://api.github.com/repos/Samsung/LPVS/pulls/18"); expected.setRepositoryUrl("https://github.com/Samsung/LPVS"); expected.setUserId("GitHub hook"); + expected.setPullRequestBase("Samsung"); + expected.setPullRequestHead("o-kopysov"); expected.setSender("o-kopysov"); - expected.setOwner("Samsung"); expected.setHeadCommitSHA("edde69ecb8e8a88dde09fa9789e2c9cab7cf7cf9"); expected.setAttempts(0); } @@ -90,10 +98,17 @@ void setUp() { "}, " + "\"pull_request\": {" + "\"html_url\": \"https://github.com/Samsung/LPVS/pull/18\", " + - "\"head\": {" + + "\"base\": {" + "\"repo\": {" + "\"owner\": {" + "\"login\": \"Samsung\"" + + "}" + + "}" + + "}, " + + "\"head\": {" + + "\"repo\": {" + + "\"owner\": {" + + "\"login\": \"o-kopysov\"" + "}," + "\"fork\": false, " + "\"html_url\": \"https://github.com/o-kopysov/LPVS/tree/utests\"" + @@ -115,8 +130,9 @@ void setUp() { expected.setPullRequestAPIUrl("https://api.github.com/repos/Samsung/LPVS/pulls/18"); expected.setRepositoryUrl("https://github.com/Samsung/LPVS"); expected.setUserId("GitHub hook"); + expected.setPullRequestBase("Samsung"); + expected.setPullRequestHead("o-kopysov"); expected.setSender("o-kopysov"); - expected.setOwner("Samsung"); expected.setHeadCommitSHA("edde69ecb8e8a88dde09fa9789e2c9cab7cf7cf9"); expected.setAttempts(0); } From a5b31951a9f2f91d8f66d6f1ed13beddeb18538a Mon Sep 17 00:00:00 2001 From: Han Kyuhyun Date: Wed, 4 Oct 2023 09:32:58 +0900 Subject: [PATCH 11/11] Update header. Signed-off-by: Han Kyuhyun Co-authored-by: ByunJeongHeum Co-authored-by: June Saehwan Co-authored-by: jongmin Lee --- .../java/com/lpvs/entity/history/HistoryEntity.java | 2 +- .../com/lpvs/entity/history/HistoryPageEntity.java | 2 +- .../java/com/lpvs/entity/history/LPVSHistory.java | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/lpvs/entity/history/HistoryEntity.java b/src/main/java/com/lpvs/entity/history/HistoryEntity.java index c66623be..312c6021 100644 --- a/src/main/java/com/lpvs/entity/history/HistoryEntity.java +++ b/src/main/java/com/lpvs/entity/history/HistoryEntity.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. + * Copyright 2023 Basaeng, kyudori, hwan5180, quswjdgma83 * * Use of this source code is governed by a MIT license that can be * found in the LICENSE file. diff --git a/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java b/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java index 6a561b31..41c0335f 100644 --- a/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java +++ b/src/main/java/com/lpvs/entity/history/HistoryPageEntity.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. + * Copyright 2023 Basaeng, kyudori, hwan5180, quswjdgma83 * * Use of this source code is governed by a MIT license that can be * found in the LICENSE file. diff --git a/src/main/java/com/lpvs/entity/history/LPVSHistory.java b/src/main/java/com/lpvs/entity/history/LPVSHistory.java index 0412eb7f..2014b3fc 100644 --- a/src/main/java/com/lpvs/entity/history/LPVSHistory.java +++ b/src/main/java/com/lpvs/entity/history/LPVSHistory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. + * Copyright 2023 Basaeng, kyudori, hwan5180, quswjdgma83 * * Use of this source code is governed by a MIT license that can be * found in the LICENSE file. @@ -13,11 +13,11 @@ @Getter @Setter @AllArgsConstructor public class LPVSHistory { - private String scanDate; //pr - private String repositoryName; //pr - private Long pullRequestId; //pr - private String url; // pr - private String status; //pr + private String scanDate; + private String repositoryName; + private Long pullRequestId; + private String url; + private String status; private String sender; private String pullNumber; // pull/number private Boolean hasIssue;