#4043 Added wizard WMI
This commit is contained in:
parent
e743c57a71
commit
7f220eae19
|
@ -688,6 +688,58 @@ class AgentWizard extends HTML
|
|||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$user_groups = users_get_groups(false, 'AR');
|
||||
if (users_is_admin() === true || isset($user_groups[0]) === true) {
|
||||
$credentials = db_get_all_rows_sql(
|
||||
'SELECT identifier FROM tcredential_store WHERE product LIKE "WMI"'
|
||||
);
|
||||
} else {
|
||||
$credentials = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
'SELECT identifier FROM tcredential_store WHERE product LIKE "WMI" AND id_group IN (%s)',
|
||||
implode(',', array_keys($user_groups))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($credentials) === false) {
|
||||
$test = [];
|
||||
foreach ($credentials as $key => $value) {
|
||||
$test[$value['identifier']] = $value['identifier'];
|
||||
}
|
||||
|
||||
$inputs[] = [
|
||||
'direct' => 1,
|
||||
'block_content' => [
|
||||
[
|
||||
'label' => __('Credential store'),
|
||||
'id' => 'slc-credential',
|
||||
'arguments' => [
|
||||
'name' => 'credential',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
'fields' => $test,
|
||||
'class' => '',
|
||||
'return' => true,
|
||||
'sort' => true,
|
||||
],
|
||||
],
|
||||
[
|
||||
'arguments' => [
|
||||
'label' => __('Apply'),
|
||||
'name' => 'btn-credential',
|
||||
'id' => 'btn-credential',
|
||||
'type' => 'button',
|
||||
'attributes' => 'class="sub next" onclick="" style="margin-left: 20px;padding-top: 3px;padding-bottom: 3px;background-position: 92% 6px;"',
|
||||
'return' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$hint_server = ' ';
|
||||
|
@ -744,6 +796,22 @@ class AgentWizard extends HTML
|
|||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$user_groups = users_get_groups(false, 'AR');
|
||||
if (users_is_admin() === true || isset($user_groups[0]) === true) {
|
||||
$credentials = db_get_all_rows_sql(
|
||||
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP"'
|
||||
);
|
||||
} else {
|
||||
$credentials = db_get_all_rows_sql(
|
||||
sprintf(
|
||||
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP" AND id_group IN (%s)',
|
||||
implode(',', array_keys($user_groups))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
hd($credentials);
|
||||
}
|
||||
|
||||
$inputs[] = [
|
||||
|
@ -5805,6 +5873,33 @@ class AgentWizard extends HTML
|
|||
filterInterfaces();
|
||||
});
|
||||
|
||||
$('#button-btn-credential').click(function() {
|
||||
|
||||
if ($('#credential').val() !== '0') {
|
||||
alert('jejeje si');
|
||||
}
|
||||
// $.ajax({
|
||||
// method: "post",
|
||||
// url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
// data: {
|
||||
// page: "<?php echo $this->ajaxController; ?>",
|
||||
// method: "listModulesToCreate",
|
||||
// data: JSON.stringify(datas),
|
||||
// id_agente: "<?php echo $this->idAgent; ?>",
|
||||
// id: "<?php echo $this->idPolicy; ?>"
|
||||
// },
|
||||
// datatype: "html",
|
||||
// success: function(data) {
|
||||
// // Show hidden OK button
|
||||
// $('.sub.ok.submit-next').removeClass('invisible_important');
|
||||
// $('#' + id).empty().append(data);
|
||||
// },
|
||||
// error: function(e) {
|
||||
// showMsg(e);
|
||||
// }
|
||||
// });
|
||||
});
|
||||
|
||||
// Loading.
|
||||
$('#submit-sub-protocol').click(function() {
|
||||
$('.wizard-result').remove();
|
||||
|
|
|
@ -1133,7 +1133,7 @@ class CredentialStore extends Wizard
|
|||
'name' => 'version',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'script' => '',
|
||||
'script' => 'showVersion()',
|
||||
'fields' => [
|
||||
'1' => __('1'),
|
||||
'2' => __('2'),
|
||||
|
@ -1148,11 +1148,12 @@ class CredentialStore extends Wizard
|
|||
$inputs[] = [
|
||||
'label' => __('Security level'),
|
||||
'id' => 'li_snmp_3',
|
||||
'style' => ($json_values['version'] !== '3') ? 'display: none;' : '',
|
||||
'arguments' => [
|
||||
'name' => 'securityLevelV3',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'script' => '',
|
||||
'script' => 'showSecurity()',
|
||||
'fields' => [
|
||||
'authNoPriv' => __('Authenticated and non-private method'),
|
||||
'authPriv' => __('Authenticated and private method'),
|
||||
|
@ -1166,6 +1167,7 @@ class CredentialStore extends Wizard
|
|||
$inputs[] = [
|
||||
'label' => __('User authentication'),
|
||||
'id' => 'li_snmp_4',
|
||||
'style' => ($json_values['version'] !== '3') ? 'display: none;' : '',
|
||||
'arguments' => [
|
||||
'name' => 'authUserV3',
|
||||
'input_class' => 'flex-row',
|
||||
|
@ -1175,14 +1177,19 @@ class CredentialStore extends Wizard
|
|||
],
|
||||
];
|
||||
|
||||
$authNoPrivate = (
|
||||
isset($json_values['securityLevelV3']) &&
|
||||
($json_values['securityLevelV3'] === 'authNoPriv' || $json_values['securityLevelV3'] === 'authPriv')
|
||||
) ? '' : 'display: none;';
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Authentication method'),
|
||||
'id' => 'li_snmp_5',
|
||||
'style' => $authNoPrivate,
|
||||
'arguments' => [
|
||||
'name' => 'authMethodV3',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'script' => '',
|
||||
'fields' => [
|
||||
'MD5' => __('MD5'),
|
||||
'SHA' => __('SHA'),
|
||||
|
@ -1195,6 +1202,7 @@ class CredentialStore extends Wizard
|
|||
$inputs[] = [
|
||||
'label' => __('Password authentication'),
|
||||
'id' => 'li_snmp_6',
|
||||
'style' => $authNoPrivate,
|
||||
'arguments' => [
|
||||
'name' => 'authPassV3',
|
||||
'input_class' => 'flex-row',
|
||||
|
@ -1204,14 +1212,18 @@ class CredentialStore extends Wizard
|
|||
],
|
||||
];
|
||||
|
||||
$authPrivate = (isset($json_values['securityLevelV3']) && $json_values['securityLevelV3'] === 'authPriv')
|
||||
? ''
|
||||
: 'display: none;';
|
||||
|
||||
$inputs[] = [
|
||||
'label' => __('Privacy method'),
|
||||
'id' => 'li_snmp_7',
|
||||
'style' => $authPrivate,
|
||||
'arguments' => [
|
||||
'name' => 'privacyMethodV3',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'script' => '',
|
||||
'fields' => [
|
||||
'AES' => __('AES'),
|
||||
'DES' => __('DES'),
|
||||
|
@ -1224,6 +1236,7 @@ class CredentialStore extends Wizard
|
|||
$inputs[] = [
|
||||
'label' => __('Privacy pass'),
|
||||
'id' => 'li_snmp_8',
|
||||
'style' => $authPrivate,
|
||||
'arguments' => [
|
||||
'name' => 'privacyPassV3',
|
||||
'input_class' => 'flex-row',
|
||||
|
@ -1366,6 +1379,8 @@ class CredentialStore extends Wizard
|
|||
|
||||
if ($('#li_snmp_1').length > 0) {
|
||||
console.log($('#li_snmp_1').length);
|
||||
const test = '<?php echo $json_values; ?>';
|
||||
console.log(test);
|
||||
} else {
|
||||
const ul = $('#modal_form').children('ul')[0];
|
||||
|
||||
|
@ -1391,19 +1406,7 @@ class CredentialStore extends Wizard
|
|||
select_version.name = 'version';
|
||||
select_version.id = 'version';
|
||||
select_version.onchange = function() {
|
||||
if (this.value === '3') {
|
||||
$('#li_snmp_3').show();
|
||||
$('#li_snmp_4').show();
|
||||
$('#li_snmp_5').show();
|
||||
$('#li_snmp_6').show();
|
||||
} else {
|
||||
$('#li_snmp_3').hide();
|
||||
$('#li_snmp_4').hide();
|
||||
$('#li_snmp_5').hide();
|
||||
$('#li_snmp_6').hide();
|
||||
$('#li_snmp_7').hide();
|
||||
$('#li_snmp_8').hide();
|
||||
}
|
||||
showVersion();
|
||||
};
|
||||
let option1 = document.createElement("option");
|
||||
let option2 = document.createElement("option");
|
||||
|
@ -1433,34 +1436,9 @@ class CredentialStore extends Wizard
|
|||
label_security.textContent = '<?php echo __('Security level'); ?>';
|
||||
const select_security = document.createElement("select");
|
||||
select_security.name = 'securityLevelV3';
|
||||
select_security.id = 'security';
|
||||
select_security.id = 'securityLevelV3';
|
||||
select_security.onchange = function() {
|
||||
switch (this.value) {
|
||||
case 'noAuthNoPriv':
|
||||
$('#li_snmp_4').show();
|
||||
$('#li_snmp_5').hide();
|
||||
$('#li_snmp_6').hide();
|
||||
$('#li_snmp_7').hide();
|
||||
$('#li_snmp_8').hide();
|
||||
break;
|
||||
|
||||
case 'authPriv':
|
||||
$('#li_snmp_4').show();
|
||||
$('#li_snmp_5').show();
|
||||
$('#li_snmp_6').show();
|
||||
$('#li_snmp_7').show();
|
||||
$('#li_snmp_8').show();
|
||||
break;
|
||||
|
||||
case 'authNoPriv':
|
||||
default:
|
||||
$('#li_snmp_4').show();
|
||||
$('#li_snmp_5').show();
|
||||
$('#li_snmp_6').show();
|
||||
$('#li_snmp_7').hide();
|
||||
$('#li_snmp_8').hide();
|
||||
break;
|
||||
}
|
||||
showSecurity();
|
||||
}
|
||||
option1 = document.createElement("option");
|
||||
option2 = document.createElement("option");
|
||||
|
@ -1477,7 +1455,7 @@ class CredentialStore extends Wizard
|
|||
li_security.append(label_security);
|
||||
li_security.append(select_security);
|
||||
ul.append(li_security);
|
||||
$("#security").select2();
|
||||
$("#securityLevelV3").select2();
|
||||
|
||||
// User.
|
||||
const li_user = document.createElement("li");
|
||||
|
@ -1570,6 +1548,63 @@ class CredentialStore extends Wizard
|
|||
}
|
||||
}
|
||||
|
||||
function showVersion() {
|
||||
if ($('#version').val() === '3') {
|
||||
$('#li_snmp_3').show();
|
||||
$('#li_snmp_4').show();
|
||||
$('#li_snmp_5').show();
|
||||
$('#li_snmp_6').show();
|
||||
} else {
|
||||
$('#li_snmp_3').hide();
|
||||
$('#li_snmp_4').hide();
|
||||
$('#li_snmp_5').hide();
|
||||
$('#li_snmp_6').hide();
|
||||
$('#li_snmp_7').hide();
|
||||
$('#li_snmp_8').hide();
|
||||
}
|
||||
}
|
||||
|
||||
function showSecurity() {
|
||||
const value = $('#securityLevelV3').val();
|
||||
switch (value) {
|
||||
case 'noAuthNoPriv':
|
||||
$('#li_snmp_4').show();
|
||||
$('#li_snmp_5').hide();
|
||||
$('#li_snmp_6').hide();
|
||||
$('#li_snmp_7').hide();
|
||||
$('#li_snmp_8').hide();
|
||||
break;
|
||||
|
||||
case 'authPriv':
|
||||
$('#li_snmp_4').show();
|
||||
$('#li_snmp_5').show();
|
||||
$('#li_snmp_6').show();
|
||||
$('#li_snmp_7').show();
|
||||
$('#li_snmp_8').show();
|
||||
break;
|
||||
|
||||
case 'authNoPriv':
|
||||
default:
|
||||
$('#li_snmp_4').show();
|
||||
$('#li_snmp_5').show();
|
||||
$('#li_snmp_6').show();
|
||||
$('#li_snmp_7').hide();
|
||||
$('#li_snmp_8').hide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function hideSNMP() {
|
||||
$('#li_snmp_1').hide();
|
||||
$('#li_snmp_2').hide();
|
||||
$('#li_snmp_3').hide();
|
||||
$('#li_snmp_4').hide();
|
||||
$('#li_snmp_5').hide();
|
||||
$('#li_snmp_6').hide();
|
||||
$('#li_snmp_7').hide();
|
||||
$('#li_snmp_8').hide();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process ajax responses and shows a dialog with results.
|
||||
*/
|
||||
|
|
|
@ -485,6 +485,10 @@ class HTML
|
|||
$class = '';
|
||||
}
|
||||
|
||||
if (empty($input['style']) === false) {
|
||||
$style_li = $input['style'];
|
||||
}
|
||||
|
||||
if (isset($input['class']) === true) {
|
||||
$class = $input['class'].$class;
|
||||
}
|
||||
|
@ -498,7 +502,7 @@ class HTML
|
|||
}
|
||||
|
||||
// Print independent block of inputs.
|
||||
$output .= '<li id="li-'.($input['block_id'] ?? '').'" class="'.$class.'">';
|
||||
$output .= '<li id="li-'.($input['block_id'] ?? '').'" class="'.$class.'" style="'.$style_li.'">';
|
||||
|
||||
if (isset($input['wrapper']) === true) {
|
||||
$output .= '<'.$input['wrapper'].' id="'.($input['block_id'] ?? '').'" class="'.$class.'">';
|
||||
|
@ -562,7 +566,7 @@ class HTML
|
|||
}
|
||||
|
||||
if (!$direct) {
|
||||
$output .= '<li id="'.($input['id'] ?? '').'" class="'.$class.'">';
|
||||
$output .= '<li id="'.($input['id'] ?? '').'" class="'.$class.'" style="'.$style_li.'">';
|
||||
}
|
||||
|
||||
if (isset($input['label']) === true) {
|
||||
|
|
Loading…
Reference in New Issue