+ * @description
+ * gets notifications next page
+ */
$scope.nextPage = function () {
if ($scope.busyLoading || $scope.finishedLoading) {
@@ -32,6 +57,16 @@ angular.module('ldrWebApp').controller('ActivityCtrl', [
});
};
+ /**
+ * @ngdoc
+ * @name ActivityCtrl#markAsRead
+ * @methodOf ActivityCtrl
+ * @param {Object} activity - activity to mark as read
+ * @example
+ *
+ * @description
+ * marks given notification as read
+ */
$scope.markAsRead = function (activity) {
if (!activity.viewed) {
Activity.viewed({id: activity._id}, {}).$promise.then(function (data) {
@@ -43,6 +78,18 @@ angular.module('ldrWebApp').controller('ActivityCtrl', [
});
}
};
+
+ /**
+ * @ngdoc
+ * @name ActivityCtrl#visitNotification
+ * @methodOf ActivityCtrl
+ * @param {Object} activity - activity to mark as read
+ * @example
+ *
+ * @description
+ * marks given notification as read and redirects to pile view
+ */
$scope.visitNotification = function (activity) {
$scope.markAsRead(activity);
$state.go('app.map.pile.view', {id: activity.pile._id});
diff --git a/client/app/admin/controllers/admin.controller.js b/client/app/admin/controllers/admin.controller.js
index 3f642cc..e634057 100644
--- a/client/app/admin/controllers/admin.controller.js
+++ b/client/app/admin/controllers/admin.controller.js
@@ -1,6 +1,26 @@
'use strict';
angular.module('ldrWebApp')
+ /**
+ * @ngdoc controller
+ * @name AdminCtrl
+ * @description admin's view main controller
+ * @requires $state
+ * @requires $scope
+ * @requires LxDialogService
+ * @requires LxNotificationService
+ * @requires Pile
+ * @requires HelperService
+ * @requires $filter
+ * @requires $q
+ * @requires User
+ * @requires $translate
+ * @requires responseHandler
+ * @property {Object} state - current state object
+ * @property {Object} datepicker - datepicker's information
+ * @property {Boolean} clickable1 - calendar opened flag
+ * @property {Boolean} clickable2 - calendar opened flag
+ */
.controller('AdminCtrl', ['$state', '$scope', 'LxDialogService', 'LxNotificationService', 'Pile', 'HelperService',
'$filter', '$q', 'User', '$translate', 'responseHandler',
function ($state, $scope, LxDialogService, LxNotificationService, Pile, HelperService,
@@ -15,13 +35,22 @@ angular.module('ldrWebApp')
LxDialogService.open(dialogId);
};
+ /**
+ * @ngdoc
+ * @name AdminCtrl#getUsersCSV
+ * @methodOf AdminCtrl
+ * @example
+ *
+ * @description
+ * formats stats, inserts header and all data
+ * @returns {Promise} Resolves to an empty response/error
+ */
$scope.getUsersCSV = function () {
var deferred = $q.defer();
User.getUsersStatistics().$promise.then(function (resp) {
var stats = responseHandler.getData(resp);
- //format stats
var formatted = [];
- //first, insert the header
formatted.push({
email: 'Email',
county: 'County',
@@ -30,7 +59,6 @@ angular.module('ldrWebApp')
role: 'Role',
created_at: 'Created at'
});
- //then insert all data
for (var i = 0; i < stats.length; i++) {
formatted.push({
email: stats[i].email,
@@ -46,6 +74,17 @@ angular.module('ldrWebApp')
return deferred.promise;
};
+ /**
+ * @ngdoc
+ * @name AdminCtrl#getCountry
+ * @methodOf AdminCtrl
+ * @example
+
+ * @description
+ * prepares country stats array to generate CSV from
+ * @returns {Array} countryArray - country stats array to generate CSV from
+ */
$scope.getCountry = function (countryArray) {
if (!angular.isArray(countryArray)) {
countryArray = [countryArray];
@@ -57,12 +96,6 @@ angular.module('ldrWebApp')
return $scope.countryArray;
};
- /*
- *Country report creation based on datepicker validation
- *see moment.js library function details
- *watcher to check validations
- *generate report
- */
$scope.createCountryReport = function (dialogId) {
LxDialogService.close(dialogId);
@@ -71,6 +104,13 @@ angular.module('ldrWebApp')
};
+ /**
+ * @ngdoc
+ * @name AdminCtrl#$watchCollection
+ * @methodOf AdminCtrl
+ * @description
+ * watcher to check validations and then generate country report
+ */
$scope.$watchCollection('datepicker', function () {
@@ -127,7 +167,13 @@ angular.module('ldrWebApp')
LxDialogService.close(dialogId);
};
- // evaluate calendar is open or not
+ /**
+ * @ngdoc
+ * @name AdminCtrl#switchBoolean
+ * @methodOf AdminCtrl
+ * @description
+ * check if calendar is open
+ */
$scope.switchBoolean = function (bool) {
var calendar = document.getElementsByClassName('lx-date-picker--is-shown');
diff --git a/client/app/admin/controllers/adminStatisticsCtrl.js b/client/app/admin/controllers/adminStatisticsCtrl.js
index 5fd68c5..977c7c2 100644
--- a/client/app/admin/controllers/adminStatisticsCtrl.js
+++ b/client/app/admin/controllers/adminStatisticsCtrl.js
@@ -1,6 +1,23 @@
'use strict';
angular.module('ldrWebApp')
+ /**
+ * @ngdoc controller
+ * @name StatisticsCtrl
+ * @description admin statistics controller
+ * @requires $scope
+ * @requires leafletData
+ * @requires $timeout
+ * @requires Pile
+ * @requires LxDialogService
+ * @requires LxNotificationService
+ * @requires LxProgressService
+ * @requires $filter
+ * @requires HelperService
+ * @requires responseHandler
+ * @property {Boolean} openInfo - open info modal flag
+ * @property {Object} defaultStyle - layer style config object
+ */
.controller('StatisticsCtrl', ['$scope',
'leafletData',
'$timeout',
@@ -32,6 +49,13 @@ angular.module('ldrWebApp')
style: $scope.defaultStyle
});
+ /**
+ * @ngdoc
+ * @name StatisticsCtrl#calculateMapWidth
+ * @methodOf StatisticsCtrl
+ * @description
+ * calculates map with
+ */
$scope.calculateMapWidth = function () {
if (window.innerWidth) {
var leftMenuWidth = (window.innerWidth / 12) * 3;
@@ -51,12 +75,31 @@ angular.module('ldrWebApp')
}
};
+ /**
+ * @ngdoc
+ * @name StatisticsCtrl#getArray
+ * @methodOf StatisticsCtrl
+ * @example
+
+ * @description
+ * prepares county stats array to generate CSV from
+ * @returns {Array} county - country stats array to generate CSV from
+ */
$scope.getArray = function (countyArray) {
$scope.data = [countyArray];
$scope.data.unshift(HelperService.headerOnCsv('County'));
return $scope.data;
};
+ /**
+ * @ngdoc
+ * @name StatisticsCtrl#onMapClick
+ * @methodOf StatisticsCtrl
+ * @description
+ * gets statistics for clicked county, sets show info flag to true
+ */
function onMapClick(e) {
$scope.featureSiruta = leafletPip.pointInLayer([e.latlng.lng, e.latlng.lat], gjLayer, true)[0].feature.properties.SIRUTA;
$scope.featureName = leafletPip.pointInLayer([e.latlng.lng, e.latlng.lat], gjLayer, true)[0].feature.properties.NAME;
@@ -72,6 +115,13 @@ angular.module('ldrWebApp')
}
}
+ /**
+ * @ngdoc
+ * @name StatisticsCtrl#highlightFeature
+ * @methodOf StatisticsCtrl
+ * @description
+ * sets style for highlighted county
+ */
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
@@ -87,6 +137,13 @@ angular.module('ldrWebApp')
gjLayer.resetStyle(e.target);
}
+ /**
+ * @ngdoc
+ * @name StatisticsCtrl#onEachFeature
+ * @methodOf StatisticsCtrl
+ * @description
+ * sets options for each layer
+ */
function onEachFeature(polygon, layer) {
layer.on({
click: onMapClick,
@@ -96,6 +153,14 @@ angular.module('ldrWebApp')
});
}
+ /**
+ * @ngdoc
+ * @name StatisticsCtrl#calculateMapStatisticsResolution
+ * @methodOf StatisticsCtrl
+ * @description
+ * calculates statistics map height
+ * @returns {Integer} statisticsMap - statistics map height
+ */
$scope.calculateMapStatisticsResolution = function () {
if (window.innerWidth > 1023) {
$scope.statisticsMap = window.innerHeight - 150 - 40;
@@ -105,8 +170,13 @@ angular.module('ldrWebApp')
return $scope.statisticsMap;
};
- //CREATE leaflet map for statistics
-
+ /**
+ * @ngdoc
+ * @name StatisticsCtrl#createMap
+ * @methodOf StatisticsCtrl
+ * @description
+ * creates leaflet map object for statistics, mapbox token is required
+ */
self.createMap = function () {
return {
defaults: {
@@ -127,7 +197,7 @@ angular.module('ldrWebApp')
baselayers: {
xyz: {
name: 'OpenStreetMap (XYZ)',
- url: 'https://api.mapbox.com/v4/mapbox.streets-basic/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoicXVhbGl0YW5jZSIsImEiOiJkYTY0ODQzMGM1MDFlOGVhM2FiZjc3M2ZkYmQ2MjA0NSJ9.3bxLXwcDaG_V0H3reJzLBg',
+ url: 'https://api.mapbox.com/v4/mapbox.streets-basic/{z}/{x}/{y}.png?access_token=*********',
type: 'xyz'
}
},
@@ -136,11 +206,18 @@ angular.module('ldrWebApp')
};
};
+ /**
+ * @ngdoc
+ * @name StatisticsCtrl#centerMap
+ * @methodOf StatisticsCtrl
+ * @description
+ * map is repositioned on Roumania's center
+ */
$scope.centerMap = function () {
angular.extend($scope.map, {
center: {
zoom: 7,
- lat: 45.834402, //middle of romania
+ lat: 45.834402,
lng: 24.996989
}
});
diff --git a/client/app/admin/controllers/adminUserCtrl.js b/client/app/admin/controllers/adminUserCtrl.js
index 859dabe..043a98d 100644
--- a/client/app/admin/controllers/adminUserCtrl.js
+++ b/client/app/admin/controllers/adminUserCtrl.js
@@ -1,5 +1,15 @@
'use strict';
-
+/**
+ * @ngdoc controller
+ * @name AdminUserCtrl
+ * @description admin user controller
+ * @requires $scope
+ * @requires User
+ * @requires $state
+ * @requires Auth
+ * @requires responseHandler
+ * @property {Boolean} user - selected user object
+ */
angular.module('ldrWebApp')
.controller('AdminUserCtrl', ['$scope',
'User',
diff --git a/client/app/admin/controllers/adminUsersCtrl.js b/client/app/admin/controllers/adminUsersCtrl.js
index f9479a6..34d150d 100644
--- a/client/app/admin/controllers/adminUsersCtrl.js
+++ b/client/app/admin/controllers/adminUsersCtrl.js
@@ -1,6 +1,32 @@
'use strict';
angular.module('ldrWebApp')
+ /**
+ * @ngdoc controller
+ * @name AdminUsersCtrl
+ * @description admin statistics controller
+ * @requires $scope
+ * @requires User
+ * @requires CountyService
+ * @requires CountryService
+ * @requires LxDialogService
+ * @requires LxNotificationService
+ * @requires HelperService
+ * @requires Auth
+ * @requires $state
+ * @requires $translate
+ * @requires responseHandler
+ * @property {Object} currentUser - current user object
+ * @property {Object} supervisor - supervisor to create object
+ * @property {Object} data - data to show
+ * @property {Boolean} disableBtn - filter button flag
+ * @property {Object} user - user to search object
+ * @property {Object} all_counties - all counties object
+ * @property {Object} all_countries - all countries object
+ * @property {Object} state - current state object
+ * @property {Object} allUserRoles - all roles object
+ * @property {Object} config_obj - params object
+ */
.controller('AdminUsersCtrl', [
'$scope',
'User',
@@ -89,15 +115,23 @@ angular.module('ldrWebApp')
};
/**
+ * @ngdoc
+ * @name AdminUsersCtrl#$watch
+ * @methodOf AdminUsersCtrl
* @description watch for changes on the config page that may be triggered when press on
- * the page skipper select and then get the according page data
- * @return {Undefined}
+ * the page skipper select and then gets the according page data
*/
$scope.$watch('config_obj.page', function () {
$scope.getUsers();
});
- //get users and pagination info
+ /**
+ * @ngdoc
+ * @name AdminUsersCtrl#getUsers
+ * @methodOf AdminUsersCtrl
+ * @description
+ * gets users and pagination info
+ */
$scope.getUsers = function () {
User.all($scope.config_obj, function (data, headers) {
$scope.data.users = responseHandler.getData(data);
@@ -106,16 +140,27 @@ angular.module('ldrWebApp')
});
};
- //function to reset filters
+ /**
+ * @ngdoc
+ * @name AdminUsersCtrl#resetFilter
+ * @methodOf AdminUsersCtrl
+ * @description
+ * resets filters
+ */
$scope.resetFilter = function (property, fetchResults) {
$scope.config_obj[property] = null;
if (fetchResults)
$scope.filter(null, null, true);
};
- // updates config object & fetches piles if required
- // fetchresults get users and reset the page counter
- // gets property to filter by and the value, and modify the config object and do the query
+ /**
+ * @ngdoc
+ * @name AdminUsersCtrl#filter
+ * @methodOf AdminUsersCtrl
+ * @description
+ * updates config object & fetches piles if required, fetch results get users and reset the page counter,
+ * gets property to filter by and the value, and modify the config object and do the query
+ */
$scope.filter = function (property, value, fetchResults) {
if (property) {
$scope.config_obj[property] = (value) ? value :
@@ -134,9 +179,10 @@ angular.module('ldrWebApp')
};
/**
- * Enable/disable filter and reset filter buttons
- * @name enableFilterBtn
- * @return {undefined}
+ * @ngdoc
+ * @name AdminUsersCtrl#enableFilterBtn
+ * @methodOf AdminUsersCtrl
+ * @description enable/disable filter and reset filter buttons
*/
$scope.enableFilterBtn = function () {
$scope.clearFilterEmptyVals();
@@ -150,9 +196,10 @@ angular.module('ldrWebApp')
};
/**
- * Clear the filters with empty values
- * @name clearFilterEmptyVals
- * @return {undefined}
+ * @ngdoc
+ * @name AdminUsersCtrl#clearFilterEmptyVals
+ * @methodOf AdminUsersCtrl
+ * @description clear the filters with empty values
*/
$scope.clearFilterEmptyVals = function () {
angular.forEach($scope.user, function (value, key) {
@@ -164,9 +211,10 @@ angular.module('ldrWebApp')
};
/**
- * generate filters from the user selections
- * @name filterUsers
- * @return {undefined}
+ * @ngdoc
+ * @name AdminUsersCtrl#filterUsers
+ * @methodOf AdminUsersCtrl
+ * @description generate filters from the user selections
*/
$scope.filterUsers = function () {
var index = 0;
@@ -182,19 +230,10 @@ angular.module('ldrWebApp')
});
};
- /**
- *
- * @name setFetchResults
- * @param index
- * @returns {boolean}
- */
$scope.setFetchResults = function (index) {
return (Object.keys($scope.user).length === index);
};
- /**
- *
- */
$scope.resetUserFilters = function () {
$scope.disableBtn = true;
angular.forEach($scope.user, function (value, key) {
@@ -212,7 +251,6 @@ angular.module('ldrWebApp')
}
};
- //reset page on pagination
$scope.resetPage = function () {
$scope.config_obj.page = 1;
};
@@ -227,9 +265,6 @@ angular.module('ldrWebApp')
$scope.getUsers();
};
- /*
- Modal functions start from here
- */
$scope.alertAdmin = function (dialogId, user) {
$scope.temp_user = user;
LxDialogService.open(dialogId);
@@ -251,7 +286,18 @@ angular.module('ldrWebApp')
LxNotificationService.info($translate.instant('views.usersList.noChanges'));
};
- //creates a supervisor after validation and sync it on the list until refresh
+ /**
+ * @ngdoc
+ * @name AdminUsersCtrl#createSupervisor
+ * @methodOf AdminUsersCtrl
+ * @param {String} dialogId - new supervisor dialog id
+ * @param {Object} form - new supervisor form object
+ * @example
+ *