Added backend functions to create vconsole template
This commit is contained in:
parent
cb77a299bb
commit
f10058428f
|
@ -1,7 +1,7 @@
|
|||
START TRANSACTION;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tlayout`
|
||||
-- Table `tlayout_template`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tlayout_template` (
|
||||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
|
@ -16,11 +16,11 @@ CREATE TABLE IF NOT EXISTS `tlayout_template` (
|
|||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tlayout_data`
|
||||
-- Table `tlayout_template_data`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
|
||||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_layout_template` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`id_layout_template` INTEGER UNSIGNED NOT NULL,
|
||||
`pos_x` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`pos_y` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`height` INTEGER UNSIGNED NOT NULL default 0,
|
||||
|
@ -29,8 +29,8 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
|
|||
`image` varchar(200) DEFAULT "",
|
||||
`type` tinyint(1) UNSIGNED NOT NULL default 0,
|
||||
`period` INTEGER UNSIGNED NOT NULL default 3600,
|
||||
`module_name` mediumint(8) unsigned NOT NULL default '0',
|
||||
`agent_name` int(10) unsigned NOT NULL default 0,
|
||||
`module_name` text NOT NULL,
|
||||
`agent_name` varchar(600) BINARY NOT NULL default '',
|
||||
`id_layout_linked` INTEGER unsigned NOT NULL default '0',
|
||||
`parent_item` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`enable_link` tinyint(1) UNSIGNED NOT NULL default 1,
|
||||
|
@ -49,7 +49,8 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
|
|||
`clock_animation` varchar(60) NOT NULL default "analogic_1",
|
||||
`time_format` varchar(60) NOT NULL default "time",
|
||||
`timezone` varchar(60) NOT NULL default "Europe/Madrid",
|
||||
PRIMARY KEY(`id`)
|
||||
PRIMARY KEY(`id`),
|
||||
FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
COMMIT;
|
|
@ -1713,7 +1713,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tlayout`
|
||||
-- Table `tlayout_template`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tlayout_template` (
|
||||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
|
@ -1728,11 +1728,11 @@ CREATE TABLE IF NOT EXISTS `tlayout_template` (
|
|||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tlayout_data`
|
||||
-- Table `tlayout_template_data`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
|
||||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_layout_template` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`id_layout_template` INTEGER UNSIGNED NOT NULL,
|
||||
`pos_x` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`pos_y` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`height` INTEGER UNSIGNED NOT NULL default 0,
|
||||
|
@ -1741,8 +1741,8 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
|
|||
`image` varchar(200) DEFAULT "",
|
||||
`type` tinyint(1) UNSIGNED NOT NULL default 0,
|
||||
`period` INTEGER UNSIGNED NOT NULL default 3600,
|
||||
`module_name` mediumint(8) unsigned NOT NULL default '0',
|
||||
`agent_name` int(10) unsigned NOT NULL default 0,
|
||||
`module_name` text NOT NULL,
|
||||
`agent_name` varchar(600) BINARY NOT NULL default '',
|
||||
`id_layout_linked` INTEGER unsigned NOT NULL default '0',
|
||||
`parent_item` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`enable_link` tinyint(1) UNSIGNED NOT NULL default 1,
|
||||
|
@ -1761,6 +1761,6 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
|
|||
`clock_animation` varchar(60) NOT NULL default "analogic_1",
|
||||
`time_format` varchar(60) NOT NULL default "time",
|
||||
`timezone` varchar(60) NOT NULL default "Europe/Madrid",
|
||||
PRIMARY KEY(`id`)
|
||||
PRIMARY KEY(`id`),
|
||||
FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
|
@ -4064,6 +4064,94 @@ function visual_map_macro($label,$module){
|
|||
$label = str_replace('_address_',agents_get_address(modules_get_agentmodule_agent($module)),$label);
|
||||
$label = str_replace('_moduledescription_',modules_get_agentmodule_descripcion($module),$label);
|
||||
return $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visual console templates
|
||||
*/
|
||||
|
||||
function visual_map_template_get_template_definition($id_layout_template) {
|
||||
global $config;
|
||||
|
||||
return db_get_row ('tlayout_template', 'id_layout_template', $id_layout_template);
|
||||
}
|
||||
|
||||
|
||||
function visual_map_template_get_template_elements($id_layout_template) {
|
||||
global $config;
|
||||
|
||||
return db_get_all_rows_filter('tlayout_template_data', array('id_layout_template' => $id_layout_template));
|
||||
}
|
||||
|
||||
function visual_map_get_definition($id_layout) {
|
||||
global $config;
|
||||
|
||||
return db_get_row ('tlayout', 'id', $id_layout);
|
||||
}
|
||||
|
||||
|
||||
function visual_map_get_elements($id_layout) {
|
||||
global $config;
|
||||
|
||||
return db_get_all_rows_filter('tlayout_data', array('id_layout' => $id_layout));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new template from existing visual console
|
||||
* @param int $id_layout existing visual console
|
||||
* @return true OK, false not OK
|
||||
*/
|
||||
function visual_map_create_template($id_layout, $name) {
|
||||
global $config;
|
||||
|
||||
$layout = visual_map_get_definition($id_layout);
|
||||
$layout_data = visual_map_get_elements($id_layout);
|
||||
|
||||
// Create new template based on received information
|
||||
$template_skel = $layout;
|
||||
|
||||
// rm id
|
||||
unset($template_skel["id"]);
|
||||
|
||||
$template_id = db_process_sql_insert('tlayout_template', $template_skel);
|
||||
|
||||
foreach ($layout_data as $item) {
|
||||
$data_template_skel = $item;
|
||||
|
||||
// remove unwanted fields
|
||||
unset($data_template_skel["id"]);
|
||||
unset($data_template_skel["id_layout"]);
|
||||
|
||||
// Update fields
|
||||
$data_template_skel["id_layout_template"] = $template_id;
|
||||
$data_template_skel["module_name"] = modules_get_agentmodule_name($item["id_agente_modulo"]);
|
||||
$data_template_skel["agent_name"] = agents_get_name($item["id_agent"]);
|
||||
|
||||
// remove unwanted fields
|
||||
unset($data_template_skel["id_agente_modulo"]);
|
||||
unset($data_template_skel["id_agent"]);
|
||||
|
||||
$data_template_id = db_process_sql_insert('tlayout_template_data', $data_template_skel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $template_id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new visual console based on target id_layout_template
|
||||
* @param int $id_layout_template target template
|
||||
* @param string $name name for new visual console
|
||||
* @param int $id_agent target id_agent to customize template
|
||||
* @return id_layout OK, null not OK
|
||||
*/
|
||||
function visual_map_instanciate_template($id_layout_template, $name, $id_agent) {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -3247,7 +3247,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tlayout`
|
||||
-- Table `tlayout_template`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tlayout_template` (
|
||||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
|
@ -3262,11 +3262,11 @@ CREATE TABLE IF NOT EXISTS `tlayout_template` (
|
|||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tlayout_data`
|
||||
-- Table `tlayout_template_data`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
|
||||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_layout_template` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`id_layout_template` INTEGER UNSIGNED NOT NULL,
|
||||
`pos_x` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`pos_y` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`height` INTEGER UNSIGNED NOT NULL default 0,
|
||||
|
@ -3275,8 +3275,8 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
|
|||
`image` varchar(200) DEFAULT "",
|
||||
`type` tinyint(1) UNSIGNED NOT NULL default 0,
|
||||
`period` INTEGER UNSIGNED NOT NULL default 3600,
|
||||
`module_name` mediumint(8) unsigned NOT NULL default '0',
|
||||
`agent_name` int(10) unsigned NOT NULL default 0,
|
||||
`module_name` text NOT NULL,
|
||||
`agent_name` varchar(600) BINARY NOT NULL default '',
|
||||
`id_layout_linked` INTEGER unsigned NOT NULL default '0',
|
||||
`parent_item` INTEGER UNSIGNED NOT NULL default 0,
|
||||
`enable_link` tinyint(1) UNSIGNED NOT NULL default 1,
|
||||
|
@ -3295,5 +3295,6 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
|
|||
`clock_animation` varchar(60) NOT NULL default "analogic_1",
|
||||
`time_format` varchar(60) NOT NULL default "time",
|
||||
`timezone` varchar(60) NOT NULL default "Europe/Madrid",
|
||||
PRIMARY KEY(`id`)
|
||||
PRIMARY KEY(`id`),
|
||||
FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
Loading…
Reference in New Issue