diff --git a/frontend/pages/AdminPage.html b/frontend/pages/AdminPage.html
index 11e06eb..d8c87b7 100644
--- a/frontend/pages/AdminPage.html
+++ b/frontend/pages/AdminPage.html
@@ -22,6 +22,12 @@
×
diff --git a/frontend/pages/Dashboard.html b/frontend/pages/Dashboard.html
index 0d1e305..1a5e865 100644
--- a/frontend/pages/Dashboard.html
+++ b/frontend/pages/Dashboard.html
@@ -75,6 +75,10 @@
Options
+
+
+
+
Content
diff --git a/frontend/scripts/adminPage.js b/frontend/scripts/adminPage.js
index b62ed20..38ab9ec 100644
--- a/frontend/scripts/adminPage.js
+++ b/frontend/scripts/adminPage.js
@@ -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 {
@@ -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";
diff --git a/frontend/scripts/home.js b/frontend/scripts/home.js
index ce059fc..a204e65 100644
--- a/frontend/scripts/home.js
+++ b/frontend/scripts/home.js
@@ -62,7 +62,7 @@ const encodedCredentials = btoa(`${username}:${password}`);
console.log(userData);
if(userData.type==="SERVERADMIN"){
let li = document.createElement("li");
- li.innerHTML = '
Manage Author Access';
+ li.innerHTML = '
Manage Access';
nav.appendChild(li);
}
}
@@ -116,8 +116,14 @@ const encodedCredentials = btoa(`${username}:${password}`);
}
}
getFriends();
- const getPosts = async () => { // A-Team
- try {
+ const getPosts = async () => {
+ const res= await axios.get(`https://beeg-yoshi-backend-858f363fca5e.herokuapp.com/service/admin/node/`)
+ const Web_Weaver_connection=res.data[0]
+ const A_Team_connection=res.data[1]
+ console.log(Web_Weaver_connection);
+ console.log(A_Team_connection);
+ if (A_Team_connection.active) {
+ try {// A-Team
const response = await axios.get(`https://c404-5f70eb0b3255.herokuapp.com/getAllPublicPosts/`)
console.log(response.data.results.items);
response.data.results.items.forEach(post => {
@@ -283,7 +289,127 @@ const encodedCredentials = btoa(`${username}:${password}`);
switch(action) {
case "share":
- console.log("share is clicked");
+ friendModal.style.display = "block";
+ friendList.innerHTML = '';
+ let friendsHtml = '';
+ friendData.forEach(friend => {
+ console.log(friend);
+ const serverName = friend.host === "https://beeg-yoshi-backend-858f363fca5e.herokuapp.com/" ? "Beeg Yoshi" : friend.server;
+ const friendHtml = `
+
+
+
+
+ ${friend.displayName}
+
+ `;
+ if (serverName === "Beeg Yoshi") {
+ friendsHtml += friendHtml;
+ }
+ if(serverName==="A-Team" && A_Team_connection.active){
+ friendsHtml += friendHtml;
+ }
+ if(serverName==="Web Weavers" && Web_Weaver_connection.active){
+ friendsHtml += friendHtml;
+ }
+ });
+ const submitbtnHTML = `
+
+ `
+ friendsHtml += submitbtnHTML;
+ friendList.innerHTML = friendsHtml;
+ const items = document.querySelectorAll(".item");
+ items.forEach(item => {
+ item.addEventListener("click", () => {
+ item.classList.toggle("checked");
+ });
+ })
+ document.querySelector(".share-posts-btn").addEventListener("click", () => {
+ const selectedFriends = [];
+ document.querySelectorAll(".item.checked").forEach(item => {
+ const server = item.querySelector(".item-text").dataset.server;
+ if (server ==="A-team" && A_Team_connection.active) {
+ console.log('A team member is added')
+ selectedFriends.push({ id: item.dataset.userId, server: server });
+ }
+ else if (server ==="Web Weavers" && Web_Weaver_connection.active) {
+ console.log('Web weavers member is added')
+ selectedFriends.push({ id: item.dataset.userId, server: server });
+ }
+ else if (server ==="Beeg Yoshi") {
+ selectedFriends.push({ id: item.dataset.userId, server: server });
+ }
+ });
+ selectedFriends.forEach(friend => {
+ console.log(friend);
+ if(friend.server==="Beeg Yoshi"){
+ const friendId = friend.id;
+ const sharePost = async () => {
+ const imageTosend=[]
+ imageTosend.push(post.image);
+ const numberOfLikes = post.likes.length;
+ const data = {
+ senderId:userData.id,
+ senderName:userData.displayName,
+ postId:post.id,
+ post:post.content,
+ author:post.author.displayName,
+ count:post.count,
+ images:imageTosend,
+ numberOfLikes:numberOfLikes,
+ }
+ try {
+ const response = await axios.get(`https://beeg-yoshi-backend-858f363fca5e.herokuapp.com/service/authors/${friendId}/inbox/`)
+ const friendRequest=response.data.items["friendrequests"];
+ const notifications=response.data.items["notifications"];
+ const inbox = response.data.items["inbox"];
+ inbox.push(data);
+ const InboxData={"inbox":inbox,"notifications":notifications,"friendrequests":friendRequest}
+ try {
+ const response = await axios.put(`https://beeg-yoshi-backend-858f363fca5e.herokuapp.com/service/authors/${friendId}/inbox/`,InboxData)
+ console.log(response.data);
+ friendModal.style.display = "none";
+ } catch (error) {
+ console.log(error);
+ }
+ } catch (error) {
+ console.log(error);
+ }
+
+ }
+
+ sharePost();
+ }
+ else if(friend.server==="A-Team"){
+ console.log("Also picked A-Team");
+ friendModal.style.display = "none";
+ }
+ else if (friend.server==="Web Weavers"){
+ console.log("Also picked Web Weavers");
+ const SharepostToWebWeavers = async () => {
+ const data = {
+ id:post.source,
+ type: "post",
+ }
+ try {
+ const res= await axios.post(`https://web-weavers-backend-fb4af7963149.herokuapp.com/authors/${friend.id}/inbox/`,data, {
+ headers: {
+ authorization: `Basic ${encodedCredentials}`
+ }
+ })
+ console.log(res.data);
+ friendModal.style.display = "none";
+ } catch (error) {
+ console.log(error);
+ }
+ }
+ SharepostToWebWeavers();
+
+ }
+ })
+
+ });
+ break;
}
});
});
@@ -296,6 +422,8 @@ const encodedCredentials = btoa(`${username}:${password}`);
} catch (error) {
console.log(error);
}
+ }
+ if (Web_Weaver_connection.active) {
try { //Web weavers
const response = await axios.get(`https://web-weavers-backend-fb4af7963149.herokuapp.com/public-posts/`,{
headers: {
@@ -508,7 +636,125 @@ const encodedCredentials = btoa(`${username}:${password}`);
}
switch(action) {
case "share":
- console.log("share is clicked");
+ friendModal.style.display = "block";
+ friendList.innerHTML = '';
+ let friendsHtml = '';
+ friendData.forEach(friend => {
+ console.log(friend);
+ const serverName = friend.host === "https://beeg-yoshi-backend-858f363fca5e.herokuapp.com/" ? "Beeg Yoshi" : friend.server;
+ const friendHtml = `
+
+
+
+
+ ${friend.displayName}
+
+ `;
+ if (serverName === "Beeg Yoshi") {
+ friendsHtml += friendHtml;
+ }
+ if(serverName==="A-Team" && A_Team_connection.active){
+ friendsHtml += friendHtml;
+ }
+ if(serverName==="Web Weavers" && Web_Weaver_connection.active){
+ friendsHtml += friendHtml;
+ }
+ });
+ const submitbtnHTML = `
+
+ `
+ friendsHtml += submitbtnHTML;
+ friendList.innerHTML = friendsHtml;
+ const items = document.querySelectorAll(".item");
+ items.forEach(item => {
+ item.addEventListener("click", () => {
+ item.classList.toggle("checked");
+ });
+ })
+ document.querySelector(".share-posts-btn").addEventListener("click", () => {
+ const selectedFriends = [];
+ document.querySelectorAll(".item.checked").forEach(item => {
+ const server = item.querySelector(".item-text").dataset.server;
+ if (server ==="A-team" && A_Team_connection.active) {
+ console.log('A team member is added')
+ selectedFriends.push({ id: item.dataset.userId, server: server });
+ }
+ else if (server ==="Web Weavers" && Web_Weaver_connection.active) {
+ console.log('Web weavers member is added')
+ selectedFriends.push({ id: item.dataset.userId, server: server });
+ }
+ else if (server ==="Beeg Yoshi") {
+ selectedFriends.push({ id: item.dataset.userId, server: server });
+ }
+ });
+ selectedFriends.forEach(friend => {
+ if(friend.server==="Beeg Yoshi"){
+ const friendId = friend.id;
+ const sharePost = async () => {
+ const image_for_this_post = [];
+ if(post.content.startsWith('http://') || post.content.startsWith('https://')){
+ image_for_this_post.push(post.content);
+ }
+ const data = {
+ senderId:userData.id,
+ senderName:userData.displayName,
+ postId:post.id,
+ post:post.title,
+ author:post.author.displayName,
+ count:post.count,
+ images:image_for_this_post,
+ }
+ try {
+ const response = await axios.get(`https://beeg-yoshi-backend-858f363fca5e.herokuapp.com/service/authors/${friendId}/inbox/`)
+ const friendRequest=response.data.items["friendrequests"];
+ const notifications=response.data.items["notifications"];
+ const inbox = response.data.items["inbox"];
+ inbox.push(data);
+ const InboxData={"inbox":inbox,"notifications":notifications,"friendrequests":friendRequest}
+ try {
+ const response = await axios.put(`https://beeg-yoshi-backend-858f363fca5e.herokuapp.com/service/authors/${friendId}/inbox/`,InboxData)
+ console.log(response.data);
+ friendModal.style.display = "none";
+ } catch (error) {
+ console.log(error);
+ }
+ } catch (error) {
+ console.log(error);
+ }
+
+ }
+
+ sharePost();
+ }
+ else if(friend.server==="A-Team"){
+ console.log("Also picked A-Team");
+ friendModal.style.display = "none";
+ }
+ else if (friend.server==="Web Weavers"){
+ console.log("Also picked Web Weavers");
+ const SharepostToWebWeavers = async () => {
+ const data = {
+ id:post.source,
+ type: "post",
+ }
+ try {
+ const res= await axios.post(`https://web-weavers-backend-fb4af7963149.herokuapp.com/authors/${friend.id}/inbox/`,data, {
+ headers: {
+ authorization: `Basic ${encodedCredentials}`
+ }
+ })
+ console.log(res.data);
+ friendModal.style.display = "none";
+ } catch (error) {
+ console.log(error);
+ }
+ }
+ SharepostToWebWeavers();
+
+ }
+ })
+
+ });
}
});
@@ -522,6 +768,7 @@ const encodedCredentials = btoa(`${username}:${password}`);
} catch (error) {
console.log(error);
}
+ }
try { //beeg-yoshi
const response = await axios.get(`https://beeg-yoshi-backend-858f363fca5e.herokuapp.com/service/authors/get/${userData.id}/posts/`);
let images=[];
@@ -718,7 +965,15 @@ const encodedCredentials = btoa(`${username}:${password}`);
${friend.displayName}
`;
- friendsHtml += friendHtml;
+ if (serverName === "Beeg Yoshi") {
+ friendsHtml += friendHtml;
+ }
+ if(serverName==="A-Team" && A_Team_connection.active){
+ friendsHtml += friendHtml;
+ }
+ if(serverName==="Web Weavers" && Web_Weaver_connection.active){
+ friendsHtml += friendHtml;
+ }
});
const submitbtnHTML = `
@@ -735,7 +990,17 @@ const encodedCredentials = btoa(`${username}:${password}`);
const selectedFriends = [];
document.querySelectorAll(".item.checked").forEach(item => {
const server = item.querySelector(".item-text").dataset.server;
+ if (server ==="A-team" && A_Team_connection.active) {
+ console.log('A team member is added')
selectedFriends.push({ id: item.dataset.userId, server: server });
+ }
+ else if (server ==="Web Weavers" && Web_Weaver_connection.active) {
+ console.log('Web weavers member is added')
+ selectedFriends.push({ id: item.dataset.userId, server: server });
+ }
+ else if (server ==="Beeg Yoshi") {
+ selectedFriends.push({ id: item.dataset.userId, server: server });
+ }
});
selectedFriends.forEach(friend => {
if(friend.server==="Beeg Yoshi"){
@@ -958,6 +1223,8 @@ postButton.addEventListener("click", () =>{
const visibility=document.querySelector("#visibility").value;
const selectedOptions = Array.from(categoriesElement.selectedOptions);
const categories = selectedOptions.map(option => option.value);
+ const unlistedCheckbox = document.getElementById('unlistedCheckbox');
+ const isUnlisted = unlistedCheckbox.checked;
const createPost = async ()=> {
const data={
title:title,
@@ -965,7 +1232,8 @@ postButton.addEventListener("click", () =>{
content:content,
contentType:contentType,
categories:categories,
- visibility:visibility
+ visibility:visibility,
+ unlisted: isUnlisted
}
try{
const response= await axios.post(`https://beeg-yoshi-backend-858f363fca5e.herokuapp.com/service/authors/${userData.id}/posts/`,data)
diff --git a/frontend/scripts/notificationsPage.js b/frontend/scripts/notificationsPage.js
index efa39de..0b9f072 100644
--- a/frontend/scripts/notificationsPage.js
+++ b/frontend/scripts/notificationsPage.js
@@ -80,7 +80,7 @@ const fetchInbox= async () => {
@@ -92,7 +92,7 @@ const fetchInbox= async () => {
const closeInboxNodeBtn = document.querySelector(".close");
closeInboxNodeBtn.addEventListener("click", () => {
inboxNodeModal.style.display="none";
- document.body.style.overflow = "auto"; /* unlocks the background */
+ document.body.style.overflow = "auto";
})
})
inboxStream.appendChild(node);
diff --git a/frontend/scripts/socialPage.js b/frontend/scripts/socialPage.js
index 59261c9..67af3a8 100644
--- a/frontend/scripts/socialPage.js
+++ b/frontend/scripts/socialPage.js
@@ -13,11 +13,16 @@ if (userData) {
console.log(userData)
if(userData.type==="SERVERADMIN"){
let li = document.createElement("li");
- li.innerHTML = '