Project

General

Profile

Revision 71acc6fa

ID71acc6fa87d75acfdf9cbe87f4b326dd9a458960
Parent 17dc73e7
Child c38f9e7c

Added by Francois POIROTTE about 13 years ago

Possibilité d'ajouter des liens externes dans VigiGraph (#682).

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

View differences:

vigigraph/config/app_cfg.py
21 21
base_config = VigiloAppConfig('vigigraph')
22 22
base_config.package = vigigraph
23 23

  
24
base_config["external_links"] = [
25
    {
26
        'label': 'Nagios page',
27
        'image': 'images/nagios-16.png',
28
        'tooltip': 'Display Nagios page for the selected host',
29
        'uri': 'nagios/{host}/cgi-bin/status.cgi?host={host}&style=detail&supNav=1',
30
        'sameWindow': True,
31
    },
32
    {
33
        'label': 'Metrology page',
34
        'image': 'images/preferences-system-windows.png',
35
        'tooltip': 'Display a page with all the graphs for the selected host',
36
        'uri': 'rpc/fullHostPage?host={host}',
37
        'sameWindow': True,
38
    },
39
]
40

  
24 41
# Extensions (Entreprise ou spécifique projet)
25 42
base_config["extensions"] = ()
vigigraph/controllers/rpc.py
763 763
            'idhost': ids and ids.idhost or None,
764 764
            'idgraph': ids and ids.idgraph or None,
765 765
        }
766

  
767
    @expose('json')
768
    def external_links(self):
769
        return dict(links=config['external_links'])
770

  
vigigraph/public/js/toolbar.js
73 73
    }
74 74
});
75 75

  
76
Jx.Button.StaticCombo = new Class({
77
    Extends: Jx.Button.Combo,
78

  
79
    initialize: function (options) {
80
        this.locked = false;
81
        this.parent(options);
82
        this.setImage(options.image);
83
        this.setLabel(options.label);
84
        this.locked = true;
85
    },
86

  
87
    setLabel: function(label) {
88
        if (!this.locked)
89
            this.parent(label);
90
    },
91

  
92
    setImage: function(path) {
93
        if (!this.locked)
94
            this.parent(path);
95
    }
96
});
97

  
76 98
var Toolbar = new Class({
99
    Implements: [Events],
100

  
77 101
    initialize: function () {
78 102
        this.jxtoolbar = new Jx.Toolbar({
79 103
            parent: $('toolbar')
......
114 138
                this.graph_picker.redraw();
115 139
                this.graph_picker.setItem(null, this.graph_picker.options.label);
116 140
            }
117
            this.show_nagios.setEnabled(1);
118
            this.show_metrology.setEnabled(1);
141
            this.fireEvent('select-host');
119 142
            this.graph_picker.setEnabled(1);
120 143
        }.bind(this));
121 144

  
122
        this.show_nagios = new Jx.Button({
123
            label: _('Nagios page'),
124
            tooltip: _('Display Nagios page for the selected host'),
125
            image: app_path + 'images/nagios-16.png',
126
            toggle: false,
127
            enabled: false,
128
            onClick: function () {
129
                var uri = new URI(
130
                    app_path + 'nagios/' +
131
                    encodeURIComponent(this.host_picker.getLabel()) +
132
                    '/cgi-bin/status.cgi'
133
                );
134
                uri.setData({
135
                    host: this.host_picker.getLabel(),
136
                    style: 'detail',
137
                    supNav: 1
138
                });
139
                window.open(uri.toString());
140
            }.bind(this)
145
        this.links = new Jx.Button.StaticCombo({
146
            label: _('External links...'),
147
            image: app_path + 'images/external-link.png',
148
            enabled: false
141 149
        });
150
        var extlinks = new Request.JSON({
151
            url: app_path + "rpc/external_links",
152
            method: 'get',
153
            onSuccess: function (data) {
154
                if (!data.links) return;
155
                data.links.each(function (extlink) {
156
                    var uri;
157
                    extlink = new Hash(extlink);
158
                    if (extlink.has('uri')) {
159
                        uri = extlink.get('uri');
160
                        extlink.erase('uri');
161
                        extlink.set('enabled', false);
162
                        extlink.set('onClick', function (obj, evt) {
163
                            var dest = new URI(uri.substitute({
164
                                'host': encodeURIComponent(this.host_picker.getLabel())
165
                            }));
166
                            if (!obj.options.sameWindow)
167
                                window.open(dest.toString());
168
                            else dest.go();
169
                        }.bind(this));
170
                        this.links.add(extlink.getClean());
171
                    }
172
                }, this);
142 173

  
143
        this.show_metrology = new Jx.Button({
144
            label: _('Metrology page'),
145
            tooltip: _('Display a page with all the graphs for the selected host'),
146
            image: app_path + 'images/preferences-system-windows.png',
147
            toggle: false,
148
            enabled: false,
149
            onClick: function () {
150
                var uri = new URI(app_path + 'rpc/fullHostPage');
151
                uri.setData({
152
                    host: this.host_picker.getLabel()
153
                });
154
                window.open(uri.toString());
174
                this.links.buttonSet.buttons.each(function (btn) {
175
                    this.addEvent('select-host', function () {
176
                        btn.setEnabled(1);
177
                    });
178
                }, this);
179

  
180
                if (this.links.buttonSet.buttons.length)
181
                    this.links.setEnabled(1);
155 182
            }.bind(this)
156 183
        });
184
        extlinks.send();
157 185

  
158 186
        this.graph_label = new Jx.Toolbar.Item(this.createLabel(_('Graph:')));
159 187

  
......
193 221

  
194 222
        // Remplissage de la barre d'outils
195 223
        this.jxtoolbar.add(this.global_refresh);
196
        this.jxtoolbar.add(this.show_nagios);
197
        this.jxtoolbar.add(this.show_metrology);
224
        this.jxtoolbar.add(this.links);
198 225
        this.jxtoolbar.add(new Jx.Toolbar.Separator());
199 226
        this.jxtoolbar.add(this.host_label); // à supprimer ?
200 227
        this.jxtoolbar.add(this.host_picker);

Also available in: Unified diff