First to subscriber dashboard
diff --git a/xos/core/dashboard/views/home.py b/xos/core/dashboard/views/home.py
index bc721f0..f72be81 100644
--- a/xos/core/dashboard/views/home.py
+++ b/xos/core/dashboard/views/home.py
@@ -2,12 +2,22 @@
from django.http import HttpResponseRedirect
import sys
+
+def isInt(s):
+ try:
+ int(s)
+ return True
+ except ValueError:
+ return False
+
+
class LoggedInView(TemplateView):
def get(self, request, name="root", *args, **kwargs):
if request.user.login_page:
- return HttpResponseRedirect(request.user.login_page)
+ return HttpResponseRedirect(request.user.login_page)
else:
- return HttpResponseRedirect("/admin/")
+ return HttpResponseRedirect("/admin/")
+
class DashboardDynamicView(TemplateView):
head_template = r"""{% extends "admin/dashboard/dashboard_base.html" %}
@@ -26,13 +36,13 @@
context = self.get_context_data(**kwargs)
context = getDashboardContext(request.user, context)
- if name=="root":
+ if name == "root":
# maybe it is a bit hacky, didn't want to mess up everything @teone
user_dashboards = request.user.get_dashboards()
- first_dasboard_name = user_dashboards[0].id;
+ first_dasboard_name = user_dashboards[0].id
return self.singleDashboardView(request, first_dasboard_name, context)
# return self.multiDashboardView(request, context)
- elif kwargs.get("wholePage",None):
+ elif kwargs.get("wholePage", None):
return self.singleFullView(request, name, context)
else:
return self.singleDashboardView(request, name, context)
@@ -48,8 +58,8 @@
else:
return "failed to find %s in %s" % (fn, TEMPLATE_DIRS)
- template= open(pathname, "r").read()
- if (fn=="tenant"):
+ template = open(pathname, "r").read()
+ if (fn == "tenant"):
# fix for tenant view - it writes html to a div called tabs-5
template = '<div id="tabs-5"></div>' + template
return template
@@ -66,14 +76,14 @@
def embedDashboardView(self, view, i=0):
body = ""
url = view.url
- if (view.controllers.all().count()>0):
- body = body + 'Controller: <select id="dashselect-%d">' % i;
- body = body + '<option value="None">(select a controller)</option>';
- for j,controllerdashboard in enumerate(view.controllerdashboardviews.all()):
+ if (view.controllers.all().count() > 0):
+ body = body + 'Controller: <select id="dashselect-%d">' % i
+ body = body + '<option value="None">(select a controller)</option>'
+ for j, controllerdashboard in enumerate(view.controllerdashboardviews.all()):
body = body + '<option value="%d">%s</option>' % (j, controllerdashboard.controller.name)
body = body + '</select><hr>'
- for j,controllerdashboard in enumerate(view.controllerdashboardviews.all()):
+ for j, controllerdashboard in enumerate(view.controllerdashboardviews.all()):
body = body + '<script type="text/template" id="dashtemplate-%d-%d">\n%s\n</script>\n' % (i,j, self.embedDashboardUrl(controllerdashboard.url));
body = body + '<div id="dashcontent-%d" class="dashcontent"></div>\n' % i
@@ -89,7 +99,7 @@
});
//$("#dashcontent-%d").html( $("#dashtemplate-%d-0").html() );
</script>
- """ % (i,i,i,i,i,i,i);
+ """ % (i, i, i, i, i, i, i)
else:
body = body + self.embedDashboardUrl(url)
return body
@@ -115,7 +125,7 @@
if (not view.enabled):
continue
- tabs.append( '<li><a href="#dashtab-%d">%s</a></li>\n' % (i, view.name) )
+ tabs.append('<li><a href="#dashtab-%d">%s</a></li>\n' % (i, view.name))
body = '<div id="dashtab-%d">%s</div>\n' % (i, self.embedDashboardView(view, i))
bodies.append(body)
@@ -124,7 +134,7 @@
# embed content provider dashboards
for cp in ContentProvider.objects.all():
if request.user in cp.users.all():
- tabs.append( '<li><a href="#dashtab-%d">%s</a></li>\n' % (i, cp.name) )
+ tabs.append('<li><a href="#dashtab-%d">%s</a></li>\n' % (i, cp.name))
body = ""
body = body + '<div id="dashtab-%d">\n' % i
@@ -134,7 +144,7 @@
bodies.append(body)
i = i + 1
- if (len(tabs)==1) and (len(bodies)==1):
+ if (len(tabs) == 1) and (len(bodies) == 1):
# there is only one dashboard, so optimize out the tabbing
contents = bodies[0]
else:
@@ -152,27 +162,29 @@
response_kwargs = {}
response_kwargs.setdefault('content_type', self.content_type)
return self.response_class(
- request = request,
- template = t,
- context = context,
+ request=request,
+ template=t,
+ context=context,
**response_kwargs)
def singleDashboardView(self, request, id, context):
head_template = self.head_template
tail_template = self.tail_template
- view = DashboardView.objects.get(id=id)
-
- print "XXX", view
-
- t = template.Template(head_template + self.embedDashboardView(view) + self.tail_template)
+ # if id is a number, load by datamodel,
+ # else look directly for the template
+ if(isInt(id)):
+ view = DashboardView.objects.get(id=id)
+ t = template.Template(head_template + self.embedDashboardView(view) + self.tail_template)
+ else:
+ t = template.Template(head_template + self.readTemplate("xos" + id) + self.tail_template)
response_kwargs = {}
response_kwargs.setdefault('content_type', self.content_type)
return self.response_class(
- request = request,
- template = t,
- context = context,
+ request=request,
+ template=t,
+ context=context,
**response_kwargs)
def singleFullView(self, request, id, context):
@@ -186,8 +198,7 @@
response_kwargs = {}
response_kwargs.setdefault('content_type', self.content_type)
return self.response_class(
- request = request,
- template = t,
- context = context,
+ request=request,
+ template=t,
+ context=context,
**response_kwargs)
-
diff --git a/xos/core/xoslib/dashboards/xosSubscribers.html b/xos/core/xoslib/dashboards/xosSubscribers.html
new file mode 100644
index 0000000..cb58882
--- /dev/null
+++ b/xos/core/xoslib/dashboards/xosSubscribers.html
@@ -0,0 +1,16 @@
+<!-- browserSync -->
+
+<!-- endcss -->
+<!-- inject:css -->
+<link rel="stylesheet" href="/static/css/xosSubscribers.css">
+<!-- endinject -->
+
+<div ng-app="xos.subscribers" id="xosSubscribers" class="container-fluid">
+ <div ui-view></div>
+</div>
+
+
+<!-- endjs -->
+<!-- inject:js -->
+<script src="/static/js/xosSubscribers.js"></script>
+<!-- endinject -->
\ No newline at end of file
diff --git a/xos/core/xoslib/static/css/xosSubscribers.css b/xos/core/xoslib/static/css/xosSubscribers.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/xos/core/xoslib/static/css/xosSubscribers.css
diff --git a/xos/core/xoslib/static/js/xosSubscribers.js b/xos/core/xoslib/static/js/xosSubscribers.js
new file mode 100644
index 0000000..c0500fb
--- /dev/null
+++ b/xos/core/xoslib/static/js/xosSubscribers.js
@@ -0,0 +1 @@
+"use strict";angular.module("xos.subscribers",["ngResource","ngCookies","ui.router","xos.helpers"]).config(["$stateProvider",function(e){e.state("user-list",{url:"/",template:"<subscribers-list></subscribers-list>"})}]).config(["$httpProvider",function(e){e.interceptors.push("NoHyperlinks")}]).directive("subscribersList",function(){return{restrict:"E",scope:{},bindToController:!0,controllerAs:"vm",templateUrl:"templates/subscribers-list.tpl.html",controller:["Subscribers",function(e){var t=this;this.tableConfig={filter:"field",order:!0,pagination:{pageSize:10},columns:[{label:"Name",prop:"humanReadableName"},{label:"Identity",prop:"identity",type:"object"},{label:"Related Info",prop:"related",type:"object"}]},this.smartTableConfig={resource:"Subscribers"},e.query().$promise.then(function(e){t.users=e})["catch"](function(e){throw new Error(e)})}]}}),angular.module("xos.subscribers").run(["$templateCache",function(e){e.put("templates/subscribers-list.tpl.html",'<!-- <xos-table config="vm.tableConfig" data="vm.users"></xos-table> -->\n\n<xos-smart-table config="vm.smartTableConfig"></xos-smart-table>')}]),angular.module("xos.subscribers").run(["$location",function(e){e.path("/")}]);
\ No newline at end of file
diff --git a/xos/services/cord/templates/vcpeadmin.html b/xos/services/cord/templates/vcpeadmin.html
index c93f032..334a3e8 100644
--- a/xos/services/cord/templates/vcpeadmin.html
+++ b/xos/services/cord/templates/vcpeadmin.html
@@ -3,7 +3,7 @@
<a class="btn btn-primary" href="/admin/cord/vsgtenant/">vSG Tenants</a>
</div>
<div class="col-xs-6">
- <a class="btn btn-primary" href="/admin/dashboard/cord/">Subscriber View</a>
+ <a class="btn btn-primary" href="/admin/dashboard/subscribers/">Subscriber View</a>
</div>
</div>