Skip to content
This repository has been archived by the owner on Nov 14, 2022. It is now read-only.

Tab based session closing UI #67

Closed
wants to merge 1 commit into from
Closed
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
28 changes: 17 additions & 11 deletions cast/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var sessions = [];
var clickCount = 0;
var TID = 0;
const MAX_LINES = 9999999;
const status = document.getElementById("status");
let socket;

const generateSSID = () => (
Expand Down Expand Up @@ -74,29 +75,35 @@ const focusStyle = (tid) => {
tablink.style.color = "white";
logger.style.display = "block";
document.getElementById(tab.ssid).style.display = "none";
status.innerHTML =
'<span class="disconnected">tab disconnected</span>';
}
else {
tablink.classList.add('active');
logger.style.display = "none";
document.getElementById(tab.ssid).style.display = "block";
status.innerHTML =
'<span class="connected">connected</span>';
}
console.log("Session ID: " + getTabByTID(tid).ssid);
}

const openSession = (tid) => {
let tab = getTabByTID(tid);
focusStyle(tid);
console.log(tab.ssid);
// currentSession = tab.session;
currentSsid = tab.session.ssid;
// document.getElementById(tab.ssid).style.display = "block";
console.log(`openSession:: ${JSON.stringify(currentSsid)}`)
if (socket) {
// To register new session on WebSocket server
socket.emit("new-session", { session_id: currentSsid });

// To mark current tab as the current session on WebSocket server
socket.emit("client-input", { input: '', session_id: currentSsid })
if(closedTabs.includes(tid)){
console.log(socket);
console.log("This session is closed");
} else {
console.log(`openSession:: ${JSON.stringify(currentSsid)}`)
if (socket) {
// To register new session on WebSocket server
socket.emit("new-session", { session_id: currentSsid });

// To mark current tab as the current session on WebSocket server
socket.emit("client-input", { input: '', session_id: currentSsid })
}
}
}

Expand Down Expand Up @@ -272,7 +279,6 @@ function downloadLog(ssid = currentSsid) {


socket = io.connect("/cast", { query: `session_id=${currentSsid}` });
const status = document.getElementById("status");

socket.on("client-output", (data) => {
let ssid = data.ssid;
Expand Down
1 change: 0 additions & 1 deletion cast/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ def connect(data=None):

print("connect: task started")


@socketio.on("client-input", namespace="/cast")
def client_input(data):
# Update current session
Expand Down