@smarterplan/ngx-smarterplan-core 1.2.23 → 1.2.25

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.
@@ -4396,10 +4396,6 @@ const uploadFileToS3 = async (path, file, objectId) => {
4396
4396
  .then((result) => {
4397
4397
  console.log("Success =>", result);
4398
4398
  return result.key;
4399
- })
4400
- .catch((error) => {
4401
- console.log("error =>", error);
4402
- return null;
4403
4399
  });
4404
4400
  };
4405
4401
  const getSignedImageUrlForEquipment = async (equip) => {
@@ -4443,6 +4439,23 @@ const uploadBase64Image = async (uri, objectId, path, friendlyFileName) => {
4443
4439
  return uploadFileToS3(path, file, objectId);
4444
4440
  });
4445
4441
  };
4442
+ const uploadBase64ImageWithRetry = async (uri, objectId, path, friendlyFileName, retry) => {
4443
+ return new Promise(async (resolve, reject) => {
4444
+ while (retry > 0) {
4445
+ try {
4446
+ const r = await uploadBase64Image(uri, objectId, path, friendlyFileName);
4447
+ resolve(r);
4448
+ return;
4449
+ }
4450
+ catch (e) {
4451
+ retry--;
4452
+ console.error(`Upload error, retry n° ${retry} : `, e);
4453
+ }
4454
+ }
4455
+ ;
4456
+ reject("Max retry exceeded");
4457
+ });
4458
+ };
4446
4459
  const removeAllFilesFromFolderS3 = async (folderPath) => {
4447
4460
  const arrayOfPromises = [];
4448
4461
  Storage.list(folderPath, { level: "public" })
@@ -6636,11 +6649,11 @@ class TicketsService extends BaseObjectService {
6636
6649
  ticketsFiltered = ticketsFiltered.filter((ticket) => this.ticketTypeFilter.includes(ticket.type));
6637
6650
  }
6638
6651
  this.currentTickets.space = ticketsFiltered;
6639
- this.ticketTags.next(ticketsFiltered); // tags without zone filter
6640
6652
  if (this.zoneIDFilter) {
6641
6653
  ticketsFiltered = await this.filterService.filterObjectsForZone(ticketsFiltered, this.zoneIDFilter);
6642
6654
  }
6643
6655
  this.currentTickets.zone = ticketsFiltered;
6656
+ this.ticketTags.next(ticketsFiltered);
6644
6657
  this.ticketsUpdated.next(this.currentTickets);
6645
6658
  this.updating.next(false);
6646
6659
  }
@@ -6996,8 +7009,21 @@ class TicketsService extends BaseObjectService {
6996
7009
  return;
6997
7010
  }
6998
7011
  if (!forceSwitchVisit) {
6999
- /** Si on ne force pas la visite, on demande si on veut etre switch */
7000
- openModalForVisitSwitch(this.modalService, result.model3D, ticket.spaceID, { sweepToMove: result.sweep, rotation: result.rotation });
7012
+ // check if we are moving within the same 3D model
7013
+ const currentModel = localStorage.getItem('model3D');
7014
+ if (currentModel && currentModel === result.model3D) {
7015
+ // we add tag to the visit
7016
+ const poi = ticket.pois.items[0];
7017
+ if (poi.coordinate) {
7018
+ // we force add because we might be in an another zone
7019
+ await this.viewerService.actionAddObjectFromPOI(ticket, poi);
7020
+ await this.viewerService.action_move_to_tag(ticket.id);
7021
+ }
7022
+ }
7023
+ else {
7024
+ /** Si on ne force pas la visite, on demande si on veut etre switch */
7025
+ openModalForVisitSwitch(this.modalService, result.model3D, ticket.spaceID, { sweepToMove: result.sweep, rotation: result.rotation });
7026
+ }
7001
7027
  }
7002
7028
  else {
7003
7029
  /** Si on force le switch de la visit */
@@ -10069,11 +10095,11 @@ class FeatureService extends BaseObjectService {
10069
10095
  filteredFeatures = [...filteredPointInterest, ...filteredDesks];
10070
10096
  this.currentFeatures.space = filteredFeatures.sort((a, b) => a.index - b.index);
10071
10097
  // emit on tags should be after setting current.space !!
10072
- this.featureTags.next(filteredFeatures); // for tags update without zone filtering
10073
10098
  if (this.zoneIDFilter) {
10074
10099
  filteredFeatures =
10075
10100
  (await this.filterService.filterObjectsForZone(filteredFeatures, this.zoneIDFilter));
10076
10101
  }
10102
+ this.featureTags.next(filteredFeatures); // for this zone
10077
10103
  this.currentFeatures.zone = filteredFeatures.sort((a, b) => a.index - b.index);
10078
10104
  // console.log(this.currentFeatures);
10079
10105
  this.featureUpdated.next(this.currentFeatures); // for lateral menu
@@ -10365,11 +10391,11 @@ class MeasurementService {
10365
10391
  }
10366
10392
  this.currentMeasurements.space = measurements;
10367
10393
  // emit on tags should be after setting current.space !!
10368
- this.measurementsTags.next(measurements.map((m) => m.comment));
10369
10394
  if (this.zoneIDFilter) {
10370
10395
  const commentsZone = await this.filterService.filterObjectsForZone(measurements.map((measure) => measure.comment), this.zoneIDFilter);
10371
10396
  measurements = measurements.filter((measure) => commentsZone.includes(measure.comment));
10372
10397
  }
10398
+ this.measurementsTags.next(measurements.map((m) => m.comment));
10373
10399
  measurements.sort((a, b) => {
10374
10400
  return (
10375
10401
  // @ts-ignore
@@ -11401,7 +11427,6 @@ class MatterportImportService {
11401
11427
  this.importingImages = new Subject();
11402
11428
  this.sweepProcessedCount = new Subject();
11403
11429
  this.totalSweepsCount = new Subject();
11404
- this.MAX_SCANS_RELOAD = 10;
11405
11430
  }
11406
11431
  get spaceID() {
11407
11432
  return this._spaceID;
@@ -11479,7 +11504,7 @@ class MatterportImportService {
11479
11504
  });
11480
11505
  });
11481
11506
  }
11482
- async importData(spaceID, surface, reloading = false, node = null) {
11507
+ async importData(spaceID, surface, reloading = false, node = null, overrideExisting = true) {
11483
11508
  if (!this.sweeps) {
11484
11509
  return Promise.reject(new Error('no sweeps initialized'));
11485
11510
  }
@@ -11495,10 +11520,9 @@ class MatterportImportService {
11495
11520
  await waitUntil(() => appIsLoaded === true);
11496
11521
  if (reloading) {
11497
11522
  // perform only 360 import since we are reloading
11498
- await this.import360images();
11523
+ await this.import360images(overrideExisting);
11499
11524
  return Promise.resolve(true);
11500
11525
  }
11501
- this.cleanLocalStorage(); // we are importing new visit
11502
11526
  this.spaceID = spaceID;
11503
11527
  let floorZones = [];
11504
11528
  const zones = await this.zoneService.getZonesBySpace(spaceID);
@@ -11535,7 +11559,7 @@ class MatterportImportService {
11535
11559
  console.log('could create navigation', navigationInput.id);
11536
11560
  }
11537
11561
  }));
11538
- await this.import360images();
11562
+ await this.import360images(overrideExisting);
11539
11563
  return Promise.resolve(true);
11540
11564
  }
11541
11565
  async createZone(name, layerID, surface = null, parentID = null, sweeps = [], node = null, metadata = null) {
@@ -11559,46 +11583,30 @@ class MatterportImportService {
11559
11583
  const newLocal = await this.zoneService.create(zoneInput);
11560
11584
  return newLocal;
11561
11585
  }
11562
- async import360images() {
11586
+ async import360images(overrideExisting = true) {
11563
11587
  console.log('Importing 360 images');
11564
11588
  this.importingImages.next(true);
11565
11589
  return new Promise(async (resolve) => {
11566
11590
  const scans = Object.values(this.sweeps);
11567
- let maxScan;
11568
- let indexScan;
11569
11591
  const nmbScans = Object.keys(scans).length;
11570
- console.log('Total number of scan points :', nmbScans);
11571
11592
  this.totalSweepsCount.next(nmbScans);
11572
- // check if we started to load images already
11573
- if (localStorage.getItem('indexScanLoad')) {
11574
- console.log('retaking import from scan', localStorage.getItem('indexScanLoad'));
11575
- indexScan = +localStorage.getItem('indexScanLoad');
11576
- nmbScans < indexScan + this.MAX_SCANS_RELOAD
11577
- ? (maxScan = nmbScans)
11578
- : (maxScan = indexScan + this.MAX_SCANS_RELOAD);
11579
- }
11580
- else {
11581
- indexScan = 0;
11582
- nmbScans < this.MAX_SCANS_RELOAD
11583
- ? (maxScan = nmbScans)
11584
- : (maxScan = this.MAX_SCANS_RELOAD);
11585
- }
11586
- for (let index = indexScan; index < maxScan; index += 1) {
11593
+ const start = overrideExisting ? 0 : await this.getUploadedImageCount(this.modelID);
11594
+ for (let index = start; index < nmbScans; index += 1) {
11587
11595
  if (!this.stop) {
11588
- await new Promise((res) => {
11589
- setTimeout(() => {
11590
- res(null);
11591
- }, 1000);
11592
- });
11593
- await this.sdk.Sweep.moveTo(scans[index].uuid);
11594
- await this.sdk.Camera.setRotation({
11595
- x: 0,
11596
- y: 0,
11597
- });
11596
+ await this.sdk.Sweep.moveTo(scans[index].uuid, { rotation: { x: 0, y: 0 }, transition: this.sdk.Sweep.Transition.INSTANT, transitionTime: 0 });
11598
11597
  const img = await this.sdk.Renderer.takeEquirectangular({ width: 2048, height: 1024 }, { mattertags: false, sweeps: true });
11599
- await uploadBase64Image(img, scans[index].uuid, `visits/${this.modelID}/sweeps/`, 'sweep');
11600
- this.sweepProcessedCount.next(index);
11601
- localStorage.setItem('indexScanLoad', index.toString());
11598
+ /**Upload on S3 are asynchronous, in order to no slow down the process*/
11599
+ uploadBase64ImageWithRetry(img, scans[index].uuid, `visits/${this.modelID}/sweeps/`, 'sweep', 5).then((r) => {
11600
+ this.sweepProcessedCount.next(index);
11601
+ if (index === nmbScans - 1) {
11602
+ console.log('Import 360 done');
11603
+ resolve(true);
11604
+ this.removeFrame();
11605
+ this.stop = true;
11606
+ }
11607
+ }).catch((e) => {
11608
+ console.log("Error uploading scan : ", e);
11609
+ });
11602
11610
  }
11603
11611
  else {
11604
11612
  console.log('Abandoning import because it was cancelled');
@@ -11606,22 +11614,17 @@ class MatterportImportService {
11606
11614
  break;
11607
11615
  }
11608
11616
  }
11609
- if (maxScan === nmbScans) {
11610
- console.log('Import 360 done');
11611
- this.cleanLocalStorage();
11612
- this.removeFrame();
11613
- this.stop = true;
11614
- resolve(true);
11615
- }
11616
- else if (!this.stop) {
11617
- // to restart the procedure from where we left of
11618
- localStorage.setItem('indexScanLoad', maxScan.toString());
11619
- localStorage.setItem('visitInImport', this.modelID);
11620
- this.removeFrame();
11621
- window.location.reload();
11622
- }
11623
11617
  });
11624
11618
  }
11619
+ async getUploadedImageCount(modelID) {
11620
+ try {
11621
+ const images = await listFilesInFolder(`visits/${modelID}/sweeps/`);
11622
+ return images.length;
11623
+ }
11624
+ catch (e) {
11625
+ return 0;
11626
+ }
11627
+ }
11625
11628
  async moveToFloor(floorName, matterportFloorSequence = null) {
11626
11629
  if (!this.floors) {
11627
11630
  console.log('Floor are not loaded yet');
@@ -11708,7 +11711,6 @@ class MatterportImportService {
11708
11711
  abandon() {
11709
11712
  setTimeout(() => {
11710
11713
  console.log('abandonning import');
11711
- localStorage.removeItem('visitInImport');
11712
11714
  this.stop = true;
11713
11715
  this.removeFrame();
11714
11716
  }, 500);
@@ -11718,10 +11720,6 @@ class MatterportImportService {
11718
11720
  this.currentFrame.remove();
11719
11721
  }
11720
11722
  }
11721
- cleanLocalStorage() {
11722
- localStorage.removeItem('indexScanLoad');
11723
- localStorage.removeItem('visitInImport');
11724
- }
11725
11723
  async getLayerByName(name) {
11726
11724
  const mission = this.userService.currentMission(this.spaceID);
11727
11725
  const currentOrgId = mission.organisationID;
@@ -12303,5 +12301,5 @@ function floatValidator() {
12303
12301
  * Generated bundle index. Do not edit.
12304
12302
  */
12305
12303
 
12306
- export { AffectationService, AvatarComponent, BaseLateralTabService, BaseTagService, BaseUserService, BaseVisibilityService, CameraMode, CaptureService, CaptureViewer, CommentService, CommentType, Config, ContentService, CsvExportComponent, DomainService, DomainType, DurationToStringPipe, EmailStatus, EquipmentService, EventService, EventStatus, EventType, FeatureService, FeatureType, FilterService, HashtagFromIdPipe, HashtagService, InterventionService, InventoryStatus, LayerService, LevelStatus, LoaderComponent, Locale, LocaleService, MatterportImportService, MatterportService, MattertagActionMode, MattertagData, MeasurementService, MenuBarComponent, MissionService, NavigationService, NavigatorService, NgxSmarterplanCoreModule, NgxSmarterplanCoreService, NodeService, Object3DService, OperationService, OrganisationService, PaymentStatus, PlanService, PoiService, PoiType, ProfileEntity, ProfileService, ProfileStatus, PropertyService, PropertyType, RoleStatus, SafeUrlPipe, SearchBarComponent, SearchObjectType, SearchService, SpModule, SpaceService, SpaceStatus, StatusEquipment, SupportModalComponent, SupportService, TagAction, TemplateService, TicketPriority, TicketStatus, TicketType, TicketsService, TimeDateToLocalStringPipe, TypeNote, UsernameFromIdPipe, ValidatorsService, ViewerInteractions, ViewerService, VisitService, ZoneChangeService, ZoneService, arraysContainSameElements, checkElementById, convertTimestampToLocalZone, dateHasExpired, dateTimeToLocalString, deleteFromS3, downloadBlob, downloadEquipmentDocument, downloadFile, downloadFileAsObject, durationToString, emailValidator, enumToArray, filterUniqueArrayByID, floatValidator, getBufferForFileFromS3, getCoefficientsForImage, getDistanceBetweenTwoPoints, getHighestLevelForMissions, getHighestRoleForMissions, getLevelsBelow, getLocaleLong, getLocaleShort, getMetaForImage, getRolesBelowForManager, getSignedFile, getSignedImageUrlForEquipment, getSignedImageUrlForProfile, getSignedImageUrlForSpace, getSpaceIDFromUrl, getVisitUrl, isEmptyObject, listFilesInFolder, mean, noEmptyValidator, numberToDateString, openDocument, openModalForVisitSwitch, poiTypeToString, removeAllFilesFromFolderS3, removeNullKeysFromObject, showScanPointsOnPlanInDiv, shuffleArray, sortAlphabeticallyOnName, stringLocaleToEnum, stringToLowercaseNoSpaces, styleButton, textValidator, translateDatePeriod, uploadBase64Image, uploadFileToS3, uploadJsonToS3, validEmail, wait, waitUntil };
12304
+ export { AffectationService, AvatarComponent, BaseLateralTabService, BaseTagService, BaseUserService, BaseVisibilityService, CameraMode, CaptureService, CaptureViewer, CommentService, CommentType, Config, ContentService, CsvExportComponent, DomainService, DomainType, DurationToStringPipe, EmailStatus, EquipmentService, EventService, EventStatus, EventType, FeatureService, FeatureType, FilterService, HashtagFromIdPipe, HashtagService, InterventionService, InventoryStatus, LayerService, LevelStatus, LoaderComponent, Locale, LocaleService, MatterportImportService, MatterportService, MattertagActionMode, MattertagData, MeasurementService, MenuBarComponent, MissionService, NavigationService, NavigatorService, NgxSmarterplanCoreModule, NgxSmarterplanCoreService, NodeService, Object3DService, OperationService, OrganisationService, PaymentStatus, PlanService, PoiService, PoiType, ProfileEntity, ProfileService, ProfileStatus, PropertyService, PropertyType, RoleStatus, SafeUrlPipe, SearchBarComponent, SearchObjectType, SearchService, SpModule, SpaceService, SpaceStatus, StatusEquipment, SupportModalComponent, SupportService, TagAction, TemplateService, TicketPriority, TicketStatus, TicketType, TicketsService, TimeDateToLocalStringPipe, TypeNote, UsernameFromIdPipe, ValidatorsService, ViewerInteractions, ViewerService, VisitService, ZoneChangeService, ZoneService, arraysContainSameElements, checkElementById, convertTimestampToLocalZone, dateHasExpired, dateTimeToLocalString, deleteFromS3, downloadBlob, downloadEquipmentDocument, downloadFile, downloadFileAsObject, durationToString, emailValidator, enumToArray, filterUniqueArrayByID, floatValidator, getBufferForFileFromS3, getCoefficientsForImage, getDistanceBetweenTwoPoints, getHighestLevelForMissions, getHighestRoleForMissions, getLevelsBelow, getLocaleLong, getLocaleShort, getMetaForImage, getRolesBelowForManager, getSignedFile, getSignedImageUrlForEquipment, getSignedImageUrlForProfile, getSignedImageUrlForSpace, getSpaceIDFromUrl, getVisitUrl, isEmptyObject, listFilesInFolder, mean, noEmptyValidator, numberToDateString, openDocument, openModalForVisitSwitch, poiTypeToString, removeAllFilesFromFolderS3, removeNullKeysFromObject, showScanPointsOnPlanInDiv, shuffleArray, sortAlphabeticallyOnName, stringLocaleToEnum, stringToLowercaseNoSpaces, styleButton, textValidator, translateDatePeriod, uploadBase64Image, uploadBase64ImageWithRetry, uploadFileToS3, uploadJsonToS3, validEmail, wait, waitUntil };
12307
12305
  //# sourceMappingURL=smarterplan-ngx-smarterplan-core.mjs.map