bring demo changes from node33 and node36 into master
authorScott Baker <smbaker@gmail.com>
Thu, 20 Mar 2014 05:10:17 +0000 (22:10 -0700)
committerScott Baker <smbaker@gmail.com>
Thu, 20 Mar 2014 05:10:17 +0000 (22:10 -0700)
planetstack/core/plus/sites.py
planetstack/core/plus/views.py
planetstack/core/static/hpc_historical.css [new file with mode: 0644]
planetstack/core/static/page_analytics.js [new file with mode: 0644]
planetstack/core/static/planetstack.css
planetstack/core/static/planetstack_graphs.js [new file with mode: 0644]
planetstack/core/static/planetstack_graphs_old.js [new file with mode: 0644]
planetstack/templates/admin/base.html
planetstack/templates/admin/dashboard/hpc_historical.html [new file with mode: 0644]
planetstack/templates/admin/dashboard/welcome.html

index 27ae352..b96169c 100644 (file)
@@ -12,15 +12,25 @@ class AdminMixin(object):
     def get_urls(self):
         """Add our dashboard view to the admin urlconf. Deleted the default index."""
         from django.conf.urls import patterns, url
-        from views import DashboardWelcomeView, DashboardAjaxView
+        from views import DashboardWelcomeView, DashboardAjaxView, SimulatorView, DashboardSummaryAjaxView, DashboardAddOrRemoveSliverView, DashboardUserSiteView, DashboardAnalyticsAjaxView
 
         urls = super(AdminMixin, self).get_urls()
         del urls[0]
         custom_url = patterns('',
-               url(r'^$', self.admin_view(DashboardWelcomeView.as_view()), 
+               url(r'^$', self.admin_view(DashboardWelcomeView.as_view()),
                     name="index"),
-               url(r'^hpcdashboard/', self.admin_view(DashboardAjaxView.as_view()), 
-                    name="hpcdashboard")
+               url(r'^hpcdashuserslices/', self.admin_view(DashboardUserSiteView.as_view()),
+                    name="hpcdashuserslices"),
+               url(r'^hpcdashboard/', self.admin_view(DashboardAjaxView.as_view()),        # DEPRECATED
+                    name="hpcdashboard"),
+               url(r'^simulator/', self.admin_view(SimulatorView.as_view()),
+                    name="simulator"),
+               url(r'^hpcsummary/', self.admin_view(DashboardSummaryAjaxView.as_view()),   # DEPRECATED
+                    name="hpcsummary"),
+               url(r'^analytics/(?P<name>\w+)/$', self.admin_view(DashboardAnalyticsAjaxView.as_view()),
+                    name="analytics"),
+               url(r'^dashboardaddorremsliver/$', self.admin_view(DashboardAddOrRemoveSliverView.as_view()),
+                    name="addorremsliver")
         )
 
         return custom_url + urls
index 653ee95..a50d946 100644 (file)
 #views.py
+import os
+import sys
 from django.views.generic import TemplateView, View
 import datetime
-
-import json 
-from core.models import Slice,SliceRole,SlicePrivilege,Site,Reservation
+from pprint import pprint
+import json
+from core.models import Slice,SliceRole,SlicePrivilege,Site,Reservation,Sliver
 from django.http import HttpResponse
+import traceback
 
+if os.path.exists("/home/smbaker/projects/vicci/cdn/bigquery"):
+    sys.path.append("/home/smbaker/projects/vicci/cdn/bigquery")
+else:
+    sys.path.append("/opt/planetstack/hpc_wizard")
+import hpc_wizard
+from planetstack_analytics import DoPlanetStackAnalytics
 
 class DashboardWelcomeView(TemplateView):
     template_name = 'admin/dashboard/welcome.html'
 
     def get(self, request, *args, **kwargs):
         context = self.get_context_data(**kwargs)
-        try:
-            site = Site.objects.filter(id=request.user.site.id)
-        except:
-            site = Site.objects.filter(name="Princeton")
-        context['site'] = site[0]
+        userDetails = getUserSliceInfo(request.user)
+        #context['site'] = userDetails['site']
 
-        context['userSliceInfo'] = getSliceInfo(request, context)
-        context['cdnData'] = getCDNOperatorData();
+        context['userSliceInfo'] = userDetails['userSliceInfo']
+        context['cdnData'] = userDetails['cdnData']
         return self.render_to_response(context=context)
 
-def getSliceInfo(request, context):
+def getUserSliceInfo(user, tableFormat = False):
+        userDetails = {}
+#        try:
+# //           site = Site.objects.filter(id=user.site.id)
+#  //      except:
+#   //         site = Site.objects.filter(name="Princeton")
+#    //    userDetails['sitename'] = site[0].name
+#     //   userDetails['siteid'] = site[0].id
+
+        userSliceData = getSliceInfo(user)
+        if (tableFormat):
+#            pprint("*******      GET USER SLICE INFO")
+            userDetails['userSliceInfo'] = userSliceTableFormatter(userSliceData)
+        else:
+            userDetails['userSliceInfo'] = userSliceData
+        userDetails['cdnData'] = getCDNOperatorData();
+#        pprint( userDetails)
+        return userDetails
+
+def userSliceTableFormatter(data):
+#    pprint(data)
+    formattedData = {
+                     'rows' : data
+                    }
+    return formattedData
+
+def getSliceInfo(user):
     sliceList = Slice.objects.all()
-    slicePrivs = SlicePrivilege.objects.filter(user=request.user)
+    slicePrivs = SlicePrivilege.objects.filter(user=user)
     userSliceInfo = []
     for entry in slicePrivs:
 
+        slicename = Slice.objects.get(id=entry.slice.id).name
+        sliceid = Slice.objects.get(id=entry.slice.id).id
         try:
-            reservationList = Reservation.objects.filter(slice=entry.slice)
-            reservations = (True,reservationList)
-
+            sliverList = Sliver.objects.filter(slice=entry.slice.id)
+            siteList = {}
+            for x in sliverList:
+               if x.node.site not in siteList:
+                  siteList[x.node.site] = 1
+            slivercount = len(sliverList)
+            sitecount = len(siteList)
         except:
-            reservations = None
+            traceback.print_exc()
+            slivercount = 0
+            sitecount = 0
 
-        userSliceInfo.append({'slice': Slice.objects.get(id=entry.slice.id),
-                           'role': SliceRole.objects.get(id=entry.role.id).role,
-                           'reservations': reservations})
-    return userSliceInfo
+        userSliceInfo.append({'slicename': slicename, 'sliceid':sliceid,
+                           'role': SliceRole.objects.get(id=entry.role.id).role, 'slivercount': slivercount, 'sitecount':sitecount})
 
+    return userSliceInfo
 
 def getCDNOperatorData(randomizeData = False):
-    cdnData = {
-        "Arizona": {
-            "lat": 32.2333,
-            "long": -110.94799999999998,
-            "health": 0,
-            "numNodes": 15,
-            "numHPCSlivers": 2,
-            "siteUrl": "http://www.cs.arizona.edu/"
-        },
-        "I2 Singapore": {
-            "lat": 1.33544,
-            "long": 103.88999999999999,
-            "health": 0,
-            "numNodes": 15,
-            "numHPCSlivers": 5,
-            "siteUrl": "http://www.internet2.edu/"
-        },
-        "ON.Lab": {
-            "lat": 37.452955,
-            "long": -122.18176599999998,
-            "health": 0,
-            "numNodes": 45,
-            "numHPCSlivers": 12,
-            "siteUrl": "http://www.onlab.us/"
-        },
-        "I2 Washington DC": {
-            "lat": 38.009,
-            "long": -77.00029999999998,
-            "health": 0,
-            "numNodes": 50,
-            "numHPCSlivers": 7,
-            "siteUrl": "http://www.internet2.edu/"
-        },
-        "I2 Seattle": {
-            "lat": 47.6531,
-            "long": -122.31299999999999,
-            "health": 0,
-            "numNodes": 100,
-            "numHPCSlivers": 10,
-            "siteUrl": "http://www.internet2.edu/"
-        },
-        "I2 Salt Lake City": {
-            "lat": 40.7659,
-            "long": -111.844,
-            "health": 0,
-            "numNodes": 35,
-            "numHPCSlivers": 10,
-            "siteUrl": "http://www.internet2.edu/"
-        },
-        "I2 New York": {
-            "lat": 40.72,
-            "long": -73.99000000000001,
-            "health": 0,
-            "numNodes": 25,
-            "numHPCSlivers": 4,
-            "siteUrl": "http://www.internet2.edu/"
-        },
-        "I2 Los Angeles": {
-            "lat": 33.2505,
-            "long": -117.50299999999999,
-            "health": 0,
-            "numNodes": 20,
-            "numHPCSlivers": 10,
-            "siteUrl": "http://www.internet2.edu/"
-        },
-        "I2 Kansas City": {
-            "lat": 39.0012,
-            "long": -94.00630000000001,
-            "health": 0,
-            "numNodes": 17,
-            "numHPCSlivers": 8,
-            "siteUrl": "http://www.internet2.edu/"
-        },
-        "I2 Houston": {
-            "lat": 29.0077,
-            "long": -95.00369999999998,
-            "health": 0,
-            "numNodes": 15,
-            "numHPCSlivers": 10,
-            "siteUrl": "http://www.internet2.edu/"
-        },
-        "I2 Chicago": {
-            "lat": 41.0085,
-            "long": -87.00650000000002,
-            "health": 0,
-            "numNodes": 15,
-            "numHPCSlivers": 10,
-            "siteUrl": "http://www.internet2.edu/"
-        },
-        "I2 Atlanta": {
-            "lat": 33.0075,
-            "long": -84.00380000000001,
-            "health": 0,
-            "numNodes": 15,
-            "numHPCSlivers": 10,
-            "siteUrl": "http://www.internet2.edu/"
-        },
-        "MaxPlanck": {
-            "lat": 49.14,
-            "long": 6.588999999999942,
-            "health": 0,
-            "numNodes": 15,
-            "numHPCSlivers": 10,
-            "siteUrl": "http://www.mpi-sws.mpg.de/"
-        },
-        "GeorgiaTech": {
-            "lat": 33.7772,
-            "long": -84.39760000000001,
-            "health": 0,
-            "numNodes": 15,
-            "numHPCSlivers": 10,
-            "siteUrl": "http://www.gatech.edu/"
-        },
-        "Princeton": {
-            "lat": 40.3502,
-            "long": -74.6524,
-            "health": 0,
-            "numNodes": 15,
-            "numHPCSlivers": 10,
-            "siteUrl": "http://princeton.edu/"
-        },
-        "Washington": {
-            "lat": 47.6531,
-            "long": -122.31299999999999,
-            "health": 0,
-            "numNodes": 15,
-            "numHPCSlivers": 10,
-            "siteUrl": "https://www.washington.edu/"
-        },
-        "Stanford": {
-            "lat": 37.4294,
-            "long": -122.17200000000003,
-            "health": 0,
-            "numNodes": 15,
-            "numHPCSlivers": 10,
-            "siteUrl": "http://www.stanford.edu/"
-        },
-    }
-
-    if randomizeData:
-        cdnData["Siobhan"] = { "lat": 43.34203, "long": -70.56351, "health": 10, "numNodes": 5, "numHPCSlivers": 3, "siteUrl": "https:devonrexes"}
-        del cdnData["Princeton"]
-        cdnData["I2 Seattle"]['siteUrl'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
-        cdnData["I2 Salt Lake City"]["numHPCSlivers"] = 34
-
-
-    return cdnData
+    return hpc_wizard.get_hpc_wizard().get_sites_for_view()
+
+def getPageSummary(request):
+    slice = request.GET.get('slice', None)
+    site = request.GET.get('site', None)
+    node = request.GET.get('node', None)
+
+
+class SimulatorView(View):
+    def get(self, request, **kwargs):
+        sim = json.loads(file("/tmp/simulator.json","r").read())
+        text = "<html><head></head><body>"
+        text += "Iteration: %d<br>" % sim["iteration"]
+        text += "Elapsed since report %d<br><br>" % sim["elapsed_since_report"]
+        text += "<table border=1>"
+        text += "<tr><th>site</th><th>trend</th><th>weight</th><th>bytes_sent</th><th>hot</th></tr>"
+        for site in sim["site_load"].values():
+            text += "<tr>"
+            text += "<td>%s</td><td>%0.2f</td><td>%0.2f</td><td>%d</td><td>%0.2f</td>" % \
+                        (site["name"], site["trend"], site["weight"], site["bytes_sent"], site["load_frac"])
+            text += "</tr>"
+        text += "</table>"
+        text += "</body></html>"
+        return HttpResponse(text)
+
+class DashboardUserSiteView(View):
+    def get(self, request, **kwargs):
+        return HttpResponse(json.dumps(getUserSliceInfo(request.user, True)), mimetype='application/javascript')
+
+class DashboardSummaryAjaxView(View):
+    def get(self, request, **kwargs):
+        return HttpResponse(json.dumps(hpc_wizard.get_hpc_wizard().get_summary_for_view()), mimetype='application/javascript')
+
+class DashboardAddOrRemoveSliverView(View):
+    def post(self, request, *args, **kwargs):
+        siteName = request.POST.get("site", "0")
+        actionToDo = request.POST.get("actionToDo", "0")
+
+        if (actionToDo == "add"):
+            hpc_wizard.get_hpc_wizard().increase_slivers(siteName, 1)
+        elif (actionToDo == "rem"):
+            hpc_wizard.get_hpc_wizard().decrease_slivers(siteName, 1)
+
+        print '*' * 50
+        print 'Ask for site: ' + siteName + ' to ' + actionToDo + ' another HPC Sliver'
+        return HttpResponse('This is POST request ')
 
 class DashboardAjaxView(View):
     def get(self, request, **kwargs):
         return HttpResponse(json.dumps(getCDNOperatorData(True)), mimetype='application/javascript')
-        
+
+class DashboardAnalyticsAjaxView(View):
+    def get(self, request, name="hello_world", **kwargs):
+        if (name == "hpcSummary"):
+            return HttpResponse(json.dumps(hpc_wizard.get_hpc_wizard().get_summary_for_view()), mimetype='application/javascript')
+        elif (name == "hpcUserSite"):
+            return HttpResponse(json.dumps(getUserSliceInfo(request.user, True)), mimetype='application/javascript')
+        elif (name == "hpcMap"):
+            return HttpResponse(json.dumps(getCDNOperatorData(True)), mimetype='application/javascript')
+        elif (name == "bigquery"):
+            (mimetype, data) = DoPlanetStackAnalytics(request)
+            return HttpResponse(data, mimetype=mimetype)
+        else:
+            return HttpResponse(json.dumps("Unknown"), mimetype='application/javascript')
+
diff --git a/planetstack/core/static/hpc_historical.css b/planetstack/core/static/hpc_historical.css
new file mode 100644 (file)
index 0000000..412e986
--- /dev/null
@@ -0,0 +1,812 @@
+.row {
+  margin-right: -15px;
+  margin-left: -15px;
+}
+
+.row:before,
+.row:after {
+  display: table;
+  content: " ";
+}
+
+.row:after {
+  clear: both;
+}
+
+.row:before,
+.row:after {
+  display: table;
+  content: " ";
+}
+
+.row:after {
+  clear: both;
+}
+
+.col-xs-1,
+.col-sm-1,
+.col-md-1,
+.col-lg-1,
+.col-xs-2,
+.col-sm-2,
+.col-md-2,
+.col-lg-2,
+.col-xs-3,
+.col-sm-3,
+.col-md-3,
+.col-lg-3,
+.col-xs-4,
+.col-sm-4,
+.col-md-4,
+.col-lg-4,
+.col-xs-5,
+.col-sm-5,
+.col-md-5,
+.col-lg-5,
+.col-xs-6,
+.col-sm-6,
+.col-md-6,
+.col-lg-6,
+.col-xs-7,
+.col-sm-7,
+.col-md-7,
+.col-lg-7,
+.col-xs-8,
+.col-sm-8,
+.col-md-8,
+.col-lg-8,
+.col-xs-9,
+.col-sm-9,
+.col-md-9,
+.col-lg-9,
+.col-xs-10,
+.col-sm-10,
+.col-md-10,
+.col-lg-10,
+.col-xs-11,
+.col-sm-11,
+.col-md-11,
+.col-lg-11,
+.col-xs-12,
+.col-sm-12,
+.col-md-12,
+.col-lg-12 {
+  position: relative;
+  min-height: 1px;
+  padding-right: 15px;
+  padding-left: 15px;
+}
+
+.col-xs-1,
+.col-xs-2,
+.col-xs-3,
+.col-xs-4,
+.col-xs-5,
+.col-xs-6,
+.col-xs-7,
+.col-xs-8,
+.col-xs-9,
+.col-xs-10,
+.col-xs-11 {
+  float: left;
+}
+
+.col-xs-12 {
+  width: 100%;
+}
+
+.col-xs-11 {
+  width: 91.66666666666666%;
+}
+
+.col-xs-10 {
+  width: 83.33333333333334%;
+}
+
+.col-xs-9 {
+  width: 75%;
+}
+
+.col-xs-8 {
+  width: 66.66666666666666%;
+}
+
+.col-xs-7 {
+  width: 58.333333333333336%;
+}
+
+.col-xs-6 {
+  width: 50%;
+}
+
+.col-xs-5 {
+  width: 41.66666666666667%;
+}
+
+.col-xs-4 {
+  width: 33.33333333333333%;
+}
+
+.col-xs-3 {
+  width: 25%;
+}
+
+.col-xs-2 {
+  width: 16.666666666666664%;
+}
+
+.col-xs-1 {
+  width: 8.333333333333332%;
+}
+
+.col-xs-pull-12 {
+  right: 100%;
+}
+
+.col-xs-pull-11 {
+  right: 91.66666666666666%;
+}
+
+.col-xs-pull-10 {
+  right: 83.33333333333334%;
+}
+
+.col-xs-pull-9 {
+  right: 75%;
+}
+
+.col-xs-pull-8 {
+  right: 66.66666666666666%;
+}
+
+.col-xs-pull-7 {
+  right: 58.333333333333336%;
+}
+
+.col-xs-pull-6 {
+  right: 50%;
+}
+
+.col-xs-pull-5 {
+  right: 41.66666666666667%;
+}
+
+.col-xs-pull-4 {
+  right: 33.33333333333333%;
+}
+
+.col-xs-pull-3 {
+  right: 25%;
+}
+
+.col-xs-pull-2 {
+  right: 16.666666666666664%;
+}
+
+.col-xs-pull-1 {
+  right: 8.333333333333332%;
+}
+
+.col-xs-pull-0 {
+  right: 0;
+}
+
+.col-xs-push-12 {
+  left: 100%;
+}
+
+.col-xs-push-11 {
+  left: 91.66666666666666%;
+}
+
+.col-xs-push-10 {
+  left: 83.33333333333334%;
+}
+
+.col-xs-push-9 {
+  left: 75%;
+}
+
+.col-xs-push-8 {
+  left: 66.66666666666666%;
+}
+
+.col-xs-push-7 {
+  left: 58.333333333333336%;
+}
+
+.col-xs-push-6 {
+  left: 50%;
+}
+
+.col-xs-push-5 {
+  left: 41.66666666666667%;
+}
+
+.col-xs-push-4 {
+  left: 33.33333333333333%;
+}
+
+.col-xs-push-3 {
+  left: 25%;
+}
+
+.col-xs-push-2 {
+  left: 16.666666666666664%;
+}
+
+.col-xs-push-1 {
+  left: 8.333333333333332%;
+}
+
+.col-xs-push-0 {
+  left: 0;
+}
+
+.col-xs-offset-12 {
+  margin-left: 100%;
+}
+
+.col-xs-offset-11 {
+  margin-left: 91.66666666666666%;
+}
+
+.col-xs-offset-10 {
+  margin-left: 83.33333333333334%;
+}
+
+.col-xs-offset-9 {
+  margin-left: 75%;
+}
+
+.col-xs-offset-8 {
+  margin-left: 66.66666666666666%;
+}
+
+.col-xs-offset-7 {
+  margin-left: 58.333333333333336%;
+}
+
+.col-xs-offset-6 {
+  margin-left: 50%;
+}
+
+.col-xs-offset-5 {
+  margin-left: 41.66666666666667%;
+}
+
+.col-xs-offset-4 {
+  margin-left: 33.33333333333333%;
+}
+
+.col-xs-offset-3 {
+  margin-left: 25%;
+}
+
+.col-xs-offset-2 {
+  margin-left: 16.666666666666664%;
+}
+
+.col-xs-offset-1 {
+  margin-left: 8.333333333333332%;
+}
+
+.col-xs-offset-0 {
+  margin-left: 0;
+}
+
+@media (min-width: 768px) {
+  .container {
+    width: 750px;
+  }
+  .col-sm-1,
+  .col-sm-2,
+  .col-sm-3,
+  .col-sm-4,
+  .col-sm-5,
+  .col-sm-6,
+  .col-sm-7,
+  .col-sm-8,
+  .col-sm-9,
+  .col-sm-10,
+  .col-sm-11 {
+    float: left;
+  }
+  .col-sm-12 {
+    width: 100%;
+  }
+  .col-sm-11 {
+    width: 91.66666666666666%;
+  }
+  .col-sm-10 {
+    width: 83.33333333333334%;
+  }
+  .col-sm-9 {
+    width: 75%;
+  }
+  .col-sm-8 {
+    width: 66.66666666666666%;
+  }
+  .col-sm-7 {
+    width: 58.333333333333336%;
+  }
+  .col-sm-6 {
+    width: 50%;
+  }
+  .col-sm-5 {
+    width: 41.66666666666667%;
+  }
+  .col-sm-4 {
+    width: 33.33333333333333%;
+  }
+  .col-sm-3 {
+    width: 25%;
+  }
+  .col-sm-2 {
+    width: 16.666666666666664%;
+  }
+  .col-sm-1 {
+    width: 8.333333333333332%;
+  }
+  .col-sm-pull-12 {
+    right: 100%;
+  }
+  .col-sm-pull-11 {
+    right: 91.66666666666666%;
+  }
+  .col-sm-pull-10 {
+    right: 83.33333333333334%;
+  }
+  .col-sm-pull-9 {
+    right: 75%;
+  }
+  .col-sm-pull-8 {
+    right: 66.66666666666666%;
+  }
+  .col-sm-pull-7 {
+    right: 58.333333333333336%;
+  }
+  .col-sm-pull-6 {
+    right: 50%;
+  }
+  .col-sm-pull-5 {
+    right: 41.66666666666667%;
+  }
+  .col-sm-pull-4 {
+    right: 33.33333333333333%;
+  }
+  .col-sm-pull-3 {
+    right: 25%;
+  }
+  .col-sm-pull-2 {
+    right: 16.666666666666664%;
+  }
+  .col-sm-pull-1 {
+    right: 8.333333333333332%;
+  }
+  .col-sm-pull-0 {
+    right: 0;
+  }
+  .col-sm-push-12 {
+    left: 100%;
+  }
+  .col-sm-push-11 {
+    left: 91.66666666666666%;
+  }
+  .col-sm-push-10 {
+    left: 83.33333333333334%;
+  }
+  .col-sm-push-9 {
+    left: 75%;
+  }
+  .col-sm-push-8 {
+    left: 66.66666666666666%;
+  }
+  .col-sm-push-7 {
+    left: 58.333333333333336%;
+  }
+  .col-sm-push-6 {
+    left: 50%;
+  }
+  .col-sm-push-5 {
+    left: 41.66666666666667%;
+  }
+  .col-sm-push-4 {
+    left: 33.33333333333333%;
+  }
+  .col-sm-push-3 {
+    left: 25%;
+  }
+  .col-sm-push-2 {
+    left: 16.666666666666664%;
+  }
+  .col-sm-push-1 {
+    left: 8.333333333333332%;
+  }
+  .col-sm-push-0 {
+    left: 0;
+  }
+  .col-sm-offset-12 {
+    margin-left: 100%;
+  }
+  .col-sm-offset-11 {
+    margin-left: 91.66666666666666%;
+  }
+  .col-sm-offset-10 {
+    margin-left: 83.33333333333334%;
+  }
+  .col-sm-offset-9 {
+    margin-left: 75%;
+  }
+  .col-sm-offset-8 {
+    margin-left: 66.66666666666666%;
+  }
+  .col-sm-offset-7 {
+    margin-left: 58.333333333333336%;
+  }
+  .col-sm-offset-6 {
+    margin-left: 50%;
+  }
+  .col-sm-offset-5 {
+    margin-left: 41.66666666666667%;
+  }
+  .col-sm-offset-4 {
+    margin-left: 33.33333333333333%;
+  }
+  .col-sm-offset-3 {
+    margin-left: 25%;
+  }
+  .col-sm-offset-2 {
+    margin-left: 16.666666666666664%;
+  }
+  .col-sm-offset-1 {
+    margin-left: 8.333333333333332%;
+  }
+  .col-sm-offset-0 {
+    margin-left: 0;
+  }
+}
+
+@media (min-width: 992px) {
+  .container {
+    width: 970px;
+  }
+  .col-md-1,
+  .col-md-2,
+  .col-md-3,
+  .col-md-4,
+  .col-md-5,
+  .col-md-6,
+  .col-md-7,
+  .col-md-8,
+  .col-md-9,
+  .col-md-10,
+  .col-md-11 {
+    float: left;
+  }
+  .col-md-12 {
+    width: 100%;
+  }
+  .col-md-11 {
+    width: 91.66666666666666%;
+  }
+  .col-md-10 {
+    width: 83.33333333333334%;
+  }
+  .col-md-9 {
+    width: 75%;
+  }
+  .col-md-8 {
+    width: 66.66666666666666%;
+  }
+  .col-md-7 {
+    width: 58.333333333333336%;
+  }
+  .col-md-6 {
+    width: 50%;
+  }
+  .col-md-5 {
+    width: 41.66666666666667%;
+  }
+  .col-md-4 {
+    width: 33.33333333333333%;
+  }
+  .col-md-3 {
+    width: 25%;
+  }
+  .col-md-2 {
+    width: 16.666666666666664%;
+  }
+  .col-md-1 {
+    width: 8.333333333333332%;
+  }
+  .col-md-pull-12 {
+    right: 100%;
+  }
+  .col-md-pull-11 {
+    right: 91.66666666666666%;
+  }
+  .col-md-pull-10 {
+    right: 83.33333333333334%;
+  }
+  .col-md-pull-9 {
+    right: 75%;
+  }
+  .col-md-pull-8 {
+    right: 66.66666666666666%;
+  }
+  .col-md-pull-7 {
+    right: 58.333333333333336%;
+  }
+  .col-md-pull-6 {
+    right: 50%;
+  }
+  .col-md-pull-5 {
+    right: 41.66666666666667%;
+  }
+  .col-md-pull-4 {
+    right: 33.33333333333333%;
+  }
+  .col-md-pull-3 {
+    right: 25%;
+  }
+  .col-md-pull-2 {
+    right: 16.666666666666664%;
+  }
+  .col-md-pull-1 {
+    right: 8.333333333333332%;
+  }
+  .col-md-pull-0 {
+    right: 0;
+  }
+  .col-md-push-12 {
+    left: 100%;
+  }
+  .col-md-push-11 {
+    left: 91.66666666666666%;
+  }
+  .col-md-push-10 {
+    left: 83.33333333333334%;
+  }
+  .col-md-push-9 {
+    left: 75%;
+  }
+  .col-md-push-8 {
+    left: 66.66666666666666%;
+  }
+  .col-md-push-7 {
+    left: 58.333333333333336%;
+  }
+  .col-md-push-6 {
+    left: 50%;
+  }
+  .col-md-push-5 {
+    left: 41.66666666666667%;
+  }
+  .col-md-push-4 {
+    left: 33.33333333333333%;
+  }
+  .col-md-push-3 {
+    left: 25%;
+  }
+  .col-md-push-2 {
+    left: 16.666666666666664%;
+  }
+  .col-md-push-1 {
+    left: 8.333333333333332%;
+  }
+  .col-md-push-0 {
+    left: 0;
+  }
+  .col-md-offset-12 {
+    margin-left: 100%;
+  }
+  .col-md-offset-11 {
+    margin-left: 91.66666666666666%;
+  }
+  .col-md-offset-10 {
+    margin-left: 83.33333333333334%;
+  }
+  .col-md-offset-9 {
+    margin-left: 75%;
+  }
+  .col-md-offset-8 {
+    margin-left: 66.66666666666666%;
+  }
+  .col-md-offset-7 {
+    margin-left: 58.333333333333336%;
+  }
+  .col-md-offset-6 {
+    margin-left: 50%;
+  }
+  .col-md-offset-5 {
+    margin-left: 41.66666666666667%;
+  }
+  .col-md-offset-4 {
+    margin-left: 33.33333333333333%;
+  }
+  .col-md-offset-3 {
+    margin-left: 25%;
+  }
+  .col-md-offset-2 {
+    margin-left: 16.666666666666664%;
+  }
+  .col-md-offset-1 {
+    margin-left: 8.333333333333332%;
+  }
+  .col-md-offset-0 {
+    margin-left: 0;
+  }
+}
+
+@media (min-width: 1200px) {
+  .container {
+    width: 1170px;
+  }
+  .col-lg-1,
+  .col-lg-2,
+  .col-lg-3,
+  .col-lg-4,
+  .col-lg-5,
+  .col-lg-6,
+  .col-lg-7,
+  .col-lg-8,
+  .col-lg-9,
+  .col-lg-10,
+  .col-lg-11 {
+    float: left;
+  }
+  .col-lg-12 {
+    width: 100%;
+  }
+  .col-lg-11 {
+    width: 91.66666666666666%;
+  }
+  .col-lg-10 {
+    width: 83.33333333333334%;
+  }
+  .col-lg-9 {
+    width: 75%;
+  }
+  .col-lg-8 {
+    width: 66.66666666666666%;
+  }
+  .col-lg-7 {
+    width: 58.333333333333336%;
+  }
+  .col-lg-6 {
+    width: 50%;
+  }
+  .col-lg-5 {
+    width: 41.66666666666667%;
+  }
+  .col-lg-4 {
+    width: 33.33333333333333%;
+  }
+  .col-lg-3 {
+    width: 25%;
+  }
+  .col-lg-2 {
+    width: 16.666666666666664%;
+  }
+  .col-lg-1 {
+    width: 8.333333333333332%;
+  }
+  .col-lg-pull-12 {
+    right: 100%;
+  }
+  .col-lg-pull-11 {
+    right: 91.66666666666666%;
+  }
+  .col-lg-pull-10 {
+    right: 83.33333333333334%;
+  }
+  .col-lg-pull-9 {
+    right: 75%;
+  }
+  .col-lg-pull-8 {
+    right: 66.66666666666666%;
+  }
+  .col-lg-pull-7 {
+    right: 58.333333333333336%;
+  }
+  .col-lg-pull-6 {
+    right: 50%;
+  }
+  .col-lg-pull-5 {
+    right: 41.66666666666667%;
+  }
+  .col-lg-pull-4 {
+    right: 33.33333333333333%;
+  }
+  .col-lg-pull-3 {
+    right: 25%;
+  }
+  .col-lg-pull-2 {
+    right: 16.666666666666664%;
+  }
+  .col-lg-pull-1 {
+    right: 8.333333333333332%;
+  }
+  .col-lg-pull-0 {
+    right: 0;
+  }
+  .col-lg-push-12 {
+    left: 100%;
+  }
+  .col-lg-push-11 {
+    left: 91.66666666666666%;
+  }
+  .col-lg-push-10 {
+    left: 83.33333333333334%;
+  }
+  .col-lg-push-9 {
+    left: 75%;
+  }
+  .col-lg-push-8 {
+    left: 66.66666666666666%;
+  }
+  .col-lg-push-7 {
+    left: 58.333333333333336%;
+  }
+  .col-lg-push-6 {
+    left: 50%;
+  }
+  .col-lg-push-5 {
+    left: 41.66666666666667%;
+  }
+  .col-lg-push-4 {
+    left: 33.33333333333333%;
+  }
+  .col-lg-push-3 {
+    left: 25%;
+  }
+  .col-lg-push-2 {
+    left: 16.666666666666664%;
+  }
+  .col-lg-push-1 {
+    left: 8.333333333333332%;
+  }
+  .col-lg-push-0 {
+    left: 0;
+  }
+  .col-lg-offset-12 {
+    margin-left: 100%;
+  }
+  .col-lg-offset-11 {
+    margin-left: 91.66666666666666%;
+  }
+  .col-lg-offset-10 {
+    margin-left: 83.33333333333334%;
+  }
+  .col-lg-offset-9 {
+    margin-left: 75%;
+  }
+  .col-lg-offset-8 {
+    margin-left: 66.66666666666666%;
+  }
+  .col-lg-offset-7 {
+    margin-left: 58.333333333333336%;
+  }
+  .col-lg-offset-6 {
+    margin-left: 50%;
+  }
+  .col-lg-offset-5 {
+    margin-left: 41.66666666666667%;
+  }
+  .col-lg-offset-4 {
+    margin-left: 33.33333333333333%;
+  }
+  .col-lg-offset-3 {
+    margin-left: 25%;
+  }
+  .col-lg-offset-2 {
+    margin-left: 16.666666666666664%;
+  }
+  .col-lg-offset-1 {
+    margin-left: 8.333333333333332%;
+  }
+  .col-lg-offset-0 {
+    margin-left: 0;
+  }
+}
diff --git a/planetstack/core/static/page_analytics.js b/planetstack/core/static/page_analytics.js
new file mode 100644 (file)
index 0000000..017b403
--- /dev/null
@@ -0,0 +1,83 @@
+function getObjectQuery() {
+    var selectedNodeTxt = $('.currentOriginalNode').text();
+    selectedNodeTxt = selectedNodeTxt.trim();
+    selectedNodeTxt = selectedNodeTxt.split(' ').join('');//selectedNodeTxt.replace(" ", "")
+    var parentNodeTxt = $('.selectedMainNav').text();
+    parentNodeTxt = parentNodeTxt.replace("/\n","");
+    parentNodeTxt = parentNodeTxt.replace("»","");
+    parentNodeTxt = parentNodeTxt.trim();
+    if (parentNodeTxt.length > 0 && parentNodeTxt.charAt(parentNodeTxt.length-1)=='s') {
+            parentNodeTxt = parentNodeTxt.substring(0, parentNodeTxt.length-1);
+    }
+
+    if (parentNodeTxt == "Slice") {
+        return "&slice=" + selectedNodeTxt;
+    } else if (parentNodeTxt == "Site") {
+        return "&site=" + selectedNodeTxt;
+    } else if (parentNodeTxt == "Node") {
+        return "&node=" + selectedNodeTxt;
+    } else {
+        return "";
+    }
+}
+
+
+function setPageStatInt(labelName, valueName, legend, units, value) {
+    $('.'+labelName).text(legend).show();
+    $('.'+valueName).text(Math.round(value)+units).show();
+}
+
+function setPageStatFloat(labelName, valueName, legend, units, value, dp) {
+    $('.'+labelName).text(legend).show();
+    $('.'+valueName).text(Number(value).toFixed(dp)+units).show();
+}
+
+// ----------------------------------------------------------------------------
+// node count and average cpu utilization
+
+function updatePageAnalyticsData(summaryData) {
+    window.pageAnalyticsData = summaryData;
+    lastRow = summaryData.rows.length-1;
+    setPageStatInt("nodesLabel", "nodesValue", "Node Count", "", summaryData.rows[lastRow]["count_hostname"]);
+    setPageStatInt("cpuLabel", "cpuValue", "Avg Load", "%", summaryData.rows[lastRow]["avg_cpu"]);
+}
+
+function updatePageAnalytics() {
+    $.ajax({
+    url : '/analytics/bigquery/?avg=%cpu&count=%hostname' + getObjectQuery(),
+    dataType : 'json',
+    type : 'GET',
+    success: function(newData)
+    {
+        updatePageAnalyticsData(newData);
+    }
+});
+    setTimeout(updatePageAnalytics, 30000);
+}
+
+setTimeout(updatePageAnalytics, 5000);
+
+// ----------------------------------------------------------------------------
+// bandwidth
+
+function updatePageBandwidthData(summaryData) {
+    window.pageBandData = summaryData;
+    lastRow = summaryData.rows.length-1;
+    setPageStatFloat("bandwidthLabel", "bandwidthValue", "Bandwidth", "Gbps", summaryData.rows[lastRow]["sum_computed_bytes_sent_div_elapsed"]*8.0/1024/1024/1024,2);
+}
+
+function updatePageBandwidth() {
+    $.ajax({
+    url : '/analytics/bigquery/?computed=%bytes_sent/%elapsed' + getObjectQuery(),
+    dataType : 'json',
+    type : 'GET',
+    success: function(newData)
+    {
+        updatePageBandwidthData(newData);
+    }
+});
+    setTimeout(updatePageBandwidth, 30000);
+}
+
+setTimeout(updatePageBandwidth, 5000);
+
index d59adb7..76bc23b 100644 (file)
@@ -1,3 +1,64 @@
+.alignCenter {
+    text-align: center !important;
+    align: center !important;
+}
+table.dataTable tr.odd {
+background-color: white !important;
+}
+table.dataTable tr.odd td.sorting_1 {
+background-color: white !important;
+}
+table.dataTable tr.even td.sorting_1 {
+background-color: white !important;
+}
+table.dataTable thead th div.DataTables_sort_wrapper {
+    font-weight: bold;
+}
+.dashboard-hpc-sliver .ui-widget-header, .dashboard-hpc-sliver .ui-dialog-title, .dashboard-hpc-sliver .ui-dialog-titlebar{
+}
+.ui-widget-overlay {
+    background: black !important;
+}
+.ui-corner-all {
+border-bottom-left-radius: 0px !important;
+border-bottom-right-radius: 0px !important;
+}
+
+#suit-center {
+  min-width: 977px !important;
+}
+#minDashboard {
+  min-width:625px;
+  display:inline;
+  float: right;
+}
+.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default{
+background: none !important;
+border-top: 0px !important;
+border-left: 0px !important;
+border-right: 0px !important;
+}
+.ui-widget-header {
+background: none !important;
+border-top: 0px !important;
+border-left: 0px !important;
+border-right: 0px !important;
+}
+#suit_form_tabs {
+border-bottom: 1px solid #B5D1EA;
+border-bottom-width: 1px;
+border-bottom-style: solid;
+border-bottom-color: rgb(181, 209, 234);
+color:#105E9E;
+}
+#tabs {
+font-size: 12px;
+border: 0px;
+}
+.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited {
+color: #105E9E ;
+}
+
 .required:after {color: red ! important; font-size: 18px }
 #.btn-success {color:black}
 #suit-center {
@@ -25,6 +86,7 @@ margin-bottom: 5px;
 /*For increasing the header height*/
 .header {
 height: 90px;
+min-width: 1321px;
 }
 
 /*For changing the background color of the left side navigation list items*/
@@ -488,12 +550,15 @@ opacity:1;
     background-position: 0;*/
 }
 
-.icon-home ,.icon-deployment ,.icon-site ,.icon-slice ,.icon-user, .icon-reservation{
+.icon-home ,.icon-deployment ,.icon-site ,.icon-slice ,.icon-user, .icon-reservation, .icon-app{
 background-position: left center;
 width:22px;
 height:22px;   
 }
 
+.icon-app {
+background-image: url("opencloudApp.png");
+}
 .icon-home {
 background-image: url("Home.png");
 }
diff --git a/planetstack/core/static/planetstack_graphs.js b/planetstack/core/static/planetstack_graphs.js
new file mode 100644 (file)
index 0000000..6e62c4b
--- /dev/null
@@ -0,0 +1,139 @@
+google.load('visualization', '1', {'packages' : ['controls','table','corechart','geochart']});
+
+function renderChartJson(jsondata, yField, xField, legend) {
+    $('#graph').empty();
+    $('#chartsModal').modal('show');
+    $('.modal-body').scrollTop(0);
+
+    var data = new google.visualization.DataTable();
+    data.addColumn("number", "Date");
+    data.addColumn("number", "NodeCount");
+
+    var arr = [];
+    jsondata.rows.forEach(function(d) {
+        arr.push([ +d[yField], +d[xField] ]);
+    });
+
+    console.log(arr);
+
+    data.addRows(arr);
+
+    var lineChart = new google.visualization.ChartWrapper({
+          'chartType': 'LineChart',
+          'containerId': 'graph',
+          'options': {
+            'width': 520,
+            'height': 300,
+            'title': 'Network-wide usage',
+                       'pages': true,
+                       'numRows': 9
+          },
+          'view': {'columns': [0, 1]}
+        });
+        lineChart.setDataTable(data);
+        lineChart.draw();
+}
+
+function renderChart(origQuery, yColumn, xColumn) {
+    $('#graph').empty();
+    $('#chartsModal').modal('show');
+    $('.modal-body').scrollTop(0)
+
+    var queryString = encodeURIComponent(origQuery);
+    var serverPart = "http://cloud-scrutiny.appspot.com/command?action=send_query&force=ColumnChart&q=";
+    var dataSourceUrl = serverPart + queryString;
+
+    //var dataSourceUrl = "http://node36.princeton.vicci.org:8000/analytics/bigquery/?avg=%25cpu&count=%25hostname&format=raw";
+
+    var query = new google.visualization.Query(dataSourceUrl)
+    query && query.abort();
+    console.log("query.send")
+    query.send(function(response) {handleResponse_psg(response, yColumn, xColumn);});
+    console.log("query.sent")
+}
+
+// NOTE: appended _psg to showLine() and handleResponse() to prevent conflict
+//       with Sapan's analytics page.
+
+function showLine_psg(dt) {
+    console.log("showline")
+    var lineChart = new google.visualization.ChartWrapper({
+          'chartType': 'LineChart',
+          'containerId': 'graph',
+          'options': {
+            'width': 520,
+            'height': 300,
+            'title': 'Network-wide usage',
+                       'pages': true,
+                       'numRows': 9
+          },
+          'view': {'columns': [0, 1]}
+        });
+        lineChart.setDataTable(dt);
+        lineChart.draw();
+}
+
+function handleResponse_psg(response, yColumn, xColumn) {
+    console.log("handleResponse")
+
+    var supportedClasses = {
+                    'Table':google.visualization.Table,
+                    'LineChart':google.visualization.LineChart,
+                    'ScatterChart':google.visualization.ScatterChart,
+                    'ColumnChart':google.visualization.ColumnChart,
+                    'GeoChart':google.visualization.GeoChart,
+                    'PieChart':google.visualization.PieChart,
+                    'Histogram':google.visualization.Histogram};
+
+    var proxy = new google.visualization.ChartWrapper({
+      'chartType': 'Table',
+      'containerId': 'graph_work',
+      'options': {
+        'width': 800,
+        'height': 300,
+                    pageSize:5,
+                    page:'enable',
+        'legend': 'none',
+        'title': 'Nodes'
+      },
+      'view': {'columns': [0,1]}
+    });
+
+    google.visualization.events.addListener(proxy, 'ready', function () {
+        // 0 - time 1 - city 2 - node 3 - site 4 - cpu 5 - bytes
+        var dt = proxy.getDataTable();
+        var groupedData1 = google.visualization.data.group(dt, [yColumn], [{
+            column: xColumn,
+            type: 'number',
+            label: dt.getColumnLabel(xColumn),
+            aggregation: google.visualization.data.sum}]);
+
+        showLine_psg(groupedData1);
+
+        console.log(xColumn);
+    });
+
+    console.log(response.getReasons());
+    console.log(response.getDataTable());
+    console.log(response.getDetailedMessage());
+    console.log(response.getMessage());
+
+    proxy.setDataTable(response.getDataTable());
+
+    proxy.draw();
+}
+
+$('.nodesLabel, .nodesValue').click(function() {
+        var jsonData = window.pageAnalyticsData;
+        renderChart(jsonData.query, 0, 2);
+        //renderChartJson(jsonData, "MinuteTime", "count_hostname", "Node Count");
+});
+
+$('.cpuLabel, .cpuValue').click(function() {
+        var jsonData = window.pageAnalyticsData;
+        renderChart(jsonData.query,0, 1);
+});
+$('.bandwidthLabel, .bandwidthValue').click(function() {
+        var jsonData = window.pageBandData;
+        renderChart(jsonData.query, 0, 1);
+});
diff --git a/planetstack/core/static/planetstack_graphs_old.js b/planetstack/core/static/planetstack_graphs_old.js
new file mode 100644 (file)
index 0000000..806afe6
--- /dev/null
@@ -0,0 +1,89 @@
+$(document).ready(function() {
+
+function renderChart(jsonData, yField, xField, legend) {
+    $('#graph').empty();
+    $('#chartsModal').modal('show');
+    $('.modal-body').scrollTop(0)
+    var margin = {top: 0, right: 100, bottom: 100, left: 175},
+    width = 520 - margin.left - margin.right,
+    height = 300 - margin.top - margin.bottom;
+
+    var parseDate = d3.time.format("%Y-%m-%m-%H-%M").parse;
+
+    var x = d3.time.scale()
+    .range([0, width]);
+
+    var y = d3.scale.linear()
+    .range([height, 0]);
+
+    var xAxis = d3.svg.axis()
+    .scale(x)
+    .ticks(d3.time.minutes, 15)
+    .orient("bottom");
+
+    var yAxis = d3.svg.axis()
+    .scale(y)
+    .ticks(4)
+    .orient("left");
+
+    var line = d3.svg.line()
+    .x(function(d) { return x(d.date); })
+    .y(function(d) { return y(d.value); });
+
+    var svg = d3.select("#graph").append("svg")
+    .attr("width", width + margin.left + margin.right)
+    .attr("height", height + margin.top + margin.bottom)
+    .append("g")
+    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
+
+    data = jsonData.rows;
+    $('#chartHeading').text(legend);
+    data.forEach(function(d) {
+            d.date = new Date(d[yField]*1000);
+            d.value = +d[xField];
+            });
+
+    x.domain(d3.extent(data, function(d) { return d.date; }));
+
+    var e = d3.extent(data, function(d) { return d.value;});
+    e = [e[0]-1,e[1]+1];
+
+    y.domain(e);
+
+    svg.append("g")
+    .attr("class", "x axis")
+    .attr("transform", "translate(0," + height + ")")
+    .attr("x", 5)
+    .call(xAxis);
+
+    svg.append("g")
+    .attr("class", "y axis")
+    .call(yAxis)
+    .append("text")
+    .attr("transform", "rotate(-90)")
+    .attr("y", 6)
+    .attr("dy", ".71em")
+    .style("text-anchor", "end")
+    .text(legend)
+    .attr("class", "legend");
+
+    svg.append("path")
+    .datum(data)
+    .attr("class", "line")
+    .attr("d", line);
+}
+
+$('.nodesLabel, .nodesValue').click(function() {
+        var jsonData = window.pageAnalyticsData;
+        renderChart(jsonData, "MinuteTime", "count_hostname", "Node Count");
+});
+$('.cpuLabel, .cpuValue').click(function() {
+        var jsonData = window.pageAnalyticsData;
+        renderChart(jsonData, "MinuteTime", "avg_cpu", "Average Cpu");
+});
+$('.bandwidthLabel, .bandwidthValue').click(function() {
+        var jsonData = window.pageBandData;
+        renderChart(jsonData, "MinuteTime", "sum_computed_bytes_sent_div_elapsed", "Bandwidth");
+});
+
+})
index 6842040..25d9743 100644 (file)
@@ -1,4 +1,4 @@
-{% load admin_static %}{% load suit_tags %}{% load url from future %}<!DOCTYPE html>
+{% load admin_static %}{% load suit_tags %}{% load url from future %}<!DOCTYPE html>
 <html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
 <head>
   <title>{% block title %}  {%if title %} {{ title }} | {% endif %} {{ 'ADMIN_NAME'|suit_conf }}{% endblock %}</title>
@@ -9,7 +9,7 @@
   {% block extrastyle %}{% endblock %}
   {% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}"/>{% endif %}
   <script type="text/javascript">window.__admin_media_prefix__ = "{% filter escapejs %}{% static "admin/" %}{% endfilter %}";</script>
-  <script src="{% static 'suit/js/jquery-1.8.3.min.js' %}"></script>
+  <script src="{% static 'suit/js/jquery-1.9.1.min.js' %}"></script>
   <script type="text/javascript">var Suit = { $: $.noConflict() }; if (!$) $ = Suit.$; </script>
   {% if 'SHOW_REQUIRED_ASTERISK'|suit_conf %}
   <style type="text/css">.required:after { content: '*'; margin: 0 0 0 5px; position: absolute; color: #ccc;}</style>
@@ -87,9 +87,7 @@
             {% if user.is_active and user.is_staff %}
               <div id="user-tools">
                 {% trans 'Welcome,' %}
-                <strong>
-                  {% filter force_escape %}
-                    {% firstof user.first_name user.username %}{% endfilter %}</strong>.
+                <a href="http://{{ request.get_host}}/admin/core/user/{{user.id}}">{{user.email}}</a>
                 <span class="user-links">
                 {% block userlinks %}
                   {% url 'django-admindocs-docroot' as docsroot %}
           <div id="suit-center" class="suit-column">
 
             {% if not is_popup %}
+            <div id=openCloudTopPage>
+            <span id="minDashboard">
+                <div class="hide">{{ app_label|capfirst|escape }}</div>
+                <div class="hide selectedMainNav">{{ opts.verbose_name_plural|capfirst }}</div>
+                <div class="hide currentOriginalNode">{{ original|truncatewords:"18" }}</div>
+
+
+               <label class="nodetextbox nodesLabel" style="display: none;" > </label>
+              <label class="nodelabel nodesValue" style="display: none;" ></label>
+                <span class="nodesCnt hide"></span>
+              <label class="nodetextbox cpuLabel" style="display: none;" ></label>
+              <label class="nodelabel cpuValue" style="display: none;" ></label>
+                <span class="cpuCnt hide"></span>
+            <label class="nodetextbox bandwidthLabel" style="display: none;" ></label>
+              <label class="nodelabel bandwidthValue" style="width:60px;display: none;"></label>
+                <span class="bandUsage hide"></span>
+            </span>
+            </div>
+
               {% block breadcrumbs %}
                 <ul class="breadcrumb"> 
                   <li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
                     </li>
                 </ul>
               {% endblock %}
-               <div class="hide">{{ app_label|capfirst|escape }}</div>
-               <div class="hide selectedMainNav">{{ opts.verbose_name_plural|capfirst }}</div>
-               <div class="hide currentOriginalNode">{{ original|truncatewords:"18" }}</div>  
-                  
-
-               <label class="nodetextbox nodesLabel" style="display: none;" > </label>
-              <label class="nodelabel nodesValue" style="display: none;" ></label>
-               <span class="nodesCnt hide"></span>
-              <label class="nodetextbox cpuLabel" style="display: none;" ></label>
-              <label class="nodelabel cpuValue" style="display: none;" ></label>
-               <span class="cpuCnt hide"></span>
-            <label class="nodetextbox bandwidthLabel" style="display: none;" ></label>    
-              <label class="nodelabel bandwidthValue" style="width:60px;display: none;"></label>
-               <span class="bandUsage hide"></span>
             {% endif %}
 
             {% block messages %}
 
   <script src="{% static 'suit/bootstrap/js/bootstrap.min.js' %}"></script>
   <script src="{% static 'suit/js/suit.js' %}"></script>
-  <script src="{% static 'main.js' %}"></script>
+  <script src="{% static 'page_analytics.js' %}"></script>
+  <script type="text/javascript" src="//www.google.com/jsapi"></script>
+  <script src="{% static 'planetstack_graphs.js' %}"></script>
+  <!-- src="{% static 'planetstack_graphs_old.js' %}" -->
+
   {% block extrajs %}{% endblock %}
 <script src="http://d3js.org/d3.v3.js"></script>
-
        <div class="modal fade hide" id="chartsModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
          <div class="modal-dialog">
            <div class="modal-content">
                                </div>
                        </div>
                </div>
+                <div id="graph_work" style="display:none"></div>
              </div>
              <!--<div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
diff --git a/planetstack/templates/admin/dashboard/hpc_historical.html b/planetstack/templates/admin/dashboard/hpc_historical.html
new file mode 100644 (file)
index 0000000..7446ae5
--- /dev/null
@@ -0,0 +1,329 @@
+
+    <script type="text/javascript" src="//www.google.com/jsapi"></script>
+    <link rel="stylesheet" href="/static/hpc_historical.css">
+    <script type="text/javascript">
+               google.load('visualization', '1', {'packages' : ['controls','table','corechart','geochart']});
+    </script>
+       
+    <script type="text/javascript">
+var queryString = encodeURIComponent("SELECT MINUTE(time) as Time, city, s8 as Node, REGEXP_REPLACE(s8,r'node[0-9]+\.(.*)\.vicci\.org',r'\\1') as Site, AVG(i0) as Cpu, AVG(i1) as Requests FROM [vicci.demoevents] WHERE i0 is not null AND s8 contains 'vicci.org' and not city IN ('princeton','Unknown') and city is not null GROUP BY Time,city,Site,Node ORDER BY Time;");
+                       var serverPart = "http://cloud-scrutiny.appspot.com/command?action=send_query&force=ColumnChart&q="
+                       var dataSourceUrl = serverPart + queryString;
+                       var query;
+
+                       var options = {
+          width: 600,
+          height: 400,
+          showRowNumber: false,
+          pages:true,
+       numRows:9,
+          backgroundColor: "black"
+                       };
+
+google.setOnLoadCallback(function() { sendAndDraw(dataSourceUrl); });
+
+function showNodeAgg(dt) {
+               var tab = new google.visualization.ChartWrapper({
+          'chartType': 'Table',
+          'containerId': 'chart3',
+          'options': {
+            'width': 300,
+            'height': 300,
+            'title': 'Network-wide usage',
+                       'page': 'enable',
+                       'pageSize': 10
+          },
+          'view': {'columns': [0, 1, 2]}
+        });
+
+        tab.setDataTable(dt);
+        tab.draw();
+}
+
+function showSiteTimeAgg(dt) {
+               var lineChart = new google.visualization.ChartWrapper({
+          'chartType': 'LineChart',
+          'containerId': 'chart4',
+          'options': {
+            'width': 300,
+            'height': 300,
+            'title': 'Network-wide usage',
+                       'pages': true,
+                       'numRows': 9
+          },
+          'view': {'columns': [0, 1, 2]}
+        });
+        lineChart.setDataTable(dt);
+        lineChart.draw();
+               /*
+               var scatterChart = new google.visualization.ChartWrapper({
+          'chartType': 'ScatterChart',
+          'containerId': 'chart5',
+          'options': {
+            'width': 300,
+            'height': 300,
+          },
+          // from the 'data' DataTable.
+          'view': {'columns': [1, 2]}
+        });
+               scatterChart.setDataTable(dt);
+               scatterChart.draw();*/
+}
+function showSiteAgg(dt) {
+               var barChart = new google.visualization.ChartWrapper({
+          'chartType': 'ColumnChart',
+          'containerId': 'chart1',
+          'options': {
+            'width': 300,
+            'height': 300,
+            'title': 'Site-wise usage',
+                       'pages': true,
+                       'numRows': 9
+          },
+          // Instruct the piechart to use colums 0 (Name) and 3 (Donuts Eaten)
+          // from the 'data' DataTable.
+          'view': {'columns': [1, 2, 3]}
+        });
+        barChart.setDataTable(dt);
+        barChart.draw();
+               var geoChart = new google.visualization.ChartWrapper({
+          'chartType': 'GeoChart',
+          'containerId': 'chart2',
+          'options': {
+            'width': 300,
+            'height': 300,
+                       'displayMode': 'markers',
+                       'region':'021',
+            'title': 'Usage map',
+               colorAxis: {colors: ['green', 'purple', 'red']}
+          },
+          // Instruct the piechart to use colums 0 (Name) and 3 (Donuts Eaten)
+          // from the 'data' DataTable.
+          'view': {'columns': [0, 2,3]}
+        });
+               geoChart.setDataTable(dt);
+               geoChart.draw();
+       
+               var histogram = new google.visualization.ChartWrapper({
+          'chartType': 'Histogram',
+          'containerId': 'chart6',
+          'options': {
+            'width': 300,
+            'height': 300,
+          },
+                 'title': 'Sites by load',
+          // Instruct the piechart to use colums 0 (Name) and 3 (Donuts Eaten)
+          // from the 'data' DataTable.
+          'view': {'columns': [1, 2]}
+        });
+               histogram.setDataTable(dt);
+               histogram.draw();
+               
+}
+
+function handleResponse(response) {
+var supportedClasses = {
+               'Table':google.visualization.Table,
+               'LineChart':google.visualization.LineChart,
+               'ScatterChart':google.visualization.ScatterChart,
+               'ColumnChart':google.visualization.ColumnChart,
+               'GeoChart':google.visualization.GeoChart,
+               'PieChart':google.visualization.PieChart,
+               'Histogram':google.visualization.Histogram
+       };
+
+       /*var slider2 = new google.visualization.ControlWrapper({
+    'controlType': 'NumberRangeFilter',
+    'containerId': 'control3',
+    'options': {
+      'filterColumnLabel': 'Cpu',
+      minValue: 0,
+      maxValue: 100,
+         ui: { ticks: 10}
+    }
+  });*/
+
+  var timeSlider = new google.visualization.ControlWrapper({
+    'controlType': 'NumberRangeFilter',
+    'containerId': 'control1',
+    'options': {
+      'filterColumnLabel': 'Time',
+         ui: { ticks: 10}
+    }
+  });
+
+  // Define a bar chart
+  var barChart = new google.visualization.ChartWrapper({
+    'chartType': 'BarChart',
+    'containerId': 'chart1',
+    'options': {
+      'width': 400,
+      'height': 300,
+      'hAxis': {'minValue': 0, 'maxValue': 60},
+      'chartArea': {top: 0, right: 0, bottom: 0}
+    }
+  });
+
+       var categoryPicker = new google.visualization.ControlWrapper({
+          'controlType': 'CategoryFilter',
+          'allowMultiple': true,
+          'containerId': 'control2',
+          'options': {
+            'filterColumnLabel': 'Site',
+            'ui': {
+            'labelStacking': 'vertical',
+              'allowTyping': false
+            }
+          }
+        });
+       //var container = document.getElementById('datatable');
+       //var table = new google.visualization.LineChart(container);
+       //var table = new google.visualization.ColumnChart(container);
+
+       var proxy = new google.visualization.ChartWrapper({
+          'chartType': 'Table',
+          'containerId': 'chart7',
+          'options': {
+            'width': 800,
+            'height': 300,
+                       pageSize:5,
+                       page:'enable',
+            'legend': 'none',
+            'title': 'Nodes'
+          },
+          // Instruct the piechart to use colums 0 (Name) and 3 (Donuts Eaten)
+          // from the 'data' DataTable.
+          'view': {'columns': [0,1,2,3,4,5]}
+        });
+
+       function core_sum(arr) {
+               var ret = 0;
+               for (var i = 0; i < arr.length; i++) {
+                       ret+=arr[i]/1000;
+               }
+               return ret;
+       }
+
+       function scaled_sum(arr) {
+               var ret = 0;
+               for (var i = 0; i < arr.length; i++) {
+                       ret+=arr[i]/1000;
+               }
+               return ret;
+       }
+
+       function count_uniq(arr) {
+               var counts = {};
+               var ret = 0;
+               console.log('Starting ret '+ret);
+               for (var i = 0; i < arr.length; i++) {
+                               if (!counts[arr[i]]) ret+=1;
+                           counts[arr[i]] = 1;
+               }
+               return ret;
+       }
+       google.visualization.events.addListener(proxy, 'ready', function () {
+        // 0 - time 1 - city 2 - node 3 - site 4 - cpu 5 - bytes
+        var dt = proxy.getDataTable();
+               var groupedData1 = google.visualization.data.group(dt, [0], [{
+            column: 4,
+            type: 'number',
+            label: dt.getColumnLabel(4),
+            aggregation: google.visualization.data.sum
+        },{
+                       column: 5,
+            type: 'number',
+            label: dt.getColumnLabel(5),
+            aggregation: google.visualization.data.sum
+               }]);
+
+        showSiteTimeAgg(groupedData1);
+    });
+
+       /*google.visualization.events.addListener(proxy, 'ready', function () {
+        // 0 - time 1 - city 2 - node 3 - site 4 - cpu 5 - bytes
+        var dt = proxy.getDataTable();
+        var groupedData0 = google.visualization.data.group(dt, [2], [{
+            column: 4,
+            type: 'number',
+            label: dt.getColumnLabel(4),
+            aggregation: google.visualization.data.sum
+        },{
+                       column: 5,
+            type: 'number',
+            label: dt.getColumnLabel(5),
+            aggregation: google.visualization.data.sum
+               }]);
+        // after grouping, the data will be sorted by column 0, then 1, then 2
+        // if you want a different order, you have to re-sort
+               showNodeAgg(groupedData0);
+               });*/
+
+       google.visualization.events.addListener(proxy, 'ready', function () {
+        // 0 - time 1 - city 2 - node 3 - site 4 - cpu 5 - bytes
+        var dt = proxy.getDataTable();
+        var groupedData0 = google.visualization.data.group(dt, [1,3], [{
+            column: 4,
+            type: 'number',
+            label: 'Cores',
+            aggregation: core_sum
+        },{
+                       column: 5,
+            type: 'number',
+            label: dt.getColumnLabel(5),
+            aggregation: scaled_sum
+               }]);
+        // after grouping, the data will be sorted by column 0, then 1, then 2
+        // if you want a different order, you have to re-sort
+               showSiteAgg(groupedData0);
+            });
+
+       data = response.getDataTable();
+       new google.visualization.Dashboard(document.getElementById('dashboard')).
+            // Establish bindings, declaring the both the slider and the category
+            // picker will drive both charts.
+            bind([categoryPicker,timeSlider], [proxy]).
+            // Draw the entire dashboard.
+            draw(data);
+
+}
+function sendAndDraw(queryString) {
+       query = new google.visualization.Query(queryString)
+       query && query.abort();
+       query.send(function(response) {handleResponse(response);});
+}
+      
+
+    </script>
+    <div id="dashboard" class="container">
+               <div class="row">
+                       <div class="col-md-8">
+                               <div class="col-md-4" id="control2"></div>
+                               <div class="col-md-4" id="control1"></div>
+                               <!--<div class="col-md-4" id="control3"></div>-->
+                       </div>
+               </div>
+               <div class="row">
+                       <div class="col-md-8">
+                               <div class="col-md-4" id="chart1">
+                               </div>
+                               <div class="col-md-4" id="chart2">
+                               </div>
+                               <!--
+                               <div class="col-md-4" id="chart3">
+                               </div>-->
+                       </div>
+               </div>
+               <div class="row">
+                       <div class="col-md-8">
+                               <div class="col-md-4" id="chart4">
+                               </div>
+                               <!--
+                               <div class="col-md-4" id="chart5">
+                               </div>-->
+                               <div class="col-md-4" id="chart6">
+                               </div>
+                       </div>
+               </div>
+    </div>
+       <div id="chart7" style="display:none"></div>
index 8df5f10..306467a 100644 (file)
 {% load admin_static %}
 
 {% block content %}
-<h1>Welcome <a href="core/user/{{user.id}}">{{user.email}}</a> from Site: <a href="core/site/{{site.id}}">{{site}}</a></h1>
-<table class="table table-striped table-bordered table-hover table-condensed">
-<thead><tr>
-<th class="sortable">Slices</th><th class="sortable">Privilege</th>
-<th class="sortable">Reservations</th>
-</tr></thead>
-{% for entry in userSliceInfo %}
-<tr><td> <a href="core/slice/{{entry.slice.id}}">{{entry.slice.name}}</a><br>
-</td><td>{{entry.role}}</td>
-{% if entry.reservations %}
-<td><a href="core/slice/{{entry.slice.id}}/#reservations">
-{% for resSlot in entry.reservations.1 %}
-{{resSlot}} <br>
-{% endfor %}
-</a></td></tr>
-{% else %}
-<td></td></tr>
-{% endif %}
-{% endfor %}
-</table>
-<script type="text/javascript" src="{% static 'log4javascript-1.4.6/log4javascript.js' %}"></script>
-<div id="HPCDashboard">
-    <h1>HPC Dashboard</h1>
-    <span id="hpcSummary">
-        <span class="summary-attr"><b>Active Slivers:</b> 78 </span>
-        <span class="summary-attr"><b>Overall Throughput:</b> 58Gbps</span>
-        <span class="summary-attr-util"><b>CPU Utilization:</b> 45%</span>
+<link rel="stylesheet"  href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables.css">
+<link rel="stylesheet" type="text/css" href="{% static 'suit/css/suit.css' %}" media="all">
+<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables_themeroller.css">
+<link rel="stylesheet" type="text/css" href="{% static 'planetstack.css' %}" media="all">
+<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
 
-    </span>
-    <div id="map-us" ></div>
-</div>
 <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
 <script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
 
-<script src="{% static 'js/Leaflet.MakiMarkers.js' %}" > </script>
 
+<!-- no need to include jquery here as it's already included by base.html. Including it multiple times will break mtuity statistics. -->
+<!-- src="http://code.jquery.com/jquery-1.9.1.js" -->
+
+<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
+<script src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
+<script type="text/javascript" src="{% static 'log4javascript-1.4.6/log4javascript.js' %}"></script>
+<script src="{% static 'js/Leaflet.MakiMarkers.js' %}" > </script>
+  
+<script>
+  $(function() {
+    $( "#tabs" ).tabs({active: 0
+      //collapsible: true
+    });
+  });
+</script>
 <script>
 
+function confirmDialog(title,msg) {
+    var dialog = $('<div>'+msg+'</div>');
+    var def = $.Deferred();
+
+    $(dialog).dialog({
+        resizable: false,
+        title: title,
+        autoOpen: true,
+        modal: true,
+        dialogClass: "dashboard-hpc-sliver",
+        buttons: {
+            'OK': function() {
+                def.resolve();
+                log.debug("Chose to add a sliver");
+                $( this ).dialog( "close" );
+            },
+            'Cancel': function() {
+                def.reject();
+                $( this ).dialog( "close" );
+            }
+        },
+        close: {
+        }
+    });
+    return def.promise();
+}
+
+  </script>
+
+<div id="tabs" class="inner-center-column ui-tabs ui-widget ui-widget-content ui-corner-all">
+  <ul id="suit_form_tabs" class="nav nav-tabs nav-tabs-suit">
+    <li class="active"><a href="#tabs-1">Developer View</a></li>
+    <li><a href="#tabs-2">CDN Operations </a></li>
+    <li><a href="#tabs-3">Historical</a></li>
+    <li><a href="#tabs-3">Tenant</a></li>
+  </ul>
+<div id="tabs-1">
+</div>
+<div id="tabs-2">
+    <div id="HPCDashboard">
+    <h1>CDN Operations View</h1>
+    <span id="hpcSummary">
+        <span class="summary-attr"><b>Active Slivers:</b> <span id="active-slivers-value"> </span> </span>
+        <span class="summary-attr"><b>Overall Throughput:</b> <span id="overall-throughput-value"> </span>  </span>
+        <span class="summary-attr-util"><b>Average CPU Utilization:</b> <span id="cpu-utilization-value"> </span>  </span>
+    </span>
+    <div id="map-us" ></div>
+    <div style="line-height: 30%"><br></div><table border=0><tr>
+    <td>Least Loaded&nbsp;&nbsp;</td>
+    <td bgcolor="#0000FF" width=40>&nbsp;</td>
+    <td bgcolor="#00FFFF" width=40>&nbsp;</td>
+    <td bgcolor="#00FF00" width=40>&nbsp;</td>
+    <td bgcolor="#FFFF00" width=40>&nbsp;</td>
+    <td bgcolor="#FF0000" width=40>&nbsp;</td>
+    <td>&nbsp;&nbsp;Most Loaded</td>
+    </tr></table>
+    </div>
+</div>
+<div id="tabs-3">
+{% include "/opt/planetstack/templates/admin/dashboard/hpc_historical.html" %}
+</div>
+</div>
+
+<script>
+var oTable;
 var consoleAppender = new log4javascript.BrowserConsoleAppender();
 var patternLayout = new log4javascript.PatternLayout("%d{HH:mm:ss,SSS} %l{s:l} %-5p - %m{1}%n");
 consoleAppender.setLayout(patternLayout);
 
+//var log  = log4javascript.getDefaultLogger();
 var log  = log4javascript.getRootLogger();
 log.addAppender(consoleAppender);
-log.setLevel(log4javascript.Level.ALL);
+log.setLevel(log4javascript.Level.ERROR);
+
+function updateUserSliceTable(){
+    log.debug("Should grab user slice info");
+    jQuery.ajax({
+        async:true,
+        dataType: 'json',
+        url: '/hpcdashuserslices',
+        success: function(data){
+            log.info("Got Data back for User SliceTable");
+            //parseData(data);
+            //createUserSliceTable(data);
+            setTimeout(function () { updateUserSliceTable() }, 5000);
+        },
+        error: function(data){
+            log.debug("COULDNT GET DATA BACK");
+            setTimeout(function () { updateUserSliceTable() }, 5000);
+        }
+    });
+}
+
+function createUserSliceTable(data) {
+    log.debug("Creating User Slice Table");
+
+    //Add check for #dynamicusersliceinfo_filter label-> input having focus here
+
+    $('#tabs-1').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="dynamicusersliceinfo"></table>' );
+    var actualEntries = [];
+    log.debug(data['userSliceInfo']['rows'][0]['slicename']);
+
+    var rows = data['userSliceInfo']['rows'];
+    for (row in rows) {
+        log.debug(row[0]);
+        slicename = rows[row]['slicename'];
+        sliceid = rows[row]['sliceid'];
+        role = rows[row]['role'];
+        slivercount = rows[row]['slivercount'];
+        sitecount = rows[row]['sitecount'];
+        actualEntries.push(['<a href="http://{{request.get_host}}/admin/core/slice/' + sliceid + '">' + slicename + '</a>',
+                            role, slivercount, sitecount]);
+    }
+    oTable = $('#dynamicusersliceinfo').dataTable( {
+        "bJQueryUI": true,
+        "aaData":  actualEntries ,
+        "bStateSave": true,
+        "aoColumns": [
+            { "sTitle": "Slice" },
+            { "sTitle": "Privilege" , sClass: "alignCenter"},
+            { "sTitle": "Number of Slivers" , sClass: "alignCenter"},
+            { "sTitle": "Number of Sites" , sClass: "alignCenter"},
+        ]
+    } );
+
+    // If the filter had focus, reapply here
+
+    setTimeout(function() {
+       jQuery.ajax({
+           url: '/hpcdashuserslices',
+           dataType: 'json',
+           success: function(data){ createUserSliceTable(data); },
+           complete: function(){ },
+       });
+    },  10000);
+}
+
+function initTable(){
+    log.debug("Initializing Table")
+    jQuery.ajax({
+        url: '/hpcdashuserslices',
+        dataType: 'json',
+        success: function(data){ createUserSliceTable(data); },
+        complete: function(){
+        }
+    });
+    updateUserSliceTable();
+}
+
+
+initTable();
+
+//$( "#dialogadd" ).dialog({ autoOpen: false });
+//$( "#remSliverdialog" ).dialog({ autoOpen: false });
 
 L.Map = L.Map.extend({
     openPopup: function(popup) {
@@ -61,22 +197,28 @@ L.Map = L.Map.extend({
 
 //Iterate through data and find the max/min coordinates to include all of our points to start
 var map = L.map('map-us'); //.setView([0, 0], 1);
+map.scrollWheelZoom.disable();
 
-L.tileLayer('http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', {
+//
+// Great tiles, but starting to occasionally see 403 errors on certain tiles causing grey out effect
+//L.tileLayer('http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', {
+//
+// Swapping out cloudmade tiles to openstreetmap - too many grey tiles showing
+L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
     maxZoom: 18,
     attribution: 'Test'
 }).addTo(map);
 
 var arrayOfLatLngs = [];
-var data = {{ cdnData|safe }};
-log.info( data );
+var mapData = {{ cdnData|safe }};
+log.debug( mapData );
 
-for ( var key in data ) {
-    arrayOfLatLngs.push([data[key]['lat'],data[key]['long']]);
-    log.info( arrayOfLatLngs );
+for ( var key in mapData ) {
+    arrayOfLatLngs.push([mapData[key]['lat'],mapData[key]['long']]);
+    log.debug( arrayOfLatLngs );
 
-    data[key]['marker'] = L.marker([data[key]['lat'], data[key]['long']], {icon: getIcon(data[key]['numNodes'], data[key]['numHPCSlivers']) });
-    data[key]['marker'].addTo(map).bindPopup(setPopupVals(key, data[key]));
+    mapData[key]['marker'] = L.marker([mapData[key]['lat'], mapData[key]['long']], {icon: getIcon(mapData[key]['numNodes'], mapData[key]['numHPCSlivers'], 0, mapData[key]['hot']) });
+    mapData[key]['marker'].addTo(map).bindPopup(setPopupVals(key, mapData[key]));
 
 }
 var bounds = new L.LatLngBounds(arrayOfLatLngs);
@@ -88,51 +230,109 @@ var popup = L.popup();
 function setPopupVals (site, siteData) {
     var retVal = '<span class="SiteDetail"><b>' + site + '</b></span>' + 
                    '</br><a href="' + siteData['siteUrl'] + '">' + siteData['siteUrl'] + '</a>' + 
-                   '</br><b>Available Nodes: </b>' + siteData['numNodes'] + 
-                   '</br><b>Active HPC Slivers: </b>' + siteData['numHPCSlivers'] + 
-                   '</br><span id="addSlivers">Add HPC Slivers</span>' + 
-                   '<span id="remSlivers">Remove HPC Slivers</span>' ; 
+                   '</br><b>HPC Slivers: </b>' + siteData['numHPCSlivers'] + 
+                   '</br><b>Total Nodes: </b>' + siteData['numNodes'] +
+//                   '</br><b>Hot: </b>' + Math.round(siteData['hot']*100) +
+                   '</br><b>Measured Load: </b>' + siteData['load'] + '%' +
+                   '<span id="addSlivers"></br><a href="#" id="addHPCSliver" data-site="' + site + '" data-availNodes="' + siteData['numNodes'] +'">Add HPC Slivers</a> </span>' +
+                   '<span id="remSlivers"><a href="#" id="remHPCSliver" data-site="' + site + '">Remove HPC Slivers</a> </span>';
 
    return retVal;
 }
-function getIcon(numNodes, numHPCSlivers, currentBW) {
-    var colorChoices = ["#007FFF", "#0000FF", "#7f00ff", "#FF00FF", "#FF007F", "#FF0000"];
 
-    var ratio = (numHPCSlivers/numNodes) * 100;
+$('#map-us').on('click', '#remHPCSliver', function() {
+   
+    $.ajax({
+        url : '/dashboardaddorremsliver/',
+        dataType : 'json',
+        data: {site: $(this).data('site'),
+               actionToDo: "rem",
+               csrfmiddlewaretoken: "{{ csrf_token }}",   // < here 
+               state:"inactive" },
+        type : 'POST',
+        //success: function(response)
+        //{
+         //   alert("Successfully posted request to REMOVE sliver");
+        //},
+        complete:function(){
+            alert("Successfully posted request to REMOVE sliver");
+        },
+        //error:function (xhr, textStatus, thrownError){
+         //   alert("Could not request to remove HPC Sliver");
+        //}
+    });
+});
+
+$('#map-us').on('click', '#addHPCSliver', function() {
+   
+    $.ajax({
+        url : '/dashboardaddorremsliver/',
+        dataType : 'json',
+        data: {site: $(this).data('site'),
+               actionToDo: "add",
+               csrfmiddlewaretoken: "{{ csrf_token }}",   // < here 
+               state:"inactive" },
+        type : 'POST',
+        success: function(response)
+        {
+            alert("Successfully posted request to add sliver");
+        },
+        complete:function()
+        { 
+            alert("Successfully posted request to add sliver");
+        },
+        //error:function (xhr, textStatus, thrownError){
+         //   alert("error doing something");
+        //}
+    });
+  //  confirmDialog("Add HPC Slivers","Add some HPC Slivers to site " + $(this).data('site'));
+});
+
+function getIcon(numNodes, numHPCSlivers, currentBW, hot) {
+    //var colorChoices = ["#007FFF", "#0000FF", "#7f00ff", "#FF00FF", "#FF007F", "#FF0000"];
+    var colorChoices = ["#0000FF", "#00FFFF", "#00FF00", "#FFFF00", "#FF0000"];
+
+    var ratio = hot * 100; //(numHPCSlivers/numNodes) * 100;
     var numColors = colorChoices.length;
     var colorBands = 100/numColors;
 
     //Algorithm for color tone should consider the number of available nodes
     // on the site, and then how much the current dedicated nodes are impacted
     //var iconColor = 0;
-    var iconColor = 5;
+    var iconColor = colorChoices.length-1;
     for (colorBand = 0; colorBand < numColors; colorBand ++) {
         if (ratio < colorBands * colorBand+1) {
             iconColor = colorBand
             break;
         }
     }
-  
-    var icon = L.MakiMarkers.icon({icon: "star-stroked", color: colorChoices[iconColor] , size: "s"});
+
+    if (numHPCSlivers < 1) {
+        iconColor = "#7F7F7F";
+    } else {
+        iconColor = colorChoices[iconColor];
+    }
+
+    var icon = L.MakiMarkers.icon({icon: "star-stroked", color: iconColor , size: "s"});
     return icon;
 }
 
 function updateMaps() {
-    log.info("Attempting to update Maps");
+    log.debug("Attempting to update Maps");
     $.ajax({
     url : '/hpcdashboard',
     dataType : 'json',
     type : 'GET',
     success: function(newData)
     {
-        log.info("Successfully got data back...");
-        log.info(newData);
-        log.info("Still have old data too");
-        log.info(data);
+        log.debug("Successfully got data back...");
+        log.debug(newData);
+        log.debug("Still have old data too");
+        log.debug(mapData);
         updateMapData(newData);
     }
 });
-    setTimeout(updateMaps, 45000)
+    setTimeout(updateMaps, 30000)
 
 }
 
@@ -140,32 +340,32 @@ function updateMapData(newData) {
     for ( site in newData ) {
         var isNewSite = false;
         //check to see if the site is new or not
-        if (site in data) {
-            log.info("Site " + site + " already mapped");
+        if (site in mapData) {
+            log.debug("Site " + site + " already mapped");
             //take ownership of marker
-            newData[site]['marker'] = data[site]['marker'];
-            delete data[site];
-            newData[site]['marker'].setIcon(getIcon(newData[site]['numNodes'], newData[site]['numHPCSlivers']));
+            newData[site]['marker'] = mapData[site]['marker'];
+            delete mapData[site];
+            newData[site]['marker'].setIcon(getIcon(newData[site]['numNodes'], newData[site]['numHPCSlivers'],  0, newData[site]['hot']));
             // workaround, markers currently don't have a setPopup Content method -- so have to grab object directly
             newData[site]['marker']._popup.setContent(setPopupVals(site, newData[site]));
         }
         else {
             isNewSite = true;
-            log.info("New Site detected: " + site);
+            log.debug("New Site detected: " + site);
             newData[site]['marker'] = L.marker([newData[site]['lat'], newData[site]['long']], 
-                                              {icon: getIcon(newData[site]['numNodes'], newData[site]['numHPCSlivers']) });
+                                              {icon: getIcon(newData[site]['numNodes'], newData[site]['numHPCSlivers'],  0, newData[site]['hot']) });
             newData[site]['marker'].addTo(map).bindPopup(setPopupVals(site, newData[site])); //.openPopup();
-            log.info("Should have added the new site");
+            log.debug("Should have added the new site");
 
         }
     }
 
     // Anything still in data needs to be removed since it is no longer a valid site
-    for (remSite in data) {
+    for (remSite in mapData) {
         log.warn("Site: " + remSite + " is no longer valid, removing from map");
         map.removeLayer(data[remSite]['marker']);
     }
-    data = newData;
+    mapData = newData;
 }
 
 function onMapClick(e) {
@@ -177,5 +377,51 @@ function onMapClick(e) {
 
 setTimeout(updateMaps, 5000)
 
+// from stackexchange
+function setInnerText (elementId, text) {
+    var element;
+    if (document.getElementById) {
+        element = document.getElementById(elementId);
+    } else if (document.all) {
+        element = document.all[elementId];
+    }
+    if (element) {
+        if (typeof element.textContent != 'undefined') {
+            element.textContent = text;
+        } else if (typeof element.innerText != 'undefined') {
+            element.innerText = text;
+        } else if (typeof element.removeChild != 'undefined') {
+            while (element.hasChildNodes()) {
+                element.removeChild(element.lastChild);
+            }
+            element.appendChild(document.createTextNode(text)) ;
+        }
+    }
+}
+
+function updateLabelData(summaryData) {
+    setInnerText("active-slivers-value", summaryData["total_slivers"]);
+    setInnerText("overall-throughput-value", (summaryData["total_bandwidth"]*8/1024/1024/1024).toFixed(2) + " Gbps");
+    setInnerText("cpu-utilization-value", summaryData["average_cpu"] + "%");
+}
+
+function updateLabels() {
+    log.debug("Attempting to update Labels");
+    $.ajax({
+    url : '/hpcsummary',
+    dataType : 'json',
+    type : 'GET',
+    success: function(newData)
+    {
+        updateLabelData(newData);
+    }
+});
+    setTimeout(updateLabels, 30000)
+
+}
+
+setTimeout(updateLabels, 5000)
+               
+
 </script>
 {% endblock %}