slicestat plugin (working) on the resource view
authorCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Thu, 24 Oct 2013 15:06:56 +0000 (17:06 +0200)
committerCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Thu, 24 Oct 2013 15:06:56 +0000 (17:06 +0200)
plugins/slicestat/__init__.py
plugins/slicestat/static/css/slicestat.css
plugins/slicestat/static/js/slicestat.js
plugins/slicestat/templates/slicestat.html
portal/resourceview.py

index 14cfdad..7186b76 100644 (file)
@@ -12,8 +12,9 @@ class Slicestat(Plugin):
     def requirements (self):
         reqs = {
             'js_files' : [
-                'js/date.js',
-                'js/slicestat.js'
+                
+                'js/slicestat.js',
+
             ],
             'css_files': [
                 'css/slicestat.css',
index e69de29..9962c83 100644 (file)
@@ -0,0 +1,6 @@
+iframe#slicestat_resource {
+    width:100%;
+    height:400px;
+    border:0;
+    overflow: hidden;
+}
index 4c63b84..a68704e 100644 (file)
          */
         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 */
         {
             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 */
index cb9474c..c97cd9e 100644 (file)
@@ -1,4 +1,3 @@
 <div id={{ domid }}>
-<p>Slicestat</p>
-<div id="slicestat_resource"></div>
+<iframe id="slicestat_resource" src=""></iframe> 
 </div>
index 0421854..7e08fe8 100644 (file)
@@ -16,6 +16,8 @@ class ResourceView(TemplateView):
 
     def get_context_data(self, **kwargs):
         page = Page(self.request)
+        
+        page.add_js_files  ( [ "js/common.functions.js" ] )
 
         for key, value in kwargs.iteritems():
             print "%s = %s" % (key, value)       
@@ -67,6 +69,7 @@ class ResourceView(TemplateView):
         resource_stats = Slicestat(
             title = None,
             page  = page,
+            stats = 'node',
             key   = 'hrn',
             query = resource_query
         )