summaryrefslogtreecommitdiffstats
path: root/public/js/icinga/behavior/application-state.js
blob: 8c0e2fd62f0df9da569bccb12e95373b17e998e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*! Icinga Web 2 | (c) 2015 Icinga Development Team | GPLv2+ */

(function(Icinga, $) {

    'use strict';

    Icinga.Behaviors = Icinga.Behaviors || {};

    var ApplicationState = function (icinga) {
        Icinga.EventListener.call(this, icinga);
        this.on('rendered', '#layout', this.onRendered, this);
        this.icinga = icinga;
    };

    ApplicationState.prototype = new Icinga.EventListener();

    ApplicationState.prototype.onRendered = function(e) {
        if (e.currentTarget !== e.target) {
            // Nested containers are ignored
            return;
        }

        if (! $('#application-state').length
            && ! $('#login').length
            && ! $('#guest-error').length
            && ! $('#setup').length
        ) {
            var _this = e.data.self;

            $('#layout').append(
                '<div id="application-state" class="container" hidden data-icinga-url="'
                + _this.icinga.loader.baseUrl
                + '/application-state" data-icinga-refresh="60"></div>'
            );
        }
    };

    Icinga.Behaviors.ApplicationState = ApplicationState;

})(Icinga, jQuery);