tango-app-api-client 3.4.0-beta.7 → 3.4.2-v1remove-0
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 +2 -2
- package/src/controllers/client.controllers.js +370 -302
- package/src/dtos/client.dtos.js +20 -0
- package/src/hbs/approved-client.hbs +170 -170
- package/src/routes/client.routes.js +10 -2
- package/src/service/auditConfig.service.js +13 -0
|
@@ -10,16 +10,17 @@ import { aggregateTickets } from '../service/tangoticket.service.js';
|
|
|
10
10
|
import { join } from 'path';
|
|
11
11
|
import { readFileSync } from 'fs';
|
|
12
12
|
import handlebars from 'handlebars';
|
|
13
|
-
import { countDocumentsGroup, createGroupModel
|
|
13
|
+
import { countDocumentsGroup, createGroupModel } from '../service/group.service.js';
|
|
14
14
|
// import { deleteOneAuthentication } from '../service/authentication.service.js';
|
|
15
15
|
import { createBilling } from '../service/billing.service.js';
|
|
16
16
|
import { createPaymentAccount } from '../service/paymentAccount.service.js';
|
|
17
17
|
import { countDocumentsClusters, createclusterModel } from '../service/cluster.service.js';
|
|
18
18
|
import { countDocumentsTeams } from '../service/teams.service.js';
|
|
19
|
+
import { createauditConfig, updateauditConfig, aggregateAuditconfig } from '../service/auditConfig.service.js';
|
|
19
20
|
|
|
20
21
|
export async function create( req, res ) {
|
|
21
22
|
try {
|
|
22
|
-
const url = JSON.parse( process.env.URL );
|
|
23
|
+
// const url = JSON.parse( process.env.URL );
|
|
23
24
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
24
25
|
const inputData = req.body;
|
|
25
26
|
const countQuery = [
|
|
@@ -96,7 +97,7 @@ export async function create( req, res ) {
|
|
|
96
97
|
record.featureConfigs.isNewZone = true;
|
|
97
98
|
}
|
|
98
99
|
if ( data.productName === 'tangoTrax' ) {
|
|
99
|
-
record.featureConfigs.
|
|
100
|
+
record.featureConfigs.isTrax = true;
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
}
|
|
@@ -178,125 +179,118 @@ export async function create( req, res ) {
|
|
|
178
179
|
|
|
179
180
|
await createBilling( primaryBillingGroup );
|
|
180
181
|
|
|
181
|
-
const createdGroup = await findOneGroup( { clientId: insertedClientRecord.clientId, isDefault: true }, {} );
|
|
182
|
-
|
|
183
|
-
let oldGroup = {
|
|
184
|
-
'_id': createdGroup._id,
|
|
185
|
-
'client_id': createdGroup.clientId,
|
|
186
|
-
'groupName': createdGroup.groupName,
|
|
187
|
-
'description': createdGroup.description,
|
|
188
|
-
'storeList': createdGroup.storeList,
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
await postApi( `${url.oldapidomain}/oldGroupAdd`, [ oldGroup ] );
|
|
193
|
-
|
|
194
182
|
// For old dashboard insert
|
|
183
|
+
// const createdGroup = await findOneGroup( { clientId: insertedClientRecord.clientId, isDefault: true }, {} );
|
|
184
|
+
// let oldGroup = {
|
|
185
|
+
// '_id': createdGroup._id,
|
|
186
|
+
// 'client_id': createdGroup.clientId,
|
|
187
|
+
// 'groupName': createdGroup.groupName,
|
|
188
|
+
// 'description': createdGroup.description,
|
|
189
|
+
// 'storeList': createdGroup.storeList,
|
|
190
|
+
// };
|
|
191
|
+
// await postApi( `${url.oldapidomain}/oldGroupAdd`, [ oldGroup ] );
|
|
192
|
+
|
|
193
|
+
// const oldBrandInsertData = {
|
|
194
|
+
// '_id': insertedClientRecord._id,
|
|
195
|
+
// 'brandName': insertedClientRecord.clientName,
|
|
196
|
+
// 'brandIndex': insertedClientRecord.tangoId,
|
|
197
|
+
// 'client_id': insertedClientRecord.clientId,
|
|
198
|
+
// 'phone': user.mobileNumber,
|
|
199
|
+
// 'email': user.email,
|
|
200
|
+
// 'dialCode': user.countryCode,
|
|
201
|
+
// 'name': user.userName,
|
|
202
|
+
// 'cameraCount': insertedClientRecord.planDetails.totalCamera,
|
|
203
|
+
// 'apiKey': insertedClientRecord.clientApi.apiKey,
|
|
204
|
+
// 'clientStatus': insertedClientRecord.status,
|
|
205
|
+
// 'client_type': insertedClientRecord.planDetails.paymentStatus,
|
|
206
|
+
// 'activeMenu': [
|
|
207
|
+
// 'reports',
|
|
208
|
+
// 'birdsEye',
|
|
209
|
+
// 'tangoZone',
|
|
210
|
+
// 'tangoTraffic',
|
|
211
|
+
// 'support',
|
|
212
|
+
// ],
|
|
213
|
+
// 'planType': insertedClientRecord.planDetails.subscriptionPeriod,
|
|
214
|
+
// 'storeCount': insertedClientRecord.planDetails.totalStores,
|
|
215
|
+
// 'squareFeet': insertedClientRecord.planDetails.storeSize,
|
|
216
|
+
// 'subscription': insertedClientRecord.planDetails.subscriptionType,
|
|
217
|
+
// 'subscription_status': true,
|
|
218
|
+
// 'subscribed_features': {
|
|
219
|
+
// 'tango_traffic': false,
|
|
220
|
+
// 'tango_zone': false,
|
|
221
|
+
// 'tango_revop': false,
|
|
222
|
+
// 'tango_storeops': false,
|
|
223
|
+
// 'controlroom': false,
|
|
224
|
+
// 'live_data': false,
|
|
225
|
+
// 'normalization_features': false,
|
|
226
|
+
// 'actual_features': false,
|
|
227
|
+
// },
|
|
228
|
+
// 'store_added_status': true,
|
|
229
|
+
// 'terms_conditions': true,
|
|
230
|
+
// 'otp_verified': true,
|
|
231
|
+
// 'price': 6510,
|
|
232
|
+
// 'currency_type': 'rupees',
|
|
233
|
+
// 'domains': [],
|
|
234
|
+
// 'store_radius_config': 500,
|
|
235
|
+
// };
|
|
236
|
+
|
|
237
|
+
// insertedClientRecord.planDetails.product.forEach( ( element ) => {
|
|
238
|
+
// if ( element.productName === 'tangoTraffic' ) {
|
|
239
|
+
// oldBrandInsertData.subscribed_features.tango_traffic = true;
|
|
240
|
+
// }
|
|
241
|
+
// if ( element.productName === 'tangoZone' ) {
|
|
242
|
+
// oldBrandInsertData.subscribed_features.tango_zone = true;
|
|
243
|
+
// }
|
|
244
|
+
// if ( element.productName === 'prioritySupport' ) {
|
|
245
|
+
// oldBrandInsertData.subscribed_features.tango_storeops = true;
|
|
246
|
+
// }
|
|
247
|
+
// } );
|
|
248
|
+
|
|
249
|
+
// switch ( insertedClientRecord.status ) {
|
|
250
|
+
// case 'active':
|
|
251
|
+
// oldBrandInsertData.clientStatus = 'live';
|
|
252
|
+
// break;
|
|
253
|
+
// case 'hold':
|
|
254
|
+
// oldBrandInsertData.clientStatus = 'hold';
|
|
255
|
+
// break;
|
|
256
|
+
// case 'suspended':
|
|
257
|
+
// oldBrandInsertData.clientStatus = 'suspended';
|
|
258
|
+
// break;
|
|
259
|
+
// case 'deactive':
|
|
260
|
+
// oldBrandInsertData.clientStatus = 'deactivated';
|
|
261
|
+
// break;
|
|
262
|
+
// default:
|
|
263
|
+
// oldBrandInsertData.clientStatus = 'live';
|
|
264
|
+
// }
|
|
265
|
+
|
|
266
|
+
// switch ( insertedClientRecord.planDetails.paymentStatus ) {
|
|
267
|
+
// case 'free':
|
|
268
|
+
// oldBrandInsertData.client_type = 'free';
|
|
269
|
+
// break;
|
|
270
|
+
// case 'trial':
|
|
271
|
+
// oldBrandInsertData.client_type = 'trial';
|
|
272
|
+
// break;
|
|
273
|
+
// case 'paid':
|
|
274
|
+
// oldBrandInsertData.client_type = 'paid';
|
|
275
|
+
// break;
|
|
276
|
+
// default:
|
|
277
|
+
// oldBrandInsertData.client_type = 'trial';
|
|
278
|
+
// }
|
|
279
|
+
// await postApi( `${url.oldapidomain}/oldBrandAdd`, oldBrandInsertData );
|
|
280
|
+
|
|
281
|
+
// const oldDefaultRolesInsertData = {
|
|
282
|
+
// '_id': user._id,
|
|
283
|
+
// 'client_id': insertedClientRecord.clientId,
|
|
284
|
+
// 'brandId': insertedClientRecord._id,
|
|
285
|
+
// 'name': user.userName,
|
|
286
|
+
// 'email': user.email,
|
|
287
|
+
// 'phone': user.mobileNumber,
|
|
288
|
+
// 'password': user.password,
|
|
289
|
+
// 'role': 'storesuperadmin',
|
|
290
|
+
// };
|
|
291
|
+
// await postApi( `${url.oldapidomain}/oldDefaultRoleInsert`, oldDefaultRolesInsertData );
|
|
195
292
|
|
|
196
293
|
|
|
197
|
-
const oldBrandInsertData = {
|
|
198
|
-
'_id': insertedClientRecord._id,
|
|
199
|
-
'brandName': insertedClientRecord.clientName,
|
|
200
|
-
'brandIndex': insertedClientRecord.tangoId,
|
|
201
|
-
'client_id': insertedClientRecord.clientId,
|
|
202
|
-
'phone': user.mobileNumber,
|
|
203
|
-
'email': user.email,
|
|
204
|
-
'dialCode': user.countryCode,
|
|
205
|
-
'name': user.userName,
|
|
206
|
-
'cameraCount': insertedClientRecord.planDetails.totalCamera,
|
|
207
|
-
'apiKey': insertedClientRecord.clientApi.apiKey,
|
|
208
|
-
'clientStatus': insertedClientRecord.status,
|
|
209
|
-
'client_type': insertedClientRecord.planDetails.paymentStatus,
|
|
210
|
-
'activeMenu': [
|
|
211
|
-
'reports',
|
|
212
|
-
'birdsEye',
|
|
213
|
-
'tangoZone',
|
|
214
|
-
'tangoTraffic',
|
|
215
|
-
'support',
|
|
216
|
-
],
|
|
217
|
-
'planType': insertedClientRecord.planDetails.subscriptionPeriod,
|
|
218
|
-
'storeCount': insertedClientRecord.planDetails.totalStores,
|
|
219
|
-
'squareFeet': insertedClientRecord.planDetails.storeSize,
|
|
220
|
-
'subscription': insertedClientRecord.planDetails.subscriptionType,
|
|
221
|
-
'subscription_status': true,
|
|
222
|
-
'subscribed_features': {
|
|
223
|
-
'tango_traffic': false,
|
|
224
|
-
'tango_zone': false,
|
|
225
|
-
'tango_revop': false,
|
|
226
|
-
'tango_storeops': false,
|
|
227
|
-
'controlroom': false,
|
|
228
|
-
'live_data': false,
|
|
229
|
-
'normalization_features': false,
|
|
230
|
-
'actual_features': false,
|
|
231
|
-
},
|
|
232
|
-
'store_added_status': true,
|
|
233
|
-
'terms_conditions': true,
|
|
234
|
-
'otp_verified': true,
|
|
235
|
-
'price': 6510,
|
|
236
|
-
'currency_type': 'rupees',
|
|
237
|
-
'domains': [],
|
|
238
|
-
'store_radius_config': 500,
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
insertedClientRecord.planDetails.product.forEach( ( element ) => {
|
|
242
|
-
if ( element.productName === 'tangoTraffic' ) {
|
|
243
|
-
oldBrandInsertData.subscribed_features.tango_traffic = true;
|
|
244
|
-
}
|
|
245
|
-
if ( element.productName === 'tangoZone' ) {
|
|
246
|
-
oldBrandInsertData.subscribed_features.tango_zone = true;
|
|
247
|
-
}
|
|
248
|
-
if ( element.productName === 'prioritySupport' ) {
|
|
249
|
-
oldBrandInsertData.subscribed_features.tango_storeops = true;
|
|
250
|
-
}
|
|
251
|
-
} );
|
|
252
|
-
|
|
253
|
-
switch ( insertedClientRecord.status ) {
|
|
254
|
-
case 'active':
|
|
255
|
-
oldBrandInsertData.clientStatus = 'live';
|
|
256
|
-
break;
|
|
257
|
-
case 'hold':
|
|
258
|
-
oldBrandInsertData.clientStatus = 'hold';
|
|
259
|
-
break;
|
|
260
|
-
case 'suspended':
|
|
261
|
-
oldBrandInsertData.clientStatus = 'suspended';
|
|
262
|
-
break;
|
|
263
|
-
case 'deactive':
|
|
264
|
-
oldBrandInsertData.clientStatus = 'deactivated';
|
|
265
|
-
break;
|
|
266
|
-
default:
|
|
267
|
-
oldBrandInsertData.clientStatus = 'live';
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
switch ( insertedClientRecord.planDetails.paymentStatus ) {
|
|
271
|
-
case 'free':
|
|
272
|
-
oldBrandInsertData.client_type = 'free';
|
|
273
|
-
break;
|
|
274
|
-
case 'trial':
|
|
275
|
-
oldBrandInsertData.client_type = 'trial';
|
|
276
|
-
break;
|
|
277
|
-
case 'paid':
|
|
278
|
-
oldBrandInsertData.client_type = 'paid';
|
|
279
|
-
break;
|
|
280
|
-
default:
|
|
281
|
-
oldBrandInsertData.client_type = 'trial';
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const oldDefaultRolesInsertData = {
|
|
286
|
-
'_id': user._id,
|
|
287
|
-
'client_id': insertedClientRecord.clientId,
|
|
288
|
-
'brandId': insertedClientRecord._id,
|
|
289
|
-
'name': user.userName,
|
|
290
|
-
'email': user.email,
|
|
291
|
-
'phone': user.mobileNumber,
|
|
292
|
-
'password': user.password,
|
|
293
|
-
'role': 'storesuperadmin',
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
await postApi( `${url.oldapidomain}/oldBrandAdd`, oldBrandInsertData );
|
|
297
|
-
|
|
298
|
-
await postApi( `${url.oldapidomain}/oldDefaultRoleInsert`, oldDefaultRolesInsertData );
|
|
299
|
-
|
|
300
294
|
const logObj = {
|
|
301
295
|
clientId: insertedClientRecord.clientId,
|
|
302
296
|
userName: req.user?.userName,
|
|
@@ -678,7 +672,7 @@ export async function detailedAllClientCount( req, res ) {
|
|
|
678
672
|
if ( result.length == 0 ) {
|
|
679
673
|
return res.sendError( 'No Data Found', 204 );
|
|
680
674
|
}
|
|
681
|
-
result[0].activeStoresCount = activeStores.length>0?Math.abs( activeStores.length - yettoInstallCount.length ):0;
|
|
675
|
+
result[0].activeStoresCount = activeStores.length > 0 ? Math.abs( activeStores.length - yettoInstallCount.length ) : 0;
|
|
682
676
|
result[0].activeCameraCount = activeCameras;
|
|
683
677
|
return res.sendSuccess( { result: result } );
|
|
684
678
|
} catch ( error ) {
|
|
@@ -697,7 +691,7 @@ export async function updateBrandInfo( req, res ) {
|
|
|
697
691
|
try {
|
|
698
692
|
const bucket = JSON.parse( process.env.BUCKET );
|
|
699
693
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
700
|
-
const url = JSON.parse( process.env.URL );
|
|
694
|
+
// const url = JSON.parse( process.env.URL );
|
|
701
695
|
let updateKeys = [];
|
|
702
696
|
|
|
703
697
|
if ( req.files?.logo ) {
|
|
@@ -769,7 +763,7 @@ export async function updateBrandInfo( req, res ) {
|
|
|
769
763
|
};
|
|
770
764
|
|
|
771
765
|
// Map and rename keys from current client info for UI display and logging
|
|
772
|
-
const newData ={
|
|
766
|
+
const newData = {
|
|
773
767
|
RegisteredCompanyName: getPosCientInfo?.profileDetails?.registeredCompanyName,
|
|
774
768
|
IndustryType: getPosCientInfo?.profileDetails?.industry,
|
|
775
769
|
FirmType: getPosCientInfo?.profileDetails?.clientType,
|
|
@@ -824,26 +818,24 @@ export async function updateBrandInfo( req, res ) {
|
|
|
824
818
|
await updateManyUser( { clientId: req.params?.id }, { isActive: false } );
|
|
825
819
|
}
|
|
826
820
|
|
|
827
|
-
const { data } = await getApi( `${url.oldapidomain}/oldBrandGet/${req.params?.id}` );
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
await postApi( `${url.oldapidomain}/oldBrandUpdate/${data?._id}`, { clientStatus: data.clientStatus } );
|
|
821
|
+
// const { data } = await getApi( `${url.oldapidomain}/oldBrandGet/${req.params?.id}` );
|
|
822
|
+
// switch ( req.body?.status ) {
|
|
823
|
+
// case 'active':
|
|
824
|
+
// data.clientStatus = 'live';
|
|
825
|
+
// break;
|
|
826
|
+
// case 'hold':
|
|
827
|
+
// data.clientStatus = 'hold';
|
|
828
|
+
// break;
|
|
829
|
+
// case 'suspended':
|
|
830
|
+
// data.clientStatus = 'suspended';
|
|
831
|
+
// break;
|
|
832
|
+
// case 'deactive':
|
|
833
|
+
// data.clientStatus = 'deactivated';
|
|
834
|
+
// break;
|
|
835
|
+
// default:
|
|
836
|
+
// data.clientStatus = 'live';
|
|
837
|
+
// }
|
|
838
|
+
// await postApi( `${url.oldapidomain}/oldBrandUpdate/${data?._id}`, { clientStatus: data.clientStatus } );
|
|
847
839
|
|
|
848
840
|
if ( updateAck ) {
|
|
849
841
|
return res.sendSuccess( { result: 'Updated Successfully' } );
|
|
@@ -955,7 +947,7 @@ export async function updateSignatoryDetails( req, res ) {
|
|
|
955
947
|
export async function updateTicketConfiguration( req, res ) {
|
|
956
948
|
try {
|
|
957
949
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
958
|
-
const fields ={
|
|
950
|
+
const fields = {
|
|
959
951
|
'ticketConfigs.downTimeType': 1,
|
|
960
952
|
'ticketConfigs.installationReAssign': 1,
|
|
961
953
|
'ticketConfigs.infraDownTime': 1,
|
|
@@ -996,7 +988,7 @@ export async function updateTicketConfiguration( req, res ) {
|
|
|
996
988
|
|
|
997
989
|
// Map and rename keys from previous client info for UI display and logging
|
|
998
990
|
const oldData = {
|
|
999
|
-
InfraDowntimeType: findClient?.ticketConfigs?.downTimeType==0? 'Single Camera': 'All Cameras',
|
|
991
|
+
InfraDowntimeType: findClient?.ticketConfigs?.downTimeType == 0 ? 'Single Camera' : 'All Cameras',
|
|
1000
992
|
AutoReAssignInstallation: findClient?.ticketConfigs?.installationReAssign,
|
|
1001
993
|
InfraDowntime: findClient?.ticketConfigs?.infraDownTime,
|
|
1002
994
|
InfraFiles: findClient?.ticketConfigs?.MinFilesCount,
|
|
@@ -1008,8 +1000,8 @@ export async function updateTicketConfiguration( req, res ) {
|
|
|
1008
1000
|
};
|
|
1009
1001
|
|
|
1010
1002
|
// Map and rename keys from current client info for UI display and logging
|
|
1011
|
-
const newData ={
|
|
1012
|
-
InfraDowntimeType: updatedClient?.ticketConfigs?.downTimeType==0? 'Single Camera': 'All Cameras',
|
|
1003
|
+
const newData = {
|
|
1004
|
+
InfraDowntimeType: updatedClient?.ticketConfigs?.downTimeType == 0 ? 'Single Camera' : 'All Cameras',
|
|
1013
1005
|
AutoReAssignInstallation: updatedClient?.ticketConfigs?.installationReAssign,
|
|
1014
1006
|
InfraDowntime: updatedClient?.ticketConfigs?.infraDownTime,
|
|
1015
1007
|
InfraFiles: updatedClient?.ticketConfigs?.MinFilesCount,
|
|
@@ -1056,7 +1048,7 @@ export async function updateTicketConfiguration( req, res ) {
|
|
|
1056
1048
|
export async function updateFeatureConfiguration( req, res ) {
|
|
1057
1049
|
try {
|
|
1058
1050
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1059
|
-
const url = JSON.parse( process.env.URL );
|
|
1051
|
+
// const url = JSON.parse( process.env.URL );
|
|
1060
1052
|
|
|
1061
1053
|
// Get updated client Feature configuration before the update operation (fetch selected fields only)
|
|
1062
1054
|
const previousData = await findOneClient( { clientId: req.params?.id }, { featureConfigs: 1 } );
|
|
@@ -1077,56 +1069,47 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
1077
1069
|
// Check if request body has any fields to update
|
|
1078
1070
|
if ( Object.keys( inputData ).length > 0 ) {
|
|
1079
1071
|
Object.keys( inputData ).forEach( ( element ) => {
|
|
1080
|
-
element === 'billableCalculation'? 'potentialCalculation': element; // Replace 'billableCalculation' with 'potentialCalculation' if present
|
|
1072
|
+
element === 'billableCalculation' ? 'potentialCalculation' : element; // Replace 'billableCalculation' with 'potentialCalculation' if present
|
|
1081
1073
|
updateKeys.push( camelCaseToWords( element ) ); // Convert camelCase field name to readable format and add to updateKeys
|
|
1082
1074
|
} );
|
|
1083
1075
|
}
|
|
1084
1076
|
|
|
1085
1077
|
const user = req.user;
|
|
1086
1078
|
|
|
1087
|
-
const { data } = await getApi( `${url.oldapidomain}/oldBrandGet/${req.params?.id}` );
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
if ( inputData?.
|
|
1098
|
-
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1079
|
+
// const { data } = await getApi( `${url.oldapidomain}/oldBrandGet/${req.params?.id}` );
|
|
1080
|
+
// if ( inputData?.open ) {
|
|
1081
|
+
// data.brandConfigs.storeOpenTime = inputData?.open;
|
|
1082
|
+
// }
|
|
1083
|
+
// if ( inputData?.close ) {
|
|
1084
|
+
// data.brandConfigs.storeCloseTime = inputData?.open;
|
|
1085
|
+
// }
|
|
1086
|
+
// if ( inputData?.missedOpportunityCalculation ) {
|
|
1087
|
+
// data.brandConfigs.missedOpportunityCalculate = inputData?.missedOpportunityCalculation;
|
|
1088
|
+
// }
|
|
1089
|
+
// if ( inputData?.conversionCalculation ) {
|
|
1090
|
+
// data.brandConfigs.conversionCalculate = inputData?.conversionCalculation;
|
|
1091
|
+
// }
|
|
1092
|
+
// if ( inputData?.billableCalculation ) {
|
|
1093
|
+
// data.brandConfigs.billableCalculate = inputData?.billableCalculation;
|
|
1094
|
+
// }
|
|
1095
|
+
// if ( inputData?.bouncedLimitCondition ) {
|
|
1096
|
+
// data.brandConfigs.bouncedConfigTime = data.brandConfigs.bouncedConfigTime.replace( /^.+(?=\d)/, inputData?.bouncedLimitCondition );
|
|
1097
|
+
// data.brandConfigs.missedOpportunityEndTime = data.brandConfigs.missedOpportunityEndTime.replace( /^.+(?=\d)/, inputData?.bouncedLimitCondition );
|
|
1098
|
+
// }
|
|
1099
|
+
// if ( inputData?.bouncedLimitValue ) {
|
|
1100
|
+
// data.brandConfigs.bouncedConfigTime = data.brandConfigs.bouncedConfigTime.replace( /\d+/, inputData?.bouncedLimitValue );
|
|
1101
|
+
// data.brandConfigs.missedOpportunityStartTime = data.brandConfigs.missedOpportunityStartTime.replace( /\d+/, inputData?.bouncedLimitValue );
|
|
1102
|
+
// }
|
|
1103
|
+
// if ( inputData?.conversionCondition ) {
|
|
1104
|
+
// data.brandConfigs.conversionConfigTime = data.brandConfigs.conversionConfigTime.replace( /^.+(?=\d)/, inputData?.conversionCondition );
|
|
1105
|
+
// data.brandConfigs.missedOpportunityStartTime = data.brandConfigs.missedOpportunityStartTime.replace( /^.+(?=\d)/, inputData?.conversionCondition );
|
|
1106
|
+
// }
|
|
1107
|
+
// if ( inputData?.conversionValue ) {
|
|
1108
|
+
// data.brandConfigs.conversionConfigTime = data.brandConfigs.conversionConfigTime.replace( /\d+/, inputData?.conversionValue );
|
|
1109
|
+
// data.brandConfigs.missedOpportunityEndTime = data.brandConfigs.missedOpportunityEndTime.replace( /\d+/, inputData?.conversionValue );
|
|
1110
|
+
// }
|
|
1111
|
+
// await postApi( `${url.oldapidomain}/oldBrandUpdate/${data?._id}`, { brandConfigs: data.brandConfigs } );
|
|
1118
1112
|
|
|
1119
|
-
if ( inputData?.conversionCondition ) {
|
|
1120
|
-
data.brandConfigs.conversionConfigTime = data.brandConfigs.conversionConfigTime.replace( /^.+(?=\d)/, inputData?.conversionCondition );
|
|
1121
|
-
data.brandConfigs.missedOpportunityStartTime = data.brandConfigs.missedOpportunityStartTime.replace( /^.+(?=\d)/, inputData?.conversionCondition );
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
if ( inputData?.conversionValue ) {
|
|
1125
|
-
data.brandConfigs.conversionConfigTime = data.brandConfigs.conversionConfigTime.replace( /\d+/, inputData?.conversionValue );
|
|
1126
|
-
data.brandConfigs.missedOpportunityEndTime = data.brandConfigs.missedOpportunityEndTime.replace( /\d+/, inputData?.conversionValue );
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
await postApi( `${url.oldapidomain}/oldBrandUpdate/${data?._id}`, { brandConfigs: data.brandConfigs } );
|
|
1130
1113
|
const keysArray = [
|
|
1131
1114
|
'isExcludedArea', 'isPasserByData', 'isNormalized', 'isbillingDisabled',
|
|
1132
1115
|
'isCameraDisabled', 'isFootfallDirectory', 'isNOB', 'isNewTraffic',
|
|
@@ -1136,9 +1119,9 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
1136
1119
|
const oldData = {
|
|
1137
1120
|
StoreOpenTime: previousData?.featureConfigs?.open,
|
|
1138
1121
|
StoreCloseTime: previousData?.featureConfigs?.close,
|
|
1139
|
-
ConversionCalculations: previousData?.featureConfigs?.conversionCalculation=='footfall-count'? 'Footfall Count': postData?.featureConfigs?.conversionCalculation=='engagers-count'?'Engagers Count':'Potential Entities',
|
|
1140
|
-
MissedOpportunityCalculation: previousData?.featureConfigs?.missedOpportunityCalculation=='engagers-conversion'? 'Engagers - Conversion': 'Potential Entities - Conversion',
|
|
1141
|
-
PotentialCalculations: previousData?.featureConfigs?.billableCalculation=='footfall-count'? 'Footfall Count': 'Engagers Count',
|
|
1122
|
+
ConversionCalculations: previousData?.featureConfigs?.conversionCalculation == 'footfall-count' ? 'Footfall Count' : postData?.featureConfigs?.conversionCalculation == 'engagers-count' ? 'Engagers Count' : 'Potential Entities',
|
|
1123
|
+
MissedOpportunityCalculation: previousData?.featureConfigs?.missedOpportunityCalculation == 'engagers-conversion' ? 'Engagers - Conversion' : 'Potential Entities - Conversion',
|
|
1124
|
+
PotentialCalculations: previousData?.featureConfigs?.billableCalculation == 'footfall-count' ? 'Footfall Count' : 'Engagers Count',
|
|
1142
1125
|
ConversionCondition: previousData?.featureConfigs?.conversion.condition,
|
|
1143
1126
|
ConversionValue: previousData?.featureConfigs?.conversion.value,
|
|
1144
1127
|
MissedOpportunityFromCondition: previousData?.featureConfigs?.missedOpportunityFrom?.condition,
|
|
@@ -1149,32 +1132,32 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
1149
1132
|
BouncedLimitValue: previousData?.featureConfigs?.bouncedLimit?.value,
|
|
1150
1133
|
InfraAlertValue: previousData?.featureConfigs?.infraAlert?.value,
|
|
1151
1134
|
InfraAlertCondition: previousData?.featureConfigs?.infraAlert?.condition,
|
|
1152
|
-
ExcludedArea: previousData?.featureConfigs?.isExcludedArea ==true ? 'Enabled': 'Disabled',
|
|
1153
|
-
PasserBydata: previousData?.featureConfigs?.isPasserByData ==true ? 'Enabled': 'Disabled',
|
|
1154
|
-
NormalizedDataDuringDowntime: previousData?.featureConfigs?.isNormalized ==true ? 'Enabled': 'Disabled',
|
|
1155
|
-
Billing: previousData?.featureConfigs?.isbillingDisabled ==true ? 'Enabled': 'Disabled',
|
|
1156
|
-
CameraBlurring: previousData?.featureConfigs?.isCameraDisabled ==true ? 'Enabled': 'Disabled',
|
|
1157
|
-
FootfallDirectory: previousData?.featureConfigs?.isFootfallDirectory ==true ? 'Enabled': 'Disabled',
|
|
1158
|
-
NOBStatus: previousData?.featureConfigs?.isNOB ==true ? 'Enabled': 'Disabled',
|
|
1159
|
-
EnableAnalyze: previousData?.featureConfigs?.isNewDashboard ==true ? 'Enabled': 'Disabled',
|
|
1160
|
-
Traffic: previousData?.featureConfigs?.isNewTraffic==true ? 'Enabled': 'Disabled',
|
|
1161
|
-
Zone: previousData?.featureConfigs?.isNewZone ==true ? 'Enabled': 'Disabled',
|
|
1162
|
-
Zonev2: previousData?.featureConfigs?.isNewZoneV2 ==true ? 'Enabled': 'Disabled',
|
|
1163
|
-
Reports: previousData?.featureConfigs?.isNewReports ==true ? 'Enabled': 'Disabled',
|
|
1164
|
-
Trax: previousData?.featureConfigs?.isTrax ==true ? 'Enabled': 'Disabled',
|
|
1165
|
-
StreamType: previousData?.featureConfigs?.streamBy =='Edge' ? 'Edge App': 'RTSP',
|
|
1166
|
-
FootfallDirectoryOnlyAudit: previousData?.featureConfigs?.isFootfallDirectoryAudit ==true ? 'Enabled': 'Disabled',
|
|
1167
|
-
FootfallDirectoryOnlyFew: previousData?.featureConfigs?.isFootfallDirectoryLimit ==true ? 'Enabled': 'Disabled',
|
|
1135
|
+
ExcludedArea: previousData?.featureConfigs?.isExcludedArea == true ? 'Enabled' : 'Disabled',
|
|
1136
|
+
PasserBydata: previousData?.featureConfigs?.isPasserByData == true ? 'Enabled' : 'Disabled',
|
|
1137
|
+
NormalizedDataDuringDowntime: previousData?.featureConfigs?.isNormalized == true ? 'Enabled' : 'Disabled',
|
|
1138
|
+
Billing: previousData?.featureConfigs?.isbillingDisabled == true ? 'Enabled' : 'Disabled',
|
|
1139
|
+
CameraBlurring: previousData?.featureConfigs?.isCameraDisabled == true ? 'Enabled' : 'Disabled',
|
|
1140
|
+
FootfallDirectory: previousData?.featureConfigs?.isFootfallDirectory == true ? 'Enabled' : 'Disabled',
|
|
1141
|
+
NOBStatus: previousData?.featureConfigs?.isNOB == true ? 'Enabled' : 'Disabled',
|
|
1142
|
+
EnableAnalyze: previousData?.featureConfigs?.isNewDashboard == true ? 'Enabled' : 'Disabled',
|
|
1143
|
+
Traffic: previousData?.featureConfigs?.isNewTraffic == true ? 'Enabled' : 'Disabled',
|
|
1144
|
+
Zone: previousData?.featureConfigs?.isNewZone == true ? 'Enabled' : 'Disabled',
|
|
1145
|
+
Zonev2: previousData?.featureConfigs?.isNewZoneV2 == true ? 'Enabled' : 'Disabled',
|
|
1146
|
+
Reports: previousData?.featureConfigs?.isNewReports == true ? 'Enabled' : 'Disabled',
|
|
1147
|
+
Trax: previousData?.featureConfigs?.isTrax == true ? 'Enabled' : 'Disabled',
|
|
1148
|
+
StreamType: previousData?.featureConfigs?.streamBy == 'Edge' ? 'Edge App' : 'RTSP',
|
|
1149
|
+
FootfallDirectoryOnlyAudit: previousData?.featureConfigs?.isFootfallDirectoryAudit == true ? 'Enabled' : 'Disabled',
|
|
1150
|
+
FootfallDirectoryOnlyFew: previousData?.featureConfigs?.isFootfallDirectoryLimit == true ? 'Enabled' : 'Disabled',
|
|
1168
1151
|
|
|
1169
1152
|
};
|
|
1170
1153
|
|
|
1171
1154
|
// Map and rename keys from current client info for UI display and logging
|
|
1172
|
-
const newData ={
|
|
1155
|
+
const newData = {
|
|
1173
1156
|
StoreOpenTime: postData?.featureConfigs?.open,
|
|
1174
1157
|
StoreCloseTime: postData?.featureConfigs?.close,
|
|
1175
|
-
ConversionCalculations: postData?.featureConfigs?.conversionCalculation=='footfall-count'? 'Footfall Count': postData?.featureConfigs?.conversionCalculation=='engagers-count'?'Engagers Count':'Potential Entities',
|
|
1176
|
-
MissedOpportunityCalculation: postData?.featureConfigs?.missedOpportunityCalculation=='engagers-conversion'? 'Engagers - Conversion': 'Potential Entities - Conversion',
|
|
1177
|
-
PotentialCalculations: postData?.featureConfigs?.billableCalculation=='footfall-count'? 'Footfall Count':'Engagers Count',
|
|
1158
|
+
ConversionCalculations: postData?.featureConfigs?.conversionCalculation == 'footfall-count' ? 'Footfall Count' : postData?.featureConfigs?.conversionCalculation == 'engagers-count' ? 'Engagers Count' : 'Potential Entities',
|
|
1159
|
+
MissedOpportunityCalculation: postData?.featureConfigs?.missedOpportunityCalculation == 'engagers-conversion' ? 'Engagers - Conversion' : 'Potential Entities - Conversion',
|
|
1160
|
+
PotentialCalculations: postData?.featureConfigs?.billableCalculation == 'footfall-count' ? 'Footfall Count' : 'Engagers Count',
|
|
1178
1161
|
ConversionCondition: postData?.featureConfigs?.conversion.condition,
|
|
1179
1162
|
ConversionValue: postData?.featureConfigs?.conversion.value,
|
|
1180
1163
|
MissedOpportunityFromCondition: postData?.featureConfigs?.missedOpportunityFrom?.condition,
|
|
@@ -1185,22 +1168,22 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
1185
1168
|
BouncedLimitValue: postData?.featureConfigs?.bouncedLimit?.value,
|
|
1186
1169
|
InfraAlertValue: postData?.featureConfigs?.infraAlert?.value,
|
|
1187
1170
|
InfraAlertCondition: postData?.featureConfigs?.infraAlert?.condition,
|
|
1188
|
-
ExcludedArea: postData?.featureConfigs?.isExcludedArea ==true ? 'Enabled': 'Disabled',
|
|
1189
|
-
PasserBydata: postData?.featureConfigs?.isPasserByData ==true ? 'Enabled': 'Disabled',
|
|
1190
|
-
NormalizedDataDuringDowntime: postData?.featureConfigs?.isNormalized ==true ? 'Enabled': 'Disabled',
|
|
1191
|
-
Billing: postData?.featureConfigs?.isbillingDisabled ==true ? 'Enabled': 'Disabled',
|
|
1192
|
-
CameraBlurring: postData?.featureConfigs?.isCameraDisabled ==true ? 'Enabled': 'Disabled',
|
|
1193
|
-
FootfallDirectory: postData?.featureConfigs?.isFootfallDirectory ==true ? 'Enabled': 'Disabled',
|
|
1194
|
-
NOBStatus: postData?.featureConfigs?.isNOB ==true ? 'Enabled': 'Disabled',
|
|
1195
|
-
EnableAnalyze: postData?.featureConfigs?.isNewDashboard ==true ? 'Enabled': 'Disabled',
|
|
1196
|
-
Traffic: postData?.featureConfigs?.isNewTraffic==true ? 'Enabled': 'Disabled',
|
|
1197
|
-
Zone: postData?.featureConfigs?.isNewZone ==true ? 'Enabled': 'Disabled',
|
|
1198
|
-
Zonev2: postData?.featureConfigs?.isNewZoneV2 ==true ? 'Enabled': 'Disabled',
|
|
1199
|
-
Reports: postData?.featureConfigs?.isNewReports ==true ? 'Enabled': 'Disabled',
|
|
1200
|
-
Trax: postData?.featureConfigs?.isTrax ==true ? 'Enabled': 'Disabled',
|
|
1201
|
-
StreamType: postData?.featureConfigs?.streamBy =='Edge' ? 'Edge App': 'RTSP',
|
|
1202
|
-
FootfallDirectoryOnlyAudit: postData?.featureConfigs?.isFootfallDirectoryAudit ==true ? 'Enabled': 'Disabled',
|
|
1203
|
-
FootfallDirectoryOnlyFew: postData?.featureConfigs?.isFootfallDirectoryLimit ==true ? 'Enabled': 'Disabled',
|
|
1171
|
+
ExcludedArea: postData?.featureConfigs?.isExcludedArea == true ? 'Enabled' : 'Disabled',
|
|
1172
|
+
PasserBydata: postData?.featureConfigs?.isPasserByData == true ? 'Enabled' : 'Disabled',
|
|
1173
|
+
NormalizedDataDuringDowntime: postData?.featureConfigs?.isNormalized == true ? 'Enabled' : 'Disabled',
|
|
1174
|
+
Billing: postData?.featureConfigs?.isbillingDisabled == true ? 'Enabled' : 'Disabled',
|
|
1175
|
+
CameraBlurring: postData?.featureConfigs?.isCameraDisabled == true ? 'Enabled' : 'Disabled',
|
|
1176
|
+
FootfallDirectory: postData?.featureConfigs?.isFootfallDirectory == true ? 'Enabled' : 'Disabled',
|
|
1177
|
+
NOBStatus: postData?.featureConfigs?.isNOB == true ? 'Enabled' : 'Disabled',
|
|
1178
|
+
EnableAnalyze: postData?.featureConfigs?.isNewDashboard == true ? 'Enabled' : 'Disabled',
|
|
1179
|
+
Traffic: postData?.featureConfigs?.isNewTraffic == true ? 'Enabled' : 'Disabled',
|
|
1180
|
+
Zone: postData?.featureConfigs?.isNewZone == true ? 'Enabled' : 'Disabled',
|
|
1181
|
+
Zonev2: postData?.featureConfigs?.isNewZoneV2 == true ? 'Enabled' : 'Disabled',
|
|
1182
|
+
Reports: postData?.featureConfigs?.isNewReports == true ? 'Enabled' : 'Disabled',
|
|
1183
|
+
Trax: postData?.featureConfigs?.isTrax == true ? 'Enabled' : 'Disabled',
|
|
1184
|
+
StreamType: postData?.featureConfigs?.streamBy == 'Edge' ? 'Edge App' : 'RTSP',
|
|
1185
|
+
FootfallDirectoryOnlyAudit: postData?.featureConfigs?.isFootfallDirectoryAudit == true ? 'Enabled' : 'Disabled',
|
|
1186
|
+
FootfallDirectoryOnlyFew: postData?.featureConfigs?.isFootfallDirectoryLimit == true ? 'Enabled' : 'Disabled',
|
|
1204
1187
|
|
|
1205
1188
|
};
|
|
1206
1189
|
|
|
@@ -1281,20 +1264,20 @@ export async function domainDetailsConfiguration( req, res ) {
|
|
|
1281
1264
|
// Map and rename keys from previous client info for UI display and logging
|
|
1282
1265
|
const oldData = {
|
|
1283
1266
|
DomainName: getPreData?.domainConfig?.ssoLogin?.domainName?.join( ', ' ),
|
|
1284
|
-
IsEnable: getPreData?.domainConfig?.ssoLogin?.isEnable ==true ? 'Enable': 'Disable',
|
|
1285
|
-
IPWhitelist: getPreData?.domainConfig?.ipWhitelisting?.enableWhitelisting ==true ? 'Enable': 'Disable',
|
|
1267
|
+
IsEnable: getPreData?.domainConfig?.ssoLogin?.isEnable == true ? 'Enable' : 'Disable',
|
|
1268
|
+
IPWhitelist: getPreData?.domainConfig?.ipWhitelisting?.enableWhitelisting == true ? 'Enable' : 'Disable',
|
|
1286
1269
|
WhitelistedIps: getPreData?.domainConfig?.ipWhitelisting?.allowedIps?.join( ', ' ),
|
|
1287
|
-
TwoFactorAuthentication: getPreData?.domainConfig?.enableOtp ==true ? 'Enable': 'Disable',
|
|
1270
|
+
TwoFactorAuthentication: getPreData?.domainConfig?.enableOtp == true ? 'Enable' : 'Disable',
|
|
1288
1271
|
|
|
1289
1272
|
};
|
|
1290
1273
|
|
|
1291
1274
|
// Map and rename keys from current client info for UI display and logging
|
|
1292
|
-
const newData ={
|
|
1275
|
+
const newData = {
|
|
1293
1276
|
DomainName: getPostData?.domainConfig?.ssoLogin?.domainName?.join( ', ' ),
|
|
1294
|
-
IsEnable: getPostData?.domainConfig?.ssoLogin?.isEnable ==true ? 'Enable': 'Disable',
|
|
1295
|
-
IPWhitelist: getPostData?.domainConfig?.ipWhitelisting?.enableWhitelisting ==true ? 'Enable': 'Disable',
|
|
1277
|
+
IsEnable: getPostData?.domainConfig?.ssoLogin?.isEnable == true ? 'Enable' : 'Disable',
|
|
1278
|
+
IPWhitelist: getPostData?.domainConfig?.ipWhitelisting?.enableWhitelisting == true ? 'Enable' : 'Disable',
|
|
1296
1279
|
WhitelistedIps: getPostData?.domainConfig?.ipWhitelisting?.allowedIps?.join( ', ' ),
|
|
1297
|
-
TwoFactorAuthentication: getPostData?.domainConfig?.enableOtp ==true ? 'Enable': 'Disable',
|
|
1280
|
+
TwoFactorAuthentication: getPostData?.domainConfig?.enableOtp == true ? 'Enable' : 'Disable',
|
|
1298
1281
|
};
|
|
1299
1282
|
|
|
1300
1283
|
logger.info( { getPreData: getPreData, getPostData: getPostData, newData: newData, oldData: oldData } );
|
|
@@ -1480,7 +1463,7 @@ export async function auditConfiguration( req, res ) {
|
|
|
1480
1463
|
auditConfigs: 1, _id: 0,
|
|
1481
1464
|
};
|
|
1482
1465
|
const previousClient = await findOneClient( query, fields );
|
|
1483
|
-
previousClient.auditConfigs.ratio = previousClient?.auditConfigs?.ratio? ( previousClient.auditConfigs.ratio )*100 : null;
|
|
1466
|
+
previousClient.auditConfigs.ratio = previousClient?.auditConfigs?.ratio ? ( previousClient.auditConfigs.ratio ) * 100 : null;
|
|
1484
1467
|
const record = {
|
|
1485
1468
|
'auditConfigs.count': inputData.count,
|
|
1486
1469
|
'auditConfigs.audit': inputData.audit,
|
|
@@ -1489,18 +1472,18 @@ export async function auditConfiguration( req, res ) {
|
|
|
1489
1472
|
await updateOneClient( query, record );
|
|
1490
1473
|
|
|
1491
1474
|
// Map and rename keys from previous client info for UI display and logging
|
|
1492
|
-
const oldData ={
|
|
1493
|
-
AuditStatus: previousClient?.auditConfigs?.audit ==true ? 'Enable': 'Disable',
|
|
1475
|
+
const oldData = {
|
|
1476
|
+
AuditStatus: previousClient?.auditConfigs?.audit == true ? 'Enable' : 'Disable',
|
|
1494
1477
|
MappingPercentage: previousClient?.auditConfigs?.ratio,
|
|
1495
1478
|
AuditCount: previousClient?.auditConfigs?.count,
|
|
1496
1479
|
};
|
|
1497
1480
|
|
|
1498
1481
|
const currentClient = await findOneClient( query, fields );
|
|
1499
|
-
currentClient.auditConfigs.ratio = currentClient?.auditConfigs?.ratio? ( currentClient.auditConfigs.ratio )*100 : null;
|
|
1482
|
+
currentClient.auditConfigs.ratio = currentClient?.auditConfigs?.ratio ? ( currentClient.auditConfigs.ratio ) * 100 : null;
|
|
1500
1483
|
|
|
1501
1484
|
// Map and rename keys from current client info for UI display and logging
|
|
1502
1485
|
const newData = {
|
|
1503
|
-
AuditStatus: currentClient?.auditConfigs?.audit ==true ? 'Enable': 'Disable',
|
|
1486
|
+
AuditStatus: currentClient?.auditConfigs?.audit == true ? 'Enable' : 'Disable',
|
|
1504
1487
|
MappingPercentage: currentClient?.auditConfigs?.ratio,
|
|
1505
1488
|
AuditCount: currentClient?.auditConfigs?.count,
|
|
1506
1489
|
|
|
@@ -2275,12 +2258,13 @@ export async function getActivityLogs1( req, res ) {
|
|
|
2275
2258
|
try {
|
|
2276
2259
|
const inputData = req.body;
|
|
2277
2260
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
2278
|
-
const clientQuery =[
|
|
2261
|
+
const clientQuery = [
|
|
2279
2262
|
{
|
|
2280
2263
|
$match: {
|
|
2281
2264
|
$and: [
|
|
2282
2265
|
{
|
|
2283
|
-
clientId: { $in: [ inputData?.clientId ] }
|
|
2266
|
+
clientId: { $in: [ inputData?.clientId ] },
|
|
2267
|
+
},
|
|
2284
2268
|
],
|
|
2285
2269
|
},
|
|
2286
2270
|
},
|
|
@@ -2298,7 +2282,7 @@ export async function getActivityLogs1( req, res ) {
|
|
|
2298
2282
|
},
|
|
2299
2283
|
];
|
|
2300
2284
|
const getClientName = await aggregateClient( clientQuery );
|
|
2301
|
-
if ( getClientName?.length == 0 || getClientName[0]?.clientName?.length ===0 ) {
|
|
2285
|
+
if ( getClientName?.length == 0 || getClientName[0]?.clientName?.length === 0 ) {
|
|
2302
2286
|
return res.sendError( 'No Data Found', 204 );
|
|
2303
2287
|
}
|
|
2304
2288
|
const query = {
|
|
@@ -2365,13 +2349,13 @@ export async function getActivityLogs1( req, res ) {
|
|
|
2365
2349
|
let temp = [];
|
|
2366
2350
|
if ( totalDocuments ) {
|
|
2367
2351
|
hits.map( ( hit, i ) => {
|
|
2368
|
-
let respo ={};
|
|
2369
|
-
hit._source.logSubType = hit._source.logSubType === 'documentUpload'? 'documentsUpload': hit._source.logSubType === 'domainDetails'? 'securityFeatures': hit?._source?.logSubType;
|
|
2370
|
-
if ( ( ( hit?._source?.eventType ).match( /update/ ) || ( hit?._source?.eventType ).match( /edit/ ) )&& hit?._source?.previous ) {
|
|
2371
|
-
const previous = hit?._source?.logType == 'cameras'?hit?._source?.oldData: hit?._source?.previous;
|
|
2372
|
-
const current=hit?._source?.logType == 'cameras'? hit?._source?.newData:hit?._source?.current;
|
|
2373
|
-
const logType =hit?._source?.logType;
|
|
2374
|
-
const logSubType =hit?._source?.logSubType;
|
|
2352
|
+
let respo = {};
|
|
2353
|
+
hit._source.logSubType = hit._source.logSubType === 'documentUpload' ? 'documentsUpload' : hit._source.logSubType === 'domainDetails' ? 'securityFeatures' : hit?._source?.logSubType;
|
|
2354
|
+
if ( ( ( hit?._source?.eventType ).match( /update/ ) || ( hit?._source?.eventType ).match( /edit/ ) ) && hit?._source?.previous ) {
|
|
2355
|
+
const previous = hit?._source?.logType == 'cameras' ? hit?._source?.oldData : hit?._source?.previous;
|
|
2356
|
+
const current = hit?._source?.logType == 'cameras' ? hit?._source?.newData : hit?._source?.current;
|
|
2357
|
+
const logType = hit?._source?.logType;
|
|
2358
|
+
const logSubType = hit?._source?.logSubType;
|
|
2375
2359
|
if ( previous && current && hit?._source?.logType == 'cameras' ) {
|
|
2376
2360
|
respo = findDifferences( previous, current );
|
|
2377
2361
|
} else {
|
|
@@ -2380,7 +2364,7 @@ export async function getActivityLogs1( req, res ) {
|
|
|
2380
2364
|
|
|
2381
2365
|
hit._source.updatedValue = respo;
|
|
2382
2366
|
temp.push( hit?._source );
|
|
2383
|
-
hit._source.changes =logSubType === 'ticketConfig'? Object.keys( respo ).map( ( item ) => item ) : hit._source.changes;
|
|
2367
|
+
hit._source.changes = logSubType === 'ticketConfig' ? Object.keys( respo ).map( ( item ) => item ) : hit._source.changes;
|
|
2384
2368
|
} else {
|
|
2385
2369
|
temp.push( hit?._source );
|
|
2386
2370
|
}
|
|
@@ -2405,7 +2389,7 @@ function findDifferences1( previous, current, logType, logSubType, path = '' ) {
|
|
|
2405
2389
|
] );
|
|
2406
2390
|
const documents = dbKeys.DOCUMENTS;
|
|
2407
2391
|
// Get correct key mapping based on logType
|
|
2408
|
-
const keyMapping = logType == 'stores' ?documents.stores: logType == 'users' ?documents.users :logSubType=='reportConfig'?documents.reports: logType=='brandInfo'?documents.client:documents.client;
|
|
2392
|
+
const keyMapping = logType == 'stores' ? documents.stores : logType == 'users' ? documents.users : logSubType == 'reportConfig' ? documents.reports : logType == 'brandInfo' ? documents.client : documents.client;
|
|
2409
2393
|
|
|
2410
2394
|
|
|
2411
2395
|
let differences = {};
|
|
@@ -2417,7 +2401,7 @@ function findDifferences1( previous, current, logType, logSubType, path = '' ) {
|
|
|
2417
2401
|
const currValue = current[key];
|
|
2418
2402
|
|
|
2419
2403
|
if ( typeof prevValue === 'object' && typeof currValue === 'object' && prevValue !== null && currValue !== null ) {
|
|
2420
|
-
if ( logSubType!== 'userUpdated' ) {
|
|
2404
|
+
if ( logSubType !== 'userUpdated' ) {
|
|
2421
2405
|
if ( key == 'spocDetails' ) {
|
|
2422
2406
|
if ( _.isEqual( prevValue, currValue ) ) {
|
|
2423
2407
|
continue;
|
|
@@ -2425,9 +2409,9 @@ function findDifferences1( previous, current, logType, logSubType, path = '' ) {
|
|
|
2425
2409
|
let result = compareArrayObjects( prevValue, currValue );
|
|
2426
2410
|
differences = { ...differences, ...result };
|
|
2427
2411
|
}
|
|
2428
|
-
} else if ( Array.isArray( prevValue ) && prevValue.every( ( item ) => typeof item === 'string' ) ||Array.isArray( currValue ) && currValue.every( ( item ) => typeof item === 'string' ) ) {
|
|
2429
|
-
|
|
2430
|
-
|
|
2412
|
+
} else if ( Array.isArray( prevValue ) && prevValue.every( ( item ) => typeof item === 'string' ) || Array.isArray( currValue ) && currValue.every( ( item ) => typeof item === 'string' ) ) {
|
|
2413
|
+
JSON.stringify( prevValue ) !== JSON.stringify( currValue ) ?
|
|
2414
|
+
differences[`${path}${key}`] = { previous: prevValue.length > 0 ? prevValue.join( ',' ) : null, current: currValue.length > 0 ? currValue.join( ',' ) : null } : null;
|
|
2431
2415
|
|
|
2432
2416
|
// differences[`${path}${key}`] = { previous: removed.length> 0 ? prevValue.join( ',' ): prevValue.join( ', ' ) :, current: added.length > 0? addedUsers.join( ', ' ) : currValue.join( ',' ) } : null;
|
|
2433
2417
|
} else {
|
|
@@ -2498,13 +2482,13 @@ function findDifferences1( previous, current, logType, logSubType, path = '' ) {
|
|
|
2498
2482
|
|
|
2499
2483
|
if (
|
|
2500
2484
|
( diff.previous === '' || diff.previous === null || ( Array.isArray( diff.previous ) && diff.previous.length === 0 ) ) &&
|
|
2501
|
-
|
|
2485
|
+
diff.current === undefined
|
|
2502
2486
|
) {
|
|
2503
2487
|
return;
|
|
2504
2488
|
}
|
|
2505
2489
|
if (
|
|
2506
2490
|
( diff.current === '' || diff.current === null || ( Array.isArray( diff.current ) && diff.current.length === 0 ) ) &&
|
|
2507
|
-
|
|
2491
|
+
diff.previous === undefined
|
|
2508
2492
|
) {
|
|
2509
2493
|
return;
|
|
2510
2494
|
}
|
|
@@ -2535,7 +2519,7 @@ export async function getActivityLogs( req, res ) {
|
|
|
2535
2519
|
try {
|
|
2536
2520
|
const inputData = req.body;
|
|
2537
2521
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
2538
|
-
const clientQuery =[
|
|
2522
|
+
const clientQuery = [
|
|
2539
2523
|
{
|
|
2540
2524
|
$match: {
|
|
2541
2525
|
$and: [
|
|
@@ -2559,7 +2543,7 @@ export async function getActivityLogs( req, res ) {
|
|
|
2559
2543
|
},
|
|
2560
2544
|
];
|
|
2561
2545
|
const getClientName = await aggregateClient( clientQuery );
|
|
2562
|
-
if ( getClientName?.length == 0 || getClientName[0]?.clientName?.length ===0 ) {
|
|
2546
|
+
if ( getClientName?.length == 0 || getClientName[0]?.clientName?.length === 0 ) {
|
|
2563
2547
|
return res.sendError( 'No Data Found', 204 );
|
|
2564
2548
|
}
|
|
2565
2549
|
const query = {
|
|
@@ -2634,11 +2618,11 @@ export async function getActivityLogs( req, res ) {
|
|
|
2634
2618
|
let temp = [];
|
|
2635
2619
|
if ( totalDocuments ) {
|
|
2636
2620
|
hits.map( ( hit, i ) => {
|
|
2637
|
-
let respo ={};
|
|
2638
|
-
hit._source.logSubType = hit._source.logSubType === 'documentUpload'? 'documentsUpload': hit._source.logSubType === 'domainDetails'? 'securityFeatures': hit?._source?.logSubType;
|
|
2639
|
-
if ( ( ( hit?._source?.eventType ).match( /update/ ) || ( hit?._source?.eventType ).match( /edit/ ) )&& hit?._source?.previous ) {
|
|
2621
|
+
let respo = {};
|
|
2622
|
+
hit._source.logSubType = hit._source.logSubType === 'documentUpload' ? 'documentsUpload' : hit._source.logSubType === 'domainDetails' ? 'securityFeatures' : hit?._source?.logSubType;
|
|
2623
|
+
if ( ( ( hit?._source?.eventType ).match( /update/ ) || ( hit?._source?.eventType ).match( /edit/ ) ) && hit?._source?.previous ) {
|
|
2640
2624
|
const previous = hit?._source?.oldData;
|
|
2641
|
-
const current=hit?._source?.newData;
|
|
2625
|
+
const current = hit?._source?.newData;
|
|
2642
2626
|
if ( previous && current ) {
|
|
2643
2627
|
respo = findDifferences( previous, current );
|
|
2644
2628
|
}
|
|
@@ -2689,41 +2673,41 @@ function splitCamelCase( text ) {
|
|
|
2689
2673
|
.replace( /^./, ( match ) => match.toUpperCase() ); // Capitalize the first letter
|
|
2690
2674
|
}
|
|
2691
2675
|
|
|
2692
|
-
async function postApi( url, data ) {
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
}
|
|
2709
|
-
|
|
2710
|
-
async function getApi( url ) {
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
}
|
|
2676
|
+
// async function postApi( url, data ) {
|
|
2677
|
+
// const requestOptions = {
|
|
2678
|
+
// method: 'POST',
|
|
2679
|
+
// headers: {
|
|
2680
|
+
// 'Content-Type': 'application/json',
|
|
2681
|
+
// 'Authorization': 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66',
|
|
2682
|
+
// },
|
|
2683
|
+
// body: JSON.stringify( data ),
|
|
2684
|
+
// };
|
|
2685
|
+
|
|
2686
|
+
// try {
|
|
2687
|
+
// const response = await fetch( url, requestOptions );
|
|
2688
|
+
// await response.json();
|
|
2689
|
+
// } catch ( error ) {
|
|
2690
|
+
// logger.error( { error: error, message: data, function: 'postApi' } );
|
|
2691
|
+
// }
|
|
2692
|
+
// }
|
|
2693
|
+
|
|
2694
|
+
// async function getApi( url ) {
|
|
2695
|
+
// const requestOptions = {
|
|
2696
|
+
// method: 'GET',
|
|
2697
|
+
// headers: {
|
|
2698
|
+
// 'Content-Type': 'application/json',
|
|
2699
|
+
// 'Authorization': 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66',
|
|
2700
|
+
// },
|
|
2701
|
+
// };
|
|
2702
|
+
|
|
2703
|
+
// try {
|
|
2704
|
+
// const response = await fetch( url, requestOptions );
|
|
2705
|
+
// const responseData = await response.json();
|
|
2706
|
+
// return responseData;
|
|
2707
|
+
// } catch ( error ) {
|
|
2708
|
+
// logger.error( { error: error, message: 'Error in GET request', function: 'getApi' } );
|
|
2709
|
+
// }
|
|
2710
|
+
// }
|
|
2727
2711
|
|
|
2728
2712
|
|
|
2729
2713
|
export async function csmAssignConfirmation( req, res ) {
|
|
@@ -2770,8 +2754,8 @@ function compareArrayObjects( prevArray, currArray ) {
|
|
|
2770
2754
|
|
|
2771
2755
|
Object.keys( { ...prevObj, ...currObj } ).forEach( ( key ) => {
|
|
2772
2756
|
if ( prevObj[key] !== currObj[key] && key !== '_id' ) {
|
|
2773
|
-
const key1 = key == 'contact'? 'Contact Number': key == 'email'? 'Email ID':key == 'name'?'Name': key == 'designation'?'Designation':key;
|
|
2774
|
-
const name = i ==0? 'Primary Spoc': `Alternate Spoc ${i+1}`;
|
|
2757
|
+
const key1 = key == 'contact' ? 'Contact Number' : key == 'email' ? 'Email ID' : key == 'name' ? 'Name' : key == 'designation' ? 'Designation' : key;
|
|
2758
|
+
const name = i == 0 ? 'Primary Spoc' : `Alternate Spoc ${i + 1}`;
|
|
2775
2759
|
diff[`${name} ${key1}`] = {
|
|
2776
2760
|
previous: prevObj[key] || 'null',
|
|
2777
2761
|
current: currObj[key] || 'null',
|
|
@@ -2787,3 +2771,87 @@ function compareArrayObjects( prevArray, currArray ) {
|
|
|
2787
2771
|
|
|
2788
2772
|
return changes;
|
|
2789
2773
|
}
|
|
2774
|
+
|
|
2775
|
+
|
|
2776
|
+
export async function createAuditConfig( req, res ) {
|
|
2777
|
+
try {
|
|
2778
|
+
await createauditConfig( req.body );
|
|
2779
|
+
return res.sendSuccess( 'created Sucessfully' );
|
|
2780
|
+
} catch ( error ) {
|
|
2781
|
+
logger.error( { error: error, message: req.body, function: 'createAuditConfig' } );
|
|
2782
|
+
return res.sendError( 'Internal Server Error', 500 );
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
export async function updateAuditConfig( req, res ) {
|
|
2786
|
+
try {
|
|
2787
|
+
await updateauditConfig( { _id: req.params.id }, req.body );
|
|
2788
|
+
return res.sendSuccess( 'updated Sucessfully' );
|
|
2789
|
+
} catch ( error ) {
|
|
2790
|
+
logger.error( { error: error, message: req.body, function: 'createAuditConfig' } );
|
|
2791
|
+
return res.sendError( 'Internal Server Error', 500 );
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
export async function AuditConfiglist( req, res ) {
|
|
2795
|
+
try {
|
|
2796
|
+
let Query = [ {
|
|
2797
|
+
$match: {
|
|
2798
|
+
'$and': [
|
|
2799
|
+
{ 'clientId': { $in: req.body.clientId } },
|
|
2800
|
+
],
|
|
2801
|
+
},
|
|
2802
|
+
} ];
|
|
2803
|
+
if ( req.body.searchValue && req.body.searchValue !== '' ) {
|
|
2804
|
+
const searchCondition = {
|
|
2805
|
+
$match: {
|
|
2806
|
+
$or: [
|
|
2807
|
+
{ AuditName: { $regex: req.body.searchValue, $options: 'i' } },
|
|
2808
|
+
{ keyWord: { $regex: req.body.searchValue, $options: 'i' } },
|
|
2809
|
+
],
|
|
2810
|
+
},
|
|
2811
|
+
};
|
|
2812
|
+
|
|
2813
|
+
Query.push( searchCondition );
|
|
2814
|
+
}
|
|
2815
|
+
if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
|
|
2816
|
+
const sortOption = { $sort: { [req.body.sortColumName]: req.body.sortBy } };
|
|
2817
|
+
Query.push( sortOption );
|
|
2818
|
+
} else {
|
|
2819
|
+
const sortOption = { $sort: { 'AuditName': -1 } };
|
|
2820
|
+
Query.push( sortOption );
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
let count = await aggregateAuditconfig( Query );
|
|
2824
|
+
|
|
2825
|
+
if ( req.body.limit && req.body.offset && !req.body.export ) {
|
|
2826
|
+
const skipValue = ( req.body.offset - 1 ) * req.body.limit;
|
|
2827
|
+
const limitValue = Number( req.body.limit );
|
|
2828
|
+
|
|
2829
|
+
const pagination = [
|
|
2830
|
+
{ $skip: skipValue },
|
|
2831
|
+
{ $limit: limitValue },
|
|
2832
|
+
];
|
|
2833
|
+
|
|
2834
|
+
Query.push( ...pagination );
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
let result = await aggregateAuditconfig( Query );
|
|
2838
|
+
|
|
2839
|
+
if ( req.body.export && result.length > 0 ) {
|
|
2840
|
+
const exportdata = result.map( ( element ) => {
|
|
2841
|
+
return {
|
|
2842
|
+
'Audit Name': element.AuditName,
|
|
2843
|
+
'Keyword': element.keyWord,
|
|
2844
|
+
'File Type': element.fileType,
|
|
2845
|
+
'Response Type': element.responseType,
|
|
2846
|
+
'Status': element.status,
|
|
2847
|
+
};
|
|
2848
|
+
} );
|
|
2849
|
+
await download( exportdata, res );
|
|
2850
|
+
return;
|
|
2851
|
+
}
|
|
2852
|
+
return res.sendSuccess( { result: result, totalCount: count.length } );
|
|
2853
|
+
} catch ( error ) {
|
|
2854
|
+
logger.error( { error: error, message: req.body, function: 'createAuditConfig' } );
|
|
2855
|
+
return res.sendError( 'Internal Server Error', 500 );
|
|
2856
|
+
}
|
|
2857
|
+
}
|