Skip to content

Commit 641ba4a

Browse files
authored
Merge pull request #775 from Real-Dev-Squad/I-758/identityLogs
Page for Identity Service Logs
2 parents 193a2d3 + 78ce667 commit 641ba4a

File tree

6 files changed

+665
-0
lines changed

6 files changed

+665
-0
lines changed

identity-service-logs/constants.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
export const SUPER_USER = 'super_user';
2+
export const BORDER_COLOR = {
3+
PROFILE_VERIFIED: 'blue',
4+
PROFILE_BLOCKED: 'orangered',
5+
PROFILE_DIFF_REJECTED: 'red',
6+
PROFILE_DIFF_APPROVED: 'green',
7+
PROFILE_DIFF_STORED: '#ADD8E6',
8+
};
9+
10+
export const TYPE_NAME = {
11+
PROFILE_VERIFIED: 'PROFILE SERVICE VERIFIED',
12+
PROFILE_BLOCKED: 'PROFILE SERVICE BLOCKED',
13+
PROFILE_DIFF_REJECTED: 'PROFILE DIFFERENCE REJECTED',
14+
PROFILE_DIFF_APPROVED: 'PROFILE DIFFERENCE APPROVED',
15+
PROFILE_DIFF_STORED: 'PROFILE DIFFERENCE STORED',
16+
};
17+
18+
export const TYPE_DESCRIPTION = {
19+
PROFILE_VERIFIED: ({ username }) =>
20+
`${username}'s profile has been verified and is now officially authenticated.`,
21+
PROFILE_BLOCKED: ({ username, reason }) =>
22+
`${username}'s profile has been blocked. ${
23+
reason ? `Reason provided: "${reason}."` : 'No reason provided!'
24+
}`,
25+
PROFILE_DIFF_REJECTED: ({ username, adminUserName, profileDiffId, reason }) =>
26+
`${adminUserName} rejected a profile update request for ${username}. The request with Profile Diff ID ${profileDiffId} was declined due to: "${
27+
reason || ''
28+
}"`,
29+
PROFILE_DIFF_APPROVED: ({ username, adminUserName, profileDiffId, reason }) =>
30+
`${adminUserName} approved a profile update request for ${username}. The changes are now live. The request has a Profile Diff ID ${profileDiffId}. Message: "${
31+
reason || ''
32+
}"`,
33+
PROFILE_DIFF_STORED: ({ username }) =>
34+
`${username}'s profile changes have been saved for further review.`,
35+
};
36+
37+
export const BACKGROUND_COLOR = {
38+
PROFILE_VERIFIED: 'rgba(0,0,255,0.2)',
39+
PROFILE_BLOCKED: 'rgba(255,69,0,0.2)',
40+
PROFILE_DIFF_REJECTED: 'rgba(255,0,0,0.2)',
41+
PROFILE_DIFF_APPROVED: 'rgba(0,128,0,0.2)',
42+
PROFILE_DIFF_STORED: 'rgb(173,216,230,0.2)',
43+
};

identity-service-logs/index.html

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<link rel="icon" href="/images/index.ico" type="image/x-icon" />
8+
<title>Identity Service Logs | Real Dev Squad</title>
9+
<link rel="stylesheet" href="/global.css" />
10+
<link rel="stylesheet" href="/identity-service-logs/style.css" />
11+
<script src="/helpers/loadENV.js"></script>
12+
<script src="/constants.js"></script>
13+
<script type="module" src="/identity-service-logs/script.js" defer></script>
14+
</head>
15+
16+
<body>
17+
<div id="cover-spin"></div>
18+
<nav>
19+
<h1>Identity Service Logs</h1>
20+
</nav>
21+
22+
<div class="stats">
23+
<div>Verified Users: <span id="verified" class="stats-value"></span></div>
24+
<div>Blocked Users: <span id="blocked" class="stats-value"></span></div>
25+
<div>
26+
Total Developers: <span id="developers" class="stats-value"></span>
27+
</div>
28+
<div>
29+
Verified Developers:
30+
<span id="verifiedDevelopers" class="stats-value"></span>
31+
</div>
32+
<div>
33+
Blocked Developers:
34+
<span id="blockedDevelopers" class="stats-value"></span>
35+
</div>
36+
<div>
37+
Developers Left: <span id="developersLeft" class="stats-value"></span>
38+
</div>
39+
</div>
40+
41+
<p id="loader">Loading...</p>
42+
43+
<footer id="footer">
44+
<p class="info-repo">
45+
The contents of this website are deployed from this
46+
<a
47+
href="https://github.com/Real-Dev-Squad/website-dashboard"
48+
target="_blank"
49+
rel="noopener noreferrer"
50+
>
51+
open sourced repo
52+
</a>
53+
</p>
54+
</footer>
55+
</body>
56+
</html>

identity-service-logs/script.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { SUPER_USER } from './constants.js';
2+
3+
import {
4+
getIdentityLogs,
5+
getSelfUser,
6+
fillData,
7+
getUserCount,
8+
} from './utils.js';
9+
10+
const self_user = await getSelfUser();
11+
12+
if (self_user?.roles[SUPER_USER]) {
13+
const {
14+
verifiedUsersCount,
15+
blockedUsersCount,
16+
verifiedDeveloperCount,
17+
blockedDeveloperCount,
18+
developersLeftToVerifyCount,
19+
developersCount,
20+
} = await getUserCount();
21+
document.getElementById('verified').innerText = verifiedUsersCount;
22+
document.getElementById('blocked').innerText = blockedUsersCount;
23+
document.getElementById('developers').innerText = developersCount;
24+
document.getElementById('verifiedDevelopers').innerText =
25+
verifiedDeveloperCount;
26+
document.getElementById('blockedDevelopers').innerText =
27+
blockedDeveloperCount;
28+
document.getElementById('developersLeft').innerText =
29+
developersLeftToVerifyCount;
30+
const { identityLogs, next, prev } = await getIdentityLogs(
31+
'/logs?dev=true&type=PROFILE_BLOCKED,PROFILE_VERIFIED,PROFILE_DIFF_REJECTED,PROFILE_DIFF_APPROVED,PROFILE_DIFF_STORED&size=10',
32+
);
33+
fillData(identityLogs, next, prev);
34+
} else {
35+
document.getElementById('loader').innerHTML = 'You are not authorized !';
36+
}

identity-service-logs/style.css

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
*,
2+
::after,
3+
::before {
4+
box-sizing: border-box;
5+
}
6+
7+
body {
8+
font-family: 'Roboto', sans-serif;
9+
}
10+
11+
#cover-spin {
12+
position: fixed;
13+
width: 100%;
14+
left: 0;
15+
right: 0;
16+
top: 0;
17+
bottom: 0;
18+
background-color: rgba(255, 255, 255, 0.7);
19+
z-index: 9999;
20+
display: none;
21+
}
22+
23+
#cover-spin::after {
24+
content: '';
25+
display: block;
26+
position: absolute;
27+
left: 48%;
28+
top: 40%;
29+
width: 40px;
30+
height: 40px;
31+
border-style: solid;
32+
border-color: black;
33+
border-top-color: transparent;
34+
border-width: 4px;
35+
border-radius: 50%;
36+
-webkit-animation: spin 0.8s linear infinite;
37+
animation: spin 0.8s linear infinite;
38+
}
39+
40+
@keyframes spin {
41+
from {
42+
transform: rotate(0deg);
43+
}
44+
45+
to {
46+
transform: rotate(360deg);
47+
}
48+
}
49+
50+
#loader {
51+
text-align: center;
52+
}
53+
54+
nav {
55+
display: flex;
56+
justify-content: center;
57+
margin-top: 32px;
58+
text-align: center;
59+
}
60+
61+
nav h1 {
62+
position: relative;
63+
max-width: max-content;
64+
font-weight: 500;
65+
}
66+
67+
nav h1::before {
68+
content: '';
69+
position: absolute;
70+
left: 10%;
71+
bottom: -10px;
72+
width: 80%;
73+
height: 2px;
74+
background-color: #000000;
75+
}
76+
77+
.wrapperDiv {
78+
display: flex;
79+
flex-direction: column;
80+
justify-content: center;
81+
align-items: center;
82+
gap: 16px;
83+
margin-top: 16px;
84+
}
85+
86+
.cardDiv {
87+
width: 80%;
88+
padding: 16px 48px;
89+
display: flex;
90+
flex-direction: column;
91+
border-radius: 10px;
92+
}
93+
94+
.typeContainer {
95+
font-size: 16px;
96+
font-weight: 600;
97+
}
98+
99+
.stats {
100+
font-size: 16px;
101+
display: flex;
102+
justify-content: space-around;
103+
align-items: center;
104+
flex-wrap: wrap;
105+
gap: 16px;
106+
padding: 24px 0;
107+
}
108+
109+
.stats-value {
110+
font-size: 16px;
111+
font-weight: 600;
112+
}
113+
114+
.navigation-button {
115+
background-color: #1d1283;
116+
color: #ffffff;
117+
border: none;
118+
border-radius: 0.4rem;
119+
cursor: pointer;
120+
display: flex;
121+
align-items: center;
122+
justify-content: center;
123+
width: 9rem;
124+
height: 2.5rem;
125+
padding: 0.7rem;
126+
}
127+
128+
.navigation-button:hover {
129+
background-color: #11085c;
130+
}
131+
132+
.buttonContainer {
133+
display: flex;
134+
gap: 1.5vw;
135+
justify-content: center;
136+
}
137+
138+
.cardDescription {
139+
font-size: 14px;
140+
font-weight: 400;
141+
}
142+
143+
.timestamp {
144+
font-size: 14px;
145+
font-weight: 600;
146+
text-align: right;
147+
cursor: default;
148+
}
149+
150+
.tooltip-container {
151+
position: relative;
152+
}
153+
154+
.tooltip {
155+
background-color: #000;
156+
color: #fff;
157+
visibility: hidden;
158+
text-align: center;
159+
border-radius: 4px;
160+
padding: 0.5rem;
161+
position: absolute;
162+
opacity: 0.9;
163+
font-size: 0.7rem;
164+
width: 10rem;
165+
bottom: 100%;
166+
left: 50%;
167+
margin-left: -5rem;
168+
}
169+
170+
.tooltip-container:hover .tooltip {
171+
visibility: visible;
172+
transition-delay: 400ms;
173+
}
174+
175+
.dateContainer {
176+
position: relative;
177+
}
178+
179+
.dateRow {
180+
display: flex;
181+
justify-content: end;
182+
}
183+
184+
footer {
185+
width: 100%;
186+
padding: 8px;
187+
}
188+
189+
footer .info-repo {
190+
font-weight: 100;
191+
text-align: center;
192+
}
193+
194+
/* responsive media query for mobile phones */
195+
196+
@media screen and (max-width: 640px) {
197+
.cardDiv {
198+
padding: 16px;
199+
width: 100%;
200+
}
201+
202+
.tooltip {
203+
left: 0;
204+
}
205+
}

0 commit comments

Comments
 (0)