Ready to start development
diff --git a/mCordPortal/src/app/fw/foot/foot.html b/mCordPortal/src/app/components/footer/footer.html
similarity index 100%
rename from mCordPortal/src/app/fw/foot/foot.html
rename to mCordPortal/src/app/components/footer/footer.html
diff --git a/mCordPortal/src/app/fw/foot/foot.js b/mCordPortal/src/app/components/footer/footer.js
similarity index 76%
rename from mCordPortal/src/app/fw/foot/foot.js
rename to mCordPortal/src/app/components/footer/footer.js
index fdaabb8..c59917b 100644
--- a/mCordPortal/src/app/fw/foot/foot.js
+++ b/mCordPortal/src/app/components/footer/footer.js
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-angular.module('cordFoot', [])
- .directive('foot', function () {
- return {
- restrict: 'E',
- templateUrl: 'app/fw/foot/foot.html'
- };
- });
+angular.module('mCord')
+ .directive('footer', function () {
+ return {
+ restrict: 'E',
+ templateUrl: 'app/components/footer/footer.html'
+ };
+ });
diff --git a/mCordPortal/src/app/fw/mast/mast.html b/mCordPortal/src/app/components/header/header.html
similarity index 62%
rename from mCordPortal/src/app/fw/mast/mast.html
rename to mCordPortal/src/app/components/header/header.html
index ac8bfe0..6e9d5f8 100644
--- a/mCordPortal/src/app/fw/mast/mast.html
+++ b/mCordPortal/src/app/components/header/header.html
@@ -1,6 +1,5 @@
-<!--Mast HTML-->
<nav class="navbar navbar-default navbar-fixed-top">
- <div class="container">
+ <div class="container-fluid">
<div class="navbar-header">
<button ng-if="page.curr !== 'login'" type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
@@ -13,18 +12,15 @@
</a>
</div>
<div id="navbar" class="collapse navbar-collapse" close-on-route-change>
- <ul ng-if="page.curr !== 'login'" class="nav navbar-nav pull-right">
- <li ng-class="{active: page.curr === 'dashboard'}">
+ <ul ng-if="vm.user" class="nav navbar-nav pull-right" active-class>
+ <li>
<a href="#/">Home</a>
</li>
- <li ng-class="{active: page.curr === 'user'}">
- <a href="#/user">User</a>
+ <li>
+ <a href="#/services">Services</a>
</li>
- <li ng-class="{active: page.curr === 'bundle'}">
- <a href="#/bundle">Services</a>
- </li>
- <li ng-click="logout()">
- <a href="#/contact">Logout</a>
+ <li ng-click="vm.logout()">
+ <a href="">Logout {{vm.a}}</a>
</li>
</ul>
</div><!--/.nav-collapse -->
diff --git a/mCordPortal/src/app/components/header/header.js b/mCordPortal/src/app/components/header/header.js
new file mode 100644
index 0000000..f2bbee2
--- /dev/null
+++ b/mCordPortal/src/app/components/header/header.js
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function () {
+ 'use strict';
+
+ angular.module('mCord')
+ .directive('header', function ($location, User) {
+ return {
+ restrict: 'E',
+ templateUrl: 'app/components/header/header.html',
+ controllerAs: 'vm',
+ controller: function() {
+
+ this.user = User.isLoggedIn();
+
+ this.logout = () => {
+ User.logout()
+ .then(function(){
+ $location.path('/login');
+ });
+ };
+ }
+ };
+ })
+ .directive('closeOnRouteChange', function(){
+ return {
+ restrict: 'A',
+ link: function(scope, elem){
+ scope.$on('$routeChangeStart', function() {
+ elem.removeClass('in');
+ });
+ }
+ }
+ })
+ .directive('activeClass', function($location) {
+ return {
+ restrict: 'A',
+ link: function($rootScope, $element, $attrs) {
+ const links = angular.element($element[0]).find('a');
+ let urlMap = {};
+ let activeClass = $attrs.activeClass || 'active';
+ for (let i = links.length - 1; i >= 0; i--) {
+ let link = angular.element(links[i]);
+ let url = link.attr('href');
+
+ if (url.substring(0, 1) === '#') {
+ urlMap[url.substring(1)] = link;
+ } else {
+ urlMap[url] = link;
+ }
+ }
+
+ const activateItem = () => {
+ var path = urlMap[$location.path()];
+ links.parent('li').removeClass(activeClass);
+ if (path) {
+ path.parent('li').addClass(activeClass);
+ }
+ }
+ activateItem();
+ $rootScope.$on('$stateChangeStart', activateItem);
+ }
+ }
+ });
+}());
diff --git a/mCordPortal/src/app/fw/icon/icon.js b/mCordPortal/src/app/fw/icon/icon.js
deleted file mode 100644
index b0d48fa..0000000
--- a/mCordPortal/src/app/fw/icon/icon.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-(function () {
- 'use strict';
-
- angular.module('cordGui')
-
- .directive('icon', [function () {
- return {
- restrict: 'E',
- compile: function (element, attrs) {
- var html =
- '<svg class="embedded-icon" width="' + attrs.size + '" ' +
- 'height="' + attrs.size + '" viewBox="0 0 50 50">' +
- '<g class="icon">' +
- '<circle cx="25" cy="25" r="25"></circle>' +
- '<use width="50" height="50" class="glyph '
- + attrs.id + '" xlink:href="#' + attrs.id +
- '"></use>' +
- '</g>' +
- '</svg>';
- element.replaceWith(html);
- }
- };
- }]);
-}());
diff --git a/mCordPortal/src/app/fw/mast/mast.js b/mCordPortal/src/app/fw/mast/mast.js
deleted file mode 100644
index eb08d79..0000000
--- a/mCordPortal/src/app/fw/mast/mast.js
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-(function () {
- 'use strict';
-
- var urlSuffix = '/rs/logout';
-
- angular.module('cordMast', [])
- .controller('CordMastCtrl', function ($log, $scope, $location, User) {
- $scope.logout = function () {
- User.logout()
- .then(function(){
- $location.path('/login');
- });
- };
- })
- .directive('mast', function () {
- return {
- restrict: 'E',
- templateUrl: 'app/fw/mast/mast.html',
- controller: 'CordMastCtrl',
- controllerAs: ''
- };
- })
- .directive('closeOnRouteChange', function(){
- return {
- restrict: 'A',
- link: function(scope, elem){
- scope.$on('$routeChangeStart', function(next, current) {
- elem.removeClass('in');
- });
- }
- }
- });
-}());
diff --git a/mCordPortal/src/app/fw/services/helpers.js b/mCordPortal/src/app/services/helpers.js
similarity index 96%
rename from mCordPortal/src/app/fw/services/helpers.js
rename to mCordPortal/src/app/services/helpers.js
index 6f6c4a6..a46833f 100644
--- a/mCordPortal/src/app/fw/services/helpers.js
+++ b/mCordPortal/src/app/services/helpers.js
@@ -17,7 +17,7 @@
(function () {
"use strict";
- angular.module('cordGui')
+ angular.module('mCord')
.service('Helpers', function(){
this.randomDate = function(start, end) {
return new Date(
diff --git a/mCordPortal/src/app/fw/services/rest.js b/mCordPortal/src/app/services/rest.js
similarity index 99%
rename from mCordPortal/src/app/fw/services/rest.js
rename to mCordPortal/src/app/services/rest.js
index 29f4d7f..c2647c9 100644
--- a/mCordPortal/src/app/fw/services/rest.js
+++ b/mCordPortal/src/app/services/rest.js
@@ -23,7 +23,7 @@
};
- angular.module('cordRest', [])
+ angular.module('mCord')
.factory('SetCSRFToken', function setCSRFToken($cookies) {
return {
request: function(request){
diff --git a/mCordPortal/src/app/view/home/home.html b/mCordPortal/src/app/view/home/home.html
index f464ad2..8fed31a 100644
--- a/mCordPortal/src/app/view/home/home.html
+++ b/mCordPortal/src/app/view/home/home.html
@@ -1,56 +1 @@
-<!-- Home page partial html -->
-<div id="home" class="container">
- <div class="row">
- <div class="col-sm-6 hidden-xs">
- <img class="img-responsive img-rounded" src="/imgs/stanford.jpg">
- <p class="text-right small">© Wikipedia</p>
- </div>
- <div class="col-sm-6">
- <div class="bundle-title">
- <h2>Welcome!</h2>
- <h5>You are subscribed to the</h5>
- </div>
-
- <div class="panel panel-primary">
- <div class="panel-heading">
- <h3 class="panel-title">{{bundle_name}}</h3>
- </div>
- <div class="panel-body">
- {{bundle_desc}}
- </div>
- </div>
-
- <div class="panel panel-primary">
- <div class="panel-heading">
- <h3 class="panel-title">Users</h3>
- </div>
- <table class="table">
- <thead>
- <tr>
- <th></th>
- <th>Name</th>
- <th>Last Login</th>
- </tr>
- </thead>
- <tbody>
-
- <!--<pre>{{users | json}}</pre>-->
-
- <tr ng-repeat="user in users" class="animate-repeat" ng-show="users">
- <td class="avatar">
- <img class="img-responsive img-rounded" ng-src="{{'/imgs/' + user.icon_id + '.jpg'}}">
- </td>
- <td>{{user.name}}</td>
- <td>{{shared.userActivity[user.id]}}</td>
- </tr>
- <tr ng-show="!users">
- <td colspan="3">
- <div class="loader"></div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- </div>
-</div>
\ No newline at end of file
+<ng-map center="[40.74, -74.18]"></ng-map>
\ No newline at end of file
diff --git a/mCordPortal/src/app/view/home/home.js b/mCordPortal/src/app/view/home/home.js
index 1e32c0f..6e6b4a7 100644
--- a/mCordPortal/src/app/view/home/home.js
+++ b/mCordPortal/src/app/view/home/home.js
@@ -17,22 +17,16 @@
(function () {
'use strict';
- angular.module('cordHome', [])
- .controller('CordHomeCtrl', function ($log, $scope, $cookies, cordConfig, SubscriberUsers) {
-
- $scope.page.curr = 'dashboard';
-
- $scope.bundle_name = cordConfig.bundles[cordConfig.activeBundle].name;
- $scope.bundle_desc = cordConfig.bundles[cordConfig.activeBundle].desc;
-
- SubscriberUsers.query({subscriberId: $cookies.get('subscriberId')}).$promise
- .then(function(res){
- $scope.users = res;
- })
- .catch(function(){
- $log.error('Problem with resource', SubscriberUsers);
- });
-
- $log.debug('Cord Home Ctrl has been created.');
+ angular.module('mCord')
+ .directive('eNodeMap', function () {
+ return {
+ restric: 'E',
+ scope: {},
+ controllerAs: 'vm',
+ templateUrl: 'app/view/home/home.html',
+ controller: function($log){
+ $log.debug('Cord Home Ctrl has been created.');
+ }
+ }
});
}());
diff --git a/mCordPortal/src/app/view/login/login.html b/mCordPortal/src/app/view/login/login.html
index 426a2e9..178f21b 100644
--- a/mCordPortal/src/app/view/login/login.html
+++ b/mCordPortal/src/app/view/login/login.html
@@ -2,17 +2,17 @@
<div class="container login">
<div class="login-wrapper">
<h3 class="text-center">Subscriber Portal</h3>
- <form ng-submit="login()">
+ <form ng-submit="vm.login()">
<div class="form-group">
- <input class="form-control" ng-model="email" type="text" placeholder="email" required>
+ <input class="form-control" ng-model="vm.email" type="text" placeholder="email" required>
</div>
<div class="form-group">
- <input class="form-control" ng-model="password" type="password" placeholder="password" required>
+ <input class="form-control" ng-model="vm.password" type="password" placeholder="password" required>
</div>
<div class="form-group">
<button class="btn btn-primary btn-block" type="submit">
Log In
- <div class="loader small reverse inline" ng-show="loading === true"></div>
+ <div class="loader small reverse inline" ng-show="vm.loading === true"></div>
</button>
</div>
<div class="form-group" ng-show="error">
diff --git a/mCordPortal/src/app/view/login/login.js b/mCordPortal/src/app/view/login/login.js
index 170abcf..348fc42 100644
--- a/mCordPortal/src/app/view/login/login.js
+++ b/mCordPortal/src/app/view/login/login.js
@@ -17,31 +17,36 @@
(function () {
'use strict';
- angular.module('cordLogin', [])
- .controller('CordLoginCtrl', function ($log, $scope, $resource, $location, $window, User) {
+ angular.module('mCord')
+ .directive('cordLogin', function ($log, $location, User) {
- $scope.page.curr = 'login';
- $scope.loading = false;
+ return {
+ restrict: 'E',
+ templateUrl: 'app/view/login/login.html',
+ controllerAs: 'vm',
+ controller: function(){
- $scope.login = function () {
- if ($scope.email && $scope.password) {
- //getResource($scope.email);
- $scope.loading = true;
- User.login($scope.email, $scope.password)
- .then(function(user){
- $location.url('/');
- })
- .catch(function(e){
- $scope.error = true;
- })
- .finally(function(){
- $scope.loading = false;
- });;
+ this.loading = false;
- $scope.shared.login = $scope.email;
+ this.login = () => {
+ if (this.email && this.password) {
+ this.loading = true;
+ User.login(this.email, this.password)
+ .then(() => {
+ $location.url('/');
+ })
+ .catch(() => {
+ this.error = true;
+ })
+ .finally(() => {
+ this.loading = false;
+ });
+ }
+ };
+
+ $log.debug('Cord Login Ctrl has been created.');
}
- };
+ }
- $log.debug('Cord Login Ctrl has been created.');
});
}());
diff --git a/mCordPortal/src/app/view/bundle/available.html b/mCordPortal/src/app/view/services/available.html
similarity index 100%
rename from mCordPortal/src/app/view/bundle/available.html
rename to mCordPortal/src/app/view/services/available.html
diff --git a/mCordPortal/src/app/view/bundle/bundle.html b/mCordPortal/src/app/view/services/services.html
similarity index 100%
rename from mCordPortal/src/app/view/bundle/bundle.html
rename to mCordPortal/src/app/view/services/services.html
diff --git a/mCordPortal/src/app/view/bundle/bundle.js b/mCordPortal/src/app/view/services/services.js
similarity index 93%
rename from mCordPortal/src/app/view/bundle/bundle.js
rename to mCordPortal/src/app/view/services/services.js
index 310118b..6d23d5e 100644
--- a/mCordPortal/src/app/view/bundle/bundle.js
+++ b/mCordPortal/src/app/view/services/services.js
@@ -22,11 +22,10 @@
var basic = 'basic',
family = 'family';
- angular.module('cordBundle', [])
+ angular.module('mCord')
.controller('CordBundleCtrl', function ($log, $scope, $resource, cordConfig) {
var BundleData, resource,
getData;
- $scope.page.curr = 'bundle';
$scope.show = false;
// set the current bundle
@@ -66,7 +65,7 @@
})
.directive('bundleAvailable', function () {
return {
- templateUrl: 'app/view/bundle/available.html'
+ templateUrl: 'app/view/services/available.html'
};
});
}());
diff --git a/mCordPortal/src/app/view/user/ratingPanel.html b/mCordPortal/src/app/view/user/ratingPanel.html
deleted file mode 100644
index 04ee430..0000000
--- a/mCordPortal/src/app/view/user/ratingPanel.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--Partial HTML for rating panel directive-->
-<div id="rating-panel">
- <div ng-cloak class="ng-hide ng-cloak panel" ng-show="ratingsShown">
- <table>
- <tr>
- <th class="title">Category</th>
- <th ng-repeat="rating in level_order">{{rating}}</th>
- </tr>
- <tr ng-repeat="cat in category_order">
- <td class="title">{{cat}}</td>
- <td ng-repeat="r in level_order">
- <div ng-if="prohibitedSites[r][cat]">
- <icon size="15" id="xMark"></icon>
- </div>
- <div ng-if="!prohibitedSites[r][cat]">
- <icon size="15" id="checkMark"></icon>
- </div>
- </td>
- </tr>
- </table>
- </div>
-</div>
\ No newline at end of file
diff --git a/mCordPortal/src/app/view/user/user.html b/mCordPortal/src/app/view/user/user.html
deleted file mode 100644
index c72b7d7..0000000
--- a/mCordPortal/src/app/view/user/user.html
+++ /dev/null
@@ -1,41 +0,0 @@
-<!-- Users page partial html -->
-<div class="container">
- <div id="user" class="row">
- <div class="col-xs-12">
- <table class="table">
- <thead>
- <tr>
- <th></th>
- <th class="form-inline">
- Name <input ng-model="q.name" type="text" class="form-control">
- </th>
- <th>Last Login</th>
- <th ng-if="isFamily">
- Video Optimization:
- </th>
- <th ng-if="isFamily"></th>
- </tr>
- </thead>
- <tr ng-repeat="user in users | filter:q" class="animate-repeat" ng-show="users.length > 0">
- <td class="avatar">
- <img class="img-rounded" ng-src="{{'/imgs/' + user.icon_id + '.jpg'}}">
- </td>
- <td>{{user.name}}</td>
- <td>{{shared.userActivity[user.id]}}</td>
- <td ng-if="isFamily">
- <select class="form-control" ng-model="user.level" ng-options="l for l in levels" ng-change="updateLevel(user)">
- </select>
- </td>
- <td ng-if="isFamily" style="width: 46px">
- <user-updated-tick user="user">Saved</user-updated-tick>
- </td>
- </tr>
- <tr ng-show="!users">
- <td colspan="4">
- <div class="loader"></div>
- </td>
- </tr>
- </table>
- </div>
- </div>
-</div>
\ No newline at end of file
diff --git a/mCordPortal/src/app/view/user/user.js b/mCordPortal/src/app/view/user/user.js
deleted file mode 100644
index 78a3a61..0000000
--- a/mCordPortal/src/app/view/user/user.js
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-(function () {
- 'use strict';
-
- angular.module('cordUser', [])
- .controller('CordUserCtrl', function ($log, $scope, $resource, $timeout, $filter, $cookies, SubscriberUsers, cordConfig, SubscriberUsersUrlFilterLevel) {
-
- $scope.page.curr = 'user';
- $scope.isFamily = false;
- $scope.newLevels = {};
- $scope.showCheck = false;
- $scope.ratingsShown = false;
-
- SubscriberUsers.query({subscriberId: $cookies.get('subscriberId')}).$promise
- .then(function(res){
- $scope.isFamily = cordConfig.bundles[cordConfig.activeBundle].id === 'family';
- // if bundle is family search for url_filter level
- if ($scope.isFamily) {
- angular.forEach(cordConfig.bundles[cordConfig.activeBundle].functions, function(fn){
- if(fn.id === 'video'){
- console.log(fn);
- $scope.levels = fn.params.levels;
- }
- });
- }
- $scope.users = res;
- })
- .catch(function () {
- $log.error('Problem with resource', SubscriberUsers);
- });
-
- $scope.updateLevel = function(user){
- // TODO save this data and show a confirmation to the user
- // NOTE subscriberId should be retrieved by login
- SubscriberUsersUrlFilterLevel.updateUrlFilterLevel(1, user.id, user.level)
- .then(function(){
- user.updated = true;
- })
- .catch(function(e){
- throw new Error(e);
- });
- };
-
- $scope.showRatings = function () {
- $scope.ratingsShown = !$scope.ratingsShown;
- };
-
- $log.debug('Cord User Ctrl has been created.');
- })
- .directive('userUpdatedTick', function($timeout){
- return {
- restric: 'E',
- scope: {
- user: '='
- },
- template: '<span class="icon-saved animate" ng-show="saved"></span>',
- link: function(scope, elem){
- scope.saved = false;
- scope.$watch('user.updated', function(val){
- if(val){
- scope.saved = true;
- $timeout(function(){
- scope.saved = false;
- }, 3000);
- }
- });
- }
- }
- });
-}());