@tiledesk/tiledesk-server 2.9.4 → 2.9.5
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +3 -0
- package/package.json +1 -1
- package/routes/project.js +70 -41
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/routes/project.js
CHANGED
@@ -886,52 +886,81 @@ router.get('/:projectid/isopen', function (req, res) {
|
|
886
886
|
router.get('/:projectid/users/availables', function (req, res) {
|
887
887
|
//winston.debug("PROJECT ROUTES FINDS AVAILABLES project_users: projectid", req.params.projectid);
|
888
888
|
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
889
|
+
if (req.query.raw && (req.query.raw === true || req.query.raw === 'true')) {
|
890
|
+
Project_user.find({ id_project: req.params.projectid, user_available: true, role: { $in : [RoleConstants.OWNER, RoleConstants.ADMIN, RoleConstants.SUPERVISOR, RoleConstants.AGENT]}}).
|
891
|
+
populate('id_user').
|
892
|
+
exec(function (err, project_users) {
|
893
|
+
if (err) {
|
894
|
+
winston.debug('PROJECT ROUTES - FINDS AVAILABLES project_users - ERROR: ', err);
|
895
|
+
return res.status(500).send({ success: false, msg: 'Error getting object.' });
|
896
|
+
}
|
897
|
+
if (project_users) {
|
898
|
+
|
899
|
+
user_available_array = [];
|
900
|
+
project_users.forEach(project_user => {
|
901
|
+
if (project_user.id_user) {
|
902
|
+
// winston.debug('PROJECT ROUTES - AVAILABLES PROJECT-USER: ', project_user)
|
903
|
+
user_available_array.push({ "id": project_user.id_user._id, "firstname": project_user.id_user.firstname });
|
904
|
+
} else {
|
905
|
+
// winston.debug('PROJECT ROUTES - AVAILABLES PROJECT-USER (else): ', project_user)
|
906
|
+
}
|
907
|
+
});
|
908
|
+
|
909
|
+
//winston.debug('ARRAY OF THE AVAILABLE USER ', user_available_array);
|
910
|
+
res.json(user_available_array);
|
911
|
+
}
|
912
|
+
});
|
913
|
+
} else {
|
914
|
+
operatingHoursService.projectIsOpenNow(req.params.projectid, function (isOpen, err) {
|
915
|
+
//winston.debug('P ---> [ OHS ] -> [ PROJECT ROUTES ] -> IS OPEN THE PROJECT: ', isOpen);
|
916
|
+
|
917
|
+
if (err) {
|
918
|
+
winston.debug('P ---> [ OHS ] -> [ PROJECT ROUTES ] -> IS OPEN THE PROJECT - EROR: ', err)
|
919
|
+
// sendError(err, res);
|
920
|
+
return res.status(500).send({ success: false, msg: err });
|
921
|
+
} else if (isOpen) {
|
922
|
+
|
923
|
+
Project_user.find({ id_project: req.params.projectid, user_available: true, role: { $in : [RoleConstants.OWNER, RoleConstants.ADMIN, RoleConstants.SUPERVISOR, RoleConstants.AGENT]}}).
|
924
|
+
populate('id_user').
|
925
|
+
exec(function (err, project_users) {
|
926
|
+
if (err) {
|
927
|
+
winston.debug('PROJECT ROUTES - FINDS AVAILABLES project_users - ERROR: ', err);
|
928
|
+
return res.status(500).send({ success: false, msg: 'Error getting object.' });
|
929
|
+
}
|
930
|
+
if (project_users) {
|
931
|
+
|
932
|
+
user_available_array = [];
|
933
|
+
project_users.forEach(project_user => {
|
934
|
+
if (project_user.id_user) {
|
935
|
+
// winston.debug('PROJECT ROUTES - AVAILABLES PROJECT-USER: ', project_user)
|
936
|
+
user_available_array.push({ "id": project_user.id_user._id, "firstname": project_user.id_user.firstname });
|
937
|
+
} else {
|
938
|
+
// winston.debug('PROJECT ROUTES - AVAILABLES PROJECT-USER (else): ', project_user)
|
939
|
+
}
|
940
|
+
});
|
941
|
+
|
942
|
+
//winston.debug('ARRAY OF THE AVAILABLE USER ', user_available_array);
|
943
|
+
|
944
|
+
res.json(user_available_array);
|
945
|
+
}
|
946
|
+
});
|
947
|
+
|
948
|
+
|
949
|
+
} else {
|
950
|
+
// winston.debug('P ---> [ OHS ] -> [ PROJECT ROUTES ] -> IS OPEN THE PRJCT: ', isOpen, ' -> AVAILABLE EMPTY');
|
951
|
+
// closed
|
952
|
+
user_available_array = [];
|
953
|
+
res.json(user_available_array);
|
954
|
+
}
|
955
|
+
});
|
956
|
+
}
|
923
957
|
|
924
|
-
|
925
|
-
// winston.debug('P ---> [ OHS ] -> [ PROJECT ROUTES ] -> IS OPEN THE PRJCT: ', isOpen, ' -> AVAILABLE EMPTY');
|
926
|
-
// closed
|
927
|
-
user_available_array = [];
|
928
|
-
res.json(user_available_array);
|
929
|
-
}
|
930
|
-
});
|
958
|
+
|
931
959
|
|
932
960
|
});
|
933
961
|
|
934
962
|
|
935
963
|
|
936
964
|
|
965
|
+
|
937
966
|
module.exports = router;
|