aboutsummaryrefslogtreecommitdiffstats
path: root/demo-ui/app/controllers/MefController.js
diff options
context:
space:
mode:
authorSteven Saunders <steve@llantz9470.cablelabs.com>2015-08-12 08:48:07 -0600
committerSteven Saunders <steve@khiatt8460b.cablelabs.com>2015-08-12 18:21:36 -0600
commite8a4652f70284c414ceafc086669dfd4b935573d (patch)
treeedfa339167fee1863505f7a39b5b3cab431b3eee /demo-ui/app/controllers/MefController.js
parented73dbf357aff41edcbab401a94e5fbc266d9391 (diff)
Add demo-ui folder. This folder contains HTML/CSS/Javascript code for the VCPE Demo UI. The Demo UI allows you to CRUD CoS instances, and EPL instances, and will also display information about EVCs and UNIs that were created as well
Change-Id: I32eea1121c21e0b451efc057a0c0f30fe5601cd5 Signed-off-by: Steven Saunders <steve@llantz9470.cablelabs.com>
Diffstat (limited to 'demo-ui/app/controllers/MefController.js')
-rw-r--r--demo-ui/app/controllers/MefController.js117
1 files changed, 117 insertions, 0 deletions
diff --git a/demo-ui/app/controllers/MefController.js b/demo-ui/app/controllers/MefController.js
new file mode 100644
index 0000000..9531b49
--- /dev/null
+++ b/demo-ui/app/controllers/MefController.js
@@ -0,0 +1,117 @@
+(function() {
+
+var MefController = function($scope, $log, mefServices, model, dbg ) {
+
+ //
+ // Controller Set Up
+ //
+
+ dbg.p("---> in MefController()");
+ $scope.currentEpl = null;
+ $scope.currentEplEvc = null;
+ $scope.currentEvcUnis = [];
+
+ //
+ // Utils
+ //
+
+ $scope.curEplEvcToJson = function () {
+ return angular.toJson($scope.currentEplEvc, true);
+ };
+
+
+ $scope.uniToSpeedString = function(uni) {
+ if (uni) {
+ speed = uni.uni[0].speed;
+ return Object.getOwnPropertyNames(speed)[0];s
+ }
+ else
+ return "";
+ }
+ //
+ // HTTP Response Handlers
+ //
+
+ var onRequestError = function(reason){
+ dbg.e("HTTP Request Problem\n" + JSON.stringify(reason));
+ };
+
+
+ var onUniGetResp = function(data) {
+ dbg.p("in onUniGetResp()");
+ dbg.pj(data);
+
+ // dbg.p("current EVC UNI list before adding");
+ //oSpeedString($scop dbg.pj($scope.currentEvcUnis);
+
+ $scope.currentEvcUnis.push(data);
+
+ // dbg.p("current EVC UNI list after adding");
+ // dbg.pj($scope.currentEvcUnis);
+ }
+
+ var onEvcGetResp = function(data) {
+ dbg.p("in onEvcGetResp()");
+ dbg.pj(data);
+ $scope.currentEplEvc = data;
+
+ // out with the old unis
+ $scope.currentEvcUnis = [];
+
+ // in with the new unis
+ mefServices.getUni($scope.currentEplEvc.uniIdList[0])
+ .then(onUniGetResp, onRequestError);
+ mefServices.getUni($scope.currentEplEvc.uniIdList[1])
+ .then(onUniGetResp, onRequestError);
+ };
+
+ //
+ // State query fxns
+ //
+
+ $scope.showEvcValues = function () {
+ return ( $scope.currentEplEvc != null );
+ }
+
+ $scope.showUniValues = function () {
+ return ( $scope.currentEvcUnis != null );
+ }
+
+ //
+ // Watch for change in selected EPL so tht we can
+ // update the corresponding EVC info
+ //
+
+ eplWatcher = function () { return model.getCurrentEpl(); }
+ onEplChange = function (newEpl, oldEpl) {
+ dbg.p("in MefController:onEplChange");
+ // dbg.p("oldEpl:"); dbg.pj(oldEpl);
+ // dbg.p("newEpl:"); dbg.pj(newEpl);
+
+ // only make a chance if we have a new EPL object
+ if ( newEpl ) {
+ var newEplId = newEpl.id;
+ var oldEplId = "null";
+ if (oldEpl) oldId = oldEpl.id
+
+ dbg.p("detected selected EPL change from " +
+ oldEplId + " to " + newEplId, 1);
+ $scope.currentEpl = newEpl;
+
+ // get the EVC info
+ mefServices.getEvc($scope.currentEpl.evcId)
+ .then(onEvcGetResp, onRequestError);
+ }
+ else {
+ $scope.currentEplEvc = null;
+ $scope.currentEvcUnis = null;
+ }
+
+ }
+ $scope.$watch( eplWatcher, onEplChange );
+};
+
+// register controller in the module
+app.controller("MefController", MefController);
+
+}()); \ No newline at end of file