tango-app-api-store-builder 1.0.0-beta-134 → 1.0.0-beta-135

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-store-builder",
3
- "version": "1.0.0-beta-134",
3
+ "version": "1.0.0-beta-135",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -164,7 +164,7 @@ export async function deleteTemplate( req, res ) {
164
164
 
165
165
  export async function duplicateTemplate( req, res ) {
166
166
  try {
167
- let templateDetails = await fixtureConfigService.findOne( { _id: req.body.templateId } );
167
+ let templateDetails = await fixtureConfigService.findOne( { _id: req.body.templateId }, { createdAt: 0, updatedAt: 0 } );
168
168
  if ( !templateDetails ) {
169
169
  return res.sendError( 'No data found', 204 );
170
170
  }
@@ -282,12 +282,14 @@ export async function getTemplateList( req, res ) {
282
282
  $group: {
283
283
  _id: null,
284
284
  planoId: { $addToSet: '$planoId' },
285
+ storeList: { $addToSet: '$storeName' },
285
286
  },
286
287
  },
287
288
  {
288
289
  $project: {
289
290
  _id: 0,
290
291
  planoId: 1,
292
+ storeList: 1,
291
293
  },
292
294
  },
293
295
  ],
@@ -301,6 +303,42 @@ export async function getTemplateList( req, res ) {
301
303
  fixtureWidth: 1,
302
304
  productBrandName: 1,
303
305
  productCategory: 1,
306
+ shelfProduct: {
307
+ $reduce: {
308
+ input: '$shelfConfig',
309
+ initialValue: [],
310
+ in: {
311
+ $concatArrays: [
312
+ '$$value',
313
+ { $ifNull: [ '$$this.productBrandName', [] ] },
314
+ ],
315
+ },
316
+ },
317
+ },
318
+ shelfProductCategory: {
319
+ $reduce: {
320
+ input: '$shelfConfig',
321
+ initialValue: [],
322
+ in: {
323
+ $concatArrays: [
324
+ '$$value',
325
+ { $ifNull: [ '$$this.productCategory', [] ] },
326
+ ],
327
+ },
328
+ },
329
+ },
330
+ shelfProductSubCategory: {
331
+ $reduce: {
332
+ input: '$shelfConfig',
333
+ initialValue: [],
334
+ in: {
335
+ $concatArrays: [
336
+ '$$value',
337
+ { $ifNull: [ '$$this.productSubCategory', [] ] },
338
+ ],
339
+ },
340
+ },
341
+ },
304
342
  clientId: 1,
305
343
  productSubCategory: 1,
306
344
  status: 1,
@@ -316,6 +354,7 @@ export async function getTemplateList( req, res ) {
316
354
  },
317
355
  },
318
356
  planoId: { $ifNull: [ { $arrayElemAt: [ '$storeFixtureDetails.planoId', 0 ] }, [] ] },
357
+ storeList: { $ifNull: [ { $arrayElemAt: [ '$storeFixtureDetails.storeList', 0 ] }, [] ] },
319
358
  },
320
359
  },
321
360
  {
@@ -345,16 +384,18 @@ export async function getTemplateList( req, res ) {
345
384
  fixtureCategory: 1,
346
385
  fixtureName: 1,
347
386
  fixtureWidth: 1,
348
- productBrandName: 1,
349
- productCategory: 1,
387
+ productBrandName: { $concatArrays: [ '$productBrandName', '$shelfProduct' ] },
388
+ productCategory: { $concatArrays: [ '$productCategory', '$shelfProductCategory' ] },
350
389
  clientId: 1,
351
390
  fixtureType: 1,
352
- productSubCategory: 1,
391
+ productSubCategory: { $concatArrays: [ '$productSubCategory', '$shelfProductSubCategory' ] },
353
392
  status: 1,
354
393
  templateId: 1,
355
394
  planoId: 1,
356
395
  vmCapacity: 1,
357
396
  productCapacity: 1,
397
+ storeList: 1,
398
+ storeCount: { $size: '$storeList' },
358
399
  planoStatus: { $ifNull: [ { $arrayElemAt: [ '$planoStatus.statusList', 0 ] }, [] ] },
359
400
  status: {
360
401
  $cond: {
@@ -79,6 +79,7 @@ export async function getplanoFeedback( req, res ) {
79
79
  $expr: {
80
80
  $and: [
81
81
  { $eq: [ '$_id', '$$taskId' ] },
82
+ { $eq: [ '$checklistStatus', 'submit' ] },
82
83
  ],
83
84
  },
84
85
  },
@@ -95,7 +96,7 @@ export async function getplanoFeedback( req, res ) {
95
96
  as: 'taskData',
96
97
  },
97
98
 
98
- }, { $unwind: { path: '$taskData', preserveNullAndEmptyArrays: true } },
99
+ }, { $unwind: { path: '$taskData', preserveNullAndEmptyArrays: false } },
99
100
  {
100
101
  $lookup: {
101
102
  from: 'storefixtures',
@@ -162,6 +163,7 @@ export async function getplanoFeedback( req, res ) {
162
163
  $expr: {
163
164
  $and: [
164
165
  { $eq: [ '$_id', '$$taskId' ] },
166
+ { $eq: [ '$checklistStatus', 'submit' ] },
165
167
  ],
166
168
  },
167
169
  },
@@ -178,7 +180,7 @@ export async function getplanoFeedback( req, res ) {
178
180
  as: 'taskData',
179
181
  },
180
182
 
181
- }, { $unwind: { path: '$taskData', preserveNullAndEmptyArrays: true } },
183
+ }, { $unwind: { path: '$taskData', preserveNullAndEmptyArrays: false } },
182
184
  {
183
185
  $lookup: {
184
186
  from: 'storefixtures',
@@ -671,6 +673,18 @@ export async function updateFixtureStatus( req, res ) {
671
673
  'status': 'complete',
672
674
  },
673
675
  );
676
+ if ( req.body.taskType==='layout' ) {
677
+ await planoTaskService.updateMany(
678
+ {
679
+ planoId: new mongoose.Types.ObjectId( req.body.planoId ),
680
+ floorId: new mongoose.Types.ObjectId( req.body.floorId ),
681
+ type: 'layout',
682
+ },
683
+ {
684
+ 'status': 'complete',
685
+ },
686
+ );
687
+ }
674
688
  }
675
689
  }
676
690
 
@@ -53,8 +53,10 @@ export async function fixtureBulkUpload( req, res ) {
53
53
  },
54
54
  ],
55
55
  ...( typeof ele?.isEdit == undefined ) ? { 'status': ele?.fixLibCode ? inputData.updateFixtureStatus : inputData.newFixtureStatus } :{},
56
+ fixtureCapacity: ele.shelfType =='shelf' ? ele.productPerShelf : ele.trayRows * ele.productPerShelf,
56
57
  };
57
58
  } else {
59
+ acc[ele.fixtureName].fixtureCapacity = acc[ele.fixtureName].fixtureCapacity + ( ele.shelfType =='shelf' ? ele.productPerShelf : ele.trayRows * ele.productPerShelf );
58
60
  acc[ele.fixtureName].shelfConfig.push(
59
61
  {
60
62
  shelfNumber: ele.shelfNumber,
@@ -67,21 +69,22 @@ export async function fixtureBulkUpload( req, res ) {
67
69
  }
68
70
  return acc;
69
71
  }, {} );
70
- let fixtureData = [];
71
- await Promise.all( Object.keys( groupedData ).map( async ( ele ) => {
72
- if ( groupedData[ele]?.fixtureLibCode && !groupedData[ele]?.status ) {
73
- await planoLibraryService.updateOne( { fixtureLibCode: groupedData[ele]?.fixtureLibCode }, groupedData[ele] );
74
- } else {
75
- let FixLibCode = await getMaxFixtureLibCode();
76
- groupedData[ele].fixtureLibCode = FixLibCode;
77
- fixtureData.push( groupedData[ele] );
78
- }
79
- } ) );
80
- let deleteList = inputData.deleteFixtureList.map( ( ele ) => new ObjectId( ele ) );
81
- if ( deleteList.length ) {
82
- await planoLibraryService.deleteMany( { _id: { $in: deleteList } } );
72
+ // let fixtureData = [];
73
+ for ( let ele of Object.keys( groupedData ) ) {
74
+ // if ( groupedData[ele]?.fixtureLibCode && !groupedData[ele]?.status ) {
75
+ // await planoLibraryService.updateOne( { fixtureLibCode: groupedData[ele]?.fixtureLibCode }, groupedData[ele] );
76
+ // } else {
77
+ let FixLibCode = await getMaxFixtureLibCode();
78
+ groupedData[ele].fixtureLibCode = FixLibCode;
79
+ // fixtureData.push( groupedData[ele] );
80
+ await planoLibraryService.findOneAndUpdate( { 'fixtureCategory': groupedData[ele].fixtureCategory, 'fixtureWidth.value': groupedData[ele].fixtureWidth.value, 'fixtureWidth.unit': groupedData[ele].fixtureWidth.unit }, groupedData[ele] );
81
+ // }
83
82
  }
84
- await planoLibraryService.insertMany( fixtureData );
83
+ // let deleteList = inputData.deleteFixtureList.map( ( ele ) => new ObjectId( ele ) );
84
+ // if ( deleteList.length ) {
85
+ // await planoLibraryService.deleteMany( { _id: { $in: deleteList } } );
86
+ // }
87
+ // await planoLibraryService.insertMany( fixtureData );
85
88
  return res.sendSuccess( 'Fixture library created successfully' );
86
89
  } catch ( e ) {
87
90
  console.log( e );
@@ -351,6 +354,7 @@ export async function FixtureLibraryList( req, res ) {
351
354
  footer: 1,
352
355
  fixtureLibCode: 1,
353
356
  planoId: { $ifNull: [ { $arrayElemAt: [ '$storeFixtureDetails.planoId', 0 ] }, [] ] },
357
+ templateCount: { $size: '$templateId' },
354
358
  },
355
359
  },
356
360
  {
@@ -389,6 +393,7 @@ export async function FixtureLibraryList( req, res ) {
389
393
  templateId: 1,
390
394
  header: 1,
391
395
  footer: 1,
396
+ templateCount: 1,
392
397
  fixtureLibCode: 1,
393
398
  planoStatus: { $ifNull: [ { $arrayElemAt: [ '$planoStatus.statusList', 0 ] }, [] ] },
394
399
  status: {
@@ -457,7 +462,7 @@ export async function FixtureLibraryList( req, res ) {
457
462
  const workbook = new ExcelJS.Workbook();
458
463
  const sheet = workbook.addWorksheet( 'Fixture Library' );
459
464
 
460
- sheet.getRow( 1 ).values = [ 'Fixture Code', 'Fixture Name', 'Fixture Type', 'Fixture Height(ft)', 'Fixture Width(ft)', 'Fixture Header Height(ft)', 'Fixture Footer Height(ft)', 'Shelf Number', 'Shelf Type', 'Tray Rows', 'Product Per Shelf/Tray', 'Panel Name' ];
465
+ sheet.getRow( 1 ).values = [ 'Fixture Name', 'Fixture Type', 'Fixture Height(ft)', 'Fixture Width(ft)', 'Fixture Header Height(ft)', 'Fixture Footer Height(ft)', 'Shelf Number', 'Shelf Type', 'Tray Rows', 'Product Per Shelf/Tray', 'Panel Name' ];
461
466
 
462
467
  let rowStart = 2;
463
468
  let lockedRowNumber = [];
@@ -483,7 +488,8 @@ export async function FixtureLibraryList( req, res ) {
483
488
  footerHeight = result.data[i].footer.height.value;
484
489
  }
485
490
  if ( !result.data[i].shelfConfig.length ) {
486
- sheet.getRow( rowStart ).values = [ result.data[i]?.fixtureLibCode || '', result.data[i]?.fixtureCategory || '', result.data[i]?.fixtureType || 'Wall', height, width, headerHeight, footerHeight, 0, '', 0, 0, '' ];
491
+ // result.data[i]?.fixtureLibCode || '',
492
+ sheet.getRow( rowStart ).values = [ result.data[i]?.fixtureCategory || '', result.data[i]?.fixtureType || 'Wall', height, width, headerHeight, footerHeight, 0, '', 0, 0, '' ];
487
493
  if ( result.data[i].status == 'active' || result.data[i].templateId.length ) {
488
494
  lockedRowNumber.push( rowStart );
489
495
  }
@@ -491,7 +497,7 @@ export async function FixtureLibraryList( req, res ) {
491
497
  }
492
498
 
493
499
  result.data[i].shelfConfig.forEach( ( shelf ) => {
494
- sheet.getRow( rowStart ).values = [ result.data[i]?.fixtureLibCode || '', result.data[i]?.fixtureCategory || '', result.data[i]?.fixtureType || 'Wall', height, width, headerHeight, footerHeight, shelf?.shelfNumber || 0, shelf?.shelfType || '', shelf?.trayRows || 0, shelf?.productPerShelf || 0, shelf?.label || '' ];
500
+ sheet.getRow( rowStart ).values = [ result.data[i]?.fixtureCategory || '', result.data[i]?.fixtureType || 'Wall', height, width, headerHeight, footerHeight, shelf?.shelfNumber || 0, shelf?.shelfType || '', shelf?.trayRows || 0, shelf?.productPerShelf || 0, shelf?.label || '' ];
495
501
  if ( result.data[i].status == 'active' || result.data[i].templateId.length ) {
496
502
  lockedRowNumber.push( rowStart );
497
503
  }
@@ -502,32 +508,32 @@ export async function FixtureLibraryList( req, res ) {
502
508
 
503
509
  const maxRows = 1048576;
504
510
 
505
- let unlockCellValues = 20000;
506
- let splitLoop = [];
507
-
508
- for ( let i=1; i<=unlockCellValues; i+=2000 ) {
509
- splitLoop.push( { start: i, end: i + 1999 } );
510
- }
511
-
512
- await Promise.all( splitLoop.map( ( item ) => {
513
- for ( let i=item.start; i<=item.end; i++ ) {
514
- const row = sheet.getRow( i );
515
- if ( i > rowStart - 1 ) {
516
- row.values = [ '', '', '', '', '', '', '', '', '', '', '', '' ];
517
- }
518
- if ( !lockedRowNumber.includes( i ) && i != 1 ) {
519
- row.eachCell( ( cell ) => {
520
- const columnLetter = cell.address.replace( /[0-9]/g, '' );
521
- if ( columnLetter != 'A' ) {
522
- cell.protection = { locked: false };
523
- }
524
- } );
525
- }
526
- }
527
- } ) );
528
-
529
-
530
- let dropDownRange = [ { key: `C2:C${maxRows}`, optionList: [ '"wall,floor"' ] }, { key: `I2:I${maxRows}`, optionList: [ '"shelf,tray"' ] } ];
511
+ // let unlockCellValues = 20000;
512
+ // let splitLoop = [];
513
+
514
+ // for ( let i=1; i<=unlockCellValues; i+=2000 ) {
515
+ // splitLoop.push( { start: i, end: i + 1999 } );
516
+ // }
517
+
518
+ // await Promise.all( splitLoop.map( ( item ) => {
519
+ // for ( let i=item.start; i<=item.end; i++ ) {
520
+ // const row = sheet.getRow( i );
521
+ // if ( i > rowStart - 1 ) {
522
+ // row.values = [ '', '', '', '', '', '', '', '', '', '', '', '' ];
523
+ // }
524
+ // if ( !lockedRowNumber.includes( i ) && i != 1 ) {
525
+ // row.eachCell( ( cell ) => {
526
+ // const columnLetter = cell.address.replace( /[0-9]/g, '' );
527
+ // if ( columnLetter != 'A' ) {
528
+ // cell.protection = { locked: false };
529
+ // }
530
+ // } );
531
+ // }
532
+ // }
533
+ // } ) );
534
+
535
+
536
+ let dropDownRange = [ { key: `B2:B${maxRows}`, optionList: [ '"wall,floor"' ] }, { key: `H2:H${maxRows}`, optionList: [ '"shelf,tray"' ] } ];
531
537
 
532
538
  dropDownRange.forEach( ( ele ) => {
533
539
  sheet.dataValidations.add( ele.key, {
@@ -541,10 +547,10 @@ export async function FixtureLibraryList( req, res ) {
541
547
  } );
542
548
 
543
549
 
544
- await sheet.protect( 'password123', {
545
- selectLockedCells: false,
546
- selectUnlockedCells: true,
547
- } );
550
+ // await sheet.protect( 'password123', {
551
+ // selectLockedCells: false,
552
+ // selectUnlockedCells: true,
553
+ // } );
548
554
 
549
555
  sheet.columns.forEach( ( column ) => {
550
556
  let maxLength = 10;
@@ -573,7 +579,7 @@ export async function duplicateFixture( req, res ) {
573
579
  if ( !req.body?.fixtureId ) {
574
580
  return res.sendError( 'FixtureId is required', 400 );
575
581
  }
576
- let fixtureLibDetails = await planoLibraryService.findOne( { _id: req.body?.fixtureId } );
582
+ let fixtureLibDetails = await planoLibraryService.findOne( { _id: req.body?.fixtureId }, { createdAt: 0, updatedAt: 0 } );
577
583
  if ( !fixtureLibDetails ) {
578
584
  return res.sendError( 'No data found', 204 );
579
585
  }
@@ -1168,8 +1174,12 @@ export async function getVmLibList( req, res ) {
1168
1174
  } else {
1169
1175
  const workbook = new ExcelJS.Workbook();
1170
1176
  const sheet = workbook.addWorksheet( 'Fixture Library' );
1177
+ const hiddenSheet = workbook.addWorksheet( 'Hidden' );
1178
+ hiddenSheet.state = 'veryHidden';
1179
+
1180
+ // 'VM Lib Code',
1171
1181
 
1172
- sheet.getRow( 1 ).values = [ 'VM Lib Code', 'VM Name', 'VM Type', 'VM Brand', 'VM Category', 'VM SubCategory', 'Unit', 'VM Height', 'VM Width', 'VM ImageUrl' ];
1182
+ sheet.getRow( 1 ).values = [ 'VM Name', 'VM Type', 'VM Brand', 'VM Category', 'VM SubCategory', 'Unit', 'VM Height', 'VM Width', 'VM ImageUrl' ];
1173
1183
 
1174
1184
  let rowStart = 2;
1175
1185
  let lockedRowNumber = [];
@@ -1191,7 +1201,8 @@ export async function getVmLibList( req, res ) {
1191
1201
  if ( result.data[i]?.vmImageUrl ) {
1192
1202
  result.data[i].vmImageUrl = process.env.PLANOCDNURL +'/'+result.data[i].vmImageUrl;
1193
1203
  }
1194
- sheet.getRow( rowStart ).values = [ result.data[i]?.vmLibCode || '', result.data[i]?.vmName || '', result.data[i]?.vmType || '', result.data[i]?.vmBrand || '', result.data[i]?.vmCategory || '', result.data[i]?.vmSubCategory ||'', unit, height, width, result.data[i]?.vmImageUrl || '' ];
1204
+ // result.data[i]?.vmLibCode || '',
1205
+ sheet.getRow( rowStart ).values = [ result.data[i]?.vmName || '', result.data[i]?.vmType || '', result.data[i]?.vmBrand || '', result.data[i]?.vmCategory || '', result.data[i]?.vmSubCategory ||'', unit, height, width, result.data[i]?.vmImageUrl || '' ];
1195
1206
  if ( result.data[i].templateId.length || result.data[i].status == 'active' ) {
1196
1207
  lockedRowNumber.push( rowStart );
1197
1208
  }
@@ -1201,15 +1212,27 @@ export async function getVmLibList( req, res ) {
1201
1212
  let productBrandDetails = await planoProductService.find( { clientId: req.body.clientId } );
1202
1213
  let vmTypeList = await vmTypeService.find( { clientId: req.body.clientId } );
1203
1214
  vmTypeList = vmTypeList.map( ( ele ) => ele.vmType );
1204
- let brand = productBrandDetails.map( ( ele ) => ele.brandName );
1215
+ let brandList = productBrandDetails.map( ( ele ) => ele.brandName );
1216
+ brandList.forEach( ( brand, index ) => {
1217
+ hiddenSheet.getCell( `A${index + 1}` ).value = brand;
1218
+ } );
1205
1219
  let brandCategories = productBrandDetails.flatMap( ( ele ) => [ ...ele.category ] );
1206
1220
  let brandSubCategories = productBrandDetails.flatMap( ( ele ) => [ ...ele.subCategory ] );
1207
1221
  brandCategories = [ ...new Set( brandCategories.map( ( ele ) => ele ) ) ];
1222
+ brandCategories = brandCategories.length ? brandCategories : [ '' ];
1223
+ brandSubCategories = brandSubCategories.length ? brandSubCategories : [ '' ];
1224
+ brandCategories.forEach( ( brand, index ) => {
1225
+ hiddenSheet.getCell( `B${index + 1}` ).value = brand;
1226
+ } );
1208
1227
  brandSubCategories = [ ...new Set( brandSubCategories.map( ( ele ) => ele ) ) ];
1228
+ brandSubCategories.forEach( ( brand, index ) => {
1229
+ hiddenSheet.getCell( `C${index + 1}` ).value = brand;
1230
+ } );
1209
1231
 
1210
1232
  const maxRows = 1048576;
1211
1233
 
1212
- let dropDownRange = [ { key: `C2:C${maxRows}`, optionList: [ `"${vmTypeList.toString()}"` ] }, { key: `D2:D${maxRows}`, optionList: [ `"${brand.toString()}"` ] }, { key: `E2:E${maxRows}`, optionList: [ `"${brandCategories.toString()}"` ] }, { key: `F2:F${maxRows}`, optionList: [ `"${brandSubCategories.toString()}"` ] }, { key: `G2:G${maxRows}`, optionList: [ '"mm,cm,inches,feet"' ] } ];
1234
+ let dropDownRange = [ { key: `B2:B${maxRows}`, optionList: [ `"${vmTypeList.toString()}"` ] }, { key: `C2:C${maxRows}`, optionList: [ `=Hidden!$A$1:$A$${brandList.length}` ] }, { key: `D2:D${maxRows}`, optionList: [ `=Hidden!$B$1:$B$${brandCategories.length}` ] }, { key: `E2:E${maxRows}`, optionList: [ `=Hidden!$C$1:$C$${brandSubCategories.length}` ] }, { key: `F2:F${maxRows}`, optionList: [ '"mm,cm,inches,feet"' ] } ];
1235
+
1213
1236
 
1214
1237
  dropDownRange.forEach( ( ele ) => {
1215
1238
  sheet.dataValidations.add( ele.key, {
@@ -1222,34 +1245,34 @@ export async function getVmLibList( req, res ) {
1222
1245
  } );
1223
1246
  } );
1224
1247
 
1225
- let unlockCellValues = 20000;
1226
- let splitLoop = [];
1227
-
1228
- for ( let i=1; i<=unlockCellValues; i+=2000 ) {
1229
- splitLoop.push( { start: i, end: i + 1999 } );
1230
- }
1231
-
1232
- await Promise.all( splitLoop.map( ( item ) => {
1233
- for ( let i=item.start; i<=item.end; i++ ) {
1234
- const row = sheet.getRow( i );
1235
- if ( i > rowStart - 1 ) {
1236
- row.values = [ '', '', '', '', '', '', '', '', '', '' ];
1237
- }
1238
- if ( !lockedRowNumber.includes( i ) && i != 1 ) {
1239
- row.eachCell( ( cell ) => {
1240
- const columnLetter = cell.address.replace( /[0-9]/g, '' );
1241
- if ( columnLetter != 'A' ) {
1242
- cell.protection = { locked: false };
1243
- }
1244
- } );
1245
- }
1246
- }
1247
- } ) );
1248
-
1249
- await sheet.protect( 'password123', {
1250
- selectLockedCells: false,
1251
- selectUnlockedCells: true,
1252
- } );
1248
+ // let unlockCellValues = 20000;
1249
+ // let splitLoop = [];
1250
+
1251
+ // for ( let i=1; i<=unlockCellValues; i+=2000 ) {
1252
+ // splitLoop.push( { start: i, end: i + 1999 } );
1253
+ // }
1254
+
1255
+ // await Promise.all( splitLoop.map( ( item ) => {
1256
+ // for ( let i=item.start; i<=item.end; i++ ) {
1257
+ // const row = sheet.getRow( i );
1258
+ // if ( i > rowStart - 1 ) {
1259
+ // row.values = [ '', '', '', '', '', '', '', '', '', '' ];
1260
+ // }
1261
+ // if ( !lockedRowNumber.includes( i ) && i != 1 ) {
1262
+ // row.eachCell( ( cell ) => {
1263
+ // const columnLetter = cell.address.replace( /[0-9]/g, '' );
1264
+ // if ( columnLetter != 'A' ) {
1265
+ // cell.protection = { locked: false };
1266
+ // }
1267
+ // } );
1268
+ // }
1269
+ // }
1270
+ // } ) );
1271
+
1272
+ // await sheet.protect( 'password123', {
1273
+ // selectLockedCells: false,
1274
+ // selectUnlockedCells: true,
1275
+ // } );
1253
1276
 
1254
1277
  sheet.columns.forEach( ( column ) => {
1255
1278
  let maxLength = 10;
@@ -1278,7 +1301,7 @@ export async function duplicateVmLib( req, res ) {
1278
1301
  if ( !req.body?.vmId ) {
1279
1302
  return res.sendError( 'VmId is required', 400 );
1280
1303
  }
1281
- let vmDetails = await vmService.findOne( { _id: req.body?.vmId } );
1304
+ let vmDetails = await vmService.findOne( { _id: req.body?.vmId }, { createdAt: 0, updatedAt: 0 } );
1282
1305
  if ( !vmDetails ) {
1283
1306
  return res.sendError( 'No data found', 204 );
1284
1307
  }
@@ -1362,20 +1385,11 @@ export async function getVmDetails( req, res ) {
1362
1385
  export async function vmBulkUpload( req, res ) {
1363
1386
  try {
1364
1387
  let inputData = req.body;
1365
- await Promise.all( inputData.vmData.map( async ( ele ) => {
1388
+
1389
+ for ( let ele of inputData.vmData ) {
1366
1390
  ele = { ...ele, clientId: req.body.clientId, vmWidth: { value: ele.vmWidth, unit: ele.unit }, vmHeight: { value: ele.vmHeight, unit: ele.unit } };
1367
- let vmLibData;
1368
- if ( !ele?.vmLibCode ) {
1369
- ele.vmLibCode = await getMaxVMLibCode();
1370
- ele.status = inputData.newVmStatus;
1371
- vmLibData = await vmService.create( ele );
1372
- } else {
1373
- if ( typeof ele?.isEdit == undefined ) {
1374
- ele.status = inputData.updateVmStatus;
1375
- await vmService.updateOne( { vmLibCode: ele.vmLibCode }, ele );
1376
- vmLibData = await vmService.findOne( { vmLibCode: ele.vmLibCode } );
1377
- }
1378
- }
1391
+ ele.vmLibCode = await getMaxVMLibCode();
1392
+ ele.status = inputData.newVmStatus;
1379
1393
  if ( vmLibData && !ele?.vmImageUrl.includes( '/vmType/' ) && ele?.vmImageUrl ) {
1380
1394
  let response = await fetch( ele?.vmImageUrl );
1381
1395
  let arrayBuffer = await response.arrayBuffer();
@@ -1388,13 +1402,42 @@ export async function vmBulkUpload( req, res ) {
1388
1402
  };
1389
1403
  let fileRes = await fileUpload( params );
1390
1404
  ele.vmImageUrl = fileRes?.Key;
1391
- await vmService.updateOne( { _id: vmLibData._id }, { vmImageUrl: ele.vmImageUrl } );
1392
1405
  }
1393
- } ) );
1394
- let deleteList = inputData.deleteVmList.map( ( ele ) => new ObjectId( ele ) );
1395
- if ( deleteList.length ) {
1396
- await vmService.deleteMany( { _id: { $in: deleteList } } );
1406
+ vmLibData = await vmService.updateOne( { vmName: ele?.vmName, clientId: inputData.clientId }, ele );
1397
1407
  }
1408
+ // await Promise.all( inputData.vmData.map( async ( ele ) => {
1409
+ // ele = { ...ele, clientId: req.body.clientId, vmWidth: { value: ele.vmWidth, unit: ele.unit }, vmHeight: { value: ele.vmHeight, unit: ele.unit } };
1410
+ // let vmLibData;
1411
+ // if ( !ele?.vmLibCode ) {
1412
+ // ele.vmLibCode = await getMaxVMLibCode();
1413
+ // ele.status = inputData.newVmStatus;
1414
+ // vmLibData = await vmService.create( ele );
1415
+ // } else {
1416
+ // if ( typeof ele?.isEdit == undefined ) {
1417
+ // ele.status = inputData.updateVmStatus;
1418
+ // await vmService.updateOne( { vmLibCode: ele.vmLibCode }, ele );
1419
+ // vmLibData = await vmService.findOne( { vmLibCode: ele.vmLibCode } );
1420
+ // }
1421
+ // }
1422
+ // if ( vmLibData && !ele?.vmImageUrl.includes( '/vmType/' ) && ele?.vmImageUrl ) {
1423
+ // let response = await fetch( ele?.vmImageUrl );
1424
+ // let arrayBuffer = await response.arrayBuffer();
1425
+ // let params = {
1426
+ // Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
1427
+ // Key: `vmType/${vmLibData._id}/${Date.now()}/${path.basename( ele?.vmImageUrl )}`,
1428
+ // fileName: path.basename( ele?.vmImageUrl ),
1429
+ // ContentType: response.headers.get( 'content-type' ),
1430
+ // body: Buffer.from( arrayBuffer ),
1431
+ // };
1432
+ // let fileRes = await fileUpload( params );
1433
+ // ele.vmImageUrl = fileRes?.Key;
1434
+ // await vmService.updateOne( { _id: vmLibData._id }, { vmImageUrl: ele.vmImageUrl } );
1435
+ // }
1436
+ // } ) );
1437
+ // let deleteList = inputData.deleteVmList.map( ( ele ) => new ObjectId( ele ) );
1438
+ // if ( deleteList.length ) {
1439
+ // await vmService.deleteMany( { _id: { $in: deleteList } } );
1440
+ // }
1398
1441
  return res.sendSuccess( 'Vmlibrary details uploaded successfully' );
1399
1442
  } catch ( e ) {
1400
1443
  console.log( e );