collabora-online/browser/admin/src/AdminSocketHistory.js

51 lines
1.2 KiB
JavaScript

/* -*- js-indent-level: 8 -*- */
/*
Socket to be intialized on opening the history page in Admin console
*/
/* global Admin $ AdminSocketBase */
var AdminSocketHistory = AdminSocketBase.extend({
constructor: function(host) {
this.base(host);
},
refreshHistory: function() {
this.socket.send('history');
},
onSocketOpen: function() {
// Base class' onSocketOpen handles authentication
this.base.call(this);
var socketHistory = this;
$('#refreshHistory').on('click', function () {
return socketHistory.refreshHistory();
});
this.refreshHistory();
},
onSocketMessage: function(e) {
//if (e.data == 'InvalidAuthToken' || e.data == 'NotAuthenticated') {
// this.base.call(this);
// this.refreshHistory();
//} else {
var jsonObj;
try {
jsonObj = JSON.parse(e.data);
var doc = jsonObj['History']['documents'];
var exdoc = jsonObj['History']['expiredDocuments'];
$('#json-doc').find('textarea').html(JSON.stringify(doc));
$('#json-ex-doc').find('textarea').html(JSON.stringify(exdoc));
} catch (e) {
$('document').alert(e.message);
}
},
onSocketClose: function() {
this.base.call(this);
}
});
Admin.History = function(host) {
return new AdminSocketHistory(host);
};