2013-10-03 15:04:25 -04:00
|
|
|
define(function() {
|
|
|
|
|
var Admin = {};
|
2013-07-15 13:49:21 -04:00
|
|
|
|
2013-11-29 23:08:42 -05:00
|
|
|
Admin.init = function() {
|
2014-01-16 15:10:37 -05:00
|
|
|
ajaxify.register_events(['meta.rooms.getAll']);
|
2014-01-10 13:27:50 -05:00
|
|
|
|
|
|
|
|
app.enterRoom('admin');
|
2014-01-16 15:10:37 -05:00
|
|
|
socket.emit('meta.rooms.getAll', Admin.updateRoomUsage);
|
2014-01-13 12:01:42 -05:00
|
|
|
socket.on('event:meta.rooms.update', Admin.updateRoomUsage);
|
2013-07-15 13:49:21 -04:00
|
|
|
|
2013-11-29 23:08:42 -05:00
|
|
|
$('#logout-link').on('click', function() {
|
|
|
|
|
$.post(RELATIVE_PATH + '/logout', {
|
|
|
|
|
_csrf: $('#csrf_token').val()
|
|
|
|
|
}, function() {
|
|
|
|
|
window.location.href = RELATIVE_PATH + '/';
|
|
|
|
|
});
|
|
|
|
|
})
|
2013-10-03 15:04:25 -04:00
|
|
|
};
|
2013-07-15 13:49:21 -04:00
|
|
|
|
2014-01-13 12:01:42 -05:00
|
|
|
Admin.updateRoomUsage = function(data) {
|
|
|
|
|
console.log('room usage updating', data);
|
|
|
|
|
var active_users = document.getElementById('active_users'),
|
|
|
|
|
total = 0;
|
|
|
|
|
active_users.innerHTML = '';
|
|
|
|
|
|
|
|
|
|
for (var room in data) {
|
|
|
|
|
if (room !== '') {
|
|
|
|
|
var count = data[room].length;
|
|
|
|
|
total += count;
|
|
|
|
|
active_users.innerHTML = active_users.innerHTML + "<div class='alert alert-success'><strong>" + room + "</strong> " + count + " active user" + (count > 1 ? "s" : "") + "</div>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.getElementById('connections').innerHTML = total;
|
|
|
|
|
};
|
|
|
|
|
|
2013-10-03 15:04:25 -04:00
|
|
|
return Admin;
|
|
|
|
|
});
|