dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28611
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14298: dashboard for tracker-capture - WIP
------------------------------------------------------------
revno: 14298
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Wed 2014-03-19 17:58:56 +0100
message:
dashboard for tracker-capture - WIP
added:
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dataentry.html
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/notes.html
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/profile.html
modified:
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dashboard.html
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/selection.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-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-03-17 15:59:31 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-03-19 16:58:56 +0000
@@ -95,16 +95,14 @@
//Load entities for the selected program and orgunit
TrackedEntityService.getByOrgUnitAndProgram($scope.selectedOrgUnit.id, $scope.selectedProgram.id).then(function(data){
- $scope.trackedEntityList = data;
- console.log('the entities are: ', $scope.trackedEntityList);
+ $scope.trackedEntityList = data;
});
}
else{
//Load entities for the selected orgunit
TrackedEntityService.getByOrgUnit($scope.selectedOrgUnit.id).then(function(data){
- $scope.trackedEntityList = data;
- console.log('the entities are: ', $scope.trackedEntityList);
+ $scope.trackedEntityList = data;
});
}
};
@@ -155,7 +153,7 @@
$scope.showDashboard = function(currentEntity){
SelectedEntity.setSelectedEntity(currentEntity);
storage.set('SELECTED_OU', $scope.selectedOrgUnit);
- $location.path('/dashboard').search({selectedEntityId: currentEntity.person, selectedProgramId: $scope.selectedProgram ? $scope.selectedProgram.id : null});
+ $location.path('/dashboard').search({selectedEntityId: currentEntity.id, selectedProgramId: $scope.selectedProgram ? $scope.selectedProgram.id : null});
};
$scope.search = function(){
@@ -169,28 +167,18 @@
//Controller for dashboard
.controller('DashboardController',
- function($scope,
+ function($rootScope,
+ $scope,
$location,
storage,
- EnrollmentService,
TrackedEntityService,
TranslationService) {
//do translation of the dashboard page
TranslationService.translate();
- //dashboard contents
- $scope.profile = {title: 'profile', isOpen: true};
- $scope.enrollment = {title: 'enrollment', isOpen: true};
- $scope.notes = {title: 'notes', isOpen: true};
- $scope.dataEntry = {title: 'dataentry', isOpen: true};
- $scope.selected = {title: 'current_selections', isOpen: true, selections: []};
-
- //attributes for profile
- $scope.attributes = {};
- angular.forEach(storage.get('ATTRIBUTES'), function(attribute){
- $scope.attributes[attribute.id] = attribute;
- });
+ //dashboard item
+ $scope.selected = {title: 'current_selections', isOpen: true, selections: []};
//selections
$scope.selectedEntityId = ($location.search()).selectedEntityId;
@@ -202,34 +190,19 @@
if($scope.selectedProgramId){
$scope.selectedProgram = storage.get($scope.selectedProgramId);
- }
-
- //programs for enrollment
- $scope.programs = [];
- var programs = storage.get('PROGRAMS');
- if( programs ){
- for(var i=0; i<programs.length; i++){
- var program = storage.get(programs[i].id);
- if($scope.selectedProgramId == programs[i].id){
- $scope.selectedProgram = program;
- }
- if(program.organisationUnits.hasOwnProperty($scope.selectedOrgUnit.id)){
- $scope.programs.push(program);
- }
- }
}
-
+
if( $scope.selectedEntityId ){
//Fetch the selected entity
TrackedEntityService.get($scope.selectedEntityId).then(function(data){
- $scope.selectedEntity = data;
- console.log('the entity is: ', $scope.selectedEntity);
- });
-
- EnrollmentService.get($scope.selectedEntityId).then(function(data){
- console.log('enrollment: ', data);
- });
+ $scope.selectedEntity = data;
+
+ //broadcast for all the dashboard item
+ $rootScope.$broadcast('selectedItems', {selectedEntity: $scope.selectedEntity,
+ selectedProgramId: $scope.selectedProgramId,
+ selectedOrgUnitId: $scope.selectedOrgUnit.id});
+ });
}
$scope.selected.selections.push({title: 'registering_unit', value: $scope.selectedOrgUnit ? $scope.selectedOrgUnit.name : 'not_selected'});
@@ -246,37 +219,83 @@
})
+//Controller for the profile section
+.controller('ProfileController',
+ function($scope,
+ storage,
+ TranslationService) {
+
+ TranslationService.translate();
+
+ $scope.profile = {title: 'profile', isOpen: true};
+
+ //attributes for profile
+ $scope.attributes = {};
+ angular.forEach(storage.get('ATTRIBUTES'), function(attribute){
+ $scope.attributes[attribute.id] = attribute;
+ });
+
+ //listen for the selected items
+ $scope.$on('selectedItems', function(event, args) {
+ $scope.selectedEntity = args.selectedEntity;
+ });
+
+})
+
+
//Controller for the enrollment section
.controller('EnrollmentController',
function($scope,
storage,
- TranslationService) {
-
- TranslationService.translate();
-
- $scope.attributes = storage.get('ATTRIBUTES');
-
-})
-
-//Controller for the notes section
-.controller('NotesController',
- function($scope,
- storage,
- TranslationService) {
-
- TranslationService.translate();
-
- $scope.attributes = storage.get('ATTRIBUTES');
-
-})
-
-//Controller for the notes section
-.controller('NotesController',
- function($scope,
- storage,
- TranslationService) {
-
- TranslationService.translate();
+ EnrollmentService,
+ TranslationService) {
+
+ TranslationService.translate();
+
+ $scope.enrollment = {title: 'enrollment', isOpen: true};
+
+ //listen for the selected items
+ $scope.$on('selectedItems', function(event, args) {
+ $scope.selectedEntity = args.selectedEntity;
+ $scope.selectedProgramId = args.selectedProgramId;
+ $scope.selectedOrgUnitId = args.selectedOrgUnitId;
+
+ //programs for enrollment
+ $scope.programs = [];
+ var programs = storage.get('PROGRAMS');
+ if( programs ){
+
+ for(var i=0; i<programs.length; i++){
+
+ var program = storage.get(programs[i].id);
+
+ if($scope.selectedProgramId == program.id){
+ $scope.selectedProgram = program;
+ }
+
+ if(program.organisationUnits.hasOwnProperty($scope.selectedOrgUnitId) &&
+ program.trackedEntity.id == $scope.selectedEntity.trackedEntity){
+
+ $scope.programs.push(program);
+ }
+ }
+ }
+
+ EnrollmentService.get($scope.selectedEntity.trackedEntityInstance).then(function(data){
+ console.log('enrollment: ', data);
+ });
+ });
+})
+
+//Controller for the notes section
+.controller('NotesController',
+ function($scope,
+ storage,
+ TranslationService) {
+
+ TranslationService.translate();
+
+ $scope.notes = {title: 'notes', isOpen: true};
$scope.attributes = storage.get('ATTRIBUTES');
@@ -290,6 +309,8 @@
TranslationService.translate();
+ $scope.dataEntry = {title: 'dataentry', isOpen: true};
+
$scope.attributes = storage.get('ATTRIBUTES');
})
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-03-19 13:02:28 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-03-19 16:58:56 +0000
@@ -89,7 +89,7 @@
return {
get: function( entity ){
- var promise = $http.get( '../api/enrollments?person=' + entity ).then(function(response){
+ var promise = $http.get( '../api/enrollments?trackedEntityInstance=' + entity ).then(function(response){
return response.data;
});
return promise;
@@ -115,30 +115,30 @@
});
return promise;
},
+
getByOrgUnitAndProgram: function(orgUnitUid, programUid) {
- promise = $http.get( '../api/trackedEntityInstances.json?ou=' + orgUnitUid + '&program=' + programUid ).then(function(response){
-
- var trackedEntityList = response.data.personList;
-
- trackedEntityList = entityFormatter(trackedEntityList, AttributesFactory.getForListing());
-
- return trackedEntityList;
+
+ var attributes = AttributesFactory.convertListingForToQuery();
+ var url = '../api/trackedEntityInstances.json?ou=' + orgUnitUid + '&program=' + programUid;
+
+ promise = $http.get( url + attributes ).then(function(response){
+
+ return entityFormatter(response.data);
});
return promise;
},
getByOrgUnit: function(orgUnitUid) {
- promise = $http.get( '../api/trackedEntityInstances.json?ou=' + orgUnitUid ).then(function(response){
-
- var trackedEntityList = response.data.personList;
-
- trackedEntityList = entityFormatter(trackedEntityList, AttributesFactory.getForListing());
+
+ var attributes = AttributesFactory.convertListingForToQuery();
+ var url = '../api/trackedEntityInstances.json?ou=' + orgUnitUid;
+
+ promise = $http.get( url + attributes ).then(function(response){
- return trackedEntityList;
+ return entityFormatter(response.data);
});
return promise;
}
- };
-
+ };
})
/* Factory for getting tracked entity attributes */
@@ -165,6 +165,14 @@
});
return attributes;
+ },
+ convertListingForToQuery: function(){
+ var param = '';
+ angular.forEach(this.getForListing(), function(attribute) {
+ param += '&' + 'attribute=' + attribute.id;
+ });
+
+ return param;
}
};
})
@@ -478,29 +486,35 @@
*/
//This is is to have consistent display of entities and attributes
//as every entity might not have value for every attribute.
-function entityFormatter(entityList, attributesForListing){
-
- angular.forEach(entityList, function(trackedEntity){
-
- //assume every entity has value for each attribute
- //initially all are empty
- angular.forEach(attributesForListing, function(attribute){
-
- var loop = true;
- var att = angular.copy(attribute);
- att.value = '';
-
- for(var i=0; i<trackedEntity.attributes.length && loop; i++){
- if(trackedEntity.attributes[i].attribute == attribute.id){
- att.value = trackedEntity.attributes[i].value;
- loop = false;
- }
- }
-
- trackedEntity[att.id] = att.value;
-
- });
- });
-
- return entityList;
+function entityFormatter(grid){
+
+ if(!grid || !grid.rows){
+ return;
+ }
+
+ //grid.headers[0-4] = Instance, Created, Last updated, Org unit, Tracked entity
+ //grid.headers[5..] = Attribute, Attribute,....
+ var attributes = [];
+ for(var i=5; i<grid.headers.length; i++){
+ attributes.push({id: grid.headers[i].name, name: grid.headers[i].column});
+ }
+
+ var entityList = [];
+
+ angular.forEach(grid.rows, function(row){
+ var entity = {};
+
+ entity.id = row[0];
+ entity.orgUnit = row[3];
+ entity.type = row[4];
+
+ for(var i=5; i<row.length; i++){
+ entity[grid.headers[i].name] = row[i];
+ }
+
+ entityList.push(entity);
+
+ });
+
+ return {headers: attributes, rows: entityList};
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dashboard.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dashboard.html 2014-03-17 15:59:31 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dashboard.html 2014-03-19 16:58:56 +0000
@@ -1,4 +1,4 @@
-<link rel="stylesheet" type="text/css" href="lib/bootstrap/css/bootstrap.min.css">
+<link rel="stylesheet" type="text/css" href="../dhis-web-commons/bootstrap/css/bootstrap.min.css">
<div class="container-1-1">
@@ -35,95 +35,22 @@
</accordion-group>
</accordion>
</div>
- <div class="col-sm-3 col-md-3">
- <accordion>
- <accordion-group is-open="{{profile.isOpen}}">
- <accordion-heading>
- <span class="list-title"> {{selectedProgram.trackedEntity.name|| 'entity' | translate}} {{profile.title| translate}}</span>
- </accordion-heading>
- <div>
- <div class="list-element" ng-repeat="attribute in selectedEntity.attributes">
- {{attribute.displayName}}
- <div class="right">
- <div ng-switch="attribute.type">
- <div ng-switch-when="date">
- <input type="text" ng-date ng-model="attribute.value" value="attribute.value | date:'yyyy-MM-dd"/>
- </div>
- <div ng-switch-when="trueOnly">
- <input type="checkbox" ng-model="attribute.value" />
- </div>
- <div ng-switch-when="bool">
- <select ng-model="attribute.value" />
- <option value="">{{'please_select'| translate}}</option>
- <option value="0">{{'no'| translate}}</option>
- <option value="1">{{'yes'| translate}}</option>
- </select>
- </div>
- <div ng-switch-when="combo">
- <input type="text"
- ng-model="attribute.value"
- typeahead="option.name for option in attributes[attribute.attribute].personAttributeOptions | filter:$viewValue | limitTo:20"
- typeahead-open-on-focus
- />
- </div>
- <div ng-switch-when="number">
- <input type="number" ng-model="attribute.value" />
- </div>
- <div ng-switch-default>
- <input type="text" ng-model="attribute.value" />
- </div>
- </div>
- </div>
- </div>
- </div>
- </accordion-group>
- </accordion>
- </div>
- <div class="col-sm-3 col-md-3">
- <accordion>
- <accordion-group is-open="{{enrollment.isOpen}}">
- <accordion-heading>
- <span class="list-title">{{enrollment.title| translate}}</span>
- </accordion-heading>
- <div class="list-element-container">
- <div class="list-element">
- {{'program'| translate}}
- <span class="right">
- <select ng-model="selectedProgram"
- ng-options="program as program.name for program in programs | orderBy: 'name'"
- ng-change="showEnrollment()">
- <option value="">{{'please_select'| translate}}</option>
- </select>
- </span>
- </div>
- </div>
- </accordion-group>
- </accordion>
- </div>
- <div class="col-sm-3 col-md-3">
- <accordion>
- <accordion-group is-open="{{notes.isOpen}}">
- <accordion-heading>
- <span class="list-title">{{notes.title| translate}}</span>
- </accordion-heading>
- This is notes.
- </accordion-group>
- </accordion>
+ <div class="col-sm-3 col-md-3" ng-controller="ProfileController">
+ <div ng-include="'views/profile.html'"></div>
+ </div>
+ <div class="col-sm-3 col-md-3" ng-controller="EnrollmentController">
+ <div ng-include="'views/enrollment.html'"></div>
+ </div>
+ <div class="col-sm-3 col-md-3" ng-controller="NotesController">
+ <div ng-include="'views/notes.html'"></div>
</div>
</div>
</div>
<div class='separator'></div>
- <div class="col-xs-12">
- <accordion>
- <accordion-group is-open="{{dataEntry.isOpen}}">
- <accordion-heading>
- <span class="list-title">{{dataEntry.title| translate}}</span>
- </accordion-heading>
- This is data entry.
- </accordion-group>
- </accordion>
+ <div class="col-xs-12" ng-controller="DataEntryController">
+ <div ng-include="'views/dataentry.html'"></div>
</div>
</div>
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dataentry.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dataentry.html 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dataentry.html 2014-03-19 16:58:56 +0000
@@ -0,0 +1,8 @@
+<accordion>
+ <accordion-group is-open="{{dataEntry.isOpen}}">
+ <accordion-heading>
+ <span class="list-title">{{dataEntry.title| translate}}</span>
+ </accordion-heading>
+ This is data entry.
+ </accordion-group>
+</accordion>
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html 2014-03-19 16:58:56 +0000
@@ -0,0 +1,19 @@
+<accordion>
+ <accordion-group is-open="{{enrollment.isOpen}}">
+ <accordion-heading>
+ <span class="list-title">{{enrollment.title| translate}}</span>
+ </accordion-heading>
+ <div class="list-element-container">
+ <div class="list-element">
+ {{'program'| translate}}
+ <span class="right">
+ <select ng-model="selectedProgram"
+ ng-options="program as program.name for program in programs | orderBy: 'name'"
+ ng-change="showEnrollment()">
+ <option value="">{{'please_select'| translate}}</option>
+ </select>
+ </span>
+ </div>
+ </div>
+ </accordion-group>
+</accordion>
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/notes.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/notes.html 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/notes.html 2014-03-19 16:58:56 +0000
@@ -0,0 +1,8 @@
+<accordion>
+ <accordion-group is-open="{{notes.isOpen}}">
+ <accordion-heading>
+ <span class="list-title">{{notes.title| translate}}</span>
+ </accordion-heading>
+ This is notes.
+ </accordion-group>
+</accordion>
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/profile.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/profile.html 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/profile.html 2014-03-19 16:58:56 +0000
@@ -0,0 +1,42 @@
+<accordion>
+ <accordion-group is-open="{{profile.isOpen}}">
+ <accordion-heading>
+ <span class="list-title"> {{selectedProgram.trackedEntity.name || 'entity' | translate}} {{profile.title| translate}}</span>
+ </accordion-heading>
+ <div>
+ <div class="list-element" ng-repeat="attribute in selectedEntity.attributes">
+ {{attribute.displayName}}
+ <div class="right">
+ <div ng-switch="attribute.type">
+ <div ng-switch-when="date">
+ <input type="text" ng-date ng-model="attribute.value" value="attribute.value | date:'yyyy-MM-dd"/>
+ </div>
+ <div ng-switch-when="trueOnly">
+ <input type="checkbox" ng-model="attribute.value" />
+ </div>
+ <div ng-switch-when="bool">
+ <select ng-model="attribute.value" />
+ <option value="">{{'please_select'| translate}}</option>
+ <option value="0">{{'no'| translate}}</option>
+ <option value="1">{{'yes'| translate}}</option>
+ </select>
+ </div>
+ <div ng-switch-when="combo">
+ <input type="text"
+ ng-model="attribute.value"
+ typeahead="option.name for option in attributes[attribute.attribute].personAttributeOptions | filter:$viewValue | limitTo:20"
+ typeahead-open-on-focus
+ />
+ </div>
+ <div ng-switch-when="number">
+ <input type="number" ng-model="attribute.value" />
+ </div>
+ <div ng-switch-default>
+ <input type="text" ng-model="attribute.value" />
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </accordion-group>
+</accordion>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/selection.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/selection.html 2014-03-17 15:59:31 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/selection.html 2014-03-19 16:58:56 +0000
@@ -119,7 +119,7 @@
<h2>
{{selectedProgram.trackedEntity.name || 'entity' | translate}} {{'list'| translate}}
</h2>
- <div ng-switch="trackedEntityList.length">
+ <div ng-switch="trackedEntityList.rows.length">
<div ng-switch-when="undefined">
<p>
{{'empty'| translate}} {{selectedProgram.trackedEntity.name || 'entity' | translate}} {{'list'| translate}}
@@ -180,7 +180,7 @@
</tr>
</thead>
<tbody id="list">
- <tr ng-repeat="trackedEntity in trackedEntityList| paginate:rowsPerPage | orderBy:sortHeader:reverse | gridFilter:filterText:currentFilter"
+ <tr ng-repeat="trackedEntity in trackedEntityList.rows | paginate:rowsPerPage | orderBy:sortHeader:reverse | gridFilter:filterText:currentFilter"
ng-click="showDashboard(trackedEntity)">
<td class="max-column-width"