X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fslicestat%2Fstatic%2Fjs%2Fslicestat.js;h=a815e7f650f07ffcb2e536f01372ca72cfe88504;hb=d3ce63ee980b2b782a02f14d40c35fe095806018;hp=4c63b849a6047a3fc7a2fa2bf235413605360d5e;hpb=17a01cef3f265688e6f8a1a4fec2d0abb3cf7397;p=myslice.git diff --git a/plugins/slicestat/static/js/slicestat.js b/plugins/slicestat/static/js/slicestat.js index 4c63b849..a815e7f6 100644 --- a/plugins/slicestat/static/js/slicestat.js +++ b/plugins/slicestat/static/js/slicestat.js @@ -13,7 +13,7 @@ (function($){ - var Slicestat = Plugin.extend({ + var SliceStat = Plugin.extend({ /** XXX to check * @brief Plugin constructor @@ -24,10 +24,7 @@ */ init: function(options, element) { // Call the parent constructor, see FAQ when forgotten - this._super(options, element); - - google.load("visualization", "1.0", {packages:["corechart"]}); - + this._super(options, element); /* Member variables */ @@ -93,52 +90,8 @@ { console.log(record); - var node = record.hostname; - var slice = 'root'; - - google.setOnLoadCallback(function() { - - var options = { - pointSize: 2, - lineWidth: 1, - title: 'Slice '+slice+' last 24 hours', 'width':780, 'height':400, - vAxes: { - 0: {format: '###,##%'}, - 1: {format: '#Kb',} - }, - hAxis: { title: "", format: 'HH:mm'}, - series: { - 0: { type: "line", targetAxisIndex: 0}, - 1: { type: "line", targetAxisIndex: 0}, - 2: { type: "line", targetAxisIndex: 1}, - 3: { type: "line", targetAxisIndex: 1} - } - }; - - var jsonData = $.ajax({ - type: 'POST', - url: "/db/slice", - dataType: "json", - async: false, - data: { period: 'day', resources: 'cpu,pmc_per,asb,arb', slice: slice, node: node }, - success: function(ret) { - var result = []; - var data = new google.visualization.DataTable(); - data.addColumn('datetime', 'Date'); - data.addColumn('number', 'CPU (%)'); - data.addColumn('number', 'MEM (%)'); - data.addColumn('number', 'Traffic Sent (Kb)'); - data.addColumn('number', 'Traffic Received (Kb)'); - $.each(ret, function() { - result.push([new Date(this[0]), this[1], this[2], this[3], this[4]]); - }); - data.addRows(result); - var chart = new google.visualization.LineChart(document.getElementById('graph')); - chart.draw(data, options); - } - }).responseText; - - }); + $('iframe#slicestat_resource').attr('src','http://plestats.planet-lab.eu/node.php?node='+record.hostname); + }, /* INTERNAL FUNCTIONS */ @@ -149,7 +102,7 @@ }); /* Plugin registration */ - $.plugin('Slicestat', Slicestat); + $.plugin('SliceStat', SliceStat); // TODO Here use cases for instanciating plugins in different ways like in the pastie.