blob: cebf32eb074d404c2c73aec834f5f7eb9f0edf3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/* -*- js-indent-level: 8 -*- */
/*
Socket to be intialized on opening the settings page in Admin console
*/
/* global DlgYesNo $ AdminSocketBase Admin _ */
var AdminSocketSettings = AdminSocketBase.extend({
constructor: function(host) {
this.base(host);
this._init();
},
_init: function() {
var socketSettings = this.socket;
$(document).ready(function() {
$('#admin_settings').on('submit', function(e) {
e.preventDefault();
var memStatsSize = $('#mem_stats_size').val();
var memStatsInterval = $('#mem_stats_interval').val();
var cpuStatsSize = $('#cpu_stats_size').val();
var cpuStatsInterval = $('#cpu_stats_interval').val();
var command = 'set';
command += ' mem_stats_size=' + memStatsSize;
command += ' mem_stats_interval=' + memStatsInterval;
command += ' cpu_stats_size=' + cpuStatsSize;
command += ' cpu_stats_interval=' + cpuStatsInterval;
command += ' limit_virt_mem_mb=' + $('#limit_virt_mem_mb').val();
command += ' limit_stack_mem_kb=' + $('#limit_stack_mem_kb').val();
command += ' limit_file_size_mb=' + $('#limit_file_size_mb').val();
socketSettings.send(command);
});
document.getElementById('btnShutdown').onclick = function() {
var dialog = (new DlgYesNo())
.title(_('Confirmation'))
.text(_('Are you sure you want to shut down the server?'))
.yesButtonText(_('OK'))
.noButtonText(_('Cancel'))
.type('warning')
.yesFunction(function() {
socketSettings.send('shutdown maintenance');
});
dialog.open();
};
});
},
onSocketOpen: function() {
// Base class' onSocketOpen handles authentication
this.base.call(this);
this.socket.send('subscribe settings');
this.socket.send('settings');
this.socket.send('version');
},
onSocketMessage: function(e) {
var textMsg;
if (typeof e.data === 'string') {
textMsg = e.data;
}
else {
textMsg = '';
}
if (textMsg.startsWith('settings')) {
textMsg = textMsg.substring('settings '.length);
var settings = textMsg.split(' ');
for (var i = 0; i < settings.length; i++) {
var setting = settings[i].split('=');
var settingKey = setting[0];
var settingVal = setting[1];
var elem = document.getElementById(settingKey);
if (elem) {
elem.value = settingVal;
}
}
}
else if (textMsg.startsWith('coolserver ')) {
// This must be the first message, unless we reconnect.
var coolwsdVersionObj = JSON.parse(textMsg.substring(textMsg.indexOf('{')));
var h = coolwsdVersionObj.Hash;
if (parseInt(h,16).toString(16) === h.toLowerCase().replace(/^0+/, '')) {
h = '<a target="_blank" href="https://github.com/CollaboraOnline/online/commits/' + h + '">' + h + '</a>';
$('#coolwsd-version').html(coolwsdVersionObj.Version + ' (git hash: ' + h + ')');
}
else {
$('#coolwsd-version').text(coolwsdVersionObj.Version);
}
}
else if (textMsg.startsWith('lokitversion ')) {
var lokitVersionObj = JSON.parse(textMsg.substring(textMsg.indexOf('{')));
h = lokitVersionObj.BuildId.substring(0, 7);
if (parseInt(h,16).toString(16) === h.toLowerCase().replace(/^0+/, '')) {
h = '<a target="_blank" href="https://hub.libreoffice.org/git-core/' + h + '">' + h + '</a>';
}
$('#lokit-version').html(lokitVersionObj.ProductName + ' ' +
lokitVersionObj.ProductVersion + lokitVersionObj.ProductExtension +
' (git hash: ' + h + ')');
}
},
onSocketClose: function() {
clearInterval(this._basicStatsIntervalId);
this.base.call(this);
}
});
Admin.Settings = function(host) {
return new AdminSocketSettings(host);
};
|