summaryrefslogtreecommitdiffstats
path: root/qooxdoo/source/class/Smokeping/ui/Graphs.js
blob: 7a9fb83771e60c9187cf5fb15ca004e65e9ab289 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* ************************************************************************
#module(Smokeping)
************************************************************************ */

/**
 * a widget showing the smokeping graph overview
 */

qx.Class.define('Smokeping.ui.Graphs', 
{
    extend: qx.ui.layout.FlowLayout,        

    /*
    *****************************************************************************
       CONSTRUCTOR
    *****************************************************************************
    */

    /**
     * @param base_url   {String}   Path to the location of the image generator
     *
     */

    construct: function (url) {

        with(this){
			base(arguments,'root node');
            setOverflow('scrollY');
            setBackgroundColor('white');
            setBorder('inset');
            setWidth('100%');
            setHeight('100%');
            setVerticalSpacing(10);
            setHorizontalSpacing(10);
			setPadding(10);
        };

		var load_graphs = function(m){
			var files = m.getData()
			this.removeAll();
			for(var i=0;i<files.length;i++){
				this.debug('adding '+files[i])
   			   	var button = new qx.ui.form.Button(null,qx.io.Alias.getInstance().resolve('SP/image/ajax-loader.gif'));
				this.add(button);
				var image = button.getIconObject();
				var preloader = qx.io.image.PreloaderManager.getInstance().create(url + 'grapher.cgi?g=' + files[i]);
				preloader.setUserData('image',image); // it seems javascript does not do closures
				preloader.addEventListener('load', function(e) {
					var image = this.getUserData('image');	/// so we use this to whisk the image into the event			
					// image.setWidth(preloader.getWidth()-10);
					this.debug('load image event: '+preloader.getSource());
					image.setPreloader(this);
					qx.io.image.PreloaderManager.getInstance().remove(this);
		    		//if (image.isLoaded()) {
					//	this.debug('outer '+image.getOuterHeight());
					//	this.debug('inner '+image.getInnerHeight());
					//	this.debug('box '+image.getBoxHeight());
				    //	this.debug('prefinner '+image.getPreferredInnerHeight());
					//	this.debug('prefbox '+image.getPreferredBoxHeight());
				},preloader);
			}
		};
                    
		qx.event.message.Bus.subscribe('sp.menu.folder',load_graphs,this);
    }


});