Refactored around to have same style in code
diff --git a/views/ngXosViews/subscriberPortal/src/app/view/bundle/bundle.js b/views/ngXosViews/subscriberPortal/src/app/view/bundle/bundle.js
index 054c703..310118b 100644
--- a/views/ngXosViews/subscriberPortal/src/app/view/bundle/bundle.js
+++ b/views/ngXosViews/subscriberPortal/src/app/view/bundle/bundle.js
@@ -64,10 +64,9 @@
$log.debug('Cord Bundle Ctrl has been created.');
})
-
- .directive('bundleAvailable', [function () {
+ .directive('bundleAvailable', function () {
return {
templateUrl: 'app/view/bundle/available.html'
};
- }]);
+ });
}());
diff --git a/views/ngXosViews/subscriberPortal/src/app/view/home/home.js b/views/ngXosViews/subscriberPortal/src/app/view/home/home.js
index 454972c..ea35436 100644
--- a/views/ngXosViews/subscriberPortal/src/app/view/home/home.js
+++ b/views/ngXosViews/subscriberPortal/src/app/view/home/home.js
@@ -17,26 +17,22 @@
(function () {
'use strict';
- var urlSuffix = '/rs/dashboard';
-
angular.module('cordHome', [])
- .controller('CordHomeCtrl', [
- '$log', '$scope', '$resource', '$filter', 'cordConfig', 'SubscriberUsers', 'Helpers',
- function ($log, $scope, $resource, $filter, cordConfig, SubscriberUsers, Helpers) {
- var DashboardData, resource;
- $scope.page.curr = 'dashboard';
+ .controller('CordHomeCtrl', function ($log, $scope, cordConfig, SubscriberUsers) {
- // NOTE subscriberId should be retrieved by login
- SubscriberUsers.query({subscriberId: 1}).$promise
- .then(function(res){
- $scope.bundle_name = cordConfig.bundles[cordConfig.activeBundle].name;
- $scope.bundle_desc = cordConfig.bundles[cordConfig.activeBundle].desc;
- $scope.users = res.users;
- })
- .catch(function(){
- $log.error('Problem with resource', resource);
- });
+ $scope.page.curr = 'dashboard';
- $log.debug('Cord Home Ctrl has been created.');
- }]);
+ // NOTE subscriberId should be retrieved by login
+ SubscriberUsers.query({subscriberId: 1}).$promise
+ .then(function(res){
+ $scope.bundle_name = cordConfig.bundles[cordConfig.activeBundle].name;
+ $scope.bundle_desc = cordConfig.bundles[cordConfig.activeBundle].desc;
+ $scope.users = res.users;
+ })
+ .catch(function(){
+ $log.error('Problem with resource', SubscriberUsers);
+ });
+
+ $log.debug('Cord Home Ctrl has been created.');
+ });
}());
diff --git a/views/ngXosViews/subscriberPortal/src/app/view/login/login.js b/views/ngXosViews/subscriberPortal/src/app/view/login/login.js
index 8a3f2cf..c902480 100644
--- a/views/ngXosViews/subscriberPortal/src/app/view/login/login.js
+++ b/views/ngXosViews/subscriberPortal/src/app/view/login/login.js
@@ -16,37 +16,25 @@
(function () {
'use strict';
- var urlSuffix = '/rs/login';
angular.module('cordLogin', [])
- .controller('CordLoginCtrl', [
- '$log', '$scope', '$resource', '$location', '$window', 'User',
- function ($log, $scope, $resource, $location, $window, User) {
- var LoginData, resource;
- $scope.page.curr = 'login';
+ .controller('CordLoginCtrl', function ($log, $scope, $resource, $location, $window, User) {
- function getResource(email) {
- LoginData = $resource($scope.shared.url + urlSuffix + '/' + email);
- resource = LoginData.get({},
- function () {
- $location.url('/home');
- $window.location.href = $location.absUrl();
- });
+ $scope.page.curr = 'login';
+
+ $scope.login = function () {
+ if ($scope.email && $scope.password) {
+ //getResource($scope.email);
+
+ User.login($scope.email, $scope.password)
+ .then(function(user){
+ $location.url('/home');
+ });
+
+ $scope.shared.login = $scope.email;
}
+ };
- $scope.login = function () {
- if ($scope.email && $scope.password) {
- //getResource($scope.email);
-
- User.login($scope.email, $scope.password)
- .then(function(user){
- $location.url('/home');
- });
-
- $scope.shared.login = $scope.email;
- }
- };
-
- $log.debug('Cord Login Ctrl has been created.');
- }]);
+ $log.debug('Cord Login Ctrl has been created.');
+ });
}());
diff --git a/views/ngXosViews/subscriberPortal/src/app/view/user/user.html b/views/ngXosViews/subscriberPortal/src/app/view/user/user.html
index 9822b57..052913e 100644
--- a/views/ngXosViews/subscriberPortal/src/app/view/user/user.html
+++ b/views/ngXosViews/subscriberPortal/src/app/view/user/user.html
@@ -33,19 +33,6 @@
</select>
</td>
</tr>
- <tr>
- <td class="buttons">
- <div ng-show="showCheck">
- <icon size="20px" id="checkMark"></icon>
- </div>
- <input type="reset" value="Cancel"
- ng-click="cancelChanges(changeLevels)"
- ng-disabled="changeLevels.$pristine">
- <input type="button" value="Apply"
- ng-click="applyChanges(changeLevels)"
- ng-disabled="changeLevels.$pristine">
- </td>
- </tr>
</table>
</form>
</div>
diff --git a/views/ngXosViews/subscriberPortal/src/app/view/user/user.js b/views/ngXosViews/subscriberPortal/src/app/view/user/user.js
index bc75afd..6eff78a 100644
--- a/views/ngXosViews/subscriberPortal/src/app/view/user/user.js
+++ b/views/ngXosViews/subscriberPortal/src/app/view/user/user.js
@@ -17,127 +17,52 @@
(function () {
'use strict';
- var bundleUrlSuffix = '/rs/bundle',
- userUrlSuffix = '/rs/users',
- family = 'family',
- url_filter = 'url_filter';
-
angular.module('cordUser', [])
- .controller('CordUserCtrl', ['$log', '$scope', '$resource', '$timeout', '$filter', 'SubscriberUsers', 'cordConfig',
- function ($log, $scope, $resource, $timeout, $filter, SubscriberUsers, cordConfig) {
+ .controller('CordUserCtrl', function ($log, $scope, $resource, $timeout, $filter, SubscriberUsers, cordConfig) {
- $scope.page.curr = 'user';
- $scope.isFamily = false;
- $scope.newLevels = {};
- $scope.showCheck = false;
- $scope.ratingsShown = false;
+ $scope.page.curr = 'user';
+ $scope.isFamily = false;
+ $scope.newLevels = {};
+ $scope.showCheck = false;
+ $scope.ratingsShown = false;
- // === Get data functions ---
-
- // NOTE subscriberId should be retrieved by login
- SubscriberUsers.query({subscriberId: 1}).$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 === 'url_filter'){
- $scope.levels = fn.params.levels;
- }
- });
- }
-
- $scope.users = res.users;
- })
- .catch(function () {
- $log.error('Problem with resource', SubscriberUsers);
- });
-
- $scope.updateLevel = function(user){
- user.$save()
- .then(function(){
- console.log('saved');
- })
- .catch(function(e){
- throw new Error(e);
- });
- };
-
- //function getUsers(url) {
- // var UserData, userResource;
- // UserData = $resource(url);
- // userResource = UserData.get({},
- // // success
- // function () {
- // $scope.users = userResource.users;
- // if ($.isEmptyObject($scope.shared.userActivity)) {
- // $scope.users.forEach(function (user) {
- // var date = randomDate(new Date(2015, 0, 1),
- // new Date());
- //
- // $scope.shared.userActivity[user.id] =
- // $filter('date')(date, 'mediumTime');
- // });
- // }
- // },
- // // error
- // function () {
- // $log.error('Problem with resource', userResource);
- // }
- // );
- //}
- //
- //getUsers($scope.shared.url + userUrlSuffix);
-
- // === Form functions ---
-
- function levelUrl(id, level) {
- return $scope.shared.url +
- userUrlSuffix + '/' + id + '/apply/url_filter/level/' + level;
- }
-
- // NOTE This will trigger one request for each user to update url_filter level
- $scope.applyChanges = function (changeLevels) {
- var requests = [];
-
- if ($scope.users) {
- $.each($scope.users, function (index, user) {
- var id = user.id,
- level = user.profile.url_filter.level;
- if ($scope.newLevels[id] !== level) {
- requests.push(levelUrl(id, $scope.newLevels[id]));
+ // NOTE subscriberId should be retrieved by login
+ SubscriberUsers.query({subscriberId: 1}).$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 === 'url_filter'){
+ $scope.levels = fn.params.levels;
}
});
-
- $.each(requests, function (index, req) {
- getUsers(req);
- });
}
- changeLevels.$setPristine();
- $scope.showCheck = true;
- $timeout(function () {
- $scope.showCheck = false;
- }, 3000);
- };
- $scope.cancelChanges = function (changeLevels) {
- if ($scope.users) {
- $.each($scope.users, function (index, user) {
- $scope.newLevels[user.id] = user.profile.url_filter.level;
- });
- }
- changeLevels.$setPristine();
- $scope.showCheck = false;
- };
+ $scope.users = res.users;
+ })
+ .catch(function () {
+ $log.error('Problem with resource', SubscriberUsers);
+ });
- $scope.showRatings = function () {
- $scope.ratingsShown = !$scope.ratingsShown;
- };
+ $scope.updateLevel = function(user){
+ // TODO save this data and show a confirmation to the user
+ user.$save()
+ .then(function(){
+ console.log('saved');
+ })
+ .catch(function(e){
+ throw new Error(e);
+ });
+ };
- $log.debug('Cord User Ctrl has been created.');
- }])
+ $scope.showRatings = function () {
+ $scope.ratingsShown = !$scope.ratingsShown;
+ };
- .directive('ratingsPanel', ['$log', function ($log) {
+ $log.debug('Cord User Ctrl has been created.');
+ })
+ .directive('ratingsPanel', function ($log) {
return {
templateUrl: 'app/view/user/ratingPanel.html',
link: function (scope, elem, attrs) {
@@ -177,6 +102,5 @@
});
}
};
- }]);
-
+ });
}());