Changeset 394


Ignore:
Timestamp:
2015-03-16 00:56:05 (10 years ago)
Author:
amg0
Message:

experimental google gauge

Location:
trunk/AltUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/AltUI/J_ALTUI_uimgr.js

    r393 r394  
    2828var cameraGlyph = glyphTemplate.format( "facetime-video", "Camera" ); 
    2929var onoffGlyph = glyphTemplate.format( "off", "On Off" ); 
     30var scaleGlyph = glyphTemplate.format( "scale", "Gauge" ); 
    3031var smallbuttonTemplate = "<button id='{0}' type='button' class='{1} btn btn-default btn-sm' aria-label='tbd' title='{3}'>{2}</button>"; 
    3132var buttonTemplate      = "<button id='{0}' type='button' class='{1} btn btn-{3}' aria-label='tbd'>{2}</button>"; 
     
    15381539            $(".altui-mainpanel div.altui-page-contents").html( Html ); 
    15391540            $("#"+activepage).addClass("active"); 
     1541            _updateDynamicDisplayTools( false ); 
    15401542        } 
    15411543     
     
    20982100            _replaceElementKeepAttributes( $(".altui-custompage-canvas .altui-widget#"+real_widget.id) , _getWidgetHtml(real_widget,true) ); 
    20992101        }); 
     2102    }; 
     2103 
     2104    function _onDisplayGauge(widgetid,bEdit) 
     2105    { 
     2106        var data = google.visualization.arrayToDataTable([ 
     2107          ['Label', 'Value'], 
     2108          ['Memory', 80], 
     2109        ]); 
     2110 
     2111        var options = { 
     2112          width: 400, height: 120, 
     2113          redFrom: 90, redTo: 100, 
     2114          yellowFrom:75, yellowTo: 90, 
     2115          minorTicks: 5 
     2116        }; 
     2117 
     2118        var chart = new google.visualization.Gauge(document.getElementById(widgetid)); 
     2119        chart.draw(data, options); 
     2120 
     2121        setInterval(function() { 
     2122          data.setValue(0, 1, 40 + Math.round(60 * Math.random())); 
     2123          chart.draw(data, options); 
     2124        }, 1000); 
    21002125    }; 
    21012126         
     
    23362361            }  
    23372362        } 
    2338         // ,{   id:80,  
    2339             // cls:'altui-widget-gauge',  
    2340             // html: _toolHtml(cameraGlyph,"Gauge"), 
    2341             // resizable: true, 
    2342             // aspectRatio: true, 
    2343             // property: _onPropertyCamera,  
    2344             // widgetdisplay: function(widget,bEdit)    {  
    2345                 // return (widget.properties.deviceid>0) ? _cameraDraw(widget.properties.deviceid,1) : "<img src='{0}'></img>".format(cameraURI);   //"<div class='altui-camera-div'>xxx</div>"; 
    2346             // }, 
    2347             // properties: {    //( deviceID, service, action, params, cbfunc ) 
    2348                 // deviceid:0 
    2349             // }  
    2350         // }     
     2363        ,{  id:80,  
     2364            cls:'altui-widget-gauge',  
     2365            html: _toolHtml(scaleGlyph,"Gauge"), 
     2366            property: _onPropertyVariable,  
     2367            widgetdisplay: function(widget,bEdit)   {  
     2368                return "<div class='altui-gauge-div' id='{0}'></div>".format(widget.id); 
     2369            }, 
     2370            onWidgetDisplay: _onDisplayGauge, 
     2371            properties: {   //( deviceID, service, action, params, cbfunc ) 
     2372                deviceid:0, 
     2373                service:'', 
     2374                variable:'' 
     2375            }  
     2376        }    
    23512377        ];       
    23522378     
     
    24282454    }; 
    24292455     
     2456    function _updateDynamicDisplayTools( bEdit ) 
     2457    { 
     2458        $.each(tools, function(idx,tool) { 
     2459            if ($.isFunction( tool.onWidgetDisplay) ) 
     2460            { 
     2461                $(".altui-custompage-canvas ."+tool.cls).each( function(idx,elem) { 
     2462                    var widgetid = $(elem).prop('id'); 
     2463                    (tool.onWidgetDisplay)(widgetid, bEdit);        // edit mode                             
     2464                }) 
     2465            } 
     2466        });  
     2467    }; 
     2468     
    24302469    // explicitly return public methods when this object is instantiated 
    24312470  return { 
     
    24352474    initEngine      : _initEngine,  
    24362475    initCustomPages : _initCustomPages, 
     2476    loadScript : _loadScript,   //(scriptLocationAndName)  
    24372477     
    24382478    // UI helpers 
     
    31413181         
    31423182        $(".altui-mainpanel").html( pageTabs + Html ); 
     3183        _updateDynamicDisplayTools( false ); 
     3184 
    31433185        $('#altui-page-tabs a:first').tab('show'); 
    31443186    }, 
     
    32293271            var pageEditorHtml = _createPageEditorHtml(); 
    32303272            $(".altui-mainpanel").html( pageEditorHtml ); 
    3231  
     3273            _updateDynamicDisplayTools( true ); //edit mode 
    32323274            // make all reloaded children draggable 
    32333275            $(".altui-mainpanel .altui-widget")                          
    32343276                .draggable(_widgetOnCanvasDraggableOptions) 
    32353277 
    3236             // add resizable 
     3278            // add resizable & gauges 
    32373279            $.each(tools, function(idx,tool){ 
    32383280                if (tool.resizable==true) { 
     
    33143356                            }); 
    33153357                        } 
     3358                        if ($.isFunction( tool.onWidgetDisplay) ) 
     3359                        { 
     3360                            (tool.onWidgetDisplay)(widgetid, true);     // edit mode                             
     3361                        } 
    33163362                    } 
    33173363                } 
     
    35913637})( window );100 
    35923638 
    3593 // $("#menu_room,#menu_device,#menu_scene,#menu_plugins,#menu_custom,#menu_plugins").toggle(); 
     3639// UIManager.loadScript('https://www.google.com/jsapi?autoload={"modules":[{"name":"visualization","version":"1","packages":["corechart","table","gauge"]}]}'); 
    35943640$(document).ready(function() { 
    35953641    $(window).on('resize', function () { 
  • TabularUnified trunk/AltUI/L_ALTUI.lua

    r391 r394  
    531531    <script src="J_ALTUI_verabox.js"></script> 
    532532    <script src="J_ALTUI_uimgr.js"></script> 
     533    <script type="text/javascript" 
     534      src='https://www.google.com/jsapi?autoload={"modules":[{"name":"visualization","version":"1","packages":["gauge","table"]}]}'> 
     535    </script> 
     536     
    533537    @optional_scripts@ 
    534538    <script type='text/javascript'> 
     539        google.setOnLoadCallback(drawVisualization); 
     540        function drawVisualization() { 
     541            AltuiDebug.debug('google loaded'); 
     542        }; 
    535543        var g_DeviceTypes =  JSON.parse('@devicetypes@'); 
    536544        var g_CustomPages = @custompages@; 
Note: See TracChangeset for help on using the changeset viewer.