Skip to content

Commit 0a19ac2

Browse files
authored
Merge pull request #81 from Madriix/master
Correction of the change nickname conflict and update of the page web admin
2 parents 0206b2a + c0672dd commit 0a19ac2

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

lib/Server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ class Server {
393393
case 'NICK':
394394
if (socket.hash && this.connections[socket.hash] && command[1]) {
395395
this.connections[socket.hash].write("NICK " + command[1] + "\n");
396-
this.connections[socket.hash].nick = command[1];
396+
//this.connections[socket.hash].nick = command[1];
397397
}
398398
break;
399399
case 'JBNC':

lib/WebAdminPanel.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class WebAdminPanel {
6161
let connection = {
6262
key: key,
6363
nick: this.connections[key].nick,
64+
user: this.connections[key].user,
65+
host: this.connections[key].host,
66+
realname: this.connections[key].realname,
6467
channelCount: this.instanceConnections.userChannelCount(key)
6568
};
6669
connectionsData.push(connection);

lib/webadminpanel/dashboard.html

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
body {
1111
padding: 0 20px;
1212
}
13+
li {
14+
margin: 3px;
15+
}
1316
</style>
1417
</head>
1518

@@ -21,7 +24,7 @@ <h5>Last UncaughtException: {{ last_bug }}</h5>
2124
<h2 class="mt-4">Connections (total: {{ count }}) :</h2>
2225
<ul>
2326
<li v-for="connection in connections" :key="connection.id">
24-
Key: {{ connection.key }} - Nick: {{ connection.nick }} - Number of channels: {{ connection.channelCount }} - <button class="kill" :data-key="connection.key">Kill</button>
27+
Key: {{ connection.key }} - Nick: {{ connection.nick }} - User: {{ connection.user }} - Host: {{ connection.host }} - Number of channels: {{ connection.channelCount }} - <button class="kill btn btn-primary" @click="removeConnection(connection.key, $event)">Kill</button>
2528
</li>
2629
</ul>
2730
</div>
@@ -54,22 +57,11 @@ <h2 class="mt-4">Connections (total: {{ count }}) :</h2>
5457
.catch(error => {
5558
console.error('Error while retrieving data:', error);
5659
});
57-
}
58-
},
59-
mounted() {
60-
this.fetchData();
61-
setInterval(() => {
62-
this.fetchData();
63-
}, 5000);
64-
}
65-
});
66-
67-
document.addEventListener("DOMContentLoaded", function() {
68-
document.addEventListener("click", function(event) {
69-
if (event.target.classList.contains('kill')) {
60+
},
61+
removeConnection(key, event) {
7062
var data = {
7163
command: "kill",
72-
key: event.target.getAttribute('data-key')
64+
key: key
7365
};
7466

7567
var url = new URL("/send", window.location.origin);
@@ -83,10 +75,14 @@ <h2 class="mt-4">Connections (total: {{ count }}) :</h2>
8375
throw new Error('Error fetching data');
8476
}
8577
})
86-
.then(function(data) {
78+
.then((data) => {
8779
if (data == "disconnected") {
8880
event.target.innerText="disconnected !";
89-
event.target.disabled=true;
81+
const index = this.connections.findIndex(connection => connection.key === key);
82+
if (index !== -1) {
83+
this.connections.splice(index, 1);
84+
this.count--;
85+
}
9086
}
9187
else
9288
console.log("Error !");
@@ -95,11 +91,15 @@ <h2 class="mt-4">Connections (total: {{ count }}) :</h2>
9591
console.error("Error sending request:", error);
9692
});
9793
}
98-
});
94+
},
95+
mounted() {
96+
this.fetchData();
97+
setInterval(() => {
98+
this.fetchData();
99+
}, 5000);
100+
}
99101
});
100102

101-
102-
103103
</script>
104104
</body>
105105
</html>

0 commit comments

Comments
 (0)