From 063e57efcab966e1fec29a22392bc0b65bc3f7a4 Mon Sep 17 00:00:00 2001 From: gmanifavas Date: Wed, 4 Nov 2020 17:10:26 +0200 Subject: [PATCH 1/3] [UNIONVMS-4866] Add selection for exporting activities to csv. --- .../activityReportsList.html | 6 + .../activityReportsList.js | 10 ++ .../activityReportsList.less | 155 +++++++++--------- .../service/activity/activityRestService.js | 12 ++ .../app/service/activity/activityService.js | 28 +++- 5 files changed, 136 insertions(+), 75 deletions(-) diff --git a/unionvms-web/app/partial/activity/activityReportsList/activityReportsList.html b/unionvms-web/app/partial/activity/activityReportsList/activityReportsList.html index dc0ff7be3..373dd3dbb 100644 --- a/unionvms-web/app/partial/activity/activityReportsList/activityReportsList.html +++ b/unionvms-web/app/partial/activity/activityReportsList/activityReportsList.html @@ -13,6 +13,12 @@
+
+ +
+
+ +
@@ -69,7 +69,7 @@
@@ -81,7 +81,7 @@
@@ -93,7 +93,7 @@
@@ -105,7 +105,7 @@
@@ -117,7 +117,7 @@
@@ -129,7 +129,7 @@
@@ -237,4 +237,4 @@ - \ No newline at end of file + diff --git a/unionvms-web/app/partial/activity/tripReportsList/tripReportsList.html b/unionvms-web/app/partial/activity/tripReportsList/tripReportsList.html index 90a169007..41ba4488b 100644 --- a/unionvms-web/app/partial/activity/tripReportsList/tripReportsList.html +++ b/unionvms-web/app/partial/activity/tripReportsList/tripReportsList.html @@ -1,6 +1,12 @@
+
+ +
+
+ +
@@ -59,14 +65,14 @@
@@ -95,7 +101,7 @@
diff --git a/unionvms-web/app/partial/activity/tripReportsList/tripReportsList.js b/unionvms-web/app/partial/activity/tripReportsList/tripReportsList.js index acfba346a..fd1aae900 100644 --- a/unionvms-web/app/partial/activity/tripReportsList/tripReportsList.js +++ b/unionvms-web/app/partial/activity/tripReportsList/tripReportsList.js @@ -21,7 +21,7 @@ copy of the GNU General Public License along with the IFDM Suite. If not, see {@link unionvmsWeb.activityRestFactory}

+ * @param activityRestFactory {service} The REST factory for the activity module

{@link unionvmsWeb.activityRestFactory}

* @description * REST services for the activity module */ @@ -173,7 +176,7 @@ angular.module('unionvmsWeb').factory('activityRestFactory', function ($resource var activityService = { /** * Get the user preferences for the activty module - * + * * @memberof activityRestService * @public * @returns {Promise} A promise with either the user preferences of the activity module or reject error @@ -190,7 +193,7 @@ angular.module('unionvmsWeb').factory('activityRestFactory', function ($resource }, /** * Get a list of fishing activity reports according to search criteria - * + * * @memberof activityRestService * @public * @param {Object} data - The search criteria and table pagination data object @@ -228,7 +231,7 @@ angular.module('unionvmsWeb').factory('activityRestFactory', function ($resource }, /** * Get the history for a FA report - * + * * @memberof activityRestService * @public * @param {Number} refId - The reference ID @@ -264,7 +267,7 @@ angular.module('unionvmsWeb').factory('activityRestFactory', function ($resource }, /** * Get the vessel and roles details of a specific trip - * + * * @memberof activityRestService * @public * @param {String} id - The trip id of the selected trip @@ -281,7 +284,7 @@ angular.module('unionvmsWeb').factory('activityRestFactory', function ($resource }, /** * Get the message type count of a specific trip - * + * * @memberof activityRestService * @public * @param {String} id - The trip id of the selected trip @@ -298,7 +301,7 @@ angular.module('unionvmsWeb').factory('activityRestFactory', function ($resource }, /** * Get the trip reports of a specific trip - * + * * @memberof activityRestService * @public * @param {String} id - The trip id of the selected trip @@ -315,7 +318,7 @@ angular.module('unionvmsWeb').factory('activityRestFactory', function ($resource }, /** * Get the trip map data - * + * * @memberof activityRestService * @public * @param {String} id - The trip id of the selected trip @@ -348,8 +351,8 @@ angular.module('unionvmsWeb').factory('activityRestFactory', function ($resource return deferred.promise; }, /** - * Get the Catches Evolution Details. - * + * Get the Catches Evolution Details. + * * @memberof activityRestService * @public * @param {String} id - The trip id of the selected trip @@ -367,11 +370,11 @@ angular.module('unionvmsWeb').factory('activityRestFactory', function ($resource }, /** * Get Fishing Activity details by type - * + * * @memberof activityRestService * @public * @param {String} type - The fisihing activity type (e.g. departure, landing, arrival) - * @param {Object} payload - The post payload containing the activity id (mandatory) and the trip id (not mandatory and to be used only in the report tab) + * @param {Object} payload - The post payload containing the activity id (mandatory) and the trip id (not mandatory and to be used only in the report tab) * @returns {Promise} A promise with either the fishing activity details or reject error */ getFishingActivityDetails: function(type, payload){ @@ -387,7 +390,7 @@ angular.module('unionvmsWeb').factory('activityRestFactory', function ($resource }, /** * Get commchannels data - * + * * @memberof activityRestService * @public * @returns {Promise} A promise with either the fishing activity details or reject error @@ -408,7 +411,16 @@ angular.module('unionvmsWeb').factory('activityRestFactory', function ($resource }, function () { console.error('Failed to export activities to CSV'); return {}; - }); + }); + }, + exportTripListToCsv: function (query) { + return activityRestFactory.exportTripListToCsv(query).then( + function (response) { + return response.data; + }, function () { + console.error('Failed to export trips to CSV'); + return {}; + }); } }; diff --git a/unionvms-web/app/service/activity/activityService.js b/unionvms-web/app/service/activity/activityService.js index 96b55c816..c3ed4cc42 100644 --- a/unionvms-web/app/service/activity/activityService.js +++ b/unionvms-web/app/service/activity/activityService.js @@ -506,10 +506,11 @@ angular.module('unionvmsWeb').factory('activityService',function(locale, activit return comboList; }; - actServ.csvLoading = false; + actServ.activitiesCsvLoading = false; + actServ.tripsCsvLoading = false; actServ.exportActivityListToCsv = function() { - actServ.csvLoading = true; + actServ.activitiesCsvLoading = true; var simpleCriteria = {}; if (angular.isDefined(actServ['reportsList'].searchObject.simpleCriteria)){ @@ -528,7 +529,31 @@ angular.module('unionvmsWeb').factory('activityService',function(locale, activit var file = new Blob([data], {type: 'text/csv;charset=UTF-8'}); $window.saveAs(file, "csvExport" + moment().format("YYYY-MM-DDTHH:mm") + ".csv"); } - actServ.csvLoading = false; + actServ.activitiesCsvLoading = false; + }) + }; + + actServ.exportTripListToCsv = function() { + actServ.tripsCsvLoading = true; + + var simpleCriteria = {}; + if (angular.isDefined(actServ['tripsList'].searchObject.simpleCriteria)){ + simpleCriteria = actServ['tripsList'].searchObject.simpleCriteria; + } + + var payload = { + pagination: getPaginationForServer(undefined), + sorting: actServ['tripsList'].sorting, + searchCriteriaMap: simpleCriteria, + searchCriteriaMapMultipleValues: actServ['tripsList'].searchObject.multipleCriteria, + showOnlyLatest: true + }; + activityRestService.exportTripListToCsv(payload).then(function (data) { + if(!angular.equals({}, data)) { + var file = new Blob([data], {type: 'text/csv;charset=UTF-8'}); + $window.saveAs(file, "csvExport" + moment().format("YYYY-MM-DDTHH:mm") + ".csv"); + } + actServ.tripsCsvLoading = false; }) }; From dbe7fb17b582ede21e6fc0a7473b9e46f90227b2 Mon Sep 17 00:00:00 2001 From: gmanifavas Date: Wed, 18 Nov 2020 14:26:29 +0200 Subject: [PATCH 3/3] [UNIONVMS-4866] Fix queries for csv export. --- unionvms-web/app/service/activity/activityService.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/unionvms-web/app/service/activity/activityService.js b/unionvms-web/app/service/activity/activityService.js index c3ed4cc42..85fd3c27d 100644 --- a/unionvms-web/app/service/activity/activityService.js +++ b/unionvms-web/app/service/activity/activityService.js @@ -545,8 +545,7 @@ angular.module('unionvmsWeb').factory('activityService',function(locale, activit pagination: getPaginationForServer(undefined), sorting: actServ['tripsList'].sorting, searchCriteriaMap: simpleCriteria, - searchCriteriaMapMultipleValues: actServ['tripsList'].searchObject.multipleCriteria, - showOnlyLatest: true + searchCriteriaMapMultipleValues: actServ['tripsList'].searchObject.multipleCriteria }; activityRestService.exportTripListToCsv(payload).then(function (data) { if(!angular.equals({}, data)) {