summaryrefslogtreecommitdiffstats
path: root/frontends/php/js
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-02-25 15:20:55 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-02-25 15:20:55 +0000
commit8b818f2fa041df344af3cfde1fec132bf3ae2927 (patch)
tree43c86a894fe6ceb8225adc933cc486de05ebdf6d /frontends/php/js
parentd215a0cc8d018303992833528c36455480cfb10b (diff)
downloadzabbix-8b818f2fa041df344af3cfde1fec132bf3ae2927.tar.gz
zabbix-8b818f2fa041df344af3cfde1fec132bf3ae2927.tar.xz
zabbix-8b818f2fa041df344af3cfde1fec132bf3ae2927.zip
- [DEV-118] added refresh options to dashboard screen {still beta} (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5394 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/js')
-rw-r--r--frontends/php/js/dashboard.js83
1 files changed, 83 insertions, 0 deletions
diff --git a/frontends/php/js/dashboard.js b/frontends/php/js/dashboard.js
index 997d3a5a..7702f388 100644
--- a/frontends/php/js/dashboard.js
+++ b/frontends/php/js/dashboard.js
@@ -1,4 +1,21 @@
// JavaScript Document
+function setRefreshRate(id,interval){
+ var params = {
+ 'favobj': 'set_rf_rate',
+ 'favid': id,
+ 'favcnt': interval
+ }
+
+ new Ajax.Request("dashboard.php?output=ajax",
+ {
+ 'method': 'post',
+ 'parameters':params,
+ 'onSuccess': function(resp){ },//alert(resp.responseText);
+ 'onFailure': function(){ document.location = 'dashboard.php?'+Object.toQueryString(params); }
+ }
+ );
+
+}
function add2favorites(){
@@ -93,6 +110,7 @@ function create_menu(e,id){
var dbrd_menu = new Array();
//to create a copy of array, but not references!!!!
+//alert(id+' : '+dashboard_menu[id]);
for(var i=0; i < dashboard_menu[id].length; i++){
if(isset(dashboard_menu[id][i]) && !empty(dashboard_menu[id][i]))
dbrd_menu[i] = dashboard_menu[id][i].clone();
@@ -107,4 +125,69 @@ function create_menu(e,id){
}
//alert(dashboard_menu[id]);
show_popup_menu(e,dbrd_menu,280);// JavaScript Document
+}
+
+
+// DOM obj update class
+// Author: Aly
+var updater = {
+objlist: new Array(), // list of objects
+optlist : new Array(), // object params, list
+interval: 10, // update interval in sec
+
+setObj4Update: function(id,url,params,frequency){
+ var obj = document.getElementById(id);
+ if(!isset(obj)) return false;
+
+ var obj4update = {
+ 'id': id,
+ 'url': url,
+ 'params': params,
+ 'interval': frequency,
+ 'lastupdate': 0
+ }
+
+ if(!isset(this.optlist[id])){
+ this.objlist.push(id);
+ }
+ this.optlist[id] = obj4update;
+},
+
+check4Update: function(){
+ if(this.objlist.length > 0){
+ var dt = new Date();
+ var now = parseInt(dt.getTime()/1000);
+
+ for(var i=0; i < this.objlist.length; i++){
+ if(isset(this.optlist[this.objlist[i]]) && !empty(this.optlist[this.objlist[i]])){
+// alert(Math.abs(now - this.optlist[this.objlist[i]].lastupdate));
+ if(this.optlist[this.objlist[i]].interval <= Math.abs(now - this.optlist[this.objlist[i]].lastupdate)){
+ this.update(this.optlist[this.objlist[i]],now);
+ }
+ }
+ }
+ }
+ setTimeout('updater.check4Update();',(this.interval*1000));
+},
+
+update: function(obj4update,time){
+ new Ajax.Updater(obj4update.id, obj4update.url,
+ {
+ method: 'post',
+ 'parameters': obj4update.params,
+ 'onSuccess': function(resp){ obj4update.lastupdate = time;},
+ 'onFailure': function(){ document.location = 'dashboard.php?'+Object.toQueryString(obj4update.params); }
+ });
+}
+}
+
+function getTimeFormated(timestamp){
+ var dt = new Date();
+
+ var hours = dt.getHours();
+ var minutes = dt.getMinutes();
+ var seconds = dt.getSeconds();
+ var str = '['+hours+':'+minutes+':'+seconds+']';
+
+return str;
} \ No newline at end of file