ebta-workflow-prod 4.0.8 → 4.0.9

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,7 +1,7 @@
1
1
  {
2
2
  "name": "ebta-workflow-prod",
3
3
  "private": false,
4
- "version": "4.0.8",
4
+ "version": "4.0.9",
5
5
  "description": "",
6
6
  "license": "UNLICENSED",
7
7
  "author": "",
@@ -93,6 +93,11 @@ interface PDFMapGeneratorInputs {
93
93
  * @description specific type name of print template, e.g.'VMP'
94
94
  */
95
95
  template: string;
96
+ /**
97
+ * @displayName Object to provide extra field detail, by key-value(string)
98
+ * @description Object to provide extra field detail, by key-value(string)
99
+ */
100
+ extraField: object;
96
101
  }
97
102
  /** An interface that defines the outputs of the activity. */
98
103
  interface PDFMapGeneratorOutputs {
@@ -277,11 +282,13 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
277
282
  let image1, image2, image3, image10
278
283
  if (inputs.template == 'VMP') {
279
284
  image10 = await doc.embedPng(image10Buffer);
285
+ console.log('image10 embed successfully')
280
286
  }
281
287
  else {
282
288
  image1 = await doc.embedPng(image1Buffer);
283
289
  image2 = await doc.embedPng(image2Buffer);
284
290
  image3 = await doc.embedPng(image3Buffer);
291
+ console.log('image1,2,3 embed successfully')
285
292
  }
286
293
  const imageBar = await doc.embedPng(imageBarBuffer);
287
294
  const imageNorth = await doc.embedPng(imageNorthBuffer);
@@ -292,6 +299,7 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
292
299
  } else if (inputs.LegendImgBase64.startsWith('data:image/jpeg;base64,') || inputs.LegendImgBase64.startsWith('data:image/jpg;base64,')) {
293
300
  legendImage = await doc.embedJpg(legendBuffer);
294
301
  }
302
+ console.log('legend image embed successfully')
295
303
  }
296
304
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
297
305
  newPage.drawImage(image, {
@@ -300,6 +308,7 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
300
308
  width: width * 0.8113,
301
309
  height: height * 0.8029,
302
310
  });
311
+ console.log('map image drawn successfully')
303
312
  if (inputs.LegendImgBase64) {
304
313
  //Define position & size of legend screeshot, depent on width/height ratio
305
314
  if (legendImage.width / legendImage.height > 0.259) {
@@ -455,15 +464,17 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
455
464
  });
456
465
  }
457
466
  }
467
+ console.log('legend image drawn successfully')
458
468
  }
459
469
  const lableSize = 100
460
470
  if (inputs.template == 'VMP') {
461
471
  newPage.drawImage(image10, {
462
- x: 28+200,
472
+ x: 28 + 200,
463
473
  y: 145,
464
474
  width: lableSize,
465
475
  height: lableSize * (image10.height / image10.width),
466
476
  });
477
+ console.log('image10 drawn successfully')
467
478
  }
468
479
  else {
469
480
  newPage.drawImage(image1, {
@@ -484,6 +495,7 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
484
495
  width: lableSize * .8,
485
496
  height: lableSize * .8 * (image3.height / image3.width),
486
497
  });
498
+ console.log('image1,2,3 drawn successfully')
487
499
  }
488
500
  console.log(`success in page. ${i} `)
489
501
  // north arrow
@@ -559,6 +571,18 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
559
571
  const revField = form.getTextField('Rev.' + i)
560
572
  revField.setText(inputs.Rev)
561
573
  revField.updateAppearances(font)
574
+ if (inputs.template=='VMP'){
575
+ //supervisor
576
+ const supervisorField = form.getTextField('Supervisor')
577
+ supervisorField.setText(inputs.extraField['supervisor'])
578
+ supervisorField.setAlignment(TextAlignment.Center)
579
+ supervisorField.updateAppearances(font)
580
+ //UHF
581
+ const uhfField = form.getTextField('UHF')
582
+ uhfField.setText(inputs.extraField['UHF'])
583
+ uhfField.setAlignment(TextAlignment.Center)
584
+ uhfField.updateAppearances(font)
585
+ }
562
586
  //date
563
587
  const today = new Date();
564
588
  const formattedDate = today.toLocaleDateString('en-AU');
@@ -588,6 +612,24 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
588
612
  }
589
613
  console.log('Text Fields removal successful')
590
614
  //draw a QR Code image only when Qr URL is given && QR image not given
615
+ const boldFont = await doc.embedFont(StandardFonts.HelveticaBold);
616
+
617
+ if (inputs.template == 'VMP') {
618
+ newPage.drawText('Maximum Speed 10KM/h within Work Area', {
619
+ x: 28,
620
+ y: 145,
621
+ size: 10.5,
622
+ color: rgb(255, 255, 255), // White color
623
+ font: boldFont,
624
+ });
625
+ newPage.drawText('Maximum Speed 10KM/h within Work Area', {
626
+ x: 28,
627
+ y: 145,
628
+ size: 10,
629
+ color: rgb(255, 0, 0), // red color
630
+ font: boldFont,
631
+ });
632
+ }
591
633
 
592
634
  if (inputs.buttonLink && inputs.buttonLink.length > 0) {
593
635
  const buttonX = width * 0.74
@@ -603,7 +645,7 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
603
645
  width: buttonW,
604
646
  height: buttonH,
605
647
  });
606
- const boldFont = await doc.embedFont(StandardFonts.HelveticaBold);
648
+
607
649
  newPage.drawText('Go to EBTA GIS', {
608
650
  x: buttonX + 5,
609
651
  y: buttonY + 22,
@@ -611,15 +653,7 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
611
653
  color: rgb(1, 1, 1), // White color
612
654
  font: boldFont,
613
655
  });
614
- if (inputs.template == 'VMP') {
615
- newPage.drawText('All must operate under', {
616
- x: 28,
617
- y: 145,
618
- size: 10,
619
- color: rgb(255, 255, 255), // White color
620
- font: boldFont,
621
- });
622
- }
656
+
623
657
 
624
658
  const existingAnnots = newPage.node.lookup(PDFName.of('Annots'));
625
659
  let annotationsArray = existingAnnots instanceof PDFArray ? existingAnnots : doc.context.obj([]);
@@ -755,6 +789,7 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
755
789
 
756
790
  const pdfBytes = await finalPDF.save();
757
791
  const base64String = this.arrayBufferToBase64(pdfBytes);
792
+ //was and still working fine, ignore the bug report
758
793
  const downloadUrl = this.createDownloadUrl(base64String);
759
794
  console.log('pdf file created and ready to download');
760
795
  return {