@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.
@@ -803,7 +803,7 @@ class CalibrationComponent {
803
803
  this.setupMenuItems();
804
804
  this.chosenPlan = this.planService.getChosenPlan();
805
805
  if (this.chosenPlan) {
806
- this.chosenPlanIsPdf = this.chosenPlan.annexe.includes("pdf");
806
+ this.chosenPlanIsPdf = this.chosenPlan.annexe.includes('pdf');
807
807
  this.launchViewer();
808
808
  setTimeout(() => {
809
809
  this.configureCanvas().then(() => {
@@ -819,11 +819,7 @@ class CalibrationComponent {
819
819
  }, 500);
820
820
  }
821
821
  else {
822
- this.router.navigate([
823
- "/dashboard/localisation",
824
- this.spaceID,
825
- "plans",
826
- ]);
822
+ this.router.navigate(['/dashboard/localisation', this.spaceID, 'plans']);
827
823
  }
828
824
  });
829
825
  }
@@ -832,17 +828,17 @@ class CalibrationComponent {
832
828
  *********************************************************************************************** */
833
829
  setupMenuItems() {
834
830
  this.menuItems = [
835
- { label: "Locations", url: "/localisation" },
831
+ { label: 'Locations', url: '/localisation' },
836
832
  {
837
833
  label: this.currentSpace.name,
838
834
  url: `/localisation/${this.spaceID}`,
839
835
  },
840
836
  {
841
- label: "Plans",
837
+ label: 'Plans',
842
838
  url: `/localisation/${this.currentSpace.id}/plans`,
843
839
  },
844
840
  {
845
- label: "Calibration",
841
+ label: 'Calibration',
846
842
  url: `/localisation/${this.currentSpace.id}/plan-calibration?spaceID=${this.currentSpace.id}`,
847
843
  },
848
844
  ];
@@ -855,7 +851,7 @@ class CalibrationComponent {
855
851
  return __awaiter(this, void 0, void 0, function* () {
856
852
  /** Get canvas */
857
853
  if (!this.canvas) {
858
- const canvas = document.querySelector("#canvas");
854
+ const canvas = document.querySelector('#canvas');
859
855
  this.canvas = canvas;
860
856
  }
861
857
  if (!this.chosenPlanIsPdf) {
@@ -888,7 +884,7 @@ class CalibrationComponent {
888
884
  drawImage(url, x = 0, y = 0, icone = false) {
889
885
  const image = new Image();
890
886
  const size = this.canvasSize;
891
- const context = this.canvas.getContext("2d");
887
+ const context = this.canvas.getContext('2d');
892
888
  /** Flip the context, for symmetry */
893
889
  // if (this.reflectV) {
894
890
  // context.translate(size.w, 0);
@@ -900,7 +896,7 @@ class CalibrationComponent {
900
896
  // }
901
897
  let imageWidth = size.w;
902
898
  let imageHeight = size.h;
903
- image.addEventListener("load", () => {
899
+ image.addEventListener('load', () => {
904
900
  if (icone) {
905
901
  imageWidth = image.width;
906
902
  imageHeight = image.height;
@@ -929,7 +925,8 @@ class CalibrationComponent {
929
925
  const pdfjs = yield import('pdfjs-dist/build/pdf');
930
926
  const pdfjsWorker = yield import('pdfjs-dist/build/pdf.worker.entry');
931
927
  pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
932
- const pdf = yield getDocument(this.chosenPlan.filepath).promise;
928
+ const pdf = yield getDocument(this.chosenPlan.filepath)
929
+ .promise;
933
930
  const page = yield pdf.getPage(1);
934
931
  const viewPortParameters = { scale: 1 };
935
932
  const viewport = page.getViewport(viewPortParameters);
@@ -939,13 +936,13 @@ class CalibrationComponent {
939
936
  console.log(size);
940
937
  this.canvasSize = size;
941
938
  this.canvasZoom = size.w / viewport.width;
942
- const context = this.canvas.getContext("2d");
939
+ const context = this.canvas.getContext('2d');
943
940
  const renderContext = {
944
941
  canvasContext: context,
945
942
  viewport,
946
943
  };
947
944
  const renderTask = page.render(renderContext).promise;
948
- renderTask.then(() => console.log("Page rendered"));
945
+ renderTask.then(() => console.log('Page rendered'));
949
946
  // const res = canvas.toDataURL();
950
947
  // if (pdf != null) pdf.destroy();
951
948
  // return res;
@@ -973,25 +970,28 @@ class CalibrationComponent {
973
970
  // console.log(this.floors);
974
971
  setTimeout(() => __awaiter(this, void 0, void 0, function* () {
975
972
  /** Move Floor mode */
976
- yield sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN);
977
- /** Display the correct floor for the plan */
978
- try {
979
- yield this.matterportImportService.moveToFloor(this.chosenPlan.name);
980
- }
981
- catch (_a) {
982
- console.log("couldnot move to floor");
983
- }
973
+ yield sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN).then((nextMode) => __awaiter(this, void 0, void 0, function* () {
974
+ // Move successful
975
+ console.log(`Arrived at new view mode ${nextMode}`);
976
+ /** Display the correct floor for the plan */
977
+ try {
978
+ yield this.matterportImportService.moveToFloor(this.chosenPlan.name);
979
+ /** When the user try to change the view mode we set it back to floorpan */
980
+ sdk.on(sdk.Mode.Event.CHANGE_END, (oldMode, newMode) => {
981
+ if (newMode !== sdk.Mode.Mode.FLOORPLAN) {
982
+ sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN, {
983
+ transition: 'transition.instant',
984
+ });
985
+ }
986
+ });
987
+ }
988
+ catch (_a) {
989
+ console.log('couldnot move to floor');
990
+ }
991
+ }));
984
992
  /** We can display the matterport view now */
985
993
  this.loading = false;
986
- }), 300);
987
- /** When the user try to change the view mode we set it back to floorpan */
988
- sdk.on(sdk.Mode.Event.CHANGE_END, (oldMode, newMode) => {
989
- if (newMode !== sdk.Mode.Mode.FLOORPLAN) {
990
- sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN, {
991
- transition: "transition.instant",
992
- });
993
- }
994
- });
994
+ }), 1000);
995
995
  /** Update current camera pose and rotation */
996
996
  sdk.Camera.pose.subscribe((event) => {
997
997
  /** We update only if the user is not changing the rotation with the <input> range, to not override the <input> value */
@@ -1064,15 +1064,15 @@ class CalibrationComponent {
1064
1064
  if (deltaXPlan === 0) {
1065
1065
  // console.log("we moved along Y axis on Plan");
1066
1066
  const deltaYPlan = this.secondMarkPlan.y - this.firstMarkPlan.y;
1067
- this.calibrage.nameYAxis = "z";
1068
- this.calibrage.nameXAxis = "x";
1067
+ this.calibrage.nameYAxis = 'z';
1068
+ this.calibrage.nameXAxis = 'x';
1069
1069
  this.calibrage.offsetY = this.secondMarkPlan.y;
1070
1070
  this.calibrage.scaleY = deltaYPlan / deltaZVisit;
1071
1071
  }
1072
1072
  else {
1073
1073
  // console.log(" we moved along X axis on Plan");
1074
- this.calibrage.nameYAxis = "x";
1075
- this.calibrage.nameXAxis = "z";
1074
+ this.calibrage.nameYAxis = 'x';
1075
+ this.calibrage.nameXAxis = 'z';
1076
1076
  this.calibrage.offsetX = this.secondMarkPlan.x;
1077
1077
  this.calibrage.scaleX = deltaXPlan / deltaZVisit;
1078
1078
  }
@@ -1116,21 +1116,13 @@ class CalibrationComponent {
1116
1116
  if (navigations.length > 0) {
1117
1117
  for (const navigation of navigations) {
1118
1118
  const testPosition = JSON.parse(navigation.position);
1119
- const positionX = this.calibrage.nameXAxis === "x"
1120
- ? testPosition.x
1121
- : testPosition.z;
1122
- const positionY = this.calibrage.nameYAxis === "x"
1123
- ? testPosition.x
1124
- : testPosition.z;
1125
- const testX = positionX * this.calibrage.scaleX +
1126
- this.calibrage.offsetX;
1127
- const testY = positionY * this.calibrage.scaleY +
1128
- this.calibrage.offsetY;
1119
+ const positionX = this.calibrage.nameXAxis === 'x' ? testPosition.x : testPosition.z;
1120
+ const positionY = this.calibrage.nameYAxis === 'x' ? testPosition.x : testPosition.z;
1121
+ const testX = positionX * this.calibrage.scaleX + this.calibrage.offsetX;
1122
+ const testY = positionY * this.calibrage.scaleY + this.calibrage.offsetY;
1129
1123
  // console.log("test position GREEN", testX, testY);
1130
- const transformedX = (testX - this.calibrage.offsetXPlan) /
1131
- this.calibrage.scalePlan; // we are undoing the pan and zoom
1132
- const transformedY = (testY - this.calibrage.offsetYPlan) /
1133
- this.calibrage.scalePlan;
1124
+ const transformedX = (testX - this.calibrage.offsetXPlan) / this.calibrage.scalePlan; // we are undoing the pan and zoom
1125
+ const transformedY = (testY - this.calibrage.offsetYPlan) / this.calibrage.scalePlan;
1134
1126
  this.positions.push({
1135
1127
  navID: navigation.id,
1136
1128
  planID: this.chosenPlan.id,
@@ -1139,7 +1131,7 @@ class CalibrationComponent {
1139
1131
  });
1140
1132
  const iconSize = 30 * this.calibrage.scalePlan;
1141
1133
  const shift = iconSize / 2;
1142
- this.drawImage("https://api.iconify.design/mdi:adjust.svg?color=green&height=30&width=30", transformedX - shift, transformedY - shift, true);
1134
+ this.drawImage('https://api.iconify.design/mdi:adjust.svg?color=green&height=30&width=30', transformedX - shift, transformedY - shift, true);
1143
1135
  }
1144
1136
  }
1145
1137
  }
@@ -1188,12 +1180,8 @@ class CalibrationComponent {
1188
1180
  })));
1189
1181
  }
1190
1182
  this.matterportImportService.removeFrame();
1191
- this.router.navigate([
1192
- "/dashboard/localisation",
1193
- this.spaceID,
1194
- "plans",
1195
- ]);
1196
- alert(this.translate.instant("calibration.success"));
1183
+ this.router.navigate(['/dashboard/localisation', this.spaceID, 'plans']);
1184
+ alert(this.translate.instant('calibration.success'));
1197
1185
  });
1198
1186
  }
1199
1187
  /** Reset the canvas */
@@ -1206,12 +1194,8 @@ class CalibrationComponent {
1206
1194
  /** Cancel, leave */
1207
1195
  onCancel() {
1208
1196
  this.matterportImportService.removeFrame();
1209
- this.router.navigate([
1210
- "/dashboard/localisation",
1211
- this.spaceID,
1212
- "plans",
1213
- ]);
1214
- alert(this.translate.instant("calibration.canceled"));
1197
+ this.router.navigate(['/dashboard/localisation', this.spaceID, 'plans']);
1198
+ alert(this.translate.instant('calibration.canceled'));
1215
1199
  }
1216
1200
  onFloorClick(floor) {
1217
1201
  return __awaiter(this, void 0, void 0, function* () {
@@ -1221,9 +1205,9 @@ class CalibrationComponent {
1221
1205
  }
1222
1206
  onActivateZoomChange() {
1223
1207
  this.zoomCanBeChanged = !this.zoomCanBeChanged;
1224
- const iframe = document.querySelector("#viewer-frame");
1208
+ const iframe = document.querySelector('#viewer-frame');
1225
1209
  if (iframe) {
1226
- iframe.style.zIndex = this.zoomCanBeChanged ? "1" : "0";
1210
+ iframe.style.zIndex = this.zoomCanBeChanged ? '1' : '0';
1227
1211
  }
1228
1212
  }
1229
1213
  }
@@ -1234,7 +1218,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImpor
1234
1218
  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"] }]
1235
1219
  }], 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: [{
1236
1220
  type: ViewChild,
1237
- args: ["canvasDiv"]
1221
+ args: ['canvasDiv']
1238
1222
  }] } });
1239
1223
 
1240
1224
  class PlansComponent {