tango-app-api-task 1.0.0-alpha.10 → 1.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -668,7 +668,7 @@ async function taskDropdownListData( requestData ) {
|
|
|
668
668
|
return res.sendError( error, 500 );
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
|
-
export const
|
|
671
|
+
export const taskDropdownListV1OLD = async ( req, res ) => {
|
|
672
672
|
try {
|
|
673
673
|
let requestData = req.body;
|
|
674
674
|
let result = {};
|
|
@@ -713,6 +713,114 @@ export const taskDropdownListV1 = async ( req, res ) => {
|
|
|
713
713
|
return res.sendError( { error: error }, 500 );
|
|
714
714
|
}
|
|
715
715
|
};
|
|
716
|
+
export const taskDropdownListV1 = async ( req, res ) => {
|
|
717
|
+
try {
|
|
718
|
+
let requestData = req.body;
|
|
719
|
+
let fromDate = new Date( requestData.fromDate );
|
|
720
|
+
let toDate = new Date( requestData.toDate );
|
|
721
|
+
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
722
|
+
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
723
|
+
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
724
|
+
let result = {};
|
|
725
|
+
|
|
726
|
+
let findQuery = [
|
|
727
|
+
{ $match: { $and: [
|
|
728
|
+
{ client_id: requestData.clientId },
|
|
729
|
+
{ store_id: { $in: requestData.storeId } },
|
|
730
|
+
{ date_iso: { $gte: fromDate, $lte: toDate } },
|
|
731
|
+
{ checkListType: { $in: [ 'task', 'checklistTask', 'cctv' ] } },
|
|
732
|
+
] } },
|
|
733
|
+
{
|
|
734
|
+
$project: {
|
|
735
|
+
sourceCheckList_id: 1,
|
|
736
|
+
checkListName: 1,
|
|
737
|
+
},
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
$group: {
|
|
741
|
+
_id: '$sourceCheckList_id',
|
|
742
|
+
checkListName: { $last: '$checkListName' },
|
|
743
|
+
},
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
$project: {
|
|
747
|
+
_id: 0,
|
|
748
|
+
sourceCheckList_id: '$_id',
|
|
749
|
+
checkListName: 1,
|
|
750
|
+
},
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
$lookup: {
|
|
754
|
+
from: 'taskconfigs',
|
|
755
|
+
let: { sourceId: '$sourceCheckList_id' },
|
|
756
|
+
pipeline: [
|
|
757
|
+
{
|
|
758
|
+
$match: {
|
|
759
|
+
$expr: {
|
|
760
|
+
$and: [
|
|
761
|
+
{ $eq: [ '$_id', '$$sourceId' ] },
|
|
762
|
+
],
|
|
763
|
+
},
|
|
764
|
+
},
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
$project: {
|
|
768
|
+
_id: 1,
|
|
769
|
+
checkListName: 1,
|
|
770
|
+
checkListNameLowercase: { $toLower: '$checkListName' },
|
|
771
|
+
checkListType: 1,
|
|
772
|
+
createdByName: 1,
|
|
773
|
+
publish: 1,
|
|
774
|
+
scheduleEndTime: 1,
|
|
775
|
+
scheduleRepeatedType: 1,
|
|
776
|
+
scheduleStartTime: 1,
|
|
777
|
+
sourceCheckList_id: '$_id',
|
|
778
|
+
storeCount: 1,
|
|
779
|
+
submitTime_string: 1,
|
|
780
|
+
scheduleEndTimeISO: 1,
|
|
781
|
+
},
|
|
782
|
+
},
|
|
783
|
+
], as: 'checklistData',
|
|
784
|
+
},
|
|
785
|
+
},
|
|
786
|
+
{ $unwind: { path: '$checklistData', preserveNullAndEmptyArrays: true } },
|
|
787
|
+
{
|
|
788
|
+
$project: {
|
|
789
|
+
sourceCheckList_id: '$checklistData._id',
|
|
790
|
+
checkListName: '$checklistData.checkListName',
|
|
791
|
+
checkListNameLowercase: { $toLower: '$checkListName' },
|
|
792
|
+
checkListType: '$checklistData.checkListType',
|
|
793
|
+
createdByName: '$checklistData.createdByName',
|
|
794
|
+
storeCount: '$checklistData.storeCount',
|
|
795
|
+
scheduleEndTimeISO: '$checklistData.scheduleEndTimeISO',
|
|
796
|
+
submitTime_string: '$checklistData.submitTime_string',
|
|
797
|
+
_id: '$checklistData._id',
|
|
798
|
+
publish: '$checklistData.publish',
|
|
799
|
+
scheduleEndTime: '$checklistData.scheduleEndTime',
|
|
800
|
+
scheduleRepeatedType: '$checklistData.scheduleRepeatedType',
|
|
801
|
+
scheduleStartTime: '$checklistData.scheduleStartTime',
|
|
802
|
+
},
|
|
803
|
+
},
|
|
804
|
+
];
|
|
805
|
+
if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy !='' ) {
|
|
806
|
+
findQuery.push( { $sort: { [requestData.sortColumnName]: requestData.sortBy } } );
|
|
807
|
+
} else {
|
|
808
|
+
findQuery.push( { $sort: { ['checkListNameLowercase']: -1 } } );
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
let getChecklistData = await processedTaskService.aggregate( findQuery );
|
|
812
|
+
if ( !getChecklistData.length ) {
|
|
813
|
+
return res.sendError( { error: 'No Data Found' }, 204 );
|
|
814
|
+
}
|
|
815
|
+
result.totalCount = getChecklistData.length;
|
|
816
|
+
result.taskDropdown = getChecklistData;
|
|
817
|
+
return res.sendSuccess( result );
|
|
818
|
+
} catch ( error ) {
|
|
819
|
+
console.log( 'error =>', error );
|
|
820
|
+
logger.error( { error: error, message: req.query, function: 'checklistDropdownV1' } );
|
|
821
|
+
return res.sendError( { error: error }, 500 );
|
|
822
|
+
}
|
|
823
|
+
};
|
|
716
824
|
export const taskInfoView = async ( req, res ) => {
|
|
717
825
|
try {
|
|
718
826
|
let requestData = req.body;
|
|
@@ -785,5 +893,3 @@ export const taskDeleteV1 = async ( req, res ) => {
|
|
|
785
893
|
return res.sendError( e, 500 );
|
|
786
894
|
}
|
|
787
895
|
};
|
|
788
|
-
|
|
789
|
-
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
export const taskDashboardRouter = express.Router();
|
|
3
|
+
import { isAllowedSessionHandler, accessVerification, isAllowedClient } from 'tango-app-api-middleware';
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
6
|
overallCards, taskTable, taskInfoTable, taskDropdownList, taskTableV1, overallCardsV1, taskInfoTableV1, taskDropdownListV1, taskDeleteV1,
|
|
6
7
|
} from '../controllers/taskDashboard.controllers.js';
|
|
7
8
|
|
|
8
9
|
taskDashboardRouter
|
|
9
|
-
.post( '/overallcards', overallCards )
|
|
10
|
-
.post( '/overallcardsV1', overallCardsV1 )
|
|
11
|
-
.post( '/taskTable', taskTable )
|
|
12
|
-
.post( '/taskTableV1', taskTableV1 )
|
|
13
|
-
.post( '/taskInfoTable', taskInfoTable )
|
|
14
|
-
.post( '/taskInfoTableV1', taskInfoTableV1 )
|
|
15
|
-
.post( '/taskDropdownList', taskDropdownList )
|
|
16
|
-
.post( '/taskDropdownListV1', taskDropdownListV1 )
|
|
17
|
-
.post( '/taskDeleteV1', taskDeleteV1 );
|
|
10
|
+
.post( '/overallcards', isAllowedSessionHandler, overallCards )
|
|
11
|
+
.post( '/overallcardsV1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [] } ] } ), overallCardsV1 )
|
|
12
|
+
.post( '/taskTable', isAllowedSessionHandler, taskTable )
|
|
13
|
+
.post( '/taskTableV1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [] } ] } ), taskTableV1 )
|
|
14
|
+
.post( '/taskInfoTable', isAllowedSessionHandler, taskInfoTable )
|
|
15
|
+
.post( '/taskInfoTableV1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [] } ] } ), taskInfoTableV1 )
|
|
16
|
+
.post( '/taskDropdownList', isAllowedSessionHandler, taskDropdownList )
|
|
17
|
+
.post( '/taskDropdownListV1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [] } ] } ), taskDropdownListV1 )
|
|
18
|
+
.post( '/taskDeleteV1', isAllowedSessionHandler, taskDeleteV1 );
|
|
18
19
|
|
|
19
20
|
export default taskDashboardRouter;
|