@smarterplan/ngx-smarterplan-locations 0.0.21

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.
Files changed (50) hide show
  1. package/README.md +24 -0
  2. package/esm2020/lib/components/carousel/carousel.component.mjs +28 -0
  3. package/esm2020/lib/components/chevron/chevron.component.mjs +18 -0
  4. package/esm2020/lib/components/detail-location/detail-location.component.mjs +154 -0
  5. package/esm2020/lib/components/form-location/form-location.component.mjs +215 -0
  6. package/esm2020/lib/components/images/images.component.mjs +91 -0
  7. package/esm2020/lib/components/locations/locations.component.mjs +138 -0
  8. package/esm2020/lib/components/locations/map/map-popup/map-popup.component.mjs +66 -0
  9. package/esm2020/lib/components/locations/map/map.component.mjs +91 -0
  10. package/esm2020/lib/components/plans/calibration/calibration.component.mjs +484 -0
  11. package/esm2020/lib/components/plans/edit-plan/edit-plan.component.mjs +314 -0
  12. package/esm2020/lib/components/plans/plans.component.mjs +211 -0
  13. package/esm2020/lib/components/tab-navigation/tab-navigation.component.mjs +40 -0
  14. package/esm2020/lib/components/visits/visits.component.mjs +227 -0
  15. package/esm2020/lib/components/zones/add-zone/add-zone.component.mjs +592 -0
  16. package/esm2020/lib/components/zones/add-zone/selection/selection.component.mjs +77 -0
  17. package/esm2020/lib/components/zones/zones.component.mjs +214 -0
  18. package/esm2020/lib/helper.service.mjs +2 -0
  19. package/esm2020/lib/ngx-smarterplan-location-routing.module.mjs +49 -0
  20. package/esm2020/lib/ngx-smarterplan-locations.module.mjs +107 -0
  21. package/esm2020/lib/ngx-smarterplan-locations.service.mjs +14 -0
  22. package/esm2020/public-api.mjs +6 -0
  23. package/esm2020/smarterplan-ngx-smarterplan-locations.mjs +5 -0
  24. package/fesm2015/smarterplan-ngx-smarterplan-locations.mjs +3126 -0
  25. package/fesm2015/smarterplan-ngx-smarterplan-locations.mjs.map +1 -0
  26. package/fesm2020/smarterplan-ngx-smarterplan-locations.mjs +2987 -0
  27. package/fesm2020/smarterplan-ngx-smarterplan-locations.mjs.map +1 -0
  28. package/lib/components/carousel/carousel.component.d.ts +12 -0
  29. package/lib/components/chevron/chevron.component.d.ts +9 -0
  30. package/lib/components/detail-location/detail-location.component.d.ts +51 -0
  31. package/lib/components/form-location/form-location.component.d.ts +40 -0
  32. package/lib/components/images/images.component.d.ts +28 -0
  33. package/lib/components/locations/locations.component.d.ts +49 -0
  34. package/lib/components/locations/map/map-popup/map-popup.component.d.ts +22 -0
  35. package/lib/components/locations/map/map.component.d.ts +22 -0
  36. package/lib/components/plans/calibration/calibration.component.d.ts +140 -0
  37. package/lib/components/plans/edit-plan/edit-plan.component.d.ts +54 -0
  38. package/lib/components/plans/plans.component.d.ts +59 -0
  39. package/lib/components/tab-navigation/tab-navigation.component.d.ts +13 -0
  40. package/lib/components/visits/visits.component.d.ts +51 -0
  41. package/lib/components/zones/add-zone/add-zone.component.d.ts +154 -0
  42. package/lib/components/zones/add-zone/selection/selection.component.d.ts +44 -0
  43. package/lib/components/zones/zones.component.d.ts +66 -0
  44. package/lib/helper.service.d.ts +6 -0
  45. package/lib/ngx-smarterplan-location-routing.module.d.ts +7 -0
  46. package/lib/ngx-smarterplan-locations.module.d.ts +31 -0
  47. package/lib/ngx-smarterplan-locations.service.d.ts +6 -0
  48. package/package.json +39 -0
  49. package/public-api.d.ts +2 -0
  50. package/smarterplan-ngx-smarterplan-locations.d.ts +5 -0
@@ -0,0 +1,3126 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, EventEmitter, Component, Output, Input, ViewChild, HostListener, NgModule } from '@angular/core';
3
+ import { __awaiter } from 'tslib';
4
+ import * as i2 from 'ngx-smarterplan-core';
5
+ import { enumToArray, LevelStatus, uploadFileToS3, deleteFromS3, PropertyType, getSignedImageUrlForSpace, SearchObjectType, SpaceStatus, getMetaForImage, getSignedFile, downloadFileAsObject, downloadBlob, CaptureViewer, showScanPointsOnPlanInDiv, getCoefficientsForImage, wait, InventoryStatus, sortAlphabeticallyOnName, NgxSmarterplanCoreModule } from 'ngx-smarterplan-core';
6
+ import * as i1 from '@angular/router';
7
+ import { RouterModule } from '@angular/router';
8
+ import * as i5 from '@angular/common';
9
+ import { CommonModule } from '@angular/common';
10
+ import * as i3 from '@ngx-translate/core';
11
+ import { TranslateModule } from '@ngx-translate/core';
12
+ import { icon, Marker, tileLayer, latLng, marker, latLngBounds, point } from 'leaflet';
13
+ import * as i1$1 from '@asymmetrik/ngx-leaflet';
14
+ import { LeafletModule } from '@asymmetrik/ngx-leaflet';
15
+ import * as i1$2 from '@angular/forms';
16
+ import { Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
17
+ import * as i7 from '@ng-bootstrap/ng-bootstrap';
18
+ import { ModalDismissReasons, NgbModule } from '@ng-bootstrap/ng-bootstrap';
19
+ import * as i7$1 from 'ngx-clipboard';
20
+ import { ClipboardModule } from 'ngx-clipboard';
21
+ import { getDocument } from 'pdfjs-dist';
22
+ import panzoom from 'panzoom';
23
+ import { PdfViewerModule } from 'ng2-pdf-viewer';
24
+
25
+ class NgxSmarterplanLocationsService {
26
+ constructor() { }
27
+ }
28
+ NgxSmarterplanLocationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
29
+ NgxSmarterplanLocationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsService, providedIn: 'root' });
30
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsService, decorators: [{
31
+ type: Injectable,
32
+ args: [{
33
+ providedIn: 'root'
34
+ }]
35
+ }], ctorParameters: function () { return []; } });
36
+
37
+ class TabNavigationComponent {
38
+ constructor(router) {
39
+ this.router = router;
40
+ this.onGoBack = new EventEmitter();
41
+ this.menuItems = [];
42
+ }
43
+ onClick(url, parameter, index) {
44
+ if (index === this.menuItems.length - 1) {
45
+ return;
46
+ }
47
+ if (url) {
48
+ const newURL = `/dashboard${url}`;
49
+ if (this.router.url !== newURL) {
50
+ this.router.navigate([newURL]);
51
+ }
52
+ else {
53
+ this.onGoBack.emit(parameter);
54
+ }
55
+ }
56
+ else {
57
+ this.onGoBack.emit(parameter);
58
+ }
59
+ }
60
+ }
61
+ TabNavigationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: TabNavigationComponent, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Component });
62
+ TabNavigationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: TabNavigationComponent, selector: "lib-tab-navigation", inputs: { menuItems: "menuItems" }, outputs: { onGoBack: "onGoBack" }, ngImport: i0, template: "<span class=\"menu\">\n <span *ngFor=\"let item of menuItems; let index = index;\">\n <span class=\"item\" [ngClass]=\"{'current':index === menuItems.length - 1}\"\n (click)=\"onClick(item.url,item.back, index)\">{{item.label | translate}}</span> <span\n *ngIf=\"index !== menuItems.length - 1\" class=\"separator\">></span>\n </span>\n</span>\n", styles: [".item{font-size:1.35em;color:var(--smarterplan-primary);cursor:pointer}.current{color:var(--smarterplan-primary)!important;cursor:default!important;text-decoration:none!important}.separator{font-size:1.4em;margin-left:10px;margin-right:10px;color:var(--smarterplan-primary)}.item:hover{text-decoration:underline}.menu{margin-top:15px;margin-bottom:20px}\n"], directives: [{ type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "translate": i3.TranslatePipe } });
63
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: TabNavigationComponent, decorators: [{
64
+ type: Component,
65
+ args: [{ selector: 'lib-tab-navigation', template: "<span class=\"menu\">\n <span *ngFor=\"let item of menuItems; let index = index;\">\n <span class=\"item\" [ngClass]=\"{'current':index === menuItems.length - 1}\"\n (click)=\"onClick(item.url,item.back, index)\">{{item.label | translate}}</span> <span\n *ngIf=\"index !== menuItems.length - 1\" class=\"separator\">></span>\n </span>\n</span>\n", styles: [".item{font-size:1.35em;color:var(--smarterplan-primary);cursor:pointer}.current{color:var(--smarterplan-primary)!important;cursor:default!important;text-decoration:none!important}.separator{font-size:1.4em;margin-left:10px;margin-right:10px;color:var(--smarterplan-primary)}.item:hover{text-decoration:underline}.menu{margin-top:15px;margin-bottom:20px}\n"] }]
66
+ }], ctorParameters: function () { return [{ type: i1.Router }]; }, propDecorators: { onGoBack: [{
67
+ type: Output
68
+ }], menuItems: [{
69
+ type: Input
70
+ }] } });
71
+
72
+ class MapPopupComponent {
73
+ constructor(router, ngZone) {
74
+ this.router = router;
75
+ this.ngZone = ngZone;
76
+ this.isOnPopup = false;
77
+ this.isMuseumUser = true;
78
+ }
79
+ ngOnInit() {
80
+ this.marker.on("click", () => this.onClickVisitFirst());
81
+ this.marker.on("mouseover", () => {
82
+ this.isOnPopup = true;
83
+ if (!this.marker.isPopupOpen()) {
84
+ this.openPopup();
85
+ }
86
+ });
87
+ }
88
+ openPopup() {
89
+ this.marker.openPopup();
90
+ this.isOnPopup = false;
91
+ this.popuparea = document.querySelector(".leaflet-popup");
92
+ this.popuparea.addEventListener("mouseleave", () => {
93
+ this.closePopup();
94
+ });
95
+ this.popuparea.addEventListener("mouseover", () => {
96
+ this.isOnPopup = true;
97
+ });
98
+ this.marker.on("mouseout", () => {
99
+ this.closePopup();
100
+ });
101
+ }
102
+ closePopup() {
103
+ this.isOnPopup = false;
104
+ /** We want to wait to avoid glitch */
105
+ setTimeout(() => {
106
+ if (!this.isOnPopup) {
107
+ this.marker.closePopup();
108
+ }
109
+ }, 100);
110
+ }
111
+ onClickVisitFirst() {
112
+ if (this.space.visits.length === 0) {
113
+ console.log("No space to visit !");
114
+ }
115
+ else {
116
+ this.onVisitClick(this.space.visits[0]);
117
+ }
118
+ }
119
+ onVisitClick(visit) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ this.ngZone.run(() => {
122
+ this.router.navigate(["visit", this.space.id], {
123
+ queryParams: { model3D: visit.model3d },
124
+ });
125
+ });
126
+ });
127
+ }
128
+ }
129
+ MapPopupComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: MapPopupComponent, deps: [{ token: i1.Router }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
130
+ MapPopupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: MapPopupComponent, selector: "lib-map-popup", ngImport: i0, template: "<div id=\"map-popup\">\n <div class=\"map-popup-header\" (click)=\"onClickVisitFirst()\" [style.cursor]=\"'pointer'\">\n <img [src]=\"space.annexes\" />\n </div>\n <div class=\"map-popup-details\">\n <h1 (click)=\"onClickVisitFirst()\" [style.cursor]=\"'pointer'\">{{space.name}}</h1>\n <span class=\"map-popup-address\">{{space.addresses}}</span>\n <span *ngFor=\"let visit of space.visits\" class=\"map-popup-visit\" (click)=\"onVisitClick(visit)\"\n [style.cursor]=\"'pointer'\">\u27A4 {{ visit.name ? visit.name : space.name}}</span>\n </div>\n</div>\n", styles: [".map-popup-header{height:120px;overflow:hidden;border-top-right-radius:20px;border-top-left-radius:20px}.map-popup-header img{width:100%;position:relative;top:50%;transform:translateY(-50%)}.map-popup-details{padding:5px 10px 10px;border-bottom-left-radius:20px;border-bottom-right-radius:20px;background-color:#fff;color:#000}.map-popup-details{display:flex;flex-direction:column}.map-popup-details h1{font-size:1.5rem;font-weight:700;margin-bottom:0;color:var(--smarterplan-primary)}.map-popup-address{align-self:flex-end;margin-bottom:10px}.map-popup-visit{color:var(--smarterplan-primary);font-size:1.15rem}.map-popup-visit:hover{color:var(--smarterplan-primary)}\n"], directives: [{ type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
131
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: MapPopupComponent, decorators: [{
132
+ type: Component,
133
+ args: [{ selector: 'lib-map-popup', template: "<div id=\"map-popup\">\n <div class=\"map-popup-header\" (click)=\"onClickVisitFirst()\" [style.cursor]=\"'pointer'\">\n <img [src]=\"space.annexes\" />\n </div>\n <div class=\"map-popup-details\">\n <h1 (click)=\"onClickVisitFirst()\" [style.cursor]=\"'pointer'\">{{space.name}}</h1>\n <span class=\"map-popup-address\">{{space.addresses}}</span>\n <span *ngFor=\"let visit of space.visits\" class=\"map-popup-visit\" (click)=\"onVisitClick(visit)\"\n [style.cursor]=\"'pointer'\">\u27A4 {{ visit.name ? visit.name : space.name}}</span>\n </div>\n</div>\n", styles: [".map-popup-header{height:120px;overflow:hidden;border-top-right-radius:20px;border-top-left-radius:20px}.map-popup-header img{width:100%;position:relative;top:50%;transform:translateY(-50%)}.map-popup-details{padding:5px 10px 10px;border-bottom-left-radius:20px;border-bottom-right-radius:20px;background-color:#fff;color:#000}.map-popup-details{display:flex;flex-direction:column}.map-popup-details h1{font-size:1.5rem;font-weight:700;margin-bottom:0;color:var(--smarterplan-primary)}.map-popup-address{align-self:flex-end;margin-bottom:10px}.map-popup-visit{color:var(--smarterplan-primary);font-size:1.15rem}.map-popup-visit:hover{color:var(--smarterplan-primary)}\n"] }]
134
+ }], ctorParameters: function () { return [{ type: i1.Router }, { type: i0.NgZone }]; } });
135
+
136
+ const iconRetinaUrl = "assets/marker-icon-2x.png";
137
+ const iconUrl = "assets/marker-icon.png";
138
+ const shadowUrl = "assets/marker-shadow.png";
139
+ const iconDefault = icon({
140
+ iconRetinaUrl,
141
+ iconUrl,
142
+ shadowUrl,
143
+ iconSize: [25, 41],
144
+ iconAnchor: [12, 41],
145
+ popupAnchor: [1, -34],
146
+ tooltipAnchor: [16, -28],
147
+ shadowSize: [41, 41],
148
+ });
149
+ Marker.prototype.options.icon = iconDefault;
150
+ class MapComponent {
151
+ constructor(componentFactoryResolver, injector) {
152
+ this.componentFactoryResolver = componentFactoryResolver;
153
+ this.injector = injector;
154
+ this.options = {
155
+ layers: [
156
+ tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
157
+ maxZoom: 18,
158
+ attribution: "...",
159
+ }),
160
+ ],
161
+ zoom: 5.5,
162
+ center: latLng(47.06394, 2.77736),
163
+ };
164
+ this.layers = [];
165
+ }
166
+ ngOnChanges(changes) {
167
+ if (changes.spaces) {
168
+ const nm = [];
169
+ const bd = [];
170
+ if (!changes.spaces.currentValue) {
171
+ return;
172
+ }
173
+ // Filtering out spaces without lat/longitudes
174
+ for (const s of changes.spaces.currentValue) {
175
+ if (s.latitude === null || s.longitude === null) {
176
+ console.log(`${s.name} has not coordinates for ${s.addresses}`);
177
+ continue;
178
+ }
179
+ // We use the popup system from leaflet, as it packs a few improvements
180
+ // on using bootstrap: autoclose other popups, closing option.
181
+ const m = marker([s.latitude, s.longitude]);
182
+ m.bindPopup(this.createPopupComponent(s, m));
183
+ nm.push(m);
184
+ bd.push(latLng(s.latitude, s.longitude));
185
+ }
186
+ // Note how we set the layers in one assignment, in order to have leaflet
187
+ // detects the change correctly
188
+ // We also set the bounds afterward, for the map to be properly zoomed and
189
+ // centered
190
+ this.layers = nm;
191
+ if (this.map && bd.length > 0) {
192
+ this.map.fitBounds(latLngBounds(bd), {
193
+ padding: point(48, 48),
194
+ maxZoom: 12,
195
+ animate: true,
196
+ });
197
+ }
198
+ }
199
+ }
200
+ onMapReady(map) {
201
+ this.map = map;
202
+ }
203
+ createPopupComponent(space, marker) {
204
+ const comp = this.componentFactoryResolver
205
+ .resolveComponentFactory(MapPopupComponent)
206
+ .create(this.injector);
207
+ comp.instance.space = space;
208
+ comp.instance.marker = marker;
209
+ comp.changeDetectorRef.detectChanges();
210
+ return comp.location.nativeElement;
211
+ }
212
+ }
213
+ MapComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: MapComponent, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });
214
+ MapComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: MapComponent, selector: "lib-map", inputs: { spaces: "spaces" }, usesOnChanges: true, ngImport: i0, template: "<div [leafletLayers]=\"layers\" [leafletOptions]=\"options\" (leafletMapReady)=\"onMapReady($event)\" id=\"map\" leaflet\n style=\"height: 500px; margin-top: 30px; z-index: 195\"></div>\n", styles: [""], directives: [{ type: i1$1.LeafletDirective, selector: "[leaflet]", inputs: ["leafletFitBoundsOptions", "leafletPanOptions", "leafletZoomOptions", "leafletZoomPanOptions", "leafletOptions", "leafletZoom", "leafletCenter", "leafletFitBounds", "leafletMaxBounds", "leafletMinZoom", "leafletMaxZoom"], outputs: ["leafletMapReady", "leafletZoomChange", "leafletCenterChange", "leafletClick", "leafletDoubleClick", "leafletMouseDown", "leafletMouseUp", "leafletMouseMove", "leafletMouseOver", "leafletMouseOut", "leafletMapMove", "leafletMapMoveStart", "leafletMapMoveEnd", "leafletMapZoom", "leafletMapZoomStart", "leafletMapZoomEnd"] }, { type: i1$1.LeafletLayersDirective, selector: "[leafletLayers]", inputs: ["leafletLayers"] }] });
215
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: MapComponent, decorators: [{
216
+ type: Component,
217
+ args: [{ selector: 'lib-map', template: "<div [leafletLayers]=\"layers\" [leafletOptions]=\"options\" (leafletMapReady)=\"onMapReady($event)\" id=\"map\" leaflet\n style=\"height: 500px; margin-top: 30px; z-index: 195\"></div>\n", styles: [""] }]
218
+ }], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }, { type: i0.Injector }]; }, propDecorators: { spaces: [{
219
+ type: Input
220
+ }] } });
221
+
222
+ class FormLocationComponent {
223
+ constructor(spaceService, propertyService, userService, fb, missionService, layerService) {
224
+ this.spaceService = spaceService;
225
+ this.propertyService = propertyService;
226
+ this.userService = userService;
227
+ this.fb = fb;
228
+ this.missionService = missionService;
229
+ this.layerService = layerService;
230
+ this.isSubmitted = false;
231
+ this.addMissionForNewSpace = true;
232
+ this.imageToBeDeleted = false;
233
+ this.onChange = new EventEmitter();
234
+ this.levels = enumToArray(LevelStatus);
235
+ }
236
+ ngOnInit() {
237
+ if (this.location) {
238
+ this.initEditForm();
239
+ }
240
+ else {
241
+ this.initForm();
242
+ }
243
+ this.handleInputImageText();
244
+ }
245
+ initForm() {
246
+ this.form = this.fb.group({
247
+ name: [null, [Validators.required]],
248
+ addresses: [""],
249
+ latitude: [null],
250
+ longitude: [null],
251
+ level: LevelStatus.LOW,
252
+ classGes: [null],
253
+ classEnergyConsumption: [null],
254
+ constructionYear: [null],
255
+ });
256
+ }
257
+ initEditForm() {
258
+ this.form = this.fb.group({
259
+ id: this.location.id,
260
+ name: [this.location.name, [Validators.required]],
261
+ addresses: this.location.addresses,
262
+ latitude: this.location.latitude,
263
+ longitude: this.location.longitude,
264
+ level: this.location.level,
265
+ classGes: this.location.classGes,
266
+ classEnergyConsumption: this.location.classEnergyConsumption,
267
+ constructionYear: this.location.constructionYear,
268
+ });
269
+ }
270
+ handleImageInput(target) {
271
+ this.imageToUpload = target.files[0];
272
+ if (this.imageToUpload) {
273
+ this.imageInputContainer.nativeElement.style.display = "none";
274
+ const reader = new FileReader();
275
+ reader.addEventListener("load", () => {
276
+ this.currentImage = reader.result;
277
+ });
278
+ reader.readAsDataURL(this.imageToUpload);
279
+ }
280
+ }
281
+ uploadImage(spaceID) {
282
+ return __awaiter(this, void 0, void 0, function* () {
283
+ if (this.imageToUpload) {
284
+ uploadFileToS3("locations/", this.imageToUpload, spaceID).then((url) => __awaiter(this, void 0, void 0, function* () {
285
+ if (url) {
286
+ yield this.spaceService.updateSpace({
287
+ id: spaceID,
288
+ annexes: url,
289
+ });
290
+ }
291
+ }));
292
+ }
293
+ else if (this.imageToBeDeleted) {
294
+ yield this.spaceService.updateSpace({
295
+ id: spaceID,
296
+ annexes: null,
297
+ });
298
+ yield deleteFromS3(this.location.annexes);
299
+ }
300
+ });
301
+ }
302
+ clearImageFile() {
303
+ this.imageToUpload = null;
304
+ this.currentImage = null;
305
+ this.imageInputContainer.nativeElement.style.display = "flex";
306
+ this.imageInput.nativeElement.value = "";
307
+ this.imageInputText = "Add picture";
308
+ }
309
+ getLayerByName(name) {
310
+ return __awaiter(this, void 0, void 0, function* () {
311
+ const currentOrgId = this.userService.currentOrganisation().id;
312
+ const layers = yield this.layerService.getLayerByNameForOrganisation(name, currentOrgId);
313
+ if (layers) {
314
+ return layers[0];
315
+ }
316
+ // create then
317
+ return this.layerService.createLayerForOrganisation(name, currentOrgId);
318
+ });
319
+ }
320
+ onSubmit() {
321
+ return __awaiter(this, void 0, void 0, function* () {
322
+ this.isSubmitted = true;
323
+ if (!this.form.valid) {
324
+ return;
325
+ }
326
+ try {
327
+ let space;
328
+ if (this.location) {
329
+ this.changeCommaToDot();
330
+ space = yield this.spaceService.updateSpace(this.form.value);
331
+ if (space) {
332
+ yield this.uploadImage(space.id);
333
+ this.location = space;
334
+ this.onChange.emit(space);
335
+ }
336
+ }
337
+ else {
338
+ this.changeCommaToDot();
339
+ let layer = yield this.getLayerByName("BUILDING");
340
+ if (!layer) {
341
+ layer = yield this.layerService.createLayerForOrganisation("BUILDING", this.userService.currentOrganisation().id);
342
+ }
343
+ space = yield this.spaceService.createSpace(this.form.value, layer);
344
+ const missions = this.userService.getManagerMissions();
345
+ if (space && missions.length > 0) {
346
+ const exampleMission = missions[0];
347
+ yield this.uploadImage(space.id);
348
+ yield this.propertyService.createProperty({
349
+ type: PropertyType.PROPERTY,
350
+ spaceID: space.id,
351
+ organisationID: exampleMission.organisationID,
352
+ });
353
+ // add directly a mission for this space
354
+ if (this.addMissionForNewSpace) {
355
+ yield this.missionService.create({
356
+ spaceID: space.id,
357
+ userID: exampleMission.userID,
358
+ role: exampleMission.role,
359
+ level: exampleMission.level,
360
+ organisationID: exampleMission.organisationID,
361
+ orderedOrganisationID: exampleMission.organisationID,
362
+ });
363
+ }
364
+ this.onChange.emit(space);
365
+ }
366
+ else {
367
+ this.onChange.emit(null);
368
+ }
369
+ }
370
+ }
371
+ catch (error) {
372
+ console.error(error);
373
+ this.onChange.emit(null);
374
+ }
375
+ });
376
+ }
377
+ onCancel() {
378
+ this.form.reset();
379
+ this.onChange.emit(null);
380
+ }
381
+ get name() {
382
+ return this.form.get("name");
383
+ }
384
+ changeCommaToDot() {
385
+ const updatedSpace = this.form.value;
386
+ if (updatedSpace.latitude &&
387
+ updatedSpace.latitude.toString().includes(",")) {
388
+ updatedSpace.latitude = updatedSpace.latitude
389
+ .toString()
390
+ .replace(",", ".");
391
+ Number.parseFloat(updatedSpace.latitude);
392
+ }
393
+ if (updatedSpace.longitude &&
394
+ updatedSpace.longitude.toString().includes(",")) {
395
+ updatedSpace.longitude = updatedSpace.longitude
396
+ .toString()
397
+ .replace(",", ".");
398
+ Number.parseFloat(updatedSpace.longitude);
399
+ }
400
+ }
401
+ handleInputImageText() {
402
+ if (this.location && this.location.annexes) {
403
+ this.imageInputText = "Change picture";
404
+ getSignedImageUrlForSpace(this.location).then((url) => {
405
+ if (url) {
406
+ this.currentImage = url;
407
+ }
408
+ });
409
+ }
410
+ else {
411
+ this.imageInputText = "Add picture";
412
+ }
413
+ }
414
+ }
415
+ FormLocationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: FormLocationComponent, deps: [{ token: i2.SpaceService }, { token: i2.PropertyService }, { token: i2.BaseUserService }, { token: i1$2.FormBuilder }, { token: i2.MissionService }, { token: i2.LayerService }], target: i0.ɵɵFactoryTarget.Component });
416
+ FormLocationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: FormLocationComponent, selector: "lib-form-location", inputs: { location: "location" }, outputs: { onChange: "onChange" }, viewQueries: [{ propertyName: "imageInputContainer", first: true, predicate: ["imageInputContainer"], descendants: true }, { propertyName: "imageInput", first: true, predicate: ["imageInput"], descendants: true }, { propertyName: "imageBasePreview", first: true, predicate: ["imageBasePreview"], descendants: true }], ngImport: i0, template: "<div class=\"col-md-6 form-new-loc\" *ngIf=\"form\">\n <form (ngSubmit)=\"onSubmit()\" [formGroup]=\"form\">\n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Name' | translate}} *</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" [class.is-invalid]=\"name.invalid && isSubmitted\" required\n formControlName=\"name\">\n <div class=\"invalid-feedback\">\n {{'Name is mandatory' | translate}}\n </div>\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Address' | translate}}</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"addresses\">\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Construction year' | translate}}</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"constructionYear\">\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Latitude' | translate}}</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"latitude\">\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Longitude' | translate}}</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"longitude\">\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Access level' | translate}}</label>\n <div class=\"col-sm-9\">\n <select class=\"d-inline-block custom-select rounded-pill\" formControlName=\"level\">\n <option *ngFor=\"let level of levels\" [value]=\"level\">{{level | translate}}</option>\n </select>\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Energy Class' | translate}}</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"classEnergyConsumption\">\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Greenhouse gas emission Class' | translate}}</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"classGes\">\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Cover picture' | translate}}</label>\n <div class=\"col-sm-9\">\n <img #imageBasePreview *ngIf=\"currentImage\" class=\"image-preview\" [src]=\"currentImage\">\n <label #imageInputContainer for=\"image\"\n class=\"btn btn-label-file btn-outline-primary rounded-pill imageInputContainer\">\n <input #imageInput type=\"file\" id=\"image\" (change)=\"handleImageInput($event.target)\" />\n {{ imageInputText | translate}}</label>\n <button *ngIf=\"currentImage && !imageToUpload\" \n class=\"btn btn-outline-primary rounded-pill\" (click)=\"imageToBeDeleted=true;clearImageFile()\">{{'Delete picture' | translate }}</button>\n <div class=\"image-name\" *ngIf=\"imageToUpload\">\n <p >{{ imageToUpload.name}}</p>\n <div (click)=\"clearImageFile()\" [style.cursor]=\"'pointer'\">\n <span class=\"iconify\" data-icon=\"mdi:trash-can-outline\"></span>\n </div>\n </div>\n \n </div>\n </div>\n <div class=\"mb-3 row\" *ngIf=\"!location\">\n <label class=\"col-sm-3 col-form-label\">{{'Create mission for this space' | translate}}</label>\n <div class=\"col-sm-3\">\n <input type=\"checkbox\" [(ngModel)]=\"addMissionForNewSpace\" [ngModelOptions]=\"{standalone: true}\">\n </div>\n </div>\n \n <button type=\"submit\" class=\"btn btn-outline-primary rounded-pill me-3\">{{'Save' | translate}}</button>\n <button type=\"button\" (click)=\"onCancel()\" class=\"btn btn-outline-primary rounded-pill\">{{'Cancel' |\n translate}}</button>\n </form>\n</div>\n", styles: ["input[type=file]{display:none}.custom-select{border-color:var(--smarterplan-primary);width:auto}.form-new-loc{background-color:#d3d3d3;padding-top:10px;padding-bottom:10px;margin-bottom:15px}.btn-outline-primary{background-color:#fff}h4{color:var(--smarterplan-primary)}.image-preview{object-fit:cover;max-height:400px;max-width:400px;display:flex;margin-bottom:15px}.imageInputContainer{width:-moz-fit-content;width:fit-content;height:-moz-fit-content;height:fit-content}.image-name{display:flex}.col-form-label{margin-bottom:1rem;width:230px}.form-new-loc{background-color:#d3d3d3;margin-bottom:15px;padding:10px;width:80%;border-radius:10px}.col-sm-9 select{width:100%;height:31.25px;padding-left:10px}.btn-outline-primary{width:200px;margin-bottom:1rem;margin-right:1rem}\n"], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1$2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1$2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i1$2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1$2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i1$2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1$2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i1$2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i1$2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { type: i1$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], pipes: { "translate": i3.TranslatePipe } });
417
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: FormLocationComponent, decorators: [{
418
+ type: Component,
419
+ args: [{ selector: 'lib-form-location', template: "<div class=\"col-md-6 form-new-loc\" *ngIf=\"form\">\n <form (ngSubmit)=\"onSubmit()\" [formGroup]=\"form\">\n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Name' | translate}} *</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" [class.is-invalid]=\"name.invalid && isSubmitted\" required\n formControlName=\"name\">\n <div class=\"invalid-feedback\">\n {{'Name is mandatory' | translate}}\n </div>\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Address' | translate}}</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"addresses\">\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Construction year' | translate}}</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"constructionYear\">\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Latitude' | translate}}</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"latitude\">\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Longitude' | translate}}</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"longitude\">\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Access level' | translate}}</label>\n <div class=\"col-sm-9\">\n <select class=\"d-inline-block custom-select rounded-pill\" formControlName=\"level\">\n <option *ngFor=\"let level of levels\" [value]=\"level\">{{level | translate}}</option>\n </select>\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Energy Class' | translate}}</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"classEnergyConsumption\">\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Greenhouse gas emission Class' | translate}}</label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"classGes\">\n </div>\n </div>\n \n <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'Cover picture' | translate}}</label>\n <div class=\"col-sm-9\">\n <img #imageBasePreview *ngIf=\"currentImage\" class=\"image-preview\" [src]=\"currentImage\">\n <label #imageInputContainer for=\"image\"\n class=\"btn btn-label-file btn-outline-primary rounded-pill imageInputContainer\">\n <input #imageInput type=\"file\" id=\"image\" (change)=\"handleImageInput($event.target)\" />\n {{ imageInputText | translate}}</label>\n <button *ngIf=\"currentImage && !imageToUpload\" \n class=\"btn btn-outline-primary rounded-pill\" (click)=\"imageToBeDeleted=true;clearImageFile()\">{{'Delete picture' | translate }}</button>\n <div class=\"image-name\" *ngIf=\"imageToUpload\">\n <p >{{ imageToUpload.name}}</p>\n <div (click)=\"clearImageFile()\" [style.cursor]=\"'pointer'\">\n <span class=\"iconify\" data-icon=\"mdi:trash-can-outline\"></span>\n </div>\n </div>\n \n </div>\n </div>\n <div class=\"mb-3 row\" *ngIf=\"!location\">\n <label class=\"col-sm-3 col-form-label\">{{'Create mission for this space' | translate}}</label>\n <div class=\"col-sm-3\">\n <input type=\"checkbox\" [(ngModel)]=\"addMissionForNewSpace\" [ngModelOptions]=\"{standalone: true}\">\n </div>\n </div>\n \n <button type=\"submit\" class=\"btn btn-outline-primary rounded-pill me-3\">{{'Save' | translate}}</button>\n <button type=\"button\" (click)=\"onCancel()\" class=\"btn btn-outline-primary rounded-pill\">{{'Cancel' |\n translate}}</button>\n </form>\n</div>\n", styles: ["input[type=file]{display:none}.custom-select{border-color:var(--smarterplan-primary);width:auto}.form-new-loc{background-color:#d3d3d3;padding-top:10px;padding-bottom:10px;margin-bottom:15px}.btn-outline-primary{background-color:#fff}h4{color:var(--smarterplan-primary)}.image-preview{object-fit:cover;max-height:400px;max-width:400px;display:flex;margin-bottom:15px}.imageInputContainer{width:-moz-fit-content;width:fit-content;height:-moz-fit-content;height:fit-content}.image-name{display:flex}.col-form-label{margin-bottom:1rem;width:230px}.form-new-loc{background-color:#d3d3d3;margin-bottom:15px;padding:10px;width:80%;border-radius:10px}.col-sm-9 select{width:100%;height:31.25px;padding-left:10px}.btn-outline-primary{width:200px;margin-bottom:1rem;margin-right:1rem}\n"] }]
420
+ }], ctorParameters: function () { return [{ type: i2.SpaceService }, { type: i2.PropertyService }, { type: i2.BaseUserService }, { type: i1$2.FormBuilder }, { type: i2.MissionService }, { type: i2.LayerService }]; }, propDecorators: { imageInputContainer: [{
421
+ type: ViewChild,
422
+ args: ["imageInputContainer"]
423
+ }], imageInput: [{
424
+ type: ViewChild,
425
+ args: ["imageInput"]
426
+ }], imageBasePreview: [{
427
+ type: ViewChild,
428
+ args: ["imageBasePreview"]
429
+ }], location: [{
430
+ type: Input
431
+ }], onChange: [{
432
+ type: Output
433
+ }] } });
434
+
435
+ class LocationsComponent {
436
+ constructor(spaceService, router, userService, viewerService, navigationService, navigatorService) {
437
+ this.spaceService = spaceService;
438
+ this.router = router;
439
+ this.userService = userService;
440
+ this.viewerService = viewerService;
441
+ this.navigationService = navigationService;
442
+ this.navigatorService = navigatorService;
443
+ this.isAdding = false;
444
+ this.filteredLocations = [];
445
+ this.isManager = false;
446
+ this.isMuseumUser = true;
447
+ this.locations = [];
448
+ this.menuItems = [];
449
+ /** Last filtered Locations, used when we go back on all locations from the search bar location */
450
+ this.lastFiltredLocations = [];
451
+ this.levels = enumToArray(LevelStatus);
452
+ this.userSubcription = this.userService.isChanged.subscribe((isConnected) => {
453
+ if (isConnected) {
454
+ this.refresh();
455
+ }
456
+ });
457
+ this.locationIDSubscription =
458
+ this.navigatorService.locationIDChange.subscribe((id) => {
459
+ this.changeSelectedLocation(id);
460
+ this.setupMenuItems();
461
+ });
462
+ }
463
+ ngOnInit() {
464
+ return __awaiter(this, void 0, void 0, function* () {
465
+ if (this.userService.cu) {
466
+ this.resetList();
467
+ this.updateUserRights();
468
+ }
469
+ this.setupMenuItems();
470
+ });
471
+ }
472
+ findSpaceById(id) {
473
+ return this.locations.find((loc) => loc.id === id);
474
+ }
475
+ /**
476
+ * Update when we change the selected location in filter (search bar)
477
+ * @param id for a location, if null display all last filtred location
478
+ */
479
+ changeSelectedLocation(id) {
480
+ const space = id ? this.findSpaceById(id) : null;
481
+ this.filteredLocations = space ? [space] : this.lastFiltredLocations; // New selected space or last filtered location
482
+ }
483
+ refresh() {
484
+ this.updateUserRights();
485
+ this.resetList();
486
+ }
487
+ ngOnDestroy() {
488
+ this.userSubcription.unsubscribe();
489
+ this.locationIDSubscription.unsubscribe();
490
+ }
491
+ setupMenuItems() {
492
+ this.menuItems = [{ label: "All Locations", url: "/localisation" }];
493
+ if (this.isAdding) {
494
+ this.menuItems.push({ label: "New" });
495
+ }
496
+ if (this.filteredLocations.length === 1) {
497
+ const selectedLoc = this.filteredLocations[0];
498
+ this.menuItems.push({ label: selectedLoc.name });
499
+ }
500
+ }
501
+ updateUserRights() {
502
+ this.isManager = this.userService.hasManagerRoleInAnyMission();
503
+ this.isMuseumUser = this.userService.hasOnlyMuseumRole();
504
+ }
505
+ isManagerForSpace(spaceID) {
506
+ return (this.userService.isManager(spaceID) ||
507
+ this.userService.isGuide(spaceID));
508
+ }
509
+ resetList() {
510
+ return __awaiter(this, void 0, void 0, function* () {
511
+ this.locations = yield this.spaceService.getLocationsForCurrentUser();
512
+ this.filteredLocations = this.locations;
513
+ this.lastFiltredLocations = this.locations;
514
+ this.isAdding = false;
515
+ this.changeSelectedLocation(this.navigatorService.currentNavBarLocationID); // Set for the current selected location
516
+ this.setupMenuItems();
517
+ });
518
+ }
519
+ onAddLocation() {
520
+ this.isAdding = true;
521
+ this.setupMenuItems();
522
+ }
523
+ handleImageInput(files) {
524
+ this.imageToUpload = files.item(0);
525
+ }
526
+ onFormChange(event) {
527
+ this.navigatorService.locationIDChange.next(null); /** Remove selected location */
528
+ this.isAdding = false;
529
+ if (event) {
530
+ this.resetList();
531
+ }
532
+ this.setupMenuItems();
533
+ }
534
+ onVisitClick(loc, visit) {
535
+ return __awaiter(this, void 0, void 0, function* () {
536
+ if (!this.userService.userHasAccessToAllZonesInSpace(loc.id)) {
537
+ // get allowed sweep for the user
538
+ const allowedSweeps = yield this.navigationService.getAllowedSweepsIDsForUserInSpace(loc.id);
539
+ const firstSweep = allowedSweeps[0];
540
+ this.viewerService.setSweepToMove(firstSweep);
541
+ }
542
+ if (this.userService.isGuide(loc.id)) {
543
+ this.router.navigate(["museum", loc.id]);
544
+ }
545
+ else {
546
+ this.router.navigate(["visit", loc.id], {
547
+ queryParams: { model3D: visit.model3d },
548
+ });
549
+ }
550
+ });
551
+ }
552
+ applyResultsSearchBar(results) {
553
+ this.filteredLocations = results || this.locations;
554
+ this.lastFiltredLocations = this.filteredLocations;
555
+ this.navigatorService.locationIDChange.next(null); // When we search with keyword, we would like to search on all locations
556
+ }
557
+ getSearchType() {
558
+ return SearchObjectType.LOCATION;
559
+ }
560
+ }
561
+ LocationsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocationsComponent, deps: [{ token: i2.SpaceService }, { token: i1.Router }, { token: i2.BaseUserService }, { token: i2.ViewerService }, { token: i2.NavigationService }, { token: i2.NavigatorService }], target: i0.ɵɵFactoryTarget.Component });
562
+ LocationsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: LocationsComponent, selector: "lib-locations", ngImport: i0, template: "<div class=\"dashboard-tab\">\n <div class=\"header-dashboard-tab\">\n <div class=\"m-3\">\n <lib-tab-navigation (onGoBack)=\"onFormChange(null)\" [menuItems]='menuItems'></lib-tab-navigation>\n <span class=\"ml-3 refreshIcon\" (click)=\"refresh()\" *ngIf=\"!(isAdding)\" ngbTooltip=\"Refresh list\">\n <span class=\"iconify refreshIcon\" data-icon=\"ion:refresh-circle\" data-width=\"35\" data-rotate=\"90deg\"></span>\n </span>\n </div> \n <lib-search-bar *ngIf=\"!isAdding && !isMuseumUser\" [searchable]=\"locations\" [objectType]=\"getSearchType()\"\n (searchEvent)=\"applyResultsSearchBar($event)\"></lib-search-bar>\n \n <div class=\"col-md-8\">\n <div class=\"sp-row\" *ngIf=\"!isAdding && isManager\">\n <button class=\"btn btn-outline-primary rounded-pill add-location\" (click)=\"onAddLocation()\">\n {{'Add location' | translate}}</button>\n <!-- <div class=\"outer_circle\">\n <button id='btn-icon' (click)=\"onAddLocation()\"></button>\n </div> -->\n </div>\n </div>\n </div>\n <hr>\n <div class=\"row\" *ngIf=\"isAdding\">\n <div class=\"col-md-6\">\n <h4>{{'New location' | translate}}</h4>\n </div>\n </div>\n <section *ngIf=\"!isAdding\">\n <div class=\"row\">\n <div class=\"col-sm-12 col-md-12 col-lg-6\" *ngIf=\"filteredLocations\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"d-flex justify-content-between list-group-item\"\n *ngFor=\"let loc of filteredLocations; index as index\">\n <div class=\"d-flex\">\n <div class=\"col-md-5 img-main-container\">\n <div id=\"img_container\">\n <img class=\"location-img\" *ngIf=\"loc.annexes; else elseBlock\" [src]=\"loc.annexes\">\n <ng-template #elseBlock><img class=\"location-img\"\n src=\"./../../../../assets/images/visuel-off-big.jpg\" />\n </ng-template>\n <button *ngIf=\"isManagerForSpace(loc.id)\" class=\"btn-details\" [routerLink]=\"[loc.id]\">\n {{'View details' | translate}}</button>\n </div>\n \n </div>\n <div class=\"col-md-7 location-info\">\n <p>{{loc.name}}</p>\n <p>{{loc.addresses}}</p>\n <p *ngFor=\"let visit of loc.visits\" (click)=\"onVisitClick(loc, visit)\" class=\"visit-name\"\n [style.cursor]=\"'pointer'\" ngbTooltip=\"Visit\">{{ visit.name ? visit.name : loc.name}}</p>\n </div>\n </div>\n </li>\n \n </ul>\n </div>\n <div class=\"col-sm-12 col-md-12 col-lg-6\">\n <lib-map [spaces]=\"filteredLocations\"></lib-map>\n </div>\n </div>\n </section>\n <lib-form-location *ngIf=\"isAdding\" (onChange)=\"onFormChange($event)\"></lib-form-location>\n</div>\n", styles: [".searchbar{margin-bottom:10px}input[type=file]{display:none}.form-control{border-radius:var(--form-control-border-radius)}.custom-select{border-color:var(--smarterplan-primary);width:auto}.form-new-loc{background-color:#d3d3d3;padding-top:10px;padding-bottom:10px;margin-bottom:15px}.btn-outline-primary{background-color:#fff}h4{color:var(--smarterplan-primary)}section .list-group{margin-top:15px}section .list-group-item{padding:5px 0}section .location-info{font-size:1.1em}section .location-img{width:100%;object-fit:cover;object-position:center bottom;height:165px}#img_container{position:relative;display:inline-block;text-align:center;width:250px}.img-main-container{max-width:250px;width:250px!important;margin-right:10px}.visit-name{color:var(--smarterplan-primary);font-weight:600}.btn-details{background-color:var(--smarterplan-primary-transparent);position:absolute;color:#fff;bottom:0px;right:0px;width:100%;height:30%;border:none;font-size:1em;text-transform:lowercase}#btn-icon{width:30px;height:30px;background:url(../../../../assets/icons/plus.svg);border:none;vertical-align:middle}#btn-icon:hover{background:url(../../../../assets/icons/plus-over.svg)}#btn-icon[disabled]:hover{background:url(../../../../assets/icons/plus.svg)}.outer_circle{background-color:#ebebeb;border-radius:50%;width:32px;height:32px;padding:1px;margin-left:5px}.refreshIcon{color:var(--smarterplan-primary);cursor:pointer}.refreshIcon svg{vertical-align:middle!important}.add-location{width:12vw}.sp-row{display:flex;flex-direction:row}\n"], components: [{ type: TabNavigationComponent, selector: "lib-tab-navigation", inputs: ["menuItems"], outputs: ["onGoBack"] }, { type: i2.SearchBarComponent, selector: "lib-search-bar", inputs: ["searchable", "objectType"], outputs: ["searchEvent"] }, { type: MapComponent, selector: "lib-map", inputs: ["spaces"] }, { type: FormLocationComponent, selector: "lib-form-location", inputs: ["location"], outputs: ["onChange"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgbTooltip, selector: "[ngbTooltip]", inputs: ["animation", "autoClose", "placement", "triggers", "container", "disableTooltip", "tooltipClass", "openDelay", "closeDelay", "ngbTooltip"], outputs: ["shown", "hidden"], exportAs: ["ngbTooltip"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.RouterLink, selector: ":not(a):not(area)[routerLink]", inputs: ["queryParams", "fragment", "queryParamsHandling", "preserveFragment", "skipLocationChange", "replaceUrl", "state", "relativeTo", "routerLink"] }], pipes: { "translate": i3.TranslatePipe } });
563
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocationsComponent, decorators: [{
564
+ type: Component,
565
+ args: [{ selector: 'lib-locations', template: "<div class=\"dashboard-tab\">\n <div class=\"header-dashboard-tab\">\n <div class=\"m-3\">\n <lib-tab-navigation (onGoBack)=\"onFormChange(null)\" [menuItems]='menuItems'></lib-tab-navigation>\n <span class=\"ml-3 refreshIcon\" (click)=\"refresh()\" *ngIf=\"!(isAdding)\" ngbTooltip=\"Refresh list\">\n <span class=\"iconify refreshIcon\" data-icon=\"ion:refresh-circle\" data-width=\"35\" data-rotate=\"90deg\"></span>\n </span>\n </div> \n <lib-search-bar *ngIf=\"!isAdding && !isMuseumUser\" [searchable]=\"locations\" [objectType]=\"getSearchType()\"\n (searchEvent)=\"applyResultsSearchBar($event)\"></lib-search-bar>\n \n <div class=\"col-md-8\">\n <div class=\"sp-row\" *ngIf=\"!isAdding && isManager\">\n <button class=\"btn btn-outline-primary rounded-pill add-location\" (click)=\"onAddLocation()\">\n {{'Add location' | translate}}</button>\n <!-- <div class=\"outer_circle\">\n <button id='btn-icon' (click)=\"onAddLocation()\"></button>\n </div> -->\n </div>\n </div>\n </div>\n <hr>\n <div class=\"row\" *ngIf=\"isAdding\">\n <div class=\"col-md-6\">\n <h4>{{'New location' | translate}}</h4>\n </div>\n </div>\n <section *ngIf=\"!isAdding\">\n <div class=\"row\">\n <div class=\"col-sm-12 col-md-12 col-lg-6\" *ngIf=\"filteredLocations\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"d-flex justify-content-between list-group-item\"\n *ngFor=\"let loc of filteredLocations; index as index\">\n <div class=\"d-flex\">\n <div class=\"col-md-5 img-main-container\">\n <div id=\"img_container\">\n <img class=\"location-img\" *ngIf=\"loc.annexes; else elseBlock\" [src]=\"loc.annexes\">\n <ng-template #elseBlock><img class=\"location-img\"\n src=\"./../../../../assets/images/visuel-off-big.jpg\" />\n </ng-template>\n <button *ngIf=\"isManagerForSpace(loc.id)\" class=\"btn-details\" [routerLink]=\"[loc.id]\">\n {{'View details' | translate}}</button>\n </div>\n \n </div>\n <div class=\"col-md-7 location-info\">\n <p>{{loc.name}}</p>\n <p>{{loc.addresses}}</p>\n <p *ngFor=\"let visit of loc.visits\" (click)=\"onVisitClick(loc, visit)\" class=\"visit-name\"\n [style.cursor]=\"'pointer'\" ngbTooltip=\"Visit\">{{ visit.name ? visit.name : loc.name}}</p>\n </div>\n </div>\n </li>\n \n </ul>\n </div>\n <div class=\"col-sm-12 col-md-12 col-lg-6\">\n <lib-map [spaces]=\"filteredLocations\"></lib-map>\n </div>\n </div>\n </section>\n <lib-form-location *ngIf=\"isAdding\" (onChange)=\"onFormChange($event)\"></lib-form-location>\n</div>\n", styles: [".searchbar{margin-bottom:10px}input[type=file]{display:none}.form-control{border-radius:var(--form-control-border-radius)}.custom-select{border-color:var(--smarterplan-primary);width:auto}.form-new-loc{background-color:#d3d3d3;padding-top:10px;padding-bottom:10px;margin-bottom:15px}.btn-outline-primary{background-color:#fff}h4{color:var(--smarterplan-primary)}section .list-group{margin-top:15px}section .list-group-item{padding:5px 0}section .location-info{font-size:1.1em}section .location-img{width:100%;object-fit:cover;object-position:center bottom;height:165px}#img_container{position:relative;display:inline-block;text-align:center;width:250px}.img-main-container{max-width:250px;width:250px!important;margin-right:10px}.visit-name{color:var(--smarterplan-primary);font-weight:600}.btn-details{background-color:var(--smarterplan-primary-transparent);position:absolute;color:#fff;bottom:0px;right:0px;width:100%;height:30%;border:none;font-size:1em;text-transform:lowercase}#btn-icon{width:30px;height:30px;background:url(../../../../assets/icons/plus.svg);border:none;vertical-align:middle}#btn-icon:hover{background:url(../../../../assets/icons/plus-over.svg)}#btn-icon[disabled]:hover{background:url(../../../../assets/icons/plus.svg)}.outer_circle{background-color:#ebebeb;border-radius:50%;width:32px;height:32px;padding:1px;margin-left:5px}.refreshIcon{color:var(--smarterplan-primary);cursor:pointer}.refreshIcon svg{vertical-align:middle!important}.add-location{width:12vw}.sp-row{display:flex;flex-direction:row}\n"] }]
566
+ }], ctorParameters: function () { return [{ type: i2.SpaceService }, { type: i1.Router }, { type: i2.BaseUserService }, { type: i2.ViewerService }, { type: i2.NavigationService }, { type: i2.NavigatorService }]; } });
567
+
568
+ class DetailLocationComponent {
569
+ constructor(route, spaceService, router, userService, translate, navigatorService) {
570
+ this.route = route;
571
+ this.spaceService = spaceService;
572
+ this.router = router;
573
+ this.userService = userService;
574
+ this.translate = translate;
575
+ this.navigatorService = navigatorService;
576
+ this.isEditing = false;
577
+ this.menuItems = [];
578
+ this.isValidatingDpe = false;
579
+ this.gettingData = false;
580
+ }
581
+ ngOnInit() {
582
+ return __awaiter(this, void 0, void 0, function* () {
583
+ this.id = this.route.snapshot.paramMap.get("id");
584
+ this.navigatorService.locationIDChange.next(this.id); // Send update for the location filter bar
585
+ this.space = yield this.spaceService.getSpace(this.id);
586
+ this.setupMenuItems();
587
+ this.setGuestLink();
588
+ this.setCanArchive();
589
+ });
590
+ }
591
+ setupMenuItems() {
592
+ this.menuItems = [
593
+ { label: "Locations", url: "/localisation" },
594
+ {
595
+ label: this.space.name,
596
+ url: `/localisation/${this.space.id}`,
597
+ },
598
+ ];
599
+ if (this.isEditing) {
600
+ this.menuItems.push({ label: "Edit" });
601
+ }
602
+ else {
603
+ this.menuItems.push({ label: "Information" });
604
+ }
605
+ }
606
+ onEdit() {
607
+ this.isEditing = true;
608
+ this.setupMenuItems();
609
+ }
610
+ onReturn() {
611
+ // this.locationService.back()
612
+ this.router.navigate(["dashboard/localisation"]);
613
+ }
614
+ reset() {
615
+ this.isEditing = false;
616
+ this.setupMenuItems();
617
+ }
618
+ onArchive() {
619
+ return __awaiter(this, void 0, void 0, function* () {
620
+ const message = this.translate.instant("confirm.archiveSpace");
621
+ if (window.confirm(message)) {
622
+ yield this.spaceService.softDeleteSpace(this.id);
623
+ this.onReturn();
624
+ }
625
+ });
626
+ }
627
+ onFormChange(event) {
628
+ this.isEditing = false;
629
+ if (event) {
630
+ this.space = event;
631
+ }
632
+ this.setupMenuItems();
633
+ }
634
+ onDpeValidate() {
635
+ this.isValidatingDpe = true;
636
+ this.parsedMetadata = JSON.parse(this.space.metadata);
637
+ this.parsedMetadata = this.parsedMetadata.filter((result) => result.geo_adresse);
638
+ }
639
+ onSelectChange(selectedResult) {
640
+ for (const result of this.parsedMetadata) {
641
+ if (result !== selectedResult && result.selected) {
642
+ result.selected = false;
643
+ }
644
+ }
645
+ this.selectedDpeResult = selectedResult;
646
+ }
647
+ onSaveResult() {
648
+ return __awaiter(this, void 0, void 0, function* () {
649
+ if (this.selectedDpeResult) {
650
+ const input = {
651
+ id: this.space.id,
652
+ constructionYear: this.selectedDpeResult.annee_construction,
653
+ classEnergyConsumption: this.selectedDpeResult.classe_consommation_energie,
654
+ classGes: this.selectedDpeResult.classe_estimation_ges,
655
+ status: SpaceStatus.DPE_VALIDATED,
656
+ };
657
+ const updatedLoc = yield this.spaceService.updateSpace(input);
658
+ this.space = updatedLoc;
659
+ this.isValidatingDpe = false;
660
+ }
661
+ });
662
+ }
663
+ onCancel() {
664
+ this.isValidatingDpe = false;
665
+ }
666
+ onErase() {
667
+ return __awaiter(this, void 0, void 0, function* () {
668
+ yield this.spaceService.updateSpace({
669
+ id: this.space.id,
670
+ status: SpaceStatus.DPE_VALIDATED,
671
+ });
672
+ this.space.status = SpaceStatus.DPE_VALIDATED;
673
+ this.isValidatingDpe = false;
674
+ });
675
+ }
676
+ onGetDpeData() {
677
+ return __awaiter(this, void 0, void 0, function* () {
678
+ this.gettingData = true;
679
+ yield this.spaceService.updateSpace({
680
+ id: this.space.id,
681
+ status: SpaceStatus.DPE_FETCH,
682
+ });
683
+ // force update of location
684
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
685
+ this.space = yield this.spaceService.getSpace(this.space.id);
686
+ this.gettingData = false;
687
+ }), 1500);
688
+ });
689
+ }
690
+ setGuestLink() {
691
+ if (this.space.guestLink) {
692
+ const { origin } = document.location;
693
+ this.guestLink = `${origin}/${this.space.guestLink}`;
694
+ setTimeout(() => {
695
+ const hyperlink = document.querySelector("#linkHref");
696
+ const message = this.translate.instant("confirm.followLink");
697
+ hyperlink.addEventListener("click", () => __awaiter(this, void 0, void 0, function* () {
698
+ if (window.confirm(message)) {
699
+ window.location.href = this.guestLink;
700
+ yield this.userService.logoutCurrentAndSignOutAuth();
701
+ this.router.navigate(["auth"]);
702
+ }
703
+ }));
704
+ }, 0);
705
+ }
706
+ }
707
+ setCanArchive() {
708
+ return __awaiter(this, void 0, void 0, function* () {
709
+ this.canArchive = this.userService.isSPAdmin()
710
+ ? true
711
+ : yield this.spaceService.canArchiveSpace(this.id);
712
+ });
713
+ }
714
+ }
715
+ DetailLocationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: DetailLocationComponent, deps: [{ token: i1.ActivatedRoute }, { token: i2.SpaceService }, { token: i1.Router }, { token: i2.BaseUserService }, { token: i3.TranslateService }, { token: i2.NavigatorService }], target: i0.ɵɵFactoryTarget.Component });
716
+ DetailLocationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: DetailLocationComponent, selector: "lib-detail-location", ngImport: i0, template: "<div class=\"container-fluid\">\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"reset()\"></lib-tab-navigation>\n </div>\n <button class=\"btn btn-outline-primary rounded-pill me-3\" (click)=\"onReturn()\">{{'Back to locations' |\n translate}}</button>\n <div class=\"row\" *ngIf=\"!isEditing && space\">\n <div class=\"col-md-5\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item bg-transparent\">{{'Name' | translate}}: {{space.name}} </li>\n <li class=\"list-group-item bg-transparent\">{{'Address' | translate}}: {{space.addresses}} </li>\n <li class=\"list-group-item bg-transparent\">{{'Construction year' | translate}}:\n {{space.constructionYear ?\n space.constructionYear : \"No data\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\">{{'Latitude' | translate}}:\n {{space.latitude ?\n space.latitude : \"No data\" | translate}}</li>\n <li class=\"list-group-item bg-transparent\">{{'Longitude' | translate}}: {{space.longitude ?\n space.longitude : \"No data\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\">{{'Access level' | translate}}: {{space.level | translate\n }} </li>\n <li class=\"list-group-item bg-transparent\">{{'Energy Class' | translate}}:\n {{space.classEnergyConsumption ?\n space.classEnergyConsumption : \"No data\" | translate}}\n <button *ngIf=\"space.status !== 'DPE_TO_VALIDATE'\"\n class=\"btn btn-outline-primary rounded-pill no-lowercase ms-5\" (click)=\"onGetDpeData()\">\n {{'Get data from API DPE' | translate}}</button>\n <a class=\"bg-transparent ms-5\" *ngIf=\"space.status === 'DPE_TO_VALIDATE'\"\n (click)=\"onDpeValidate()\" style=\"cursor: pointer;\">\n <span class=\"iconify\" data-icon=\"mdi:alert-circle-check\" style=\"color: #f19c80;\" data-width=\"25\"\n data-height=\"25\"></span>\n {{'DPE data found. Click to validate' | translate}}\n </a>\n </li>\n <li class=\"list-group-item bg-transparent\">{{'Greenhouse gas emission Class' | translate}}:\n {{space.classGes ? space.classGes : \"No data\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\">{{'Shareable Guest Link' | translate}}:\n <div style=\"display: inline;\" *ngIf=\"guestLink\">\n <a id=\"linkHref\" target=\"_blank\">{{'Try the link' | translate }}</a>\n <div ngxClipboard [cbContent]=\"guestLink\" [style.cursor]=\"'pointer'\"\n style=\"margin-left: 5px; max-width: 20px; display: inline;\" ngbTooltip=\"Copied!\"\n triggers=\"click:blur\">\n <span class=\"iconify\" data-icon=\"mdi:content-copy\" data-inline=\"false\" data-width=\"20\"\n data-height=\"20\"></span>\n </div>\n </div>\n <p *ngIf=\"!guestLink\" style=\"display: inline;\">{{'No link' | translate }}</p>\n <p *ngIf=\"!guestLink\"><small>({{'Generate link from a VISITOR mission'|translate}})</small>\n </p>\n </li>\n\n </ul>\n <div class=\"d-flex justify-content-center\" *ngIf=\"gettingData\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n <hr>\n <div class=\"d-flex\">\n <button class=\"btn btn-outline-primary rounded-pill me-3\" (click)=\"onEdit()\">{{'Edit' |\n translate}}</button>\n <div class=\"tooltip-wrapper\" ngbTooltip=\"{{!canArchive ? ('Contact SmarterPlan' | translate) : ('Archive location and related data' | translate)}}\">\n <button class=\"btn btn-outline-primary rounded-pill\" (click)=\"onArchive()\" [disabled]=\"!canArchive\">\n {{'Archive' | translate}}</button>\n </div>\n </div>\n\n\n </div>\n <div class=\"col-md-7\" *ngIf=\"isValidatingDpe\">\n <h6>{{'Most relevant results for' | translate}} : \n <b>diagnostics de performance \u00E9nerg\u00E9tique (DPE) des b\u00E2timents tertiaires</b></h6>\n <table class=\"table table-striped\">\n <thead>\n <tr>\n <th scope=\"col\">#</th>\n <th scope=\"col\">{{'Apply to location' | translate}}</th>\n <th scope=\"col\">{{'Address' | translate}}</th>\n <th scope=\"col\">{{'Activity sector' | translate}}</th>\n <th scope=\"col\">{{'Construction year' | translate}}</th>\n <th scope=\"col\">{{'Energy Class' | translate}}</th>\n <th scope=\"col\">{{'Greenhouse gas emission Class' | translate}}</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let result of parsedMetadata; index as i\">\n <th scope=\"row\">{{ i + 1 }}</th>\n <td><input class=\"checkbox-apply\" type=\"checkbox\" [(ngModel)]=\"result.selected\"\n (change)=\"onSelectChange(result)\"></td>\n <td>{{result.geo_adresse}}</td>\n <td>{{result.secteur_activite}}</td>\n <td>{{ result.annee_construction }}</td>\n <td>{{ result.classe_consommation_energie }}</td>\n <td>{{ result.classe_estimation_ges }}</td>\n </tr>\n </tbody>\n </table>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onSaveResult()\"\n [disabled]=\"!selectedDpeResult\">{{'Save selected' |\n translate}}</button>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onErase()\">\n {{'No match (erase data)' | translate}}</button>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onCancel()\">\n {{'Cancel' | translate}}</button>\n </div>\n </div>\n <lib-form-location *ngIf=\"isEditing\" [location]=\"space\" (onChange)=\"onFormChange($event)\"></lib-form-location>\n</div>\n", styles: [""], components: [{ type: TabNavigationComponent, selector: "lib-tab-navigation", inputs: ["menuItems"], outputs: ["onGoBack"] }, { type: FormLocationComponent, selector: "lib-form-location", inputs: ["location"], outputs: ["onChange"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7$1.ClipboardDirective, selector: "[ngxClipboard]", inputs: ["ngxClipboard", "container", "cbContent", "cbSuccessMsg"], outputs: ["cbOnSuccess", "cbOnError"] }, { type: i7.NgbTooltip, selector: "[ngbTooltip]", inputs: ["animation", "autoClose", "placement", "triggers", "container", "disableTooltip", "tooltipClass", "openDelay", "closeDelay", "ngbTooltip"], outputs: ["shown", "hidden"], exportAs: ["ngbTooltip"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1$2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], pipes: { "translate": i3.TranslatePipe } });
717
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: DetailLocationComponent, decorators: [{
718
+ type: Component,
719
+ args: [{ selector: 'lib-detail-location', template: "<div class=\"container-fluid\">\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"reset()\"></lib-tab-navigation>\n </div>\n <button class=\"btn btn-outline-primary rounded-pill me-3\" (click)=\"onReturn()\">{{'Back to locations' |\n translate}}</button>\n <div class=\"row\" *ngIf=\"!isEditing && space\">\n <div class=\"col-md-5\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item bg-transparent\">{{'Name' | translate}}: {{space.name}} </li>\n <li class=\"list-group-item bg-transparent\">{{'Address' | translate}}: {{space.addresses}} </li>\n <li class=\"list-group-item bg-transparent\">{{'Construction year' | translate}}:\n {{space.constructionYear ?\n space.constructionYear : \"No data\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\">{{'Latitude' | translate}}:\n {{space.latitude ?\n space.latitude : \"No data\" | translate}}</li>\n <li class=\"list-group-item bg-transparent\">{{'Longitude' | translate}}: {{space.longitude ?\n space.longitude : \"No data\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\">{{'Access level' | translate}}: {{space.level | translate\n }} </li>\n <li class=\"list-group-item bg-transparent\">{{'Energy Class' | translate}}:\n {{space.classEnergyConsumption ?\n space.classEnergyConsumption : \"No data\" | translate}}\n <button *ngIf=\"space.status !== 'DPE_TO_VALIDATE'\"\n class=\"btn btn-outline-primary rounded-pill no-lowercase ms-5\" (click)=\"onGetDpeData()\">\n {{'Get data from API DPE' | translate}}</button>\n <a class=\"bg-transparent ms-5\" *ngIf=\"space.status === 'DPE_TO_VALIDATE'\"\n (click)=\"onDpeValidate()\" style=\"cursor: pointer;\">\n <span class=\"iconify\" data-icon=\"mdi:alert-circle-check\" style=\"color: #f19c80;\" data-width=\"25\"\n data-height=\"25\"></span>\n {{'DPE data found. Click to validate' | translate}}\n </a>\n </li>\n <li class=\"list-group-item bg-transparent\">{{'Greenhouse gas emission Class' | translate}}:\n {{space.classGes ? space.classGes : \"No data\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\">{{'Shareable Guest Link' | translate}}:\n <div style=\"display: inline;\" *ngIf=\"guestLink\">\n <a id=\"linkHref\" target=\"_blank\">{{'Try the link' | translate }}</a>\n <div ngxClipboard [cbContent]=\"guestLink\" [style.cursor]=\"'pointer'\"\n style=\"margin-left: 5px; max-width: 20px; display: inline;\" ngbTooltip=\"Copied!\"\n triggers=\"click:blur\">\n <span class=\"iconify\" data-icon=\"mdi:content-copy\" data-inline=\"false\" data-width=\"20\"\n data-height=\"20\"></span>\n </div>\n </div>\n <p *ngIf=\"!guestLink\" style=\"display: inline;\">{{'No link' | translate }}</p>\n <p *ngIf=\"!guestLink\"><small>({{'Generate link from a VISITOR mission'|translate}})</small>\n </p>\n </li>\n\n </ul>\n <div class=\"d-flex justify-content-center\" *ngIf=\"gettingData\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n <hr>\n <div class=\"d-flex\">\n <button class=\"btn btn-outline-primary rounded-pill me-3\" (click)=\"onEdit()\">{{'Edit' |\n translate}}</button>\n <div class=\"tooltip-wrapper\" ngbTooltip=\"{{!canArchive ? ('Contact SmarterPlan' | translate) : ('Archive location and related data' | translate)}}\">\n <button class=\"btn btn-outline-primary rounded-pill\" (click)=\"onArchive()\" [disabled]=\"!canArchive\">\n {{'Archive' | translate}}</button>\n </div>\n </div>\n\n\n </div>\n <div class=\"col-md-7\" *ngIf=\"isValidatingDpe\">\n <h6>{{'Most relevant results for' | translate}} : \n <b>diagnostics de performance \u00E9nerg\u00E9tique (DPE) des b\u00E2timents tertiaires</b></h6>\n <table class=\"table table-striped\">\n <thead>\n <tr>\n <th scope=\"col\">#</th>\n <th scope=\"col\">{{'Apply to location' | translate}}</th>\n <th scope=\"col\">{{'Address' | translate}}</th>\n <th scope=\"col\">{{'Activity sector' | translate}}</th>\n <th scope=\"col\">{{'Construction year' | translate}}</th>\n <th scope=\"col\">{{'Energy Class' | translate}}</th>\n <th scope=\"col\">{{'Greenhouse gas emission Class' | translate}}</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let result of parsedMetadata; index as i\">\n <th scope=\"row\">{{ i + 1 }}</th>\n <td><input class=\"checkbox-apply\" type=\"checkbox\" [(ngModel)]=\"result.selected\"\n (change)=\"onSelectChange(result)\"></td>\n <td>{{result.geo_adresse}}</td>\n <td>{{result.secteur_activite}}</td>\n <td>{{ result.annee_construction }}</td>\n <td>{{ result.classe_consommation_energie }}</td>\n <td>{{ result.classe_estimation_ges }}</td>\n </tr>\n </tbody>\n </table>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onSaveResult()\"\n [disabled]=\"!selectedDpeResult\">{{'Save selected' |\n translate}}</button>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onErase()\">\n {{'No match (erase data)' | translate}}</button>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onCancel()\">\n {{'Cancel' | translate}}</button>\n </div>\n </div>\n <lib-form-location *ngIf=\"isEditing\" [location]=\"space\" (onChange)=\"onFormChange($event)\"></lib-form-location>\n</div>\n", styles: [""] }]
720
+ }], ctorParameters: function () { return [{ type: i1.ActivatedRoute }, { type: i2.SpaceService }, { type: i1.Router }, { type: i2.BaseUserService }, { type: i3.TranslateService }, { type: i2.NavigatorService }]; } });
721
+
722
+ class CalibrationComponent {
723
+ constructor(matterportImportService, planService, route, router, zoneService, spaceService, navigationService, translate) {
724
+ this.matterportImportService = matterportImportService;
725
+ this.planService = planService;
726
+ this.route = route;
727
+ this.router = router;
728
+ this.zoneService = zoneService;
729
+ this.spaceService = spaceService;
730
+ this.navigationService = navigationService;
731
+ this.translate = translate;
732
+ /** Item to display for the navbar */
733
+ this.menuItems = [];
734
+ /** Zoom ratio of the canvas/plan */
735
+ this.canvasZoom = 0;
736
+ /** Opacity for matterport iframe */
737
+ this.opacity = 50;
738
+ /** Current rotation for matterport, [0-360], matterport rotation is bind to input range */
739
+ this.rotation = 180;
740
+ /** Previous rotation, use to calculate the deltaRotation to rotate, when user change rotation value using range input */
741
+ this.prevRotation = 180;
742
+ /** True when the user is currently rotating with the input range, the matterport rotation events will be ignored */
743
+ this.isRotatingRange = false;
744
+ /** Rotating queue event to send to matterport */
745
+ this.rotatingQueueEvent = [];
746
+ /** True when Vertical symmetry is enabled */
747
+ this.reflectV = false;
748
+ /** True when Horizontal symmetry is enabled */
749
+ this.reflectH = false;
750
+ this.chosenPlanIsPdf = false;
751
+ /** First Point in visit, used to determine the calibration */
752
+ this.firstMarkVisit = { x: 0, y: 0 };
753
+ /** Second Point in visit, used to determine the calibration */
754
+ this.secondMarkVisit = { x: 0.5, y: 0.5 };
755
+ /** Equivalent of 'firstMarkVisit' in canvas */
756
+ this.firstMarkPlan = { x: 0, y: 0 };
757
+ /** Equivalent of 'secondMarkVisit' in canvas */
758
+ this.secondMarkPlan = { x: 0, y: 0 };
759
+ /** Calibration result, (offsetX, offsetY, x, y) */
760
+ this.calibrage = {};
761
+ /** Is in preview mode (see scan result) */
762
+ this.preview = false;
763
+ /** Matterport is loading */
764
+ this.loading = true;
765
+ this.positions = [];
766
+ this.floors = [];
767
+ this.zoomCanBeChanged = false;
768
+ }
769
+ ngOnDestroy() {
770
+ if (!this.loading) {
771
+ this.matterportImportService.removeFrame();
772
+ }
773
+ }
774
+ ngOnInit() {
775
+ return __awaiter(this, void 0, void 0, function* () {
776
+ this.spaceID = this.route.snapshot.queryParams.spaceID;
777
+ this.currentSpace = yield this.spaceService.getSpace(this.spaceID);
778
+ /** Menu nav bar */
779
+ this.setupMenuItems();
780
+ this.chosenPlan = this.planService.getChosenPlan();
781
+ if (this.chosenPlan) {
782
+ this.chosenPlanIsPdf = this.chosenPlan.annexe.includes("pdf");
783
+ this.launchViewer();
784
+ setTimeout(() => {
785
+ this.configureCanvas().then(() => {
786
+ this.panzoom = panzoom(this.canvas, {
787
+ bounds: true,
788
+ boundsPadding: 0,
789
+ maxZoom: 2.5,
790
+ minZoom: 0.1,
791
+ initialZoom: 1,
792
+ zoomSpeed: 0.02,
793
+ });
794
+ });
795
+ }, 500);
796
+ }
797
+ else {
798
+ this.router.navigate([
799
+ "/dashboard/localisation",
800
+ this.spaceID,
801
+ "plans",
802
+ ]);
803
+ }
804
+ });
805
+ }
806
+ /** **********************************************************************************************
807
+ * MENU NAV BAR
808
+ *********************************************************************************************** */
809
+ setupMenuItems() {
810
+ this.menuItems = [
811
+ { label: "Locations", url: "/localisation" },
812
+ {
813
+ label: this.currentSpace.name,
814
+ url: `/localisation/${this.spaceID}`,
815
+ },
816
+ {
817
+ label: "Plans",
818
+ url: `/localisation/${this.currentSpace.id}/plans`,
819
+ },
820
+ {
821
+ label: "Calibration",
822
+ url: `/localisation/${this.currentSpace.id}/plan-calibration?spaceID=${this.currentSpace.id}`,
823
+ },
824
+ ];
825
+ }
826
+ /** **********************************************************************************************
827
+ * CANVAS
828
+ *********************************************************************************************** */
829
+ /** Display the plan */
830
+ configureCanvas() {
831
+ return __awaiter(this, void 0, void 0, function* () {
832
+ /** Get canvas */
833
+ if (!this.canvas) {
834
+ const canvas = document.querySelector("#canvas");
835
+ this.canvas = canvas;
836
+ }
837
+ if (!this.chosenPlanIsPdf) {
838
+ const image = yield getMetaForImage(this.chosenPlan.filepath);
839
+ /** Compute the new size for the canvas/matterport, base on the dimension of the plan, keeping the ratio */
840
+ const size = this.getSizeForCanvas(image.width, image.height);
841
+ /** Compute the plan zoom ratio (use for the calibration later) */
842
+ this.canvasZoom = size.w / image.width;
843
+ this.resizeView(size);
844
+ /** Draw Plan on the canvas */
845
+ this.drawImage(this.chosenPlan.filepath);
846
+ }
847
+ else {
848
+ // TODO
849
+ this.pdfToCanvas();
850
+ }
851
+ });
852
+ }
853
+ /** Update size of the canvas/matterport */
854
+ resizeView(size) {
855
+ this.canvasDiv.nativeElement.style.width = `${size.w}px`;
856
+ this.canvasDiv.nativeElement.style.height = `${size.h}px`;
857
+ this.canvas.style.width = `${size.w}px`;
858
+ this.canvas.style.height = `${size.h}px`;
859
+ this.canvas.width = size.w;
860
+ this.canvas.height = size.h;
861
+ this.canvasSize = size;
862
+ }
863
+ /** Draw something on the canvas */
864
+ drawImage(url, x = 0, y = 0, icone = false) {
865
+ const image = new Image();
866
+ const size = this.canvasSize;
867
+ const context = this.canvas.getContext("2d");
868
+ /** Flip the context, for symmetry */
869
+ // if (this.reflectV) {
870
+ // context.translate(size.w, 0);
871
+ // context.scale(-1, 1);
872
+ // }
873
+ // if (this.reflectH) {
874
+ // context.translate(0, size.h);
875
+ // context.scale(1, -1);
876
+ // }
877
+ let imageWidth = size.w;
878
+ let imageHeight = size.h;
879
+ image.addEventListener("load", () => {
880
+ if (icone) {
881
+ imageWidth = image.width;
882
+ imageHeight = image.height;
883
+ }
884
+ context.drawImage(image, 0, 0, image.width, image.height, x, y, imageWidth, imageHeight);
885
+ });
886
+ image.src = url;
887
+ }
888
+ /** Get the size for the canvas, based on the plan size, keeping the ratio */
889
+ getSizeForCanvas(w, h) {
890
+ let canvasW = this.canvasDiv.nativeElement.offsetWidth;
891
+ let canvasH = this.canvasDiv.nativeElement.offsetHeight;
892
+ const imageRatio = w / h;
893
+ const canvasRatio = canvasW / canvasH;
894
+ if (imageRatio > canvasRatio) {
895
+ canvasH = canvasW / imageRatio;
896
+ }
897
+ else {
898
+ canvasW = canvasH * imageRatio;
899
+ }
900
+ return { w: canvasW, h: canvasH };
901
+ }
902
+ /** [TODO] Convert a PDF to a Canvas */
903
+ pdfToCanvas() {
904
+ return __awaiter(this, void 0, void 0, function* () {
905
+ const pdfjs = yield import('pdfjs-dist/build/pdf');
906
+ const pdfjsWorker = yield import('pdfjs-dist/build/pdf.worker.entry');
907
+ pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
908
+ const pdf = yield getDocument(this.chosenPlan.filepath).promise;
909
+ const page = yield pdf.getPage(1);
910
+ const viewPortParameters = { scale: 1 };
911
+ const viewport = page.getViewport(viewPortParameters);
912
+ this.canvas.height = viewport.height;
913
+ this.canvas.width = viewport.width;
914
+ const size = this.getSizeForCanvas(viewport.width, viewport.height);
915
+ console.log(size);
916
+ this.canvasSize = size;
917
+ this.canvasZoom = size.w / viewport.width;
918
+ const context = this.canvas.getContext("2d");
919
+ const renderContext = {
920
+ canvasContext: context,
921
+ viewport,
922
+ };
923
+ const renderTask = page.render(renderContext).promise;
924
+ renderTask.then(() => console.log("Page rendered"));
925
+ // const res = canvas.toDataURL();
926
+ // if (pdf != null) pdf.destroy();
927
+ // return res;
928
+ });
929
+ }
930
+ /** User click to user Symmetry Vertical */
931
+ onReflectV() {
932
+ this.reflectV = !this.reflectV;
933
+ this.configureCanvas();
934
+ }
935
+ /** User click to user Symmetry Horizontal */
936
+ onReflectH() {
937
+ this.reflectH = !this.reflectH;
938
+ this.configureCanvas();
939
+ }
940
+ /** **********************************************************************************************
941
+ * MATTERPORT
942
+ *********************************************************************************************** */
943
+ /** Launch matterport */
944
+ launchViewer() {
945
+ return __awaiter(this, void 0, void 0, function* () {
946
+ yield this.matterportImportService.initSdkForModel(this.chosenPlan.model3d);
947
+ const { sdk } = this.matterportImportService;
948
+ this.floors = Object.values(this.matterportImportService.floors);
949
+ // console.log(this.floors);
950
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
951
+ /** Move Floor mode */
952
+ yield sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN);
953
+ /** Display the correct floor for the plan */
954
+ try {
955
+ yield this.matterportImportService.moveToFloor(this.chosenPlan.name);
956
+ }
957
+ catch (_a) {
958
+ console.log("couldnot move to floor");
959
+ }
960
+ /** We can display the matterport view now */
961
+ this.loading = false;
962
+ }), 300);
963
+ /** When the user try to change the view mode we set it back to floorpan */
964
+ sdk.on(sdk.Mode.Event.CHANGE_END, (oldMode, newMode) => {
965
+ if (newMode !== sdk.Mode.Mode.FLOORPLAN) {
966
+ sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN, {
967
+ transition: "transition.instant",
968
+ });
969
+ }
970
+ });
971
+ /** Update current camera pose and rotation */
972
+ sdk.Camera.pose.subscribe((event) => {
973
+ /** We update only if the user is not changing the rotation with the <input> range, to not override the <input> value */
974
+ if (!this.isRotatingRange) {
975
+ this.rotation = event.rotation.y + 180;
976
+ this.prevRotation = this.rotation;
977
+ this.cameraPose = event;
978
+ }
979
+ });
980
+ });
981
+ }
982
+ /** When the <input> range, for rotation, change */
983
+ onRotationChange() {
984
+ return __awaiter(this, void 0, void 0, function* () {
985
+ const rotationDelta = this.rotation - this.prevRotation;
986
+ this.prevRotation = this.rotation;
987
+ /** Send the rotationDelta to th queue event in order to be send to matterport */
988
+ this.rotatingQueueEvent.push(rotationDelta);
989
+ /** Start to process the queue, if it's the first event */
990
+ if (!this.isRotatingRange) {
991
+ this.isRotatingRange = true;
992
+ this.processRotatingQueueEvent();
993
+ }
994
+ });
995
+ }
996
+ /** Process the rotating event queue, send event one by one to matterport */
997
+ processRotatingQueueEvent() {
998
+ return __awaiter(this, void 0, void 0, function* () {
999
+ const { sdk } = this.matterportImportService;
1000
+ /** While the queue is not empty */
1001
+ while (this.rotatingQueueEvent.length > 0) {
1002
+ /** Rotate matterport by deltaRotation and remove event from queue */
1003
+ yield sdk.Camera.rotate(this.rotatingQueueEvent.shift(), 0, {
1004
+ speed: 360,
1005
+ });
1006
+ }
1007
+ /** When the queue is empty, then the user is not rotating with the <input> range anymore */
1008
+ this.isRotatingRange = false;
1009
+ });
1010
+ }
1011
+ /** **********************************************************************************************
1012
+ * USER ACTIONS
1013
+ *********************************************************************************************** */
1014
+ /** Preview calibration */
1015
+ onPreview() {
1016
+ return __awaiter(this, void 0, void 0, function* () {
1017
+ this.preview = true;
1018
+ /** Place sweeps */
1019
+ this.onPlaceSweeps();
1020
+ });
1021
+ }
1022
+ calibrate() {
1023
+ return __awaiter(this, void 0, void 0, function* () {
1024
+ const [navigation] = this.currentNavigations;
1025
+ const position = JSON.parse(navigation.position);
1026
+ this.firstMarkPlan =
1027
+ yield this.matterportImportService.sdk.Renderer.getScreenPosition({
1028
+ x: position.x,
1029
+ y: position.y,
1030
+ z: position.z,
1031
+ });
1032
+ this.secondMarkPlan =
1033
+ yield this.matterportImportService.sdk.Renderer.getScreenPosition({
1034
+ x: position.x,
1035
+ y: 0,
1036
+ z: 0,
1037
+ });
1038
+ const deltaZVisit = 0 - position.z;
1039
+ let deltaXPlan = this.secondMarkPlan.x - this.firstMarkPlan.x;
1040
+ if (deltaXPlan === 0) {
1041
+ // console.log("we moved along Y axis on Plan");
1042
+ const deltaYPlan = this.secondMarkPlan.y - this.firstMarkPlan.y;
1043
+ this.calibrage.nameYAxis = "z";
1044
+ this.calibrage.nameXAxis = "x";
1045
+ this.calibrage.offsetY = this.secondMarkPlan.y;
1046
+ this.calibrage.scaleY = deltaYPlan / deltaZVisit;
1047
+ }
1048
+ else {
1049
+ // console.log(" we moved along X axis on Plan");
1050
+ this.calibrage.nameYAxis = "x";
1051
+ this.calibrage.nameXAxis = "z";
1052
+ this.calibrage.offsetX = this.secondMarkPlan.x;
1053
+ this.calibrage.scaleX = deltaXPlan / deltaZVisit;
1054
+ }
1055
+ const thirdMarkPlan = yield this.matterportImportService.sdk.Renderer.getScreenPosition({
1056
+ x: 0,
1057
+ y: 0,
1058
+ z: position.z,
1059
+ });
1060
+ const deltaXVisit = 0 - position.x;
1061
+ if (deltaXPlan === 0) {
1062
+ // console.log(" we moved along X axis on Plan");
1063
+ deltaXPlan = thirdMarkPlan.x - this.firstMarkPlan.x;
1064
+ this.calibrage.offsetX = thirdMarkPlan.x;
1065
+ this.calibrage.scaleX = deltaXPlan / deltaXVisit;
1066
+ }
1067
+ else {
1068
+ const deltaYPlan = thirdMarkPlan.y - this.firstMarkPlan.y;
1069
+ this.calibrage.offsetY = thirdMarkPlan.y;
1070
+ this.calibrage.scaleY = deltaYPlan / deltaXVisit;
1071
+ }
1072
+ /** Take considiration of pan and zoom of plan on canvas */
1073
+ const transformInfo = this.panzoom.getTransform();
1074
+ const { scale, x, y } = transformInfo;
1075
+ // console.log(transformInfo);
1076
+ this.calibrage.offsetXPlan = x;
1077
+ this.calibrage.offsetYPlan = y;
1078
+ this.calibrage.scalePlan = scale;
1079
+ console.log(this.calibrage);
1080
+ });
1081
+ }
1082
+ /** Place sweeps */
1083
+ onPlaceSweeps() {
1084
+ return __awaiter(this, void 0, void 0, function* () {
1085
+ /** Display all scan */
1086
+ const zone = yield this.zoneService.getZone(this.chosenPlan.zoneID);
1087
+ if (zone) {
1088
+ this.currentZone = zone;
1089
+ const navigations = yield this.navigationService.getNavigationsForZone(this.currentZone);
1090
+ this.currentNavigations = navigations;
1091
+ yield this.calibrate();
1092
+ if (navigations.length > 0) {
1093
+ for (const navigation of navigations) {
1094
+ const testPosition = JSON.parse(navigation.position);
1095
+ const positionX = this.calibrage.nameXAxis === "x"
1096
+ ? testPosition.x
1097
+ : testPosition.z;
1098
+ const positionY = this.calibrage.nameYAxis === "x"
1099
+ ? testPosition.x
1100
+ : testPosition.z;
1101
+ const testX = positionX * this.calibrage.scaleX +
1102
+ this.calibrage.offsetX;
1103
+ const testY = positionY * this.calibrage.scaleY +
1104
+ this.calibrage.offsetY;
1105
+ // console.log("test position GREEN", testX, testY);
1106
+ const transformedX = (testX - this.calibrage.offsetXPlan) /
1107
+ this.calibrage.scalePlan; // we are undoing the pan and zoom
1108
+ const transformedY = (testY - this.calibrage.offsetYPlan) /
1109
+ this.calibrage.scalePlan;
1110
+ this.positions.push({
1111
+ navID: navigation.id,
1112
+ planID: this.chosenPlan.id,
1113
+ x: transformedX,
1114
+ y: transformedY,
1115
+ });
1116
+ const iconSize = 30 * this.calibrage.scalePlan;
1117
+ const shift = iconSize / 2;
1118
+ this.drawImage("https://api.iconify.design/mdi:adjust.svg?color=green&height=30&width=30", transformedX - shift, transformedY - shift, true);
1119
+ }
1120
+ }
1121
+ }
1122
+ });
1123
+ }
1124
+ /** Save calibration */
1125
+ onSave() {
1126
+ return __awaiter(this, void 0, void 0, function* () {
1127
+ if (this.currentZone) {
1128
+ /** Normalize with the zoom */
1129
+ // this.calibrage.offsetX /= this.canvasZoom;
1130
+ // this.calibrage.offsetY /= this.canvasZoom;
1131
+ // this.calibrage.x /= this.canvasZoom;
1132
+ // this.calibrage.y /= this.canvasZoom;
1133
+ this.calibrage.new = true;
1134
+ this.calibrage.imgWidth = this.canvasSize.w;
1135
+ this.calibrage.imgHeight = this.canvasSize.h;
1136
+ yield this.planService.updatePlan({
1137
+ id: this.chosenPlan.id,
1138
+ calibration: JSON.stringify(this.calibrage),
1139
+ });
1140
+ yield Promise.all(this.positions.map((position) => __awaiter(this, void 0, void 0, function* () {
1141
+ const { navID } = position;
1142
+ delete position.navID;
1143
+ const nav = this.currentNavigations.find((_nav) => _nav.id === navID);
1144
+ let positionsDataToUpdate;
1145
+ if (nav.positionOnPlan) {
1146
+ const positionOnPlan = nav.positionOnPlan.map((entry) => JSON.parse(entry));
1147
+ const positionForCurrentPlan = positionOnPlan.find((entry) => entry.planID === this.chosenPlan.id);
1148
+ if (positionForCurrentPlan) {
1149
+ positionOnPlan.splice(positionOnPlan.indexOf(positionForCurrentPlan), 1, position);
1150
+ }
1151
+ else {
1152
+ positionOnPlan.push(position);
1153
+ }
1154
+ positionsDataToUpdate = [...positionOnPlan];
1155
+ }
1156
+ else {
1157
+ positionsDataToUpdate = [position];
1158
+ }
1159
+ // console.log(positionsDataToUpdate);
1160
+ yield this.navigationService.updateNavigation({
1161
+ id: navID,
1162
+ positionOnPlan: positionsDataToUpdate.map((entry) => JSON.stringify(entry)),
1163
+ });
1164
+ })));
1165
+ }
1166
+ this.matterportImportService.removeFrame();
1167
+ this.router.navigate([
1168
+ "/dashboard/localisation",
1169
+ this.spaceID,
1170
+ "plans",
1171
+ ]);
1172
+ alert(this.translate.instant("calibration.success"));
1173
+ });
1174
+ }
1175
+ /** Reset the canvas */
1176
+ onReset() {
1177
+ this.reflectH = false;
1178
+ this.reflectV = false;
1179
+ this.preview = false;
1180
+ this.configureCanvas();
1181
+ }
1182
+ /** Cancel, leave */
1183
+ onCancel() {
1184
+ this.matterportImportService.removeFrame();
1185
+ this.router.navigate([
1186
+ "/dashboard/localisation",
1187
+ this.spaceID,
1188
+ "plans",
1189
+ ]);
1190
+ alert(this.translate.instant("calibration.canceled"));
1191
+ }
1192
+ onFloorClick(floor) {
1193
+ return __awaiter(this, void 0, void 0, function* () {
1194
+ this.currentFloor = floor;
1195
+ yield this.matterportImportService.moveToFloor(floor.id);
1196
+ });
1197
+ }
1198
+ onActivateZoomChange() {
1199
+ this.zoomCanBeChanged = !this.zoomCanBeChanged;
1200
+ const iframe = document.querySelector("#viewer-frame");
1201
+ if (iframe) {
1202
+ iframe.style.zIndex = this.zoomCanBeChanged ? "1" : "0";
1203
+ }
1204
+ }
1205
+ }
1206
+ CalibrationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CalibrationComponent, deps: [{ token: i2.MatterportImportService }, { token: i2.PlanService }, { token: i1.ActivatedRoute }, { token: i1.Router }, { token: i2.ZoneService }, { token: i2.SpaceService }, { token: i2.NavigationService }, { token: i3.TranslateService }], target: i0.ɵɵFactoryTarget.Component });
1207
+ CalibrationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: CalibrationComponent, selector: "lib-calibration", viewQueries: [{ propertyName: "canvasDiv", first: true, predicate: ["canvasDiv"], descendants: true }], ngImport: i0, template: "<div class=\"row mt-3\">\n <div class=\"col\">\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems'></lib-tab-navigation>\n </div>\n </div>\n</div>\n\n<div id=\"rowCanvas\">\n <div #canvasDiv id=\"canvasDiv\">\n\n <div id=\"viewer-frame\" [style.pointer-events]=\"zoomCanBeChanged?'auto':'none'\">\n <!-- <div class=\"blur\"></div> -->\n </div>\n <canvas id=\"canvas\" [ngStyle]=\"{'opacity': (preview||loading) ? '1' : 'calc(' + opacity + '/ 100)'}\"></canvas>\n </div>\n\n <div class=\"calibration-tools container-fluid\" *ngIf=\"!(preview || loading)\">\n <h1>{{'Calibration tool' | translate}}</h1>\n <div class=\"tool\">\n <div class=\"row ms-0 me-0 legend\">\n <div [ngStyle]=\"{'opacity': 'calc(' + (-(opacity-100)+10) + '/ 100)'}\">{{'Less' | translate}}</div>\n <div class=\"legend-title\">{{'Plan Opacity' | translate }}</div>\n <div [ngStyle]=\"{'opacity': 'calc(' + (opacity+10) + '/ 100)'}\">{{'More' | translate}}</div>\n </div>\n <div class=\"row ms-0 me-0 \">\n <input [disabled]=\"false\" [ngModelOptions]=\"{standalone: true}\" [(ngModel)]=\"opacity\" type=\"range\"\n class=\"form-range\" min=\"0\" max=\"100\" value=\"50\" id=\"opacity\">\n </div>\n </div>\n <div class=\"tool\">\n <div class=\"row ms-0 me-0 \">\n <div class=\"label-legend\">{{'Change Visit Floor' | translate}}</div>\n <div ngbDropdown class=\"d-inline-block ms-3\">\n <button class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\" ngbDropdownToggle>\n {{currentFloor ? currentFloor.id : ('Floor' | translate) }}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\n <button ngbDropdownItem *ngFor=\"let floor of floors\" (click)=\"onFloorClick(floor)\">\n {{ floor.name.length > 0 ? floor.name : ('Floor ' + floor.id) }}\n </button>\n </div>\n </div>\n </div>\n\n </div>\n <div class=\"tool\">\n <div class=\"row ms-0 me-0 \">\n <div class=\"label-legend me-3\">{{'Pan/Zoom Visit' | translate}} {{zoomCanBeChanged ? \"ON\" : \"OFF\"}}\n </div>\n <input type=\"checkbox\" (change)=\"onActivateZoomChange()\" style=\"margin-top: 5px;\">\n <div class=\"card border-warning mb-3 mt-3\" *ngIf=\"zoomCanBeChanged\">\n <div class=\"card-body text-warning\">\n <h5 class=\"card-title\">{{\"calibration.wait-message\" | translate}}</h5>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"action\">\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onPreview()\"\n [disabled]=\"zoomCanBeChanged\">{{'Preview' | translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onCancel()\">{{'Cancel' |\n translate}}</button>\n\n </div>\n\n </div>\n <div class=\"calibration-tools container-fluid\" *ngIf=\"preview\">\n <h1>{{'Validation' | translate}}</h1>\n <div class=\"action\">\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onSave()\">{{'Validate' |\n translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onReset()\">{{'Reset' |\n translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onCancel()\">{{'Cancel' |\n translate}}</button>\n\n </div>\n </div>\n\n\n <div class=\"calibration-tools container-fluid\" *ngIf=\"loading\">\n <h3>{{\"Waiting for Matterport\" | translate}}...</h3>\n <div class=\"d-flex justify-content-center\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n\n </div>\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);position:absolute;margin:auto;width:100%;text-align:center;font-weight:700}.tool .label-legend{color:var(--smarterplan-primary);font-size:1.1rem}.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"], components: [{ type: TabNavigationComponent, selector: "lib-tab-navigation", inputs: ["menuItems"], outputs: ["onGoBack"] }], directives: [{ type: i5.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1$2.RangeValueAccessor, selector: "input[type=range][formControlName],input[type=range][formControl],input[type=range][ngModel]" }, { type: i1$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i7.NgbDropdown, selector: "[ngbDropdown]", inputs: ["autoClose", "dropdownClass", "open", "placement", "container", "display"], outputs: ["openChange"], exportAs: ["ngbDropdown"] }, { type: i7.NgbDropdownToggle, selector: "[ngbDropdownToggle]" }, { type: i7.NgbDropdownMenu, selector: "[ngbDropdownMenu]" }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgbDropdownItem, selector: "[ngbDropdownItem]", inputs: ["disabled"] }], pipes: { "translate": i3.TranslatePipe } });
1208
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CalibrationComponent, decorators: [{
1209
+ type: Component,
1210
+ args: [{ selector: 'lib-calibration', template: "<div class=\"row mt-3\">\n <div class=\"col\">\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems'></lib-tab-navigation>\n </div>\n </div>\n</div>\n\n<div id=\"rowCanvas\">\n <div #canvasDiv id=\"canvasDiv\">\n\n <div id=\"viewer-frame\" [style.pointer-events]=\"zoomCanBeChanged?'auto':'none'\">\n <!-- <div class=\"blur\"></div> -->\n </div>\n <canvas id=\"canvas\" [ngStyle]=\"{'opacity': (preview||loading) ? '1' : 'calc(' + opacity + '/ 100)'}\"></canvas>\n </div>\n\n <div class=\"calibration-tools container-fluid\" *ngIf=\"!(preview || loading)\">\n <h1>{{'Calibration tool' | translate}}</h1>\n <div class=\"tool\">\n <div class=\"row ms-0 me-0 legend\">\n <div [ngStyle]=\"{'opacity': 'calc(' + (-(opacity-100)+10) + '/ 100)'}\">{{'Less' | translate}}</div>\n <div class=\"legend-title\">{{'Plan Opacity' | translate }}</div>\n <div [ngStyle]=\"{'opacity': 'calc(' + (opacity+10) + '/ 100)'}\">{{'More' | translate}}</div>\n </div>\n <div class=\"row ms-0 me-0 \">\n <input [disabled]=\"false\" [ngModelOptions]=\"{standalone: true}\" [(ngModel)]=\"opacity\" type=\"range\"\n class=\"form-range\" min=\"0\" max=\"100\" value=\"50\" id=\"opacity\">\n </div>\n </div>\n <div class=\"tool\">\n <div class=\"row ms-0 me-0 \">\n <div class=\"label-legend\">{{'Change Visit Floor' | translate}}</div>\n <div ngbDropdown class=\"d-inline-block ms-3\">\n <button class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\" ngbDropdownToggle>\n {{currentFloor ? currentFloor.id : ('Floor' | translate) }}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\n <button ngbDropdownItem *ngFor=\"let floor of floors\" (click)=\"onFloorClick(floor)\">\n {{ floor.name.length > 0 ? floor.name : ('Floor ' + floor.id) }}\n </button>\n </div>\n </div>\n </div>\n\n </div>\n <div class=\"tool\">\n <div class=\"row ms-0 me-0 \">\n <div class=\"label-legend me-3\">{{'Pan/Zoom Visit' | translate}} {{zoomCanBeChanged ? \"ON\" : \"OFF\"}}\n </div>\n <input type=\"checkbox\" (change)=\"onActivateZoomChange()\" style=\"margin-top: 5px;\">\n <div class=\"card border-warning mb-3 mt-3\" *ngIf=\"zoomCanBeChanged\">\n <div class=\"card-body text-warning\">\n <h5 class=\"card-title\">{{\"calibration.wait-message\" | translate}}</h5>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"action\">\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onPreview()\"\n [disabled]=\"zoomCanBeChanged\">{{'Preview' | translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onCancel()\">{{'Cancel' |\n translate}}</button>\n\n </div>\n\n </div>\n <div class=\"calibration-tools container-fluid\" *ngIf=\"preview\">\n <h1>{{'Validation' | translate}}</h1>\n <div class=\"action\">\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onSave()\">{{'Validate' |\n translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onReset()\">{{'Reset' |\n translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" (click)=\"onCancel()\">{{'Cancel' |\n translate}}</button>\n\n </div>\n </div>\n\n\n <div class=\"calibration-tools container-fluid\" *ngIf=\"loading\">\n <h3>{{\"Waiting for Matterport\" | translate}}...</h3>\n <div class=\"d-flex justify-content-center\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n\n </div>\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);position:absolute;margin:auto;width:100%;text-align:center;font-weight:700}.tool .label-legend{color:var(--smarterplan-primary);font-size:1.1rem}.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"] }]
1211
+ }], 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: [{
1212
+ type: ViewChild,
1213
+ args: ["canvasDiv"]
1214
+ }] } });
1215
+
1216
+ class PlansComponent {
1217
+ constructor(route, router, spaceService, planService, fb, translate) {
1218
+ this.route = route;
1219
+ this.router = router;
1220
+ this.spaceService = spaceService;
1221
+ this.planService = planService;
1222
+ this.fb = fb;
1223
+ this.translate = translate;
1224
+ // chosenPlan: Plan;
1225
+ this.indexDetails = -1;
1226
+ this.loading = false;
1227
+ this.uploadingPlan = false;
1228
+ this.isCurrentPlanForZone = false;
1229
+ this.chosenPlanIsPdf = false;
1230
+ this.menuItems = [];
1231
+ }
1232
+ ngOnInit() {
1233
+ this.spaceID = this.route.snapshot.paramMap.get("id");
1234
+ this.getPlans();
1235
+ if (this.planService.getPlanFileCache() &&
1236
+ this.planService.getChosenPlan()) {
1237
+ this.addPlanFromCache(this.planService.getPlanFileCache(), this.planService.getChosenPlan());
1238
+ this.planService.setPlanFileCache(null);
1239
+ }
1240
+ this.planService.setChosenPlan(null);
1241
+ }
1242
+ setupMenuItems() {
1243
+ this.menuItems = [
1244
+ { label: "Locations", url: "/localisation" },
1245
+ {
1246
+ label: this.currentSpace.name,
1247
+ url: `/localisation/${this.currentSpace.id}`,
1248
+ },
1249
+ {
1250
+ label: "Plans",
1251
+ url: `/localisation/${this.currentSpace.id}/plans`,
1252
+ },
1253
+ ];
1254
+ }
1255
+ onGoBack() { }
1256
+ onPlanClick(plan) {
1257
+ return __awaiter(this, void 0, void 0, function* () {
1258
+ if (plan)
1259
+ this.planService.setChosenPlan(plan);
1260
+ this.chosenPlanIsPdf = plan.annexe.includes("pdf");
1261
+ if (!this.chosenPlanIsPdf) {
1262
+ setTimeout(() => {
1263
+ this.configureCanvas().then(() => {
1264
+ this.panzoom = panzoom(this.canvas, {
1265
+ bounds: true,
1266
+ boundsPadding: 0,
1267
+ maxZoom: 3.5,
1268
+ minZoom: 0.1,
1269
+ initialZoom: 0.5,
1270
+ });
1271
+ });
1272
+ }, 500);
1273
+ }
1274
+ });
1275
+ }
1276
+ configureCanvas() {
1277
+ return __awaiter(this, void 0, void 0, function* () {
1278
+ this.uploadingPlan = true;
1279
+ const canvas = document.querySelector("#canvas");
1280
+ const image = yield getMetaForImage(this.getChoosenPlan().filepath);
1281
+ canvas.width = image.width;
1282
+ canvas.height = image.height;
1283
+ this.canvas = canvas;
1284
+ this.drawImage(this.getChoosenPlan().filepath);
1285
+ this.uploadingPlan = false;
1286
+ });
1287
+ }
1288
+ drawImage(url, x = 0, y = 0) {
1289
+ const image = new Image();
1290
+ const context = this.canvas.getContext("2d");
1291
+ const imageWidth = this.canvas.width;
1292
+ const imageHeight = this.canvas.height;
1293
+ image.addEventListener("load", () => {
1294
+ context.drawImage(image, 0, 0, image.width, image.height, x, y, imageWidth, imageHeight);
1295
+ });
1296
+ image.src = url;
1297
+ // image.crossOrigin = "*"; //need to download as png,
1298
+ // BUT: https://stackoverflow.com/questions/49503171/the-image-tag-with-crossorigin-anonymous-cant-load-success-from-s3
1299
+ }
1300
+ getPlans() {
1301
+ return __awaiter(this, void 0, void 0, function* () {
1302
+ this.loading = true;
1303
+ this.currentSpace = yield this.spaceService.getSpace(this.spaceID);
1304
+ this.setupMenuItems();
1305
+ this.zones = this.currentSpace.zones.items;
1306
+ this.plans = yield this.planService.getSingedPlansForSpace(this.spaceID);
1307
+ this.loading = false;
1308
+ if (this.plans.length === 1) {
1309
+ this.onPlanClick(this.plans[0]);
1310
+ }
1311
+ });
1312
+ }
1313
+ getChoosenPlan() {
1314
+ return this.planService.getChosenPlan();
1315
+ }
1316
+ removeImage() {
1317
+ const context = this.canvas.getContext("2d");
1318
+ context.clearRect(0, 0, 4096, 4096);
1319
+ }
1320
+ /**
1321
+ *
1322
+ */
1323
+ onCalibrateClick() {
1324
+ if (this.getChoosenPlan()) {
1325
+ this.router.navigate(["/dashboard/localisation", this.spaceID, "plan-calibration"], { queryParams: { spaceID: this.spaceID } });
1326
+ }
1327
+ }
1328
+ /**
1329
+ *
1330
+ */
1331
+ onEditClick() {
1332
+ if (this.getChoosenPlan()) {
1333
+ this.router.navigate(["/dashboard/localisation", this.spaceID, "plan-edit"], { queryParams: { spaceID: this.spaceID } });
1334
+ }
1335
+ }
1336
+ onUploadClick() {
1337
+ const inputFile = document.querySelector("#upload-file");
1338
+ inputFile.click();
1339
+ }
1340
+ addPlan(target) {
1341
+ this.fileToUpload = target.files[0];
1342
+ this.planForm = this.fb.group({
1343
+ name: [this.fileToUpload.name, [Validators.required]],
1344
+ zoneID: [null, [Validators.required]],
1345
+ spaceID: this.spaceID,
1346
+ isModified: false,
1347
+ calibration: "",
1348
+ });
1349
+ }
1350
+ addPlanFromCache(file, plan) {
1351
+ this.fileToUpload = file;
1352
+ this.planForm = this.fb.group({
1353
+ name: [this.fileToUpload.name, [Validators.required]],
1354
+ zoneID: [plan ? plan.zoneID : null, [Validators.required]],
1355
+ spaceID: this.spaceID,
1356
+ isModified: !!plan,
1357
+ calibration: plan && plan.isModified && plan.calibration
1358
+ ? plan.calibration
1359
+ : "",
1360
+ });
1361
+ }
1362
+ onSavePlan() {
1363
+ return __awaiter(this, void 0, void 0, function* () {
1364
+ const formValue = this.planForm.value;
1365
+ formValue.isCurrentForZone = this.isCurrentPlanForZone;
1366
+ const createdPlan = yield this.planService.createPlanWithAnnexe(formValue, this.fileToUpload);
1367
+ const filepath = yield getSignedFile(createdPlan.annexe);
1368
+ if (filepath) {
1369
+ createdPlan.filepath = filepath;
1370
+ }
1371
+ if (formValue.isCurrentForZone) {
1372
+ // set all other plans to not current
1373
+ this.planService.setAllPlansForZoneNotCurrent(createdPlan.zoneID, createdPlan.id);
1374
+ }
1375
+ this.plans.push(createdPlan);
1376
+ this.planForm = null;
1377
+ this.fileToUpload = null;
1378
+ });
1379
+ }
1380
+ onCancelUpload() {
1381
+ this.fileToUpload = null;
1382
+ this.planForm = null;
1383
+ }
1384
+ onCurrentPlanClick() {
1385
+ return __awaiter(this, void 0, void 0, function* () {
1386
+ yield this.planService.updatePlan({
1387
+ id: this.getChoosenPlan().id,
1388
+ isCurrentForZone: this.getChoosenPlan().isCurrentForZone,
1389
+ });
1390
+ if (this.getChoosenPlan().isCurrentForZone) {
1391
+ this.planService.setAllPlansForZoneNotCurrent(this.getChoosenPlan().zoneID, this.getChoosenPlan().id);
1392
+ }
1393
+ });
1394
+ }
1395
+ onDownloadClick() {
1396
+ return __awaiter(this, void 0, void 0, function* () {
1397
+ const signedFile = yield downloadFileAsObject(this.getChoosenPlan().annexe);
1398
+ if (signedFile) {
1399
+ // @ts-ignore
1400
+ downloadBlob(signedFile.Body, this.getChoosenPlan().name);
1401
+ }
1402
+ });
1403
+ }
1404
+ onDownloadAsPng() {
1405
+ return __awaiter(this, void 0, void 0, function* () {
1406
+ const canvas = document.querySelector("#canvas");
1407
+ canvas.toBlob(function (blob) {
1408
+ downloadBlob(blob, "plan-as-png.png");
1409
+ });
1410
+ });
1411
+ }
1412
+ onRemoveClick() {
1413
+ return __awaiter(this, void 0, void 0, function* () {
1414
+ const message = this.translate.instant("confirm.deletePlan");
1415
+ if (window.confirm(message)) {
1416
+ yield this.planService.deletePlan(this.getChoosenPlan());
1417
+ this.removeImage();
1418
+ this.planService.setChosenPlan(null);
1419
+ this.getPlans();
1420
+ }
1421
+ });
1422
+ }
1423
+ }
1424
+ PlansComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: PlansComponent, deps: [{ token: i1.ActivatedRoute }, { token: i1.Router }, { token: i2.SpaceService }, { token: i2.PlanService }, { token: i1$2.FormBuilder }, { token: i3.TranslateService }], target: i0.ɵɵFactoryTarget.Component });
1425
+ PlansComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: PlansComponent, selector: "lib-plans", ngImport: i0, template: "<div class=\"container-fluid\" *ngIf=\"currentSpace\" class=\"dashboard-tab\">\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"onGoBack()\"></lib-tab-navigation>\n </div>\n <div class=\"d-flex justify-content-center\" *ngIf=\"loading\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n <div class=\"mt-3\" *ngIf=\"!plans && !loading\">\n <h4 style=\"font-weight: bold;\">{{'No imported plans' | translate }}</h4>\n <p>{{'For import from 3D visit: go Virtual Visits => Import Images' | translate}}</p>\n </div>\n <div class=\"row ms-1\">\n <div ngbDropdown class=\"d-inline-block me-3\">\n <button class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\" ngbDropdownToggle>{{getChoosenPlan() ?\n getChoosenPlan().name: ('Choose Plan' | translate) }}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\n <button ngbDropdownItem *ngFor=\"let plan of plans\" (click)=\"onPlanClick(plan)\">{{plan.name }}\n </button>\n </div>\n </div>\n <div class=\"d-inline-block\" ngbDropdown #myDrop=\"ngbDropdown\">\n <button class=\"btn btn-label-file rounded-pill\" id=\"dropdownManual\" ngbDropdownToggle>{{'Choose action' |\n translate}}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownManual\">\n <button (click)=\"onCalibrateClick()\" ngbDropdownItem [disabled]=\"!getChoosenPlan()\">{{'Calibrate' |\n translate}}</button>\n <button (click)=\"onEditClick()\" ngbDropdownItem [disabled]=\"!getChoosenPlan()\">{{'Edit plan' |\n translate}}\n </button>\n <button (click)=\"onUploadClick()\" ngbDropdownItem>{{'Upload new plan' | translate}}</button>\n <button (click)=\"onDownloadClick()\" ngbDropdownItem [disabled]=\"!getChoosenPlan()\">{{'Download plan' |\n translate}}</button>\n <button (click)=\"onRemoveClick()\" ngbDropdownItem\n [disabled]=\"!getChoosenPlan() || getChoosenPlan().isImportedMatterport\">{{'Delete plan' |\n translate}}</button>\n <!-- <button (click)=\"onDownloadAsPng()\" ngbDropdownItem [disabled]=\"!getChoosenPlan()\">\n {{'Download plan as PNG' | translate}}</button> -->\n </div>\n </div>\n </div>\n <div class=\"row mt-3 ms-0\">\n <h4 *ngIf=\"fileToUpload\">{{'New plan' | translate }}</h4>\n <input class=\"hidden\" type=\"file\" id=\"upload-file\" name=\"upload-file\" accept=\"image/png, image/jpeg, .pdf, .svg\"\n ngf-max-size=\"6MB\" (change)=\"addPlan($event.target)\">\n </div>\n <div class=\"col-md-6 mt-3\" *ngIf=\"planForm\">\n <form (ngSubmit)=\"onSavePlan()\" [formGroup]=\"planForm\">\n <div class=\"mb-3 row\">\n <label class=\"col-sm-3\">{{'Name' | translate}} </label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"name\">\n </div>\n </div>\n <div class=\"mb-3 row\">\n <label class=\"col-sm-3\">{{'Zone' | translate}} </label>\n <div class=\"col-sm-9\">\n <select class=\"form-control\" formControlName=\"zoneID\">\n <option *ngFor=\"let zone of zones\" [ngValue]=\"zone.id\">\n {{ zone.name }}\n </option>\n </select>\n </div>\n </div>\n <div class=\"mb-3 row\">\n <label class=\"col-sm-3\">{{'Set as current plan for zone' | translate}}</label>\n <div class=\"col-sm-3\">\n <input type=\"checkbox\" [(ngModel)]=\"isCurrentPlanForZone\" [ngModelOptions]=\"{standalone: true}\">\n </div>\n </div>\n <button [disabled]=\"planForm.invalid\" type='submit' class=\"btn btn-label-file rounded-pill\">{{'Save' |\n translate}}</button>\n <button class=\"btn btn-label-file rounded-pill ms-3\" type=\"button\" (click)=\"onCancelUpload()\">{{'Cancel' |\n translate}}</button>\n </form>\n </div>\n <ul class=\"col-md-6 list-group list-group-flush\" *ngIf=\"getChoosenPlan()\">\n <li class=\"list-group-item bg-transparent\">{{'Name' | translate }} : {{getChoosenPlan().name}} </li>\n <li class=\"list-group-item bg-transparent\"> {{'Plan is ' | translate }} :\n {{getChoosenPlan().calibration ? ('Calibrated' | translate) : ('Not calibrated' | translate)}}</li>\n <li class=\"list-group-item bg-transparent\">{{'Attributed to zone ' | translate }} :\n {{getChoosenPlan().zone ? getChoosenPlan().zone.name : 'None'}}</li>\n <li class=\"list-group-item bg-transparent\">{{'Is current plan for zone ' | translate }} :\n <input type=\"checkbox\" [(ngModel)]=\"getChoosenPlan().isCurrentForZone\" (change)=\"onCurrentPlanClick()\">\n </li>\n\n </ul>\n\n <div class=\"row mt-4\">\n <div class=\"col-md-10\">\n <embed *ngIf=\"getChoosenPlan() && chosenPlanIsPdf\" [src]=\"getChoosenPlan().filepath | safeUrl\"\n type=\"application/pdf\" frameBorder=\"0\" scrolling=\"auto\" height=\"650px;\" width=\"100%\" />\n <div *ngIf=\"!chosenPlanIsPdf\" class=\"row\" style=\"height: 500px; overflow: hidden;\" id=\"canvasDiv\">\n <canvas id=\"canvas\" width=\"4096px\" height=\"4096px\">\n <!-- <img *ngIf=\"chosenPlan\" id=\"plan-image\" [src]=\"chosenPlan.filepath\" style=\"width: 100%;\"> -->\n </canvas>\n\n </div>\n </div>\n </div>\n</div>\n", 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}.hidden{visibility:hidden;width:1px;height:1px}\n"], components: [{ type: TabNavigationComponent, selector: "lib-tab-navigation", inputs: ["menuItems"], outputs: ["onGoBack"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgbDropdown, selector: "[ngbDropdown]", inputs: ["autoClose", "dropdownClass", "open", "placement", "container", "display"], outputs: ["openChange"], exportAs: ["ngbDropdown"] }, { type: i7.NgbDropdownToggle, selector: "[ngbDropdownToggle]" }, { type: i7.NgbDropdownMenu, selector: "[ngbDropdownMenu]" }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgbDropdownItem, selector: "[ngbDropdownItem]", inputs: ["disabled"] }, { type: i1$2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1$2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1$2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i1$2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i1$2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i1$2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i1$2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { type: i1$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], pipes: { "translate": i3.TranslatePipe, "safeUrl": i2.SafeUrlPipe } });
1426
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: PlansComponent, decorators: [{
1427
+ type: Component,
1428
+ args: [{ selector: 'lib-plans', template: "<div class=\"container-fluid\" *ngIf=\"currentSpace\" class=\"dashboard-tab\">\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"onGoBack()\"></lib-tab-navigation>\n </div>\n <div class=\"d-flex justify-content-center\" *ngIf=\"loading\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n <div class=\"mt-3\" *ngIf=\"!plans && !loading\">\n <h4 style=\"font-weight: bold;\">{{'No imported plans' | translate }}</h4>\n <p>{{'For import from 3D visit: go Virtual Visits => Import Images' | translate}}</p>\n </div>\n <div class=\"row ms-1\">\n <div ngbDropdown class=\"d-inline-block me-3\">\n <button class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\" ngbDropdownToggle>{{getChoosenPlan() ?\n getChoosenPlan().name: ('Choose Plan' | translate) }}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\n <button ngbDropdownItem *ngFor=\"let plan of plans\" (click)=\"onPlanClick(plan)\">{{plan.name }}\n </button>\n </div>\n </div>\n <div class=\"d-inline-block\" ngbDropdown #myDrop=\"ngbDropdown\">\n <button class=\"btn btn-label-file rounded-pill\" id=\"dropdownManual\" ngbDropdownToggle>{{'Choose action' |\n translate}}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownManual\">\n <button (click)=\"onCalibrateClick()\" ngbDropdownItem [disabled]=\"!getChoosenPlan()\">{{'Calibrate' |\n translate}}</button>\n <button (click)=\"onEditClick()\" ngbDropdownItem [disabled]=\"!getChoosenPlan()\">{{'Edit plan' |\n translate}}\n </button>\n <button (click)=\"onUploadClick()\" ngbDropdownItem>{{'Upload new plan' | translate}}</button>\n <button (click)=\"onDownloadClick()\" ngbDropdownItem [disabled]=\"!getChoosenPlan()\">{{'Download plan' |\n translate}}</button>\n <button (click)=\"onRemoveClick()\" ngbDropdownItem\n [disabled]=\"!getChoosenPlan() || getChoosenPlan().isImportedMatterport\">{{'Delete plan' |\n translate}}</button>\n <!-- <button (click)=\"onDownloadAsPng()\" ngbDropdownItem [disabled]=\"!getChoosenPlan()\">\n {{'Download plan as PNG' | translate}}</button> -->\n </div>\n </div>\n </div>\n <div class=\"row mt-3 ms-0\">\n <h4 *ngIf=\"fileToUpload\">{{'New plan' | translate }}</h4>\n <input class=\"hidden\" type=\"file\" id=\"upload-file\" name=\"upload-file\" accept=\"image/png, image/jpeg, .pdf, .svg\"\n ngf-max-size=\"6MB\" (change)=\"addPlan($event.target)\">\n </div>\n <div class=\"col-md-6 mt-3\" *ngIf=\"planForm\">\n <form (ngSubmit)=\"onSavePlan()\" [formGroup]=\"planForm\">\n <div class=\"mb-3 row\">\n <label class=\"col-sm-3\">{{'Name' | translate}} </label>\n <div class=\"col-sm-9\">\n <input type=\"text\" class=\"form-control\" formControlName=\"name\">\n </div>\n </div>\n <div class=\"mb-3 row\">\n <label class=\"col-sm-3\">{{'Zone' | translate}} </label>\n <div class=\"col-sm-9\">\n <select class=\"form-control\" formControlName=\"zoneID\">\n <option *ngFor=\"let zone of zones\" [ngValue]=\"zone.id\">\n {{ zone.name }}\n </option>\n </select>\n </div>\n </div>\n <div class=\"mb-3 row\">\n <label class=\"col-sm-3\">{{'Set as current plan for zone' | translate}}</label>\n <div class=\"col-sm-3\">\n <input type=\"checkbox\" [(ngModel)]=\"isCurrentPlanForZone\" [ngModelOptions]=\"{standalone: true}\">\n </div>\n </div>\n <button [disabled]=\"planForm.invalid\" type='submit' class=\"btn btn-label-file rounded-pill\">{{'Save' |\n translate}}</button>\n <button class=\"btn btn-label-file rounded-pill ms-3\" type=\"button\" (click)=\"onCancelUpload()\">{{'Cancel' |\n translate}}</button>\n </form>\n </div>\n <ul class=\"col-md-6 list-group list-group-flush\" *ngIf=\"getChoosenPlan()\">\n <li class=\"list-group-item bg-transparent\">{{'Name' | translate }} : {{getChoosenPlan().name}} </li>\n <li class=\"list-group-item bg-transparent\"> {{'Plan is ' | translate }} :\n {{getChoosenPlan().calibration ? ('Calibrated' | translate) : ('Not calibrated' | translate)}}</li>\n <li class=\"list-group-item bg-transparent\">{{'Attributed to zone ' | translate }} :\n {{getChoosenPlan().zone ? getChoosenPlan().zone.name : 'None'}}</li>\n <li class=\"list-group-item bg-transparent\">{{'Is current plan for zone ' | translate }} :\n <input type=\"checkbox\" [(ngModel)]=\"getChoosenPlan().isCurrentForZone\" (change)=\"onCurrentPlanClick()\">\n </li>\n\n </ul>\n\n <div class=\"row mt-4\">\n <div class=\"col-md-10\">\n <embed *ngIf=\"getChoosenPlan() && chosenPlanIsPdf\" [src]=\"getChoosenPlan().filepath | safeUrl\"\n type=\"application/pdf\" frameBorder=\"0\" scrolling=\"auto\" height=\"650px;\" width=\"100%\" />\n <div *ngIf=\"!chosenPlanIsPdf\" class=\"row\" style=\"height: 500px; overflow: hidden;\" id=\"canvasDiv\">\n <canvas id=\"canvas\" width=\"4096px\" height=\"4096px\">\n <!-- <img *ngIf=\"chosenPlan\" id=\"plan-image\" [src]=\"chosenPlan.filepath\" style=\"width: 100%;\"> -->\n </canvas>\n\n </div>\n </div>\n </div>\n</div>\n", 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}.hidden{visibility:hidden;width:1px;height:1px}\n"] }]
1429
+ }], ctorParameters: function () { return [{ type: i1.ActivatedRoute }, { type: i1.Router }, { type: i2.SpaceService }, { type: i2.PlanService }, { type: i1$2.FormBuilder }, { type: i3.TranslateService }]; } });
1430
+
1431
+ class ChevronComponent {
1432
+ constructor() {
1433
+ this.conditionShowing = false;
1434
+ }
1435
+ ngOnInit() {
1436
+ }
1437
+ }
1438
+ ChevronComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ChevronComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1439
+ ChevronComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: ChevronComponent, selector: "lib-chevron", inputs: { conditionShowing: "conditionShowing" }, ngImport: i0, template: "<div style=\"height: 30px; width: 30px;\">\n <span class=\"icon-container\" >\n <div [class]=\"conditionShowing ? 'icon-img-up' : 'icon-img-down'\"></div>\n </span>\n</div>\n", styles: [".icon-container{height:30px;width:30px}.icon-img-down{width:30px;height:100%;background:url(https://api.iconify.design/mdi-light/chevron-right.svg?width=28) no-repeat center center/contain}.icon-img-up{width:30px;height:100%;background:url(https://api.iconify.design/mdi-light/chevron-down.svg?width=28) no-repeat center center/contain}\n"] });
1440
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ChevronComponent, decorators: [{
1441
+ type: Component,
1442
+ args: [{ selector: 'lib-chevron', template: "<div style=\"height: 30px; width: 30px;\">\n <span class=\"icon-container\" >\n <div [class]=\"conditionShowing ? 'icon-img-up' : 'icon-img-down'\"></div>\n </span>\n</div>\n", styles: [".icon-container{height:30px;width:30px}.icon-img-down{width:30px;height:100%;background:url(https://api.iconify.design/mdi-light/chevron-right.svg?width=28) no-repeat center center/contain}.icon-img-up{width:30px;height:100%;background:url(https://api.iconify.design/mdi-light/chevron-down.svg?width=28) no-repeat center center/contain}\n"] }]
1443
+ }], ctorParameters: function () { return []; }, propDecorators: { conditionShowing: [{
1444
+ type: Input
1445
+ }] } });
1446
+
1447
+ class VisitsComponent {
1448
+ constructor(fb, matterportImportService, captureService, nodeService, spaceService, route, modalService, visitService) {
1449
+ this.fb = fb;
1450
+ this.matterportImportService = matterportImportService;
1451
+ this.captureService = captureService;
1452
+ this.nodeService = nodeService;
1453
+ this.spaceService = spaceService;
1454
+ this.route = route;
1455
+ this.modalService = modalService;
1456
+ this.visitService = visitService;
1457
+ this.visitIndexDetails = -1;
1458
+ this.isEditing = false;
1459
+ this.visitSubmitted = false;
1460
+ this.currentSpace = { zones: [] };
1461
+ this.visits = [];
1462
+ this.canCancelImport = false;
1463
+ this.imagesProcessed = 0;
1464
+ this.totalImages = 0;
1465
+ this.menuItems = [];
1466
+ this.matterportImportService.importingImages.subscribe(() => {
1467
+ this.canCancelImport = true;
1468
+ });
1469
+ this.matterportImportService.sweepProcessedCount.subscribe((count) => {
1470
+ this.imagesProcessed = count + 1;
1471
+ });
1472
+ this.matterportImportService.totalSweepsCount.subscribe((count) => {
1473
+ this.totalImages = count;
1474
+ });
1475
+ }
1476
+ ngOnInit() {
1477
+ this.spaceId = this.route.snapshot.paramMap.get("id");
1478
+ this.resetVisits();
1479
+ }
1480
+ /*
1481
+ Visit = {
1482
+ captureID: string,
1483
+ model3d: string,
1484
+ takenAt: number,
1485
+ spaceID: string,
1486
+ viewer: CaptureViewer,
1487
+ surface: number,
1488
+ node: Node,
1489
+ name?: string | null
1490
+ }
1491
+ */
1492
+ setupMenuItems() {
1493
+ this.menuItems = [
1494
+ { label: "Locations", url: "/localisation" },
1495
+ {
1496
+ label: this.currentSpace.name,
1497
+ url: `/localisation/${this.currentSpace.id}`,
1498
+ },
1499
+ {
1500
+ label: "Virtual visits",
1501
+ url: `/localisation/${this.currentSpace.id}/visits`,
1502
+ },
1503
+ ];
1504
+ }
1505
+ onGoBack() {
1506
+ this.onCancel();
1507
+ }
1508
+ resetVisits() {
1509
+ return __awaiter(this, void 0, void 0, function* () {
1510
+ this.visits = [];
1511
+ this.currentSpace = yield this.spaceService.getSpace(this.spaceId);
1512
+ this.setupMenuItems();
1513
+ yield this.visitService
1514
+ .getVisitsForSpaceForUser(this.spaceId)
1515
+ .then((visits) => {
1516
+ if (visits) {
1517
+ this.visits = visits;
1518
+ }
1519
+ });
1520
+ });
1521
+ }
1522
+ initVisitForm(input = null) {
1523
+ if (input) {
1524
+ this.visitForm = this.fb.group({
1525
+ captureID: input.captureID,
1526
+ nodeID: input.node.id,
1527
+ name: [input.name, [Validators.required]],
1528
+ model3D: [input.model3d, [Validators.required]],
1529
+ viewer: input.viewer ? input.viewer : CaptureViewer.MATTERPORT,
1530
+ surface: input.surface ? input.surface : null,
1531
+ });
1532
+ this.captureDate = input.takenAt;
1533
+ }
1534
+ else {
1535
+ this.visitForm = this.fb.group({
1536
+ model3D: [null, [Validators.required]],
1537
+ viewer: CaptureViewer.MATTERPORT,
1538
+ surface: null,
1539
+ name: [null, [Validators.required]],
1540
+ });
1541
+ }
1542
+ }
1543
+ onToggleDetail(index) {
1544
+ this.visitIndexDetails = index === this.visitIndexDetails ? -1 : index;
1545
+ }
1546
+ onAddVisit() {
1547
+ this.initVisitForm();
1548
+ this.menuItems.push({ label: "New" });
1549
+ }
1550
+ onEdit(visit) {
1551
+ this.initVisitForm(visit);
1552
+ this.isEditing = true;
1553
+ this.menuItems.push({ label: visit.name });
1554
+ }
1555
+ onSubmitVisit() {
1556
+ return __awaiter(this, void 0, void 0, function* () {
1557
+ this.visitSubmitted = true;
1558
+ if (!this.visitForm.valid) {
1559
+ return;
1560
+ }
1561
+ const formValue = this.visitForm.value;
1562
+ const capture = {
1563
+ viewer: formValue.viewer,
1564
+ takenAt: this.captureDate,
1565
+ surface: formValue.surface,
1566
+ spaceID: this.currentSpace.id,
1567
+ };
1568
+ if (this.isEditing) {
1569
+ capture.id = formValue.captureID;
1570
+ yield this.captureService.updateCapture(capture);
1571
+ const node = {
1572
+ id: formValue.nodeID,
1573
+ model3D: formValue.model3D,
1574
+ metadata: formValue.name,
1575
+ };
1576
+ yield this.nodeService.updateNode(node);
1577
+ }
1578
+ else {
1579
+ let createdNode;
1580
+ yield this.captureService.createCapture(capture).then((res) => __awaiter(this, void 0, void 0, function* () {
1581
+ if (res) {
1582
+ const node = {
1583
+ model3D: formValue.model3D,
1584
+ captureID: res.id,
1585
+ metadata: formValue.name,
1586
+ };
1587
+ createdNode = yield this.nodeService.createNode(node);
1588
+ }
1589
+ }));
1590
+ // let newMetadata = this.currentSpace.metadata + "," + formValue.model3D;
1591
+ // this.spaceService.update({ id: this.spaceId, metadata: newMetadata});
1592
+ yield this.launchImport(formValue.model3D, formValue.surface, createdNode, false);
1593
+ this.modalReference.close();
1594
+ }
1595
+ yield this.resetVisits();
1596
+ this.onCancel();
1597
+ });
1598
+ }
1599
+ get model3D() {
1600
+ return this.visitForm.get("model3D");
1601
+ }
1602
+ get name() {
1603
+ return this.visitForm.get("name");
1604
+ }
1605
+ onCancel() {
1606
+ this.visitSubmitted = false;
1607
+ this.visitForm = null;
1608
+ this.isEditing = false;
1609
+ this.canCancelImport = false;
1610
+ this.totalImages = 0;
1611
+ this.imagesProcessed = 0;
1612
+ this.setupMenuItems();
1613
+ }
1614
+ onDelete(visit, index) {
1615
+ return __awaiter(this, void 0, void 0, function* () {
1616
+ yield this.visitService.deleteVisit(visit, this.spaceId);
1617
+ this.resetVisits();
1618
+ });
1619
+ }
1620
+ getDismissReason(reason) {
1621
+ if (reason === ModalDismissReasons.ESC) {
1622
+ return "by pressing ESC";
1623
+ }
1624
+ if (reason === ModalDismissReasons.BACKDROP_CLICK) {
1625
+ return "by clicking on a backdrop";
1626
+ }
1627
+ return `with: ${reason}`;
1628
+ }
1629
+ launchImport(model3D, surface, node, imagesOnly = false) {
1630
+ return __awaiter(this, void 0, void 0, function* () {
1631
+ this.modalReference = this.modalService.open(this.content, {
1632
+ ariaLabelledBy: "modal-basic-title",
1633
+ });
1634
+ this.modalReference.result.then((result) => {
1635
+ this.closeResult = `Closed with: ${result}`;
1636
+ console.log(this.closeResult);
1637
+ this.cancelImport();
1638
+ }, (error) => {
1639
+ this.closeResult = `Dismissed ${this.getDismissReason(error)}`;
1640
+ console.log(this.closeResult);
1641
+ this.cancelImport();
1642
+ });
1643
+ const sdkStarted = yield this.matterportImportService.initSdkForModel(model3D);
1644
+ yield (imagesOnly
1645
+ ? this.matterportImportService.importData(this.spaceId, surface, true, node)
1646
+ : this.matterportImportService.importData(this.spaceId, surface, false, node));
1647
+ return Promise.resolve();
1648
+ });
1649
+ }
1650
+ cancelImport() {
1651
+ this.matterportImportService.abandon();
1652
+ this.onCancel();
1653
+ this.resetVisits();
1654
+ }
1655
+ onImport(visit) {
1656
+ this.launchImport(visit.model3d, null, visit.node.id, true);
1657
+ }
1658
+ }
1659
+ VisitsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: VisitsComponent, deps: [{ token: i1$2.FormBuilder }, { token: i2.MatterportImportService }, { token: i2.CaptureService }, { token: i2.NodeService }, { token: i2.SpaceService }, { token: i1.ActivatedRoute }, { token: i7.NgbModal }, { token: i2.VisitService }], target: i0.ɵɵFactoryTarget.Component });
1660
+ VisitsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: VisitsComponent, selector: "lib-visits", viewQueries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true }], ngImport: i0, template: "<div class=\"container-fluid\" class=\"dashboard-tab\">\r\n <div class=\"m-3\">\r\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"onGoBack()\"></lib-tab-navigation>\r\n </div>\r\n\r\n <div class=\"row main-form-container\">\r\n <div class=\"col-md-6 form-container\">\r\n <ul class=\"list-group list-group-flush\" *ngIf=\"!visitForm\">\r\n <li class=\"list-group-item list-group-item-action\" *ngFor=\"let visit of visits; index as index\"\r\n (click)=\"onToggleDetail(index)\">\r\n <div class=\"d-flex justify-content-between align-items-center\">\r\n {{visit.name ? visit.name : visit.model3d }}\r\n <lib-chevron [conditionShowing]=\"index==visitIndexDetails\"></lib-chevron>\r\n </div>\r\n <div *ngIf=\"index==visitIndexDetails\">\r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item bg-transparent\">{{'Name' | translate}} : {{ visit.name ?\r\n visit.name : \"Not provided\" | translate}}</li>\r\n <li class=\"list-group-item bg-transparent\">{{'3D Model' | translate}} : {{ visit.model3d }}\r\n </li>\r\n <li class=\"list-group-item bg-transparent\">{{'Surface' | translate}}, m<sup>2</sup>: {{\r\n visit.surface ?\r\n visit.surface : 'Not provided' | translate}}</li>\r\n <li class=\"list-group-item bg-transparent\">{{'Viewer' | translate}} : {{ visit.viewer }}\r\n </li>\r\n <li class=\"list-group-item bg-transparent\">{{'Date of capture' | translate}} : {{\r\n visit.takenAt | timeDateString | async}}\r\n <li class=\"list-group-item bg-transparent\">{{'Images are imported' | translate}} : {{\r\n visit.imagesImported }}\r\n </li>\r\n </ul>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\r\n *ngIf=\"!visit.imagesImported\" (click)=\"onImport(visit)\">{{'Import images' |\r\n translate}}</button>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\r\n (click)=\"onEdit(visit)\">{{'Edit' | translate}}</button>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\"\r\n (click)=\"onDelete(visit, index)\">{{'Delete' | translate}}</button>\r\n </div>\r\n </li>\r\n </ul>\r\n <div *ngIf=\"visitForm\">\r\n <form (ngSubmit)=\"onSubmitVisit()\" [formGroup]=\"visitForm\">\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Name' | translate}}</label>\r\n <div class=\"col-sm-10\">\r\n <input type=\"text\" class=\"form-control\" formControlName=\"name\">\r\n </div>\r\n </div>\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Reference 3D model' | translate}} *</label>\r\n <div class=\"col-sm-10\">\r\n <input type=\"text\" class=\"form-control\" [readonly]=\"isEditing\"\r\n [class.is-invalid]=\"model3D.invalid && visitSubmitted\" required\r\n formControlName=\"model3D\">\r\n <div class=\"invalid-feedback\">\r\n {{'Please provide the 3D model reference' | translate}}\r\n </div>\r\n <div *ngIf=\"isEditing\" class=\"text-danger\">\r\n {{'Cannot change 3D model reference. Please add new model.' | translate}}\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Viewer' | translate}}</label>\r\n <div class=\"col-sm-10\">\r\n <input type=\"text\" class=\"form-control\" formControlName=\"viewer\">\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Surface' | translate}}</label>\r\n <div class=\"col-sm-10\">\r\n <input type=\"text\" class=\"form-control\" formControlName=\"surface\">\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Capture Date' | translate}}</label>\r\n <div class=\"input-group\">\r\n <input class=\"form-control\" placeholder=\"dd/mm/yyyy\" [(ngModel)]=\"captureDate\" ngbDatepicker\r\n #d1=\"ngbDatepicker\" [ngModelOptions]=\"{standalone: true}\">\r\n <div class=\"input-group-append\">\r\n <button class=\"btn btn-outline-secondary calendar\" (click)=\"d1.toggle()\"\r\n type=\"button\"></button>\r\n </div>\r\n </div>\r\n </div>\r\n <button type=\"submit\" class=\"btn btn-outline-primary rounded-pill me-2\">{{'Save' |\r\n translate}}</button>\r\n <button type=\"button\" (click)=\"onCancel()\" class=\"btn btn-outline-primary rounded-pill\">{{'Cancel' |\r\n translate}}</button>\r\n </form>\r\n </div>\r\n <div *ngIf=\"!visitForm\">\r\n <button class=\"btn btn-outline-primary rounded-pill\" (click)=\"onAddVisit()\">{{'Add 3D visit' |\r\n translate}}</button>\r\n </div>\r\n </div>\r\n <div id=\"viewer-frame\" style=\"width: 100%; aspect-ratio: 2/1;\"></div>\r\n </div>\r\n <ng-template #content let-modal>\r\n <div class=\"modal-header\">\r\n <h4 class=\"modal-title\" id=\"modal-basic-title\">{{'Importing Data' | translate}}</h4>\r\n <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"modal.dismiss('Cross click')\">\r\n <span aria-hidden=\"true\">\u00D7</span>\r\n </button>\r\n </div>\r\n <div class=\"modal-body\">\r\n {{'Please do not leave or refresh this page...' | translate}}\r\n <div *ngIf=\"totalImages != 0\">Imported {{imagesProcessed}} out of {{totalImages}} images.</div>\r\n <div class=\"d-flex justify-content-center\">\r\n <div class=\"spinner-border\" role=\"status\">\r\n <span class=\"visually-hidden\">{{'Loading' | translate}}...</span>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"modal-footer\">\r\n <button type=\"button\" class=\"btn btn-outline-dark\" [disabled]=\"!canCancelImport\"\r\n (click)=\"modal.close('Cancel click')\">{{'Cancel import of images' | translate}}</button>\r\n </div>\r\n </ng-template>\r\n</div>", styles: [".col-form-label{width:180px;margin-bottom:1rem}.btn-outline-primary{width:200px;margin-right:1rem}.input-group{width:83%;height:-moz-fit-content;height:fit-content}.main-form-container{width:60vw;display:flex;flex-direction:column}@media screen and (max-width: 765px){.main-form-container{width:90vw}}.main-form-container .form-container{width:100%}\n"], components: [{ type: TabNavigationComponent, selector: "lib-tab-navigation", inputs: ["menuItems"], outputs: ["onGoBack"] }, { type: ChevronComponent, selector: "lib-chevron", inputs: ["conditionShowing"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1$2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1$2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1$2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i1$2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i7.NgbInputDatepicker, selector: "input[ngbDatepicker]", inputs: ["autoClose", "datepickerClass", "dayTemplate", "dayTemplateData", "displayMonths", "firstDayOfWeek", "footerTemplate", "markDisabled", "minDate", "maxDate", "navigation", "outsideDays", "placement", "restoreFocus", "showWeekNumbers", "startDate", "container", "positionTarget", "weekdays", "disabled"], outputs: ["dateSelect", "navigate", "closed"], exportAs: ["ngbDatepicker"] }, { type: i1$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], pipes: { "translate": i3.TranslatePipe, "async": i5.AsyncPipe, "timeDateString": i2.TimeDateToLocalStringPipe } });
1661
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: VisitsComponent, decorators: [{
1662
+ type: Component,
1663
+ args: [{ selector: 'lib-visits', template: "<div class=\"container-fluid\" class=\"dashboard-tab\">\r\n <div class=\"m-3\">\r\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"onGoBack()\"></lib-tab-navigation>\r\n </div>\r\n\r\n <div class=\"row main-form-container\">\r\n <div class=\"col-md-6 form-container\">\r\n <ul class=\"list-group list-group-flush\" *ngIf=\"!visitForm\">\r\n <li class=\"list-group-item list-group-item-action\" *ngFor=\"let visit of visits; index as index\"\r\n (click)=\"onToggleDetail(index)\">\r\n <div class=\"d-flex justify-content-between align-items-center\">\r\n {{visit.name ? visit.name : visit.model3d }}\r\n <lib-chevron [conditionShowing]=\"index==visitIndexDetails\"></lib-chevron>\r\n </div>\r\n <div *ngIf=\"index==visitIndexDetails\">\r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item bg-transparent\">{{'Name' | translate}} : {{ visit.name ?\r\n visit.name : \"Not provided\" | translate}}</li>\r\n <li class=\"list-group-item bg-transparent\">{{'3D Model' | translate}} : {{ visit.model3d }}\r\n </li>\r\n <li class=\"list-group-item bg-transparent\">{{'Surface' | translate}}, m<sup>2</sup>: {{\r\n visit.surface ?\r\n visit.surface : 'Not provided' | translate}}</li>\r\n <li class=\"list-group-item bg-transparent\">{{'Viewer' | translate}} : {{ visit.viewer }}\r\n </li>\r\n <li class=\"list-group-item bg-transparent\">{{'Date of capture' | translate}} : {{\r\n visit.takenAt | timeDateString | async}}\r\n <li class=\"list-group-item bg-transparent\">{{'Images are imported' | translate}} : {{\r\n visit.imagesImported }}\r\n </li>\r\n </ul>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\r\n *ngIf=\"!visit.imagesImported\" (click)=\"onImport(visit)\">{{'Import images' |\r\n translate}}</button>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\r\n (click)=\"onEdit(visit)\">{{'Edit' | translate}}</button>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\"\r\n (click)=\"onDelete(visit, index)\">{{'Delete' | translate}}</button>\r\n </div>\r\n </li>\r\n </ul>\r\n <div *ngIf=\"visitForm\">\r\n <form (ngSubmit)=\"onSubmitVisit()\" [formGroup]=\"visitForm\">\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Name' | translate}}</label>\r\n <div class=\"col-sm-10\">\r\n <input type=\"text\" class=\"form-control\" formControlName=\"name\">\r\n </div>\r\n </div>\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Reference 3D model' | translate}} *</label>\r\n <div class=\"col-sm-10\">\r\n <input type=\"text\" class=\"form-control\" [readonly]=\"isEditing\"\r\n [class.is-invalid]=\"model3D.invalid && visitSubmitted\" required\r\n formControlName=\"model3D\">\r\n <div class=\"invalid-feedback\">\r\n {{'Please provide the 3D model reference' | translate}}\r\n </div>\r\n <div *ngIf=\"isEditing\" class=\"text-danger\">\r\n {{'Cannot change 3D model reference. Please add new model.' | translate}}\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Viewer' | translate}}</label>\r\n <div class=\"col-sm-10\">\r\n <input type=\"text\" class=\"form-control\" formControlName=\"viewer\">\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Surface' | translate}}</label>\r\n <div class=\"col-sm-10\">\r\n <input type=\"text\" class=\"form-control\" formControlName=\"surface\">\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Capture Date' | translate}}</label>\r\n <div class=\"input-group\">\r\n <input class=\"form-control\" placeholder=\"dd/mm/yyyy\" [(ngModel)]=\"captureDate\" ngbDatepicker\r\n #d1=\"ngbDatepicker\" [ngModelOptions]=\"{standalone: true}\">\r\n <div class=\"input-group-append\">\r\n <button class=\"btn btn-outline-secondary calendar\" (click)=\"d1.toggle()\"\r\n type=\"button\"></button>\r\n </div>\r\n </div>\r\n </div>\r\n <button type=\"submit\" class=\"btn btn-outline-primary rounded-pill me-2\">{{'Save' |\r\n translate}}</button>\r\n <button type=\"button\" (click)=\"onCancel()\" class=\"btn btn-outline-primary rounded-pill\">{{'Cancel' |\r\n translate}}</button>\r\n </form>\r\n </div>\r\n <div *ngIf=\"!visitForm\">\r\n <button class=\"btn btn-outline-primary rounded-pill\" (click)=\"onAddVisit()\">{{'Add 3D visit' |\r\n translate}}</button>\r\n </div>\r\n </div>\r\n <div id=\"viewer-frame\" style=\"width: 100%; aspect-ratio: 2/1;\"></div>\r\n </div>\r\n <ng-template #content let-modal>\r\n <div class=\"modal-header\">\r\n <h4 class=\"modal-title\" id=\"modal-basic-title\">{{'Importing Data' | translate}}</h4>\r\n <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"modal.dismiss('Cross click')\">\r\n <span aria-hidden=\"true\">\u00D7</span>\r\n </button>\r\n </div>\r\n <div class=\"modal-body\">\r\n {{'Please do not leave or refresh this page...' | translate}}\r\n <div *ngIf=\"totalImages != 0\">Imported {{imagesProcessed}} out of {{totalImages}} images.</div>\r\n <div class=\"d-flex justify-content-center\">\r\n <div class=\"spinner-border\" role=\"status\">\r\n <span class=\"visually-hidden\">{{'Loading' | translate}}...</span>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"modal-footer\">\r\n <button type=\"button\" class=\"btn btn-outline-dark\" [disabled]=\"!canCancelImport\"\r\n (click)=\"modal.close('Cancel click')\">{{'Cancel import of images' | translate}}</button>\r\n </div>\r\n </ng-template>\r\n</div>", styles: [".col-form-label{width:180px;margin-bottom:1rem}.btn-outline-primary{width:200px;margin-right:1rem}.input-group{width:83%;height:-moz-fit-content;height:fit-content}.main-form-container{width:60vw;display:flex;flex-direction:column}@media screen and (max-width: 765px){.main-form-container{width:90vw}}.main-form-container .form-container{width:100%}\n"] }]
1664
+ }], ctorParameters: function () { return [{ type: i1$2.FormBuilder }, { type: i2.MatterportImportService }, { type: i2.CaptureService }, { type: i2.NodeService }, { type: i2.SpaceService }, { type: i1.ActivatedRoute }, { type: i7.NgbModal }, { type: i2.VisitService }]; }, propDecorators: { content: [{
1665
+ type: ViewChild,
1666
+ args: ["content", { static: false }]
1667
+ }] } });
1668
+
1669
+ class CarouselComponent {
1670
+ constructor() {
1671
+ this.currentScan = new EventEmitter();
1672
+ }
1673
+ ngOnInit() {
1674
+ this.currentScan.emit(0);
1675
+ }
1676
+ onSlide(event) {
1677
+ this.dataEvent = JSON.stringify(event);
1678
+ const imageIndex = Number.parseInt(event.current.replace("slideId_", ""), 10);
1679
+ this.currentScan.emit(imageIndex);
1680
+ }
1681
+ }
1682
+ CarouselComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CarouselComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1683
+ CarouselComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: CarouselComponent, selector: "lib-carousel", inputs: { images: "images" }, outputs: { currentScan: "currentScan" }, ngImport: i0, template: "<ngb-carousel [interval]=\"5000\" *ngIf=\"images && images.length > 1\" (slide)=\"onSlide($event)\">\n <ng-template *ngFor=\"let image of images; let i = index\" ngbSlide [id]=\"'slideId_' + i\">\n <div class=\"picsum-img-wrapper\">\n <img [src]=\"image.path\" alt=\"Scan\" class=\"d-block w-100\">\n </div>\n <div class=\"carousel-caption\">\n <h3>{{image.title}}</h3>\n <p>{{image.description}}</p>\n </div>\n </ng-template>\n</ngb-carousel>\n\n<img *ngIf=\"images.length === 1\" [src]=\"images[0].path\" alt=\"Scan\" class=\"d-block w-100\">\n", styles: [""], components: [{ type: i7.NgbCarousel, selector: "ngb-carousel", inputs: ["animation", "activeId", "interval", "wrap", "keyboard", "pauseOnHover", "pauseOnFocus", "showNavigationArrows", "showNavigationIndicators"], outputs: ["slide", "slid"], exportAs: ["ngbCarousel"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgbSlide, selector: "ng-template[ngbSlide]", inputs: ["id"], outputs: ["slid"] }] });
1684
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CarouselComponent, decorators: [{
1685
+ type: Component,
1686
+ args: [{ selector: 'lib-carousel', template: "<ngb-carousel [interval]=\"5000\" *ngIf=\"images && images.length > 1\" (slide)=\"onSlide($event)\">\n <ng-template *ngFor=\"let image of images; let i = index\" ngbSlide [id]=\"'slideId_' + i\">\n <div class=\"picsum-img-wrapper\">\n <img [src]=\"image.path\" alt=\"Scan\" class=\"d-block w-100\">\n </div>\n <div class=\"carousel-caption\">\n <h3>{{image.title}}</h3>\n <p>{{image.description}}</p>\n </div>\n </ng-template>\n</ngb-carousel>\n\n<img *ngIf=\"images.length === 1\" [src]=\"images[0].path\" alt=\"Scan\" class=\"d-block w-100\">\n", styles: [""] }]
1687
+ }], ctorParameters: function () { return []; }, propDecorators: { images: [{
1688
+ type: Input
1689
+ }], currentScan: [{
1690
+ type: Output
1691
+ }] } });
1692
+
1693
+ class SelectionComponent {
1694
+ constructor() {
1695
+ /**Emit a new selection */
1696
+ this.onSelectionChanged = new EventEmitter();
1697
+ this.isMousedown = false;
1698
+ this.selection = { startX: 0, startY: 0, endX: 0, endY: 0 };
1699
+ this.selectionRectangle = { top: 0, left: 0, width: 0, height: 0 };
1700
+ }
1701
+ ngOnInit() {
1702
+ this.selectionableZone = document.querySelector(".selectZone");
1703
+ this.selectionElement = document.querySelector("#selection");
1704
+ this.selectionableZone.addEventListener("mousedown", this.mousedown.bind(this));
1705
+ this.selectionableZone.addEventListener("mousemove", this.mousemove.bind(this));
1706
+ this.selectionableZone.addEventListener("mouseup", this.mouseup.bind(this));
1707
+ }
1708
+ /**
1709
+ * Update the current selection
1710
+ * Will update the selectionRectangle and Selection HTML element
1711
+ * @param shouldEmit if true an event will be emitted through onSelectionChanged (true by default)
1712
+ */
1713
+ updateSelectionElement(shouldEmit = true) {
1714
+ this.selectionRectangle.width = Math.abs(this.selection.endX - this.selection.startX);
1715
+ this.selectionRectangle.height = Math.abs(this.selection.endY - this.selection.startY);
1716
+ this.selectionRectangle.top = Math.min(this.selection.endY, this.selection.startY);
1717
+ this.selectionRectangle.left = Math.min(this.selection.endX, this.selection.startX);
1718
+ this.selectionElement.style.top = `${this.selectionRectangle.top}px`;
1719
+ this.selectionElement.style.left = `${this.selectionRectangle.left}px`;
1720
+ this.selectionElement.style.width = `${this.selectionRectangle.width}px`;
1721
+ this.selectionElement.style.height = `${this.selectionRectangle.height}px`;
1722
+ if (shouldEmit) {
1723
+ this.onSelectionChanged.emit(this.selectionRectangle);
1724
+ }
1725
+ }
1726
+ /**
1727
+ * Trigger when mouse is press down on selectionableZone
1728
+ * @param event
1729
+ */
1730
+ mousedown(event) {
1731
+ if (event.button !== 2) { /**Selection with the right click, so ignore all other event */
1732
+ return;
1733
+ }
1734
+ this.isMousedown = true;
1735
+ this.selection = { startY: event.clientY, startX: event.clientX, endX: event.clientX, endY: event.clientY };
1736
+ this.updateSelectionElement();
1737
+ }
1738
+ /**
1739
+ * Trigger when mouse is release on selectionableZone
1740
+ * @param event
1741
+ */
1742
+ mouseup(event) {
1743
+ this.isMousedown = false;
1744
+ this.selection = { startX: 0, startY: 0, endX: 0, endY: 0 };
1745
+ this.updateSelectionElement(false);
1746
+ }
1747
+ /**
1748
+ * Trigger when mouse is moving on selectionableZone
1749
+ * @param event
1750
+ */
1751
+ mousemove(event) {
1752
+ if (this.isMousedown) {
1753
+ this.selection.endX = event.clientX;
1754
+ this.selection.endY = event.clientY;
1755
+ this.updateSelectionElement();
1756
+ }
1757
+ }
1758
+ }
1759
+ SelectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SelectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1760
+ SelectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: SelectionComponent, selector: "lib-selection", outputs: { onSelectionChanged: "onSelectionChanged" }, ngImport: i0, template: "<ng-content></ng-content>\n\n<div id=\"selection\"></div>", styles: ["#selection{will-change:top,left,width,height;top:0px;left:0px;position:fixed;display:block;margin-top:0;margin-left:0;width:0px;height:0px;background:rgba(83,182,187,.3);border-radius:.15em;border:.15em solid rgba(83,182,187,.8);pointer-events:none}\n"] });
1761
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SelectionComponent, decorators: [{
1762
+ type: Component,
1763
+ args: [{ selector: 'lib-selection', template: "<ng-content></ng-content>\n\n<div id=\"selection\"></div>", styles: ["#selection{will-change:top,left,width,height;top:0px;left:0px;position:fixed;display:block;margin-top:0;margin-left:0;width:0px;height:0px;background:rgba(83,182,187,.3);border-radius:.15em;border:.15em solid rgba(83,182,187,.8);pointer-events:none}\n"] }]
1764
+ }], ctorParameters: function () { return []; }, propDecorators: { onSelectionChanged: [{
1765
+ type: Output
1766
+ }] } });
1767
+
1768
+ class AddZoneComponent {
1769
+ constructor(fb, zoneService, layerService, userService, navigationService, planService) {
1770
+ this.fb = fb;
1771
+ this.zoneService = zoneService;
1772
+ this.layerService = layerService;
1773
+ this.userService = userService;
1774
+ this.navigationService = navigationService;
1775
+ this.planService = planService;
1776
+ this.updatedZone = new EventEmitter();
1777
+ this.isMuseumVisit = false;
1778
+ this.parentZones = [];
1779
+ this.carouselIsVisible = false;
1780
+ this.isSubmitted = false;
1781
+ this.chosenScans = [];
1782
+ this.fromPlan = false;
1783
+ this.planCalibrated = false;
1784
+ this.chosenScansOnPlan = [];
1785
+ this.navIDsZoneEdit = [];
1786
+ this.zoneInitialNavCount = 0;
1787
+ /** all scan buttons Element */
1788
+ this.buttonElements = [];
1789
+ /** Scan buttons that are in the current selection */
1790
+ this.buttonsInSelection = [];
1791
+ this.zoneIsMatterportFloor = false;
1792
+ }
1793
+ ngOnInit() {
1794
+ this.parentZones = this.zones.filter((zone) => zone.layer && zone.layer.name === "FLOOR");
1795
+ this.parentZones.unshift(this.defaultZone);
1796
+ this.initZoneForm();
1797
+ this.updateLayers();
1798
+ this.getPlans();
1799
+ }
1800
+ ngOnChanges() {
1801
+ this.initZoneForm();
1802
+ if (this.newZoneData)
1803
+ this.iniPlanForDraw();
1804
+ }
1805
+ updateLayers() {
1806
+ return __awaiter(this, void 0, void 0, function* () {
1807
+ const mission = this.userService.currentMission(this.spaceID);
1808
+ this.currentOrgId = mission.organisationID;
1809
+ this.layers = yield this.layerService.getLayerForOrganisation(this.currentOrgId);
1810
+ });
1811
+ }
1812
+ initZoneForm() {
1813
+ return __awaiter(this, void 0, void 0, function* () {
1814
+ if (this.zoneEdit) {
1815
+ if (this.zoneEdit.metadata) {
1816
+ const metadata = JSON.parse(this.zoneEdit.metadata);
1817
+ this.zoneIsMatterportFloor = metadata.hasOwnProperty("matterportFloorSequence");
1818
+ }
1819
+ const isVirtual = this.zoneService.zoneIsVirtual(this.zoneEdit);
1820
+ if (!isVirtual) {
1821
+ yield this.loadNavigations();
1822
+ }
1823
+ this.isMuseumVisit = this.zoneEdit.isMuseumVisitZone
1824
+ ? this.zoneEdit.isMuseumVisitZone
1825
+ : false;
1826
+ this.zoneForm = this.fb.group({
1827
+ id: this.zoneEdit.id,
1828
+ name: [this.zoneEdit.name, [Validators.required]],
1829
+ layerID: this.zoneEdit.layer ? this.zoneEdit.layer.id : null,
1830
+ surface: this.zoneEdit.surface ? this.zoneEdit.surface : 0,
1831
+ parentID: this.zoneEdit.parentID,
1832
+ parent: this.zoneEdit.parent,
1833
+ newLayer: null,
1834
+ isMuseumVisitZone: this.isMuseumVisit,
1835
+ });
1836
+ }
1837
+ else {
1838
+ const mainZone = this.zones.find((z) => !z.parentID);
1839
+ this.zoneForm = this.fb.group({
1840
+ name: [
1841
+ this.newZoneData ? this.newZoneData.name : "",
1842
+ [Validators.required],
1843
+ ],
1844
+ layerID: null,
1845
+ surface: 0,
1846
+ parentID: mainZone.id,
1847
+ newLayer: null,
1848
+ isMuseumVisitZone: this.isMuseumVisit,
1849
+ });
1850
+ }
1851
+ });
1852
+ }
1853
+ getPlans() {
1854
+ return __awaiter(this, void 0, void 0, function* () {
1855
+ this.plans = yield this.planService.getSingedPlansForSpace(this.spaceID);
1856
+ });
1857
+ }
1858
+ onSubmitZone() {
1859
+ return __awaiter(this, void 0, void 0, function* () {
1860
+ this.isSubmitted = true;
1861
+ if (!this.zoneForm.valid) {
1862
+ return;
1863
+ }
1864
+ const formValue = this.zoneForm.value;
1865
+ if (formValue.newLayer) {
1866
+ yield this.createLayer(formValue.newLayer).then((layer) => {
1867
+ formValue.layerID = layer.id;
1868
+ });
1869
+ }
1870
+ if (!formValue.layerID && !this.isMuseumVisit) {
1871
+ // by defaul assign to layer: "Local" with uuid: d6138c5d-6938-49fa-a5c3-9cebde97594b
1872
+ formValue.layerID = "d6138c5d-6938-49fa-a5c3-9cebde97594b";
1873
+ }
1874
+ const zoneInput = {
1875
+ name: formValue.name,
1876
+ surface: formValue.surface,
1877
+ spaceID: this.spaceID,
1878
+ layerID: formValue.layerID,
1879
+ parentID: formValue.parentID,
1880
+ isMuseumVisitZone: this.isMuseumVisit,
1881
+ sweepIDs: [],
1882
+ };
1883
+ try {
1884
+ this.zoneForm = null;
1885
+ this.isSubmitted = false;
1886
+ if (this.zoneEdit) {
1887
+ const zoneUpdate = zoneInput;
1888
+ zoneUpdate.sweepIDs = this.zoneEdit.sweepIDs;
1889
+ zoneUpdate.id = formValue.id;
1890
+ yield this.setSweepsAndNodeForZoneInput(zoneUpdate);
1891
+ console.log(zoneUpdate);
1892
+ yield this.zoneService.updateZone(zoneUpdate);
1893
+ this.zoneEdit = null;
1894
+ this.updatedZone.emit(zoneUpdate.id);
1895
+ }
1896
+ else {
1897
+ yield this.setSweepsAndNodeForZoneInput(zoneInput);
1898
+ // console.log(zoneInput);
1899
+ yield this.zoneService
1900
+ .create(zoneInput)
1901
+ .then(zoneCreated => {
1902
+ this.updatedZone.emit(zoneCreated.id);
1903
+ });
1904
+ }
1905
+ }
1906
+ catch (error) {
1907
+ console.error(error);
1908
+ }
1909
+ });
1910
+ }
1911
+ onCancel() {
1912
+ this.isSubmitted = false;
1913
+ this.zoneForm = null;
1914
+ this.chosenScansOnPlan = [];
1915
+ this.chosenScans = [];
1916
+ this.updatedZone.emit(false);
1917
+ }
1918
+ get name() {
1919
+ return this.zoneForm.get("name");
1920
+ }
1921
+ toggleCarousel() {
1922
+ this.carouselIsVisible = true;
1923
+ this.chosenScansOnPlan = [];
1924
+ }
1925
+ togglePlan() {
1926
+ this.fromPlan = true;
1927
+ this.chosenScans = [];
1928
+ }
1929
+ onAddScan() {
1930
+ if (!this.chosenScans.includes(this.currentScanShowing)) {
1931
+ // console.log("adding scan", this.currentScanShowing);
1932
+ this.chosenScans.push(this.currentScanShowing);
1933
+ }
1934
+ else {
1935
+ alert("Scan already added!");
1936
+ }
1937
+ }
1938
+ onRemoveScanImage(scan) {
1939
+ const index = this.chosenScans.indexOf(scan);
1940
+ this.chosenScans.splice(index, 1);
1941
+ }
1942
+ onRemoveScanPlan(scan) {
1943
+ const index = this.chosenScansOnPlan.indexOf(scan);
1944
+ this.chosenScansOnPlan.splice(index, 1);
1945
+ }
1946
+ setSweepsAndNodeForZoneInput(zoneInput) {
1947
+ return __awaiter(this, void 0, void 0, function* () {
1948
+ if (this.chosenScans.length > 0 &&
1949
+ this.chosenScans.length !== this.zoneInitialNavCount &&
1950
+ !this.fromPlan) {
1951
+ // if we chose scans from the carousel
1952
+ const sweepIDs = [];
1953
+ this.chosenScans.map((scan) => __awaiter(this, void 0, void 0, function* () {
1954
+ const imageUuid = this.images360[scan].filename.split("_")[0];
1955
+ const sweepID = this.navigationIDs.find((nav) => {
1956
+ return nav.includes(imageUuid);
1957
+ });
1958
+ if (sweepID) {
1959
+ sweepIDs.push(sweepID);
1960
+ }
1961
+ }));
1962
+ zoneInput.sweepIDs = sweepIDs;
1963
+ }
1964
+ else {
1965
+ // we are not coming from gallery choice
1966
+ if (this.chosenScansOnPlan.length > 0) {
1967
+ zoneInput.sweepIDs = this.chosenScansOnPlan;
1968
+ }
1969
+ }
1970
+ if (zoneInput.sweepIDs && zoneInput.sweepIDs.length > 0) {
1971
+ const navForSweep = yield this.navigationService.getNavigationsForMatterportIDForSpace(zoneInput.sweepIDs[0], this.spaceID);
1972
+ zoneInput.nodeIDs = [navForSweep[0].nodeID];
1973
+ }
1974
+ });
1975
+ }
1976
+ createLayer(name) {
1977
+ return __awaiter(this, void 0, void 0, function* () {
1978
+ return this.layerService.createLayerForOrganisation(name, this.currentOrgId);
1979
+ });
1980
+ }
1981
+ loadNavigations() {
1982
+ return __awaiter(this, void 0, void 0, function* () {
1983
+ if (this.zoneEdit.sweepIDs.length > 0) {
1984
+ this.zoneInitialNavCount = this.zoneEdit.sweepIDs.length;
1985
+ const navList = [];
1986
+ const scansZoneEdit = [];
1987
+ yield Promise.all(this.zoneEdit.sweepIDs.map((sweepID) => __awaiter(this, void 0, void 0, function* () {
1988
+ scansZoneEdit.push(sweepID);
1989
+ const index = this.images360.findIndex((im) => {
1990
+ return im.filename.includes(sweepID.slice(0, 8));
1991
+ });
1992
+ if (index !== -1) {
1993
+ navList.push(index);
1994
+ }
1995
+ })));
1996
+ this.chosenScans = navList;
1997
+ this.navIDsZoneEdit = scansZoneEdit;
1998
+ this.chosenScansOnPlan = scansZoneEdit;
1999
+ return Promise.resolve();
2000
+ }
2001
+ return Promise.resolve();
2002
+ });
2003
+ }
2004
+ onPlanClick(plan = this.chosenPlan) {
2005
+ return __awaiter(this, void 0, void 0, function* () {
2006
+ this.chosenScansOnPlan = [];
2007
+ this.chosenPlan = plan;
2008
+ this.clearDivPlan();
2009
+ this.addScanPoints();
2010
+ });
2011
+ }
2012
+ addScanPoints() {
2013
+ return __awaiter(this, void 0, void 0, function* () {
2014
+ this.divPlan = document.querySelector("#planDiv");
2015
+ const zoneOfPlan = yield this.zoneService.getZone(this.chosenPlan.zoneID);
2016
+ const navigations = yield this.navigationService.getNavigationsForZone(zoneOfPlan);
2017
+ if (this.newZoneData)
2018
+ yield this.setScanByDraw(navigations);
2019
+ this.buttonElements = yield showScanPointsOnPlanInDiv(this.chosenPlan, this.divPlan, navigations);
2020
+ for (const element of this.buttonElements) {
2021
+ if (this.navIDsZoneEdit.length > 0 &&
2022
+ this.navIDsZoneEdit.includes(element.id) // button id is the navigation(not graph!) ids
2023
+ ) {
2024
+ this.styleButton(element, true);
2025
+ this.chosenScansOnPlan.push(element.id);
2026
+ }
2027
+ else {
2028
+ this.styleButton(element);
2029
+ }
2030
+ element.addEventListener("click", (event) => this.onButtonScanClicked(event.target));
2031
+ }
2032
+ this.panZoom = panzoom(this.divPlan, {
2033
+ bounds: true,
2034
+ boundsPadding: 0,
2035
+ maxZoom: 3.5,
2036
+ beforeMouseDown(e) {
2037
+ return (e.button === 2); /** Ignore event for right click (use for selecting) */
2038
+ },
2039
+ });
2040
+ });
2041
+ }
2042
+ /**
2043
+ * When a button representing a scan is clicked
2044
+ * @param button
2045
+ */
2046
+ onButtonScanClicked(button) {
2047
+ button.style.backgroundImage = this.buttonIsChosen(button)
2048
+ ? `url("https://api.iconify.design/mdi:close-circle-outline.svg?color=red&height=17&width=17")`
2049
+ : `url("https://api.iconify.design/mdi:adjust.svg?color=green&height=17&width=17")`;
2050
+ if (this.buttonIsChosen(button)) {
2051
+ if (!this.chosenScansOnPlan.includes(button.id)) {
2052
+ this.chosenScansOnPlan.push(button.id);
2053
+ }
2054
+ }
2055
+ else if (this.chosenScansOnPlan.includes(button.id)) {
2056
+ const index = this.chosenScansOnPlan.indexOf(button.id);
2057
+ this.chosenScansOnPlan.splice(index, 1);
2058
+ }
2059
+ }
2060
+ styleButton(button, isAdded = false) {
2061
+ button.style.backgroundImage = isAdded
2062
+ ? `url("https://api.iconify.design/mdi:adjust.svg?color=green&height=17&width=17")`
2063
+ : `url("https://api.iconify.design/mdi:close-circle-outline.svg?color=red&height=17&width=17")`;
2064
+ button.style.backgroundColor = "transparent";
2065
+ button.style.position = "absolute";
2066
+ button.style.border = "none";
2067
+ button.style.width = "17px";
2068
+ button.style.height = "17px";
2069
+ button.disabled = false;
2070
+ button.type = "button";
2071
+ }
2072
+ buttonIsChosen(button) {
2073
+ return button.style.backgroundImage.includes("adjust");
2074
+ }
2075
+ clearDivPlan() {
2076
+ if (this.divPlan)
2077
+ this.divPlan.innerHTML = "";
2078
+ }
2079
+ iniPlanForDraw() {
2080
+ this.togglePlan();
2081
+ setTimeout(() => {
2082
+ this.onPlanClick();
2083
+ }, 500);
2084
+ }
2085
+ setScanByDraw(navigations) {
2086
+ return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
2087
+ const rect = {
2088
+ width: this.newZoneData.width,
2089
+ height: this.newZoneData.height,
2090
+ };
2091
+ const img = yield getMetaForImage(this.chosenPlan.filepath);
2092
+ const { coeffX, coeffY } = getCoefficientsForImage(img, rect);
2093
+ const draw = this.newZoneData.elements;
2094
+ draw.map((element) => __awaiter(this, void 0, void 0, function* () {
2095
+ switch (element.nodeName) {
2096
+ case "rect":
2097
+ yield this.setScanInRect(coeffX, coeffY, element, navigations);
2098
+ break;
2099
+ case "ellipse":
2100
+ yield this.setScanInCircle(coeffX, coeffY, element, navigations);
2101
+ break;
2102
+ case "path":
2103
+ yield this.setScanInPolygon(coeffX, coeffY, element, navigations);
2104
+ break;
2105
+ default:
2106
+ break;
2107
+ }
2108
+ }));
2109
+ resolve();
2110
+ }));
2111
+ }
2112
+ setScanInRect(coeffX, coeffY, element, navigations) {
2113
+ return __awaiter(this, void 0, void 0, function* () {
2114
+ const calibrage = JSON.parse(this.chosenPlan.calibration);
2115
+ navigations.map((navigation) => {
2116
+ const position = JSON.parse(navigation.position);
2117
+ let navX = (calibrage.offsetX + position.x * calibrage.x) / coeffX;
2118
+ let navY = (calibrage.offsetY + position.z * calibrage.y) / coeffY;
2119
+ if (element.angle) {
2120
+ const rotatePos = this.rotate({ x: navX, y: navY }, { x: element.cx, y: element.cy }, element.angle);
2121
+ navX = rotatePos.x;
2122
+ navY = rotatePos.y;
2123
+ }
2124
+ /**
2125
+ * TODO calculer la rotation du rectangle
2126
+ */
2127
+ if (navX > element.x &&
2128
+ navX < element.x + element.width &&
2129
+ navY > element.y &&
2130
+ navY < element.y + element.height &&
2131
+ !this.navIDsZoneEdit.includes(navigation.id)) {
2132
+ this.navIDsZoneEdit.push(navigation.id);
2133
+ }
2134
+ });
2135
+ });
2136
+ } // EO
2137
+ setScanInCircle(coeffX, coeffY, element, navigations) {
2138
+ return __awaiter(this, void 0, void 0, function* () {
2139
+ const calibrage = JSON.parse(this.chosenPlan.calibration);
2140
+ navigations.map(navigation => {
2141
+ const position = JSON.parse(navigation.position);
2142
+ let navX = (calibrage.offsetX + position.x * calibrage.x) / coeffX;
2143
+ let navY = (calibrage.offsetY + position.z * calibrage.y) / coeffY;
2144
+ if (element.angle) {
2145
+ const rotatePos = this.rotate({ x: navX, y: navY }, { x: element.cx, y: element.cy }, element.angle);
2146
+ navX = rotatePos.x;
2147
+ navY = rotatePos.y;
2148
+ }
2149
+ const valueX = Math.pow(navX - element.cx, 2) / Math.pow(element.rx, 2);
2150
+ const valueY = Math.pow(navY - element.cy, 2) / Math.pow(element.ry, 2);
2151
+ const result = valueX + valueY;
2152
+ if (result <= 1 && !this.navIDsZoneEdit.includes(navigation.id)) {
2153
+ this.navIDsZoneEdit.push(navigation.id);
2154
+ }
2155
+ });
2156
+ });
2157
+ } // EO
2158
+ setScanInPolygon(coeffX, coeffY, element, navigations) {
2159
+ return __awaiter(this, void 0, void 0, function* () {
2160
+ const calibrage = JSON.parse(this.chosenPlan.calibration);
2161
+ navigations.map((navigation) => __awaiter(this, void 0, void 0, function* () {
2162
+ const position = JSON.parse(navigation.position);
2163
+ const p = {
2164
+ x: (calibrage.offsetX + position.x * calibrage.x) / coeffX,
2165
+ y: (calibrage.offsetY + position.z * calibrage.y) / coeffY,
2166
+ };
2167
+ // if (element.angle) {
2168
+ // p = this.rotate(
2169
+ // p,
2170
+ // { x: element.cx, y: element.cy },
2171
+ // element.angle,
2172
+ // );
2173
+ // }
2174
+ if ((yield this.isInPolygon(p, element.segList)) &&
2175
+ !this.navIDsZoneEdit.includes(navigation.id)) {
2176
+ this.navIDsZoneEdit.push(navigation.id);
2177
+ }
2178
+ }));
2179
+ });
2180
+ }
2181
+ isInPolygon(p, polygon) {
2182
+ return __awaiter(this, void 0, void 0, function* () {
2183
+ return new Promise((resolve) => {
2184
+ let isInside = false;
2185
+ let minX = polygon[0].x;
2186
+ let maxX = polygon[0].x;
2187
+ let minY = polygon[0].y;
2188
+ let maxY = polygon[0].y;
2189
+ for (let n = 1; n < polygon.length; n++) {
2190
+ const q = polygon[n];
2191
+ minX = Math.min(q.x, minX);
2192
+ maxX = Math.max(q.x, maxX);
2193
+ minY = Math.min(q.y, minY);
2194
+ maxY = Math.max(q.y, maxY);
2195
+ }
2196
+ if (p.x < minX || p.x > maxX || p.y < minY || p.y > maxY) {
2197
+ resolve(false);
2198
+ }
2199
+ for (let index = 0, index_ = polygon.length - 1; index < polygon.length; index_ = index++) {
2200
+ if (polygon[index].y > p.y !== polygon[index_].y > p.y &&
2201
+ p.x <
2202
+ ((polygon[index_].x - polygon[index].x) *
2203
+ (p.y - polygon[index].y)) /
2204
+ (polygon[index_].y - polygon[index].y) +
2205
+ polygon[index].x) {
2206
+ isInside = !isInside;
2207
+ }
2208
+ }
2209
+ resolve(isInside);
2210
+ });
2211
+ });
2212
+ }
2213
+ rotate(point, center, angle) {
2214
+ let xM;
2215
+ let yM;
2216
+ let x;
2217
+ let y;
2218
+ angle *= Math.PI / 180;
2219
+ xM = point.x - center.x;
2220
+ yM = point.y - center.y;
2221
+ x = xM * Math.cos(angle) + yM * Math.sin(angle) + center.x;
2222
+ y = -xM * Math.sin(angle) + yM * Math.cos(angle) + center.y;
2223
+ return { x: Math.round(x), y: Math.round(y) };
2224
+ }
2225
+ /**
2226
+ * Check if an HtmlElement is inside a selection
2227
+ * @param button HTMLElement
2228
+ * @param selection
2229
+ * @returns true if the element is inside the selection, false otherwise
2230
+ */
2231
+ buttonIsInSelection(button, selection) {
2232
+ const bounds = button.getBoundingClientRect();
2233
+ return (bounds.bottom > selection.top &&
2234
+ bounds.top < selection.top + selection.height &&
2235
+ bounds.right > selection.left &&
2236
+ bounds.left < selection.left + selection.width);
2237
+ }
2238
+ /**
2239
+ * Trigger each by the selectionComponent when selection change
2240
+ * Update the current selected scan buttons
2241
+ * @param selection new selection
2242
+ */
2243
+ onSelectionChanged(selection) {
2244
+ const unselectedButtons = [];
2245
+ const newSelectedButtons = [];
2246
+ /** For each button, decide whether will be add to selected list or unselected list */
2247
+ for (const button of this.buttonElements) {
2248
+ const isSelected = this.buttonIsInSelection(button, selection);
2249
+ if (this.buttonsInSelection.includes(button)) {
2250
+ /** If the button is already in the selected list, we check if it should be unselect */
2251
+ if (!isSelected) {
2252
+ unselectedButtons.push(button);
2253
+ }
2254
+ }
2255
+ else if (isSelected) {
2256
+ newSelectedButtons.push(button);
2257
+ }
2258
+ }
2259
+ /** Visually Update unselected list */
2260
+ for (const button of unselectedButtons) {
2261
+ this.setVisuallySelected(button, false);
2262
+ }
2263
+ /** Visually Update selected list */
2264
+ for (const button of newSelectedButtons) {
2265
+ this.setVisuallySelected(button, true);
2266
+ }
2267
+ /** Remove unselected list */
2268
+ this.buttonsInSelection = this.buttonsInSelection.filter((button) => {
2269
+ return !unselectedButtons.includes(button);
2270
+ });
2271
+ /** Add new selected buttons */
2272
+ this.buttonsInSelection = [
2273
+ ...this.buttonsInSelection,
2274
+ ...newSelectedButtons,
2275
+ ];
2276
+ }
2277
+ /**
2278
+ * Visually change the state of a scan button, a selected button is blue
2279
+ * @param button
2280
+ * @param selected if true the button will be blue, otherwise it will red or green
2281
+ */
2282
+ setVisuallySelected(button, selected) {
2283
+ if (selected) {
2284
+ /** Color in blue */
2285
+ button.style.backgroundImage = button.style.backgroundImage
2286
+ .replace("red", "blue")
2287
+ .replace("green", "blue");
2288
+ }
2289
+ else {
2290
+ /** Get back in red or green */
2291
+ const color = this.buttonIsChosen(button) ? "green" : "red";
2292
+ button.style.backgroundImage = button.style.backgroundImage.replace("blue", color);
2293
+ }
2294
+ }
2295
+ /**
2296
+ * Trigger when the user click to add the selected scans
2297
+ */
2298
+ onSelectionAdd() {
2299
+ for (const button of this.buttonsInSelection) {
2300
+ if (!this.chosenScansOnPlan.includes(button.id)) {
2301
+ this.onButtonScanClicked(button);
2302
+ }
2303
+ }
2304
+ this.onSelectionChanged({ top: 0, left: 0, width: 0, height: 0 });
2305
+ }
2306
+ /**
2307
+ * Trigger when the user click to remove the selected scans
2308
+ */
2309
+ onSelectionRemove() {
2310
+ for (const button of this.buttonsInSelection) {
2311
+ if (this.chosenScansOnPlan.includes(button.id)) {
2312
+ this.onButtonScanClicked(button);
2313
+ }
2314
+ }
2315
+ this.onSelectionChanged({ top: 0, left: 0, width: 0, height: 0 });
2316
+ }
2317
+ /**
2318
+ * Trigger when the user click to select all scans
2319
+ */
2320
+ onSelectAll() {
2321
+ this.buttonsInSelection = [...this.buttonElements];
2322
+ for (const button of this.buttonsInSelection) {
2323
+ this.setVisuallySelected(button, true);
2324
+ }
2325
+ }
2326
+ /**
2327
+ * Trigger when the user change the size of the scan points
2328
+ * @param event
2329
+ */
2330
+ onChangeScanSize(event) {
2331
+ const factor = event.target.value;
2332
+ for (const button of this.buttonElements) {
2333
+ button.style.transform = `scale(${factor})`;
2334
+ }
2335
+ }
2336
+ /**
2337
+ * Adds all sweeps of the space
2338
+ */
2339
+ onAddAll() {
2340
+ const defaultZone = this.zones.find((zone) => zone.layer && zone.layer.name === "BUILDING" && zone.sweepIDs);
2341
+ if (defaultZone) {
2342
+ this.chosenScansOnPlan = defaultZone.sweepIDs;
2343
+ this.zoneForm.get("parentID").setValue(defaultZone.id);
2344
+ }
2345
+ }
2346
+ }
2347
+ AddZoneComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: AddZoneComponent, deps: [{ token: i1$2.FormBuilder }, { token: i2.ZoneService }, { token: i2.LayerService }, { token: i2.BaseUserService }, { token: i2.NavigationService }, { token: i2.PlanService }], target: i0.ɵɵFactoryTarget.Component });
2348
+ AddZoneComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: AddZoneComponent, selector: "lib-add-zone", inputs: { zoneEdit: "zoneEdit", spaceID: "spaceID", images360: "images360", navigationIDs: "navigationIDs", zones: "zones", newZoneData: "newZoneData", chosenPlan: "chosenPlan", isMuseumVisit: "isMuseumVisit", defaultZone: "defaultZone" }, outputs: { updatedZone: "updatedZone" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"row\" *ngIf=\"zoneForm\">\r\n <div class=\"col-7\">\r\n <form (ngSubmit)=\"onSubmitZone()\" [formGroup]=\"zoneForm\">\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Name' | translate}} *</label>\r\n <div class=\"col-sm-10\">\r\n <input type=\"text\" class=\"form-control\" [class.is-invalid]=\"name.invalid && isSubmitted\" required\r\n formControlName=\"name\">\r\n <div class=\"invalid-feedback\">\r\n {{'A name is required' | translate}}\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\" *ngIf=\"!isMuseumVisit && !zoneIsMatterportFloor\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Type of zone' | translate}}</label>\r\n <div class=\"col-sm-10\">\r\n <select class=\"form-control\" formControlName=\"layerID\">\r\n <option value=\"null\" selected disabled hidden> {{ zoneEdit && zoneEdit.layer ?\r\n zoneEdit.layer.name : 'Choose type'}}</option>\r\n <option *ngFor=\"let layer of layers\" [value]=\"layer.id\">\r\n {{ layer.name }}\r\n </option>\r\n </select>\r\n <p class=\"mt-1 new-type-text\">{{'or add new type of zone' | translate }}</p>\r\n <input type=\"text\" class=\"form-control new-type-input\" formControlName=\"newLayer\">\r\n </div>\r\n </div>\r\n <!--If Editing Zone possibility to assign it to museum itinerary-->\r\n <div class=\"mb-3 row\" *ngIf=\"zoneEdit && !zoneIsMatterportFloor\">\r\n <label class=\"col-sm-2 col-form-label\">{{ 'Museum Itinerary' | translate }}</label>\r\n <div class=\"col-sm-10\">\r\n <input class=\"checkbox-apply mt-3\" type=\"checkbox\" [(ngModel)]=\"isMuseumVisit\"\r\n [ngModelOptions]=\"{standalone: true}\">\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Surface' | translate}}</label>\r\n <div class=\"col-sm-10\">\r\n <input type=\"text\" class=\"form-control\" formControlName=\"surface\">\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\" *ngIf=\"!zoneIsMatterportFloor\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Parent zone' | translate}}</label>\r\n <div class=\"col-sm-10\">\r\n <select class=\"form-control\" formControlName=\"parentID\">\r\n <option *ngFor=\"let zone of parentZones\" [ngValue]=\"zone.id\">\r\n {{ zone.name }}\r\n </option>\r\n </select>\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\" style=\"max-height: 200px; overflow: auto;\" *ngIf=\"!zoneIsMatterportFloor\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Scan Points' | translate}}</label>\r\n <!-- <p class=\"col-sm-2\" *ngIf=\"zoneEdit\">{{ zoneEdit.sweepIDs.length }} scans</p> -->\r\n <p class=\"col\" *ngIf=\"chosenScansOnPlan.length === 0 && chosenScans.length === 0\">\r\n {{'No scan points chosen' | translate}}</p>\r\n <div class=\"col-sm-5\" *ngIf=\"chosenScansOnPlan && chosenScansOnPlan.length > 0\">\r\n <p>{{ chosenScansOnPlan.length }} {{'scan points chosen' | translate}}</p>\r\n <div *ngFor=\"let scan of chosenScansOnPlan\">\r\n <div class=\"row\">\r\n <p class=\"me-2\">{{ scan | slice:0:8 }}</p>\r\n <div (click)=\"onRemoveScanPlan(scan)\" [style.cursor]=\"'pointer'\">\r\n <span class=\"iconify\" data-icon=\"mdi:trash-can-outline\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"col-sm-5\" *ngIf=\"carouselIsVisible && chosenScans && chosenScans.length > 0\">\r\n <p>{{ chosenScans.length }} {{'scan points chosen' | translate}}</p>\r\n <div *ngFor=\"let scan of chosenScans\">\r\n <div class=\"row\">\r\n <p class=\"me-2\">{{ images360[scan].filename }}</p>\r\n <div (click)=\"onRemoveScanImage(scan)\" [style.cursor]=\"'pointer'\">\r\n <span class=\"iconify\" data-icon=\"mdi:trash-can-outline\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\" *ngIf=\"!zoneIsMatterportFloor\">\r\n <div class=\"col\">\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" [disabled]=\"!plans\"\r\n (click)=\"togglePlan()\">{{'Choose scan points on plan' |\r\n translate}}</button>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"toggleCarousel()\"\r\n [disabled]=\"fromPlan || !images360 ||images360.length === 0\">\r\n {{'Choose scan points from gallery' | translate}}</button>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddAll()\"\r\n [disabled]=\"fromPlan || !images360 ||images360.length === 0\">\r\n {{'Add all scans of this space' | translate}}</button>\r\n </div>\r\n </div>\r\n\r\n <!-- <div class=\"mb-3 row\">\r\n <label class=\"col-sm-3 col-form-label\">{{'No visible scan points' | translate}}</label>\r\n <div class=\"col-sm-3\">\r\n <input class=\"checkbox-apply mt-3\" type=\"checkbox\" [(ngModel)]=\"noScanPoints\"\r\n [ngModelOptions]=\"{standalone: true}\">\r\n </div>\r\n </div> -->\r\n\r\n <div *ngIf=\"carouselIsVisible\" class=\"mb-2\">\r\n <lib-carousel *ngIf=\"images360 && images360.length > 0\" [images]=\"images360\"\r\n (currentScan)=\"currentScanShowing=$event\"></lib-carousel>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2 mt-3\"\r\n (click)=\"onAddScan()\">{{'Add to zone' | translate}}</button>\r\n </div>\r\n <div ngbDropdown class=\"row d-inline-block me-3\" *ngIf=\"fromPlan\">\r\n <div class=\"col\">\r\n <button type=\"button\" class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\"\r\n ngbDropdownToggle>{{chosenPlan ?\r\n chosenPlan.name : ('Choose Plan' | translate) }}</button>\r\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\r\n <button type=\"button\" ngbDropdownItem *ngFor=\"let plan of plans\" (click)=\"onPlanClick(plan)\"\r\n [disabled]=\"!plan.calibration\">{{ plan.name }}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mt-1\" *ngIf=\"fromPlan\">\r\n <lib-selection class=\"col-md-8\" (onSelectionChanged)=\"onSelectionChanged($event)\">\r\n <div class=\"selectZone\" oncontextmenu=\"return false;\">\r\n <div class=\"row\">\r\n <div style=\"overflow: hidden;width:100%;\">\r\n <div style=\"height: 400px; width: 100%;\" id=\"planDiv\">\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </lib-selection>\r\n\r\n <div class=\"col-md-4 scanTool\" *ngIf=\"buttonElements.length > 0\">\r\n <div class=\"row mb-5 d-inline-block\">\r\n <h2>Selection tool</h2>\r\n <div class=\"protip\">Hold right click and move your cursor to select multiple scans.</div>\r\n </div>\r\n\r\n <div class=\"row mb-4\">\r\n <div class=\"col-3\" style=\"padding:0px\">\r\n <label class=\"tool-label\" for=\"scanSize\">Scan size</label>\r\n </div>\r\n <div class=\"col-9\">\r\n <input type=\"range\" class=\"form-range\" min=\"0.001\" max=\"5\" step=\"0.01\" value=\"1\"\r\n id=\"scanSize\" (input)=\"onChangeScanSize($event)\">\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mb-4\">\r\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"onSelectAll()\">Select all scans</button>\r\n </div>\r\n\r\n <div *ngIf=\"buttonsInSelection.length > 0\" class=\"row editSelected\">\r\n <span class=\"tool-label\">Edit selected scans : </span>\r\n <button type=\"button\" class=\"btn btn-primary ms-3 me-2\" (click)=\"onSelectionAdd()\">Add</button>\r\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"onSelectionRemove()\">Remove</button>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"mt-3\">\r\n <button type=\"submit\" class=\"btn btn-outline-primary rounded-pill me-2\">{{'Save' | translate}}</button>\r\n <button type=\"button\" (click)=\"onCancel()\" class=\"btn btn-outline-primary rounded-pill me-2\">\r\n {{'Cancel' | translate}}</button>\r\n </div>\r\n </form>\r\n </div>\r\n</div>", styles: [".form-range{width:100%}.scanTool{padding-left:50px;padding-right:50px}h2{color:var(--smarterplan-primary)}.protip{color:gray}.tool-label{font-size:1.3rem}.selectZone{background-color:gray;border-radius:1rem;overflow:hidden}.col-form-label{margin-bottom:1rem}.btn-outline-primary{min-width:200px;margin-bottom:1rem;margin-right:1rem}.new-type-input{margin-bottom:1rem}.new-type-text{margin-bottom:.5rem}\n"], components: [{ type: CarouselComponent, selector: "lib-carousel", inputs: ["images"], outputs: ["currentScan"] }, { type: SelectionComponent, selector: "lib-selection", outputs: ["onSelectionChanged"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1$2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1$2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i1$2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1$2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i1$2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i1$2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i1$2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1$2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { type: i1$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i7.NgbDropdown, selector: "[ngbDropdown]", inputs: ["autoClose", "dropdownClass", "open", "placement", "container", "display"], outputs: ["openChange"], exportAs: ["ngbDropdown"] }, { type: i7.NgbDropdownToggle, selector: "[ngbDropdownToggle]" }, { type: i7.NgbDropdownMenu, selector: "[ngbDropdownMenu]" }, { type: i7.NgbDropdownItem, selector: "[ngbDropdownItem]", inputs: ["disabled"] }], pipes: { "translate": i3.TranslatePipe, "slice": i5.SlicePipe } });
2349
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: AddZoneComponent, decorators: [{
2350
+ type: Component,
2351
+ args: [{ selector: 'lib-add-zone', template: "<div class=\"row\" *ngIf=\"zoneForm\">\r\n <div class=\"col-7\">\r\n <form (ngSubmit)=\"onSubmitZone()\" [formGroup]=\"zoneForm\">\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Name' | translate}} *</label>\r\n <div class=\"col-sm-10\">\r\n <input type=\"text\" class=\"form-control\" [class.is-invalid]=\"name.invalid && isSubmitted\" required\r\n formControlName=\"name\">\r\n <div class=\"invalid-feedback\">\r\n {{'A name is required' | translate}}\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\" *ngIf=\"!isMuseumVisit && !zoneIsMatterportFloor\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Type of zone' | translate}}</label>\r\n <div class=\"col-sm-10\">\r\n <select class=\"form-control\" formControlName=\"layerID\">\r\n <option value=\"null\" selected disabled hidden> {{ zoneEdit && zoneEdit.layer ?\r\n zoneEdit.layer.name : 'Choose type'}}</option>\r\n <option *ngFor=\"let layer of layers\" [value]=\"layer.id\">\r\n {{ layer.name }}\r\n </option>\r\n </select>\r\n <p class=\"mt-1 new-type-text\">{{'or add new type of zone' | translate }}</p>\r\n <input type=\"text\" class=\"form-control new-type-input\" formControlName=\"newLayer\">\r\n </div>\r\n </div>\r\n <!--If Editing Zone possibility to assign it to museum itinerary-->\r\n <div class=\"mb-3 row\" *ngIf=\"zoneEdit && !zoneIsMatterportFloor\">\r\n <label class=\"col-sm-2 col-form-label\">{{ 'Museum Itinerary' | translate }}</label>\r\n <div class=\"col-sm-10\">\r\n <input class=\"checkbox-apply mt-3\" type=\"checkbox\" [(ngModel)]=\"isMuseumVisit\"\r\n [ngModelOptions]=\"{standalone: true}\">\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Surface' | translate}}</label>\r\n <div class=\"col-sm-10\">\r\n <input type=\"text\" class=\"form-control\" formControlName=\"surface\">\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\" *ngIf=\"!zoneIsMatterportFloor\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Parent zone' | translate}}</label>\r\n <div class=\"col-sm-10\">\r\n <select class=\"form-control\" formControlName=\"parentID\">\r\n <option *ngFor=\"let zone of parentZones\" [ngValue]=\"zone.id\">\r\n {{ zone.name }}\r\n </option>\r\n </select>\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\" style=\"max-height: 200px; overflow: auto;\" *ngIf=\"!zoneIsMatterportFloor\">\r\n <label class=\"col-sm-2 col-form-label\">{{'Scan Points' | translate}}</label>\r\n <!-- <p class=\"col-sm-2\" *ngIf=\"zoneEdit\">{{ zoneEdit.sweepIDs.length }} scans</p> -->\r\n <p class=\"col\" *ngIf=\"chosenScansOnPlan.length === 0 && chosenScans.length === 0\">\r\n {{'No scan points chosen' | translate}}</p>\r\n <div class=\"col-sm-5\" *ngIf=\"chosenScansOnPlan && chosenScansOnPlan.length > 0\">\r\n <p>{{ chosenScansOnPlan.length }} {{'scan points chosen' | translate}}</p>\r\n <div *ngFor=\"let scan of chosenScansOnPlan\">\r\n <div class=\"row\">\r\n <p class=\"me-2\">{{ scan | slice:0:8 }}</p>\r\n <div (click)=\"onRemoveScanPlan(scan)\" [style.cursor]=\"'pointer'\">\r\n <span class=\"iconify\" data-icon=\"mdi:trash-can-outline\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"col-sm-5\" *ngIf=\"carouselIsVisible && chosenScans && chosenScans.length > 0\">\r\n <p>{{ chosenScans.length }} {{'scan points chosen' | translate}}</p>\r\n <div *ngFor=\"let scan of chosenScans\">\r\n <div class=\"row\">\r\n <p class=\"me-2\">{{ images360[scan].filename }}</p>\r\n <div (click)=\"onRemoveScanImage(scan)\" [style.cursor]=\"'pointer'\">\r\n <span class=\"iconify\" data-icon=\"mdi:trash-can-outline\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"mb-3 row\" *ngIf=\"!zoneIsMatterportFloor\">\r\n <div class=\"col\">\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" [disabled]=\"!plans\"\r\n (click)=\"togglePlan()\">{{'Choose scan points on plan' |\r\n translate}}</button>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"toggleCarousel()\"\r\n [disabled]=\"fromPlan || !images360 ||images360.length === 0\">\r\n {{'Choose scan points from gallery' | translate}}</button>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddAll()\"\r\n [disabled]=\"fromPlan || !images360 ||images360.length === 0\">\r\n {{'Add all scans of this space' | translate}}</button>\r\n </div>\r\n </div>\r\n\r\n <!-- <div class=\"mb-3 row\">\r\n <label class=\"col-sm-3 col-form-label\">{{'No visible scan points' | translate}}</label>\r\n <div class=\"col-sm-3\">\r\n <input class=\"checkbox-apply mt-3\" type=\"checkbox\" [(ngModel)]=\"noScanPoints\"\r\n [ngModelOptions]=\"{standalone: true}\">\r\n </div>\r\n </div> -->\r\n\r\n <div *ngIf=\"carouselIsVisible\" class=\"mb-2\">\r\n <lib-carousel *ngIf=\"images360 && images360.length > 0\" [images]=\"images360\"\r\n (currentScan)=\"currentScanShowing=$event\"></lib-carousel>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2 mt-3\"\r\n (click)=\"onAddScan()\">{{'Add to zone' | translate}}</button>\r\n </div>\r\n <div ngbDropdown class=\"row d-inline-block me-3\" *ngIf=\"fromPlan\">\r\n <div class=\"col\">\r\n <button type=\"button\" class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\"\r\n ngbDropdownToggle>{{chosenPlan ?\r\n chosenPlan.name : ('Choose Plan' | translate) }}</button>\r\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\r\n <button type=\"button\" ngbDropdownItem *ngFor=\"let plan of plans\" (click)=\"onPlanClick(plan)\"\r\n [disabled]=\"!plan.calibration\">{{ plan.name }}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mt-1\" *ngIf=\"fromPlan\">\r\n <lib-selection class=\"col-md-8\" (onSelectionChanged)=\"onSelectionChanged($event)\">\r\n <div class=\"selectZone\" oncontextmenu=\"return false;\">\r\n <div class=\"row\">\r\n <div style=\"overflow: hidden;width:100%;\">\r\n <div style=\"height: 400px; width: 100%;\" id=\"planDiv\">\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </lib-selection>\r\n\r\n <div class=\"col-md-4 scanTool\" *ngIf=\"buttonElements.length > 0\">\r\n <div class=\"row mb-5 d-inline-block\">\r\n <h2>Selection tool</h2>\r\n <div class=\"protip\">Hold right click and move your cursor to select multiple scans.</div>\r\n </div>\r\n\r\n <div class=\"row mb-4\">\r\n <div class=\"col-3\" style=\"padding:0px\">\r\n <label class=\"tool-label\" for=\"scanSize\">Scan size</label>\r\n </div>\r\n <div class=\"col-9\">\r\n <input type=\"range\" class=\"form-range\" min=\"0.001\" max=\"5\" step=\"0.01\" value=\"1\"\r\n id=\"scanSize\" (input)=\"onChangeScanSize($event)\">\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mb-4\">\r\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"onSelectAll()\">Select all scans</button>\r\n </div>\r\n\r\n <div *ngIf=\"buttonsInSelection.length > 0\" class=\"row editSelected\">\r\n <span class=\"tool-label\">Edit selected scans : </span>\r\n <button type=\"button\" class=\"btn btn-primary ms-3 me-2\" (click)=\"onSelectionAdd()\">Add</button>\r\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"onSelectionRemove()\">Remove</button>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"mt-3\">\r\n <button type=\"submit\" class=\"btn btn-outline-primary rounded-pill me-2\">{{'Save' | translate}}</button>\r\n <button type=\"button\" (click)=\"onCancel()\" class=\"btn btn-outline-primary rounded-pill me-2\">\r\n {{'Cancel' | translate}}</button>\r\n </div>\r\n </form>\r\n </div>\r\n</div>", styles: [".form-range{width:100%}.scanTool{padding-left:50px;padding-right:50px}h2{color:var(--smarterplan-primary)}.protip{color:gray}.tool-label{font-size:1.3rem}.selectZone{background-color:gray;border-radius:1rem;overflow:hidden}.col-form-label{margin-bottom:1rem}.btn-outline-primary{min-width:200px;margin-bottom:1rem;margin-right:1rem}.new-type-input{margin-bottom:1rem}.new-type-text{margin-bottom:.5rem}\n"] }]
2352
+ }], ctorParameters: function () { return [{ type: i1$2.FormBuilder }, { type: i2.ZoneService }, { type: i2.LayerService }, { type: i2.BaseUserService }, { type: i2.NavigationService }, { type: i2.PlanService }]; }, propDecorators: { zoneEdit: [{
2353
+ type: Input
2354
+ }], spaceID: [{
2355
+ type: Input
2356
+ }], images360: [{
2357
+ type: Input
2358
+ }], navigationIDs: [{
2359
+ type: Input
2360
+ }], zones: [{
2361
+ type: Input
2362
+ }], newZoneData: [{
2363
+ type: Input
2364
+ }], updatedZone: [{
2365
+ type: Output
2366
+ }], chosenPlan: [{
2367
+ type: Input
2368
+ }], isMuseumVisit: [{
2369
+ type: Input
2370
+ }], defaultZone: [{
2371
+ type: Input
2372
+ }] } });
2373
+
2374
+ class ZonesComponent {
2375
+ constructor(route, zoneService, spaceService, visitService, navigationService, userService, planService, translate) {
2376
+ this.route = route;
2377
+ this.zoneService = zoneService;
2378
+ this.spaceService = spaceService;
2379
+ this.visitService = visitService;
2380
+ this.navigationService = navigationService;
2381
+ this.userService = userService;
2382
+ this.planService = planService;
2383
+ this.translate = translate;
2384
+ this.lotIndexDetails = -1;
2385
+ this.updatedZone = new EventEmitter();
2386
+ this.isEditingZone = false;
2387
+ this.carouselIsVisible = false;
2388
+ this.planIsVisible = false;
2389
+ this.loadingPlan = false;
2390
+ this.menuItems = [];
2391
+ this.isMuseumVisit = false;
2392
+ this.isGuide = false;
2393
+ this.isAdmin = false;
2394
+ this.floorZones = [];
2395
+ this.zonesMap = new Map();
2396
+ this.floorDetails = -1;
2397
+ this.defaultShowing = false;
2398
+ }
2399
+ ngOnInit() {
2400
+ return __awaiter(this, void 0, void 0, function* () {
2401
+ this.spaceID = this.route.snapshot.paramMap.get("id");
2402
+ this.setUserPermissions();
2403
+ this.resetZones();
2404
+ });
2405
+ }
2406
+ setUserPermissions() {
2407
+ this.isGuide = this.userService.isGuide();
2408
+ this.isAdmin = this.userService.isAdmin(this.spaceID);
2409
+ }
2410
+ setupMenuItems() {
2411
+ this.menuItems = [
2412
+ { label: "Locations", url: "/localisation" },
2413
+ {
2414
+ label: this.currentSpace.name,
2415
+ url: `/localisation/${this.spaceID}`,
2416
+ },
2417
+ {
2418
+ label: "Zones",
2419
+ url: `/localisation/${this.currentSpace.id}/zones`,
2420
+ },
2421
+ ];
2422
+ }
2423
+ onGoBack() {
2424
+ this.editCompleted(null);
2425
+ }
2426
+ ngOnChanges() {
2427
+ this.resetZones();
2428
+ }
2429
+ resetZones() {
2430
+ return __awaiter(this, void 0, void 0, function* () {
2431
+ this.isMuseumVisit = false;
2432
+ this.currentSpace = yield this.spaceService.getSpace(this.spaceID);
2433
+ this.setupMenuItems();
2434
+ this.allZones = yield this.zoneService.getZonesBySpace(this.spaceID);
2435
+ this.defaultZone = this.allZones.find((zone) => zone.layer && zone.layer.name === "BUILDING" && zone.sweepIDs);
2436
+ this.floorZones = this.allZones.filter((zone) => zone.layer && zone.layer.name === "FLOOR");
2437
+ // we add only children zones that are not Floors
2438
+ this.zonesMap.set(this.defaultZone.id, this.allZones.filter((zone) => zone.parentID === this.defaultZone.id && !this.floorZones.includes(zone)));
2439
+ for (const floor of this.floorZones) {
2440
+ this.zonesMap.set(floor.id, this.allZones.filter((zone) => zone.parentID === floor.id));
2441
+ }
2442
+ // this.zones = sortAlphabeticallyOnName(this.zones);
2443
+ this.resetNavigations();
2444
+ this.images360 = yield this.visitService.loadImagesForSpace(this.currentSpace);
2445
+ this.plans = yield this.planService.getPlansWithZonesForSpace(this.spaceID);
2446
+ this.plans = this.plans.filter((plan) => plan.isCurrentForZone);
2447
+ this.onPlansLoaded();
2448
+ });
2449
+ }
2450
+ resetNavigations() {
2451
+ this.navigations = [];
2452
+ const zonesWithSweeps = this.allZones.filter((zone) => zone.sweepIDs);
2453
+ this.navigations = [
2454
+ ...new Set(zonesWithSweeps.flatMap((zone) => zone.sweepIDs)),
2455
+ ];
2456
+ }
2457
+ onPlansLoaded() {
2458
+ return __awaiter(this, void 0, void 0, function* () {
2459
+ if (this.planIsVisible && this.currentZone) {
2460
+ this.preparePlan();
2461
+ }
2462
+ });
2463
+ }
2464
+ /**
2465
+ * onToggleDetail folds/unfolds details for a zone
2466
+ * @param i index of the lot to be toggled
2467
+ */
2468
+ onToggleDetail(index, zone) {
2469
+ return __awaiter(this, void 0, void 0, function* () {
2470
+ this.lotIndexDetails = index === this.lotIndexDetails ? -1 : index;
2471
+ if (this.lotIndexDetails === -1) {
2472
+ return;
2473
+ }
2474
+ this.currentZone = zone;
2475
+ this.planIsVisible = true;
2476
+ if (!this.plans) {
2477
+ return; // wait until the plans are set
2478
+ }
2479
+ if (this.loadingPlan) {
2480
+ // another plan is already loading
2481
+ yield wait(1000);
2482
+ }
2483
+ this.preparePlan();
2484
+ });
2485
+ }
2486
+ onToggleDetailFloor(index, floor) {
2487
+ this.defaultShowing = false;
2488
+ this.floorDetails = index === this.floorDetails ? -1 : index;
2489
+ if (this.floorDetails === -1) {
2490
+ return;
2491
+ }
2492
+ this.currentZone = floor;
2493
+ this.planIsVisible = true;
2494
+ if (!this.plans) {
2495
+ console.log("plans not ready");
2496
+ return; // wait until the plans are set
2497
+ }
2498
+ this.preparePlan();
2499
+ }
2500
+ onToggleDefaultZone() {
2501
+ this.defaultShowing = !this.defaultShowing;
2502
+ this.currentZone = this.defaultShowing ? this.defaultZone : null;
2503
+ }
2504
+ preparePlan() {
2505
+ return __awaiter(this, void 0, void 0, function* () {
2506
+ this.loadingPlan = true;
2507
+ this.currentPlan = null;
2508
+ if (this.currentZone.virtual) {
2509
+ this.currentPlan = null;
2510
+ this.loadingPlan = false;
2511
+ return;
2512
+ }
2513
+ this.currentPlan = yield this.planService.getCalibratedPlanForZone(this.currentZone);
2514
+ if (this.currentPlan) {
2515
+ const scans = yield this.navigationService.getNavigationsForZone(this.currentZone);
2516
+ yield this.showScanPointsOnPlan(scans);
2517
+ }
2518
+ this.loadingPlan = false;
2519
+ });
2520
+ }
2521
+ toggleCarousel() {
2522
+ this.carouselIsVisible = true;
2523
+ }
2524
+ onEdit(zone) {
2525
+ this.zoneForEdit = zone;
2526
+ this.isEditingZone = true;
2527
+ this.menuItems.push({
2528
+ label: `${zone.name}`,
2529
+ });
2530
+ }
2531
+ onAddLot() {
2532
+ this.isMuseumVisit = false;
2533
+ this.isEditingZone = true;
2534
+ this.menuItems.push({
2535
+ label: "New",
2536
+ });
2537
+ }
2538
+ onAddMuseumZone() {
2539
+ this.isMuseumVisit = true;
2540
+ this.isEditingZone = true;
2541
+ this.menuItems.push({
2542
+ label: "New Museum Itinerary",
2543
+ });
2544
+ }
2545
+ onDelete(zone, floorID) {
2546
+ return __awaiter(this, void 0, void 0, function* () {
2547
+ const message = this.translate.instant("confirm.deleteZone");
2548
+ // eslint-disable-next-line no-alert
2549
+ if (window.confirm(message)) {
2550
+ yield this.zoneService.deleteZone(zone.id);
2551
+ this.allZones.splice(this.allZones.indexOf(zone), 1);
2552
+ const floorZones = this.zonesMap.get(floorID);
2553
+ floorZones.splice(floorZones.indexOf(zone), 1);
2554
+ this.zonesMap.set(floorID, floorZones);
2555
+ }
2556
+ });
2557
+ }
2558
+ editCompleted(event) {
2559
+ this.lotIndexDetails = -1;
2560
+ if (event) {
2561
+ this.resetZones();
2562
+ }
2563
+ this.isEditingZone = false;
2564
+ this.zoneForEdit = null;
2565
+ this.planIsVisible = false;
2566
+ this.carouselIsVisible = false;
2567
+ this.setupMenuItems();
2568
+ }
2569
+ showScanPointsOnPlan(navigations) {
2570
+ return __awaiter(this, void 0, void 0, function* () {
2571
+ const divPlan = document.querySelector("#planDiv");
2572
+ yield showScanPointsOnPlanInDiv(this.currentPlan, divPlan, navigations);
2573
+ this.loadingPlan = false;
2574
+ panzoom(divPlan, {
2575
+ bounds: true,
2576
+ boundsPadding: 0,
2577
+ maxZoom: 3.5,
2578
+ });
2579
+ });
2580
+ }
2581
+ }
2582
+ ZonesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ZonesComponent, deps: [{ token: i1.ActivatedRoute }, { token: i2.ZoneService }, { token: i2.SpaceService }, { token: i2.VisitService }, { token: i2.NavigationService }, { token: i2.BaseUserService }, { token: i2.PlanService }, { token: i3.TranslateService }], target: i0.ɵɵFactoryTarget.Component });
2583
+ ZonesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: ZonesComponent, selector: "lib-zones", outputs: { updatedZone: "updatedZone" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"container-fluid\" *ngIf=\"currentSpace\">\r\n <div class=\"m-3\">\r\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"onGoBack()\"></lib-tab-navigation>\r\n </div>\r\n <div class=\"row\">\r\n <div class=\"col-md-6\">\r\n <ul class=\"list-group list-group-flush\" *ngIf=\"!isEditingZone\">\r\n <li class=\"list-group-item default-zone-line-item\">\r\n <div class=\"d-flex justify-content-between align-items-center zone-name\" *ngIf=\"defaultZone\">\r\n {{defaultZone.name}}\r\n <div class=\"default-zone-label\">{{ \"whole space\" | translate }}</div>\r\n <lib-chevron [conditionShowing]=\"defaultShowing\" (click)=\"onToggleDefaultZone()\"></lib-chevron>\r\n </div>\r\n <div *ngIf=\"defaultShowing\">\r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item bg-transparent\">{{'Type of zone' | translate}}: {{currentZone.layer ?\r\n currentZone.layer.name :\r\n \"No type\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"currentZone.surface\">{{'Surface' | translate}}, m<sup>2</sup>:\r\n {{currentZone.surface }}\r\n </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!currentZone.virtual\">{{'Scan Points' | translate}}:\r\n {{currentZone.sweepIDs ? currentZone.sweepIDs.length : \"No scan points\" | translate}} </li>\r\n </ul>\r\n <div *ngFor=\"let pair of zonesMap | keyvalue\">\r\n <div *ngIf=\"pair.key == defaultZone.id\">\r\n <h5 style=\"margin: 8px;\" *ngIf=\"pair.value.length > 0\">{{'Children zones'|translate}}</h5>\r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item list-group-flush list-group-item-action\"\r\n *ngFor=\"let lot of pair.value; index as zoneIndex\">\r\n <div class=\"d-flex justify-content-between align-items-center zone-name\">\r\n {{lot.name}}\r\n <div class=\"museum-label\" *ngIf=\"lot.isMuseumVisitZone\">{{ \"itinerary\" | translate }}</div>\r\n <lib-chevron [conditionShowing]=\"zoneIndex==lotIndexDetails\" (click)=\"onToggleDetail(zoneIndex, lot)\"></lib-chevron>\r\n \r\n </div>\r\n <div *ngIf=\"zoneIndex==lotIndexDetails\">\r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.isMuseumVisitZone\">{{'Type of zone' |\r\n translate}}: {{lot.layer ? lot.layer.name :\r\n \"No type\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.surface\">{{'Surface' | translate}},\r\n m<sup>2</sup>:\r\n {{lot.surface }}\r\n </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.virtual\">{{'Scan Points' | translate}}:\r\n {{lot.sweepIDs ? lot.sweepIDs.length : \"No scan points\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.virtual\">{{'Zone not visible in 3D visit'\r\n |\r\n translate}}</li>\r\n </ul>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\r\n (click)=\"onEdit(lot)\">{{'Edit' |\r\n translate}}</button>\r\n <!-- <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\"\r\n (click)=\"onDelete(lot, floor.id)\">{{'Delete'\r\n | translate}}</button> -->\r\n </div>\r\n </li>\r\n </ul>\r\n \r\n </div>\r\n </div>\r\n </div>\r\n </li>\r\n \r\n <li class=\"list-group-item\" *ngFor=\"let floor of floorZones; index as index\">\r\n <div class=\"d-flex justify-content-between align-items-center zone-name\">\r\n {{floor.name}}\r\n <!-- <small>({{ lot.metadata ? ('Calibrated' | translate) : ('Not calibrated' | translate)}})</small> -->\r\n <div class=\"museum-label\" *ngIf=\"floor.isMuseumVisitZone\">{{ \"itinerary\" | translate }}</div>\r\n <lib-chevron [conditionShowing]=\"index==floorDetails\" (click)=\"onToggleDetailFloor(index, floor)\"></lib-chevron>\r\n </div>\r\n <div *ngIf=\"index==floorDetails\"> \r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item bg-transparent\">{{'Type of zone' | translate}}: {{floor.layer ?\r\n floor.layer.name :\r\n \"No type\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"floor.surface\">{{'Surface' | translate}}, m<sup>2</sup>:\r\n {{floor.surface }}\r\n </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!floor.virtual\">{{'Scan Points' | translate}}:\r\n {{floor.sweepIDs ? floor.sweepIDs.length : \"No scan points\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"floor.virtual\">{{'Zone not visible in 3D visit' |\r\n translate}}</li>\r\n </ul>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onEdit(floor)\">{{'Edit' |\r\n translate}}</button>\r\n \r\n <!-- List of children zones -->\r\n \r\n <div *ngFor=\"let pair of zonesMap | keyvalue\">\r\n <div *ngIf=\"pair.key == floor.id\">\r\n <h5 style=\"margin: 8px;\" *ngIf=\"pair.value.length > 0\">{{'Children zones'|translate}}</h5>\r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item list-group-flush list-group-item-action\"\r\n *ngFor=\"let lot of pair.value; index as zoneIndex\">\r\n <div class=\"d-flex justify-content-between align-items-center zone-name\">\r\n {{lot.name}}\r\n <div class=\"museum-label\" *ngIf=\"lot.isMuseumVisitZone\">{{ \"itinerary\" | translate }}</div>\r\n <lib-chevron [conditionShowing]=\"zoneIndex==lotIndexDetails\" (click)=\"onToggleDetail(zoneIndex, lot)\"></lib-chevron>\r\n \r\n </div>\r\n <div *ngIf=\"zoneIndex==lotIndexDetails\">\r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.isMuseumVisitZone\">{{'Type of zone' |\r\n translate}}: {{lot.layer ? lot.layer.name :\r\n \"No type\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.surface\">{{'Surface' | translate}},\r\n m<sup>2</sup>:\r\n {{lot.surface }}\r\n </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.virtual\">{{'Scan Points' | translate}}:\r\n {{lot.sweepIDs ? lot.sweepIDs.length : \"No scan points\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.virtual\">{{'Zone not visible in 3D visit'\r\n |\r\n translate}}</li>\r\n </ul>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\r\n (click)=\"onEdit(lot)\">{{'Edit' |\r\n translate}}</button>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\"\r\n (click)=\"onDelete(lot, floor.id)\">{{'Delete'\r\n | translate}}</button>\r\n </div>\r\n </li>\r\n </ul>\r\n \r\n </div>\r\n </div>\r\n </div>\r\n </li>\r\n </ul>\r\n \r\n <div *ngIf=\"!isEditingZone\">\r\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddLot()\">{{'Add zone' |\r\n translate}}</button>\r\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddMuseumZone()\"\r\n *ngIf=\"isGuide || isAdmin\">\r\n {{'Add museum itinerary' | translate}}</button>\r\n </div>\r\n </div>\r\n <div class=\"col-md-6\" *ngIf=\"!isEditingZone\">\r\n <div class=\"d-flex justify-content-center\" *ngIf=\"loadingPlan\">\r\n <div class=\"spinner-border\" role=\"status\">\r\n <span class=\"visually-hidden\">Loading...</span>\r\n </div>\r\n </div>\r\n <div class=\"row\" style=\"overflow: hidden;\" *ngIf=\"currentZone\">\r\n <div class=\"mt-3 ms-3\" style=\"height: 500px; width: 100%;\" id=\"planDiv\" *ngIf=\"currentPlan\"></div>\r\n <div class=\"mt-3 ms-3\" id=\"no-plan\" *ngIf=\"!currentPlan && plans && !currentZone.virtual && !loadingPlan\">\r\n {{ 'Plan is not calibrated' | translate}}\r\n </div>\r\n <div class=\"mt-3 ms-3\" id=\"no-plan\" *ngIf=\"currentZone && currentZone.virtual\">\r\n {{ 'No scan points chosen' | translate}}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"mb-3\" *ngIf=\"isEditingZone\">\r\n <lib-add-zone [zoneEdit]=\"zoneForEdit\" [spaceID]=\"spaceID\" [images360]=\"images360\" [navigationIDs]=\"navigations\"\r\n [zones]=\"allZones\" [defaultZone]=\"defaultZone\" (updatedZone)=\"editCompleted($event)\" [isMuseumVisit]=\"isMuseumVisit\"></lib-add-zone>\r\n </div>\r\n </div>\r\n", styles: [".museum-label{background-color:#6f3974;font-size:.95rem;border-radius:10px;padding:5px 10px;color:#fff;text-transform:uppercase;margin-left:auto;margin-right:8px}.default-zone-line-item{border-bottom-width:3px}.default-zone-label{background-color:var(--smarterplan-primary);font-size:.95rem;border-radius:10px;padding:5px 10px;color:#fff;text-transform:uppercase;margin-left:auto;margin-right:8px}\n"], components: [{ type: TabNavigationComponent, selector: "lib-tab-navigation", inputs: ["menuItems"], outputs: ["onGoBack"] }, { type: ChevronComponent, selector: "lib-chevron", inputs: ["conditionShowing"] }, { type: AddZoneComponent, selector: "lib-add-zone", inputs: ["zoneEdit", "spaceID", "images360", "navigationIDs", "zones", "newZoneData", "chosenPlan", "isMuseumVisit", "defaultZone"], outputs: ["updatedZone"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "translate": i3.TranslatePipe, "keyvalue": i5.KeyValuePipe } });
2584
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ZonesComponent, decorators: [{
2585
+ type: Component,
2586
+ args: [{ selector: 'lib-zones', template: "<div class=\"container-fluid\" *ngIf=\"currentSpace\">\r\n <div class=\"m-3\">\r\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"onGoBack()\"></lib-tab-navigation>\r\n </div>\r\n <div class=\"row\">\r\n <div class=\"col-md-6\">\r\n <ul class=\"list-group list-group-flush\" *ngIf=\"!isEditingZone\">\r\n <li class=\"list-group-item default-zone-line-item\">\r\n <div class=\"d-flex justify-content-between align-items-center zone-name\" *ngIf=\"defaultZone\">\r\n {{defaultZone.name}}\r\n <div class=\"default-zone-label\">{{ \"whole space\" | translate }}</div>\r\n <lib-chevron [conditionShowing]=\"defaultShowing\" (click)=\"onToggleDefaultZone()\"></lib-chevron>\r\n </div>\r\n <div *ngIf=\"defaultShowing\">\r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item bg-transparent\">{{'Type of zone' | translate}}: {{currentZone.layer ?\r\n currentZone.layer.name :\r\n \"No type\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"currentZone.surface\">{{'Surface' | translate}}, m<sup>2</sup>:\r\n {{currentZone.surface }}\r\n </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!currentZone.virtual\">{{'Scan Points' | translate}}:\r\n {{currentZone.sweepIDs ? currentZone.sweepIDs.length : \"No scan points\" | translate}} </li>\r\n </ul>\r\n <div *ngFor=\"let pair of zonesMap | keyvalue\">\r\n <div *ngIf=\"pair.key == defaultZone.id\">\r\n <h5 style=\"margin: 8px;\" *ngIf=\"pair.value.length > 0\">{{'Children zones'|translate}}</h5>\r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item list-group-flush list-group-item-action\"\r\n *ngFor=\"let lot of pair.value; index as zoneIndex\">\r\n <div class=\"d-flex justify-content-between align-items-center zone-name\">\r\n {{lot.name}}\r\n <div class=\"museum-label\" *ngIf=\"lot.isMuseumVisitZone\">{{ \"itinerary\" | translate }}</div>\r\n <lib-chevron [conditionShowing]=\"zoneIndex==lotIndexDetails\" (click)=\"onToggleDetail(zoneIndex, lot)\"></lib-chevron>\r\n \r\n </div>\r\n <div *ngIf=\"zoneIndex==lotIndexDetails\">\r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.isMuseumVisitZone\">{{'Type of zone' |\r\n translate}}: {{lot.layer ? lot.layer.name :\r\n \"No type\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.surface\">{{'Surface' | translate}},\r\n m<sup>2</sup>:\r\n {{lot.surface }}\r\n </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.virtual\">{{'Scan Points' | translate}}:\r\n {{lot.sweepIDs ? lot.sweepIDs.length : \"No scan points\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.virtual\">{{'Zone not visible in 3D visit'\r\n |\r\n translate}}</li>\r\n </ul>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\r\n (click)=\"onEdit(lot)\">{{'Edit' |\r\n translate}}</button>\r\n <!-- <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\"\r\n (click)=\"onDelete(lot, floor.id)\">{{'Delete'\r\n | translate}}</button> -->\r\n </div>\r\n </li>\r\n </ul>\r\n \r\n </div>\r\n </div>\r\n </div>\r\n </li>\r\n \r\n <li class=\"list-group-item\" *ngFor=\"let floor of floorZones; index as index\">\r\n <div class=\"d-flex justify-content-between align-items-center zone-name\">\r\n {{floor.name}}\r\n <!-- <small>({{ lot.metadata ? ('Calibrated' | translate) : ('Not calibrated' | translate)}})</small> -->\r\n <div class=\"museum-label\" *ngIf=\"floor.isMuseumVisitZone\">{{ \"itinerary\" | translate }}</div>\r\n <lib-chevron [conditionShowing]=\"index==floorDetails\" (click)=\"onToggleDetailFloor(index, floor)\"></lib-chevron>\r\n </div>\r\n <div *ngIf=\"index==floorDetails\"> \r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item bg-transparent\">{{'Type of zone' | translate}}: {{floor.layer ?\r\n floor.layer.name :\r\n \"No type\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"floor.surface\">{{'Surface' | translate}}, m<sup>2</sup>:\r\n {{floor.surface }}\r\n </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!floor.virtual\">{{'Scan Points' | translate}}:\r\n {{floor.sweepIDs ? floor.sweepIDs.length : \"No scan points\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"floor.virtual\">{{'Zone not visible in 3D visit' |\r\n translate}}</li>\r\n </ul>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onEdit(floor)\">{{'Edit' |\r\n translate}}</button>\r\n \r\n <!-- List of children zones -->\r\n \r\n <div *ngFor=\"let pair of zonesMap | keyvalue\">\r\n <div *ngIf=\"pair.key == floor.id\">\r\n <h5 style=\"margin: 8px;\" *ngIf=\"pair.value.length > 0\">{{'Children zones'|translate}}</h5>\r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item list-group-flush list-group-item-action\"\r\n *ngFor=\"let lot of pair.value; index as zoneIndex\">\r\n <div class=\"d-flex justify-content-between align-items-center zone-name\">\r\n {{lot.name}}\r\n <div class=\"museum-label\" *ngIf=\"lot.isMuseumVisitZone\">{{ \"itinerary\" | translate }}</div>\r\n <lib-chevron [conditionShowing]=\"zoneIndex==lotIndexDetails\" (click)=\"onToggleDetail(zoneIndex, lot)\"></lib-chevron>\r\n \r\n </div>\r\n <div *ngIf=\"zoneIndex==lotIndexDetails\">\r\n <ul class=\"list-group list-group-flush\">\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.isMuseumVisitZone\">{{'Type of zone' |\r\n translate}}: {{lot.layer ? lot.layer.name :\r\n \"No type\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.surface\">{{'Surface' | translate}},\r\n m<sup>2</sup>:\r\n {{lot.surface }}\r\n </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.virtual\">{{'Scan Points' | translate}}:\r\n {{lot.sweepIDs ? lot.sweepIDs.length : \"No scan points\" | translate}} </li>\r\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.virtual\">{{'Zone not visible in 3D visit'\r\n |\r\n translate}}</li>\r\n </ul>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\r\n (click)=\"onEdit(lot)\">{{'Edit' |\r\n translate}}</button>\r\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\"\r\n (click)=\"onDelete(lot, floor.id)\">{{'Delete'\r\n | translate}}</button>\r\n </div>\r\n </li>\r\n </ul>\r\n \r\n </div>\r\n </div>\r\n </div>\r\n </li>\r\n </ul>\r\n \r\n <div *ngIf=\"!isEditingZone\">\r\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddLot()\">{{'Add zone' |\r\n translate}}</button>\r\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddMuseumZone()\"\r\n *ngIf=\"isGuide || isAdmin\">\r\n {{'Add museum itinerary' | translate}}</button>\r\n </div>\r\n </div>\r\n <div class=\"col-md-6\" *ngIf=\"!isEditingZone\">\r\n <div class=\"d-flex justify-content-center\" *ngIf=\"loadingPlan\">\r\n <div class=\"spinner-border\" role=\"status\">\r\n <span class=\"visually-hidden\">Loading...</span>\r\n </div>\r\n </div>\r\n <div class=\"row\" style=\"overflow: hidden;\" *ngIf=\"currentZone\">\r\n <div class=\"mt-3 ms-3\" style=\"height: 500px; width: 100%;\" id=\"planDiv\" *ngIf=\"currentPlan\"></div>\r\n <div class=\"mt-3 ms-3\" id=\"no-plan\" *ngIf=\"!currentPlan && plans && !currentZone.virtual && !loadingPlan\">\r\n {{ 'Plan is not calibrated' | translate}}\r\n </div>\r\n <div class=\"mt-3 ms-3\" id=\"no-plan\" *ngIf=\"currentZone && currentZone.virtual\">\r\n {{ 'No scan points chosen' | translate}}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"mb-3\" *ngIf=\"isEditingZone\">\r\n <lib-add-zone [zoneEdit]=\"zoneForEdit\" [spaceID]=\"spaceID\" [images360]=\"images360\" [navigationIDs]=\"navigations\"\r\n [zones]=\"allZones\" [defaultZone]=\"defaultZone\" (updatedZone)=\"editCompleted($event)\" [isMuseumVisit]=\"isMuseumVisit\"></lib-add-zone>\r\n </div>\r\n </div>\r\n", styles: [".museum-label{background-color:#6f3974;font-size:.95rem;border-radius:10px;padding:5px 10px;color:#fff;text-transform:uppercase;margin-left:auto;margin-right:8px}.default-zone-line-item{border-bottom-width:3px}.default-zone-label{background-color:var(--smarterplan-primary);font-size:.95rem;border-radius:10px;padding:5px 10px;color:#fff;text-transform:uppercase;margin-left:auto;margin-right:8px}\n"] }]
2587
+ }], ctorParameters: function () { return [{ type: i1.ActivatedRoute }, { type: i2.ZoneService }, { type: i2.SpaceService }, { type: i2.VisitService }, { type: i2.NavigationService }, { type: i2.BaseUserService }, { type: i2.PlanService }, { type: i3.TranslateService }]; }, propDecorators: { updatedZone: [{
2588
+ type: Output
2589
+ }] } });
2590
+
2591
+ class ImagesComponent {
2592
+ constructor(route, spaceService, visitService, nodeService) {
2593
+ this.route = route;
2594
+ this.spaceService = spaceService;
2595
+ this.visitService = visitService;
2596
+ this.nodeService = nodeService;
2597
+ this.loading = false;
2598
+ this.menuItems = [];
2599
+ }
2600
+ ngOnInit() {
2601
+ this.spaceID = this.route.snapshot.paramMap.get("id");
2602
+ this.loadImages();
2603
+ }
2604
+ setupMenuItems() {
2605
+ this.menuItems = [
2606
+ { label: "Locations", url: "/localisation" },
2607
+ {
2608
+ label: this.currentSpace.name,
2609
+ url: `/localisation/${this.spaceID}`,
2610
+ },
2611
+ { label: "360° Images" },
2612
+ ];
2613
+ if (this.currentVisit) {
2614
+ this.menuItems.push({ label: this.currentVisit.name });
2615
+ }
2616
+ }
2617
+ onGoBack() {
2618
+ this.currentVisit = null;
2619
+ this.currentImages = null;
2620
+ this.setupMenuItems();
2621
+ }
2622
+ loadImages() {
2623
+ return __awaiter(this, void 0, void 0, function* () {
2624
+ this.loading = true;
2625
+ this.currentSpace = yield this.spaceService.getSpace(this.spaceID);
2626
+ this.setupMenuItems();
2627
+ this.images = yield this.visitService.loadImagesForSpace(this.currentSpace);
2628
+ if (this.currentSpace.visits.length === 1) {
2629
+ this.setVisit(this.currentSpace.visits[0]);
2630
+ }
2631
+ this.loading = false;
2632
+ });
2633
+ }
2634
+ setVisit(visit) {
2635
+ this.currentVisit = visit;
2636
+ this.currentImages = this.images.filter((im) => {
2637
+ return im.visit === visit;
2638
+ });
2639
+ this.setupMenuItems();
2640
+ }
2641
+ setCurrentScan(id) {
2642
+ this.currentScanID = id;
2643
+ }
2644
+ onInventoryClick() {
2645
+ return __awaiter(this, void 0, void 0, function* () {
2646
+ const { node } = this.currentVisit;
2647
+ const { filename } = this.currentImages[this.currentScanID]; // 110ee452_sweep.jpeg
2648
+ // check if node has already errors of inventory
2649
+ const missingFilesErrors = [
2650
+ InventoryStatus.ERROR_FILE_JSON_NOT_EXIST,
2651
+ InventoryStatus.ERROR_FILE_MODEL_NOT_EXIST,
2652
+ InventoryStatus.ERROR_FILE_OBJ_NOT_EXIST,
2653
+ ];
2654
+ if (node.inventoryStatus &&
2655
+ missingFilesErrors.includes(node.inventoryStatus)) {
2656
+ alert("Files missing for this visit's inventory. Contact your administrator.");
2657
+ }
2658
+ else {
2659
+ yield this.nodeService.updateNode({
2660
+ id: node.id,
2661
+ inventoryStatus: InventoryStatus.TO_RUN_ONE_IMAGE,
2662
+ navigationForInventory: filename.split("_")[0],
2663
+ });
2664
+ alert("Automatic AI Inventory started! Detected equipments will appear soon in the visit.");
2665
+ }
2666
+ });
2667
+ }
2668
+ }
2669
+ ImagesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ImagesComponent, deps: [{ token: i1.ActivatedRoute }, { token: i2.SpaceService }, { token: i2.VisitService }, { token: i2.NodeService }], target: i0.ɵɵFactoryTarget.Component });
2670
+ ImagesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: ImagesComponent, selector: "lib-images", ngImport: i0, template: "<div class=\"container-fluid dashboard-tab col-sm-10 mb-3\" *ngIf=\"currentSpace\" >\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"onGoBack()\"></lib-tab-navigation>\n </div>\n <div class=\"d-flex justify-content-center\" *ngIf=\"loading\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">{{'Loading' | translate}}...</span>\n </div>\n </div>\n <div ngbDropdown class=\"d-inline-block\" *ngIf=\"currentSpace.visits && currentSpace.visits.length > 0\">\n <button class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\" *ngIf=\"!currentVisit\"\n ngbDropdownToggle>{{'Choose 3D visit' | translate}}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\n <button ngbDropdownItem *ngFor=\"let visit of currentSpace.visits\" (click)=\"setVisit(visit)\"> {{ visit.name }}\n </button>\n </div>\n </div>\n <h3 *ngIf=\"currentVisit\">{{ currentVisit.name }}</h3>\n <div class=\"mt-3\" *ngIf=\"currentVisit && currentImages.length == 0 && !loading\">\n <h4>{{'No imported images' | translate }}</h4>\n <p>{{'For import: go Virtual Visits => Import Images' | translate}}</p>\n </div>\n <button *ngIf=\"currentVisit && currentImages.length > 0 && !loading\"\n class=\"btn btn-outline-primary rounded-pill no-lowercase mb-2\" (click)=\"onInventoryClick()\">\n {{'Run AI inventory on this image' | translate}}</button>\n <lib-carousel [images]=\"currentImages\" *ngIf=\"currentImages\" (currentScan)=\"setCurrentScan($event)\"></lib-carousel>\n </div>", styles: [""], components: [{ type: TabNavigationComponent, selector: "lib-tab-navigation", inputs: ["menuItems"], outputs: ["onGoBack"] }, { type: CarouselComponent, selector: "lib-carousel", inputs: ["images"], outputs: ["currentScan"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgbDropdown, selector: "[ngbDropdown]", inputs: ["autoClose", "dropdownClass", "open", "placement", "container", "display"], outputs: ["openChange"], exportAs: ["ngbDropdown"] }, { type: i7.NgbDropdownToggle, selector: "[ngbDropdownToggle]" }, { type: i7.NgbDropdownMenu, selector: "[ngbDropdownMenu]" }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgbDropdownItem, selector: "[ngbDropdownItem]", inputs: ["disabled"] }], pipes: { "translate": i3.TranslatePipe } });
2671
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ImagesComponent, decorators: [{
2672
+ type: Component,
2673
+ args: [{ selector: 'lib-images', template: "<div class=\"container-fluid dashboard-tab col-sm-10 mb-3\" *ngIf=\"currentSpace\" >\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"onGoBack()\"></lib-tab-navigation>\n </div>\n <div class=\"d-flex justify-content-center\" *ngIf=\"loading\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">{{'Loading' | translate}}...</span>\n </div>\n </div>\n <div ngbDropdown class=\"d-inline-block\" *ngIf=\"currentSpace.visits && currentSpace.visits.length > 0\">\n <button class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\" *ngIf=\"!currentVisit\"\n ngbDropdownToggle>{{'Choose 3D visit' | translate}}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\n <button ngbDropdownItem *ngFor=\"let visit of currentSpace.visits\" (click)=\"setVisit(visit)\"> {{ visit.name }}\n </button>\n </div>\n </div>\n <h3 *ngIf=\"currentVisit\">{{ currentVisit.name }}</h3>\n <div class=\"mt-3\" *ngIf=\"currentVisit && currentImages.length == 0 && !loading\">\n <h4>{{'No imported images' | translate }}</h4>\n <p>{{'For import: go Virtual Visits => Import Images' | translate}}</p>\n </div>\n <button *ngIf=\"currentVisit && currentImages.length > 0 && !loading\"\n class=\"btn btn-outline-primary rounded-pill no-lowercase mb-2\" (click)=\"onInventoryClick()\">\n {{'Run AI inventory on this image' | translate}}</button>\n <lib-carousel [images]=\"currentImages\" *ngIf=\"currentImages\" (currentScan)=\"setCurrentScan($event)\"></lib-carousel>\n </div>", styles: [""] }]
2674
+ }], ctorParameters: function () { return [{ type: i1.ActivatedRoute }, { type: i2.SpaceService }, { type: i2.VisitService }, { type: i2.NodeService }]; } });
2675
+
2676
+ class EditPlanComponent {
2677
+ constructor(planService, route, router, modalService, zoneService, visitService, spaceService, translate) {
2678
+ this.planService = planService;
2679
+ this.route = route;
2680
+ this.router = router;
2681
+ this.modalService = modalService;
2682
+ this.zoneService = zoneService;
2683
+ this.visitService = visitService;
2684
+ this.spaceService = spaceService;
2685
+ this.translate = translate;
2686
+ this.loading = false;
2687
+ this.isNewZone = false;
2688
+ /**
2689
+ * Options for svgEditor
2690
+ */
2691
+ this.config = {
2692
+ noStorageOnLoad: true,
2693
+ forceStorage: true,
2694
+ // imgPath: "/assets/editor/images/",
2695
+ // extPath: "/assets/editor/extensions/",
2696
+ // langPath: "/assets/editor/locale/",
2697
+ // canvgPath: "/assets/editor/canvg/",
2698
+ // jspdfPath: "/assets/editor/jspdf/",
2699
+ // jGraduatePath: "/assets/editor/jgraduate/images/",
2700
+ // extIconsPath: "/assets/editor/extensions/",
2701
+ // stylesheets: [
2702
+ // "/assets/editor/jgraduate/css/jGraduate.css",
2703
+ // "/assets/editor/spinbtn/jQuery.SpinButton.css",
2704
+ // "/assets/editor/jgraduate/css/jPicker.css",
2705
+ // "/assets/editor/svg-editor.css",
2706
+ // ],
2707
+ dimensions: [10000, 10000],
2708
+ showlayers: true,
2709
+ noDefaultExtensions: true,
2710
+ basePath: "/assets/editor/",
2711
+ customExportImage: true,
2712
+ extensions: [
2713
+ "ext-connector",
2714
+ // "ext-eyedropper",
2715
+ // "ext-grid",
2716
+ // "ext-markers",
2717
+ // "ext-overview_window",
2718
+ // "ext-spi-library",
2719
+ // "ext-spi-icon",
2720
+ "ext-sp-zone",
2721
+ // "ext-arrows",
2722
+ // "ext-sp-css",
2723
+ // "ext-placemark",
2724
+ ],
2725
+ };
2726
+ this.menuItems = [];
2727
+ this.chosenPlan = this.planService.getChosenPlan();
2728
+ }
2729
+ ngOnInit() {
2730
+ return __awaiter(this, void 0, void 0, function* () {
2731
+ this.editorUrl = "/assets/editor/main.html";
2732
+ this.spaceID = this.route.snapshot.queryParams.spaceID;
2733
+ this.currentSpace = yield this.spaceService.getSpace(this.spaceID);
2734
+ this.setupMenuItems();
2735
+ if (this.spaceID && !this.planService.getChosenPlan()) {
2736
+ this.router.navigate([
2737
+ "/dashboard/localisation",
2738
+ this.spaceID,
2739
+ "plans",
2740
+ ]);
2741
+ }
2742
+ else if (!this.spaceID && !this.planService.getChosenPlan()) {
2743
+ this.router.navigate(["/dashboard/localisation"]);
2744
+ }
2745
+ });
2746
+ }
2747
+ setupMenuItems() {
2748
+ this.menuItems = [
2749
+ { label: "Locations", url: "/localisation" },
2750
+ {
2751
+ label: this.currentSpace.name,
2752
+ url: `/localisation/${this.spaceID}`,
2753
+ },
2754
+ {
2755
+ label: "Plans",
2756
+ url: `/localisation/${this.currentSpace.id}/plans`,
2757
+ },
2758
+ {
2759
+ label: "Edit",
2760
+ url: `/localisation/${this.currentSpace.id}/plan-edit?spaceID=${this.currentSpace.id}`,
2761
+ },
2762
+ ];
2763
+ }
2764
+ switchAction(event) {
2765
+ return __awaiter(this, void 0, void 0, function* () {
2766
+ if (event.origin === window.location.origin) {
2767
+ switch (event.data.message) {
2768
+ case "save":
2769
+ this.onSave(event.data.redirect);
2770
+ break;
2771
+ case "close":
2772
+ this.onCancel();
2773
+ break;
2774
+ case "new-zone":
2775
+ const modalReference = this.modalService.open(this.loadingModal);
2776
+ const svg = unescape(encodeURIComponent(this.svgEditor.svgCanvas.getSvgString()));
2777
+ const base64 = `data:image/svg+xml;base64,${window.btoa(svg)}`;
2778
+ const currentSpace = yield this.spaceService.getSpace(this.spaceID);
2779
+ this.images360 = yield this.visitService.loadImagesForSpace(currentSpace);
2780
+ this.editedPlan = Object.assign({}, this.chosenPlan);
2781
+ this.editedPlan.filepath = base64;
2782
+ this.newZoneData = event.data.zoneData;
2783
+ if (this.newZoneData.elements.length === 0) {
2784
+ modalReference.close();
2785
+ alert(this.translate.instant("edition.no-zone"));
2786
+ break;
2787
+ }
2788
+ this.zones = yield this.zoneService.getZonesBySpace(this.spaceID);
2789
+ this.zones = sortAlphabeticallyOnName(this.zones);
2790
+ this.editedZone = this.zones.find((z) => z.name === this.newZoneData.name);
2791
+ this.resetNavigations();
2792
+ modalReference.close();
2793
+ this.modalService.open(this.dialogZone);
2794
+ break;
2795
+ default:
2796
+ break;
2797
+ }
2798
+ }
2799
+ });
2800
+ }
2801
+ resetNavigations() {
2802
+ return __awaiter(this, void 0, void 0, function* () {
2803
+ this.navigations = [];
2804
+ const defaultZone = this.zones.find((zone) => !zone.parentID);
2805
+ if (defaultZone.sweepIDs.length > 0) {
2806
+ this.navigations = defaultZone.sweepIDs;
2807
+ }
2808
+ });
2809
+ }
2810
+ onLoad(svgEditor) {
2811
+ return __awaiter(this, void 0, void 0, function* () {
2812
+ if (svgEditor.contentWindow.SvgEditor) {
2813
+ this.svgEditorIframe = svgEditor;
2814
+ this.svgEditor = new svgEditor.contentWindow.SvgEditor();
2815
+ yield this.svgEditor.init();
2816
+ // await this.svgEditor.pref(key, val);
2817
+ // await this.svgEditor.setConfig({ extentions: this.extensions });
2818
+ yield this.svgEditor.setConfig(this.config, {
2819
+ allowInitialUserOverride: true,
2820
+ });
2821
+ if (this.chosenPlan && this.chosenPlan.extension === "svg") {
2822
+ this.loadSvg();
2823
+ }
2824
+ if (this.chosenPlan && this.chosenPlan.extension === "pdf") {
2825
+ this.loadPdf();
2826
+ }
2827
+ if (!this.chosenPlan.calibration || !this.chosenPlan.isModified) {
2828
+ setTimeout(() => {
2829
+ this.svgEditorIframe.contentWindow.postMessage({ action: "disable-zone" }, "*");
2830
+ }, 1000);
2831
+ }
2832
+ }
2833
+ });
2834
+ }
2835
+ onSave(redirect) {
2836
+ return __awaiter(this, void 0, void 0, function* () {
2837
+ const imgBlob = yield new Blob([this.svgEditor.svgCanvas.getSvgString()], {
2838
+ type: "image/svg+xml",
2839
+ });
2840
+ const [name] = this.chosenPlan.name.split(".");
2841
+ const imgFile = new File([imgBlob], `${name}-edited.svg`, {
2842
+ type: "image/svg+xml",
2843
+ lastModified: Date.now(),
2844
+ });
2845
+ this.planService.setPlanFileCache(imgFile);
2846
+ if (this.chosenPlan.isModified) {
2847
+ this.modalService.open(this.dialog);
2848
+ }
2849
+ else {
2850
+ this.router.navigate([
2851
+ "/dashboard/localisation",
2852
+ this.spaceID,
2853
+ "plans",
2854
+ ]);
2855
+ }
2856
+ });
2857
+ }
2858
+ updateSvg() {
2859
+ return __awaiter(this, void 0, void 0, function* () {
2860
+ const newUrl = yield this.planService.updatePlanFile();
2861
+ yield this.planService.updatePlan({
2862
+ id: this.chosenPlan.id,
2863
+ annexe: newUrl,
2864
+ });
2865
+ this.planService.setPlanFileCache(null);
2866
+ this.router.navigate([
2867
+ "/dashboard/localisation",
2868
+ this.spaceID,
2869
+ "plans",
2870
+ ]);
2871
+ });
2872
+ }
2873
+ newSvg() {
2874
+ return __awaiter(this, void 0, void 0, function* () {
2875
+ this.router.navigate([
2876
+ "/dashboard/localisation",
2877
+ this.spaceID,
2878
+ "plans",
2879
+ ]);
2880
+ });
2881
+ }
2882
+ onCancel() {
2883
+ return __awaiter(this, void 0, void 0, function* () {
2884
+ this.router.navigate([
2885
+ "/dashboard/localisation",
2886
+ this.spaceID,
2887
+ "plans",
2888
+ ]);
2889
+ alert(this.translate.instant("edition.cancel"));
2890
+ });
2891
+ }
2892
+ loadSvg() {
2893
+ return __awaiter(this, void 0, void 0, function* () {
2894
+ const svgRequest = yield downloadFileAsObject(this.chosenPlan.annexe);
2895
+ if (svgRequest) {
2896
+ const svgBlob = yield svgRequest.Body;
2897
+ const reader = new FileReader();
2898
+ reader.onloadend = () => {
2899
+ this.svgEditor.loadFromDataURI(reader.result);
2900
+ };
2901
+ reader.readAsDataURL(svgBlob);
2902
+ }
2903
+ });
2904
+ }
2905
+ loadPdf() {
2906
+ return __awaiter(this, void 0, void 0, function* () {
2907
+ this.svgEditorIframe.contentWindow.postMessage({ action: "disable-zone" }, "*");
2908
+ const canvas = document.querySelector("#canvas4pdf");
2909
+ const context = canvas.getContext("2d");
2910
+ const pdfjs = yield import('pdfjs-dist/build/pdf');
2911
+ const pdfjsWorker = yield import('pdfjs-dist/build/pdf.worker.entry');
2912
+ pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
2913
+ const pdf = yield getDocument(this.chosenPlan.filepath).promise;
2914
+ const page = yield pdf.getPage(1);
2915
+ const viewPortParameters = { scale: 1.5 };
2916
+ const viewport = page.getViewport(viewPortParameters);
2917
+ this.svgEditor.svgCanvas.setResolution(viewport.width, viewport.height);
2918
+ canvas.height = viewport.height;
2919
+ canvas.width = viewport.width;
2920
+ const renderContext = {
2921
+ canvasContext: context,
2922
+ viewport,
2923
+ };
2924
+ const renderTask = page.render(renderContext).promise;
2925
+ renderTask.then(() => {
2926
+ const newImage = this.svgEditor.svgCanvas.addSVGElementFromJson({
2927
+ element: "image",
2928
+ attr: {
2929
+ x: 0,
2930
+ y: 0,
2931
+ width: viewport.width,
2932
+ height: viewport.height,
2933
+ id: this.svgEditor.svgCanvas.getNextId(),
2934
+ style: "pointer-events:inherit",
2935
+ },
2936
+ });
2937
+ this.svgEditor.svgCanvas.setHref(newImage, canvas.toDataURL("image/png"));
2938
+ });
2939
+ });
2940
+ }
2941
+ onLoadImg(img) {
2942
+ return __awaiter(this, void 0, void 0, function* () {
2943
+ this.svgEditorIframe.contentWindow.postMessage({ action: "disable-zone" }, "*");
2944
+ const imgRequest = yield downloadFileAsObject(this.chosenPlan.annexe);
2945
+ if (imgRequest) {
2946
+ const imgBlob = yield imgRequest.Body;
2947
+ const imgWidth = img.naturalWidth;
2948
+ const imgHeight = img.naturalHeight;
2949
+ // await this.svgEditor.setConfig({
2950
+ // dimensions: [imgWidth, imgHeight],
2951
+ // });
2952
+ this.svgEditor.svgCanvas.setResolution(imgWidth, imgHeight);
2953
+ const reader = new FileReader();
2954
+ reader.onloadend = () => {
2955
+ const newImage = this.svgEditor.svgCanvas.addSVGElementFromJson({
2956
+ element: "image",
2957
+ attr: {
2958
+ x: 0,
2959
+ y: 0,
2960
+ width: imgWidth,
2961
+ height: imgHeight,
2962
+ id: this.svgEditor.svgCanvas.getNextId(),
2963
+ style: "pointer-events:inherit",
2964
+ },
2965
+ });
2966
+ this.svgEditor.svgCanvas.setHref(newImage, reader.result);
2967
+ };
2968
+ reader.readAsDataURL(imgBlob);
2969
+ }
2970
+ });
2971
+ }
2972
+ onNewZone(event) {
2973
+ this.isNewZone = false;
2974
+ if (event) {
2975
+ this.svgEditorIframe.contentWindow.postMessage({ action: "rename-layer", name: event }, "*");
2976
+ }
2977
+ else {
2978
+ this.svgEditorIframe.contentWindow.postMessage({ action: "cancel-layer" }, "*");
2979
+ }
2980
+ }
2981
+ }
2982
+ EditPlanComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: EditPlanComponent, deps: [{ token: i2.PlanService }, { token: i1.ActivatedRoute }, { token: i1.Router }, { token: i7.NgbModal }, { token: i2.ZoneService }, { token: i2.VisitService }, { token: i2.SpaceService }, { token: i3.TranslateService }], target: i0.ɵɵFactoryTarget.Component });
2983
+ EditPlanComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: EditPlanComponent, selector: "lib-edit-plan", host: { listeners: { "window:message": "switchAction($event)" } }, viewQueries: [{ propertyName: "dialog", first: true, predicate: ["dialog"], descendants: true }, { propertyName: "dialogZone", first: true, predicate: ["dialogZone"], descendants: true }, { propertyName: "loadingModal", first: true, predicate: ["preparing"], descendants: true }], ngImport: i0, template: "<div class=\"row mt-3\">\n <div class=\"col\">\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems'></lib-tab-navigation>\n </div>\n </div>\n</div>\n<iframe *ngIf=\"editorUrl\" #svgEditor [src]=\"editorUrl | safeUrl\" frameborder=\"0\"\n style=\"height: 100%;width:100%;min-height:750px\" (load)=\"onLoad(svgEditor)\"></iframe>\n<!-- chosenPlan && -->\n<!-- ./../../../../../../assets/svgeditor/index.html -->\n\n<img #imgPng *ngIf=\"chosenPlan && chosenPlan.extension !== 'svg' && svgEditor\" [src]=\"chosenPlan.filepath\"\n (load)=\"onLoadImg(imgPng)\" style=\"display: none;\">\n\n<canvas id=\"canvas4pdf\" style=\"display: none;\"></canvas>\n\n<lib-add-zone *ngIf=\"isNewZone\" [images360]=\"images360\" [spaceID]=\"spaceID\" [navigationIDs]=\"navigations\"\n [zoneEdit]=\"editedZone\" [zones]=\"zones\" (updatedZone)=\"onNewZone($event)\" [chosenPlan]=\"editedPlan\"\n [newZoneData]=\"newZoneData\"></lib-add-zone>\n\n<ng-template #dialog let-modal>\n\n <div class=\"modal-header\">\n <h4 class=\"modal-title\">{{'Submit' | translate}}</h4>\n <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"modal.dismiss('Cross click')\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n {{'save plan edited' | translate}}\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-outline-dark\" (click)=\"newSvg();modal.close('Close click')\">{{'Yes' |\n translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-dark\" (click)=\"updateSvg();modal.close('Close click')\">{{'No' |\n translate}}</button>\n </div>\n\n</ng-template>\n\n<ng-template #dialogZone let-modal>\n\n <div class=\"modal-header\">\n <h4 class=\"modal-title\">{{'Submit' | translate}}</h4>\n <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"modal.dismiss('Cross click')\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n {{'Select zone' | translate}}\n <div ngbDropdown class=\"d-inline-block me-3\">\n <button class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\" ngbDropdownToggle>{{editedZone ?\n editedZone.name: ('New zone' | translate) }}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\n <button ngbDropdownItem (click)=\"editedZone = null\" translate=\"New zone\">\n </button>\n <button ngbDropdownItem *ngFor=\"let zone of zones\" (click)=\"editedZone = zone\">{{zone.name }}\n </button>\n </div>\n </div>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-outline-dark\"\n (click)=\"isNewZone = true;modal.close('Close click')\">{{'Validate' |\n translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-dark\" (click)=\"modal.close('Close click')\">{{'Cancel' |\n translate}}</button>\n </div>\n\n</ng-template>\n\n<ng-template #preparing let-modal>\n <div class=\"modal-header\">\n <h4 class=\"modal-title\">{{'Processing' | translate}}</h4>\n <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"modal.dismiss('Cross click')\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n <div class=\"d-flex justify-content-center\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n </div>\n\n</ng-template>", styles: ["app-add-zone{position:absolute;top:0;left:0;background-color:#fff;width:100%;height:100%;padding:30px}\n"], components: [{ type: TabNavigationComponent, selector: "lib-tab-navigation", inputs: ["menuItems"], outputs: ["onGoBack"] }, { type: AddZoneComponent, selector: "lib-add-zone", inputs: ["zoneEdit", "spaceID", "images360", "navigationIDs", "zones", "newZoneData", "chosenPlan", "isMuseumVisit", "defaultZone"], outputs: ["updatedZone"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgbDropdown, selector: "[ngbDropdown]", inputs: ["autoClose", "dropdownClass", "open", "placement", "container", "display"], outputs: ["openChange"], exportAs: ["ngbDropdown"] }, { type: i7.NgbDropdownToggle, selector: "[ngbDropdownToggle]" }, { type: i7.NgbDropdownMenu, selector: "[ngbDropdownMenu]" }, { type: i7.NgbDropdownItem, selector: "[ngbDropdownItem]", inputs: ["disabled"] }, { type: i3.TranslateDirective, selector: "[translate],[ngx-translate]", inputs: ["translate", "translateParams"] }, { type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "safeUrl": i2.SafeUrlPipe, "translate": i3.TranslatePipe } });
2984
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: EditPlanComponent, decorators: [{
2985
+ type: Component,
2986
+ args: [{ selector: 'lib-edit-plan', template: "<div class=\"row mt-3\">\n <div class=\"col\">\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems'></lib-tab-navigation>\n </div>\n </div>\n</div>\n<iframe *ngIf=\"editorUrl\" #svgEditor [src]=\"editorUrl | safeUrl\" frameborder=\"0\"\n style=\"height: 100%;width:100%;min-height:750px\" (load)=\"onLoad(svgEditor)\"></iframe>\n<!-- chosenPlan && -->\n<!-- ./../../../../../../assets/svgeditor/index.html -->\n\n<img #imgPng *ngIf=\"chosenPlan && chosenPlan.extension !== 'svg' && svgEditor\" [src]=\"chosenPlan.filepath\"\n (load)=\"onLoadImg(imgPng)\" style=\"display: none;\">\n\n<canvas id=\"canvas4pdf\" style=\"display: none;\"></canvas>\n\n<lib-add-zone *ngIf=\"isNewZone\" [images360]=\"images360\" [spaceID]=\"spaceID\" [navigationIDs]=\"navigations\"\n [zoneEdit]=\"editedZone\" [zones]=\"zones\" (updatedZone)=\"onNewZone($event)\" [chosenPlan]=\"editedPlan\"\n [newZoneData]=\"newZoneData\"></lib-add-zone>\n\n<ng-template #dialog let-modal>\n\n <div class=\"modal-header\">\n <h4 class=\"modal-title\">{{'Submit' | translate}}</h4>\n <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"modal.dismiss('Cross click')\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n {{'save plan edited' | translate}}\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-outline-dark\" (click)=\"newSvg();modal.close('Close click')\">{{'Yes' |\n translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-dark\" (click)=\"updateSvg();modal.close('Close click')\">{{'No' |\n translate}}</button>\n </div>\n\n</ng-template>\n\n<ng-template #dialogZone let-modal>\n\n <div class=\"modal-header\">\n <h4 class=\"modal-title\">{{'Submit' | translate}}</h4>\n <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"modal.dismiss('Cross click')\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n {{'Select zone' | translate}}\n <div ngbDropdown class=\"d-inline-block me-3\">\n <button class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\" ngbDropdownToggle>{{editedZone ?\n editedZone.name: ('New zone' | translate) }}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\n <button ngbDropdownItem (click)=\"editedZone = null\" translate=\"New zone\">\n </button>\n <button ngbDropdownItem *ngFor=\"let zone of zones\" (click)=\"editedZone = zone\">{{zone.name }}\n </button>\n </div>\n </div>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-outline-dark\"\n (click)=\"isNewZone = true;modal.close('Close click')\">{{'Validate' |\n translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-dark\" (click)=\"modal.close('Close click')\">{{'Cancel' |\n translate}}</button>\n </div>\n\n</ng-template>\n\n<ng-template #preparing let-modal>\n <div class=\"modal-header\">\n <h4 class=\"modal-title\">{{'Processing' | translate}}</h4>\n <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"modal.dismiss('Cross click')\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n <div class=\"d-flex justify-content-center\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n </div>\n\n</ng-template>", styles: ["app-add-zone{position:absolute;top:0;left:0;background-color:#fff;width:100%;height:100%;padding:30px}\n"] }]
2987
+ }], ctorParameters: function () { return [{ type: i2.PlanService }, { type: i1.ActivatedRoute }, { type: i1.Router }, { type: i7.NgbModal }, { type: i2.ZoneService }, { type: i2.VisitService }, { type: i2.SpaceService }, { type: i3.TranslateService }]; }, propDecorators: { dialog: [{
2988
+ type: ViewChild,
2989
+ args: ["dialog"]
2990
+ }], dialogZone: [{
2991
+ type: ViewChild,
2992
+ args: ["dialogZone"]
2993
+ }], loadingModal: [{
2994
+ type: ViewChild,
2995
+ args: ["preparing"]
2996
+ }], switchAction: [{
2997
+ type: HostListener,
2998
+ args: ["window:message", ["$event"]]
2999
+ }] } });
3000
+
3001
+ const routes = [
3002
+ {
3003
+ path: "",
3004
+ component: LocationsComponent,
3005
+ },
3006
+ {
3007
+ path: ":id",
3008
+ children: [
3009
+ { path: "", component: DetailLocationComponent },
3010
+ { path: "zones", component: ZonesComponent },
3011
+ { path: "visits", component: VisitsComponent },
3012
+ { path: "plans", component: PlansComponent },
3013
+ {
3014
+ path: "plan-calibration",
3015
+ component: CalibrationComponent,
3016
+ },
3017
+ {
3018
+ path: "plan-edit",
3019
+ component: EditPlanComponent,
3020
+ },
3021
+ { path: "images", component: ImagesComponent },
3022
+ ],
3023
+ },
3024
+ ];
3025
+ class LocationsRoutingModule {
3026
+ }
3027
+ LocationsRoutingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocationsRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3028
+ LocationsRoutingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocationsRoutingModule, imports: [i1.RouterModule], exports: [RouterModule] });
3029
+ LocationsRoutingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocationsRoutingModule, imports: [[RouterModule.forChild(routes)], RouterModule] });
3030
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocationsRoutingModule, decorators: [{
3031
+ type: NgModule,
3032
+ args: [{
3033
+ imports: [RouterModule.forChild(routes)],
3034
+ exports: [RouterModule],
3035
+ }]
3036
+ }] });
3037
+
3038
+ class NgxSmarterplanLocationsModule {
3039
+ }
3040
+ NgxSmarterplanLocationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3041
+ NgxSmarterplanLocationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsModule, declarations: [LocationsComponent,
3042
+ DetailLocationComponent,
3043
+ CalibrationComponent,
3044
+ PlansComponent,
3045
+ VisitsComponent,
3046
+ ZonesComponent,
3047
+ ImagesComponent,
3048
+ EditPlanComponent,
3049
+ TabNavigationComponent,
3050
+ MapComponent,
3051
+ MapPopupComponent,
3052
+ FormLocationComponent,
3053
+ ChevronComponent,
3054
+ AddZoneComponent,
3055
+ SelectionComponent,
3056
+ CarouselComponent], imports: [PdfViewerModule,
3057
+ ClipboardModule,
3058
+ NgbModule,
3059
+ CommonModule, i3.TranslateModule, LeafletModule,
3060
+ FormsModule,
3061
+ ReactiveFormsModule,
3062
+ NgxSmarterplanCoreModule,
3063
+ LocationsRoutingModule] });
3064
+ NgxSmarterplanLocationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsModule, imports: [[
3065
+ PdfViewerModule,
3066
+ ClipboardModule,
3067
+ NgbModule,
3068
+ CommonModule,
3069
+ TranslateModule.forChild({
3070
+ extend: true
3071
+ }),
3072
+ LeafletModule,
3073
+ FormsModule,
3074
+ ReactiveFormsModule,
3075
+ NgxSmarterplanCoreModule,
3076
+ LocationsRoutingModule,
3077
+ ]] });
3078
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsModule, decorators: [{
3079
+ type: NgModule,
3080
+ args: [{
3081
+ declarations: [
3082
+ LocationsComponent,
3083
+ DetailLocationComponent,
3084
+ CalibrationComponent,
3085
+ PlansComponent,
3086
+ VisitsComponent,
3087
+ ZonesComponent,
3088
+ ImagesComponent,
3089
+ EditPlanComponent,
3090
+ TabNavigationComponent,
3091
+ MapComponent,
3092
+ MapPopupComponent,
3093
+ FormLocationComponent,
3094
+ ChevronComponent,
3095
+ AddZoneComponent,
3096
+ SelectionComponent,
3097
+ CarouselComponent
3098
+ ],
3099
+ imports: [
3100
+ PdfViewerModule,
3101
+ ClipboardModule,
3102
+ NgbModule,
3103
+ CommonModule,
3104
+ TranslateModule.forChild({
3105
+ extend: true
3106
+ }),
3107
+ LeafletModule,
3108
+ FormsModule,
3109
+ ReactiveFormsModule,
3110
+ NgxSmarterplanCoreModule,
3111
+ LocationsRoutingModule,
3112
+ ],
3113
+ exports: []
3114
+ }]
3115
+ }] });
3116
+
3117
+ /*
3118
+ * Public API Surface of ngx-smarterplan-locations
3119
+ */
3120
+
3121
+ /**
3122
+ * Generated bundle index. Do not edit.
3123
+ */
3124
+
3125
+ export { NgxSmarterplanLocationsModule, NgxSmarterplanLocationsService };
3126
+ //# sourceMappingURL=smarterplan-ngx-smarterplan-locations.mjs.map