president/public/js/manager/security.js

97 lines
2.5 KiB
JavaScript
Executable File

$(document).on('click', '.security_view_select', function() {
var view = $(this).attr('view');
settingSetter({
'app': '__president',
'setting': 'security_view',
'value': view
});
$('.security_view').hide();
$('.security_view[view="' + view + '"]').show();
$('.security_view_select').css({ 'background-color': 'lightgray' });
$('.security_view_select[view="' + view +'"]').css({ 'background-color': 'lightgreen' });
var url = '/manager/security';
var timestamp = Date.now();
$.ajax({
url: url,
type: 'GET',
data: { timestamp: timestamp, security_view: view },
success: function(response) {
$('#security').html(response);
appointment_chron();
}, error: function (response) {
padlockReset();
}
});
});
$(document).on('click', '.neighbour_link_updater', function() {
var nlu = $(this);
var nl = nlu.closest('.neighbour_link');
var uuid = nl.attr('uuid');
var nlus = $('.neighbour_link_updater_selection[uuid="' + uuid + '"]');
console.log(uuid);
if (nlus.is(':visible')) {
nlus.hide();
}
else {
nlus.show();
}
});
$(document).on('click', '.neighbour_link_privilege_change', function() {
var privilege = $(this).attr('privilege');
var nl = $(this).closest('.neighbour_link_updater_selection');
console.log(nl);
var uuid = nl.attr('uuid');
console.log(privilege + ' ' + uuid);
$.ajax({
url: '/manager/security/neighbour_link_privilege',
type: 'POST',
data: { uuid: uuid, privilege: privilege },
success: function(response) {
$('#security').html(response);
appointment_chron();
}
});
});
$(document).on('click', '.neighbour_link_credential', function() {
var nlr = $(this).closest('.neighbour_link_request');
var privilege = $(this).attr('privilege');
var credential = nlr.attr('credential');
var remote_address = nlr.attr('remote_address');
var local_address = nlr.attr('local_address');
var my_name = nlr.attr('my_name');
console.log('neighbouring');
$.ajax({
url: '/manager/security/neighbour_link_assign',
type: 'POST',
data: {
privilege: privilege,
remote_address: remote_address,
local_address: local_address,
my_name: my_name,
credential: credential
},
success: function(response) {
$('#alert').html('').hide();
}
});
});
$(document).on('click', '.neighbour_link_delete', function() {
var uuid = $(this).closest('.neighbour_link').attr('uuid');
$.ajax({
url: '/manager/security/neighbour_link_delete',
type: 'POST',
data: { uuid: uuid },
success: function(response) {
$('#security').html(response);
appointment_chron();
}
});
});