@@ -65,52 +65,62 @@ router.get('/', async function (req, res) {
6565 const headers = ngsiLD . setHeaders ( req . session . access_token , LinkHeader ) ;
6666 try {
6767 monitor ( 'NGSI' , 'listEntities ?type=Building' ) ;
68- const buildings = await ngsiLD . listEntities (
68+ const getBuildings = await ngsiLD . listEntities (
6969 {
7070 type : 'Building' ,
7171 format : 'keyValues' ,
72- attrs : 'name' ,
72+ pick : 'id, name' ,
7373 limit : ENTITY_LIMIT
7474 } ,
7575 headers
7676 ) ;
77+ const buildings = getBuildings . sort ( ( a , b ) => {
78+ return a . name . localeCompare ( b . name ) ;
79+ } ) ;
7780 monitor ( 'NGSI' , 'listEntities ?type=Animal' ) ;
7881 const animals = await ngsiLD . listEntities (
7982 {
8083 type : 'Animal' ,
8184 format : 'keyValues' ,
82- attrs : 'name,species' ,
85+ pick : 'id, name,species,phenologicalCondition ' ,
8386 limit : ENTITY_LIMIT
8487 } ,
8588 headers
8689 ) ;
8790 monitor ( 'NGSI' , 'listEntities ?type=AgriParcel' ) ;
88- const parcels = await ngsiLD . listEntities (
91+ const getParcels = await ngsiLD . listEntities (
8992 {
9093 type : 'AgriParcel' ,
9194 format : 'keyValues' ,
92- attrs : 'name' ,
95+ pick : 'id, name' ,
9396 limit : ENTITY_LIMIT
9497 } ,
9598 headers
9699 ) ;
100+ const parcels = getParcels . sort ( ( a , b ) => {
101+ return a . name . localeCompare ( b . name ) ;
102+ } ) ;
97103
98104 monitor ( 'NGSI' , 'listEntities ?type=Device' ) ;
99105 const devices = await ngsiLD . listEntities (
100106 {
101107 type : 'Device' ,
102108 format : 'keyValues' ,
103- attrs : 'name' ,
109+ pick : 'id, name' ,
104110 limit : ENTITY_LIMIT
105111 } ,
106112 headers
107113 ) ;
108114
109115 const cows = _ . filter ( animals , ( o ) => {
110116 return o . species === 'dairy cattle' ;
117+ } ) . sort ( ( a , b ) => {
118+ return a . name . localeCompare ( b . name ) ;
111119 } ) ;
112120 const pigs = _ . filter ( animals , ( o ) => {
113121 return o . species === 'pig' ;
122+ } ) . sort ( ( a , b ) => {
123+ return a . name . localeCompare ( b . name ) ;
114124 } ) ;
115125
116126 return res . render ( 'index' , {
0 commit comments