Skip to content

Commit 4b27378

Browse files
committed
fe edit
ui
1 parent 6c1a44e commit 4b27378

File tree

5 files changed

+42
-11
lines changed

5 files changed

+42
-11
lines changed

rsa-frontend/src/contants/endpoints.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const Endpoints = {
55
USER_KEY : `${API_BASE_URL}/user/key`,
66
FILE : `${API_BASE_URL}/file`,
77
FILE_GET : `${API_BASE_URL}/file/get`,
8+
KEY : `${API_BASE_URL}/key`,
89
};
910

1011
export default Endpoints;

rsa-frontend/src/routes/components/FileExplorer.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {openFile} from "./api/OpenFile";
44
import Endpoints from "../../contants/endpoints";
55

66
const FileContainer = ({ owner, fileName, size, id }) => (
7-
<div className={"file-container custom-row"} style={{justifyContent:"space-between",alignItems:"center"}}>
7+
<div key={id} className={"file-container custom-row"} style={{justifyContent:"space-between",alignItems:"center"}}>
88
<div>
99
<p className={"font-bold"}>{owner === 1 ? "Alice" : owner === 2 ? "Bob" : "Charlie" }</p>
1010
<p>{fileName}</p>
@@ -38,6 +38,8 @@ const FileExplorer = () => {
3838

3939
const [loading, setLoading] = useState(false);
4040
const [files, setFiles] = useState(null);
41+
const [publicKey, setPublicKey] = useState(null);
42+
const [privateKey, setPrivateKey] = useState(null);
4143

4244
const clean = () => {
4345
axios.get(`${Endpoints.USER}/clean`)
@@ -66,6 +68,7 @@ const FileExplorer = () => {
6668

6769
useEffect(() => {
6870
fetchFiles();
71+
getKey()
6972
/*
7073
const intervalId = setInterval(() => {
7174
fetchFiles();
@@ -76,6 +79,25 @@ const FileExplorer = () => {
7679
}, []);
7780

7881

82+
const getKey = async () => {
83+
setLoading(true);
84+
try {
85+
const publicResponse = await axios.get(`${Endpoints.KEY}/public`, {
86+
responseType: "text",
87+
});
88+
setPublicKey(publicResponse.data);
89+
const privateResponse = await axios.get(`${Endpoints.KEY}/private`, {
90+
responseType: "text",
91+
});
92+
setPrivateKey(privateResponse.data);
93+
} catch (error) {
94+
console.error("Abahtar alınırken hata oluştu:", error);
95+
} finally {
96+
setLoading(false);
97+
}
98+
};
99+
100+
79101
return (
80102
<>
81103
{loading && <div className={"loading-overlay"}><div className={"main-spinner"}></div></div>}
@@ -85,18 +107,23 @@ const FileExplorer = () => {
85107
<p onClick={fetchFiles} style={{cursor:"pointer"}}>Yenile</p>
86108
</div>
87109
<div className={"custom-row"}>
88-
<img src="/icon/public.png" alt="" className={"mid-icon"}/>
110+
<img src="/icon/public.png" alt="" className={"mid-icon"} />
89111
<div>
90-
<p style={{color: "var(--orange-color-1)"}}>Geçerli <span>Açık Anahtar</span></p>
91-
<p className={"small-text"}>Anahtar Bekleniyor</p>
112+
<p style={{ color: "var(--orange-color-1)" }}>Geçerli <span>Açık Anahtar</span></p>
113+
<p className={"small-text"} style={{ wordBreak: "break-all" }}>
114+
{publicKey == null ? "Anahtar Bekleniyor" : publicKey}
115+
</p>
92116
</div>
93117
</div>
94118

119+
95120
<div className={"custom-row"}>
96121
<img src="/icon/private.png" alt="" className={"mid-icon"}/>
97122
<div>
98123
<p style={{color: "var(--yellow-color-1)"}}>Geçerli <span>Kapalı Anahtar</span></p>
99-
<p className={"small-text"}>Anahtar Bekleniyor</p>
124+
<p className={"small-text"} style={{ wordBreak: "break-all" }}>
125+
{privateKey == null ? "Anahtar Bekleniyor" : privateKey}
126+
</p>
100127
</div>
101128
</div>
102129
{

rsa-frontend/src/routes/components/ScenarioArea.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const UserContainer = ({ user, handleUserToggle }) => {
1515
const fetchFiles = async () => {
1616
setLoading(true);
1717
try {
18-
const response = await axios.get(`${Endpoints.USER}/info/${user.id}`);
18+
const response = await axios.get(`${Endpoints.FILE}/info/${user.id}`);
1919
setFileList(response.data);
2020
} catch (error) {
2121
console.error("Dosyalar alınırken hata oluştu:", error);

rsa-frontend/src/routes/components/Scenarios.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, { useState } from 'react';
22

33
const scenarios = [
4-
{ id: 1, text: 'Birinci Senaryo Yazısı' },
5-
{ id: 2, text: 'İkinci Senaryo Yazısı' },
6-
{ id: 3, text: 'Üçüncü Senaryo Yazısı' },
4+
{ id: 1, text: 'Bu senaryoda tek kullanıcı vardır. Kullanıcı elinde bulunan açık anahtar ile sisteme bir dosya yükler bu dosya şifrelenerek kayıt edilir. Daha sonrasında kullanıcı dosyasına erişmek istediğinde dosyanın şifresi çözülerek kullanıcya iletilir.' },
5+
{ id: 2, text: 'Bu senaryoda iki kullanıcı vardır. İlk kullanıcı ikinci kullanıcıya bir dosya gönderir bu dosya şifreli olarak gider, ikinci kullanıcı ise bu şifreli dosyayı şifresi çözülmüş şekilde alır.' },
6+
{ id: 3, text: 'Bu senaryoda üç kullanıcı vardır. Üçüncü kullanıcı hiçbir anahtarı olmadan diğer kullanıcıların dosyalarına erişmek isteyecektir. Aynı zamanda senaryo 1 ve senaryo 2 içerisinde yapılan işlemlere izinsiz erişim sağlayacaktır. Burada şifrelenmiş dosyalarla karşılaşması beklenmektedir.' },
77
];
88

99
const Scenarios = () => {
@@ -23,7 +23,10 @@ const Scenarios = () => {
2323
))}
2424
</div>
2525
{activeScenario ? (
26-
<p>{scenarios.find(scenario => scenario.id === activeScenario)?.text}</p>
26+
<div>
27+
<p>{scenarios.find(scenario => scenario.id === activeScenario)?.text}</p>
28+
</div>
29+
2730
) : (
2831
<p>Lütfen bir senaryo seçin</p>
2932
)}

rsa-frontend/src/routes/css/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ span{
143143
flex-direction: column;
144144
gap: 12px;
145145
background-color: var(--primary-color-1);
146-
width: max-content;
147146
border-radius: 12px;
148147
padding: 12px;
148+
width: content-box;
149149
}
150150

151151
.scenario-button {

0 commit comments

Comments
 (0)