This commit is contained in:
fbsanchez 2021-10-06 19:52:46 +02:00
parent dae8a9ba14
commit 6781e513c8
5 changed files with 44 additions and 23 deletions

View File

@ -37,7 +37,6 @@ CREATE TABLE IF NOT EXISTS `tncm_template_scripts` (
`id` serial,
`id_template` bigint(20) unsigned NOT NULL,
`id_script` bigint(20) unsigned NOT NULL,
`order` int unsigned not null default 0,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE

View File

@ -4120,7 +4120,6 @@ CREATE TABLE IF NOT EXISTS `tncm_template_scripts` (
`id` serial,
`id_template` bigint(20) unsigned NOT NULL,
`id_script` bigint(20) unsigned NOT NULL,
`order` int unsigned not null default 0,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
@ -4131,13 +4130,13 @@ CREATE TABLE IF NOT EXISTS `tncm_template_scripts` (
-- ----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tncm_agent` (
`id_agent` int(10) unsigned NOT NULL,
`vendor` text,
`vendor` text,
`model` text,
`protocol` int unsigned not null default 0,
`cred_key` varchar(100),
`status` int(4) NOT NULL default 5,
`updated_at` bigint(20) NOT NULL default 0,
`config_backup_id` bigint(20) UNSIGNED DEFAULT NULL,
`status` int(4) NOT NULL default 5,
`updated_at` bigint(20) NOT NULL default 0,
`config_backup_id` bigint(20) UNSIGNED DEFAULT NULL,
PRIMARY KEY (`id_agent`),
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`cred_key`) REFERENCES `tcredential_store`(`identifier`) ON UPDATE CASCADE ON DELETE SET NULL
@ -4149,9 +4148,9 @@ CREATE TABLE IF NOT EXISTS `tncm_agent` (
CREATE TABLE IF NOT EXISTS `tncm_agent_templates` (
`id_agent` int(10) unsigned NOT NULL,
`id_template` bigint(20) unsigned NOT NULL,
`status` int(4) NOT NULL default 5,
`updated_at` bigint(20) NOT NULL default 0,
`status` int(4) NOT NULL default 5,
`updated_at` bigint(20) NOT NULL default 0,
`execute` int(2) UNSIGNED NOT NULL default 0,
PRIMARY KEY (`id_agent`, `id_template`),
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
@ -4163,9 +4162,9 @@ CREATE TABLE IF NOT EXISTS `tncm_agent_templates` (
CREATE TABLE IF NOT EXISTS `tncm_agent_data` (
`id_agent` int(10) unsigned NOT NULL,
`id_template` bigint(20) unsigned NOT NULL,
`data` LONGBLOB,
`status` int(4) NOT NULL default 5,
`updated_at` bigint(20) NOT NULL default 0,
`data` LONGBLOB,
`status` int(4) NOT NULL default 5,
`updated_at` bigint(20) NOT NULL default 0,
PRIMARY KEY (`id_agent`, `id_template`),
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE

View File

@ -36,6 +36,13 @@ namespace PandoraFMS;
abstract class Entity
{
/**
* Load from DB or new one.
*
* @var boolean
*/
protected $existsInDB;
/**
* Entity fields (from table).
*
@ -88,6 +95,7 @@ abstract class Entity
$obj->{$k}($v);
}
$obj->existsInDB = true;
return $obj;
}
@ -137,6 +145,9 @@ abstract class Entity
foreach ($data as $k => $v) {
$this->fields[$k] = $v;
}
// Mark as existing object.
$this->existsInDB = true;
} else {
// Empty one.
$data = \db_get_all_rows_sql(
@ -149,6 +160,9 @@ abstract class Entity
foreach ($data as $row) {
$this->fields[$row['Field']] = null;
}
// Mark as virtual object.
$this->existsInDB = false;
}
if (\enterprise_installed() === true

View File

@ -0,0 +1,10 @@
span.select2.select2-container.select2-container--default {
max-width: 175px !important;
width: 175px !important;
}
.edit_discovery_input b {
display: flex;
flex-direction: row;
align-items: center;
}

View File

@ -4056,7 +4056,6 @@ CREATE TABLE IF NOT EXISTS `tncm_template_scripts` (
`id` serial,
`id_template` bigint(20) unsigned NOT NULL,
`id_script` bigint(20) unsigned NOT NULL,
`order` int unsigned not null default 0,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
@ -4067,13 +4066,13 @@ CREATE TABLE IF NOT EXISTS `tncm_template_scripts` (
-- ----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tncm_agent` (
`id_agent` int(10) unsigned NOT NULL,
`vendor` text,
`vendor` text,
`model` text,
`protocol` int unsigned not null default 0,
`cred_key` varchar(100),
`status` int(4) NOT NULL default 5,
`udpated_at` bigint(20) NOT NULL default 0,
`config_backup_id` bigint(20) UNSIGNED DEFAULT NULL,
`status` int(4) NOT NULL default 5,
`updated_at` bigint(20) NOT NULL default 0,
`config_backup_id` bigint(20) UNSIGNED DEFAULT NULL,
PRIMARY KEY (`id_agent`),
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`cred_key`) REFERENCES `tcredential_store`(`identifier`) ON UPDATE CASCADE ON DELETE SET NULL
@ -4085,9 +4084,9 @@ CREATE TABLE IF NOT EXISTS `tncm_agent` (
CREATE TABLE IF NOT EXISTS `tncm_agent_templates` (
`id_agent` int(10) unsigned NOT NULL,
`id_template` bigint(20) unsigned NOT NULL,
`status` int(4) NOT NULL default 5,
`udpated_at` bigint(20) NOT NULL default 0,
`execute` int(2) UNSIGNED NOT NULL default 0,
`status` int(4) NOT NULL default 5,
`updated_at` bigint(20) NOT NULL default 0,
`execute` int(2) UNSIGNED NOT NULL default 0,
PRIMARY KEY (`id_agent`, `id_template`),
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
@ -4099,9 +4098,9 @@ CREATE TABLE IF NOT EXISTS `tncm_agent_templates` (
CREATE TABLE IF NOT EXISTS `tncm_agent_data` (
`id_agent` int(10) unsigned NOT NULL,
`id_template` bigint(20) unsigned NOT NULL,
`data` LONGBLOB,
`status` int(4) NOT NULL default 5,
`udpated_at` bigint(20) NOT NULL default 0,
`data` LONGBLOB,
`status` int(4) NOT NULL default 5,
`updated_at` bigint(20) NOT NULL default 0,
PRIMARY KEY (`id_agent`, `id_template`),
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE