@smarterplan/ngx-smarterplan-core 1.2.24 → 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.
- package/esm2020/lib/services/matterport-import.service.mjs +30 -58
- package/esm2020/lib/services/s3.service.mjs +18 -5
- package/fesm2015/smarterplan-ngx-smarterplan-core.mjs +48 -61
- package/fesm2015/smarterplan-ngx-smarterplan-core.mjs.map +1 -1
- package/fesm2020/smarterplan-ngx-smarterplan-core.mjs +46 -61
- package/fesm2020/smarterplan-ngx-smarterplan-core.mjs.map +1 -1
- package/lib/services/matterport-import.service.d.ts +3 -4
- package/lib/services/s3.service.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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" })
|
|
@@ -11414,7 +11427,6 @@ class MatterportImportService {
|
|
|
11414
11427
|
this.importingImages = new Subject();
|
|
11415
11428
|
this.sweepProcessedCount = new Subject();
|
|
11416
11429
|
this.totalSweepsCount = new Subject();
|
|
11417
|
-
this.MAX_SCANS_RELOAD = 10;
|
|
11418
11430
|
}
|
|
11419
11431
|
get spaceID() {
|
|
11420
11432
|
return this._spaceID;
|
|
@@ -11492,7 +11504,7 @@ class MatterportImportService {
|
|
|
11492
11504
|
});
|
|
11493
11505
|
});
|
|
11494
11506
|
}
|
|
11495
|
-
async importData(spaceID, surface, reloading = false, node = null) {
|
|
11507
|
+
async importData(spaceID, surface, reloading = false, node = null, overrideExisting = true) {
|
|
11496
11508
|
if (!this.sweeps) {
|
|
11497
11509
|
return Promise.reject(new Error('no sweeps initialized'));
|
|
11498
11510
|
}
|
|
@@ -11508,10 +11520,9 @@ class MatterportImportService {
|
|
|
11508
11520
|
await waitUntil(() => appIsLoaded === true);
|
|
11509
11521
|
if (reloading) {
|
|
11510
11522
|
// perform only 360 import since we are reloading
|
|
11511
|
-
await this.import360images();
|
|
11523
|
+
await this.import360images(overrideExisting);
|
|
11512
11524
|
return Promise.resolve(true);
|
|
11513
11525
|
}
|
|
11514
|
-
this.cleanLocalStorage(); // we are importing new visit
|
|
11515
11526
|
this.spaceID = spaceID;
|
|
11516
11527
|
let floorZones = [];
|
|
11517
11528
|
const zones = await this.zoneService.getZonesBySpace(spaceID);
|
|
@@ -11548,7 +11559,7 @@ class MatterportImportService {
|
|
|
11548
11559
|
console.log('could create navigation', navigationInput.id);
|
|
11549
11560
|
}
|
|
11550
11561
|
}));
|
|
11551
|
-
await this.import360images();
|
|
11562
|
+
await this.import360images(overrideExisting);
|
|
11552
11563
|
return Promise.resolve(true);
|
|
11553
11564
|
}
|
|
11554
11565
|
async createZone(name, layerID, surface = null, parentID = null, sweeps = [], node = null, metadata = null) {
|
|
@@ -11572,46 +11583,30 @@ class MatterportImportService {
|
|
|
11572
11583
|
const newLocal = await this.zoneService.create(zoneInput);
|
|
11573
11584
|
return newLocal;
|
|
11574
11585
|
}
|
|
11575
|
-
async import360images() {
|
|
11586
|
+
async import360images(overrideExisting = true) {
|
|
11576
11587
|
console.log('Importing 360 images');
|
|
11577
11588
|
this.importingImages.next(true);
|
|
11578
11589
|
return new Promise(async (resolve) => {
|
|
11579
11590
|
const scans = Object.values(this.sweeps);
|
|
11580
|
-
let maxScan;
|
|
11581
|
-
let indexScan;
|
|
11582
11591
|
const nmbScans = Object.keys(scans).length;
|
|
11583
|
-
console.log('Total number of scan points :', nmbScans);
|
|
11584
11592
|
this.totalSweepsCount.next(nmbScans);
|
|
11585
|
-
|
|
11586
|
-
|
|
11587
|
-
console.log('retaking import from scan', localStorage.getItem('indexScanLoad'));
|
|
11588
|
-
indexScan = +localStorage.getItem('indexScanLoad');
|
|
11589
|
-
nmbScans < indexScan + this.MAX_SCANS_RELOAD
|
|
11590
|
-
? (maxScan = nmbScans)
|
|
11591
|
-
: (maxScan = indexScan + this.MAX_SCANS_RELOAD);
|
|
11592
|
-
}
|
|
11593
|
-
else {
|
|
11594
|
-
indexScan = 0;
|
|
11595
|
-
nmbScans < this.MAX_SCANS_RELOAD
|
|
11596
|
-
? (maxScan = nmbScans)
|
|
11597
|
-
: (maxScan = this.MAX_SCANS_RELOAD);
|
|
11598
|
-
}
|
|
11599
|
-
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) {
|
|
11600
11595
|
if (!this.stop) {
|
|
11601
|
-
await
|
|
11602
|
-
setTimeout(() => {
|
|
11603
|
-
res(null);
|
|
11604
|
-
}, 1000);
|
|
11605
|
-
});
|
|
11606
|
-
await this.sdk.Sweep.moveTo(scans[index].uuid);
|
|
11607
|
-
await this.sdk.Camera.setRotation({
|
|
11608
|
-
x: 0,
|
|
11609
|
-
y: 0,
|
|
11610
|
-
});
|
|
11596
|
+
await this.sdk.Sweep.moveTo(scans[index].uuid, { rotation: { x: 0, y: 0 }, transition: this.sdk.Sweep.Transition.INSTANT, transitionTime: 0 });
|
|
11611
11597
|
const img = await this.sdk.Renderer.takeEquirectangular({ width: 2048, height: 1024 }, { mattertags: false, sweeps: true });
|
|
11612
|
-
|
|
11613
|
-
this.
|
|
11614
|
-
|
|
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
|
+
});
|
|
11615
11610
|
}
|
|
11616
11611
|
else {
|
|
11617
11612
|
console.log('Abandoning import because it was cancelled');
|
|
@@ -11619,22 +11614,17 @@ class MatterportImportService {
|
|
|
11619
11614
|
break;
|
|
11620
11615
|
}
|
|
11621
11616
|
}
|
|
11622
|
-
if (maxScan === nmbScans) {
|
|
11623
|
-
console.log('Import 360 done');
|
|
11624
|
-
this.cleanLocalStorage();
|
|
11625
|
-
this.removeFrame();
|
|
11626
|
-
this.stop = true;
|
|
11627
|
-
resolve(true);
|
|
11628
|
-
}
|
|
11629
|
-
else if (!this.stop) {
|
|
11630
|
-
// to restart the procedure from where we left of
|
|
11631
|
-
localStorage.setItem('indexScanLoad', maxScan.toString());
|
|
11632
|
-
localStorage.setItem('visitInImport', this.modelID);
|
|
11633
|
-
this.removeFrame();
|
|
11634
|
-
window.location.reload();
|
|
11635
|
-
}
|
|
11636
11617
|
});
|
|
11637
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
|
+
}
|
|
11638
11628
|
async moveToFloor(floorName, matterportFloorSequence = null) {
|
|
11639
11629
|
if (!this.floors) {
|
|
11640
11630
|
console.log('Floor are not loaded yet');
|
|
@@ -11721,7 +11711,6 @@ class MatterportImportService {
|
|
|
11721
11711
|
abandon() {
|
|
11722
11712
|
setTimeout(() => {
|
|
11723
11713
|
console.log('abandonning import');
|
|
11724
|
-
localStorage.removeItem('visitInImport');
|
|
11725
11714
|
this.stop = true;
|
|
11726
11715
|
this.removeFrame();
|
|
11727
11716
|
}, 500);
|
|
@@ -11731,10 +11720,6 @@ class MatterportImportService {
|
|
|
11731
11720
|
this.currentFrame.remove();
|
|
11732
11721
|
}
|
|
11733
11722
|
}
|
|
11734
|
-
cleanLocalStorage() {
|
|
11735
|
-
localStorage.removeItem('indexScanLoad');
|
|
11736
|
-
localStorage.removeItem('visitInImport');
|
|
11737
|
-
}
|
|
11738
11723
|
async getLayerByName(name) {
|
|
11739
11724
|
const mission = this.userService.currentMission(this.spaceID);
|
|
11740
11725
|
const currentOrgId = mission.organisationID;
|
|
@@ -12316,5 +12301,5 @@ function floatValidator() {
|
|
|
12316
12301
|
* Generated bundle index. Do not edit.
|
|
12317
12302
|
*/
|
|
12318
12303
|
|
|
12319
|
-
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 };
|
|
12320
12305
|
//# sourceMappingURL=smarterplan-ngx-smarterplan-core.mjs.map
|