-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from OpenLMIS/SELV3-784
SELV3-784: Added Home Page Report Component to home page
- Loading branch information
Showing
8 changed files
with
195 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
34
src/openlmis-home-page-report/home-page-report.component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
113
src/openlmis-home-page-report/home-page-report.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}); | ||
} | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
]); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters