Skip to content

Commit

Permalink
Merge pull request #53 from OpenLMIS/SELV3-784
Browse files Browse the repository at this point in the history
SELV3-784: Added Home Page Report Component to home page
  • Loading branch information
olewandowski1 authored Jan 9, 2025
2 parents d1a70ca + 35a16e5 commit b1e4d7e
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
==================
New functionality:
* [SELV3-782](https://openlmis.atlassian.net/browse/SELV3-782): Added Reports Management Page in Administration
* [SELV3-784](https://openlmis.atlassian.net/browse/SELV3-784): Added Home Page Report Component to home page

5.6.14 / 2024-12-17
==================
Expand Down
3 changes: 3 additions & 0 deletions src/openlmis-home-page-report/_home-page-report.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.home-page-report-panel {
margin-top: 4rem;
}
34 changes: 34 additions & 0 deletions src/openlmis-home-page-report/home-page-report.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* This program is part of the OpenLMIS logistics management information system platform software.
* Copyright © 2017 VillageReach
*
* 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
* version 3 of the License, or (at your option) any later version.
*  
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
* See the GNU Affero General Public License for more details. You should have received a copy of
* the GNU Affero General Public License along with this program. If not, see
* http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org. 
*/

(function() {

'use strict';

/**
* @ngdoc component
* @name openlmis-home-page-report.component:openlmisHomePageReport
*
* @description
* Component responsible for displaying home page report
*/
angular
.module('openlmis-home-page-report')
.component('openlmisHomePageReport', {
templateUrl: 'openlmis-home-page-report/home-page-report.html',
controller: 'OpenlmisHomePageReportController',
controllerAs: 'vm'
});
})();
113 changes: 113 additions & 0 deletions src/openlmis-home-page-report/home-page-report.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* This program is part of the OpenLMIS logistics management information system platform software.
* Copyright © 2017 VillageReach
*
* 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
* version 3 of the License, or (at your option) any later version.
*  
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
* See the GNU Affero General Public License for more details. You should have received a copy of
* the GNU Affero General Public License along with this program. If not, see
* http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org. 
*/

(function() {

'use strict';

/**
* @ngdoc controller
* @name openlmis-home-page-report.controller:OpenlmisHomePageReportController
* @description
* Manages the openlmis-home-page-report component
*/
angular
.module('openlmis-home-page-report')
.controller('OpenlmisHomePageReportController', OpenlmisHomePageReportController);

OpenlmisHomePageReportController.$inject = ['reportDashboardService', 'offlineService', '$sce',
'supersetOAuthService', '$rootScope', '$state', 'REPORT_TYPES'];

function OpenlmisHomePageReportController(reportDashboardService, offlineService, $sce, supersetOAuthService,
$rootScope, $state, REPORT_TYPES) {

var vm = this;
vm.$onInit = onInit;

/**
* @ngdoc property
* @propertyOf openlmis-home-page-report.controller:OpenlmisHomePageReportController
* @type {Object}
* @name report
*
* @description
* Holds information about the home page report
*/
vm.report = undefined;

/**
* @ngdoc property
* @propertyOf openlmis-home-page-report.controller:OpenlmisHomePageReportController
* @type {boolean}
* @name isOffline
*
* @description
* Indicates offline connection.
*/
vm.isOffline = undefined;

/**
* @ngdoc property
* @propertyOf openlmis-home-page-report.controller:OpenlmisHomePageReportController
* @name isAuthorized
* @type {boolean}
*
* @description
* Indicates if the controller is ready for iframe.
*/
vm.isAuthorized = false;

/**
* @ngdoc method
* @methodOf openlmis-home-page-report.controller:OpenlmisHomePageReportController
* @name $onInit
*
* @description
* Method that is executed on initiating HomeSystemNotificationsController.
*/
function onInit() {
vm.isOffline = offlineService.isOffline();

reportDashboardService.getHomePageReport().then(function(report) {
if (report.content[0]) {
vm.report = report.content[0];
vm.report.url = $sce.trustAsResourceUrl(vm.report.url);

if (vm.report.type !== REPORT_TYPES.SUPERSET) {
vm.isAuthorized = true;
}

if (!vm.isOffline && vm.report.type === REPORT_TYPES.SUPERSET) {
checkAuthorizationInSuperset();
}
}
});
}

$rootScope.$on('openlmis-auth.authorized-in-superset', function() {
$state.reload();
});

function checkAuthorizationInSuperset() {
supersetOAuthService.checkAuthorizationInSuperset()
.then(function(data) {
vm.supersetOAuthState = data.state;
if (data.isAuthorized === true) {
vm.isAuthorized = true;
}
});
}
}
})();
11 changes: 11 additions & 0 deletions src/openlmis-home-page-report/home-page-report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="home-page-report-panel">
<iframe
ng-if="vm.isAuthorized"
title="home_page_report"
style="width: 95vw; height: 90vh"
src="{{ vm.report.url }}"
frameborder="0"
scrolling="auto"
allowFullScreen="true">
</iframe>
</div>
30 changes: 30 additions & 0 deletions src/openlmis-home-page-report/home-page-report.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This program is part of the OpenLMIS logistics management information system platform software.
* Copyright © 2017 VillageReach
*
* 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
* version 3 of the License, or (at your option) any later version.
*  
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
* See the GNU Affero General Public License for more details. You should have received a copy of
* the GNU Affero General Public License along with this program. If not, see
* http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org. 
*/

(function() {

'use strict';

/**
* @module openlmis-home-page-report
*
* @description
* Responsible for displaying dashboard home page report
*/
angular.module('openlmis-home-page-report', [
'report',
'openlmis-superset'
]);
})();
1 change: 1 addition & 0 deletions src/openlmis-home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ <h3 ng-if="!vm.homePageSystemNotifications || vm.homePageSystemNotifications.len
</div>
</div>
<openlmis-home-alerts-panel></openlmis-home-alerts-panel>
<openlmis-home-page-report></openlmis-home-page-report>
</div>
3 changes: 2 additions & 1 deletion src/openlmis-home/openlmis-home.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
'referencedata-system-notification',
'openlmis-message',
'openlmis-home-alerts-panel',
'ui.router'
'ui.router',
'openlmis-home-page-report'
]);

})();

0 comments on commit b1e4d7e

Please sign in to comment.