Skip to content

Commit

Permalink
Merge branch 'main' into dec_5
Browse files Browse the repository at this point in the history
  • Loading branch information
YouweiPeng authored Dec 6, 2023
2 parents cccd6fb + d54cb11 commit eaeb5d8
Show file tree
Hide file tree
Showing 7 changed files with 346 additions and 19 deletions.
6 changes: 6 additions & 0 deletions frontend/pages/AdminPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ <h2>Active Users</h2>
</ul>
</div>
</div>
<div class="user-list active-users">
<h2>External node connection</h2>
<ul id="nodeConnectionList">
</ul>
</div>
<button id="backButton">Back to Dashboard</button>
<div id="editUserModal" class="modal">
<div class="modal-content">
<span class="close-button">×</span>
Expand Down
4 changes: 4 additions & 0 deletions frontend/pages/Dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ <h3>Options</h3>
<option value="FRIENDS">Friends Only</option>
</select>
</div>
<div class="unlistedOption">
<input type="checkbox" id="unlistedCheckbox">
<label for="unlistedCheckbox">Unlisted?</label>
</div>

<h4>Content</h4>
<textarea id="postContent" name="postContent" maxlength="500" placeholder="Enter Text (Max 500 characters)"></textarea>
Expand Down
40 changes: 40 additions & 0 deletions frontend/scripts/adminPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const Backbtn = document.getElementById('backButton');
document.addEventListener("DOMContentLoaded", () => {
const activeUserList = document.getElementById('activeUserList');
const inactiveUserList = document.getElementById('inactiveUserList');
const nodeConnectionList = document.getElementById('nodeConnectionList');
const users = [];
const fetchAuthors = async () => {
try {
Expand Down Expand Up @@ -86,6 +87,45 @@ document.addEventListener("DOMContentLoaded", () => {
}
}
fetchAuthors();
const fetchNodeConnections = async () => {
try {
const response = await axios.get('https://beeg-yoshi-backend-858f363fca5e.herokuapp.com/service/admin/node/');

response.data.forEach(nodeConnection => {
console.log(nodeConnection);
const nodeConnectionItem = document.createElement('div');
nodeConnectionItem.className = 'user-item';
nodeConnectionItem.textContent = nodeConnection.name + " is ";
const statusWords= nodeConnection.active? 'active' : 'inactive';
nodeConnectionItem.textContent+= statusWords;
const actionButton = document.createElement('button');
const buttonContainer = document.createElement('div');
buttonContainer.className = 'button-container';
const deleteNodeConnection = async (nodeConnection) => {
console.log(nodeConnection);
console.log("delete is called");

try {
const data={
name:nodeConnection.name,
}
const response = await axios.put(`https://beeg-yoshi-backend-858f363fca5e.herokuapp.com/service/admin/node/`, data);
window.location.reload();
}catch(error) {
console.log(error);
}
}
actionButton.textContent = nodeConnection.active ? 'Deactivate' : 'Activate';
actionButton.onclick = () => deleteNodeConnection(nodeConnection);
buttonContainer.appendChild(actionButton);
nodeConnectionItem.appendChild(buttonContainer);
nodeConnectionList.appendChild(nodeConnectionItem);
});
}catch(error) {
console.log(error)
}
}
fetchNodeConnections();
});
Backbtn.addEventListener('click', () => {
window.location.href = "Dashboard.html";
Expand Down
Loading

0 comments on commit eaeb5d8

Please sign in to comment.