@smarterplan/ngx-smarterplan-locations 0.2.7 → 0.2.8

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.
@@ -775,7 +775,7 @@ class CalibrationComponent {
775
775
  this.setupMenuItems();
776
776
  this.chosenPlan = this.planService.getChosenPlan();
777
777
  if (this.chosenPlan) {
778
- this.chosenPlanIsPdf = this.chosenPlan.annexe.includes("pdf");
778
+ this.chosenPlanIsPdf = this.chosenPlan.annexe.includes('pdf');
779
779
  this.launchViewer();
780
780
  setTimeout(() => {
781
781
  this.configureCanvas().then(() => {
@@ -791,11 +791,7 @@ class CalibrationComponent {
791
791
  }, 500);
792
792
  }
793
793
  else {
794
- this.router.navigate([
795
- "/dashboard/localisation",
796
- this.spaceID,
797
- "plans",
798
- ]);
794
+ this.router.navigate(['/dashboard/localisation', this.spaceID, 'plans']);
799
795
  }
800
796
  }
801
797
  /** **********************************************************************************************
@@ -803,17 +799,17 @@ class CalibrationComponent {
803
799
  *********************************************************************************************** */
804
800
  setupMenuItems() {
805
801
  this.menuItems = [
806
- { label: "Locations", url: "/localisation" },
802
+ { label: 'Locations', url: '/localisation' },
807
803
  {
808
804
  label: this.currentSpace.name,
809
805
  url: `/localisation/${this.spaceID}`,
810
806
  },
811
807
  {
812
- label: "Plans",
808
+ label: 'Plans',
813
809
  url: `/localisation/${this.currentSpace.id}/plans`,
814
810
  },
815
811
  {
816
- label: "Calibration",
812
+ label: 'Calibration',
817
813
  url: `/localisation/${this.currentSpace.id}/plan-calibration?spaceID=${this.currentSpace.id}`,
818
814
  },
819
815
  ];
@@ -825,7 +821,7 @@ class CalibrationComponent {
825
821
  async configureCanvas() {
826
822
  /** Get canvas */
827
823
  if (!this.canvas) {
828
- const canvas = document.querySelector("#canvas");
824
+ const canvas = document.querySelector('#canvas');
829
825
  this.canvas = canvas;
830
826
  }
831
827
  if (!this.chosenPlanIsPdf) {
@@ -857,7 +853,7 @@ class CalibrationComponent {
857
853
  drawImage(url, x = 0, y = 0, icone = false) {
858
854
  const image = new Image();
859
855
  const size = this.canvasSize;
860
- const context = this.canvas.getContext("2d");
856
+ const context = this.canvas.getContext('2d');
861
857
  /** Flip the context, for symmetry */
862
858
  // if (this.reflectV) {
863
859
  // context.translate(size.w, 0);
@@ -869,7 +865,7 @@ class CalibrationComponent {
869
865
  // }
870
866
  let imageWidth = size.w;
871
867
  let imageHeight = size.h;
872
- image.addEventListener("load", () => {
868
+ image.addEventListener('load', () => {
873
869
  if (icone) {
874
870
  imageWidth = image.width;
875
871
  imageHeight = image.height;
@@ -897,7 +893,8 @@ class CalibrationComponent {
897
893
  const pdfjs = await import('pdfjs-dist/build/pdf');
898
894
  const pdfjsWorker = await import('pdfjs-dist/build/pdf.worker.entry');
899
895
  pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
900
- const pdf = await getDocument(this.chosenPlan.filepath).promise;
896
+ const pdf = await getDocument(this.chosenPlan.filepath)
897
+ .promise;
901
898
  const page = await pdf.getPage(1);
902
899
  const viewPortParameters = { scale: 1 };
903
900
  const viewport = page.getViewport(viewPortParameters);
@@ -907,13 +904,13 @@ class CalibrationComponent {
907
904
  console.log(size);
908
905
  this.canvasSize = size;
909
906
  this.canvasZoom = size.w / viewport.width;
910
- const context = this.canvas.getContext("2d");
907
+ const context = this.canvas.getContext('2d');
911
908
  const renderContext = {
912
909
  canvasContext: context,
913
910
  viewport,
914
911
  };
915
912
  const renderTask = page.render(renderContext).promise;
916
- renderTask.then(() => console.log("Page rendered"));
913
+ renderTask.then(() => console.log('Page rendered'));
917
914
  // const res = canvas.toDataURL();
918
915
  // if (pdf != null) pdf.destroy();
919
916
  // return res;
@@ -939,25 +936,28 @@ class CalibrationComponent {
939
936
  // console.log(this.floors);
940
937
  setTimeout(async () => {
941
938
  /** Move Floor mode */
942
- await sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN);
943
- /** Display the correct floor for the plan */
944
- try {
945
- await this.matterportImportService.moveToFloor(this.chosenPlan.name);
946
- }
947
- catch {
948
- console.log("couldnot move to floor");
949
- }
939
+ await sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN).then(async (nextMode) => {
940
+ // Move successful
941
+ console.log(`Arrived at new view mode ${nextMode}`);
942
+ /** Display the correct floor for the plan */
943
+ try {
944
+ await this.matterportImportService.moveToFloor(this.chosenPlan.name);
945
+ /** When the user try to change the view mode we set it back to floorpan */
946
+ sdk.on(sdk.Mode.Event.CHANGE_END, (oldMode, newMode) => {
947
+ if (newMode !== sdk.Mode.Mode.FLOORPLAN) {
948
+ sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN, {
949
+ transition: 'transition.instant',
950
+ });
951
+ }
952
+ });
953
+ }
954
+ catch {
955
+ console.log('couldnot move to floor');
956
+ }
957
+ });
950
958
  /** We can display the matterport view now */
951
959
  this.loading = false;
952
- }, 300);
953
- /** When the user try to change the view mode we set it back to floorpan */
954
- sdk.on(sdk.Mode.Event.CHANGE_END, (oldMode, newMode) => {
955
- if (newMode !== sdk.Mode.Mode.FLOORPLAN) {
956
- sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN, {
957
- transition: "transition.instant",
958
- });
959
- }
960
- });
960
+ }, 1000);
961
961
  /** Update current camera pose and rotation */
962
962
  sdk.Camera.pose.subscribe((event) => {
963
963
  /** We update only if the user is not changing the rotation with the <input> range, to not override the <input> value */
@@ -1022,15 +1022,15 @@ class CalibrationComponent {
1022
1022
  if (deltaXPlan === 0) {
1023
1023
  // console.log("we moved along Y axis on Plan");
1024
1024
  const deltaYPlan = this.secondMarkPlan.y - this.firstMarkPlan.y;
1025
- this.calibrage.nameYAxis = "z";
1026
- this.calibrage.nameXAxis = "x";
1025
+ this.calibrage.nameYAxis = 'z';
1026
+ this.calibrage.nameXAxis = 'x';
1027
1027
  this.calibrage.offsetY = this.secondMarkPlan.y;
1028
1028
  this.calibrage.scaleY = deltaYPlan / deltaZVisit;
1029
1029
  }
1030
1030
  else {
1031
1031
  // console.log(" we moved along X axis on Plan");
1032
- this.calibrage.nameYAxis = "x";
1033
- this.calibrage.nameXAxis = "z";
1032
+ this.calibrage.nameYAxis = 'x';
1033
+ this.calibrage.nameXAxis = 'z';
1034
1034
  this.calibrage.offsetX = this.secondMarkPlan.x;
1035
1035
  this.calibrage.scaleX = deltaXPlan / deltaZVisit;
1036
1036
  }
@@ -1072,21 +1072,13 @@ class CalibrationComponent {
1072
1072
  if (navigations.length > 0) {
1073
1073
  for (const navigation of navigations) {
1074
1074
  const testPosition = JSON.parse(navigation.position);
1075
- const positionX = this.calibrage.nameXAxis === "x"
1076
- ? testPosition.x
1077
- : testPosition.z;
1078
- const positionY = this.calibrage.nameYAxis === "x"
1079
- ? testPosition.x
1080
- : testPosition.z;
1081
- const testX = positionX * this.calibrage.scaleX +
1082
- this.calibrage.offsetX;
1083
- const testY = positionY * this.calibrage.scaleY +
1084
- this.calibrage.offsetY;
1075
+ const positionX = this.calibrage.nameXAxis === 'x' ? testPosition.x : testPosition.z;
1076
+ const positionY = this.calibrage.nameYAxis === 'x' ? testPosition.x : testPosition.z;
1077
+ const testX = positionX * this.calibrage.scaleX + this.calibrage.offsetX;
1078
+ const testY = positionY * this.calibrage.scaleY + this.calibrage.offsetY;
1085
1079
  // console.log("test position GREEN", testX, testY);
1086
- const transformedX = (testX - this.calibrage.offsetXPlan) /
1087
- this.calibrage.scalePlan; // we are undoing the pan and zoom
1088
- const transformedY = (testY - this.calibrage.offsetYPlan) /
1089
- this.calibrage.scalePlan;
1080
+ const transformedX = (testX - this.calibrage.offsetXPlan) / this.calibrage.scalePlan; // we are undoing the pan and zoom
1081
+ const transformedY = (testY - this.calibrage.offsetYPlan) / this.calibrage.scalePlan;
1090
1082
  this.positions.push({
1091
1083
  navID: navigation.id,
1092
1084
  planID: this.chosenPlan.id,
@@ -1095,7 +1087,7 @@ class CalibrationComponent {
1095
1087
  });
1096
1088
  const iconSize = 30 * this.calibrage.scalePlan;
1097
1089
  const shift = iconSize / 2;
1098
- this.drawImage("https://api.iconify.design/mdi:adjust.svg?color=green&height=30&width=30", transformedX - shift, transformedY - shift, true);
1090
+ this.drawImage('https://api.iconify.design/mdi:adjust.svg?color=green&height=30&width=30', transformedX - shift, transformedY - shift, true);
1099
1091
  }
1100
1092
  }
1101
1093
  }
@@ -1142,12 +1134,8 @@ class CalibrationComponent {
1142
1134
  }));
1143
1135
  }
1144
1136
  this.matterportImportService.removeFrame();
1145
- this.router.navigate([
1146
- "/dashboard/localisation",
1147
- this.spaceID,
1148
- "plans",
1149
- ]);
1150
- alert(this.translate.instant("calibration.success"));
1137
+ this.router.navigate(['/dashboard/localisation', this.spaceID, 'plans']);
1138
+ alert(this.translate.instant('calibration.success'));
1151
1139
  }
1152
1140
  /** Reset the canvas */
1153
1141
  onReset() {
@@ -1159,12 +1147,8 @@ class CalibrationComponent {
1159
1147
  /** Cancel, leave */
1160
1148
  onCancel() {
1161
1149
  this.matterportImportService.removeFrame();
1162
- this.router.navigate([
1163
- "/dashboard/localisation",
1164
- this.spaceID,
1165
- "plans",
1166
- ]);
1167
- alert(this.translate.instant("calibration.canceled"));
1150
+ this.router.navigate(['/dashboard/localisation', this.spaceID, 'plans']);
1151
+ alert(this.translate.instant('calibration.canceled'));
1168
1152
  }
1169
1153
  async onFloorClick(floor) {
1170
1154
  this.currentFloor = floor;
@@ -1172,9 +1156,9 @@ class CalibrationComponent {
1172
1156
  }
1173
1157
  onActivateZoomChange() {
1174
1158
  this.zoomCanBeChanged = !this.zoomCanBeChanged;
1175
- const iframe = document.querySelector("#viewer-frame");
1159
+ const iframe = document.querySelector('#viewer-frame');
1176
1160
  if (iframe) {
1177
- iframe.style.zIndex = this.zoomCanBeChanged ? "1" : "0";
1161
+ iframe.style.zIndex = this.zoomCanBeChanged ? '1' : '0';
1178
1162
  }
1179
1163
  }
1180
1164
  }
@@ -1185,7 +1169,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImpor
1185
1169
  args: [{ selector: 'lib-calibration', template: "<div class=\"row mt-3\">\r\n <div class=\"col\">\r\n <div class=\"m-3\">\r\n <lib-tab-navigation [menuItems]='menuItems'></lib-tab-navigation>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n<div id=\"rowCanvas\">\r\n <div #canvasDiv id=\"canvasDiv\">\r\n\r\n <div id=\"viewer-frame\" [style.pointer-events]=\"zoomCanBeChanged?'auto':'none'\">\r\n <!-- <div class=\"blur\"></div> -->\r\n </div>\r\n <canvas id=\"canvas\" [ngStyle]=\"{'opacity': (preview||loading) ? '1' : 'calc(' + opacity + '/ 100)'}\"></canvas>\r\n </div>\r\n\r\n <div class=\"calibration-tools container-fluid\" *ngIf=\"!(preview || loading)\">\r\n <h1>{{'Calibration tool' | translate}}</h1>\r\n <div class=\"tool\">\r\n <div class=\"row ms-0 me-0 legend\">\r\n <div class=\"legend-bar-indicator\" [ngStyle]=\"{'opacity': 'calc(' + (-(opacity-100)+10) + '/ 100)'}\">\r\n {{'Less' | translate}}</div>\r\n <div class=\"legend-title\">{{'Plan Opacity' | translate }}</div>\r\n <div class=\"legend-bar-indicator\" [ngStyle]=\"{'opacity': 'calc(' + (opacity+10) + '/ 100)'}\">{{'More' |\r\n translate}}</div>\r\n </div>\r\n <div class=\"row ms-0 me-0 \">\r\n <input [disabled]=\"false\" [ngModelOptions]=\"{standalone: true}\" [(ngModel)]=\"opacity\" type=\"range\"\r\n class=\"form-range\" min=\"0\" max=\"100\" value=\"50\" id=\"opacity\">\r\n </div>\r\n </div>\r\n <div class=\"tool\">\r\n <div class=\"row ms-0 me-0 \">\r\n <div class=\"label-legend\">{{'Change Visit Floor' | translate}}</div>\r\n <div ngbDropdown class=\"d-inline-block ms-3\">\r\n <button class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\" ngbDropdownToggle>\r\n {{currentFloor ? currentFloor.id : ('Floor' | translate) }}</button>\r\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\r\n <button ngbDropdownItem *ngFor=\"let floor of floors\" (click)=\"onFloorClick(floor)\">\r\n {{ floor.name.length > 0 ? floor.name : ('Floor ' + floor.id) }}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n </div>\r\n <div class=\"tool\">\r\n <div class=\"row ms-0 me-0 \">\r\n <div class=\"tool-checkbox-container\">\r\n <div class=\"tool-checkbox-subcontainer\">\r\n <div class=\"label-legend me-3\">{{'Pan/Zoom Visit' | translate}} {{zoomCanBeChanged ? \"ON\" :\r\n \"OFF\"}}\r\n </div>\r\n <input type=\"checkbox\" (change)=\"onActivateZoomChange()\" style=\"margin-top: 5px;\">\r\n </div>\r\n <div class=\"card border-warning mb-3 mt-3\" *ngIf=\"zoomCanBeChanged\">\r\n <div class=\"card-body text-warning\">\r\n <h5 class=\"card-title\">{{\"calibration.wait-message\" | translate}}</h5>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"action\">\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onPreview()\"\r\n [disabled]=\"zoomCanBeChanged\">{{'Preview' | translate}}</button>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onCancel()\">{{'Cancel' |\r\n translate}}</button>\r\n\r\n </div>\r\n\r\n </div>\r\n <div class=\"calibration-tools container-fluid\" *ngIf=\"preview\">\r\n <h1>{{'Validation' | translate}}</h1>\r\n <div class=\"action\">\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onSave()\">{{'Validate' |\r\n translate}}</button>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onReset()\">{{'Reset' |\r\n translate}}</button>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onCancel()\">{{'Cancel' |\r\n translate}}</button>\r\n\r\n </div>\r\n </div>\r\n\r\n\r\n <div class=\"calibration-tools container-fluid\" *ngIf=\"loading\">\r\n <h3>{{\"Waiting for Matterport\" | translate}}...</h3>\r\n <div class=\"d-flex justify-content-center\">\r\n <div class=\"spinner-border\" role=\"status\">\r\n <span class=\"visually-hidden\">Loading...</span>\r\n </div>\r\n </div>\r\n\r\n </div>\r\n</div>", styles: [".button-visit{display:none;height:30px;width:30px;position:absolute;background:url(https://api.iconify.design/mdi:map-marker-check.svg?color=red&height=30) no-repeat scroll 0 0 transparent;border:none}#button-visit-left{left:350px;top:550px}#button-visit-right{left:500px;top:600px}#rowCanvas{display:flex}#canvasDiv{height:100%;width:100%;position:relative}#canvas{width:100%;height:100%;opacity:.5}#viewer-frame{top:0;position:absolute;width:100%;height:100%}.calibration-tools{margin-left:20px;width:400px;background-color:#fff;z-index:11;border:1px solid var(--smarterplan-primary);padding:7px}.form-range{width:100%}.tool{margin-top:20px}.tool .legend{justify-content:space-between;position:relative;margin-bottom:5px}.tool .legend-title{font-size:1.2rem;color:var(--smarterplan-primary);margin:auto;width:100%;font-weight:700;display:flex;justify-content:center}.tool .legend-bar-indicator{width:15%!important}.tool .label-legend{color:var(--smarterplan-primary);font-size:1.1rem;max-width:55%}.tool .tool-checkbox-container{display:flex;flex-direction:column}.tool .tool-checkbox-container .tool-checkbox-subcontainer{display:flex}.blur{width:150px;height:52px;position:absolute;background-color:#1e2023;bottom:0}.symmetry{padding:5px;border:solid 2px;border-radius:10px;color:var(--smarterplan-primary);margin:25px 10px;cursor:pointer}.symmetry:hover{color:var(--smarterplan-primary)}.symmetry-row{justify-content:center}.action{margin-top:30px;display:flex;justify-content:space-evenly}h1{color:var(--smarterplan-primary);text-align:center;margin-bottom:20px}h3{color:var(--smarterplan-primary);text-align:center;margin-bottom:10px}.btn-outline-primary.disabled{background-color:var(--smarterplan-orange)!important}\n"] }]
1186
1170
  }], ctorParameters: function () { return [{ type: i2.MatterportImportService }, { type: i2.PlanService }, { type: i1.ActivatedRoute }, { type: i1.Router }, { type: i2.ZoneService }, { type: i2.SpaceService }, { type: i2.NavigationService }, { type: i3.TranslateService }]; }, propDecorators: { canvasDiv: [{
1187
1171
  type: ViewChild,
1188
- args: ["canvasDiv"]
1172
+ args: ['canvasDiv']
1189
1173
  }] } });
1190
1174
 
1191
1175
  class PlansComponent {