';
+ echo '
';
html_print_select(
[
'0' => 'Disable / Enable selected agents',
@@ -248,18 +249,18 @@ class SatelliteAgent extends HTML
);
echo '
';
- echo '';
-
- // Create button.
- echo '
';
+ // Create button add host.
+ echo '
';
html_print_submit_button(
__('Add host'),
'create',
false,
'class="sub next"'
);
+ echo '
';
echo '
';
+
// Load own javascript file.
echo $this->loadJS();
}
@@ -1255,6 +1256,8 @@ class SatelliteAgent extends HTML
$(document).ready(function() {
+ $('body').append('
');
+
$("#submit-create").on('click', function() {
show_form();
});
@@ -1267,61 +1270,140 @@ class SatelliteAgent extends HTML
$('#submit-submit_satellite_action').click(function() {
const checks = $('input[name*=check_]:checked');
const action = $('#satellite_action').val();
- $.each(checks, function(i, val) {
- const params = val.value.split(",");
- if (action === '0') {
- if (params[2] === '0') {
- $.ajax({
- method: 'post',
- async: false,
- url: '',
- data: {
- page: 'enterprise/godmode/servers/agents_satellite',
- method: 'disableAgent',
- address: params[0],
- disable: params[3],
- id: params[4],
- name: params[1],
- no_msg: 1,
- server_remote: satellite_server; ?>,
- },
- datatype: "json",
- success: function (data) {
- },
- error: function(e) {
- console.error(e);
- }
- });
- }
- } else {
- if (params[3] === '0') {
- $.ajax({
- method: 'post',
- async: false,
- url: '',
- data: {
- page: 'enterprise/godmode/servers/agents_satellite',
- method: 'deleteAgent',
- address: params[0],
- name: params[1],
- id: params[4],
- delete: params[2],
- no_msg: 1,
- server_remote: satellite_server; ?>,
- },
- datatype: "json",
- success: function (data) {
- },
- error: function(e) {
- console.error(e);
- }
- });
- }
- }
- });
+ let agent_delete_error = [];
+ let agent_disable_error = [];
+ $('#aux').empty();
+ $('#aux').text('');
+ $('#aux').dialog({
+ title: (action === '0') ? '' : '',
+ buttons: [
+ {
+ class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
+ text: '',
+ click: function(e) {
+ $(this).dialog('close');
+ cleanupDOM();
- var dt_satellite_agents = $("#satellite_agents").DataTable();
- dt_satellite_agents.draw();
+ }
+ },
+ {
+ text: '',
+ class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
+ click: function(e) {
+ $(this).dialog('close');
+ $.each(checks, function(i, val) {
+ const params = val.value.split(",");
+ if (action === '0') {
+ if (params[2] === '0') {
+ $.ajax({
+ method: 'post',
+ async: false,
+ url: '',
+ data: {
+ page: 'enterprise/godmode/servers/agents_satellite',
+ method: 'disableAgent',
+ address: params[0],
+ disable: params[3],
+ id: params[4],
+ name: params[1],
+ no_msg: 1,
+ server_remote: satellite_server; ?>,
+ },
+ datatype: "json",
+ success: function (data) {
+ },
+ error: function(e) {
+ console.error(e);
+ }
+ });
+ } else {
+ agent_disable_error.push(params[0]);
+ }
+ } else {
+ if (params[3] === '0') {
+ $.ajax({
+ method: 'post',
+ async: false,
+ url: '',
+ data: {
+ page: 'enterprise/godmode/servers/agents_satellite',
+ method: 'deleteAgent',
+ address: params[0],
+ name: params[1],
+ id: params[4],
+ delete: params[2],
+ no_msg: 1,
+ server_remote: satellite_server; ?>,
+ },
+ datatype: "json",
+ success: function (data) {
+ },
+ error: function(e) {
+ console.error(e);
+ }
+ });
+ } else {
+ agent_delete_error.push(params[0]);
+ }
+ }
+ });
+
+ if (agent_delete_error.length > 0) {
+ $("#dialog").dialog({
+ resizable: true,
+ draggable: true,
+ modal: true,
+ height: 240,
+ width: 600,
+ title: '',
+ open: function(){
+ let text = '';
+ text += ` (${agent_delete_error.join()})`;
+ $('#dialog').html(`
 | ${text} |
`);
+ },
+ buttons: [
+ {
+ text: "Ok",
+ click: function() {
+ $( this ).dialog( "close" );
+ return false;
+ }
+ }
+ ]
+ });
+ }
+
+ if (agent_disable_error.length > 0) {
+ $("#dialog").dialog({
+ resizable: true,
+ draggable: true,
+ modal: true,
+ height: 240,
+ width: 600,
+ title: '',
+ open: function(){
+ let text = '';
+ text += ` (${agent_disable_error.join()})`;
+ $('#dialog').html(`
 | ${text} |
`);
+ },
+ buttons: [
+ {
+ text: "Ok",
+ click: function() {
+ $( this ).dialog( "close" );
+ return false;
+ }
+ }
+ ]
+ });
+ }
+
+ var dt_satellite_agents = $("#satellite_agents").DataTable();
+ dt_satellite_agents.draw();
+ }
+ }
+ ]
+ });
});
});