Project

General

Profile

Revision aed0c054

IDaed0c054fb8060402541dfef262cf63688c8e3a5
Parent 07b61154
Child 6216260a

Added by Aurelien BOMPARD over 13 years ago

  • Amélioration des menus de choix dans VigiGraph * Présentation légèrement différente de la barre d'outils

git-svn-id: https://vigilo-dev.si.c-s.fr/svn@5628 b22e2e97-25c9-44ff-b637-2e5ceca36478

View differences:

vigigraph/controllers/rpc.py
31 31
from vigilo.models.tables import PerfDataSource
32 32
from vigilo.models.tables import Graph, GraphGroup
33 33
from vigilo.models.tables.grouphierarchy import GroupHierarchy
34
from vigilo.models.tables import Change
34 35

  
35 36
from vigilo.models.tables.secondary_tables import SUPITEM_GROUP_TABLE
36 37
from vigilo.models.tables.secondary_tables import GRAPH_GROUP_TABLE
......
724 725
                ).filter(Host.name == host
725 726
                ).all()
726 727
        return indicators
728

  
729
    @expose('json')
730
    def dbmtime(self):
731
        change = Change.by_table_name(u"Graph")
732
        if change is None:
733
            return {"mtime": None}
734
        mtime = change.last_modified.replace(microsecond=0)
735
        return {"mtime": mtime}
736

  
vigigraph/public/js/toolbar.js
2 2
    Extends: Jx.Button.Flyout,
3 3

  
4 4
    initialize: function (options, url, hostid) {
5
        this.parent(options);
6 5
        this.idselection = null;
7 6
        this.tree = new TreeGroup({
8 7
            title: this.options.label,
9 8
            url: url,
10 9
            hostid: hostid
11 10
        });
11
        options.content = this.tree.container;
12
        this.parent(options);
12 13
        this.tree.addEvent('select', this.selectItem.bind(this));
14

  
15
        // On adapte la fenêtre popup aux dépliements de l'arbre
16
        var adaptPopup = function(e) {
17
            if (!this.options.active) return;
18
            // On évite le scrolling dans le menu popup
19
            var size_x = this.content.getSize().x;
20
            var scroll_size_x = this.content.getScrollSize().x;
21
            if (scroll_size_x > size_x) {
22
                this.content.setStyle("width", scroll_size_x + 10);
23
                // 10: padding-right du div
24
            }
25
            // On adapte la bordure ombrée
26
            this.contentContainer.setContentBoxSize(
27
                    $(this.content).getMarginBoxSize());
28
        };
29
        this.tree.addEvent("branchloaded", adaptPopup.bind(this));
30
        this.tree.addEvent("nodedisclosed", adaptPopup.bind(this));
31
        
13 32
   },
14 33

  
15 34
    setItem: function (idselection, label) {
......
20 39

  
21 40
    selectItem: function (item) {
22 41
        this.setItem(item.options.data, item.options.label);
42
        this.hide();
23 43
    },
24 44

  
25
    clicked: function (e) {
26
        if (!this.options.enabled)
27
            return;
28
        this.tree.selectGroup();
45
    //clicked: function (e) {
46
    //    if (!this.options.enabled)
47
    //        return;
48
    //    this.tree.selectGroup();
49
    //},
50

  
51
    redraw: function() {
52
        this.tree.redraw();
29 53
    }
30 54
});
31 55

  
......
37 61

  
38 62
        this.global_refresh = new Jx.Button({
39 63
            tooltip: _('Globally change auto-refresh setting'),
40
            image: app_path + 'images/refresh-all.png',
64
            //image: app_path + 'images/refresh-all.png',
65
            image: app_path + 'images/refresh.png',
41 66
            toggle: true,
42 67
            onDown: function () {
43 68
                window.graphs.each(function (graph) {
......
50 75
                }, this.global_refresh);
51 76
            }.bind(this)
52 77
        });
53
        this.jxtoolbar.add(this.global_refresh);
54 78

  
55 79
        this.host_label = new Jx.Toolbar.Item(this.createLabel(_('Host:')));
56 80

  
57 81
        this.host_picker = new Jx.Button.SelectorFlyout({
58 82
                label: _('Select a host'),
59
                tooltip: _('Click me to select another host')
83
                tooltip: _('Click me to select another host'),
60 84
            },
61 85
            app_path + 'rpc/hosttree',
62 86
            null
......
74 98
        }.bind(this));
75 99

  
76 100
        this.show_nagios = new Jx.Button({
77
            label: _('Nagios page'),
101
            //label: _('Nagios page'),
78 102
            tooltip: _('Display Nagios page for the selected host'),
103
            image: app_path + 'images/nagios-16.png',
79 104
            toggle: false,
80 105
            enabled: false,
81 106
            onClick: function () {
......
93 118
            }.bind(this)
94 119
        })
95 120

  
96
        this.jxtoolbar.add(this.host_label);
97
        this.jxtoolbar.add(this.host_picker);
98
        this.jxtoolbar.add(this.show_nagios);
99

  
100
        var separator = new Jx.Toolbar.Separator();
101
        this.jxtoolbar.add(separator);
102

  
103 121
        this.graph_label = new Jx.Toolbar.Item(this.createLabel(_('Graph:')));
104 122

  
105 123
        this.graph_picker = new Jx.Button.SelectorFlyout({
......
112 130
        );
113 131

  
114 132
        this.graph_picker.addEvent("select", function (idselection, label) {
115
            if (idselection !== null)
116
                this.show_graph.setEnabled(1);
133
            if (idselection !== null) {
134
                //this.show_graph.setEnabled(1);
135
                new Graph(
136
                    {autoRefresh: this.global_refresh.isActive() ? 1 : 0},
137
                    this.host_picker.getLabel(),
138
                    this.graph_picker.getLabel()
139
                );
140
            }
117 141
        }.bind(this));
118 142

  
119 143
        this.show_graph = new Jx.Button({
......
130 154
            }.bind(this)
131 155
        })
132 156

  
133
        this.jxtoolbar.add(this.graph_label);
157
        // Remplissage de la barre d'outils
158
        this.jxtoolbar.add(this.global_refresh);
159
        this.jxtoolbar.add(this.show_nagios);
160
        this.jxtoolbar.add(new Jx.Toolbar.Separator());
161
        this.jxtoolbar.add(this.host_label); // à supprimer ?
162
        this.jxtoolbar.add(this.host_picker);
163
        this.jxtoolbar.add(new Jx.Toolbar.Separator());
164
        this.jxtoolbar.add(this.graph_label); // à supprimer ?
134 165
        this.jxtoolbar.add(this.graph_picker);
135
        this.jxtoolbar.add(this.show_graph);
166
        //this.jxtoolbar.add(this.show_graph);
167

  
168
        // Vérification de la date de dernière modification en base, et
169
        // rechargement des arbres le cas échéant
170
        this.loadtime = new Date();
171
        this.req_expiration = new Request.JSON({
172
            method: "get",
173
            url: app_path + "rpc/dbmtime",
174
            onSuccess: function(result){
175
                if (!result) return;
176
                var mtime = Date.parse(result.mtime);
177
                if ((toolbar.loadtime - mtime) >= 0) return;
178
                // la base a changé, on recharge les arbres
179
                toolbar.host_picker.tree.redraw();
180
                toolbar.graph_picker.tree.redraw();
181
                // @todo: En théorie on devrait aussi vérifier que l'élément
182
                // sélectionné existe dans l'arbre, mais c'est un peu compliqué
183
                // avec le chargement dynamique. Il faudrait faire une requête
184
                // spécifique
185
                toolbar.loadtime = new Date();
186
            }
187
        });
188
        this.req_expiration.send.periodical(30 * 1000, this.req_expiration);
136 189
    },
137 190

  
138 191
    // Retourne un objet opaque qui possède un label,
......
152 205
        content.inject(container);
153 206

  
154 207
        return container;
208
    },
209

  
210
    // Vérifie si la base a changé, et recharge les sélecteurs en conséquence
211
    checkExpiration: function() {
212
        if (!this.req_expiration) { // ne creer qu'une instance
213
            this.req_expiration = new Request.JSON({
214
                method: "get",
215
                url: app_path + "rpc/dbmtime",
216
                onSuccess: function(result){
217
                    if (!result) return;
218
                    var mtime = Date.parse(result.mtime);
219
                    if ((toolbar.loadtime - mtime) >= 0) return;
220
                    // la base a changé, on recharge les arbres
221
                    if (toolbar.host_picker.idselection) {
222
                        toolbar.host_picker.tree.redraw();
223
                    }
224
                    if (toolbar.graph_picker.idselection) {
225
                        toolbar.graph_picker.tree.redraw();
226
                    }
227
                    // @todo: En théorie on devrait aussi vérifier que
228
                    // l'élément sélectionné existe dans l'arbre, mais c'est un
229
                    // peu compliqué avec le chargement dynamique. Il faudrait
230
                    // faire une requête spécifique
231
                    toolbar.loadtime = new Date();
232
                }
233
            });
234
        }
235
        this.req_expiration.send();
155 236
    }
156 237
});
157 238

  
vigigraph/public/js/tree.js
15 15
        this.setOptions(options);
16 16

  
17 17
        /* L'objet tree se réfère à un élément div*/
18
        var container = new Element('div')
19
        this.tree = new Jx.Tree({parent: container});
18
        this.container = new Element('div')
19
        this.container.setStyle("padding", "0 10px 10px 10px");
20
        this.tree = new Jx.Tree({parent: this.container});
20 21

  
21 22
        this.dlg = new Jx.Dialog({
22 23
            label: this.options.title,
23 24
            modal: true,
24 25
            resize: true,
25
            content: container
26
            content: this.container
26 27
        });
27 28

  
28 29
        this.redraw();
......
47 48
                        this.addLeaf(item, parent_node);
48 49
                    }, this);
49 50
                }
51
                this.fireEvent("branchloaded");
50 52
            }.bind(this)
51 53
        });
52 54

  
......
70 72
        });
71 73

  
72 74
        node.addEvent("disclosed", function(node) {
75
            this.fireEvent("nodedisclosed", node);
73 76
            if (!node.options.open || node.nodes.length > 0)
74 77
                return;
75 78
            this.retrieve_tree_items(node);

Also available in: Unified diff