Added the toolbox button for copy items. Ticket: #1479

This commit is contained in:
mdtrooper 2014-11-19 16:29:36 +01:00
parent 7ba791f787
commit afebae0b80
13 changed files with 150 additions and 3 deletions

View File

@ -387,6 +387,7 @@ function toggle_item_palette() {
activeToolboxButton('percentile_item', false);
activeToolboxButton('group_item', false);
activeToolboxButton('copy_item', false);
activeToolboxButton('edit_item', false);
activeToolboxButton('delete_item', false);
activeToolboxButton('show_grid', false);
@ -1597,6 +1598,45 @@ function updateDB(type, idElement , values, event) {
}
}
function copyDB(idItem) {
metaconsole = $("input[name='metaconsole']").val();
var url_ajax = "ajax.php";
if (metaconsole != 0) {
url_ajax = "../../ajax.php";
}
parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
parameter.push ({name: "action", value: "copy"});
parameter.push ({name: "id_visual_console", value: id_visual_console});
parameter.push ({name: "id_element", value: idItem});
jQuery.ajax({
url: url_ajax,
async: false,
data: parameter,
type: "POST",
dataType: 'json',
success: function (data) {
if (data['correct']) {
values = data['values'];
type = data['type'];
id = data['id_data'];
createItem(type, values, id);
addItemSelectParents(id, data['text']);
//Reload all events for the item and new item.
eventsItems();
}
else {
//TODO
}
}
});
}
function deleteDB(idElement) {
metaconsole = $("input[name='metaconsole']").val();
@ -1698,6 +1738,7 @@ function eventsItems(drag) {
creationItem = null;
selectedItem = 'static_graph';
idItem = $(divParent).attr('id');
activeToolboxButton('copy_item', true);
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
activeToolboxButton('show_grid', false);
@ -1706,6 +1747,7 @@ function eventsItems(drag) {
creationItem = null;
selectedItem = 'group_item';
idItem = $(divParent).attr('id');
activeToolboxButton('copy_item', true);
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
activeToolboxButton('show_grid', false);
@ -1714,6 +1756,7 @@ function eventsItems(drag) {
creationItem = null;
selectedItem = 'percentile_item';
idItem = $(divParent).attr('id');
activeToolboxButton('copy_item', true);
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
activeToolboxButton('show_grid', false);
@ -1722,6 +1765,7 @@ function eventsItems(drag) {
creationItem = null;
selectedItem = 'module_graph';
idItem = $(divParent).attr('id');
activeToolboxButton('copy_item', true);
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
activeToolboxButton('show_grid', false);
@ -1730,6 +1774,7 @@ function eventsItems(drag) {
creationItem = null;
selectedItem = 'simple_value';
idItem = $(divParent).attr('id');
activeToolboxButton('copy_item', true);
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
activeToolboxButton('show_grid', false);
@ -1738,6 +1783,7 @@ function eventsItems(drag) {
creationItem = null;
selectedItem = 'label';
idItem = $(divParent).attr('id');
activeToolboxButton('copy_item', true);
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
activeToolboxButton('show_grid', false);
@ -1746,6 +1792,7 @@ function eventsItems(drag) {
creationItem = null;
selectedItem = 'icon';
idItem = $(divParent).attr('id');
activeToolboxButton('copy_item', true);
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
activeToolboxButton('show_grid', false);
@ -1809,6 +1856,7 @@ function eventsItems(drag) {
if (selectedItem != null) {
creationItem = null;
idItem = $(event.target).attr('id');
activeToolboxButton('copy_item', true);
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
}
@ -1867,6 +1915,7 @@ function eventsBackground() {
if (!is_opened_palette) {
unselectAll();
$("#background").css('border', '2px blue dotted');
activeToolboxButton('copy_item', false);
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', false);
activeToolboxButton('show_grid', true);
@ -1948,6 +1997,11 @@ function click_button_toolbox(id) {
toggle_item_palette();
break;
case 'copy_item':
click_copy_item_callback();
break;
case 'edit_item':
toggle_item_palette();
break;
@ -1976,6 +2030,7 @@ function click_button_toolbox(id) {
activeToolboxButton('service', false);
activeToolboxButton('group_item', false);
activeToolboxButton('copy_item', false);
activeToolboxButton('edit_item', false);
activeToolboxButton('delete_item', false);
activeToolboxButton('show_grid', false);
@ -1993,6 +2048,7 @@ function click_button_toolbox(id) {
activeToolboxButton('show_grid', true);
}
if (selectedItem != null) {
activeToolboxButton('copy_item', true);
activeToolboxButton('edit_item', true);
}
@ -2121,6 +2177,10 @@ function showPreviewIcon(icon) {
}
}
function click_copy_item_callback() {
copyDB(idItem);
}
function showGrid() {
metaconsole = $("input[name='metaconsole']").val();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -682,6 +682,43 @@ switch ($action) {
case 'copy':
$values = db_get_row_filter('tlayout_data',
array('id' => $id_element));
unset($values['id']);
$values['pos_x'] = $values['pos_x'] + 20;
$values['pos_y'] = $values['pos_y'] + 20;
$idData = db_process_sql_insert('tlayout_data', $values);
$return = array();
if ($idData === false) {
$return['correct'] = 0;
}
else {
$text = visual_map_create_internal_name_item($label, $type, $image, $agent, $id_module, $idData);
$values['label'] = io_safe_output($values['label']);
$values['left'] = $values['pos_x'];
$values['top'] = $values['pos_y'];
$values['parent'] = $values['parent_item'];
$return['values'] = $values;
$return['correct'] = 1;
$return['id_data'] = $idData;
$return['text'] = $text;
$return['type'] = visual_map_type_in_js($values['type']);
}
html_debug_print($return, true);
echo json_encode($return);
break;
case 'delete':
if (db_process_sql_delete('tlayout_data', array('id' => $id_element, 'id_layout' => $id_visual_console)) === false) {
$return['correct'] = 0;

View File

@ -70,6 +70,7 @@ function visual_map_print_item($mode = "read", $layoutData,
$borderStyle = '';
$imageSize = '';
$text = '<span id="text_' . $id . '" class="text">' . $label . '</span>';
if (!isset($layoutData['status_calculated'])) {
@ -1970,4 +1971,45 @@ function visual_map_get_layoutdata_y ($id_layoutdata){
return (float) db_get_value ('pos_y', 'tlayout_data', 'id', (int) $id_layoutdata);
}
function visual_map_type_in_js($type) {
switch ($type) {
case STATIC_GRAPH:
return 'static_graph';
break;
case PERCENTILE_BAR:
return 'percentile_item';
break;
case MODULE_GRAPH:
return 'module_graph';
break;
case SIMPLE_VALUE:
return 'simple_value';
break;
case LABEL:
return 'label';
break;
case ICON:
return 'icon';
break;
case SIMPLE_VALUE_MAX:
return 'simple_value';
break;
case SIMPLE_VALUE_MIN:
return 'simple_value';
break;
case SIMPLE_VALUE_AVG:
return 'simple_value';
break;
case PERCENTILE_BUBBLE:
return 'percentile_item';
break;
case SERVICE:
return 'service';
break;
case GROUP_ITEM:
return 'group_item';
break;
}
}
?>

View File

@ -443,12 +443,15 @@ function visual_map_editor_print_toolbox() {
visual_map_print_button_editor('show_grid', __('Show grid'), 'right', true, 'grid_min', true);
visual_map_print_button_editor('edit_item', __('Update item'), 'right', true, 'config_min', true);
visual_map_print_button_editor('delete_item', __('Delete item'), 'right', true, 'delete_min', true);
visual_map_print_button_editor('copy_item', __('Copy item'), 'right', true, 'delete_min', true);
echo '</div>';
echo '</div>';
echo '<div style="clear: right; margin-bottom: 10px;"></div>';
}
function visual_map_print_button_editor($idDiv, $label, $float = 'left', $disabled = false, $class= '', $imageButton = false) {
function visual_map_print_button_editor($idDiv, $label, $float = 'left',
$disabled = false, $class= '', $imageButton = false) {
if ($float == 'left') {
$margin = 'margin-right';
}

View File

@ -29,8 +29,7 @@ function draw_line (line, id_div) {
lineThickness = line['thickness'];
div = document.getElementById (id_div);
console.log(id_div);
console.log(div);
brush = new jsGraphics (div);
brush.setStroke (lineThickness);
brush.setColor (line['color']);

6
pandora_console/include/styles/pandora.css Normal file → Executable file
View File

@ -758,6 +758,12 @@ input.icon_min {
input.icon_min[disabled] {
background: #fefefe url(../../images/photo.disabled.png) no-repeat center !important;
}
input.copy_item {
background: #fefefe url(../../images/copy_visualmap.png) no-repeat center !important;
}
input.copy_item[disabled] {
background: #fefefe url(../../images/copy_visualmap.disabled.png) no-repeat center !important;
}
input.grid_min {
background: #fefefe url(../../images/grid.png) no-repeat center !important;
}