Added item form and code in js
This commit is contained in:
parent
20cccbc87f
commit
90e12d66c2
|
@ -420,6 +420,42 @@ function update_button_palette_callback() {
|
|||
$("#image_" + idItem).attr("src", "images/spinner.gif");
|
||||
setModuleGraph(idItem);
|
||||
break;
|
||||
case 'bars_graph':
|
||||
if($('#dir_items').html() == 'horizontal'){
|
||||
if(parseInt($('#text-left').val()) + (parseInt($('input[name=height_module_graph]').val() * $('#count_items').html())) > parseInt($('#background').css('width'))
|
||||
|| parseInt($('#text-left').val()) + (parseInt($('input[name=width_module_graph]').val() * $('#count_items').html())) > parseInt($('#background').css('width'))){
|
||||
|
||||
alert($('#count_items').html()+' joined graph items are wider than background');
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($('#dir_items').html() == 'vertical'){
|
||||
if(parseInt($('#text-top').val()) + (parseInt($('input[name=height_module_graph]').val() * $('#count_items').html())) > parseInt($('#background').css('height'))){
|
||||
alert($('#count_items').html()+' joined graph items are higher than background');
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($('input[name=width_module_graph]').val() == ''){
|
||||
alert('Undefined width');
|
||||
return false;
|
||||
}
|
||||
if($('input[name=height_module_graph]').val() == ''){
|
||||
alert('Undefined height');
|
||||
return false;
|
||||
}
|
||||
if($('#custom_graph_row').css('display') != 'none' && $("#custom_graph option:selected").html() == 'None'){
|
||||
alert('Undefined graph');
|
||||
return false;
|
||||
}
|
||||
|
||||
$("#text_" + idItem).html(values['label']);
|
||||
$("#image_" + idItem).attr("src", "images/spinner.gif");
|
||||
setBarsGraph(idItem, values);
|
||||
break;
|
||||
case 'auto_sla_graph':
|
||||
if($('input[name=width]').val() == ''){
|
||||
alert('Undefined width');
|
||||
|
@ -616,6 +652,7 @@ function readFields() {
|
|||
}
|
||||
}
|
||||
values['height'] = $("input[name=height]").val();
|
||||
values['bars_graph_type'] = $("select[name=bars_graph_type]").val();
|
||||
values['parent'] = $("select[name=parent]").val();
|
||||
values['map_linked'] = $("select[name=map_linked]").val();
|
||||
values['width_percentile'] = $("input[name=width_percentile]").val();
|
||||
|
@ -766,6 +803,24 @@ function create_button_palette_callback() {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case 'bars_graph':
|
||||
if (values['width_module_graph'] == '') {
|
||||
alert('Undefined width');
|
||||
validate = false;
|
||||
}
|
||||
if (values['height_module_graph'] == '') {
|
||||
alert('Undefined height');
|
||||
validate = false;
|
||||
}
|
||||
if ((values['agent'] == '')) {
|
||||
alert($("#message_alert_no_agent").html());
|
||||
validate = false;
|
||||
}
|
||||
if ((values['module'] == 0)) {
|
||||
alert($("#message_alert_no_module").html());
|
||||
validate = false;
|
||||
}
|
||||
break;
|
||||
case 'simple_value':
|
||||
if ((values['agent'] == '')) {
|
||||
alert($("#message_alert_no_agent").html());
|
||||
|
@ -967,6 +1022,7 @@ function toggle_item_palette() {
|
|||
|
||||
activeToolboxButton('static_graph', true);
|
||||
activeToolboxButton('module_graph', true);
|
||||
activeToolboxButton('bars_graph', true);
|
||||
activeToolboxButton('simple_value', true);
|
||||
activeToolboxButton('label', true);
|
||||
activeToolboxButton('icon', true);
|
||||
|
@ -994,6 +1050,7 @@ function toggle_item_palette() {
|
|||
|
||||
activeToolboxButton('static_graph', false);
|
||||
activeToolboxButton('module_graph', false);
|
||||
activeToolboxButton('bars_graph', false);
|
||||
activeToolboxButton('auto_sla_graph', false);
|
||||
activeToolboxButton('simple_value', false);
|
||||
activeToolboxButton('label', false);
|
||||
|
@ -1267,6 +1324,8 @@ function loadFieldsFromDB(item) {
|
|||
$("input[name=width_module_graph]").val(val);
|
||||
if (key == 'height_module_graph')
|
||||
$("input[name=height_module_graph]").val(val);
|
||||
if (key == 'bars_graph_type')
|
||||
$("select[name=bars_graph_type]").val(val);
|
||||
|
||||
if (key == 'type_percentile') {
|
||||
if (val == 'percentile') {
|
||||
|
@ -1527,6 +1586,9 @@ function hiddenFields(item) {
|
|||
$("#module_graph_size_row").css('display', 'none');
|
||||
$("#module_graph_size_row." + item).css('display', '');
|
||||
|
||||
$("#bars_graph_type").css('display', 'none');
|
||||
$("#bars_graph_type." + item).css('display', '');
|
||||
|
||||
$("#background_color").css('display', 'none');
|
||||
$("#background_color." + item).css('display', '');
|
||||
|
||||
|
@ -1743,6 +1805,57 @@ function set_image(type, idElement, image) {
|
|||
});
|
||||
}
|
||||
|
||||
function setBarsGraph(id_data, values) {
|
||||
var url_hack_metaconsole = '';
|
||||
if (is_metaconsole()) {
|
||||
url_hack_metaconsole = '../../';
|
||||
}
|
||||
|
||||
parameter = Array();
|
||||
|
||||
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
|
||||
parameter.push ({name: "action", value: "get_module_type_string"});
|
||||
parameter.push ({name: "id_agent", value: values['id_agent']});
|
||||
parameter.push ({name: "id_agent_module", value: values['module']});
|
||||
parameter.push ({name: "id_visual_console", value: id_visual_console});
|
||||
jQuery.ajax({
|
||||
url: get_url_ajax(),
|
||||
data: parameter,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if (data['no_data'] == true) {
|
||||
if (values['width'] == "0" || values['height'] == "0") {
|
||||
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/module-events.png');
|
||||
}
|
||||
else {
|
||||
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/module-events.png');
|
||||
$("#" + id_data + " img").css('width', values['width'] + 'px');
|
||||
$("#" + id_data + " img").css('height', values['height'] + 'px');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/module-events.png');
|
||||
|
||||
if($('#text-width').val() == 0 || $('#text-height').val() == 0){
|
||||
// Image size
|
||||
}
|
||||
else{
|
||||
$("#" + id_data + " img").css('width', $('#text-width').val()+'px');
|
||||
$("#" + id_data + " img").css('height', $('#text-height').val()+'px');
|
||||
}
|
||||
}
|
||||
|
||||
if($('#'+id_data+' table').css('float') == 'right' || $('#'+id_data+ ' table').css('float') == 'left'){
|
||||
$('#'+id_data+ ' img').css('margin-top', parseInt($('#'+id_data).css('height'))/2 - parseInt($('#'+id_data+ ' img').css('height'))/2);
|
||||
}
|
||||
else{
|
||||
$('#'+id_data+ ' img').css('margin-left',parseInt($('#'+id_data).css('width'))/2 - parseInt($('#'+id_data+ ' img').css('width'))/2);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setModuleGraph(id_data) {
|
||||
var parameter = Array();
|
||||
|
||||
|
@ -2459,6 +2572,42 @@ function createItem(type, values, id_data) {
|
|||
|
||||
setModuleGraph(id_data);
|
||||
break;
|
||||
case 'bars_graph':
|
||||
sizeStyle = '';
|
||||
imageSize = '';
|
||||
|
||||
if(values['label_position'] == 'up'){
|
||||
item = $('<div id="' + id_data + '" class="item module_graph" style="text-align: left; position: absolute; ' + sizeStyle + ' top: ' + values['top'] + 'px; left: ' + values['left'] + 'px;">' +
|
||||
'<table><tr><td></td></tr><tr><td><span id="text_' + id_data + '" class="text">' + values['label'] + '</span></td></tr><tr><td></td></tr></table>' +
|
||||
'<img class="image" id="image_' + id_data + '" src="images/spinner.gif" />' +
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
else if(values['label_position'] == 'down'){
|
||||
item = $('<div id="' + id_data + '" class="item module_graph" style="text-align: left; position: absolute; ' + sizeStyle + ' top: ' + values['top'] + 'px; left: ' + values['left'] + 'px;">' +
|
||||
'<img class="image" id="image_' + id_data + '" src="images/spinner.gif" />' +
|
||||
'<table><tr><td></td></tr><tr><td><span id="text_' + id_data + '" class="text">' + values['label'] + '</span></td></tr><tr><td></td></tr></table>' +
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
else if(values['label_position'] == 'left'){
|
||||
item = $('<div id="' + id_data + '" class="item module_graph" style="text-align: left; position: absolute; ' + sizeStyle + ' top: ' + values['top'] + 'px; left: ' + values['left'] + 'px;">' +
|
||||
'<img style="float:right" class="image" id="image_' + id_data + '" src="images/spinner.gif" />' +
|
||||
'<table style="float:left;height:'+values['height_module_graph']+'px;"><tr><td></td></tr><tr><td><span id="text_' + id_data + '" class="text">' + values['label'] + '</span></td></tr><tr><td></td></tr></table>' +
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
else if(values['label_position'] == 'right'){
|
||||
item = $('<div id="' + id_data + '" class="item module_graph" style="text-align: left; position: absolute; ' + sizeStyle + ' top: ' + values['top'] + 'px; left: ' + values['left'] + 'px;">' +
|
||||
'<img style="float:left" class="image" id="image_' + id_data + '" src="images/spinner.gif" />' +
|
||||
'<table style="float:right;height:'+values['height_module_graph']+'px;"><tr><td></td></tr><tr><td><span id="text_' + id_data + '" class="text">' + values['label'] + '</span></td></tr><tr><td></td></tr></table>' +
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
setBarsGraph(id_data, values);
|
||||
break;
|
||||
case 'simple_value':
|
||||
sizeStyle = '';
|
||||
imageSize = '';
|
||||
|
@ -2678,6 +2827,7 @@ function updateDB_visual(type, idElement , values, event, top, left) {
|
|||
case 'label':
|
||||
case 'icon':
|
||||
case 'module_graph':
|
||||
case 'bars_graph':
|
||||
case 'auto_sla_graph':
|
||||
if (type == 'simple_value') {
|
||||
setModuleValue(idElement,
|
||||
|
@ -3120,6 +3270,15 @@ function eventsItems(drag) {
|
|||
activeToolboxButton('delete_item', true);
|
||||
activeToolboxButton('show_grid', false);
|
||||
}
|
||||
if ($(divParent).hasClass('bars_graph')) {
|
||||
creationItem = null;
|
||||
selectedItem = 'bars_graph';
|
||||
idItem = $(divParent).attr('id');
|
||||
activeToolboxButton('copy_item', true);
|
||||
activeToolboxButton('edit_item', true);
|
||||
activeToolboxButton('delete_item', true);
|
||||
activeToolboxButton('show_grid', false);
|
||||
}
|
||||
if ($(divParent).hasClass('simple_value')) {
|
||||
creationItem = null;
|
||||
selectedItem = 'simple_value';
|
||||
|
@ -3302,6 +3461,9 @@ function eventsItems(drag) {
|
|||
if ($(event.target).hasClass('module_graph')) {
|
||||
selectedItem = 'module_graph';
|
||||
}
|
||||
if ($(event.target).hasClass('bars_graph')) {
|
||||
selectedItem = 'bars_graph';
|
||||
}
|
||||
if ($(event.target).hasClass('simple_value')) {
|
||||
selectedItem = 'simple_value';
|
||||
}
|
||||
|
@ -3613,6 +3775,10 @@ function click_button_toolbox(id) {
|
|||
toolbuttonActive = creationItem = 'module_graph';
|
||||
toggle_item_palette();
|
||||
break;
|
||||
case 'bars_graph':
|
||||
toolbuttonActive = creationItem = 'bars_graph';
|
||||
toggle_item_palette();
|
||||
break;
|
||||
case 'auto_sla_graph':
|
||||
toolbuttonActive = creationItem = 'auto_sla_graph';
|
||||
toggle_item_palette();
|
||||
|
@ -3668,6 +3834,7 @@ function click_button_toolbox(id) {
|
|||
activeToolboxButton('static_graph', false);
|
||||
activeToolboxButton('percentile_item', false);
|
||||
activeToolboxButton('module_graph', false);
|
||||
activeToolboxButton('bars_graph', false);
|
||||
activeToolboxButton('simple_value', false);
|
||||
activeToolboxButton('label', false);
|
||||
activeToolboxButton('icon', false);
|
||||
|
@ -3699,6 +3866,7 @@ function click_button_toolbox(id) {
|
|||
activeToolboxButton('static_graph', true);
|
||||
activeToolboxButton('percentile_item', true);
|
||||
activeToolboxButton('module_graph', true);
|
||||
activeToolboxButton('bars_graph', true);
|
||||
activeToolboxButton('simple_value', true);
|
||||
activeToolboxButton('label', true);
|
||||
activeToolboxButton('icon', true);
|
||||
|
|
|
@ -140,6 +140,39 @@ switch ($action) {
|
|||
$return['font'] = $config['fontpath'];
|
||||
echo json_encode($return);
|
||||
break;
|
||||
|
||||
case 'get_module_type_string':
|
||||
$data = array ();
|
||||
|
||||
$layoutData = db_get_row_filter('tlayout_data', array('id' => $id_element));
|
||||
|
||||
if ($layoutData['id_metaconsole'] != 0) {
|
||||
$connection = db_get_row_filter ('tmetaconsole_setup', $layoutData['id_metaconsole']);
|
||||
|
||||
if (metaconsole_load_external_db($connection) != NOERR) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$is_string = db_get_value_filter ('id_tipo_modulo', 'tagente_modulo',
|
||||
array ('id_agente' => $id_agent,
|
||||
'id_agente_modulo' => $id_module));
|
||||
|
||||
if ($layoutData['id_metaconsole'] != 0) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
$return = array();
|
||||
if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) ||
|
||||
($is_string == 10) || ($is_string == 33)) {
|
||||
$return['no_data'] = false;
|
||||
}
|
||||
else {
|
||||
$return['no_data'] = true;
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
break;
|
||||
|
||||
case 'get_module_events':
|
||||
$data = array ();
|
||||
|
|
|
@ -280,7 +280,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
|
|||
$form_items['agent_row'] = array();
|
||||
$form_items['agent_row']['items'] = array('static_graph',
|
||||
'percentile_bar', 'percentile_item', 'module_graph',
|
||||
'simple_value', 'datos', 'auto_sla_graph');
|
||||
'simple_value', 'datos', 'auto_sla_graph', 'bars_graph');
|
||||
$form_items['agent_row']['html'] = '<td align="left">' .
|
||||
__('Agent') . '</td>';
|
||||
$params = array();
|
||||
|
@ -313,7 +313,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
|
|||
$form_items['module_row'] = array();
|
||||
$form_items['module_row']['items'] = array('static_graph',
|
||||
'percentile_bar', 'percentile_item', 'module_graph',
|
||||
'simple_value', 'datos', 'auto_sla_graph');
|
||||
'simple_value', 'datos', 'auto_sla_graph', 'bars_graph');
|
||||
$form_items['module_row']['html'] = '<td align="left">' .
|
||||
__('Module') . '</td>
|
||||
<td align="left">' .
|
||||
|
@ -452,7 +452,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
|
|||
|
||||
|
||||
$form_items['period_row'] = array();
|
||||
$form_items['period_row']['items'] = array('module_graph', 'simple_value', 'datos', 'bars_graph');
|
||||
$form_items['period_row']['items'] = array('module_graph', 'simple_value', 'datos');
|
||||
$form_items['period_row']['html'] = '<td align="left">' . __('Period') . '</td>
|
||||
<td align="left">' . html_print_extended_select_for_time ('period', SECONDS_5MINUTES, '', '', '', false, true) . '</td>';
|
||||
|
||||
|
@ -475,6 +475,13 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
|
|||
'<span id="count_items">1</span> '.
|
||||
'<span id="dir_items"></span> item/s
|
||||
</td>';
|
||||
|
||||
$bars_graph_types = array('vertical' => __('Vertical'), 'horizontal' => __('Horizontal'));
|
||||
$form_items['bars_graph_type'] = array();
|
||||
$form_items['bars_graph_type']['items'] = array('bars_graph');
|
||||
$form_items['bars_graph_type']['html'] = '<td align="left">' .
|
||||
__('Type') . '</td>
|
||||
<td align="left">' . html_print_select($bars_graph_types, 'bars_graph_type', 'vertical', '', '', '', true) . '</td>';
|
||||
|
||||
|
||||
//Insert and modify before the buttons to create or update.
|
||||
|
@ -497,14 +504,6 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
|
|||
html_print_button(__('Cancel'), 'cancel_button', false, 'cancel_button_palette_callback();', 'class="sub cancel"', true) . '<span ="margin-right:10px;"> </span>' .
|
||||
html_print_button(__('Create'), 'create_button', false, 'create_button_palette_callback();', 'class="sub wand"', true) .
|
||||
'</td>';
|
||||
|
||||
|
||||
$bars_graph_types = array('vertical' => __('Vertical'), 'horizontal' => __('Horizontal'));
|
||||
$form_items['bars_graph_type'] = array();
|
||||
$form_items['bars_graph_type']['items'] = array('bars_graph');
|
||||
$form_items['bars_graph_type']['html'] = '<td align="left">' .
|
||||
__('Background') . '</td>
|
||||
<td align="left">' . html_print_select($bars_graph_types, 'bars_graph_type', 'vertical', '', '', '', true) . '</td>';
|
||||
|
||||
|
||||
foreach ($form_items as $item => $item_options) {
|
||||
|
|
Loading…
Reference in New Issue