From 69d5cd907f2f26fc98428248489cda2c98db0e0e Mon Sep 17 00:00:00 2001 From: "peter.abiodun" Date: Sun, 7 Apr 2024 20:16:11 +0100 Subject: [PATCH 1/4] OLMIS-7909-inventory-items-export --- .../cce-inventory-item.service.js | 21 +++++++++++++--- .../cce-inventory-list.controller.js | 25 ++++++++++++++++--- .../cce-inventory-list.html | 1 + src/cce-inventory-list/messages_en.json | 3 ++- 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/cce-inventory-item/cce-inventory-item.service.js b/src/cce-inventory-item/cce-inventory-item.service.js index 4baa2b7..7bb72eb 100644 --- a/src/cce-inventory-item/cce-inventory-item.service.js +++ b/src/cce-inventory-item/cce-inventory-item.service.js @@ -1,6 +1,6 @@ /* * This program is part of the OpenLMIS logistics management information system platform software. - * Copyright © 2017 VillageReach + * Copyright © 2017-2024 VillageReach, Techie Planet Ltd * * This program is free software: you can redistribute it and/or modify it under the terms * of the GNU Affero General Public License as published by the Free Software Foundation, either @@ -54,7 +54,8 @@ get: get, query: query, save: save, - transfer: transfer + transfer: transfer, + getDownloadURL: getDownloadURL }; /** @@ -130,6 +131,20 @@ return resource.save({}, inventoryItem).$promise; } + /** + * @ngdoc method + * @methodOf cce-inventory-item.inventoryItemService + * @name getDownloadURL + * + * @description + * Returns the download url for the provided parameters + * + * @return {String} the download url + */ + function getDownloadURL(params) { + return cceUrlFactory('/api/inventoryItems/download?format=csv&programId=' + params.programId + '&facilityId=' + params.facilityId); + } + function transformGetResponse(data, headers, status) { return transformResponse(data, status, transformInventoryItem); } @@ -155,4 +170,4 @@ return data; } } -})(); +})(); \ No newline at end of file diff --git a/src/cce-inventory-list/cce-inventory-list.controller.js b/src/cce-inventory-list/cce-inventory-list.controller.js index 3f24e0c..a2601fd 100644 --- a/src/cce-inventory-list/cce-inventory-list.controller.js +++ b/src/cce-inventory-list/cce-inventory-list.controller.js @@ -1,6 +1,6 @@ /* * This program is part of the OpenLMIS logistics management information system platform software. - * Copyright © 2017 VillageReach + * Copyright © 2017-2024 VillageReach, Techie Planet Ltd * * This program is free software: you can redistribute it and/or modify it under the terms * of the GNU Affero General Public License as published by the Free Software Foundation, either @@ -30,12 +30,12 @@ CceInventoryListController.$inject = [ 'inventoryItems', '$state', '$stateParams', 'FUNCTIONAL_STATUS', 'CCE_RIGHTS', 'messageService', - 'REASON_FOR_NOT_WORKING', 'cceAlerts', 'canEdit', 'canTransfer' + 'REASON_FOR_NOT_WORKING', 'cceAlerts', 'canEdit', 'canTransfer', 'inventoryItemService' ]; function CceInventoryListController(inventoryItems, $state, $stateParams, FUNCTIONAL_STATUS, CCE_RIGHTS, messageService, REASON_FOR_NOT_WORKING, cceAlerts, canEdit, - canTransfer) { + canTransfer, inventoryItemService) { var vm = this; @@ -45,6 +45,7 @@ vm.getReasonLabel = getReasonLabel; vm.search = search; vm.getFunctionalStatusClass = FUNCTIONAL_STATUS.getClass; + vm.getDownloadURL = getDownloadURL; /** * @ngdoc property @@ -237,6 +238,24 @@ reload: true }); } + + /** + * @ngdoc method + * @methodOf cce-inventory-list.controller:CceInventoryListController + * @name getDownloadURL + * + * @description + * Downloads the facility Inventory data as a csv. + * + * @return {String} url + */ + function getDownloadURL() { + return inventoryItemService.getDownloadURL({ + facilityId: vm.facility.id, + programId: vm.program.id + }) + } + } })(); diff --git a/src/cce-inventory-list/cce-inventory-list.html b/src/cce-inventory-list/cce-inventory-list.html index 0bde46b..d7bb404 100644 --- a/src/cce-inventory-list/cce-inventory-list.html +++ b/src/cce-inventory-list/cce-inventory-list.html @@ -9,6 +9,7 @@

{{'cceInventoryList.cceInventory' | message}}

+