#9771 new input for select mode of interval and changes in database

This commit is contained in:
Daniel Cebrian 2023-06-27 17:37:41 +02:00
parent d2413ed461
commit eac3cf409b
6 changed files with 69 additions and 13 deletions

View File

@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS `tdiscovery_apps_executions` (
`id` int(10) unsigned NOT NULL auto_increment,
`id_app` int(10),
`execution` text NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
PRIMARY KEY (`id`, `id_app`),
FOREIGN KEY (`id_app`) REFERENCES tdiscovery_apps(`id_app`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;

View File

@ -160,7 +160,7 @@ if ((bool) check_acl($config['id_user'], 0, 'AR') === true
|| check_acl($config['id_user'], 0, 'RM')
|| check_acl($config['id_user'], 0, 'PM')
) {
$sub['godmode/servers/discovery&wiz=magextensions']['text'] = __('Manage extensions');
$sub['godmode/servers/discovery&wiz=magextensions']['text'] = __('Manage disco packages');
$sub['godmode/servers/discovery&wiz=magextensions']['id'] = 'mextensions';
}

View File

@ -58,7 +58,7 @@ class ManageExtensions extends HTML
*
* @var string
*/
public $label = 'Manage extensions';
public $label = 'Manage disco packages';
/**
* Url of section
@ -226,7 +226,7 @@ class ManageExtensions extends HTML
],
[
'link' => '',
'label' => _('Manage extensions'),
'label' => _('Manage disco packages'),
'selected' => 1,
],
]
@ -234,7 +234,7 @@ class ManageExtensions extends HTML
// Header.
ui_print_page_header(
__('Manage extensions'),
__('Manage disco packages'),
'',
false,
'',

View File

@ -280,6 +280,7 @@ class ExtensionsDiscovery extends Wizard
*/
public function run()
{
ui_require_javascript_file('extensions_discovery');
$_iniFile = $this->loadIni();
if ($_iniFile === false) {
include 'general/noaccess.php';
@ -1349,15 +1350,40 @@ class ExtensionsDiscovery extends Wizard
)
);
$data[4][0] = html_print_label_input_block(
__('Interval'),
html_print_extended_select_for_time(
$inputs_interval = html_print_select(
[
'defined' => 'Defined',
'manual' => 'Manual',
],
'mode_interval',
($task['interval_sweep'] === '0') ? 'manual' : 'defined',
'changeModeInterval(this)',
'',
'0',
true,
false,
true,
'',
false
).html_print_extended_select_for_time(
'interval',
(empty($task['interval_sweep']) === true) ? '300' : $task['interval_sweep'],
'',
'',
'0',
false,
true,
false,
true,
);
$js_variables = '<script>const interval = "'.$task['interval_sweep'].'";</script>';
$data[4][0] = html_print_label_input_block(
__('Interval'),
html_print_div(
[
'style' => 'display: flex;max-width: 345px; justify-content: space-between;',
'content' => $inputs_interval.$js_variables,
],
true
)
);
@ -1402,10 +1428,15 @@ class ExtensionsDiscovery extends Wizard
$description = get_parameter('description', '');
$discoveryServer = get_parameter('discovery_server', '');
$group = get_parameter('group', 0);
$mode_interval = get_parameter('mode_interval', 'defined');
$interval = get_parameter('interval', '');
$tiemout = get_parameter('tiemout', 60);
$completeTask = get_parameter('complete_button', '');
if ($mode_interval === 'manual') {
$interval = '0';
}
$error = false;
if ($taskName === ''

View File

@ -0,0 +1,25 @@
/* global $, interval */
$(document).ready(() => {
if (interval === "0") {
setTimeout(() => {
$("#mode_interval")
.parent()
.find("[id^='interval']")
.hide();
}, 100);
}
});
function changeModeInterval(e) {
if ($(e).val() === "manual") {
$(e)
.parent()
.find("[id^='interval']")
.hide();
} else {
var interval = $(e)
.parent()
.find("div[id^='interval']")[0];
$(interval).show();
}
}

View File

@ -4351,7 +4351,7 @@ CREATE TABLE IF NOT EXISTS `tdiscovery_apps_executions` (
`id` int(10) unsigned NOT NULL auto_increment,
`id_app` int(10),
`execution` text NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
PRIMARY KEY (`id`, `id_app`),
FOREIGN KEY (`id_app`) REFERENCES tdiscovery_apps(`id_app`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;