Working in the new networkmaps.

This commit is contained in:
mdtrooper 2016-02-01 16:02:43 +01:00
parent 7931b7f770
commit 8602d9eb4b
5 changed files with 57 additions and 15 deletions

View File

@ -28,4 +28,31 @@ function maps_save_map($values) {
function maps_get_maps($filter) {
return db_get_all_rows_filter('tmap', $filter);
}
function maps_get_subtype_string($subtype) {
switch ($subtype) {
case MAP_SUBTYPE_TOPOLOGY:
return __('Topology');
break;
case MAP_SUBTYPE_POLICIES:
return __('Policies');
break;
case MAP_SUBTYPE_GROUPS:
return __('Groups');
break;
case MAP_SUBTYPE_RADIAL_DYNAMIC:
return __('Dynamic');
break;
default:
return __('Unknown');
break;
}
}
function maps_get_count_nodes($id) {
$result = db_get_sql(
"SELECT COUNT(*) FROM titem WHERE id_map = " . $id);
return (int)$result;
}
?>

View File

@ -38,6 +38,8 @@ if (!$networkmaps_read && !$networkmaps_write && !$networkmaps_manage) {
require_once('include/functions_migration.php');
ui_print_page_header(__('Network map'), "images/op_network.png", false, "network_map", false);
////////////////////////////////////////////////////////////////////////
// It is dirty but at the moment (minor release is not)
// this place is the place for migration
@ -48,9 +50,15 @@ $migrate_open_networkmaps = (int)get_parameter('migrate_open_networkmaps');
if ($migrate_open_networkmaps)
migration_open_networkmaps();
?>
<br />
<a href="index.php?sec=network&sec2=operation/maps/networkmap_list&migrate_open_networkmaps=1">(temp, this is for minor relases) migrate open networkmaps</a>
<br />
<br />
<?php
////////////////////////////////////////////////////////////////////////
ui_print_page_header(__('Network map'), "images/op_network.png", false, "network_map", false);
$id = (int)get_parameter('id_networkmap', 0);
$delete_networkmap = (bool)get_parameter('delete_networkmap', 0);
@ -138,23 +146,27 @@ if (empty($networkmaps)) {
else {
foreach ($networkmaps as $networkmap) {
$data = array();
$data['name'] = $networkmap['name'];
$data['name'] = '<a href="index.php?' .
'sec=maps&' .
'sec2=operation/maps/networkmap_editor&' .
'id_networkmap=' . $networkmap['id'] .'">' .
$networkmap['name'] . '</a>';
$data['type'] = $networkmap['type'];
$data['type'] = maps_get_subtype_string($networkmap['subtype']);
if (enterprise_installed()) {
//FUNCION
//$data['nodes'] = networkmap_get_nodes();
$data['nodes'] = 0;
if ($networkmap['generated']) {
$data['nodes'] = maps_get_count_nodes($networkmap['id']);
}
else {
$data['nodes'] = __('Pending to generate');
}
}
if (!empty($networkmap['id_user'])) {
$data['group'] = __('Private for (%s)', $networkmap['id_user']);
}
@ -162,33 +174,33 @@ else {
$data['groups'] =
ui_print_group_icon($networkmap['id_group'], true);
}
$data['copy'] = '<a href="index.php?' .
'sec=maps&;' .
'sec2=operation/maps/networkmap_list' .
'duplicate_networkmap=1&id_networkmap=' . $networkmap['id'] . '" alt="' . __('Copy') . '">' .
html_print_image("images/copy.png", true) . '</a>';
$data['edit'] = '<a href="index.php?' .
'sec=maps&;' .
'sec2=operation/maps/networkmap_editor' .
'id_networkmap=' . $networkmap['id'] .'">' .
html_print_image("images/edit.png", true) . '</a>';
$data['delete'] = '<a href="index.php?' .
'sec=maps&;' .
'sec2=operation/maps/networkmap_list' .
'delete_networkmap=1&id_networkmap=' . $networkmap['id'] . '" alt="' . __('Delete') .
'" onclick="javascript: if (!confirm(\'' . __('Are you sure?') . '\')) return false;">' .
html_print_image('images/cross.png', true) . '</a>';
$table->data[] = $data;
}
html_print_table($table);
}
?>
<a href="index.php?sec=network&sec2=operation/maps/networkmap_list&migrate_open_networkmaps=1">(temp, this is for minor relases) migrate open networkmaps</a>
<script type="text/javascript">
</script>

View File

@ -2077,6 +2077,7 @@ CREATE TABLE IF NOT EXISTS tmap (
source NUMBER(10, 0) DEFAULT 0,
source_data VARCHAR2(250) DEFAULT '',
generation_method NUMBER(10, 0) DEFAULT 0,
generated NUMBER(10, 0) DEFAULT 0,
filter CLOB DEFAULT '',
);

View File

@ -1737,6 +1737,7 @@ CREATE TABLE IF NOT EXISTS "tmap" (
"source" SMALLINT NOT NULL default 0,
"source_data" varchar(250) default '',
"generation_method" SMALLINT NOT NULL default 0,
"generated" SMALLINT NOT NULL default 0,
"filter" TEXT
);

View File

@ -1845,6 +1845,7 @@ CREATE TABLE IF NOT EXISTS `tmap` (
`source` INTEGER UNSIGNED NOT NULL default 0,
`source_data` varchar(250) default '',
`generation_method` INTEGER UNSIGNED NOT NULL default 0,
`generated` INTEGER UNSIGNED NOT NULL default 0,
`filter` TEXT,
PRIMARY KEY(`id`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;