Skip to content

Commit

Permalink
Merge pull request #246 from osamhack2021/feature/api-hotfix
Browse files Browse the repository at this point in the history
* 최종 PR
  • Loading branch information
dev-taewon-kim authored Oct 20, 2021
2 parents 5bbc3a0 + 588dadd commit bf553f4
Show file tree
Hide file tree
Showing 11 changed files with 487 additions and 522 deletions.
580 changes: 298 additions & 282 deletions WEB(FE)/frontend/public/main.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions WEB(FE)/frontend/src/components/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react';
import { Box, Chip, TextField } from '@mui/material';

export default function Demo(demoPaddingTop, demoPaddingLeft) {
return(
return (
<Box sx={{ display: "flex", marginBottom: "3px" }}>
<Chip label="Demo" color="warning" sx={{ color: "white", fontWeight: "bold" }}/>
<h4 style={{ color: "darkgray", marginLeft: "7px", marginTop: "5px" }}>본 페이지는 BETA 테스트 시범운영중으로 일부 오류가 발생할 수 있습니다.</h4>
</Box>
<Chip label="Beta" color="info" sx={{ color: "white", fontWeight: "bold" }} />
<h4 style={{ color: "darkgray", marginLeft: "7px", marginTop: "5px" }}>본 페이지는 BETA 테스트 시범운영 중으로 일부 오류가 발생할 수 있습니다.</h4>
</Box>
);
}
69 changes: 40 additions & 29 deletions WEB(FE)/frontend/src/components/Modal/LoginModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,42 @@ const LoginModal = (props) => {
color: 'white',
};

const onClick = () => {
alert('데모 버전에서는 제공하지 않는 기능입니다')
};

const fetchLoginApi = (e) => {
fetch('/api/user/login/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
})
.then((res) => res.json())
.then((json) => {
if (json.token) {
props.userHasAuthenticated(
true,
data.username,
json.token
);
alert('환영합니다.' + username + '님.');
history.push('/presstrends');
props.setModal(true);
console.log(json);
} else {
alert('아이디 또는 비밀번호를 확인해주세요.');
}
})
.catch((error) => alert(error));
}

const keyDown = (e) => {
if (e.key === 'Enter')
fetchLoginApi();
}

return (
<Box className="loginModalBack">
<Paper elevation={10} style={paperStyle}>
Expand Down Expand Up @@ -79,42 +115,16 @@ const LoginModal = (props) => {
required
variant="outlined"
onChange={handlePasswordChange}
onKeyDown={keyDown}
/>
</Box>
{/* */}
<Link sx={{ textDecoration: 'none' }}>
<Button
type="submit"
variant="contained"
style={btnstyle}
className="JoinLoign-button"
onClick={(e) => {
e.preventDefault();
fetch('/api/user/login/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
})
.then((res) => res.json())
.then((json) => {
if (json.token) {
props.userHasAuthenticated(
true,
data.username,
json.token
);
alert('환영합니다.' + username + '님.');
history.push('/presstrends');
props.setModal(true);
console.log(json);
} else {
alert('아이디 또는 비밀번호를 확인해주세요.');
}
})
.catch((error) => alert(error));
}}
onClick={fetchLoginApi}
>
로그인
</Button>
Expand All @@ -130,7 +140,8 @@ const LoginModal = (props) => {
{/* <br /> */}
<Typography align="center" variant="subtitle1">
<Link
href="/register"
// href="/register"
onClick={onClick}
sx={{ textDecoration: 'none', color: '#3a8ffb' }}
>
RISKOUT 회원이 아닌가요? 지금 가입하세요.
Expand Down
7 changes: 4 additions & 3 deletions WEB(FE)/frontend/src/components/Modal/SecretsDetailModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function SecretsDetailModal(props) {
<hr align="left" />
</Typography>
<Stack direction="row" justifyContent="flex-end" spacing={1}>
<Chip
{/* <Chip
style={{ borderRadius: '6px' }}
variant="outlined"
aria-label="add to scrap"
Expand All @@ -79,13 +79,14 @@ export default function SecretsDetailModal(props) {
onClick={() => analyzePage(data._id)}
icon={<AnalyzeIcon />}
label="Analyze"
/>
/> */}

<Chip
style={{ borderRadius: '6px' }}
variant="outlined"
onClick={() => {
window.open(data.site_url, '_blank').focus();
let url = (data.category === 'sns') ? ('https://twitter.com/search?q=' + data.author + '&src=typed_query&f=user') : data.site_url;
window.open(url, '_blank').focus();
}}
icon={<NavigationIcon sx={{ mr: 1 }} />}
label="Source"
Expand Down
2 changes: 1 addition & 1 deletion WEB(FE)/frontend/src/components/RiskReport/Graphs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function Graphs({ data }) {
const barData = [
{ category: '기밀 유출 횟수', value: data.secretsCount },
{ category: '허위 뉴스 개수', value: data.fakeNewsCount },
{ category: '부정적 기사 비율 (%)', value: data.negativeSentiment * 100 },
{ category: '부정적 기사 비율 (%)', value: (data.negativeSentiment * 100).toFixed(2) },
];

let total = 0;
Expand Down
9 changes: 8 additions & 1 deletion WEB(FE)/frontend/src/lib/api/searchDetected.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import client from './client';
// import client from './client';
import axios from 'axios'

export async function searchDetected(params) {
const formatted = {
Expand All @@ -7,6 +8,12 @@ export async function searchDetected(params) {
.filter((k) => params.tags[k].length !== 0 && k !== 'ETC')
.reduce((a, k) => ({ ...a, [k]: params.tags[k] }), {}),
};
const client = axios.create({
headers: {
Authorization: `Token ${localStorage.getItem('token')}`,
},
withCredentials: true,
});
const requestUrl =
process.env.REACT_APP_USE_STATIC_RESPONSE == 'True'
? `/static/SecretData.example.json`
Expand Down
6 changes: 4 additions & 2 deletions WEB(FE)/frontend/src/pages/DetectionStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,18 @@ export default function DetectionStatus() {
console.log(search);
if (shouldScrap) {
addCart(_id);
message = 'Scrapped article | ' + article.title;
message = article.title ? article.title : 'Twitter Article';
message = 'Scrapped article | ' + message;
variant = 'success';
} else {
removeCart(_id);
message = article.title ? article.title : 'Twitter Article';
message = 'Removed article | ' + article.title;
variant = 'default';
}
enqueueSnackbar(message, {
variant: variant,
autoHideDuration: 10000,
autoHideDuration: 3000,
});
return;
};
Expand Down
Loading

0 comments on commit bf553f4

Please sign in to comment.