dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33325
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17007: loading faster when dealing with large optionSet in attributes/dataelements
------------------------------------------------------------
revno: 17007
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-10-08 13:53:55 +0200
message:
loading faster when dealing with large optionSet in attributes/dataelements
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/WEB-INF/web.xml
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/WEB-INF/web.xml'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/WEB-INF/web.xml 2014-08-18 14:37:59 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/WEB-INF/web.xml 2014-10-08 11:53:55 +0000
@@ -70,6 +70,11 @@
<filter-name>Struts</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
+
+ <mime-mapping>
+ <extension>woff</extension>
+ <mime-type>application/font-woff</mime-type>
+ </mime-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html 2014-09-11 12:35:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html 2014-10-08 11:53:55 +0000
@@ -59,7 +59,7 @@
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angular-translate-loader-static-files.min.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angular-translate-loader-url.min.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/select2.js"></script>
- <script type="text/javascript" src="scripts/ng-csv.js"></script>
+ <script type="text/javascript" src="scripts/ng-csv.js"></script>
<script type="text/javascript" src="scripts/app.js"></script>
<script type="text/javascript" src="scripts/services.js"></script>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-08-29 12:39:37 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-10-08 11:53:55 +0000
@@ -45,7 +45,7 @@
//Reporting
$scope.showReportDiv = false;
-
+
//watch for selection of org unit from tree
$scope.$watch('selectedOrgUnit', function() {
@@ -58,25 +58,7 @@
//apply translation - by now user's profile is fetched from server.
TranslationService.translate();
- $scope.loadPrograms($scope.selectedOrgUnit);
-
- if($scope.selectedProgram){
- AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
- $scope.attributes = atts;
- $scope.attributes = $scope.generateAttributeFilters($scope.attributes);
- $scope.gridColumns = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode.name);
- $scope.search($scope.searchMode.listAll); ;
- });
- }
- else{
- AttributesFactory.getWithoutProgram().then(function(atts){
-
- $scope.attributes = atts;
- $scope.attributes = $scope.generateAttributeFilters($scope.attributes);
- $scope.gridColumns = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode.name);
- $scope.search($scope.searchMode.listAll);
- });
- }
+ $scope.loadPrograms($scope.selectedOrgUnit);
}
});
@@ -85,12 +67,7 @@
$scope.selectedOrgUnit = storage.get('SELECTED_OU');
ProgramFactory.get($scope.dashboardProgramId).then(function(program){
$scope.selectedProgram = program;
- AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
- $scope.attributes = atts;
- $scope.attributes = $scope.generateAttributeFilters($scope.attributes);
- $scope.gridColumns = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode.name);
- $scope.getProgramAttributes($scope.selectedProgram);
- });
+ $scope.processAttributes();
});
}
@@ -125,7 +102,9 @@
$scope.selectedProgram = $scope.programs[0];
}
}
- }
+ }
+ $scope.processAttributes();
+ $scope.search($scope.searchMode.listAll);
});
}
};
@@ -134,29 +113,8 @@
$scope.trackedEntityList = null;
$scope.selectedProgram = program;
-
- if($scope.selectedProgram){
- AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
- setTimeout(function () {
- $scope.$apply(function () {
- $scope.attributes = atts;
- $scope.attributes = $scope.generateAttributeFilters($scope.attributes);
- $scope.gridColumns = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode.name);
- });
- }, 100);
- });
- }
- else{
- AttributesFactory.getWithoutProgram().then(function(atts){
- setTimeout(function () {
- $scope.$apply(function () {
- $scope.attributes = atts;
- $scope.attributes = $scope.generateAttributeFilters($scope.attributes);
- $scope.gridColumns = TEIGridService.generateGridColumns(atts, $scope.selectedOuMode.name);
- });
- }, 100);
- });
- }
+
+ $scope.processAttributes();
if($scope.showRegistrationDiv || $scope.showReportDiv){
$scope.doSearch = false;
@@ -165,8 +123,45 @@
if($scope.doSearch){
$scope.search($scope.searchMode);
}
- };
+ };
+
+ $scope.processAttributes = function(){
+
+ if($scope.selectedProgram){
+ AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
+ $scope.attributesLighter = [];
+ $scope.attributes = [];
+ setTimeout(function () {
+ $scope.$apply(function () {
+ angular.forEach(atts, function(att){
+ $scope.attributesLighter.push({id: att.id, name: att.name, type: att.valueType, displayInListNoProgram: att.displayInListNoProgram});
+ $scope.attributes[att.id] = att;
+ });
+ $scope.attributesLighter = $scope.generateAttributeFilters($scope.attributesLighter);
+ $scope.gridColumns = TEIGridService.generateGridColumns($scope.attributesLighter, $scope.selectedOuMode.name);
+ });
+ }, 100);
+ });
+ }
+ else{
+ AttributesFactory.getWithoutProgram().then(function(atts){
+ $scope.attributesLighter = [];
+ $scope.attributes = [];
+ setTimeout(function () {
+ $scope.$apply(function () {
+ angular.forEach(atts, function(att){
+ $scope.attributesLighter.push({id: att.id, name: att.name, type: att.valueType, displayInListNoProgram: att.displayInListNoProgram});
+ $scope.attributes[att.id] = att;
+ });
+ $scope.attributesLighter = $scope.generateAttributeFilters($scope.attributesLighter);
+ $scope.gridColumns = TEIGridService.generateGridColumns($scope.attributesLighter, $scope.selectedOuMode.name);
+ });
+ }, 100);
+ });
+ }
+ };
+ $scope.searchParam = {bools: []};
$scope.search = function(mode){
$scope.teiFetched = false;
@@ -198,16 +193,15 @@
return;
}
- $scope.queryUrl = 'query=' + $scope.searchText;
-
- $scope.attributes = EntityQueryFactory.resetAttributesQuery($scope.attributes, $scope.enrollment);
+ $scope.queryUrl = 'query=' + $scope.searchText;
+ $scope.attributesLighter = EntityQueryFactory.resetAttributesQuery($scope.attributesLighter, $scope.enrollment);
}
if( $scope.selectedSearchMode === $scope.searchMode.attributeBased ){
$scope.searchText = '';
- $scope.attributeUrl = EntityQueryFactory.getAttributesQuery($scope.attributes, $scope.enrollment);
+ $scope.attributeUrl = EntityQueryFactory.getAttributesQuery($scope.attributesLighter, $scope.enrollment);
if(!$scope.attributeUrl.hasValue && !$scope.selectedProgram){
$scope.emptySearchAttribute = true;
@@ -276,7 +270,7 @@
$scope.generateAttributeFilters = function(attributes){
angular.forEach(attributes, function(attribute){
- if(attribute.valueType === 'number' || attribute.valueType === 'date'){
+ if(attribute.type === 'number' || attribute.type === 'date'){
attribute.operator = $scope.defaultOperators[0];
}
});
@@ -288,7 +282,7 @@
$scope.trackedEntityList = null;
};
- $scope.showHideSearch = function(){
+ $scope.showHideSearch = function(){
$scope.showSearchDiv = !$scope.showSearchDiv;
};
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js 2014-09-17 14:54:25 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js 2014-10-08 11:53:55 +0000
@@ -23,7 +23,7 @@
link: function(scope, element, attrs){
//when tree has loaded, get selected orgunit - if there is any - and inform angular
- $(function() {
+ /*$(function() {
var adapters = [];
var partial_adapters = [];
@@ -63,7 +63,7 @@
});
});
- });
+ });*/
//listen to user selection, and inform angular
selection.setListenerFunction( organisationUnitSelected );
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-10-03 08:25:10 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-10-08 11:53:55 +0000
@@ -647,7 +647,7 @@
angular.forEach(attributes, function(attribute){
- if(attribute.valueType === 'date' || attribute.valueType === 'number'){
+ if(attribute.type === 'date' || attribute.type === 'number'){
var q = '';
if(attribute.operator === OperatorFactory.defaultOperators[0]){
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html 2014-10-08 08:48:34 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html 2014-10-08 11:53:55 +0000
@@ -107,12 +107,12 @@
</div>
</td>
</tr>
- <tr ng-repeat="attribute in attributes">
+ <tr ng-repeat="attribute in attributesLighter">
<td>
{{attribute.name}}
</td>
<td>
- <div ng-switch="attribute.valueType">
+ <div ng-switch="attribute.type">
<div ng-switch-when="number">
<div class="dataelement-filter">
<div class="filter-operator">
@@ -153,11 +153,11 @@
</div>
<div ng-switch-when="optionSet">
<select multiple ui-select2 ng-model="attribute.value" data-placeholder="{{'please_select'| translate}}" style="width:100%;">
- <option ng-repeat="option in attribute.optionSet.options" value="{{option.code}}">{{option.name}}</option>
+ <option ng-repeat="option in attributes[attribute.id].optionSet.options | filter:$viewValue | limitTo:100" value="{{option.code}}">{{option.name}}</option>
</select>
</div>
<div ng-switch-when="bool">
- <select ui-select2 ng-model="attribute.value" data-placeholder="{{'please_select'| translate}}" style="width:100%;">
+ <select ui-select2 multiple ng-model="attribute.value" data-placeholder="{{'please_select'| translate}}" style="width:100%;">
<option ng-repeat="option in boolOperators" value="{{option}}">{{option| translate}}</option>
</select>
</div>