diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:39:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:39:39 +0000 |
commit | 8ca6cc32b2c789a3149861159ad258f2cb9491e3 (patch) | |
tree | 2492de6f1528dd44eaa169a5c1555026d9cb75ec /modules/monitoring/public/js/module.js | |
parent | Initial commit. (diff) | |
download | icingaweb2-8ca6cc32b2c789a3149861159ad258f2cb9491e3.tar.xz icingaweb2-8ca6cc32b2c789a3149861159ad258f2cb9491e3.zip |
Adding upstream version 2.11.4.upstream/2.11.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules/monitoring/public/js/module.js')
-rw-r--r-- | modules/monitoring/public/js/module.js | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/modules/monitoring/public/js/module.js b/modules/monitoring/public/js/module.js new file mode 100644 index 0000000..d665e6b --- /dev/null +++ b/modules/monitoring/public/js/module.js @@ -0,0 +1,84 @@ +/*! Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */ + +(function(Icinga) { + + var Monitoring = function(module) { + /** + * The Icinga.Module instance + */ + this.module = module; + + /** + * The observer used to handle the timeline's infinite loading + */ + this.scrollCheckTimer = null; + + /** + * Whether to skip the timeline's scroll-check + */ + this.skipScrollCheck = false; + + this.initialize(); + }; + + Monitoring.prototype = { + + initialize: function() + { + this.module.on('rendered', this.enableScrollCheck); + this.module.icinga.logger.debug('Monitoring module loaded'); + }, + + /** + * Enable the timeline's scroll-check + */ + enableScrollCheck: function() + { + /** + * Re-enable the scroll-check in case the timeline has just been extended + */ + if (this.skipScrollCheck) { + this.skipScrollCheck = false; + } + + /** + * Prepare the timer to handle the timeline's infinite loading + */ + var $timeline = $('div.timeline'); + if ($timeline.length && !$timeline.closest('.dashboard').length) { + if (this.scrollCheckTimer === null) { + this.scrollCheckTimer = this.module.icinga.timer.register( + this.checkTimelinePosition, + this, + 800 + ); + this.module.icinga.logger.debug('Enabled timeline scroll-check'); + } + } + }, + + /** + * Check whether the user scrolled to the end of the timeline + */ + checkTimelinePosition: function() + { + if (!$('div.timeline').length) { + this.module.icinga.timer.unregister(this.scrollCheckTimer); + this.scrollCheckTimer = null; + this.module.icinga.logger.debug('Disabled timeline scroll-check'); + } else if (!this.skipScrollCheck && this.module.icinga.utils.isVisible('#end')) { + this.skipScrollCheck = true; + this.module.icinga.loader.loadUrl( + $('#end').remove().attr('href'), + $('div.timeline'), + undefined, + undefined, + 'append' + ).addToHistory = false; + } + } + }; + + Icinga.availableModules.monitoring = Monitoring; + +}(Icinga)); |