Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3851] - Add Collaborate Space #3912

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ var urlsToCache = [
'planet/js/ProjectStorage.js',
'planet/js/ServerInterface.js',
'planet/js/GlobalPlanet.js',
'planet/js/CollaborationSpace.js',
'planet/js/LocalPlanet.js',
'planet/js/ProjectViewer.js',
'planet/js/GlobalTag.js',
Expand Down
5 changes: 3 additions & 2 deletions planet/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<script type="text/javascript" src="js/GlobalTag.js"></script>
<script type="text/javascript" src="js/GlobalCard.js"></script>
<script type="text/javascript" src="js/ProjectViewer.js"></script>
<script type="text/javascript" src="js/CollaborationSpace.js"></script>
<script type="text/javascript" src="js/GlobalPlanet.js"></script>

<script type="text/javascript" src="js/Planet.js"></script>
Expand All @@ -62,9 +63,9 @@
}
</script>

<body>
<body id="planetBody">
<nav class="nav-extended light-green lighten-1" role="navigation">
<div class="nav-wrapper container">
<div class="nav-wrapper container" id="planetNavWrapper">
<a id="logo-container" class="brand-logo inactiveLink"><i class="material-icons" id="planeticon">public</i></a>
<ul class="right"><li><a id="close-planet" class="tooltipped" data-position="bottom" data-delay="50" data-tooltip=""><i class="material-icons">close</i></a></li></ul>
<ul class="right"><li><a id="planet-open-file" class="tooltipped" data-position="bottom" data-delay="50" data-tooltip=""><i class="material-icons">folder_open</i></a></li></ul>
Expand Down
133 changes: 133 additions & 0 deletions planet/js/CollaborationSpace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// Copyright (c) 2024 Ajeet Pratap Singh
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the The GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// You should have received a copy of the GNU Affero General Public
// License along with this library; if not, write to the Free Software
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA

// CollaborationSpace

class CollaborationSpace {
constructor(Planet) {
this.planet = Planet;
}

renderNavbar() {

// Hide buttons in navbar that will not be used in collaboration

const globalTab = document.getElementById("global-tab");
globalTab.style.display = "none";

const localTab = document.getElementById("local-tab");
localTab.style.display = "none";

const searchContainer = document.getElementById("searchcontainer-one");
searchContainer.style.display = "none";

const newProjectButton = document.getElementById("planet-new-project");
newProjectButton.style.display = "none";

const openFileButton = document.getElementById("planet-open-file");
openFileButton.style.display = "none";

const closePlanetButton = document.getElementById("close-planet");
closePlanetButton.style.display = "none";

// Add exit button in the navbar

const planetNav = document.getElementById("planetNavWrapper");

const exitBtn = document.createElement("ul");
exitBtn.id = "exitCollabRoom";
exitBtn.classList.add("right");
exitBtn.textContent = "Exit";
exitBtn.style.cursor = "pointer";
exitBtn.style.padding = "3px";
exitBtn.href = "#global";

planetNav.appendChild(exitBtn);
exitBtn.addEventListener("click", this.exitSpace);

}

renderCommonSpace(){

// Hide global and local tabs
const globalPage = document.getElementById("global");
globalPage.style.visibility = "hidden";

const localPage = document.getElementById("local");
localPage.style.visibility = "hidden";

const planetBody = document.getElementById("planetBody");
// Add a note of under construction
const note = document.createElement("h5");
note.id = "constructionNote";
note.textContent = "(Under Construction)";
note.style.color = "black";
note.style.position = "absolute";
note.style.top = "50%";
note.style.left = "50%";
note.style.transform = "translate(-50%, -50%)";

planetBody.appendChild(note);

}

// Prepare the room by adding/hiding elements

prepareRoom(){
this.renderNavbar();
this.renderCommonSpace();
}

// Exit the collaboration space
exitSpace(){

const exitButton = document.getElementById("exitCollabRoom");
exitButton.remove();

const constructionNote = document.getElementById("constructionNote");
constructionNote.remove();

const globalTab = document.getElementById("global-tab");
globalTab.style.display = "";

const localTab = document.getElementById("local-tab");
localTab.style.display = "";

const searchContainer = document.getElementById("searchcontainer-one");
searchContainer.style.display = "block";

const newProjectButton = document.getElementById("planet-new-project");
newProjectButton.style.display = "";

const openFileButton = document.getElementById("planet-open-file");
openFileButton.style.display = "";

const closePlanetButton = document.getElementById("close-planet");
closePlanetButton.style.display = "";


const globalPage = document.getElementById("global");
globalPage.style.visibility = "visible";

const localPage = document.getElementById("local");
localPage.style.visibility = "visible";

}

// Render the room
renderRoom(){
this.prepareRoom();
}

initiate() {
this.renderRoom();
}
}
11 changes: 10 additions & 1 deletion planet/js/GlobalCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ class GlobalCard {
)}</a>
</div>
</div>
</div>
</div>
<a class="project-icon tooltipped" data-position="bottom" data-delay="50" data-tooltip="${_(
"Collaborate"
)}" id="global-project-collaborate-{ID}"><i class="material-icons">group</i></a>
</div>
</div>

Expand Down Expand Up @@ -160,6 +163,12 @@ class GlobalCard {
Planet.GlobalPlanet.ProjectViewer.open(this.id);
});

// set collaboration starter
// eslint-disable-next-line no-unused-vars
frag.getElementById(`global-project-collaborate-${this.id}`).addEventListener("click", (evt) => {
Planet.GlobalPlanet.CollaborationSpace.initiate();
});

// set merge modify listener
// eslint-disable-next-line no-unused-vars
frag.getElementById(`global-project-merge-${this.id}`).addEventListener("click", (evt) => {
Expand Down
4 changes: 3 additions & 1 deletion planet/js/GlobalPlanet.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GlobalPlanet {
constructor(Planet) {
this.Planet = Planet ;
this.ProjectViewer = null;

this.CollaborationSpace = null;
this.offlineHTML = `<div class= "container center-align">
${_(`Feature unavailable - cannot connect to server. Reload ${Planet.IsMusicBlocks ? "Music" : "Turtle"} Blocks to try again.`)}
</div>`;
Expand Down Expand Up @@ -596,6 +596,8 @@ class GlobalPlanet {

this.ProjectViewer = new ProjectViewer(Planet);
this.ProjectViewer.init();
this.CollaborationSpace = new CollaborationSpace(Planet);
this.CollaborationSpace.init();
}
};

Expand Down