var history;
var graph;
var symbols;
+ var read_only = false;
+ var btn_class = "";
+ var stat_timeout;
var selected = []; // Keep graph selectors state
symbols.destroy();
symbols = null;
}
+ clearTimeout(stat_timeout);
cleanCredentials();
connectRSPAMD();
// window.location.reload();
// @detect session storate
supportsSessionStorage();
- // @request credentials
- function requestCredentials() {
- $.ajax({
- dataType: 'json',
- type: 'GET',
- url: 'auth',
- jsonp: false,
- beforeSend: function (xhr) {
- xhr.setRequestHeader('Password', getPassword());
- },
- success: function (data) {
- if (data.auth === 'failed') {
- connectRSPAMD();
- }
- }
- });
- }
- // @request credentials
- function updateCredentials() {
- $.ajax({
- dataType: 'json',
- type: 'GET',
- url: 'auth',
- beforeSend: function (xhr) {
- xhr.setRequestHeader('Password', getPassword());
- },
- success: function (data) {
- saveCredentials(data, password);
- }
- });
- }
// @save credentials
function saveCredentials(data, password) {
if (!supportsSessionStorage()) {
$.each(data, function (i, item) {
var caption;
var label;
- if ((item.editable == false)) {
+ if ((item.editable == false || read_only)) {
caption = 'View';
label = '<span class="label label-default">Read</span>';
} else {
},
success: function (text) {
var disabled = '';
- if ((item.editable == false)) {
+ if ((item.editable == false || read_only)) {
disabled = 'disabled="disabled"';
}
// @show widgets
function statWidgets() {
var widgets = $('#statWidgets');
- updateCredentials();
$(widgets).empty().hide();
var data;
if (!supportsSessionStorage()) {
});
$('#statWidgets .left,#statWidgets .right').wrapAll('<li class="stat-box pull-right"><div class="widget"></div></li>');
$(widgets).show();
- window.setTimeout(statWidgets, 10000);
+ stat_timeout = window.setTimeout(statWidgets, 10000);
}
// @opem modal with target form enabled
$(document).on('click', '[data-toggle="modal"]', function (e) {
'" id="_sym_' + item.symbol + '"></span></td>' +
'<td data-order="' + item.frequency + '">' + item.frequency + '</td>' +
'<td data-order="' + item.time + '">' + Number(item.time).toFixed(2) + 'ms</td>' +
- '<td><button type="button" class="btn btn-primary btn-sm">Save</button></td>' +
- '</tr>');
+ '<td><button type="button" class="btn btn-primary btn-sm ' + btn_class +
+ '">Save</button></td></tr>');
});
});
$('<tbody/>', {
return e.html;
}).join('') +
'<br><div class="form-group">' +
- '<button class="btn btn-primary" ' +
- 'type="submit">Save actions</button></div></form>');
+ '<button class="btn btn-primary ' + btn_class +
+ '" type="submit">Save actions</button></div></form>');
}
});
}
alertMessage('alert-modal alert-error', data.statusText);
}
});
- getMapById('update');
return false;
});
// @catch changes of file upload form
displayUI();
return;
}
- $.ajax({
- type: 'GET',
- url: 'stat',
- jsonp: false,
- success: function () {
- saveCredentials({}, 'nopassword');
- $(dialog).hide();
- $(backdrop).hide();
- displayUI();
- },
- });
var nav = $('#navBar');
var ui = $('#mainUI');
var dialog = $('#connectDialog');
$(dialog).show();
$('#connectHost').focus();
$(backdrop).show();
- $(document).on('submit', '#connectForm', function (e) {
+ $('#connectForm').one('submit', function (e) {
e.preventDefault();
var password = $('#connectPassword').val();
document.getElementById('connectPassword').value = '';
$('.form-group').addClass('error');
});
} else {
+ if (data.read_only) {
+ read_only = true;
+ btn_class = "disabled";
+ $('#learning_nav').parent().addClass('disabled');
+ }
+ else {
+ read_only = false;
+ btn_class = "";
+ $('#learning_nav').parent().removeClass('disabled')
+ }
+
saveCredentials(data, password);
$(dialog).hide();
$(backdrop).hide();
}
/* Check for password if it is required by configuration */
-static gboolean rspamd_controller_check_password(
- struct rspamd_http_connection_entry *entry,
+static gboolean
+rspamd_controller_check_password (struct rspamd_http_connection_entry *entry,
struct rspamd_controller_session *session,
struct rspamd_http_message *msg, gboolean is_enable)
{
st->messages_scanned), "scanned", 0, false);
ucl_object_insert_key (obj, ucl_object_fromint (
st->messages_learned), "learned", 0, false);
+ ucl_object_insert_key (obj, ucl_object_frombool (!session->is_enable),
+ "read_only", 0, false);
rspamd_controller_send_ucl (conn_ent, obj);
ucl_object_unref (obj);