@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.
@@ -4591,10 +4591,6 @@ const uploadFileToS3 = (path, file, objectId) => __awaiter(void 0, void 0, void
4591
4591
  .then((result) => {
4592
4592
  console.log("Success =>", result);
4593
4593
  return result.key;
4594
- })
4595
- .catch((error) => {
4596
- console.log("error =>", error);
4597
- return null;
4598
4594
  });
4599
4595
  });
4600
4596
  const getSignedImageUrlForEquipment = (equip) => __awaiter(void 0, void 0, void 0, function* () {
@@ -4638,6 +4634,23 @@ const uploadBase64Image = (uri, objectId, path, friendlyFileName) => __awaiter(v
4638
4634
  return uploadFileToS3(path, file, objectId);
4639
4635
  });
4640
4636
  });
4637
+ const uploadBase64ImageWithRetry = (uri, objectId, path, friendlyFileName, retry) => __awaiter(void 0, void 0, void 0, function* () {
4638
+ return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
4639
+ while (retry > 0) {
4640
+ try {
4641
+ const r = yield uploadBase64Image(uri, objectId, path, friendlyFileName);
4642
+ resolve(r);
4643
+ return;
4644
+ }
4645
+ catch (e) {
4646
+ retry--;
4647
+ console.error(`Upload error, retry n° ${retry} : `, e);
4648
+ }
4649
+ }
4650
+ ;
4651
+ reject("Max retry exceeded");
4652
+ }));
4653
+ });
4641
4654
  const removeAllFilesFromFolderS3 = (folderPath) => __awaiter(void 0, void 0, void 0, function* () {
4642
4655
  const arrayOfPromises = [];
4643
4656
  Storage.list(folderPath, { level: "public" })
@@ -6972,11 +6985,11 @@ class TicketsService extends BaseObjectService {
6972
6985
  ticketsFiltered = ticketsFiltered.filter((ticket) => this.ticketTypeFilter.includes(ticket.type));
6973
6986
  }
6974
6987
  this.currentTickets.space = ticketsFiltered;
6975
- this.ticketTags.next(ticketsFiltered); // tags without zone filter
6976
6988
  if (this.zoneIDFilter) {
6977
6989
  ticketsFiltered = yield this.filterService.filterObjectsForZone(ticketsFiltered, this.zoneIDFilter);
6978
6990
  }
6979
6991
  this.currentTickets.zone = ticketsFiltered;
6992
+ this.ticketTags.next(ticketsFiltered);
6980
6993
  this.ticketsUpdated.next(this.currentTickets);
6981
6994
  this.updating.next(false);
6982
6995
  }
@@ -7366,8 +7379,21 @@ class TicketsService extends BaseObjectService {
7366
7379
  return;
7367
7380
  }
7368
7381
  if (!forceSwitchVisit) {
7369
- /** Si on ne force pas la visite, on demande si on veut etre switch */
7370
- openModalForVisitSwitch(this.modalService, result.model3D, ticket.spaceID, { sweepToMove: result.sweep, rotation: result.rotation });
7382
+ // check if we are moving within the same 3D model
7383
+ const currentModel = localStorage.getItem('model3D');
7384
+ if (currentModel && currentModel === result.model3D) {
7385
+ // we add tag to the visit
7386
+ const poi = ticket.pois.items[0];
7387
+ if (poi.coordinate) {
7388
+ // we force add because we might be in an another zone
7389
+ yield this.viewerService.actionAddObjectFromPOI(ticket, poi);
7390
+ yield this.viewerService.action_move_to_tag(ticket.id);
7391
+ }
7392
+ }
7393
+ else {
7394
+ /** Si on ne force pas la visite, on demande si on veut etre switch */
7395
+ openModalForVisitSwitch(this.modalService, result.model3D, ticket.spaceID, { sweepToMove: result.sweep, rotation: result.rotation });
7396
+ }
7371
7397
  }
7372
7398
  else {
7373
7399
  /** Si on force le switch de la visit */
@@ -10615,11 +10641,11 @@ class FeatureService extends BaseObjectService {
10615
10641
  filteredFeatures = [...filteredPointInterest, ...filteredDesks];
10616
10642
  this.currentFeatures.space = filteredFeatures.sort((a, b) => a.index - b.index);
10617
10643
  // emit on tags should be after setting current.space !!
10618
- this.featureTags.next(filteredFeatures); // for tags update without zone filtering
10619
10644
  if (this.zoneIDFilter) {
10620
10645
  filteredFeatures =
10621
10646
  (yield this.filterService.filterObjectsForZone(filteredFeatures, this.zoneIDFilter));
10622
10647
  }
10648
+ this.featureTags.next(filteredFeatures); // for this zone
10623
10649
  this.currentFeatures.zone = filteredFeatures.sort((a, b) => a.index - b.index);
10624
10650
  // console.log(this.currentFeatures);
10625
10651
  this.featureUpdated.next(this.currentFeatures); // for lateral menu
@@ -10933,11 +10959,11 @@ class MeasurementService {
10933
10959
  }
10934
10960
  this.currentMeasurements.space = measurements;
10935
10961
  // emit on tags should be after setting current.space !!
10936
- this.measurementsTags.next(measurements.map((m) => m.comment));
10937
10962
  if (this.zoneIDFilter) {
10938
10963
  const commentsZone = yield this.filterService.filterObjectsForZone(measurements.map((measure) => measure.comment), this.zoneIDFilter);
10939
10964
  measurements = measurements.filter((measure) => commentsZone.includes(measure.comment));
10940
10965
  }
10966
+ this.measurementsTags.next(measurements.map((m) => m.comment));
10941
10967
  measurements.sort((a, b) => {
10942
10968
  return (
10943
10969
  // @ts-ignore
@@ -12054,7 +12080,6 @@ class MatterportImportService {
12054
12080
  this.importingImages = new Subject();
12055
12081
  this.sweepProcessedCount = new Subject();
12056
12082
  this.totalSweepsCount = new Subject();
12057
- this.MAX_SCANS_RELOAD = 10;
12058
12083
  }
12059
12084
  get spaceID() {
12060
12085
  return this._spaceID;
@@ -12134,7 +12159,7 @@ class MatterportImportService {
12134
12159
  });
12135
12160
  });
12136
12161
  }
12137
- importData(spaceID, surface, reloading = false, node = null) {
12162
+ importData(spaceID, surface, reloading = false, node = null, overrideExisting = true) {
12138
12163
  return __awaiter(this, void 0, void 0, function* () {
12139
12164
  if (!this.sweeps) {
12140
12165
  return Promise.reject(new Error('no sweeps initialized'));
@@ -12151,10 +12176,9 @@ class MatterportImportService {
12151
12176
  yield waitUntil(() => appIsLoaded === true);
12152
12177
  if (reloading) {
12153
12178
  // perform only 360 import since we are reloading
12154
- yield this.import360images();
12179
+ yield this.import360images(overrideExisting);
12155
12180
  return Promise.resolve(true);
12156
12181
  }
12157
- this.cleanLocalStorage(); // we are importing new visit
12158
12182
  this.spaceID = spaceID;
12159
12183
  let floorZones = [];
12160
12184
  const zones = yield this.zoneService.getZonesBySpace(spaceID);
@@ -12191,7 +12215,7 @@ class MatterportImportService {
12191
12215
  console.log('could create navigation', navigationInput.id);
12192
12216
  }
12193
12217
  })));
12194
- yield this.import360images();
12218
+ yield this.import360images(overrideExisting);
12195
12219
  return Promise.resolve(true);
12196
12220
  });
12197
12221
  }
@@ -12218,47 +12242,31 @@ class MatterportImportService {
12218
12242
  return newLocal;
12219
12243
  });
12220
12244
  }
12221
- import360images() {
12245
+ import360images(overrideExisting = true) {
12222
12246
  return __awaiter(this, void 0, void 0, function* () {
12223
12247
  console.log('Importing 360 images');
12224
12248
  this.importingImages.next(true);
12225
12249
  return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
12226
12250
  const scans = Object.values(this.sweeps);
12227
- let maxScan;
12228
- let indexScan;
12229
12251
  const nmbScans = Object.keys(scans).length;
12230
- console.log('Total number of scan points :', nmbScans);
12231
12252
  this.totalSweepsCount.next(nmbScans);
12232
- // check if we started to load images already
12233
- if (localStorage.getItem('indexScanLoad')) {
12234
- console.log('retaking import from scan', localStorage.getItem('indexScanLoad'));
12235
- indexScan = +localStorage.getItem('indexScanLoad');
12236
- nmbScans < indexScan + this.MAX_SCANS_RELOAD
12237
- ? (maxScan = nmbScans)
12238
- : (maxScan = indexScan + this.MAX_SCANS_RELOAD);
12239
- }
12240
- else {
12241
- indexScan = 0;
12242
- nmbScans < this.MAX_SCANS_RELOAD
12243
- ? (maxScan = nmbScans)
12244
- : (maxScan = this.MAX_SCANS_RELOAD);
12245
- }
12246
- for (let index = indexScan; index < maxScan; index += 1) {
12253
+ const start = overrideExisting ? 0 : yield this.getUploadedImageCount(this.modelID);
12254
+ for (let index = start; index < nmbScans; index += 1) {
12247
12255
  if (!this.stop) {
12248
- yield new Promise((res) => {
12249
- setTimeout(() => {
12250
- res(null);
12251
- }, 1000);
12252
- });
12253
- yield this.sdk.Sweep.moveTo(scans[index].uuid);
12254
- yield this.sdk.Camera.setRotation({
12255
- x: 0,
12256
- y: 0,
12257
- });
12256
+ yield this.sdk.Sweep.moveTo(scans[index].uuid, { rotation: { x: 0, y: 0 }, transition: this.sdk.Sweep.Transition.INSTANT, transitionTime: 0 });
12258
12257
  const img = yield this.sdk.Renderer.takeEquirectangular({ width: 2048, height: 1024 }, { mattertags: false, sweeps: true });
12259
- yield uploadBase64Image(img, scans[index].uuid, `visits/${this.modelID}/sweeps/`, 'sweep');
12260
- this.sweepProcessedCount.next(index);
12261
- localStorage.setItem('indexScanLoad', index.toString());
12258
+ /**Upload on S3 are asynchronous, in order to no slow down the process*/
12259
+ uploadBase64ImageWithRetry(img, scans[index].uuid, `visits/${this.modelID}/sweeps/`, 'sweep', 5).then((r) => {
12260
+ this.sweepProcessedCount.next(index);
12261
+ if (index === nmbScans - 1) {
12262
+ console.log('Import 360 done');
12263
+ resolve(true);
12264
+ this.removeFrame();
12265
+ this.stop = true;
12266
+ }
12267
+ }).catch((e) => {
12268
+ console.log("Error uploading scan : ", e);
12269
+ });
12262
12270
  }
12263
12271
  else {
12264
12272
  console.log('Abandoning import because it was cancelled');
@@ -12266,23 +12274,20 @@ class MatterportImportService {
12266
12274
  break;
12267
12275
  }
12268
12276
  }
12269
- if (maxScan === nmbScans) {
12270
- console.log('Import 360 done');
12271
- this.cleanLocalStorage();
12272
- this.removeFrame();
12273
- this.stop = true;
12274
- resolve(true);
12275
- }
12276
- else if (!this.stop) {
12277
- // to restart the procedure from where we left of
12278
- localStorage.setItem('indexScanLoad', maxScan.toString());
12279
- localStorage.setItem('visitInImport', this.modelID);
12280
- this.removeFrame();
12281
- window.location.reload();
12282
- }
12283
12277
  }));
12284
12278
  });
12285
12279
  }
12280
+ getUploadedImageCount(modelID) {
12281
+ return __awaiter(this, void 0, void 0, function* () {
12282
+ try {
12283
+ const images = yield listFilesInFolder(`visits/${modelID}/sweeps/`);
12284
+ return images.length;
12285
+ }
12286
+ catch (e) {
12287
+ return 0;
12288
+ }
12289
+ });
12290
+ }
12286
12291
  moveToFloor(floorName, matterportFloorSequence = null) {
12287
12292
  return __awaiter(this, void 0, void 0, function* () {
12288
12293
  if (!this.floors) {
@@ -12375,7 +12380,6 @@ class MatterportImportService {
12375
12380
  abandon() {
12376
12381
  setTimeout(() => {
12377
12382
  console.log('abandonning import');
12378
- localStorage.removeItem('visitInImport');
12379
12383
  this.stop = true;
12380
12384
  this.removeFrame();
12381
12385
  }, 500);
@@ -12385,10 +12389,6 @@ class MatterportImportService {
12385
12389
  this.currentFrame.remove();
12386
12390
  }
12387
12391
  }
12388
- cleanLocalStorage() {
12389
- localStorage.removeItem('indexScanLoad');
12390
- localStorage.removeItem('visitInImport');
12391
- }
12392
12392
  getLayerByName(name) {
12393
12393
  return __awaiter(this, void 0, void 0, function* () {
12394
12394
  const mission = this.userService.currentMission(this.spaceID);
@@ -13048,5 +13048,5 @@ function floatValidator() {
13048
13048
  * Generated bundle index. Do not edit.
13049
13049
  */
13050
13050
 
13051
- 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 };
13051
+ 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 };
13052
13052
  //# sourceMappingURL=smarterplan-ngx-smarterplan-core.mjs.map