diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | frontends/php/chart.php | 8 | ||||
-rw-r--r-- | frontends/php/chart2.php | 10 | ||||
-rw-r--r-- | frontends/php/chart3.php | 84 | ||||
-rw-r--r-- | frontends/php/chart6.php | 2 | ||||
-rw-r--r-- | frontends/php/chart7.php | 10 | ||||
-rw-r--r-- | frontends/php/charts.php | 4 | ||||
-rw-r--r-- | frontends/php/history.php | 4 | ||||
-rw-r--r-- | frontends/php/httpdetails.php | 6 | ||||
-rw-r--r-- | frontends/php/include/config.inc.php | 3 | ||||
-rw-r--r-- | frontends/php/include/screens.inc.php | 5 | ||||
-rw-r--r-- | frontends/php/js/gmenu.js | 8 | ||||
-rw-r--r-- | frontends/php/js/sbinit.js | 159 | ||||
-rw-r--r-- | frontends/php/js/sbox.js | 4 | ||||
-rw-r--r-- | frontends/php/js/scrollbar.js | 86 | ||||
-rw-r--r-- | frontends/php/screens.php | 2 |
16 files changed, 243 insertions, 153 deletions
@@ -1,5 +1,6 @@ Changes for 1.5.3 + - [DEV-170] improved charts period & start time selection (Artem) - [DEV-163] added support of perf_counter[path<,period>] (Sasha) - [DEV-169] improved msg functionality in GUI (Artem) - [DEV-149] added hosts masss update functionality (Artem) diff --git a/frontends/php/chart.php b/frontends/php/chart.php index e8ccabbe..8d4e92bb 100644 --- a/frontends/php/chart.php +++ b/frontends/php/chart.php @@ -59,6 +59,14 @@ include_once "include/page_header.php"; $graph = new Chart(); + $effectiveperiod = navigation_bar_calc(); + + $_REQUEST['period'] = get_request('period',get_profile('web.item['.$_REQUEST['itemid'].'].graph.period', ZBX_PERIOD_DEFAULT)); + if($_REQUEST['period'] >= ZBX_MIN_PERIOD){ + update_profile('web.item['.$_REQUEST['itemid'].'].graph.period',$_REQUEST['period']); + } + + if(isset($_REQUEST["period"])) $graph->SetPeriod($_REQUEST["period"]); if(isset($_REQUEST["from"])) $graph->SetFrom($_REQUEST["from"]); if(isset($_REQUEST["width"])) $graph->SetWidth($_REQUEST["width"]); diff --git a/frontends/php/chart2.php b/frontends/php/chart2.php index 9d81e933..ac050628 100644 --- a/frontends/php/chart2.php +++ b/frontends/php/chart2.php @@ -54,7 +54,15 @@ include_once 'include/page_header.php'; if(!graph_accessible($_REQUEST['graphid'])){ access_deny(); } - + + $effectiveperiod = navigation_bar_calc(); + + if(($_REQUEST['graphid']>0) && ($_REQUEST['period'] >= ZBX_MIN_PERIOD)){ + update_profile('web.graph['.$_REQUEST['graphid'].'].period',$_REQUEST['period']); + } + + update_profile('web.charts.graphid',$_REQUEST['graphid']); + $sql = 'SELECT g.*,h.host,h.hostid '. ' FROM graphs g '. ' LEFT JOIN graphs_items gi ON g.graphid=gi.graphid '. diff --git a/frontends/php/chart3.php b/frontends/php/chart3.php index e941370d..d7771006 100644 --- a/frontends/php/chart3.php +++ b/frontends/php/chart3.php @@ -19,33 +19,33 @@ **/ ?> <?php - require_once "include/config.inc.php"; - require_once "include/graphs.inc.php"; - require_once "include/classes/chart.inc.php"; + require_once 'include/config.inc.php'; + require_once 'include/graphs.inc.php'; + require_once 'include/classes/chart.inc.php'; - $page["file"] = "chart3.php"; - $page["title"] = "S_CHART"; - $page["type"] = PAGE_TYPE_IMAGE; + $page['file'] = 'chart3.php'; + $page['title'] = 'S_CHART'; + $page['type'] = PAGE_TYPE_IMAGE; -include_once "include/page_header.php"; +include_once 'include/page_header.php'; ?> <?php // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields=array( - "period"=> array(T_ZBX_INT, O_OPT, P_NZERO, BETWEEN(ZBX_MIN_PERIOD,ZBX_MAX_PERIOD), null), - "from"=> array(T_ZBX_INT, O_OPT, P_NZERO, null, null), - "stime"=> array(T_ZBX_INT, O_OPT, P_NZERO, null, null), - "border"=> array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), - "name"=> array(T_ZBX_STR, O_OPT, NULL, null, null), - "width"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535), null), - "height"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535), null), - "yaxistype"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1,2"), null), - "graphtype"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), null), - "yaxismin"=> array(T_ZBX_DBL, O_OPT, NULL, BETWEEN(-65535,65535), null), - "yaxismax"=> array(T_ZBX_DBL, O_OPT, NULL, null, null), - "yaxismax"=> array(T_ZBX_DBL, O_OPT, NULL, null, null), - "items"=> array(T_ZBX_STR, O_OPT, NULL, null, null) + 'period'=> array(T_ZBX_INT, O_OPT, P_NZERO, BETWEEN(ZBX_MIN_PERIOD,ZBX_MAX_PERIOD), null), + 'from'=> array(T_ZBX_INT, O_OPT, P_NZERO, null, null), + 'stime'=> array(T_ZBX_INT, O_OPT, P_NZERO, null, null), + 'border'=> array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), + 'name'=> array(T_ZBX_STR, O_OPT, NULL, null, null), + 'width'=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535), null), + 'height'=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535), null), + 'yaxistype'=> array(T_ZBX_INT, O_OPT, NULL, IN('0,1,2'), null), + 'graphtype'=> array(T_ZBX_INT, O_OPT, NULL, IN('0,1'), null), + 'yaxismin'=> array(T_ZBX_DBL, O_OPT, NULL, BETWEEN(-65535,65535), null), + 'yaxismax'=> array(T_ZBX_DBL, O_OPT, NULL, null, null), + 'yaxismax'=> array(T_ZBX_DBL, O_OPT, NULL, null, null), + 'items'=> array(T_ZBX_STR, O_OPT, NULL, null, null) ); check_fields($fields); @@ -64,37 +64,37 @@ include_once "include/page_header.php"; access_deny(); } } + + $graph = new Chart(get_request('graphtype' ,GRAPH_TYPE_NORMAL)); - $graph = new Chart(get_request("graphtype" ,GRAPH_TYPE_NORMAL)); - - $graph->SetHeader($host["host"].":".get_request("name","")); + $graph->SetHeader($host['host'].':'.get_request('name','')); unset($host); - if(isset($_REQUEST["period"])) $graph->SetPeriod($_REQUEST["period"]); - if(isset($_REQUEST["from"])) $graph->SetFrom($_REQUEST["from"]); - if(isset($_REQUEST["stime"])) $graph->SetSTime($_REQUEST["stime"]); - if(isset($_REQUEST["border"])) $graph->SetBorder(0); + if(isset($_REQUEST['period'])) $graph->SetPeriod($_REQUEST['period']); + if(isset($_REQUEST['from'])) $graph->SetFrom($_REQUEST['from']); + if(isset($_REQUEST['stime'])) $graph->SetSTime($_REQUEST['stime']); + if(isset($_REQUEST['border'])) $graph->SetBorder(0); - $graph->SetWidth(get_request("width", 900)); - $graph->SetHeight(get_request("height", 200)); + $graph->SetWidth(get_request('width', 900)); + $graph->SetHeight(get_request('height', 200)); - $graph->ShowWorkPeriod(get_request("showworkperiod" ,1)); - $graph->ShowTriggers(get_request("showtriggers" ,1)); - $graph->SetYAxisType(get_request("yaxistype" ,GRAPH_YAXIS_TYPE_CALCULATED)); - $graph->SetYAxisMin(get_request("yaxismin" ,0.00)); - $graph->SetYAxisMax(get_request("yaxismax" ,100.00)); + $graph->ShowWorkPeriod(get_request('showworkperiod' ,1)); + $graph->ShowTriggers(get_request('showtriggers' ,1)); + $graph->SetYAxisType(get_request('yaxistype' ,GRAPH_YAXIS_TYPE_CALCULATED)); + $graph->SetYAxisMin(get_request('yaxismin' ,0.00)); + $graph->SetYAxisMax(get_request('yaxismax' ,100.00)); foreach($items as $id => $gitem) { $graph->AddItem( - $gitem["itemid"], - $gitem["yaxisside"], - $gitem["calc_fnc"], - $gitem["color"], - $gitem["drawtype"], - $gitem["type"], - $gitem["periods_cnt"] + $gitem['itemid'], + $gitem['yaxisside'], + $gitem['calc_fnc'], + $gitem['color'], + $gitem['drawtype'], + $gitem['type'], + $gitem['periods_cnt'] ); unset($items[$id]); @@ -103,6 +103,6 @@ include_once "include/page_header.php"; ?> <?php -include_once "include/page_footer.php"; +include_once 'include/page_footer.php'; ?> diff --git a/frontends/php/chart6.php b/frontends/php/chart6.php index a3f7e0f7..937c7b09 100644 --- a/frontends/php/chart6.php +++ b/frontends/php/chart6.php @@ -56,7 +56,7 @@ include_once "include/page_header.php"; if(!graph_accessible($_REQUEST['graphid'])){ access_deny(); } - + $sql = 'SELECT g.*,h.host,h.hostid '. ' FROM graphs g '. ' LEFT JOIN graphs_items gi ON g.graphid=gi.graphid '. diff --git a/frontends/php/chart7.php b/frontends/php/chart7.php index 30e67fec..df6d0e6a 100644 --- a/frontends/php/chart7.php +++ b/frontends/php/chart7.php @@ -62,7 +62,17 @@ include_once "include/page_header.php"; access_deny(); } } + + + $effectiveperiod = navigation_bar_calc(); + if(count($items) == 1){ + $_REQUEST['period'] = get_request('period',get_profile('web.item['.$items['itemid'].'].graph.period', ZBX_PERIOD_DEFAULT)); + if($_REQUEST['period'] >= ZBX_MIN_PERIOD){ + update_profile('web.item['.$items['itemid'].'].graph.period',$_REQUEST['period']); + } + } + $graph = new Pie(get_request("graphtype" ,GRAPH_TYPE_NORMAL)); $graph->SetHeader($host["host"].":".get_request("name","")); diff --git a/frontends/php/charts.php b/frontends/php/charts.php index 90a752b1..191e0856 100644 --- a/frontends/php/charts.php +++ b/frontends/php/charts.php @@ -391,10 +391,10 @@ include_once 'include/page_header.php'; $bstime = mktime(substr($bstime,8,2),substr($bstime,10,2),0,substr($bstime,4,2),substr($bstime,6,2),substr($bstime,0,4)); } - $script = 'scrollinit(0,0,0,'.$effectiveperiod.','.$stime.',0,'.$bstime.'); showgraphmenu("graph");'; + $script = 'scrollinit(0,'.$effectiveperiod.','.$stime.',0,'.$bstime.'); showgraphmenu("graph");'; if(($graphtype == GRAPH_TYPE_NORMAL) || ($graphtype == GRAPH_TYPE_STACKED)){ - $script.= 'graph_zoom_init("'.$dom_graph_id.'",'.$bstime.','.$effectiveperiod.',ZBX_G_WIDTH,'.$graph_height.');'; + $script.= 'graph_zoom_init("'.$dom_graph_id.'",'.$bstime.','.$effectiveperiod.',ZBX_G_WIDTH,'.$graph_height.',true);'; } zbx_add_post_js($script); diff --git a/frontends/php/history.php b/frontends/php/history.php index 9ca0a1e2..20ce8324 100644 --- a/frontends/php/history.php +++ b/frontends/php/history.php @@ -550,10 +550,10 @@ COpt::profiling_stop("history"); $bstime = mktime(substr($bstime,8,2),substr($bstime,10,2),0,substr($bstime,4,2),substr($bstime,6,2),substr($bstime,0,4)); } - $script = 'scrollinit(0,0,0,'.$effectiveperiod.','.$stime.',0,'.$bstime.'); + $script = 'scrollinit(0,'.$effectiveperiod.','.$stime.',0,'.$bstime.'); showgraphmenu("graph");'; if(isset($dom_graph_id)) - $script.='graph_zoom_init("'.$dom_graph_id.'",'.$bstime.','.$effectiveperiod.',ZBX_G_WIDTH, 200);'; + $script.='graph_zoom_init("'.$dom_graph_id.'",'.$bstime.','.$effectiveperiod.',ZBX_G_WIDTH, 200, true);'; zbx_add_post_js($script); diff --git a/frontends/php/httpdetails.php b/frontends/php/httpdetails.php index 7607b2da..f7016ae5 100644 --- a/frontends/php/httpdetails.php +++ b/frontends/php/httpdetails.php @@ -261,10 +261,10 @@ include_once "include/page_header.php"; $bstime = mktime(substr($bstime,8,2),substr($bstime,10,2),0,substr($bstime,4,2),substr($bstime,6,2),substr($bstime,0,4)); } - $script = 'scrollinit(0,0,0,'.$period.','.$stime.',0,'.$bstime.'); + $script = 'scrollinit(0,'.$period.','.$stime.',0,'.$bstime.'); showgraphmenu("graph"); - graph_zoom_init("graph_1",'.$bstime.','.$period.',ZBX_G_WIDTH, 150); - graph_zoom_init("graph_2",'.$bstime.','.$period.',ZBX_G_WIDTH, 150);'; + graph_zoom_init("graph_1",'.$bstime.','.$period.',ZBX_G_WIDTH, 150, false); + graph_zoom_init("graph_2",'.$bstime.','.$period.',ZBX_G_WIDTH, 150, false);'; zbx_add_post_js($script); diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 0a1762cd..bae6c3e4 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -1034,7 +1034,8 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! # Show History Graph function show_history($itemid,$from,$stime,$period){ $till=date(S_DATE_FORMAT_YMDHMS,time(NULL)-$from*3600); - show_table_header(S_TILL.SPACE.$till.' ('.($period/3600).' HOURs)'); + + show_table_header(S_TILL.SPACE.$till.' ( '.zbx_date2age($stime,$stime+$period).' )'); $td = new CCol(get_js_sizeable_graph('graph','chart.php?itemid='.$itemid. url_param($from,false,'from'). diff --git a/frontends/php/include/screens.inc.php b/frontends/php/include/screens.inc.php index 5a92c8ec..7a420e63 100644 --- a/frontends/php/include/screens.inc.php +++ b/frontends/php/include/screens.inc.php @@ -400,7 +400,8 @@ $g_img->AddOPtion('id',$dom_graph_id); $item = new CLink($g_img,$action); - if(!is_null($graphid)){ + + if(!is_null($graphid) && ($editmode != 1)){ insert_js(' A_SBOX["'.$dom_graph_id.'"] = new Object;'. 'A_SBOX["'.$dom_graph_id.'"].shiftT = 17;'. 'A_SBOX["'.$dom_graph_id.'"].shiftL = '.$shiftXleft.';' @@ -413,7 +414,7 @@ else{ $stime = 'null'; } - zbx_add_post_js('graph_zoom_init("'.$dom_graph_id.'",'.$stime.','.$effectiveperiod.','.$width.','.$height.');'); + zbx_add_post_js('graph_zoom_init("'.$dom_graph_id.'",'.$stime.','.$effectiveperiod.','.$width.','.$height.', false);'); } } } diff --git a/frontends/php/js/gmenu.js b/frontends/php/js/gmenu.js index 5f074fab..c8de9891 100644 --- a/frontends/php/js/gmenu.js +++ b/frontends/php/js/gmenu.js @@ -28,14 +28,14 @@ var _PE_GM = null; // Periodical executer obj reference var GMENU_IMG_PATH='images/general/bar'; //var cal = new calendar(); -function gmenuinit(top,left,period,bar_stime){ +function gmenuinit(bar_stime,period){ - gmenucreate(top,left); + gmenucreate(0,0); period = period || 3600; bar_stime = bar_stime || 0; - G_MENU = new gmenu(period,bar_stime); + G_MENU = new gmenu(bar_stime,period); G_MENU.gm_value = $('gmenu_period_value'); G_MENU.gm_type = $('gmenu_period_type'); @@ -181,7 +181,7 @@ period_type: 0, // period value type period_typename: new Array('Hours','Days','Weeks','Months','Years'), //period value type -initialize: function(period, bstime){ +initialize: function(bstime,period){ this.bstime = parseInt(bstime); // setting graph starttime if(this.bstime < 1000000000){ diff --git a/frontends/php/js/sbinit.js b/frontends/php/js/sbinit.js index 54bcc88a..b0b411cf 100644 --- a/frontends/php/js/sbinit.js +++ b/frontends/php/js/sbinit.js @@ -28,7 +28,7 @@ function hidegraphmenu(pe){ _PE_SB.stop(); _PE_SB = null; - if((G_MENU.gmenumsover == 0 ) && (SCROLL_BAR.barmsdown == 0) && (SCROLL_BAR.arrowmsdown == 0)){ + if((G_MENU.gmenumsover == 0 ) && (SCROLL_BAR.barmsdown == 0) && (SCROLL_BAR.arrowmsdown == 0) && (SCROLL_BAR.changed == 1)){ graphsubmit(); } } @@ -38,19 +38,25 @@ function showgraphmenu(obj_id){ var obj = $(obj_id); if((typeof(obj) == 'undefined')) return false; + var period_exec = 2; + if(obj.nodeName.toLowerCase() == 'img'){ + SCROLL_BAR.dom_graphs.push(obj); + addListener(obj,'load',function(){SCROLL_BAR.disabled=0;}); + period_exec = 0.01; + } + var pos = getPosition(obj); pos.top+=obj.offsetHeight+18; - var scrl = $('scroll'); - scrl.style.top = pos.top+"px"; - scrl.style.left = 1+"px"; + SCROLL_BAR.scrl_scroll.style.top = pos.top+"px"; // 110 = G_MENU height + SCROLL_BAR.scrl_scroll.style.left = 1+"px"; G_MENU.gm_gmenu.style.top = (pos.top-108)+"px"; // 110 = G_MENU height G_MENU.gm_gmenu.style.left = 1+"px"; SCROLL_BAR.onchange = function(){ if(is_null(_PE_SB)){ - _PE_SB = new PeriodicalExecuter(hidegraphmenu,2); + _PE_SB = new PeriodicalExecuter(hidegraphmenu,period_exec); } } @@ -66,8 +72,10 @@ function showgraphmenu(obj_id){ // G_MENU.gmenumouseout = function(){G_MENU.gmenuhide(); } var gmshow = function(){ + if(SCROLL_BAR.disabled) return false; + if(SCROLL_BAR.changed == 1){ - G_MENU.gmenushow(SCROLL_BAR.period,SCROLL_BAR.getsTimeInUnix()); + G_MENU.gmenushow(SCROLL_BAR.getsTimeInUnix(),SCROLL_BAR.period); } else{ G_MENU.gmenushow(); @@ -76,66 +84,24 @@ function showgraphmenu(obj_id){ addListener($('scroll_calendar'),'click',gmshow,false); - if(IE){ SCROLL_BAR.settabinfo(); try{$('scroll_calendar').setStyle({'border' : '0px white solid;'});} catch(e){} } - scrl.style.visibility = 'visible'; -} - -function graphsubmit(){ - var scrl = $('scroll'); - - scrl.style.display = 'none'; - - var uri = new url(location.href); - var stime = SCROLL_BAR.getsTime(); - - if((SCROLL_BAR.dt.getTime()-(SCROLL_BAR.period * 1000)) == SCROLL_BAR.sdt.getTime()){ -// alert((SCROLL_BAR.dt.getTime()-(SCROLL_BAR.period * 1000))+' != '+SCROLL_BAR.sdt.getTime()); - stime=parseInt(stime)+100000000; - } - - uri.setArgument('stime', stime); - uri.setArgument('period', SCROLL_BAR.getPeriod()); - - location.href = uri.getUrl(); -} - -function gmenuload(){ - - var date = datetoarray(G_MENU.bstime); - var stime = ''+date[2]+date[1]+date[0]+date[3]+date[4]; - var uri = new url(location.href); - - uri.setArgument('stime', stime); - uri.setArgument('period', G_MENU.period); - - location.href = uri.getUrl(); + SCROLL_BAR.scrl_scroll.style.visibility = 'visible'; + SCROLL_BAR.disabled=0; } -function sboxload(){ - var date = datetoarray(parseInt(this.stime)); // `this` becomes related to the object who ownes that function!! -//SDI(this.sbox_id); - var stime = ''+date[2]+date[1]+date[0]+date[3]+date[4]; - - var uri = new url(location.href); - - uri.setArgument('stime', stime); - uri.setArgument('period', this.period); - - location.href = uri.getUrl(); -} - -function graph_zoom_init(graph_id,stime,period,width,height){ +function graph_zoom_init(graph_id,stime,period,width,height, dynamic){ if((typeof(graph_id) == 'undefined') || empty(graph_id)) return; + dynamic = dynamic || 0; A_SBOX[graph_id].sbox = sbox_init(stime,period); A_SBOX[graph_id].sbox.sbox_id = graph_id; + A_SBOX[graph_id].sbox.dynamic = dynamic; var igraph = $(graph_id); var boxongraph = create_box_on_obj(igraph.parentNode); @@ -181,6 +147,93 @@ function graph_zoom_init(graph_id,stime,period,width,height){ } } +function graphload(dom_objects,unix_stime,period,dynamic){ + + if(period < 3600) return false; + + var date = datetoarray(unix_stime); + var url_stime = ''+date[2]+date[1]+date[0]+date[3]+date[4]; + + if((typeof(SCROLL_BAR) != 'undefined') && SCROLL_BAR.changed){ + if((SCROLL_BAR.dt.getTime()-(SCROLL_BAR.period * 1000)) == SCROLL_BAR.sdt.getTime()){ + url_stime=parseInt(url_stime)+100000000; + } + } + + + if(empty(dom_objects) || !dynamic){ + dynamic = 0; + dom_objects = new Array(location); + } + + dynamic = dynamic || 0; + var src = ''; + var uri = ''; + + if(!is_array(dom_objects)) dom_objects = new Array($(dom_objects)); + + if(dynamic){ + for(var i=0; i<dom_objects.length; i++){ + if((typeof(dom_objects[i].nodeName) == 'undefined') && (dom_objects[i].nodeName.toLowerCase() != 'img')){ + continue; + } +// SBOX + A_SBOX[dom_objects[i].id].sbox.obj.stime = unix_stime; + A_SBOX[dom_objects[i].id].sbox.obj.period = period; +//------ +//SCROLL_BAR + SCROLL_BAR.initialize(SCROLL_BAR.starttime,period,unix_stime,0) + + SCROLL_BAR.scrl_tabinfoleft.innerHTML = SCROLL_BAR.FormatStampbyDHM(period)+" | "+date[0]+'.'+date[1]+'.'+date[2]+' '+date[3]+':'+date[4]+':'+date[5]; + + date = datetoarray(unix_stime + (parseInt(period/60)*60)); + SCROLL_BAR.scrl_tabinforight.innerHTML = date[0]+'.'+date[1]+'.'+date[2]+' '+date[3]+':'+date[4]+':'+date[5]; + +//---------- +//GMENU + G_MENU.initialize(unix_stime,period); + + G_MENU.syncBSDateByBSTime(); + + G_MENU.calcPeriodAndTypeByUnix(period); + G_MENU.setBSDate(); + G_MENU.setPeriod(); + G_MENU.setPeriodType(); +//--------- +//alert(url_stime); + uri = new url(dom_objects[i].src); + uri.setArgument('stime', url_stime); + uri.setArgument('period', period); + + dom_objects[i].src = uri.getUrl(); + } + } + else{ + uri = new url(dom_objects[0].href); + uri.setArgument('stime', url_stime); + uri.setArgument('period', period); + + dom_objects[0].href = uri.getUrl(); + } +} + +function graphsubmit(){ + SCROLL_BAR.disabled = 1; + SCROLL_BAR.changed = 0; + graphload(SCROLL_BAR.dom_graphs, SCROLL_BAR.getsTimeInUnix(), SCROLL_BAR.getPeriod(), (SCROLL_BAR.dom_graphs.length > 0)); +} + +function gmenuload(){ + G_MENU.gmenuhide(); + graphload(SCROLL_BAR.dom_graphs, G_MENU.bstime, G_MENU.period, (SCROLL_BAR.dom_graphs.length > 0)); +} + + +function sboxload(){ + var igraph = $(this.sbox_id); + graphload(igraph, parseInt(this.stime), this.period, this.dynamic); +} + function datetoarray(unixtime){ var date = new Date(); diff --git a/frontends/php/js/sbox.js b/frontends/php/js/sbox.js index 3bc14a2e..fd323774 100644 --- a/frontends/php/js/sbox.js +++ b/frontends/php/js/sbox.js @@ -57,6 +57,8 @@ dom_period_span: '', // period container html obj px2time: '', // seconds in 1px +dynamic: '', // how page updates, all page/graph only update + initialize: function(stime, period){ @@ -295,7 +297,9 @@ clear_params: function(){ this.start_event = new Object; this.dom_box = ''; + this.box = new Object; + this.box.width = 0; } } diff --git a/frontends/php/js/scrollbar.js b/frontends/php/js/scrollbar.js index 5e6f1ed1..3047afba 100644 --- a/frontends/php/js/scrollbar.js +++ b/frontends/php/js/scrollbar.js @@ -27,8 +27,8 @@ var SCROLL_BAR; var IMG_PATH='images/general/bar'; //var cal = new calendar(); -function scrollinit(left,top,w,period,stime,timel,bar_stime){ - if((typeof(top) == 'undefined') && (typeof(left) == 'undefined')){ +function scrollinit(w,period,stime,timel,bar_stime){ + if(typeof(w) == 'undefined'){ throw "Parametrs haven't been sent properly"; return false; } @@ -39,11 +39,10 @@ function scrollinit(left,top,w,period,stime,timel,bar_stime){ stime = ('undefined' == typeof(stime))?0:stime; bar_stime = ('undefined' == typeof(bar_stime))?0:bar_stime; - gmenuinit(top,left,period,bar_stime); + gmenuinit(bar_stime,period); SCROLL_BAR = new scrollbar(stime,period,bar_stime,w); - SCROLL_BAR.showscroll(top,left); - + SCROLL_BAR.scrl_arrowleft.onmousedown = SCROLL_BAR.arrowmousedown.bind(SCROLL_BAR); SCROLL_BAR.scrl_arrowright.onmousedown = SCROLL_BAR.arrowmousedown.bind(SCROLL_BAR); @@ -97,8 +96,10 @@ scrl_arrowleft: '', // html left arrow scrl_arrowright:'', // html right arrow scrl_tabinfoleft: '', // html object(div) where view info (left) scrl_tabinforight: '', // html object(div) where view info (right) -scrl_barbgl:'', // size of left side +6 of bar -scrl_barbgr:'', // size of right side +6 of bar +scrl_barbgl:'', // size of left side +6 of bar +scrl_barbgr:'', // size of right side +6 of bar + +dom_graphs: new Array(), // list of img objects (graphs), attached to this bar // status scrollmsover: 0, // if mouse over scrollbar then = 1, out = 0 @@ -106,13 +107,17 @@ barmsdown: 0, // if mousedown on bar = 1, else = 0 arrowmsdown: 0, // if mousedown on arrow = 1, else = 0 arrow: '', // pressed arrow (l/r) changed: 0, // switches to 1, when scrollbar been moved or period changed +disabled: 1, // activates/disables scrollbar xp: 0, // exponential of time length initialize: function(stime,period,bar_stime,width){ // where to put bar on start(time on graph) try{ - this.scrollcreate(0,0,width); + if(empty(this.scrl_scroll)) this.scrollcreate(0,0,width); + this.period = period; + this.barX = 0; + this.barW = 8+4+4; /************************************************************************ * Do not change till you fully understand what you are doing. * @@ -131,12 +136,13 @@ initialize: function(stime,period,bar_stime,width){ // where to put bar on start this.timeline = 3*this.period; this.starttime = parseInt(this.dt.getTime()/1000 - this.timeline); } - + if(!bar_stime) bar_stime = (this.dt.getTime()/1000) - this.period; this.scrollbarMaxW = parseInt($('scroll_middle').style.width); this.xp = Math.log(this.timeline) / this.scrollbarMaxW; + this.pxtime = 0; this.minbarW = this.time2px(3600); this.minbarW = (this.minbarW<16)?16:this.minbarW; @@ -145,16 +151,13 @@ initialize: function(stime,period,bar_stime,width){ // where to put bar on start this.scrollbarW = parseInt(this.scrollbarMaxW) - this.barW; this.calcpx2time(); - + this.barX = this.time2px(bar_stime - this.starttime); this.barX = this.checkbarX(0); - -//SDI(this.barX+' : '+this.barW+' : '+this.scrollbarMaxW); -//SDI(this.barX+' : '+this.barW+' : '+this.scrollbarMaxW); - +//SDI(this.xp+' : '+this.period+' : '+bar_stime+' : '+this.starttime+" ---||--- "+this.barX+' : '+this.barW+' : '+this.scrollbarMaxW); this.barchangeW(); this.movescroll(); - + this.settabinfo(); this.changed = 0; // we need to reset this attribute, because generaly we may already performe a movement @@ -221,6 +224,7 @@ arrowmouseout: function(){ }, arrowmousedown: function(e){ + if(this.disabled) return false; e = e || window.event; this.deselectall(); @@ -242,8 +246,11 @@ arrowmousedown: function(e){ }, arrowmousemove: function(e){ + if(this.disabled) return false; e = e || window.event; + if(this.arrowmsdown!=1) return false; + if(this.arrow.id == 'arrow_l'){ this.arrowmousemove_L(e); } @@ -302,6 +309,8 @@ arrowmousemove_R: function(e){ }, arrowmouseup: function(e){ + if(this.disabled) return false; + this.period = this.calcperiod(); document.onmousemove = null; this.arrowmsdown = 0; @@ -314,26 +323,33 @@ arrowmouseup: function(e){ ------------------------------ BAR CONTROLS ------------------------------ ------------------------------------------------------------------------*/ mousedown: function(e){ + if(this.disabled) return false; + e = e || window.event; this.deselectall(); this.mouseStartX = parseInt(this.getmousexy(e).x); this.prevmouseX = this.mouseStartX; this.barStartX = this.barX; - + this.barmsdown = 1; this.barmousedown(); document.onmousemove = this.mousemove.bind(this); }, mousebarup: function(e){ + if(this.disabled) return false; + document.onmousemove = null; this.barmsdown = 0; this.onbarchange(); }, mouseup: function(e){ + if(this.disabled) return false; + e = e || window.event; + if( this.barmsdown == 1){ this.mousebarup(e); } @@ -343,6 +359,8 @@ mouseup: function(e){ }, mousemove: function(e){ + if(this.disabled) return false; + e = e || window.event; var mousexy = this.getmousexy(e); @@ -358,6 +376,8 @@ mousemove: function(e){ //--- scrollmoves scrollmoveleft: function(){ + if(this.disabled) return false; + this.barmousedown(); this.barX--; @@ -365,6 +385,8 @@ scrollmoveleft: function(){ this.onbarchange(); }, scrollmoveright: function(){ + if(this.disabled) return false; + this.barmousedown(); this.barX++; @@ -476,25 +498,6 @@ getmousexy: function(e){ }; }, -datetoarray: function(unixtime){ - - var date = new Date(); - date.setTime(unixtime*1000); - - var thedate = new Array(); - thedate[0] = date.getDate(); - thedate[1] = date.getMonth()+1; - thedate[2] = date.getFullYear(); - thedate[3] = date.getHours(); - thedate[4] = date.getMinutes(); - thedate[5] = date.getSeconds(); - - for(i = 0; i < thedate.length; i++){ - if((thedate[i]+'').length < 2) thedate[i] = '0'+thedate[i]; - } -return thedate; -}, - deselectall: function(){ if(IE){ document.selection.empty(); @@ -517,9 +520,10 @@ arrowmovetoX: function(){ //---bar period2bar: function(period){ - this.barW = this.time2px(period); + + this.barW = this.time2px(period); this.barW = this.checkbarW(0); - + this.barchangeW(this.barW); }, //------------------------------- @@ -540,10 +544,10 @@ settabinfo: function(){ this.sdt.setTime(this.dt.getTime()-(this.period * 1000)); } - var date = this.datetoarray((this.sdt.getTime() / 1000)); + var date = datetoarray((this.sdt.getTime() / 1000)); this.scrl_tabinfoleft.innerHTML = this.FormatStampbyDHM(this.period)+" | "+date[0]+'.'+date[1]+'.'+date[2]+' '+date[3]+':'+date[4]+':'+date[5]; - var date = this.datetoarray((this.sdt.getTime() / 1000) + this.period); + var date = datetoarray((this.sdt.getTime() / 1000) + this.period); this.scrl_tabinforight.innerHTML = date[0]+'.'+date[1]+'.'+date[2]+' '+date[3]+':'+date[4]+':'+date[5]; }, @@ -555,11 +559,11 @@ return period; }, getsTimeInUnix: function(){ - return Math.round((this.starttime+(this.barX*this.pxtime))); + return parseInt(this.sdt.getTime()/1000); }, getsTime: function(){ - var date = this.datetoarray((this.sdt.getTime() / 1000)); + var date = datetoarray(this.sdt.getTime() / 1000); return ''+date[2]+date[1]+date[0]+date[3]+date[4]; }, diff --git a/frontends/php/screens.php b/frontends/php/screens.php index bac980aa..83f7aee4 100644 --- a/frontends/php/screens.php +++ b/frontends/php/screens.php @@ -330,7 +330,7 @@ include_once "include/page_header.php"; $bstime = mktime(substr($bstime,8,2),substr($bstime,10,2),0,substr($bstime,4,2),substr($bstime,6,2),substr($bstime,0,4)); } - $script = 'scrollinit(0,0,0,'.$effectiveperiod.','.$stime.',0,'.$bstime.'); + $script = 'scrollinit(0,'.$effectiveperiod.','.$stime.',0,'.$bstime.'); showgraphmenu("iframe");'; zbx_add_post_js($script); |