tango-app-api-task 1.0.0-alpha.21 → 1.0.0-alpha.22
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
|
@@ -133,21 +133,22 @@ async function insertData( requestData ) {
|
|
|
133
133
|
for ( let [ index2, element2 ] of resultchecklist.entries() ) {
|
|
134
134
|
let getCLconfig = await taskService.findOne( { _id: element2 } );
|
|
135
135
|
if ( getCLconfig ) {
|
|
136
|
-
if ( dayjs( getCLconfig?.scheduleDate ).format( 'YYYY-MM-DD' ) != dayjs( date ).format( 'YYYY-MM-DD' ) ) {
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
console.log( getCLconfig.scheduleEndTime );
|
|
140
|
-
|
|
136
|
+
// if ( dayjs( getCLconfig?.scheduleDate ).format( 'YYYY-MM-DD' ) != dayjs( date ).format( 'YYYY-MM-DD' ) ) {
|
|
137
|
+
// getCLconfig.scheduleEndTime = '11:59 PM';
|
|
138
|
+
// }
|
|
139
|
+
// console.log( getCLconfig.scheduleEndTime );
|
|
140
|
+
let sTime = dayjs.utc( getCLconfig.publishDate ).format( 'hh:mm A' );
|
|
141
141
|
let startTimeIso; let endTimeIso;
|
|
142
|
-
startTimeIso = dayjs.utc( `${currentdate}
|
|
143
|
-
endTimeIso = dayjs.utc(
|
|
142
|
+
startTimeIso = dayjs.utc( `${currentdate} ${sTime}`, 'YYYY-MM-DD hh:mm A' );
|
|
143
|
+
endTimeIso = dayjs.utc( getCLconfig.scheduleEndTimeISO );
|
|
144
144
|
console.log( endTimeIso );
|
|
145
145
|
|
|
146
146
|
let insertdata = {};
|
|
147
|
-
insertdata.date_iso =
|
|
147
|
+
insertdata.date_iso = new Date( dayjs( currentdate, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) );
|
|
148
148
|
insertdata.date_string = currentdate;
|
|
149
149
|
insertdata.sourceCheckList_id = getCLconfig._id;
|
|
150
150
|
insertdata.checkListName = getCLconfig.checkListName;
|
|
151
|
+
insertdata.checkListDescription = getCLconfig.checkListName;
|
|
151
152
|
insertdata.publish = getCLconfig.publish;
|
|
152
153
|
insertdata.scheduleStartTime = startTimeIso.format();
|
|
153
154
|
insertdata.scheduleStartTime_iso = startTimeIso.format();
|
|
@@ -244,6 +245,7 @@ async function insertData( requestData ) {
|
|
|
244
245
|
delete element4.updatedAt;
|
|
245
246
|
element4.checkListId = updatedchecklist._id;
|
|
246
247
|
element4.checkListName = getCLconfig.checkListName;
|
|
248
|
+
element4.checkListDescription = getCLconfig.checkListDescription;
|
|
247
249
|
element4.date_iso = new Date( currentdate );
|
|
248
250
|
element4.date_string = currentdate;
|
|
249
251
|
element4.allowedOverTime = false;
|
|
@@ -108,11 +108,13 @@ export async function createUpdateTask( req, res ) {
|
|
|
108
108
|
section.questionReferenceImage = image;
|
|
109
109
|
}
|
|
110
110
|
section.answers.forEach( ( answer ) => {
|
|
111
|
-
if ( answer.referenceImage
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
if ( answer.referenceImage.length ) {
|
|
112
|
+
answer.referenceImage = answer.referenceImage.map( ( value ) => {
|
|
113
|
+
let imgUrl = decodeURIComponent( value?.split( '?' )[0] );
|
|
114
|
+
let url = imgUrl.split( '/' );
|
|
115
|
+
url.splice( 0, 3 );
|
|
116
|
+
return url.join( '/' );
|
|
117
|
+
} );
|
|
116
118
|
}
|
|
117
119
|
} );
|
|
118
120
|
} );
|
|
@@ -256,12 +258,16 @@ export async function taskDetails( req, res ) {
|
|
|
256
258
|
}
|
|
257
259
|
}
|
|
258
260
|
question.answers.forEach( async ( answer ) => {
|
|
259
|
-
if ( answer.referenceImage
|
|
260
|
-
let
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
261
|
+
if ( answer.referenceImage.length > 0 ) {
|
|
262
|
+
let updatedImages = [];
|
|
263
|
+
for ( let refImage of answer.referenceImage ) {
|
|
264
|
+
let inputData = {
|
|
265
|
+
Bucket: bucket.sop,
|
|
266
|
+
file_path: decodeURIComponent( refImage ),
|
|
267
|
+
};
|
|
268
|
+
updatedImages.push( await signedUrl( inputData ) );
|
|
269
|
+
}
|
|
270
|
+
answer.referenceImage = updatedImages;
|
|
265
271
|
}
|
|
266
272
|
} );
|
|
267
273
|
} );
|
|
@@ -665,7 +671,7 @@ export async function taskConfig( req, res ) {
|
|
|
665
671
|
} ) : [];
|
|
666
672
|
let endDate = dayjs.utc( configDetails?.scheduleDate ).format( 'YYYY-MM-DD' ) + ' ' + configDetails.scheduleEndTime;
|
|
667
673
|
configDetails.scheduleEndTimeISO = dayjs.utc( endDate, 'YYYY-MM-DD hh:mm A' ).format();
|
|
668
|
-
configDetails.publishDate = dayjs().format();
|
|
674
|
+
configDetails.publishDate = dayjs.utc( dayjs().format( 'hh:mm A' ), 'hh:mm A' ).format();
|
|
669
675
|
|
|
670
676
|
let response = await taskService.updateOne( { _id: inputBody._id }, configDetails );
|
|
671
677
|
if ( inputBody?.approver.length ) {
|
|
@@ -752,7 +758,7 @@ export async function taskConfig( req, res ) {
|
|
|
752
758
|
}
|
|
753
759
|
}
|
|
754
760
|
} catch ( e ) {
|
|
755
|
-
logger.error( { functionName: '
|
|
761
|
+
logger.error( { functionName: 'taskConfig =>', error: e, message: req.body } );
|
|
756
762
|
return res.sendError( e, 500 );
|
|
757
763
|
}
|
|
758
764
|
}
|
|
@@ -767,20 +773,21 @@ export async function insertSingleProcessData( checklistId ) {
|
|
|
767
773
|
let endDate = dayjs( getCLconfig?.scheduleDate ).format( 'YYYY-MM-DD' ) + ' ' + getCLconfig.scheduleEndTime;
|
|
768
774
|
endDate = dayjs.utc( endDate, 'YYYY-MM-DD hh:mm A' ).format();
|
|
769
775
|
if ( endDate >= date ) {
|
|
770
|
-
if ( dayjs( getCLconfig?.scheduleDate ).format( 'YYYY-MM-DD' ) != dayjs( currentdate ).format( 'YYYY-MM-DD' ) ) {
|
|
771
|
-
|
|
772
|
-
}
|
|
776
|
+
// if ( dayjs( getCLconfig?.scheduleDate ).format( 'YYYY-MM-DD' ) != dayjs( currentdate ).format( 'YYYY-MM-DD' ) ) {
|
|
777
|
+
// getCLconfig.scheduleEndTime = '11:59 PM';
|
|
778
|
+
// }
|
|
773
779
|
} else {
|
|
774
780
|
return false;
|
|
775
781
|
}
|
|
776
|
-
|
|
777
|
-
startTimeIso = dayjs.utc(
|
|
778
|
-
endTimeIso = dayjs.utc( getCLconfig.
|
|
782
|
+
let sTime = dayjs.utc( getCLconfig.publishDate ).format( 'hh:mm A' );
|
|
783
|
+
startTimeIso = dayjs.utc( sTime, 'hh:mm A' );
|
|
784
|
+
endTimeIso = dayjs.utc( getCLconfig.scheduleEndTimeISO );
|
|
779
785
|
let insertdata = {};
|
|
780
|
-
insertdata.date_iso =
|
|
786
|
+
insertdata.date_iso = new Date( dayjs( date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) );
|
|
781
787
|
insertdata.date_string = dayjs( currentdate ).format( 'YYYY-MM-DD' );
|
|
782
788
|
insertdata.sourceCheckList_id = getCLconfig._id;
|
|
783
789
|
insertdata.checkListName = getCLconfig.checkListName;
|
|
790
|
+
insertdata.checkListDescription = getCLconfig.checkListDescription;
|
|
784
791
|
insertdata.publish = getCLconfig.publish;
|
|
785
792
|
insertdata.scheduleStartTime = '12:00 AM';
|
|
786
793
|
insertdata.scheduleStartTime_iso = startTimeIso.format();
|
|
@@ -882,7 +889,8 @@ async function insertPCBulkV3( getCLconfig, checklistId, currentdate, updatedche
|
|
|
882
889
|
delete element4.updatedAt;
|
|
883
890
|
element4.checkListId = updatedchecklist._id;
|
|
884
891
|
element4.checkListName = getCLconfig.checkListName;
|
|
885
|
-
element4.
|
|
892
|
+
element4.checkListDescription = getCLconfig.checkListDescription;
|
|
893
|
+
element4.date_iso = new Date( dayjs( date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) );
|
|
886
894
|
element4.date_string = dayjs( currentdate ).format( 'YYYY-MM-DD' );
|
|
887
895
|
element4.allowedOverTime = false;
|
|
888
896
|
element4.allowedStoreLocation = getCLconfig.allowedStoreLocation;
|
|
@@ -910,7 +918,6 @@ async function insertPCBulkV3( getCLconfig, checklistId, currentdate, updatedche
|
|
|
910
918
|
assigndeletequery.date_string = insertdata.date_string;
|
|
911
919
|
assigndeletequery.date_iso = insertdata.date_iso;
|
|
912
920
|
assigndeletequery.client_id = insertdata.client_id;
|
|
913
|
-
assigndeletequery.brandId = insertdata.brandId;
|
|
914
921
|
assigndeletequery.checkListId = updatedchecklist._id;
|
|
915
922
|
assigndeletequery.checklistStatus = { $nin: [ 'submit' ] };
|
|
916
923
|
await taskProcessedService.deleteMany( assigndeletequery );
|
|
@@ -1078,7 +1085,7 @@ export async function createChecklistTask( req, res ) {
|
|
|
1078
1085
|
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
1079
1086
|
};
|
|
1080
1087
|
|
|
1081
|
-
if ( req.user.userType == 'tango' || ( req.user.userType == 'client' && [ 'user' ].includes( req.
|
|
1088
|
+
if ( req.user.userType == 'tango' || ( req.user.userType == 'client' && [ 'user' ].includes( req.user.role ) ) ) {
|
|
1082
1089
|
let userList = await userService.findOne( { clientId: inputBody.clientId, role: 'superadmin' }, { userName: 1, email: 1 } );
|
|
1083
1090
|
if ( userList ) {
|
|
1084
1091
|
data['approver'] = { name: userList.userName, value: userList.email };
|
|
@@ -1113,6 +1120,16 @@ export async function createChecklistTask( req, res ) {
|
|
|
1113
1120
|
} );
|
|
1114
1121
|
inputBody.question[0].questionReferenceImage = images;
|
|
1115
1122
|
}
|
|
1123
|
+
if ( inputBody.question[0].answers[0].referenceImage.length ) {
|
|
1124
|
+
let images = [];
|
|
1125
|
+
inputBody.question[0].answers[0].referenceImage.forEach( ( ele ) => {
|
|
1126
|
+
let imgUrl = decodeURIComponent( ele.split( '?' )[0] );
|
|
1127
|
+
let url = imgUrl.split( '/' );
|
|
1128
|
+
url.splice( 0, 3 );
|
|
1129
|
+
images.push( url.join( '/' ) );
|
|
1130
|
+
} );
|
|
1131
|
+
inputBody.question[0].answers[0].referenceImage = images;
|
|
1132
|
+
}
|
|
1116
1133
|
let question = {
|
|
1117
1134
|
checkListId: response?._id,
|
|
1118
1135
|
question: inputBody.question,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as taskService from '../service/task.service.js';
|
|
2
2
|
import * as processedTaskService from '../service/processedTaskList.service.js';
|
|
3
|
-
import { logger } from 'tango-app-api-middleware';
|
|
3
|
+
import { logger, download } from 'tango-app-api-middleware';
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
5
|
import mongoose from 'mongoose';
|
|
6
6
|
// const ObjectId = mongoose.Types.ObjectId;
|
|
@@ -893,3 +893,109 @@ export const taskDeleteV1 = async ( req, res ) => {
|
|
|
893
893
|
return res.sendError( e, 500 );
|
|
894
894
|
}
|
|
895
895
|
};
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
export async function taskDetails( req, res ) {
|
|
899
|
+
try {
|
|
900
|
+
if ( !req.body.fromDate || !req.body.toDate ) {
|
|
901
|
+
return res.sendError( 'fromDate or toDate is missing', 400 );
|
|
902
|
+
}
|
|
903
|
+
if ( !req.body.clientId ) {
|
|
904
|
+
return res.sendError( 'clientId is required', 400 );
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
let toDate = new Date( req.body.toDate );
|
|
908
|
+
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
909
|
+
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
910
|
+
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
911
|
+
let limit = req.body?.limit || 10;
|
|
912
|
+
let page = req.body?.offset ? ( req.body.offset * req.body.limit ) : 0;
|
|
913
|
+
|
|
914
|
+
let query = [
|
|
915
|
+
{
|
|
916
|
+
$match: {
|
|
917
|
+
date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
|
|
918
|
+
client_id: req.body.clientId,
|
|
919
|
+
...( req.body?.storeId?.length ) ? { store_id: { $in: req.body.storeId } } : {},
|
|
920
|
+
},
|
|
921
|
+
},
|
|
922
|
+
{ $sort: { date_iso: -1 } },
|
|
923
|
+
{
|
|
924
|
+
$group: {
|
|
925
|
+
_id: '$sourceCheckList_id',
|
|
926
|
+
checkListName: { $first: '$checkListName' },
|
|
927
|
+
createdByName: { $first: '$createdByName' },
|
|
928
|
+
publishDate: { $first: '$publishDate' },
|
|
929
|
+
priorityType: { $first: '$priorityType' },
|
|
930
|
+
storeCount: { $first: '$storeCount' },
|
|
931
|
+
submitCount: { $sum: { $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, 1, 0 ] } },
|
|
932
|
+
redoCount: { $sum: { $cond: [ { $eq: [ '$redoStatus', true ] }, 1, 0 ] } },
|
|
933
|
+
scheduleEndTime_iso: { $first: '$scheduleEndTime_iso' },
|
|
934
|
+
},
|
|
935
|
+
},
|
|
936
|
+
];
|
|
937
|
+
|
|
938
|
+
if ( req.body?.searchValue.trim().length ) {
|
|
939
|
+
query.push(
|
|
940
|
+
{
|
|
941
|
+
$match: {
|
|
942
|
+
checkListName: { $regex: req.body.searchValue, $options: 'i' },
|
|
943
|
+
},
|
|
944
|
+
},
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
if ( req.body.sortColumnName && req.body.sortBy ) {
|
|
949
|
+
query.push( {
|
|
950
|
+
$sort: { [req.body.sortColumnName]: req.body.sortBy },
|
|
951
|
+
} );
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
if ( req.body.filter.length ) {
|
|
955
|
+
query.push( {
|
|
956
|
+
$match: { priorityType: { $in: req.body.filter } },
|
|
957
|
+
} );
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
query.push( {
|
|
961
|
+
$facet: {
|
|
962
|
+
data: [
|
|
963
|
+
{ $skip: page }, { $limit: limit },
|
|
964
|
+
],
|
|
965
|
+
count: [
|
|
966
|
+
{ $count: 'total' },
|
|
967
|
+
],
|
|
968
|
+
},
|
|
969
|
+
} );
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
let taskDetails = await processedTaskService.aggregate( query );
|
|
973
|
+
|
|
974
|
+
if ( req.body.export ) {
|
|
975
|
+
const exportResult = [];
|
|
976
|
+
for ( let task of taskDetails[0].data ) {
|
|
977
|
+
exportResult.push( {
|
|
978
|
+
'Checklist Name': task?.checkListName ||'',
|
|
979
|
+
'Created by': task?.createdByName||'',
|
|
980
|
+
'Created On': task?.publishDate||'',
|
|
981
|
+
'Priority': task?.priorityType || '',
|
|
982
|
+
'Assigned To': task?.storeCount||'',
|
|
983
|
+
'Submitted': task?.submitCount||'',
|
|
984
|
+
'Redo': task?.redoCount||'',
|
|
985
|
+
'Due on': task?.scheduleEndTime_iso||'',
|
|
986
|
+
} );
|
|
987
|
+
}
|
|
988
|
+
await download( exportResult, res );
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
if ( !taskDetails[0].data.length ) {
|
|
993
|
+
return res.sendError( 'no date found', 204 );
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
return res.sendSuccess( { data: taskDetails?.[0]?.data || [], count: taskDetails?.[0]?.count?.[0]?.total || 0 } );
|
|
997
|
+
} catch ( e ) {
|
|
998
|
+
logger.error( { function: 'taskDetails', error: e, message: req.body } );
|
|
999
|
+
return res.sendError( e, 500 );
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
@@ -3,7 +3,7 @@ export const taskDashboardRouter = express.Router();
|
|
|
3
3
|
import { isAllowedSessionHandler, accessVerification, isAllowedClient } from 'tango-app-api-middleware';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
overallCards, taskTable, taskInfoTable, taskDropdownList, taskTableV1, overallCardsV1, taskInfoTableV1, taskDropdownListV1, taskDeleteV1,
|
|
6
|
+
overallCards, taskTable, taskInfoTable, taskDropdownList, taskTableV1, overallCardsV1, taskInfoTableV1, taskDropdownListV1, taskDeleteV1, taskDetails,
|
|
7
7
|
} from '../controllers/taskDashboard.controllers.js';
|
|
8
8
|
|
|
9
9
|
taskDashboardRouter
|
|
@@ -15,6 +15,7 @@ taskDashboardRouter
|
|
|
15
15
|
.post( '/taskInfoTableV1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [] } ] } ), taskInfoTableV1 )
|
|
16
16
|
.post( '/taskDropdownList', isAllowedSessionHandler, taskDropdownList )
|
|
17
17
|
.post( '/taskDropdownListV1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [] } ] } ), taskDropdownListV1 )
|
|
18
|
-
.post( '/taskDeleteV1', isAllowedSessionHandler, taskDeleteV1 )
|
|
18
|
+
.post( '/taskDeleteV1', isAllowedSessionHandler, taskDeleteV1 )
|
|
19
|
+
.post( '/taskDetails', isAllowedSessionHandler, taskDetails );
|
|
19
20
|
|
|
20
21
|
export default taskDashboardRouter;
|