@smarterplan/ngx-smarterplan-locations 0.2.44 → 0.2.45

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 (152) hide show
  1. package/esm2020/lib/components/carousel/carousel.component.mjs +28 -0
  2. package/esm2020/lib/components/chevron/chevron.component.mjs +18 -0
  3. package/esm2020/lib/components/detail-location/detail-location.component.mjs +168 -0
  4. package/esm2020/lib/components/form-location/form-location.component.mjs +237 -0
  5. package/esm2020/lib/components/images/images.component.mjs +107 -0
  6. package/esm2020/lib/components/locations/locations.component.mjs +145 -0
  7. package/esm2020/lib/components/locations/map/map-popup/map-popup.component.mjs +66 -0
  8. package/esm2020/lib/components/locations/map/map.component.mjs +91 -0
  9. package/esm2020/lib/components/plan-legend/plan-legend.component.mjs +47 -0
  10. package/esm2020/lib/components/plans/calibration/calibration.component.mjs +468 -0
  11. package/esm2020/lib/components/plans/edit-plan/edit-plan.component.mjs +324 -0
  12. package/esm2020/lib/components/plans/plans.component.mjs +225 -0
  13. package/esm2020/lib/components/tab-navigation/tab-navigation.component.mjs +41 -0
  14. package/esm2020/lib/components/visits/visits.component.mjs +283 -0
  15. package/esm2020/lib/components/zones/add-audio-zone/add-audio-zone.component.mjs +230 -0
  16. package/esm2020/lib/components/zones/add-zone/add-zone.component.mjs +315 -0
  17. package/esm2020/lib/components/zones/add-zone/selection/selection.component.mjs +77 -0
  18. package/esm2020/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.mjs +502 -0
  19. package/esm2020/lib/components/zones/zones.component.mjs +268 -0
  20. package/esm2020/lib/helper.service.mjs +134 -0
  21. package/esm2020/lib/ngx-smarterplan-location-routing.module.mjs +49 -0
  22. package/esm2020/lib/ngx-smarterplan-locations.module.mjs +125 -0
  23. package/esm2020/lib/ngx-smarterplan-locations.service.mjs +14 -0
  24. package/esm2020/lib/pipes/count-audio-sweeps.pipe.mjs +27 -0
  25. package/esm2020/lib/radio-button/radio-button.component.mjs +26 -0
  26. package/esm2020/public-api.mjs +9 -0
  27. package/esm2020/smarterplan-ngx-smarterplan-locations.mjs +5 -0
  28. package/fesm2015/smarterplan-ngx-smarterplan-locations.mjs +3991 -0
  29. package/fesm2015/smarterplan-ngx-smarterplan-locations.mjs.map +1 -0
  30. package/fesm2020/smarterplan-ngx-smarterplan-locations.mjs +3828 -0
  31. package/fesm2020/smarterplan-ngx-smarterplan-locations.mjs.map +1 -0
  32. package/lib/components/carousel/carousel.component.d.ts +12 -0
  33. package/lib/components/chevron/chevron.component.d.ts +9 -0
  34. package/lib/components/detail-location/detail-location.component.d.ts +55 -0
  35. package/lib/components/form-location/form-location.component.d.ts +45 -0
  36. package/lib/components/images/images.component.d.ts +33 -0
  37. package/lib/components/locations/locations.component.d.ts +51 -0
  38. package/lib/components/locations/map/map-popup/map-popup.component.d.ts +22 -0
  39. package/lib/components/locations/map/map.component.d.ts +22 -0
  40. package/lib/components/plan-legend/plan-legend.component.d.ts +14 -0
  41. package/lib/components/plans/calibration/calibration.component.d.ts +140 -0
  42. package/lib/components/plans/edit-plan/edit-plan.component.d.ts +55 -0
  43. package/lib/components/plans/plans.component.d.ts +63 -0
  44. package/lib/components/tab-navigation/tab-navigation.component.d.ts +13 -0
  45. package/lib/components/visits/visits.component.d.ts +62 -0
  46. package/lib/components/zones/add-audio-zone/add-audio-zone.component.d.ts +63 -0
  47. package/lib/components/zones/add-zone/add-zone.component.d.ts +69 -0
  48. package/lib/components/zones/add-zone/selection/selection.component.d.ts +44 -0
  49. package/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.d.ts +107 -0
  50. package/lib/components/zones/zones.component.d.ts +73 -0
  51. package/lib/helper.service.d.ts +53 -0
  52. package/lib/ngx-smarterplan-location-routing.module.d.ts +7 -0
  53. package/lib/ngx-smarterplan-locations.module.d.ts +36 -0
  54. package/lib/ngx-smarterplan-locations.service.d.ts +6 -0
  55. package/lib/pipes/count-audio-sweeps.pipe.d.ts +10 -0
  56. package/lib/radio-button/radio-button.component.d.ts +12 -0
  57. package/package.json +22 -5
  58. package/{src/public-api.ts → public-api.d.ts} +4 -11
  59. package/smarterplan-ngx-smarterplan-locations.d.ts +5 -0
  60. package/.browserslistrc +0 -16
  61. package/karma.conf.js +0 -44
  62. package/ng-package.json +0 -7
  63. package/src/lib/components/carousel/carousel.component.html +0 -13
  64. package/src/lib/components/carousel/carousel.component.scss +0 -0
  65. package/src/lib/components/carousel/carousel.component.spec.ts +0 -25
  66. package/src/lib/components/carousel/carousel.component.ts +0 -31
  67. package/src/lib/components/chevron/chevron.component.html +0 -5
  68. package/src/lib/components/chevron/chevron.component.scss +0 -16
  69. package/src/lib/components/chevron/chevron.component.spec.ts +0 -25
  70. package/src/lib/components/chevron/chevron.component.ts +0 -17
  71. package/src/lib/components/detail-location/detail-location.component.html +0 -108
  72. package/src/lib/components/detail-location/detail-location.component.scss +0 -0
  73. package/src/lib/components/detail-location/detail-location.component.spec.ts +0 -25
  74. package/src/lib/components/detail-location/detail-location.component.ts +0 -215
  75. package/src/lib/components/form-location/form-location.component.html +0 -160
  76. package/src/lib/components/form-location/form-location.component.scss +0 -62
  77. package/src/lib/components/form-location/form-location.component.spec.ts +0 -25
  78. package/src/lib/components/form-location/form-location.component.ts +0 -274
  79. package/src/lib/components/images/images.component.html +0 -27
  80. package/src/lib/components/images/images.component.scss +0 -0
  81. package/src/lib/components/images/images.component.spec.ts +0 -25
  82. package/src/lib/components/images/images.component.ts +0 -133
  83. package/src/lib/components/locations/locations.component.html +0 -63
  84. package/src/lib/components/locations/locations.component.scss +0 -121
  85. package/src/lib/components/locations/locations.component.spec.ts +0 -25
  86. package/src/lib/components/locations/locations.component.ts +0 -186
  87. package/src/lib/components/locations/map/map-popup/map-popup.component.html +0 -11
  88. package/src/lib/components/locations/map/map-popup/map-popup.component.scss +0 -51
  89. package/src/lib/components/locations/map/map-popup/map-popup.component.spec.ts +0 -25
  90. package/src/lib/components/locations/map/map-popup/map-popup.component.ts +0 -79
  91. package/src/lib/components/locations/map/map.component.html +0 -2
  92. package/src/lib/components/locations/map/map.component.scss +0 -0
  93. package/src/lib/components/locations/map/map.component.spec.ts +0 -25
  94. package/src/lib/components/locations/map/map.component.ts +0 -111
  95. package/src/lib/components/plan-legend/plan-legend.component.html +0 -9
  96. package/src/lib/components/plan-legend/plan-legend.component.scss +0 -38
  97. package/src/lib/components/plan-legend/plan-legend.component.spec.ts +0 -25
  98. package/src/lib/components/plan-legend/plan-legend.component.ts +0 -50
  99. package/src/lib/components/plans/calibration/calibration.component.html +0 -98
  100. package/src/lib/components/plans/calibration/calibration.component.scss +0 -136
  101. package/src/lib/components/plans/calibration/calibration.component.spec.ts +0 -25
  102. package/src/lib/components/plans/calibration/calibration.component.ts +0 -603
  103. package/src/lib/components/plans/edit-plan/edit-plan.component.html +0 -77
  104. package/src/lib/components/plans/edit-plan/edit-plan.component.scss +0 -9
  105. package/src/lib/components/plans/edit-plan/edit-plan.component.spec.ts +0 -25
  106. package/src/lib/components/plans/edit-plan/edit-plan.component.ts +0 -421
  107. package/src/lib/components/plans/plans.component.html +0 -102
  108. package/src/lib/components/plans/plans.component.scss +0 -24
  109. package/src/lib/components/plans/plans.component.spec.ts +0 -25
  110. package/src/lib/components/plans/plans.component.ts +0 -305
  111. package/src/lib/components/tab-navigation/tab-navigation.component.html +0 -7
  112. package/src/lib/components/tab-navigation/tab-navigation.component.scss +0 -27
  113. package/src/lib/components/tab-navigation/tab-navigation.component.spec.ts +0 -25
  114. package/src/lib/components/tab-navigation/tab-navigation.component.ts +0 -35
  115. package/src/lib/components/visits/visits.component.html +0 -134
  116. package/src/lib/components/visits/visits.component.scss +0 -24
  117. package/src/lib/components/visits/visits.component.spec.ts +0 -25
  118. package/src/lib/components/visits/visits.component.ts +0 -357
  119. package/src/lib/components/zones/add-audio-zone/add-audio-zone.component.html +0 -73
  120. package/src/lib/components/zones/add-audio-zone/add-audio-zone.component.scss +0 -14
  121. package/src/lib/components/zones/add-audio-zone/add-audio-zone.component.spec.ts +0 -25
  122. package/src/lib/components/zones/add-audio-zone/add-audio-zone.component.ts +0 -269
  123. package/src/lib/components/zones/add-zone/add-zone.component.html +0 -153
  124. package/src/lib/components/zones/add-zone/add-zone.component.scss +0 -44
  125. package/src/lib/components/zones/add-zone/add-zone.component.spec.ts +0 -25
  126. package/src/lib/components/zones/add-zone/add-zone.component.ts +0 -377
  127. package/src/lib/components/zones/add-zone/selection/selection.component.html +0 -3
  128. package/src/lib/components/zones/add-zone/selection/selection.component.scss +0 -16
  129. package/src/lib/components/zones/add-zone/selection/selection.component.spec.ts +0 -25
  130. package/src/lib/components/zones/add-zone/selection/selection.component.ts +0 -95
  131. package/src/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.html +0 -73
  132. package/src/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.scss +0 -23
  133. package/src/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.spec.ts +0 -25
  134. package/src/lib/components/zones/add-zone/sweep-plan-selection/sweep-plan-selection.component.ts +0 -595
  135. package/src/lib/components/zones/zones.component.html +0 -181
  136. package/src/lib/components/zones/zones.component.scss +0 -36
  137. package/src/lib/components/zones/zones.component.spec.ts +0 -25
  138. package/src/lib/components/zones/zones.component.ts +0 -339
  139. package/src/lib/helper.service.ts +0 -161
  140. package/src/lib/ngx-smarterplan-location-routing.module.ts +0 -41
  141. package/src/lib/ngx-smarterplan-locations.module.ts +0 -74
  142. package/src/lib/ngx-smarterplan-locations.service.spec.ts +0 -16
  143. package/src/lib/ngx-smarterplan-locations.service.ts +0 -9
  144. package/src/lib/pipes/count-audio-sweeps.pipe.ts +0 -21
  145. package/src/lib/radio-button/radio-button.component.html +0 -9
  146. package/src/lib/radio-button/radio-button.component.scss +0 -152
  147. package/src/lib/radio-button/radio-button.component.spec.ts +0 -25
  148. package/src/lib/radio-button/radio-button.component.ts +0 -26
  149. package/src/test.ts +0 -27
  150. package/tsconfig.lib.json +0 -15
  151. package/tsconfig.lib.prod.json +0 -10
  152. package/tsconfig.spec.json +0 -17
@@ -0,0 +1,3991 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, EventEmitter, Component, Output, Input, ViewChild, Pipe, HostListener, NgModule } from '@angular/core';
3
+ import { __awaiter } from 'tslib';
4
+ import * as i2 from '@smarterplan/ngx-smarterplan-core';
5
+ import { enumToArray, LevelStatus, textValidator, noEmptyValidator, floatValidator, uploadFileToS3, deleteFromS3, PropertyType, getSignedImageUrlForSpace, SearchObjectType, SpaceStatus, getMetaForImage, getSignedFile, downloadFileAsObject, downloadBlob, CaptureViewer, showScanPointsOnPlanInDiv, getCoefficientsForImage, CommentType, SpModule, wait, InventoryStatus, NgxSmarterplanCoreModule } from '@smarterplan/ngx-smarterplan-core';
6
+ import * as i1 from '@angular/router';
7
+ import { RouterModule } from '@angular/router';
8
+ import * as i6 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, NgbAlertModule } from '@ng-bootstrap/ng-bootstrap';
19
+ import { Subject, takeUntil } from 'rxjs';
20
+ import * as i7$1 from 'ngx-clipboard';
21
+ import { ClipboardModule } from 'ngx-clipboard';
22
+ import { getDocument } from 'pdfjs-dist';
23
+ import panzoom from 'panzoom';
24
+ import { PdfViewerModule } from 'ng2-pdf-viewer';
25
+
26
+ class NgxSmarterplanLocationsService {
27
+ constructor() { }
28
+ }
29
+ NgxSmarterplanLocationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
30
+ NgxSmarterplanLocationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsService, providedIn: 'root' });
31
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsService, decorators: [{
32
+ type: Injectable,
33
+ args: [{
34
+ providedIn: 'root'
35
+ }]
36
+ }], ctorParameters: function () { return []; } });
37
+
38
+ class TabNavigationComponent {
39
+ constructor(router) {
40
+ this.router = router;
41
+ this.onGoBack = new EventEmitter();
42
+ this.menuItems = [];
43
+ }
44
+ onClick(url, parameter, index) {
45
+ if (index === this.menuItems.length - 1) {
46
+ return;
47
+ }
48
+ if (url) {
49
+ const newURL = `/dashboard${url}`;
50
+ if (this.router.url !== newURL) {
51
+ console.log('new url', newURL);
52
+ this.router.navigate([newURL]);
53
+ }
54
+ else {
55
+ this.onGoBack.emit(parameter);
56
+ }
57
+ }
58
+ else {
59
+ this.onGoBack.emit(parameter);
60
+ }
61
+ }
62
+ }
63
+ TabNavigationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: TabNavigationComponent, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Component });
64
+ 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: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i6.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "translate": i3.TranslatePipe } });
65
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: TabNavigationComponent, decorators: [{
66
+ type: Component,
67
+ 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"] }]
68
+ }], ctorParameters: function () { return [{ type: i1.Router }]; }, propDecorators: { onGoBack: [{
69
+ type: Output
70
+ }], menuItems: [{
71
+ type: Input
72
+ }] } });
73
+
74
+ class MapPopupComponent {
75
+ constructor(router, ngZone) {
76
+ this.router = router;
77
+ this.ngZone = ngZone;
78
+ this.isOnPopup = false;
79
+ this.isMuseumUser = true;
80
+ }
81
+ ngOnInit() {
82
+ this.marker.on("click", () => this.onClickVisitFirst());
83
+ this.marker.on("mouseover", () => {
84
+ this.isOnPopup = true;
85
+ if (!this.marker.isPopupOpen()) {
86
+ this.openPopup();
87
+ }
88
+ });
89
+ }
90
+ openPopup() {
91
+ this.marker.openPopup();
92
+ this.isOnPopup = false;
93
+ this.popuparea = document.querySelector(".leaflet-popup");
94
+ this.popuparea.addEventListener("mouseleave", () => {
95
+ this.closePopup();
96
+ });
97
+ this.popuparea.addEventListener("mouseover", () => {
98
+ this.isOnPopup = true;
99
+ });
100
+ this.marker.on("mouseout", () => {
101
+ this.closePopup();
102
+ });
103
+ }
104
+ closePopup() {
105
+ this.isOnPopup = false;
106
+ /** We want to wait to avoid glitch */
107
+ setTimeout(() => {
108
+ if (!this.isOnPopup) {
109
+ this.marker.closePopup();
110
+ }
111
+ }, 100);
112
+ }
113
+ onClickVisitFirst() {
114
+ if (this.space.visits.length === 0) {
115
+ console.log("No space to visit !");
116
+ }
117
+ else {
118
+ this.onVisitClick(this.space.visits[0]);
119
+ }
120
+ }
121
+ onVisitClick(visit) {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ this.ngZone.run(() => {
124
+ this.router.navigate(["visit", this.space.id], {
125
+ queryParams: { model3D: visit.model3d },
126
+ });
127
+ });
128
+ });
129
+ }
130
+ }
131
+ 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 });
132
+ 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: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
133
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: MapPopupComponent, decorators: [{
134
+ type: Component,
135
+ 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"] }]
136
+ }], ctorParameters: function () { return [{ type: i1.Router }, { type: i0.NgZone }]; } });
137
+
138
+ const iconRetinaUrl = "assets/marker-icon-2x.png";
139
+ const iconUrl = "assets/marker-icon.png";
140
+ const shadowUrl = "assets/marker-shadow.png";
141
+ const iconDefault = icon({
142
+ iconRetinaUrl,
143
+ iconUrl,
144
+ shadowUrl,
145
+ iconSize: [25, 41],
146
+ iconAnchor: [12, 41],
147
+ popupAnchor: [1, -34],
148
+ tooltipAnchor: [16, -28],
149
+ shadowSize: [41, 41],
150
+ });
151
+ Marker.prototype.options.icon = iconDefault;
152
+ class MapComponent {
153
+ constructor(componentFactoryResolver, injector) {
154
+ this.componentFactoryResolver = componentFactoryResolver;
155
+ this.injector = injector;
156
+ this.options = {
157
+ layers: [
158
+ tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
159
+ maxZoom: 18,
160
+ attribution: "...",
161
+ }),
162
+ ],
163
+ zoom: 5.5,
164
+ center: latLng(47.06394, 2.77736),
165
+ };
166
+ this.layers = [];
167
+ }
168
+ ngOnChanges(changes) {
169
+ if (changes.spaces) {
170
+ const nm = [];
171
+ const bd = [];
172
+ if (!changes.spaces.currentValue) {
173
+ return;
174
+ }
175
+ // Filtering out spaces without lat/longitudes
176
+ for (const s of changes.spaces.currentValue) {
177
+ if (s.latitude === null || s.longitude === null) {
178
+ console.log(`${s.name} has not coordinates for ${s.addresses}`);
179
+ continue;
180
+ }
181
+ // We use the popup system from leaflet, as it packs a few improvements
182
+ // on using bootstrap: autoclose other popups, closing option.
183
+ const m = marker([s.latitude, s.longitude]);
184
+ m.bindPopup(this.createPopupComponent(s, m));
185
+ nm.push(m);
186
+ bd.push(latLng(s.latitude, s.longitude));
187
+ }
188
+ // Note how we set the layers in one assignment, in order to have leaflet
189
+ // detects the change correctly
190
+ // We also set the bounds afterward, for the map to be properly zoomed and
191
+ // centered
192
+ this.layers = nm;
193
+ if (this.map && bd.length > 0) {
194
+ this.map.fitBounds(latLngBounds(bd), {
195
+ padding: point(48, 48),
196
+ maxZoom: 12,
197
+ animate: true,
198
+ });
199
+ }
200
+ }
201
+ }
202
+ onMapReady(map) {
203
+ this.map = map;
204
+ }
205
+ createPopupComponent(space, marker) {
206
+ const comp = this.componentFactoryResolver
207
+ .resolveComponentFactory(MapPopupComponent)
208
+ .create(this.injector);
209
+ comp.instance.space = space;
210
+ comp.instance.marker = marker;
211
+ comp.changeDetectorRef.detectChanges();
212
+ return comp.location.nativeElement;
213
+ }
214
+ }
215
+ 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 });
216
+ 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"] }] });
217
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: MapComponent, decorators: [{
218
+ type: Component,
219
+ 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: [""] }]
220
+ }], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }, { type: i0.Injector }]; }, propDecorators: { spaces: [{
221
+ type: Input
222
+ }] } });
223
+
224
+ class FormLocationComponent {
225
+ constructor(spaceService, propertyService, userService, fb, missionService, layerService, validatorsService) {
226
+ this.spaceService = spaceService;
227
+ this.propertyService = propertyService;
228
+ this.userService = userService;
229
+ this.fb = fb;
230
+ this.missionService = missionService;
231
+ this.layerService = layerService;
232
+ this.validatorsService = validatorsService;
233
+ this.isSubmitted = false;
234
+ this.addMissionForNewSpace = true;
235
+ this.imageToBeDeleted = false;
236
+ this.errorForm = false;
237
+ this.onChange = new EventEmitter();
238
+ this.levels = enumToArray(LevelStatus);
239
+ }
240
+ ngOnInit() {
241
+ if (this.location) {
242
+ this.initEditForm();
243
+ }
244
+ else {
245
+ this.initForm();
246
+ }
247
+ this.handleInputImageText();
248
+ }
249
+ initForm() {
250
+ this.form = this.fb.group({
251
+ name: ["", [Validators.required, Validators.maxLength(255), textValidator(), noEmptyValidator()]],
252
+ addresses: ["", [Validators.maxLength(255), textValidator(), noEmptyValidator()]],
253
+ latitude: [null, [Validators.maxLength(255), noEmptyValidator(), floatValidator()]],
254
+ longitude: [null, [Validators.maxLength(255), noEmptyValidator(), floatValidator()]],
255
+ level: LevelStatus.LOW,
256
+ classGes: ["", [Validators.maxLength(255), textValidator(), noEmptyValidator()]],
257
+ classEnergyConsumption: ["", [Validators.maxLength(255), textValidator(), noEmptyValidator()]],
258
+ constructionYear: ["", [Validators.maxLength(255), textValidator(), noEmptyValidator()]],
259
+ });
260
+ }
261
+ initEditForm() {
262
+ this.form = this.fb.group({
263
+ id: this.location.id,
264
+ name: [this.location.name, [Validators.required, Validators.maxLength(255), textValidator(), noEmptyValidator()]],
265
+ addresses: [this.location.addresses, [Validators.maxLength(255), textValidator(), noEmptyValidator()]],
266
+ latitude: [this.location.latitude, [Validators.maxLength(255), floatValidator()]],
267
+ longitude: [this.location.longitude, [Validators.maxLength(255), floatValidator()]],
268
+ level: this.location.level,
269
+ classGes: [this.location.classGes, [Validators.maxLength(255), textValidator(), noEmptyValidator()]],
270
+ classEnergyConsumption: [this.location.classEnergyConsumption, [Validators.maxLength(255), textValidator(), noEmptyValidator()]],
271
+ constructionYear: [this.location.constructionYear, [Validators.maxLength(255), textValidator(), noEmptyValidator()]],
272
+ });
273
+ }
274
+ handleImageInput(target) {
275
+ this.imageToUpload = target.files[0];
276
+ if (this.imageToUpload) {
277
+ this.imageInputContainer.nativeElement.style.display = "none";
278
+ const reader = new FileReader();
279
+ reader.addEventListener("load", () => {
280
+ this.currentImage = reader.result;
281
+ });
282
+ reader.readAsDataURL(this.imageToUpload);
283
+ }
284
+ }
285
+ uploadImage(spaceID) {
286
+ return __awaiter(this, void 0, void 0, function* () {
287
+ if (this.imageToUpload) {
288
+ uploadFileToS3("locations/", this.imageToUpload, spaceID).then((url) => __awaiter(this, void 0, void 0, function* () {
289
+ if (url) {
290
+ yield this.spaceService.updateSpace({
291
+ id: spaceID,
292
+ annexes: url,
293
+ });
294
+ }
295
+ }));
296
+ }
297
+ else if (this.imageToBeDeleted) {
298
+ yield this.spaceService.updateSpace({
299
+ id: spaceID,
300
+ annexes: null,
301
+ });
302
+ yield deleteFromS3(this.location.annexes);
303
+ }
304
+ });
305
+ }
306
+ clearImageFile() {
307
+ this.imageToUpload = null;
308
+ this.currentImage = null;
309
+ this.imageInputContainer.nativeElement.style.display = "flex";
310
+ this.imageInput.nativeElement.value = "";
311
+ this.imageInputText = "Add picture";
312
+ }
313
+ getLayerByName(name) {
314
+ return __awaiter(this, void 0, void 0, function* () {
315
+ const currentOrgId = this.userService.currentOrganisation().id;
316
+ const layers = yield this.layerService.getLayerByNameForOrganisation(name, currentOrgId);
317
+ if (layers) {
318
+ return layers[0];
319
+ }
320
+ // create then
321
+ return this.layerService.createLayerForOrganisation(name, currentOrgId);
322
+ });
323
+ }
324
+ onSubmit() {
325
+ return __awaiter(this, void 0, void 0, function* () {
326
+ this.isSubmitted = true;
327
+ if (!this.form.valid) {
328
+ this.errorForm = true;
329
+ return;
330
+ }
331
+ try {
332
+ this.errorForm = false;
333
+ let space;
334
+ if (this.location) {
335
+ this.changeCommaToDot();
336
+ space = yield this.spaceService.updateSpace(this.form.value);
337
+ if (space) {
338
+ yield this.uploadImage(space.id);
339
+ this.location = space;
340
+ this.onChange.emit(space);
341
+ }
342
+ }
343
+ else {
344
+ this.changeCommaToDot();
345
+ const spaceInput = this.form.value;
346
+ const currentOrgID = this.userService.currentOrganisation().id;
347
+ spaceInput.organisationID = currentOrgID;
348
+ let layer = yield this.getLayerByName("BUILDING");
349
+ if (!layer) {
350
+ layer = yield this.layerService.createLayerForOrganisation("BUILDING", currentOrgID);
351
+ }
352
+ space = yield this.spaceService.createSpace(spaceInput, layer);
353
+ const missions = this.userService.getManagerMissions();
354
+ if (space && missions.length > 0) {
355
+ const exampleMission = missions[0];
356
+ yield this.uploadImage(space.id);
357
+ try {
358
+ yield this.propertyService.createProperty({
359
+ type: PropertyType.PROPERTY,
360
+ spaceID: space.id,
361
+ organisationID: currentOrgID,
362
+ });
363
+ }
364
+ catch (e) {
365
+ console.log("API Service does not have Property requests");
366
+ }
367
+ // add directly a mission for this space
368
+ if (this.addMissionForNewSpace) {
369
+ yield this.missionService.create({
370
+ spaceID: space.id,
371
+ userID: exampleMission.userID,
372
+ role: exampleMission.role,
373
+ level: exampleMission.level,
374
+ organisationID: exampleMission.organisationID,
375
+ orderedOrganisationID: exampleMission.organisationID,
376
+ });
377
+ }
378
+ this.onChange.emit(space);
379
+ }
380
+ else {
381
+ this.onChange.emit(null);
382
+ }
383
+ }
384
+ }
385
+ catch (error) {
386
+ console.error(error);
387
+ this.onChange.emit(null);
388
+ }
389
+ });
390
+ }
391
+ onCancel() {
392
+ this.form.reset();
393
+ this.onChange.emit(null);
394
+ }
395
+ get name() {
396
+ return this.form.get("name");
397
+ }
398
+ changeCommaToDot() {
399
+ const updatedSpace = this.form.value;
400
+ if (updatedSpace.latitude &&
401
+ updatedSpace.latitude.toString().includes(",")) {
402
+ updatedSpace.latitude = updatedSpace.latitude
403
+ .toString()
404
+ .replace(",", ".");
405
+ Number.parseFloat(updatedSpace.latitude);
406
+ }
407
+ if (updatedSpace.longitude &&
408
+ updatedSpace.longitude.toString().includes(",")) {
409
+ updatedSpace.longitude = updatedSpace.longitude
410
+ .toString()
411
+ .replace(",", ".");
412
+ Number.parseFloat(updatedSpace.longitude);
413
+ }
414
+ }
415
+ handleInputImageText() {
416
+ if (this.location && this.location.annexes) {
417
+ this.imageInputText = "Change picture";
418
+ getSignedImageUrlForSpace(this.location).then((url) => {
419
+ if (url) {
420
+ this.currentImage = url;
421
+ }
422
+ });
423
+ }
424
+ else {
425
+ this.imageInputText = "Add picture";
426
+ }
427
+ }
428
+ isFormError(control) {
429
+ return control && control.invalid && this.errorForm;
430
+ }
431
+ onFormChange() {
432
+ if (this.errorForm && this.form.valid) {
433
+ this.errorForm = false;
434
+ }
435
+ }
436
+ }
437
+ 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 }, { token: i2.ValidatorsService }], target: i0.ɵɵFactoryTarget.Component });
438
+ 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\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\" data-testid=\"new-location-name\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['name'])|| isFormError(form.controls['name'])}\"\n required formControlName=\"name\">\n\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-name-invalid\" [dismissible]=\"false\" type=\"danger\" *ngIf=\"validatorsService.isControlError(form.controls['name']) \n || isFormError(form.controls['name'])\">\n {{validatorsService.getError(form.controls['name']) | translate}}\n </ngb-alert>\n\n </div>\n </div>\n </div>\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\" data-testid=\"new-location-address\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['addresses']) || isFormError(form.controls['addresses'])}\">\n <div class=\"invalid-feedback\">\n <span data-testid=\"\" [translate]=\"validatorsService.getError(form.controls['addresses'])\"\n *ngIf=\" validatorsService.isControlError(form.controls['addresses'])\"></span>\n\n <ngb-alert data-testid=\"new-location-address-invalid\" [dismissible]=\"false\" type=\"danger\"\n *ngIf=\"validatorsService.isControlError(form.controls['addresses']) \">\n\n {{validatorsService.getError(form.controls['addresses']) | translate}}\n </ngb-alert>\n\n </div>\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 data-testid=\"new-location-constructionYear\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['constructionYear']) || isFormError(form.controls['constructionYear'])}\">\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-constructionYear-invalid\" [dismissible]=\"false\" type=\"danger\"\n *ngIf=\"validatorsService.isControlError(form.controls['constructionYear']) || isFormError(form.controls['constructionYear'])\">\n {{validatorsService.getError(form.controls['constructionYear']) | translate}}\n </ngb-alert>\n </div>\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\" data-testid=\"new-location-latitude\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['latitude'])|| isFormError(form.controls['latitude'])}\">\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-latitude-invalid\" [dismissible]=\"false\" type=\"danger\"\n *ngIf=\"validatorsService.isControlError(form.controls['latitude']) || isFormError(form.controls['latitude'])\">\n {{validatorsService.getError(form.controls['latitude']) | translate}}\n </ngb-alert>\n </div>\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\" data-testid=\"new-location-longitude\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['longitude'])|| isFormError(form.controls['longitude'])}\">\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-longitude-invalid\" [dismissible]=\"false\" type=\"danger\"\n *ngIf=\"validatorsService.isControlError(form.controls['longitude']) || isFormError(form.controls['longitude'])\">\n {{validatorsService.getError(form.controls['longitude']) | translate}}\n </ngb-alert>\n </div>\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 data-testid=\"new-location-classEnergyConsumption\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['classEnergyConsumption']) || isFormError(form.controls['classEnergyConsumption'])}\">\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-classEnergyConsumption-invalid\" [dismissible]=\"false\" type=\"danger\"\n *ngIf=\"validatorsService.isControlError(form.controls['classEnergyConsumption']) || isFormError(form.controls['classEnergyConsumption'])\">\n {{validatorsService.getError(form.controls['classEnergyConsumption']) | translate}}\n </ngb-alert>\n </div>\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\" data-testid=\"new-location-classGes\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['classGes'])|| isFormError(form.controls['classGes'])}\">\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-classGes-invalid\" [dismissible]=\"false\" type=\"danger\"\n *ngIf=\"validatorsService.isControlError(form.controls['classGes']) || isFormError(form.controls['classGes'])\">\n {{validatorsService.getError(form.controls['classGes']) | translate}}\n </ngb-alert>\n </div>\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\" class=\"btn btn-outline-primary rounded-pill\"\n (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 data-testid=\"new-location-submit-btn\" [ngClass]=\"{'is-invalid' : errorForm }\" type=\"submit\"\n class=\"btn btn-outline-primary rounded-pill me-3\">{{'Save' | translate}}</button>\n\n <button data-testid=\"new-location-close-btn\" type=\"button\" (click)=\"onCancel()\"\n class=\"btn btn-outline-primary rounded-pill\">{{'Cancel' |\n translate}}</button>\n\n <div class=\"invalid-feedback\" *ngIf=\"errorForm\">\n <ngb-alert data-testid=\"new-location-form-invalid\" [dismissible]=\"false\" type=\"danger\">\n {{'errorForm.infoBtn' |translate}}\n\n </ngb-alert>\n </div>\n </form>\n</div>", 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}.is-invalid,.btn-outline-primary.is-invalid{border-color:red!important}\n"], components: [{ type: i7.NgbAlert, selector: "ngb-alert", inputs: ["animation", "dismissible", "type"], outputs: ["closed"], exportAs: ["ngbAlert"] }], directives: [{ type: i6.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: i6.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.TranslateDirective, selector: "[translate],[ngx-translate]", inputs: ["translate", "translateParams"] }, { type: i1$2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i6.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 } });
439
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: FormLocationComponent, decorators: [{
440
+ type: Component,
441
+ args: [{ selector: 'lib-form-location', template: "<div class=\"col-md-6 form-new-loc\" *ngIf=\"form\">\n <form (ngSubmit)=\"onSubmit()\" [formGroup]=\"form\">\n\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\" data-testid=\"new-location-name\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['name'])|| isFormError(form.controls['name'])}\"\n required formControlName=\"name\">\n\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-name-invalid\" [dismissible]=\"false\" type=\"danger\" *ngIf=\"validatorsService.isControlError(form.controls['name']) \n || isFormError(form.controls['name'])\">\n {{validatorsService.getError(form.controls['name']) | translate}}\n </ngb-alert>\n\n </div>\n </div>\n </div>\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\" data-testid=\"new-location-address\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['addresses']) || isFormError(form.controls['addresses'])}\">\n <div class=\"invalid-feedback\">\n <span data-testid=\"\" [translate]=\"validatorsService.getError(form.controls['addresses'])\"\n *ngIf=\" validatorsService.isControlError(form.controls['addresses'])\"></span>\n\n <ngb-alert data-testid=\"new-location-address-invalid\" [dismissible]=\"false\" type=\"danger\"\n *ngIf=\"validatorsService.isControlError(form.controls['addresses']) \">\n\n {{validatorsService.getError(form.controls['addresses']) | translate}}\n </ngb-alert>\n\n </div>\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 data-testid=\"new-location-constructionYear\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['constructionYear']) || isFormError(form.controls['constructionYear'])}\">\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-constructionYear-invalid\" [dismissible]=\"false\" type=\"danger\"\n *ngIf=\"validatorsService.isControlError(form.controls['constructionYear']) || isFormError(form.controls['constructionYear'])\">\n {{validatorsService.getError(form.controls['constructionYear']) | translate}}\n </ngb-alert>\n </div>\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\" data-testid=\"new-location-latitude\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['latitude'])|| isFormError(form.controls['latitude'])}\">\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-latitude-invalid\" [dismissible]=\"false\" type=\"danger\"\n *ngIf=\"validatorsService.isControlError(form.controls['latitude']) || isFormError(form.controls['latitude'])\">\n {{validatorsService.getError(form.controls['latitude']) | translate}}\n </ngb-alert>\n </div>\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\" data-testid=\"new-location-longitude\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['longitude'])|| isFormError(form.controls['longitude'])}\">\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-longitude-invalid\" [dismissible]=\"false\" type=\"danger\"\n *ngIf=\"validatorsService.isControlError(form.controls['longitude']) || isFormError(form.controls['longitude'])\">\n {{validatorsService.getError(form.controls['longitude']) | translate}}\n </ngb-alert>\n </div>\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 data-testid=\"new-location-classEnergyConsumption\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['classEnergyConsumption']) || isFormError(form.controls['classEnergyConsumption'])}\">\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-classEnergyConsumption-invalid\" [dismissible]=\"false\" type=\"danger\"\n *ngIf=\"validatorsService.isControlError(form.controls['classEnergyConsumption']) || isFormError(form.controls['classEnergyConsumption'])\">\n {{validatorsService.getError(form.controls['classEnergyConsumption']) | translate}}\n </ngb-alert>\n </div>\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\" data-testid=\"new-location-classGes\" (ngModelChange)=\"onFormChange()\"\n [ngClass]=\"{'is-invalid' : validatorsService.isControlError(form.controls['classGes'])|| isFormError(form.controls['classGes'])}\">\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-classGes-invalid\" [dismissible]=\"false\" type=\"danger\"\n *ngIf=\"validatorsService.isControlError(form.controls['classGes']) || isFormError(form.controls['classGes'])\">\n {{validatorsService.getError(form.controls['classGes']) | translate}}\n </ngb-alert>\n </div>\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\" class=\"btn btn-outline-primary rounded-pill\"\n (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 data-testid=\"new-location-submit-btn\" [ngClass]=\"{'is-invalid' : errorForm }\" type=\"submit\"\n class=\"btn btn-outline-primary rounded-pill me-3\">{{'Save' | translate}}</button>\n\n <button data-testid=\"new-location-close-btn\" type=\"button\" (click)=\"onCancel()\"\n class=\"btn btn-outline-primary rounded-pill\">{{'Cancel' |\n translate}}</button>\n\n <div class=\"invalid-feedback\" *ngIf=\"errorForm\">\n <ngb-alert data-testid=\"new-location-form-invalid\" [dismissible]=\"false\" type=\"danger\">\n {{'errorForm.infoBtn' |translate}}\n\n </ngb-alert>\n </div>\n </form>\n</div>", 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}.is-invalid,.btn-outline-primary.is-invalid{border-color:red!important}\n"] }]
442
+ }], ctorParameters: function () { return [{ type: i2.SpaceService }, { type: i2.PropertyService }, { type: i2.BaseUserService }, { type: i1$2.FormBuilder }, { type: i2.MissionService }, { type: i2.LayerService }, { type: i2.ValidatorsService }]; }, propDecorators: { imageInputContainer: [{
443
+ type: ViewChild,
444
+ args: ["imageInputContainer"]
445
+ }], imageInput: [{
446
+ type: ViewChild,
447
+ args: ["imageInput"]
448
+ }], imageBasePreview: [{
449
+ type: ViewChild,
450
+ args: ["imageBasePreview"]
451
+ }], location: [{
452
+ type: Input
453
+ }], onChange: [{
454
+ type: Output
455
+ }] } });
456
+
457
+ class LocationsComponent {
458
+ constructor(spaceService, router, userService, viewerService, navigationService, navigatorService) {
459
+ this.spaceService = spaceService;
460
+ this.router = router;
461
+ this.userService = userService;
462
+ this.viewerService = viewerService;
463
+ this.navigationService = navigationService;
464
+ this.navigatorService = navigatorService;
465
+ this.isAdding = false;
466
+ this.filteredLocations = [];
467
+ this.isManager = false;
468
+ this.isMuseumUser = true;
469
+ this.locations = [];
470
+ this.menuItems = [];
471
+ /** Last filtered Locations, used when we go back on all locations from the search bar location */
472
+ this.lastFiltredLocations = [];
473
+ this.levels = enumToArray(LevelStatus);
474
+ this.userSubcription = this.userService.isChanged.subscribe((isConnected) => {
475
+ if (isConnected) {
476
+ this.refresh();
477
+ }
478
+ });
479
+ this.locationIDSubscription =
480
+ this.navigatorService.locationIDChange.subscribe((id) => {
481
+ this.changeSelectedLocation(id);
482
+ this.setupMenuItems();
483
+ });
484
+ }
485
+ ngOnInit() {
486
+ return __awaiter(this, void 0, void 0, function* () {
487
+ if (this.userService.cu) {
488
+ this.resetList();
489
+ this.updateUserRights();
490
+ }
491
+ this.setupMenuItems();
492
+ });
493
+ }
494
+ findSpaceById(id) {
495
+ return this.locations.find((loc) => loc.id === id);
496
+ }
497
+ /**
498
+ * Update when we change the selected location in filter (search bar)
499
+ * @param id for a location, if null display all last filtred location
500
+ */
501
+ changeSelectedLocation(id) {
502
+ const space = id ? this.findSpaceById(id) : null;
503
+ this.filteredLocations = space ? [space] : this.lastFiltredLocations; // New selected space or last filtered location
504
+ }
505
+ refresh() {
506
+ this.updateUserRights();
507
+ this.resetList();
508
+ }
509
+ ngOnDestroy() {
510
+ this.userSubcription.unsubscribe();
511
+ this.locationIDSubscription.unsubscribe();
512
+ }
513
+ setupMenuItems() {
514
+ this.menuItems = [{ label: "All Locations", url: "/localisation" }];
515
+ if (this.isAdding) {
516
+ this.menuItems.push({ label: "New" });
517
+ }
518
+ if (this.filteredLocations.length === 1) {
519
+ const selectedLoc = this.filteredLocations[0];
520
+ this.menuItems.push({ label: selectedLoc.name });
521
+ }
522
+ }
523
+ updateUserRights() {
524
+ this.isManager = this.userService.hasManagerRoleInAnyMission();
525
+ this.isMuseumUser = this.userService.hasOnlyMuseumRole();
526
+ }
527
+ isManagerForSpace(spaceID) {
528
+ return (this.userService.isManager(spaceID) ||
529
+ this.userService.isGuide(spaceID));
530
+ }
531
+ resetList() {
532
+ return __awaiter(this, void 0, void 0, function* () {
533
+ this.locations = yield this.spaceService.getLocationsForCurrentUser();
534
+ this.filteredLocations = this.locations;
535
+ this.lastFiltredLocations = this.locations;
536
+ this.isAdding = false;
537
+ this.changeSelectedLocation(this.navigatorService.currentNavBarLocationID); // Set for the current selected location
538
+ this.setupMenuItems();
539
+ });
540
+ }
541
+ onAddLocation() {
542
+ this.isAdding = true;
543
+ this.setupMenuItems();
544
+ }
545
+ handleImageInput(files) {
546
+ this.imageToUpload = files.item(0);
547
+ }
548
+ onFormChange(event) {
549
+ this.navigatorService.locationIDChange.next(null); /** Remove selected location */
550
+ this.isAdding = false;
551
+ if (event) {
552
+ this.resetList();
553
+ }
554
+ this.setupMenuItems();
555
+ }
556
+ onVisitClick(loc, visit) {
557
+ return __awaiter(this, void 0, void 0, function* () {
558
+ if (!this.userService.userHasAccessToAllZonesInSpace(loc.id)) {
559
+ // get allowed sweep for the user
560
+ const allowedSweeps = yield this.navigationService.getAllowedSweepsIDsForUserInSpace(loc.id);
561
+ const firstSweep = allowedSweeps[0];
562
+ this.viewerService.setSweepToMove(firstSweep);
563
+ }
564
+ if (this.userService.isGuide(loc.id)) {
565
+ this.router.navigate(["museum", loc.id]);
566
+ }
567
+ else {
568
+ this.router.navigate(["visit", loc.id], {
569
+ queryParams: { model3D: visit.model3d },
570
+ });
571
+ }
572
+ });
573
+ }
574
+ applyResultsSearchBar(results) {
575
+ this.filteredLocations = results || this.locations;
576
+ this.lastFiltredLocations = this.filteredLocations;
577
+ this.navigatorService.locationIDChange.next(null); // When we search with keyword, we would like to search on all locations
578
+ }
579
+ getSearchType() {
580
+ return SearchObjectType.LOCATION;
581
+ }
582
+ getStringNoSpace(data) {
583
+ return data.replace(/\s/g, '');
584
+ }
585
+ onDetailViewClick(spaceID) {
586
+ this.navigatorService.locationIDChange.next(spaceID); // Send update for the location filter bar
587
+ this.router.navigate(["dashboard/localisation", spaceID]);
588
+ }
589
+ }
590
+ 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 });
591
+ 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 data-testid=\"new-location-btn\" 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 data-testid=\"location-list-container\" 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 [ngClass]=\"['open-btn-'+getStringNoSpace(loc.name)]\" *ngIf=\"isManagerForSpace(loc.id)\" class=\"btn-details\" (click)=\"onDetailViewClick(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 [ngClass]=\"['view-btn-'+getStringNoSpace(loc.name)]\" *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: i6.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: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i6.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], pipes: { "translate": i3.TranslatePipe } });
592
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocationsComponent, decorators: [{
593
+ type: Component,
594
+ 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 data-testid=\"new-location-btn\" 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 data-testid=\"location-list-container\" 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 [ngClass]=\"['open-btn-'+getStringNoSpace(loc.name)]\" *ngIf=\"isManagerForSpace(loc.id)\" class=\"btn-details\" (click)=\"onDetailViewClick(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 [ngClass]=\"['view-btn-'+getStringNoSpace(loc.name)]\" *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"] }]
595
+ }], ctorParameters: function () { return [{ type: i2.SpaceService }, { type: i1.Router }, { type: i2.BaseUserService }, { type: i2.ViewerService }, { type: i2.NavigationService }, { type: i2.NavigatorService }]; } });
596
+
597
+ class DetailLocationComponent {
598
+ constructor(route, spaceService, router, userService, translate, navigatorService) {
599
+ this.route = route;
600
+ this.spaceService = spaceService;
601
+ this.router = router;
602
+ this.userService = userService;
603
+ this.translate = translate;
604
+ this.navigatorService = navigatorService;
605
+ this.isEditing = false;
606
+ this.menuItems = [];
607
+ this.isValidatingDpe = false;
608
+ this.gettingData = false;
609
+ this.destroy$ = new Subject();
610
+ this.navigatorService.locationIDChange
611
+ .pipe(takeUntil(this.destroy$))
612
+ .subscribe((spaceID) => {
613
+ this.router.navigate(["dashboard/localisation", spaceID]);
614
+ });
615
+ this.route.params.subscribe((params) => {
616
+ this.id = params.id;
617
+ this.setup();
618
+ });
619
+ }
620
+ ngOnInit() { }
621
+ setup() {
622
+ return __awaiter(this, void 0, void 0, function* () {
623
+ this.space = yield this.spaceService.getSpace(this.id);
624
+ this.setupMenuItems();
625
+ this.setGuestLink();
626
+ this.setCanArchive();
627
+ });
628
+ }
629
+ ngOnDestroy() {
630
+ this.destroy$.next(true);
631
+ this.destroy$.complete();
632
+ }
633
+ setupMenuItems() {
634
+ this.menuItems = [
635
+ { label: "Locations", url: "/localisation" },
636
+ {
637
+ label: this.space.name,
638
+ url: `/localisation/${this.space.id}`,
639
+ },
640
+ ];
641
+ if (this.isEditing) {
642
+ this.menuItems.push({ label: "Edit" });
643
+ }
644
+ else {
645
+ this.menuItems.push({ label: "Information" });
646
+ }
647
+ }
648
+ onEdit() {
649
+ this.isEditing = true;
650
+ this.setupMenuItems();
651
+ }
652
+ onReturn() {
653
+ // this.locationService.back()
654
+ this.router.navigate(["dashboard/localisation"]);
655
+ }
656
+ reset() {
657
+ this.isEditing = false;
658
+ this.setupMenuItems();
659
+ }
660
+ onArchive() {
661
+ return __awaiter(this, void 0, void 0, function* () {
662
+ const message = this.translate.instant("confirm.archiveSpace");
663
+ if (window.confirm(message)) {
664
+ yield this.spaceService.softDeleteSpace(this.id);
665
+ this.onReturn();
666
+ }
667
+ });
668
+ }
669
+ onFormChange(event) {
670
+ this.isEditing = false;
671
+ if (event) {
672
+ this.space = event;
673
+ }
674
+ this.setupMenuItems();
675
+ }
676
+ onDpeValidate() {
677
+ this.isValidatingDpe = true;
678
+ this.parsedMetadata = JSON.parse(this.space.metadata);
679
+ this.parsedMetadata = this.parsedMetadata.filter((result) => result.geo_adresse);
680
+ }
681
+ onSelectChange(selectedResult) {
682
+ for (const result of this.parsedMetadata) {
683
+ if (result !== selectedResult && result.selected) {
684
+ result.selected = false;
685
+ }
686
+ }
687
+ this.selectedDpeResult = selectedResult;
688
+ }
689
+ onSaveResult() {
690
+ return __awaiter(this, void 0, void 0, function* () {
691
+ if (this.selectedDpeResult) {
692
+ const input = {
693
+ id: this.space.id,
694
+ constructionYear: this.selectedDpeResult.annee_construction,
695
+ classEnergyConsumption: this.selectedDpeResult.classe_consommation_energie,
696
+ classGes: this.selectedDpeResult.classe_estimation_ges,
697
+ status: SpaceStatus.DPE_VALIDATED,
698
+ };
699
+ const updatedLoc = yield this.spaceService.updateSpace(input);
700
+ this.space = updatedLoc;
701
+ this.isValidatingDpe = false;
702
+ }
703
+ });
704
+ }
705
+ onCancel() {
706
+ this.isValidatingDpe = false;
707
+ }
708
+ onErase() {
709
+ return __awaiter(this, void 0, void 0, function* () {
710
+ yield this.spaceService.updateSpace({
711
+ id: this.space.id,
712
+ status: SpaceStatus.DPE_VALIDATED,
713
+ });
714
+ this.space.status = SpaceStatus.DPE_VALIDATED;
715
+ this.isValidatingDpe = false;
716
+ });
717
+ }
718
+ onGetDpeData() {
719
+ return __awaiter(this, void 0, void 0, function* () {
720
+ this.gettingData = true;
721
+ yield this.spaceService.updateSpace({
722
+ id: this.space.id,
723
+ status: SpaceStatus.DPE_FETCH,
724
+ });
725
+ // force update of location
726
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
727
+ this.space = yield this.spaceService.getSpace(this.space.id);
728
+ this.gettingData = false;
729
+ }), 1500);
730
+ });
731
+ }
732
+ setGuestLink() {
733
+ if (this.space.guestLink) {
734
+ const { origin } = document.location;
735
+ this.guestLink = `${origin}/${this.space.guestLink}`;
736
+ setTimeout(() => {
737
+ const hyperlink = document.querySelector("#linkHref");
738
+ const message = this.translate.instant("confirm.followLink");
739
+ hyperlink.addEventListener("click", () => __awaiter(this, void 0, void 0, function* () {
740
+ if (window.confirm(message)) {
741
+ window.location.href = this.guestLink;
742
+ yield this.userService.logoutCurrentAndSignOutAuth();
743
+ this.router.navigate(["auth"]);
744
+ }
745
+ }));
746
+ }, 0);
747
+ }
748
+ }
749
+ setCanArchive() {
750
+ return __awaiter(this, void 0, void 0, function* () {
751
+ this.canArchive = this.userService.isSPAdmin()
752
+ ? true
753
+ : yield this.spaceService.canArchiveSpace(this.id);
754
+ });
755
+ }
756
+ }
757
+ 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 });
758
+ 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()\" data-testid=\"location-edit-btn\">{{'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: i6.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: i6.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 } });
759
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: DetailLocationComponent, decorators: [{
760
+ type: Component,
761
+ 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()\" data-testid=\"location-edit-btn\">{{'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: [""] }]
762
+ }], ctorParameters: function () { return [{ type: i1.ActivatedRoute }, { type: i2.SpaceService }, { type: i1.Router }, { type: i2.BaseUserService }, { type: i3.TranslateService }, { type: i2.NavigatorService }]; } });
763
+
764
+ class CalibrationComponent {
765
+ constructor(matterportImportService, planService, route, router, zoneService, spaceService, navigationService, translate) {
766
+ this.matterportImportService = matterportImportService;
767
+ this.planService = planService;
768
+ this.route = route;
769
+ this.router = router;
770
+ this.zoneService = zoneService;
771
+ this.spaceService = spaceService;
772
+ this.navigationService = navigationService;
773
+ this.translate = translate;
774
+ /** Item to display for the navbar */
775
+ this.menuItems = [];
776
+ /** Zoom ratio of the canvas/plan */
777
+ this.canvasZoom = 0;
778
+ /** Opacity for matterport iframe */
779
+ this.opacity = 50;
780
+ /** Current rotation for matterport, [0-360], matterport rotation is bind to input range */
781
+ this.rotation = 180;
782
+ /** Previous rotation, use to calculate the deltaRotation to rotate, when user change rotation value using range input */
783
+ this.prevRotation = 180;
784
+ /** True when the user is currently rotating with the input range, the matterport rotation events will be ignored */
785
+ this.isRotatingRange = false;
786
+ /** Rotating queue event to send to matterport */
787
+ this.rotatingQueueEvent = [];
788
+ /** True when Vertical symmetry is enabled */
789
+ this.reflectV = false;
790
+ /** True when Horizontal symmetry is enabled */
791
+ this.reflectH = false;
792
+ this.chosenPlanIsPdf = false;
793
+ /** First Point in visit, used to determine the calibration */
794
+ this.firstMarkVisit = { x: 0, y: 0 };
795
+ /** Second Point in visit, used to determine the calibration */
796
+ this.secondMarkVisit = { x: 0.5, y: 0.5 };
797
+ /** Equivalent of 'firstMarkVisit' in canvas */
798
+ this.firstMarkPlan = { x: 0, y: 0 };
799
+ /** Equivalent of 'secondMarkVisit' in canvas */
800
+ this.secondMarkPlan = { x: 0, y: 0 };
801
+ /** Calibration result, (offsetX, offsetY, x, y) */
802
+ this.calibrage = {};
803
+ /** Is in preview mode (see scan result) */
804
+ this.preview = false;
805
+ /** Matterport is loading */
806
+ this.loading = true;
807
+ this.positions = [];
808
+ this.floors = [];
809
+ this.zoomCanBeChanged = false;
810
+ }
811
+ ngOnDestroy() {
812
+ if (!this.loading) {
813
+ this.matterportImportService.removeFrame();
814
+ }
815
+ }
816
+ ngOnInit() {
817
+ return __awaiter(this, void 0, void 0, function* () {
818
+ this.spaceID = this.route.snapshot.queryParams.spaceID;
819
+ this.currentSpace = yield this.spaceService.getSpace(this.spaceID);
820
+ /** Menu nav bar */
821
+ this.setupMenuItems();
822
+ this.chosenPlan = this.planService.getChosenPlan();
823
+ if (this.chosenPlan) {
824
+ this.chosenPlanIsPdf = this.chosenPlan.annexe.includes('pdf');
825
+ this.launchViewer();
826
+ setTimeout(() => {
827
+ this.configureCanvas().then(() => {
828
+ this.panzoom = panzoom(this.canvas, {
829
+ bounds: true,
830
+ boundsPadding: 0,
831
+ maxZoom: 2.5,
832
+ minZoom: 0.1,
833
+ initialZoom: 1,
834
+ zoomSpeed: 0.02,
835
+ });
836
+ });
837
+ }, 500);
838
+ }
839
+ else {
840
+ this.router.navigate(['/dashboard/localisation', this.spaceID, 'plans']);
841
+ }
842
+ });
843
+ }
844
+ /** **********************************************************************************************
845
+ * MENU NAV BAR
846
+ *********************************************************************************************** */
847
+ setupMenuItems() {
848
+ this.menuItems = [
849
+ { label: 'Locations', url: '/localisation' },
850
+ {
851
+ label: this.currentSpace.name,
852
+ url: `/localisation/${this.spaceID}`,
853
+ },
854
+ {
855
+ label: 'Plans',
856
+ url: `/localisation/${this.currentSpace.id}/plans`,
857
+ },
858
+ {
859
+ label: 'Calibration',
860
+ url: `/localisation/${this.currentSpace.id}/plan-calibration?spaceID=${this.currentSpace.id}`,
861
+ },
862
+ ];
863
+ }
864
+ /** **********************************************************************************************
865
+ * CANVAS
866
+ *********************************************************************************************** */
867
+ /** Display the plan */
868
+ configureCanvas() {
869
+ return __awaiter(this, void 0, void 0, function* () {
870
+ /** Get canvas */
871
+ if (!this.canvas) {
872
+ const canvas = document.querySelector('#canvas');
873
+ this.canvas = canvas;
874
+ }
875
+ if (!this.chosenPlanIsPdf) {
876
+ const image = yield getMetaForImage(this.chosenPlan.filepath);
877
+ /** Compute the new size for the canvas/matterport, base on the dimension of the plan, keeping the ratio */
878
+ const size = this.getSizeForCanvas(image.width, image.height);
879
+ /** Compute the plan zoom ratio (use for the calibration later) */
880
+ this.canvasZoom = size.w / image.width;
881
+ this.resizeView(size);
882
+ /** Draw Plan on the canvas */
883
+ this.drawImage(this.chosenPlan.filepath);
884
+ }
885
+ else {
886
+ // TODO
887
+ this.pdfToCanvas();
888
+ }
889
+ });
890
+ }
891
+ /** Update size of the canvas/matterport */
892
+ resizeView(size) {
893
+ this.canvasDiv.nativeElement.style.width = `${size.w}px`;
894
+ this.canvasDiv.nativeElement.style.height = `${size.h}px`;
895
+ this.canvas.style.width = `${size.w}px`;
896
+ this.canvas.style.height = `${size.h}px`;
897
+ this.canvas.width = size.w;
898
+ this.canvas.height = size.h;
899
+ this.canvasSize = size;
900
+ }
901
+ /** Draw something on the canvas */
902
+ drawImage(url, x = 0, y = 0, icone = false) {
903
+ const image = new Image();
904
+ const size = this.canvasSize;
905
+ const context = this.canvas.getContext('2d');
906
+ /** Flip the context, for symmetry */
907
+ // if (this.reflectV) {
908
+ // context.translate(size.w, 0);
909
+ // context.scale(-1, 1);
910
+ // }
911
+ // if (this.reflectH) {
912
+ // context.translate(0, size.h);
913
+ // context.scale(1, -1);
914
+ // }
915
+ let imageWidth = size.w;
916
+ let imageHeight = size.h;
917
+ image.addEventListener('load', () => {
918
+ if (icone) {
919
+ imageWidth = image.width;
920
+ imageHeight = image.height;
921
+ }
922
+ context.drawImage(image, 0, 0, image.width, image.height, x, y, imageWidth, imageHeight);
923
+ });
924
+ image.src = url;
925
+ }
926
+ /** Get the size for the canvas, based on the plan size, keeping the ratio */
927
+ getSizeForCanvas(w, h) {
928
+ let canvasW = this.canvasDiv.nativeElement.offsetWidth;
929
+ let canvasH = this.canvasDiv.nativeElement.offsetHeight;
930
+ const imageRatio = w / h;
931
+ const canvasRatio = canvasW / canvasH;
932
+ if (imageRatio > canvasRatio) {
933
+ canvasH = canvasW / imageRatio;
934
+ }
935
+ else {
936
+ canvasW = canvasH * imageRatio;
937
+ }
938
+ return { w: canvasW, h: canvasH };
939
+ }
940
+ /** [TODO] Convert a PDF to a Canvas */
941
+ pdfToCanvas() {
942
+ return __awaiter(this, void 0, void 0, function* () {
943
+ const pdfjs = yield import('pdfjs-dist/build/pdf');
944
+ const pdfjsWorker = yield import('pdfjs-dist/build/pdf.worker.entry');
945
+ pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
946
+ const pdf = yield getDocument(this.chosenPlan.filepath)
947
+ .promise;
948
+ const page = yield pdf.getPage(1);
949
+ const viewPortParameters = { scale: 1 };
950
+ const viewport = page.getViewport(viewPortParameters);
951
+ this.canvas.height = viewport.height;
952
+ this.canvas.width = viewport.width;
953
+ const size = this.getSizeForCanvas(viewport.width, viewport.height);
954
+ console.log(size);
955
+ this.canvasSize = size;
956
+ this.canvasZoom = size.w / viewport.width;
957
+ const context = this.canvas.getContext('2d');
958
+ const renderContext = {
959
+ canvasContext: context,
960
+ viewport,
961
+ };
962
+ const renderTask = page.render(renderContext).promise;
963
+ renderTask.then(() => console.log('Page rendered'));
964
+ // const res = canvas.toDataURL();
965
+ // if (pdf != null) pdf.destroy();
966
+ // return res;
967
+ });
968
+ }
969
+ /** User click to user Symmetry Vertical */
970
+ onReflectV() {
971
+ this.reflectV = !this.reflectV;
972
+ this.configureCanvas();
973
+ }
974
+ /** User click to user Symmetry Horizontal */
975
+ onReflectH() {
976
+ this.reflectH = !this.reflectH;
977
+ this.configureCanvas();
978
+ }
979
+ /** **********************************************************************************************
980
+ * MATTERPORT
981
+ *********************************************************************************************** */
982
+ /** Launch matterport */
983
+ launchViewer() {
984
+ return __awaiter(this, void 0, void 0, function* () {
985
+ yield this.matterportImportService.initSdkForModel(this.chosenPlan.model3d);
986
+ const { sdk } = this.matterportImportService;
987
+ this.floors = Object.values(this.matterportImportService.floors);
988
+ // console.log(this.floors);
989
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
990
+ /** Move Floor mode */
991
+ sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN).then((nextMode) => __awaiter(this, void 0, void 0, function* () {
992
+ /** Display the correct floor for the plan */
993
+ try {
994
+ const matterportFloor = this.chosenPlan.zone.metadata ?
995
+ JSON.parse(this.chosenPlan.zone.metadata).matterportFloorSequence : null;
996
+ yield this.matterportImportService.moveToFloor(this.chosenPlan.zone.name, matterportFloor);
997
+ /** When the user try to change the view mode we set it back to floorpan */
998
+ sdk.on(sdk.Mode.Event.CHANGE_END, (oldMode, newMode) => {
999
+ if (newMode !== sdk.Mode.Mode.FLOORPLAN) {
1000
+ sdk.Mode.moveTo(sdk.Mode.Mode.FLOORPLAN, {
1001
+ transition: 'transition.instant',
1002
+ });
1003
+ }
1004
+ });
1005
+ }
1006
+ catch (_a) {
1007
+ console.log('couldnot move to floor');
1008
+ }
1009
+ }));
1010
+ /** We can display the matterport view now */
1011
+ this.loading = false;
1012
+ }), 1000);
1013
+ /** Update current camera pose and rotation */
1014
+ sdk.Camera.pose.subscribe((event) => {
1015
+ /** We update only if the user is not changing the rotation with the <input> range, to not override the <input> value */
1016
+ if (!this.isRotatingRange) {
1017
+ this.rotation = event.rotation.y + 180;
1018
+ this.prevRotation = this.rotation;
1019
+ this.cameraPose = event;
1020
+ }
1021
+ });
1022
+ });
1023
+ }
1024
+ /** When the <input> range, for rotation, change */
1025
+ onRotationChange() {
1026
+ return __awaiter(this, void 0, void 0, function* () {
1027
+ const rotationDelta = this.rotation - this.prevRotation;
1028
+ this.prevRotation = this.rotation;
1029
+ /** Send the rotationDelta to th queue event in order to be send to matterport */
1030
+ this.rotatingQueueEvent.push(rotationDelta);
1031
+ /** Start to process the queue, if it's the first event */
1032
+ if (!this.isRotatingRange) {
1033
+ this.isRotatingRange = true;
1034
+ this.processRotatingQueueEvent();
1035
+ }
1036
+ });
1037
+ }
1038
+ /** Process the rotating event queue, send event one by one to matterport */
1039
+ processRotatingQueueEvent() {
1040
+ return __awaiter(this, void 0, void 0, function* () {
1041
+ const { sdk } = this.matterportImportService;
1042
+ /** While the queue is not empty */
1043
+ while (this.rotatingQueueEvent.length > 0) {
1044
+ /** Rotate matterport by deltaRotation and remove event from queue */
1045
+ yield sdk.Camera.rotate(this.rotatingQueueEvent.shift(), 0, {
1046
+ speed: 360,
1047
+ });
1048
+ }
1049
+ /** When the queue is empty, then the user is not rotating with the <input> range anymore */
1050
+ this.isRotatingRange = false;
1051
+ });
1052
+ }
1053
+ /** **********************************************************************************************
1054
+ * USER ACTIONS
1055
+ *********************************************************************************************** */
1056
+ /** Preview calibration */
1057
+ onPreview() {
1058
+ return __awaiter(this, void 0, void 0, function* () {
1059
+ this.preview = true;
1060
+ /** Place sweeps */
1061
+ this.onPlaceSweeps();
1062
+ });
1063
+ }
1064
+ calibrate() {
1065
+ return __awaiter(this, void 0, void 0, function* () {
1066
+ const [navigation] = this.currentNavigations;
1067
+ const position = JSON.parse(navigation.position);
1068
+ this.firstMarkPlan =
1069
+ yield this.matterportImportService.sdk.Renderer.getScreenPosition({
1070
+ x: position.x,
1071
+ y: position.y,
1072
+ z: position.z,
1073
+ });
1074
+ this.secondMarkPlan =
1075
+ yield this.matterportImportService.sdk.Renderer.getScreenPosition({
1076
+ x: position.x,
1077
+ y: 0,
1078
+ z: 0,
1079
+ });
1080
+ const deltaZVisit = 0 - position.z;
1081
+ let deltaXPlan = this.secondMarkPlan.x - this.firstMarkPlan.x;
1082
+ if (deltaXPlan === 0) {
1083
+ // console.log("we moved along Y axis on Plan");
1084
+ const deltaYPlan = this.secondMarkPlan.y - this.firstMarkPlan.y;
1085
+ this.calibrage.nameYAxis = 'z';
1086
+ this.calibrage.nameXAxis = 'x';
1087
+ this.calibrage.offsetY = this.secondMarkPlan.y;
1088
+ this.calibrage.scaleY = deltaYPlan / deltaZVisit;
1089
+ }
1090
+ else {
1091
+ // console.log(" we moved along X axis on Plan");
1092
+ this.calibrage.nameYAxis = 'x';
1093
+ this.calibrage.nameXAxis = 'z';
1094
+ this.calibrage.offsetX = this.secondMarkPlan.x;
1095
+ this.calibrage.scaleX = deltaXPlan / deltaZVisit;
1096
+ }
1097
+ const thirdMarkPlan = yield this.matterportImportService.sdk.Renderer.getScreenPosition({
1098
+ x: 0,
1099
+ y: 0,
1100
+ z: position.z,
1101
+ });
1102
+ const deltaXVisit = 0 - position.x;
1103
+ if (deltaXPlan === 0) {
1104
+ // console.log(" we moved along X axis on Plan");
1105
+ deltaXPlan = thirdMarkPlan.x - this.firstMarkPlan.x;
1106
+ this.calibrage.offsetX = thirdMarkPlan.x;
1107
+ this.calibrage.scaleX = deltaXPlan / deltaXVisit;
1108
+ }
1109
+ else {
1110
+ const deltaYPlan = thirdMarkPlan.y - this.firstMarkPlan.y;
1111
+ this.calibrage.offsetY = thirdMarkPlan.y;
1112
+ this.calibrage.scaleY = deltaYPlan / deltaXVisit;
1113
+ }
1114
+ /** Take considiration of pan and zoom of plan on canvas */
1115
+ const transformInfo = this.panzoom.getTransform();
1116
+ const { scale, x, y } = transformInfo;
1117
+ // console.log(transformInfo);
1118
+ this.calibrage.offsetXPlan = x;
1119
+ this.calibrage.offsetYPlan = y;
1120
+ this.calibrage.scalePlan = scale;
1121
+ console.log(this.calibrage);
1122
+ });
1123
+ }
1124
+ /** Place sweeps */
1125
+ onPlaceSweeps() {
1126
+ return __awaiter(this, void 0, void 0, function* () {
1127
+ /** Display all scan */
1128
+ const zone = yield this.zoneService.getZone(this.chosenPlan.zoneID);
1129
+ if (zone) {
1130
+ this.currentZone = zone;
1131
+ const navigations = yield this.navigationService.getNavigationsForZone(this.currentZone);
1132
+ this.currentNavigations = navigations;
1133
+ yield this.calibrate();
1134
+ if (navigations.length > 0) {
1135
+ for (const navigation of navigations) {
1136
+ const testPosition = JSON.parse(navigation.position);
1137
+ const positionX = this.calibrage.nameXAxis === 'x' ? testPosition.x : testPosition.z;
1138
+ const positionY = this.calibrage.nameYAxis === 'x' ? testPosition.x : testPosition.z;
1139
+ const testX = positionX * this.calibrage.scaleX + this.calibrage.offsetX;
1140
+ const testY = positionY * this.calibrage.scaleY + this.calibrage.offsetY;
1141
+ // console.log("test position GREEN", testX, testY);
1142
+ const transformedX = (testX - this.calibrage.offsetXPlan) / this.calibrage.scalePlan; // we are undoing the pan and zoom
1143
+ const transformedY = (testY - this.calibrage.offsetYPlan) / this.calibrage.scalePlan;
1144
+ this.positions.push({
1145
+ navID: navigation.id,
1146
+ planID: this.chosenPlan.id,
1147
+ x: transformedX,
1148
+ y: transformedY,
1149
+ });
1150
+ const iconSize = 30 * this.calibrage.scalePlan;
1151
+ const shift = iconSize / 2;
1152
+ this.drawImage('https://api.iconify.design/mdi:adjust.svg?color=green&height=30&width=30', transformedX - shift, transformedY - shift, true);
1153
+ }
1154
+ }
1155
+ }
1156
+ });
1157
+ }
1158
+ /** Save calibration */
1159
+ onSave() {
1160
+ return __awaiter(this, void 0, void 0, function* () {
1161
+ if (this.currentZone) {
1162
+ /** Normalize with the zoom */
1163
+ // this.calibrage.offsetX /= this.canvasZoom;
1164
+ // this.calibrage.offsetY /= this.canvasZoom;
1165
+ // this.calibrage.x /= this.canvasZoom;
1166
+ // this.calibrage.y /= this.canvasZoom;
1167
+ this.calibrage.new = true;
1168
+ this.calibrage.imgWidth = this.canvasSize.w;
1169
+ this.calibrage.imgHeight = this.canvasSize.h;
1170
+ yield this.planService.updatePlan({
1171
+ id: this.chosenPlan.id,
1172
+ calibration: JSON.stringify(this.calibrage),
1173
+ });
1174
+ yield Promise.all(this.positions.map((position) => __awaiter(this, void 0, void 0, function* () {
1175
+ const { navID } = position;
1176
+ delete position.navID;
1177
+ const nav = this.currentNavigations.find((_nav) => _nav.id === navID);
1178
+ let positionsDataToUpdate;
1179
+ if (nav.positionOnPlan) {
1180
+ const positionOnPlan = nav.positionOnPlan.map((entry) => JSON.parse(entry));
1181
+ const positionForCurrentPlan = positionOnPlan.find((entry) => entry.planID === this.chosenPlan.id);
1182
+ if (positionForCurrentPlan) {
1183
+ positionOnPlan.splice(positionOnPlan.indexOf(positionForCurrentPlan), 1, position);
1184
+ }
1185
+ else {
1186
+ positionOnPlan.push(position);
1187
+ }
1188
+ positionsDataToUpdate = [...positionOnPlan];
1189
+ }
1190
+ else {
1191
+ positionsDataToUpdate = [position];
1192
+ }
1193
+ // console.log(positionsDataToUpdate);
1194
+ yield this.navigationService.updateNavigation({
1195
+ id: navID,
1196
+ positionOnPlan: positionsDataToUpdate.map((entry) => JSON.stringify(entry)),
1197
+ });
1198
+ })));
1199
+ }
1200
+ this.matterportImportService.removeFrame();
1201
+ this.router.navigate(['/dashboard/localisation', this.spaceID, 'plans']);
1202
+ alert(this.translate.instant('calibration.success'));
1203
+ });
1204
+ }
1205
+ /** Reset the canvas */
1206
+ onReset() {
1207
+ this.reflectH = false;
1208
+ this.reflectV = false;
1209
+ this.preview = false;
1210
+ this.configureCanvas();
1211
+ }
1212
+ /** Cancel, leave */
1213
+ onCancel() {
1214
+ this.matterportImportService.removeFrame();
1215
+ this.router.navigate(['/dashboard/localisation', this.spaceID, 'plans']);
1216
+ alert(this.translate.instant('calibration.canceled'));
1217
+ }
1218
+ onFloorClick(floor) {
1219
+ return __awaiter(this, void 0, void 0, function* () {
1220
+ this.currentFloor = floor;
1221
+ yield this.matterportImportService.moveToFloor(floor.id);
1222
+ });
1223
+ }
1224
+ onActivateZoomChange() {
1225
+ this.zoomCanBeChanged = !this.zoomCanBeChanged;
1226
+ const iframe = document.querySelector('#viewer-frame');
1227
+ if (iframe) {
1228
+ iframe.style.zIndex = this.zoomCanBeChanged ? '1' : '0';
1229
+ }
1230
+ }
1231
+ }
1232
+ 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 });
1233
+ 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 class=\"legend-bar-indicator\" [ngStyle]=\"{'opacity': 'calc(' + (-(opacity-100)+10) + '/ 100)'}\">\n {{'Less' | translate}}</div>\n <div class=\"legend-title\">{{'Plan Opacity' | translate }}</div>\n <div class=\"legend-bar-indicator\" [ngStyle]=\"{'opacity': 'calc(' + (opacity+10) + '/ 100)'}\">{{'More' |\n 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=\"tool-checkbox-container\">\n <div class=\"tool-checkbox-subcontainer\">\n <div class=\"label-legend me-3\">{{'Pan/Zoom Visit' | translate}} {{zoomCanBeChanged ? \"ON\" :\n \"OFF\"}}\n </div>\n <input type=\"checkbox\" (change)=\"onActivateZoomChange()\" style=\"margin-top: 5px;\">\n </div>\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 </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);margin:auto;width:100%;font-weight:700;display:flex;justify-content:center}.tool .legend-bar-indicator{width:15%!important}.tool .label-legend{color:var(--smarterplan-primary);font-size:1.1rem;max-width:55%}.tool .tool-checkbox-container{display:flex;flex-direction:column}.tool .tool-checkbox-container .tool-checkbox-subcontainer{display:flex}.blur{width:150px;height:52px;position:absolute;background-color:#1e2023;bottom:0}.symmetry{padding:5px;border:solid 2px;border-radius:10px;color:var(--smarterplan-primary);margin:25px 10px;cursor:pointer}.symmetry:hover{color:var(--smarterplan-primary)}.symmetry-row{justify-content:center}.action{margin-top:30px;display:flex;justify-content:space-evenly}h1{color:var(--smarterplan-primary);text-align:center;margin-bottom:20px}h3{color:var(--smarterplan-primary);text-align:center;margin-bottom:10px}.btn-outline-primary.disabled{background-color:var(--smarterplan-orange)!important}\n"], components: [{ type: TabNavigationComponent, selector: "lib-tab-navigation", inputs: ["menuItems"], outputs: ["onGoBack"] }], directives: [{ type: i6.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i6.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: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgbDropdownItem, selector: "[ngbDropdownItem]", inputs: ["disabled"] }], pipes: { "translate": i3.TranslatePipe } });
1234
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CalibrationComponent, decorators: [{
1235
+ type: Component,
1236
+ 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 class=\"legend-bar-indicator\" [ngStyle]=\"{'opacity': 'calc(' + (-(opacity-100)+10) + '/ 100)'}\">\n {{'Less' | translate}}</div>\n <div class=\"legend-title\">{{'Plan Opacity' | translate }}</div>\n <div class=\"legend-bar-indicator\" [ngStyle]=\"{'opacity': 'calc(' + (opacity+10) + '/ 100)'}\">{{'More' |\n 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=\"tool-checkbox-container\">\n <div class=\"tool-checkbox-subcontainer\">\n <div class=\"label-legend me-3\">{{'Pan/Zoom Visit' | translate}} {{zoomCanBeChanged ? \"ON\" :\n \"OFF\"}}\n </div>\n <input type=\"checkbox\" (change)=\"onActivateZoomChange()\" style=\"margin-top: 5px;\">\n </div>\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 </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);margin:auto;width:100%;font-weight:700;display:flex;justify-content:center}.tool .legend-bar-indicator{width:15%!important}.tool .label-legend{color:var(--smarterplan-primary);font-size:1.1rem;max-width:55%}.tool .tool-checkbox-container{display:flex;flex-direction:column}.tool .tool-checkbox-container .tool-checkbox-subcontainer{display:flex}.blur{width:150px;height:52px;position:absolute;background-color:#1e2023;bottom:0}.symmetry{padding:5px;border:solid 2px;border-radius:10px;color:var(--smarterplan-primary);margin:25px 10px;cursor:pointer}.symmetry:hover{color:var(--smarterplan-primary)}.symmetry-row{justify-content:center}.action{margin-top:30px;display:flex;justify-content:space-evenly}h1{color:var(--smarterplan-primary);text-align:center;margin-bottom:20px}h3{color:var(--smarterplan-primary);text-align:center;margin-bottom:10px}.btn-outline-primary.disabled{background-color:var(--smarterplan-orange)!important}\n"] }]
1237
+ }], 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: [{
1238
+ type: ViewChild,
1239
+ args: ['canvasDiv']
1240
+ }] } });
1241
+
1242
+ class PlansComponent {
1243
+ constructor(route, router, spaceService, planService, fb, translate, navigatorService) {
1244
+ this.route = route;
1245
+ this.router = router;
1246
+ this.spaceService = spaceService;
1247
+ this.planService = planService;
1248
+ this.fb = fb;
1249
+ this.translate = translate;
1250
+ this.navigatorService = navigatorService;
1251
+ // chosenPlan: Plan;
1252
+ this.indexDetails = -1;
1253
+ this.loading = false;
1254
+ this.uploadingPlan = false;
1255
+ this.isCurrentPlanForZone = false;
1256
+ this.chosenPlanIsPdf = false;
1257
+ this.menuItems = [];
1258
+ this.destroy$ = new Subject();
1259
+ this.navigatorService.locationIDChange
1260
+ .pipe(takeUntil(this.destroy$))
1261
+ .subscribe((spaceID) => {
1262
+ this.router.navigate(["dashboard/localisation", spaceID, "plans"]);
1263
+ });
1264
+ this.route.params.subscribe((params) => {
1265
+ this.spaceID = params.id;
1266
+ this.getPlans();
1267
+ });
1268
+ }
1269
+ ngOnInit() {
1270
+ if (this.planService.getPlanFileCache() &&
1271
+ this.planService.getChosenPlan()) {
1272
+ this.addPlanFromCache(this.planService.getPlanFileCache(), this.planService.getChosenPlan());
1273
+ this.planService.setPlanFileCache(null);
1274
+ }
1275
+ this.planService.setChosenPlan(null);
1276
+ }
1277
+ ngOnDestroy() {
1278
+ this.destroy$.next(true);
1279
+ this.destroy$.complete();
1280
+ }
1281
+ setupMenuItems() {
1282
+ this.menuItems = [
1283
+ { label: "Locations", url: "/localisation" },
1284
+ {
1285
+ label: this.currentSpace.name,
1286
+ url: `/localisation/${this.currentSpace.id}`,
1287
+ },
1288
+ {
1289
+ label: "Plans",
1290
+ url: `/localisation/${this.currentSpace.id}/plans`,
1291
+ },
1292
+ ];
1293
+ }
1294
+ onGoBack() { }
1295
+ onPlanClick(plan) {
1296
+ return __awaiter(this, void 0, void 0, function* () {
1297
+ if (plan)
1298
+ this.planService.setChosenPlan(plan);
1299
+ this.chosenPlanIsPdf = plan.annexe.includes("pdf");
1300
+ if (!this.chosenPlanIsPdf) {
1301
+ setTimeout(() => {
1302
+ this.configureCanvas().then(() => {
1303
+ this.panzoom = panzoom(this.canvas, {
1304
+ bounds: true,
1305
+ boundsPadding: 0,
1306
+ maxZoom: 3.5,
1307
+ minZoom: 0.1,
1308
+ initialZoom: 0.5,
1309
+ });
1310
+ });
1311
+ }, 500);
1312
+ }
1313
+ });
1314
+ }
1315
+ configureCanvas() {
1316
+ return __awaiter(this, void 0, void 0, function* () {
1317
+ this.uploadingPlan = true;
1318
+ const canvas = document.querySelector("#canvas");
1319
+ const image = yield getMetaForImage(this.getChoosenPlan().filepath);
1320
+ canvas.width = image.width;
1321
+ canvas.height = image.height;
1322
+ this.canvas = canvas;
1323
+ this.drawImage(this.getChoosenPlan().filepath);
1324
+ this.uploadingPlan = false;
1325
+ });
1326
+ }
1327
+ drawImage(url, x = 0, y = 0) {
1328
+ const image = new Image();
1329
+ const context = this.canvas.getContext("2d");
1330
+ const imageWidth = this.canvas.width;
1331
+ const imageHeight = this.canvas.height;
1332
+ image.addEventListener("load", () => {
1333
+ context.drawImage(image, 0, 0, image.width, image.height, x, y, imageWidth, imageHeight);
1334
+ });
1335
+ image.src = url;
1336
+ // image.crossOrigin = "*"; //need to download as png,
1337
+ // BUT: https://stackoverflow.com/questions/49503171/the-image-tag-with-crossorigin-anonymous-cant-load-success-from-s3
1338
+ }
1339
+ getPlans() {
1340
+ return __awaiter(this, void 0, void 0, function* () {
1341
+ this.loading = true;
1342
+ this.currentSpace = yield this.spaceService.getSpace(this.spaceID);
1343
+ this.setupMenuItems();
1344
+ this.zones = this.currentSpace.zones.items;
1345
+ this.plans = yield this.planService.getSingedPlansForSpace(this.spaceID);
1346
+ this.loading = false;
1347
+ if (this.plans.length === 1) {
1348
+ this.onPlanClick(this.plans[0]);
1349
+ }
1350
+ });
1351
+ }
1352
+ getChoosenPlan() {
1353
+ return this.planService.getChosenPlan();
1354
+ }
1355
+ removeImage() {
1356
+ const context = this.canvas.getContext("2d");
1357
+ context.clearRect(0, 0, 4096, 4096);
1358
+ }
1359
+ /**
1360
+ *
1361
+ */
1362
+ onCalibrateClick() {
1363
+ if (this.getChoosenPlan()) {
1364
+ this.router.navigate(["/dashboard/localisation", this.spaceID, "plan-calibration"], { queryParams: { spaceID: this.spaceID } });
1365
+ }
1366
+ }
1367
+ /**
1368
+ *
1369
+ */
1370
+ onEditClick() {
1371
+ if (this.getChoosenPlan()) {
1372
+ this.router.navigate(["/dashboard/localisation", this.spaceID, "plan-edit"], { queryParams: { spaceID: this.spaceID } });
1373
+ }
1374
+ }
1375
+ onUploadClick() {
1376
+ const inputFile = document.querySelector("#upload-file");
1377
+ inputFile.click();
1378
+ }
1379
+ addPlan(target) {
1380
+ this.fileToUpload = target.files[0];
1381
+ this.planForm = this.fb.group({
1382
+ name: [this.fileToUpload.name, [Validators.required]],
1383
+ zoneID: [null, [Validators.required]],
1384
+ spaceID: this.spaceID,
1385
+ isModified: false,
1386
+ calibration: "",
1387
+ });
1388
+ }
1389
+ addPlanFromCache(file, plan) {
1390
+ this.fileToUpload = file;
1391
+ this.planForm = this.fb.group({
1392
+ name: [this.fileToUpload.name, [Validators.required]],
1393
+ zoneID: [plan ? plan.zoneID : null, [Validators.required]],
1394
+ spaceID: this.spaceID,
1395
+ isModified: !!plan,
1396
+ calibration: plan && plan.isModified && plan.calibration
1397
+ ? plan.calibration
1398
+ : "",
1399
+ });
1400
+ }
1401
+ onSavePlan() {
1402
+ return __awaiter(this, void 0, void 0, function* () {
1403
+ const formValue = this.planForm.value;
1404
+ formValue.isCurrentForZone = this.isCurrentPlanForZone;
1405
+ const createdPlan = yield this.planService.createPlanWithAnnexe(formValue, this.fileToUpload);
1406
+ const filepath = yield getSignedFile(createdPlan.annexe);
1407
+ if (filepath) {
1408
+ createdPlan.filepath = filepath;
1409
+ }
1410
+ if (formValue.isCurrentForZone) {
1411
+ // set all other plans to not current
1412
+ this.planService.setAllPlansForZoneNotCurrent(createdPlan.zoneID, createdPlan.id);
1413
+ }
1414
+ this.plans.push(createdPlan);
1415
+ this.planForm = null;
1416
+ this.fileToUpload = null;
1417
+ });
1418
+ }
1419
+ onCancelUpload() {
1420
+ this.fileToUpload = null;
1421
+ this.planForm = null;
1422
+ }
1423
+ onCurrentPlanClick() {
1424
+ return __awaiter(this, void 0, void 0, function* () {
1425
+ yield this.planService.updatePlan({
1426
+ id: this.getChoosenPlan().id,
1427
+ isCurrentForZone: this.getChoosenPlan().isCurrentForZone,
1428
+ });
1429
+ if (this.getChoosenPlan().isCurrentForZone) {
1430
+ this.planService.setAllPlansForZoneNotCurrent(this.getChoosenPlan().zoneID, this.getChoosenPlan().id);
1431
+ }
1432
+ });
1433
+ }
1434
+ onDownloadClick() {
1435
+ return __awaiter(this, void 0, void 0, function* () {
1436
+ const signedFile = yield downloadFileAsObject(this.getChoosenPlan().annexe);
1437
+ if (signedFile) {
1438
+ // @ts-ignore
1439
+ downloadBlob(signedFile.Body, this.getChoosenPlan().name);
1440
+ }
1441
+ });
1442
+ }
1443
+ onDownloadAsPng() {
1444
+ return __awaiter(this, void 0, void 0, function* () {
1445
+ const canvas = document.querySelector("#canvas");
1446
+ canvas.toBlob(function (blob) {
1447
+ downloadBlob(blob, "plan-as-png.png");
1448
+ });
1449
+ });
1450
+ }
1451
+ onRemoveClick() {
1452
+ return __awaiter(this, void 0, void 0, function* () {
1453
+ const message = this.translate.instant("confirm.deletePlan");
1454
+ if (window.confirm(message)) {
1455
+ yield this.planService.deletePlan(this.getChoosenPlan());
1456
+ this.removeImage();
1457
+ this.planService.setChosenPlan(null);
1458
+ this.getPlans();
1459
+ }
1460
+ });
1461
+ }
1462
+ }
1463
+ 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 }, { token: i2.NavigatorService }], target: i0.ɵɵFactoryTarget.Component });
1464
+ 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: i6.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: i6.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 } });
1465
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: PlansComponent, decorators: [{
1466
+ type: Component,
1467
+ 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"] }]
1468
+ }], ctorParameters: function () { return [{ type: i1.ActivatedRoute }, { type: i1.Router }, { type: i2.SpaceService }, { type: i2.PlanService }, { type: i1$2.FormBuilder }, { type: i3.TranslateService }, { type: i2.NavigatorService }]; } });
1469
+
1470
+ class ChevronComponent {
1471
+ constructor() {
1472
+ this.conditionShowing = false;
1473
+ }
1474
+ ngOnInit() {
1475
+ }
1476
+ }
1477
+ ChevronComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ChevronComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1478
+ 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"] });
1479
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ChevronComponent, decorators: [{
1480
+ type: Component,
1481
+ 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"] }]
1482
+ }], ctorParameters: function () { return []; }, propDecorators: { conditionShowing: [{
1483
+ type: Input
1484
+ }] } });
1485
+
1486
+ class VisitsComponent {
1487
+ constructor(fb, matterportImportService, captureService, nodeService, spaceService, route, modalService, visitService, validatorsService, translate, navigatorService, router) {
1488
+ this.fb = fb;
1489
+ this.matterportImportService = matterportImportService;
1490
+ this.captureService = captureService;
1491
+ this.nodeService = nodeService;
1492
+ this.spaceService = spaceService;
1493
+ this.route = route;
1494
+ this.modalService = modalService;
1495
+ this.visitService = visitService;
1496
+ this.validatorsService = validatorsService;
1497
+ this.translate = translate;
1498
+ this.navigatorService = navigatorService;
1499
+ this.router = router;
1500
+ this.visitIndexDetails = -1;
1501
+ this.isEditing = false;
1502
+ this.visitSubmitted = false;
1503
+ this.currentSpace = { zones: [] };
1504
+ this.visits = [];
1505
+ this.canCancelImport = false;
1506
+ this.imagesProcessed = 0;
1507
+ this.totalImages = 0;
1508
+ this.menuItems = [];
1509
+ this.errorForm = false;
1510
+ this.isProcessing = false;
1511
+ this.destroy$ = new Subject();
1512
+ this.matterportImportService.importingImages.pipe(takeUntil(this.destroy$)).subscribe(() => {
1513
+ this.canCancelImport = true;
1514
+ });
1515
+ this.matterportImportService.sweepProcessedCount.pipe(takeUntil(this.destroy$)).subscribe((count) => {
1516
+ this.imagesProcessed = count + 1;
1517
+ });
1518
+ this.matterportImportService.totalSweepsCount.pipe(takeUntil(this.destroy$)).subscribe((count) => {
1519
+ this.totalImages = count;
1520
+ });
1521
+ this.navigatorService.locationIDChange
1522
+ .pipe(takeUntil(this.destroy$))
1523
+ .subscribe((spaceID) => {
1524
+ this.router.navigate(["dashboard/localisation", spaceID, "visits"]);
1525
+ });
1526
+ this.route.params.subscribe((params) => {
1527
+ this.spaceId = params.id;
1528
+ this.resetVisits();
1529
+ });
1530
+ }
1531
+ ngOnInit() {
1532
+ return __awaiter(this, void 0, void 0, function* () {
1533
+ this.spaceId = this.route.snapshot.paramMap.get('id');
1534
+ yield this.resetVisits();
1535
+ // console.log('visit in import', localStorage.getItem("visitInImport"));
1536
+ if (localStorage.getItem("visitInImport") && localStorage.getItem("indexScanLoad")) {
1537
+ const visitToRetake = this.visits.find((visit) => visit.model3d === localStorage.getItem("visitInImport"));
1538
+ if (visitToRetake.spaceID === this.spaceId) {
1539
+ console.log("retaking import");
1540
+ this.imagesProcessed = parseInt(localStorage.getItem("indexScanLoad"));
1541
+ this.onImport(visitToRetake);
1542
+ }
1543
+ }
1544
+ });
1545
+ }
1546
+ ngOnDestroy() {
1547
+ this.destroy$.next(true);
1548
+ this.destroy$.complete();
1549
+ }
1550
+ /*
1551
+ Visit = {
1552
+ captureID: string,
1553
+ model3d: string,
1554
+ takenAt: number,
1555
+ spaceID: string,
1556
+ viewer: CaptureViewer,
1557
+ surface: number,
1558
+ node: Node,
1559
+ name?: string | null
1560
+ }
1561
+ */
1562
+ setupMenuItems() {
1563
+ this.menuItems = [
1564
+ { label: 'Locations', url: '/localisation' },
1565
+ {
1566
+ label: this.currentSpace.name,
1567
+ url: `/localisation/${this.currentSpace.id}`,
1568
+ },
1569
+ {
1570
+ label: 'Virtual visits',
1571
+ url: `/localisation/${this.currentSpace.id}/visits`,
1572
+ },
1573
+ ];
1574
+ }
1575
+ onGoBack() {
1576
+ this.onCancel();
1577
+ }
1578
+ resetVisits() {
1579
+ return __awaiter(this, void 0, void 0, function* () {
1580
+ this.visits = [];
1581
+ this.currentSpace = yield this.spaceService.getSpace(this.spaceId);
1582
+ this.setupMenuItems();
1583
+ yield this.visitService
1584
+ .getVisitsForSpaceForUser(this.spaceId)
1585
+ .then((visits) => {
1586
+ if (visits) {
1587
+ this.visits = visits;
1588
+ }
1589
+ });
1590
+ });
1591
+ }
1592
+ initVisitForm(input = null) {
1593
+ if (input) {
1594
+ this.visitForm = this.fb.group({
1595
+ captureID: input.captureID,
1596
+ nodeID: input.node.id,
1597
+ name: [input.name, [Validators.required]],
1598
+ model3D: [input.model3d, [Validators.required]],
1599
+ viewer: input.viewer ? input.viewer : CaptureViewer.MATTERPORT,
1600
+ surface: input.surface ? input.surface : null,
1601
+ });
1602
+ this.captureDate = input.takenAt;
1603
+ }
1604
+ else {
1605
+ this.visitForm = this.fb.group({
1606
+ model3D: [null, [Validators.required]],
1607
+ viewer: CaptureViewer.MATTERPORT,
1608
+ surface: null,
1609
+ name: [null, [Validators.required]],
1610
+ });
1611
+ }
1612
+ }
1613
+ onToggleDetail(index) {
1614
+ this.visitIndexDetails = index === this.visitIndexDetails ? -1 : index;
1615
+ }
1616
+ onAddVisit() {
1617
+ this.initVisitForm();
1618
+ this.menuItems.push({ label: 'New' });
1619
+ }
1620
+ onEdit(visit) {
1621
+ this.initVisitForm(visit);
1622
+ this.isEditing = true;
1623
+ this.menuItems.push({ label: visit.name });
1624
+ }
1625
+ onSubmitVisit() {
1626
+ return __awaiter(this, void 0, void 0, function* () {
1627
+ this.visitSubmitted = true;
1628
+ if (!this.visitForm.valid) {
1629
+ this.errorForm = true;
1630
+ return;
1631
+ }
1632
+ this.errorForm = false;
1633
+ const formValue = this.visitForm.value;
1634
+ const capture = {
1635
+ viewer: formValue.viewer,
1636
+ takenAt: this.captureDate,
1637
+ surface: formValue.surface,
1638
+ spaceID: this.currentSpace.id,
1639
+ };
1640
+ if (this.isEditing) {
1641
+ capture.id = formValue.captureID;
1642
+ yield this.captureService.updateCapture(capture);
1643
+ const node = {
1644
+ id: formValue.nodeID,
1645
+ model3D: formValue.model3D,
1646
+ metadata: formValue.name,
1647
+ };
1648
+ yield this.nodeService.updateNode(node);
1649
+ }
1650
+ else {
1651
+ let createdNode;
1652
+ yield this.captureService.createCapture(capture).then((res) => __awaiter(this, void 0, void 0, function* () {
1653
+ if (res) {
1654
+ const node = {
1655
+ model3D: formValue.model3D,
1656
+ captureID: res.id,
1657
+ metadata: formValue.name,
1658
+ };
1659
+ createdNode = yield this.nodeService.createNode(node);
1660
+ }
1661
+ }));
1662
+ this.launchImport(formValue.model3D, formValue.surface, createdNode, false)
1663
+ .then((success) => {
1664
+ this.modalReference.close('import ended with success');
1665
+ })
1666
+ .catch((e) => {
1667
+ this.modalReference.close(`Error while import: ${e}`);
1668
+ alert(`Error while import: ${e} ${JSON.stringify(e)}`);
1669
+ this.onDelete({
1670
+ node: createdNode,
1671
+ captureID: createdNode.captureID,
1672
+ }, false);
1673
+ });
1674
+ }
1675
+ yield this.resetVisits();
1676
+ this.onCancel();
1677
+ });
1678
+ }
1679
+ get model3D() {
1680
+ return this.visitForm.get('model3D');
1681
+ }
1682
+ get name() {
1683
+ return this.visitForm.get('name');
1684
+ }
1685
+ onCancel() {
1686
+ this.visitSubmitted = false;
1687
+ this.visitForm = null;
1688
+ this.isEditing = false;
1689
+ this.canCancelImport = false;
1690
+ this.totalImages = 0;
1691
+ this.imagesProcessed = 0;
1692
+ this.errorForm = false;
1693
+ this.setupMenuItems();
1694
+ }
1695
+ onDelete(visit, needPermission = true) {
1696
+ return __awaiter(this, void 0, void 0, function* () {
1697
+ const message = this.translate.instant('confirm.deleteVisit');
1698
+ // eslint-disable-next-line no-alert
1699
+ if (window.confirm(message) || !needPermission) {
1700
+ console.log(this.visitIndexDetails);
1701
+ this.isProcessing = true;
1702
+ yield this.visitService.deleteVisit(visit, this.spaceId);
1703
+ yield this.resetVisits();
1704
+ this.isProcessing = false;
1705
+ }
1706
+ });
1707
+ }
1708
+ getDismissReason(reason) {
1709
+ if (reason === ModalDismissReasons.ESC) {
1710
+ return 'by pressing ESC';
1711
+ }
1712
+ if (reason === ModalDismissReasons.BACKDROP_CLICK) {
1713
+ return 'by clicking on a backdrop';
1714
+ }
1715
+ return `with: ${reason}`;
1716
+ }
1717
+ launchImport(model3D, surface, node, imagesOnly = false) {
1718
+ return __awaiter(this, void 0, void 0, function* () {
1719
+ this.modalReference = this.modalService.open(this.content, {
1720
+ ariaLabelledBy: 'modal-basic-title',
1721
+ });
1722
+ this.modalReference.result.then((result) => {
1723
+ this.closeResult = `Closed with: ${result}`;
1724
+ console.log(this.closeResult);
1725
+ this.cancelImport();
1726
+ }, (error) => {
1727
+ this.closeResult = `Dismissed ${this.getDismissReason(error)}`;
1728
+ console.log(this.closeResult);
1729
+ this.cancelImport();
1730
+ });
1731
+ try {
1732
+ yield this.matterportImportService.initSdkForModel(model3D);
1733
+ return imagesOnly
1734
+ ? this.matterportImportService.importData(this.spaceId, surface, true, node)
1735
+ : this.matterportImportService.importData(this.spaceId, surface, false, node);
1736
+ }
1737
+ catch (error) {
1738
+ console.log(error);
1739
+ return Promise.reject(error);
1740
+ }
1741
+ });
1742
+ }
1743
+ cancelImport() {
1744
+ this.matterportImportService.abandon();
1745
+ this.onCancel();
1746
+ this.resetVisits();
1747
+ }
1748
+ onImport(visit) {
1749
+ this.launchImport(visit.model3d, null, visit.node.id, true);
1750
+ }
1751
+ isFormError(control) {
1752
+ return control && control.invalid && this.errorForm;
1753
+ }
1754
+ }
1755
+ 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 }, { token: i2.ValidatorsService }, { token: i3.TranslateService }, { token: i2.NavigatorService }, { token: i1.Router }], target: i0.ɵɵFactoryTarget.Component });
1756
+ 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\">\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"onGoBack()\"></lib-tab-navigation>\n </div>\n\n <div class=\"row main-form-container\">\n <div class=\"col-md-6 form-container\">\n <ul class=\"list-group list-group-flush\" *ngIf=\"!visitForm\">\n <li class=\"list-group-item list-group-item-action\" *ngFor=\"let visit of visits; index as index\">\n <div class=\"d-flex justify-content-between align-items-center\" (click)=\"onToggleDetail(index)\">\n {{visit.name ? visit.name : visit.model3d }}\n <lib-chevron [conditionShowing]=\"index==visitIndexDetails\"></lib-chevron>\n </div>\n <div *ngIf=\"index==visitIndexDetails\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item bg-transparent\">{{'Name' | translate}} : {{ visit.name ?\n visit.name : \"Not provided\" | translate}}</li>\n <li class=\"list-group-item bg-transparent\">{{'3D Model' | translate}} : {{ visit.model3d }}\n </li>\n <li class=\"list-group-item bg-transparent\">{{'Surface' | translate}}, m<sup>2</sup>: {{\n visit.surface ?\n visit.surface : 'Not provided' | translate}}</li>\n <li class=\"list-group-item bg-transparent\">{{'Viewer' | translate}} : {{ visit.viewer }}\n </li>\n <li class=\"list-group-item bg-transparent\">{{'Date of capture' | translate}} : {{\n visit.takenAt | timeDateString | async}}\n <li class=\"list-group-item bg-transparent\">{{'Images imported' | translate}} : {{\n visit.nmbImagesImported }}\n </li>\n </ul>\n \n <lib-loader *ngIf=\"isProcessing\"></lib-loader>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onImport(visit)\" [disabled]=\"isProcessing\">{{'Import images' |\n translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" [disabled]=\"isProcessing\"\n (click)=\"onEdit(visit)\">{{'Edit' | translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" [disabled]=\"isProcessing\"\n (click)=\"onDelete(visit)\">{{'Delete' | translate}}</button>\n </div>\n </li>\n </ul>\n <div *ngIf=\"visitForm\">\n <form (ngSubmit)=\"onSubmitVisit()\" [formGroup]=\"visitForm\">\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Name' | translate}}</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" formControlName=\"name\">\n </div>\n </div>\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Reference 3D model' | translate}} *</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" [readonly]=\"isEditing\"\n [class.is-invalid]=\"model3D.invalid && visitSubmitted\" required\n formControlName=\"model3D\">\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-name-invalid\" [dismissible]=\"false\" type=\"danger\" \n *ngIf=\"validatorsService.isControlError(visitForm.controls['name']) \n || isFormError(visitForm.controls['name'])\">\n {{validatorsService.getError(visitForm.controls['name']) | translate}}\n </ngb-alert>\n </div>\n <div *ngIf=\"isEditing\" class=\"text-danger\">\n {{'Cannot change 3D model reference. Please add new model.' | translate}}\n </div>\n </div>\n </div>\n\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Viewer' | translate}}</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" formControlName=\"viewer\">\n </div>\n </div>\n\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Surface' | translate}}</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" formControlName=\"surface\">\n </div>\n </div>\n\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Capture Date' | translate}}</label>\n <div class=\"input-group\">\n <input class=\"form-control\" placeholder=\"dd/mm/yyyy\" [(ngModel)]=\"captureDate\" ngbDatepicker\n #d1=\"ngbDatepicker\" [ngModelOptions]=\"{standalone: true}\">\n <div class=\"input-group-append\">\n <button class=\"btn btn-outline-secondary calendar\" (click)=\"d1.toggle()\"\n type=\"button\"></button>\n </div>\n </div>\n </div>\n <button type=\"submit\" class=\"btn btn-outline-primary rounded-pill me-2\">{{'Save' |\n translate}}</button>\n <button type=\"button\" (click)=\"onCancel()\" class=\"btn btn-outline-primary rounded-pill\">{{'Cancel' |\n translate}}</button>\n <div class=\"invalid-feedback\" *ngIf=\"errorForm\">\n <ngb-alert data-testid=\"new-location-form-invalid\" [dismissible]=\"false\" type=\"danger\">\n {{'errorForm.infoBtn' |translate}}\n \n </ngb-alert>\n </div>\n </form>\n </div>\n <div *ngIf=\"!visitForm\">\n <button class=\"btn btn-outline-primary rounded-pill\" (click)=\"onAddVisit()\">{{'Add 3D visit' |\n translate}}</button>\n </div>\n </div>\n <div id=\"viewer-frame\" style=\"width: 100%; aspect-ratio: 2/1;\"></div>\n </div>\n <ng-template #content let-modal>\n <div class=\"modal-header\">\n <h4 class=\"modal-title\" id=\"modal-basic-title\">{{'Importing Data' | translate}}</h4>\n <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"modal.dismiss('Cross click')\">\n <span aria-hidden=\"true\">\u00D7</span>\n </button>\n </div>\n <div class=\"modal-body\">\n {{'Please do not leave or refresh this page...' | translate}}\n <div *ngIf=\"totalImages != 0\">Imported {{imagesProcessed}} out of {{totalImages}} images.</div>\n <div class=\"d-flex justify-content-center\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">{{'Loading' | translate}}...</span>\n </div>\n </div>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-outline-dark\" [disabled]=\"!canCancelImport\"\n (click)=\"modal.close('Cancel click')\">{{'Cancel import of images' | translate}}</button>\n </div>\n </ng-template>\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"] }, { type: i2.LoaderComponent, selector: "lib-loader", inputs: ["useLogo", "color"] }, { type: i7.NgbAlert, selector: "ngb-alert", inputs: ["animation", "dismissible", "type"], outputs: ["closed"], exportAs: ["ngbAlert"] }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.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": i6.AsyncPipe, "timeDateString": i2.TimeDateToLocalStringPipe } });
1757
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: VisitsComponent, decorators: [{
1758
+ type: Component,
1759
+ args: [{ selector: 'lib-visits', template: "<div class=\"container-fluid\" class=\"dashboard-tab\">\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"onGoBack()\"></lib-tab-navigation>\n </div>\n\n <div class=\"row main-form-container\">\n <div class=\"col-md-6 form-container\">\n <ul class=\"list-group list-group-flush\" *ngIf=\"!visitForm\">\n <li class=\"list-group-item list-group-item-action\" *ngFor=\"let visit of visits; index as index\">\n <div class=\"d-flex justify-content-between align-items-center\" (click)=\"onToggleDetail(index)\">\n {{visit.name ? visit.name : visit.model3d }}\n <lib-chevron [conditionShowing]=\"index==visitIndexDetails\"></lib-chevron>\n </div>\n <div *ngIf=\"index==visitIndexDetails\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item bg-transparent\">{{'Name' | translate}} : {{ visit.name ?\n visit.name : \"Not provided\" | translate}}</li>\n <li class=\"list-group-item bg-transparent\">{{'3D Model' | translate}} : {{ visit.model3d }}\n </li>\n <li class=\"list-group-item bg-transparent\">{{'Surface' | translate}}, m<sup>2</sup>: {{\n visit.surface ?\n visit.surface : 'Not provided' | translate}}</li>\n <li class=\"list-group-item bg-transparent\">{{'Viewer' | translate}} : {{ visit.viewer }}\n </li>\n <li class=\"list-group-item bg-transparent\">{{'Date of capture' | translate}} : {{\n visit.takenAt | timeDateString | async}}\n <li class=\"list-group-item bg-transparent\">{{'Images imported' | translate}} : {{\n visit.nmbImagesImported }}\n </li>\n </ul>\n \n <lib-loader *ngIf=\"isProcessing\"></lib-loader>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onImport(visit)\" [disabled]=\"isProcessing\">{{'Import images' |\n translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" [disabled]=\"isProcessing\"\n (click)=\"onEdit(visit)\">{{'Edit' | translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" [disabled]=\"isProcessing\"\n (click)=\"onDelete(visit)\">{{'Delete' | translate}}</button>\n </div>\n </li>\n </ul>\n <div *ngIf=\"visitForm\">\n <form (ngSubmit)=\"onSubmitVisit()\" [formGroup]=\"visitForm\">\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Name' | translate}}</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" formControlName=\"name\">\n </div>\n </div>\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Reference 3D model' | translate}} *</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" [readonly]=\"isEditing\"\n [class.is-invalid]=\"model3D.invalid && visitSubmitted\" required\n formControlName=\"model3D\">\n <div class=\"invalid-feedback\">\n <ngb-alert data-testid=\"new-location-name-invalid\" [dismissible]=\"false\" type=\"danger\" \n *ngIf=\"validatorsService.isControlError(visitForm.controls['name']) \n || isFormError(visitForm.controls['name'])\">\n {{validatorsService.getError(visitForm.controls['name']) | translate}}\n </ngb-alert>\n </div>\n <div *ngIf=\"isEditing\" class=\"text-danger\">\n {{'Cannot change 3D model reference. Please add new model.' | translate}}\n </div>\n </div>\n </div>\n\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Viewer' | translate}}</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" formControlName=\"viewer\">\n </div>\n </div>\n\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Surface' | translate}}</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" formControlName=\"surface\">\n </div>\n </div>\n\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Capture Date' | translate}}</label>\n <div class=\"input-group\">\n <input class=\"form-control\" placeholder=\"dd/mm/yyyy\" [(ngModel)]=\"captureDate\" ngbDatepicker\n #d1=\"ngbDatepicker\" [ngModelOptions]=\"{standalone: true}\">\n <div class=\"input-group-append\">\n <button class=\"btn btn-outline-secondary calendar\" (click)=\"d1.toggle()\"\n type=\"button\"></button>\n </div>\n </div>\n </div>\n <button type=\"submit\" class=\"btn btn-outline-primary rounded-pill me-2\">{{'Save' |\n translate}}</button>\n <button type=\"button\" (click)=\"onCancel()\" class=\"btn btn-outline-primary rounded-pill\">{{'Cancel' |\n translate}}</button>\n <div class=\"invalid-feedback\" *ngIf=\"errorForm\">\n <ngb-alert data-testid=\"new-location-form-invalid\" [dismissible]=\"false\" type=\"danger\">\n {{'errorForm.infoBtn' |translate}}\n \n </ngb-alert>\n </div>\n </form>\n </div>\n <div *ngIf=\"!visitForm\">\n <button class=\"btn btn-outline-primary rounded-pill\" (click)=\"onAddVisit()\">{{'Add 3D visit' |\n translate}}</button>\n </div>\n </div>\n <div id=\"viewer-frame\" style=\"width: 100%; aspect-ratio: 2/1;\"></div>\n </div>\n <ng-template #content let-modal>\n <div class=\"modal-header\">\n <h4 class=\"modal-title\" id=\"modal-basic-title\">{{'Importing Data' | translate}}</h4>\n <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"modal.dismiss('Cross click')\">\n <span aria-hidden=\"true\">\u00D7</span>\n </button>\n </div>\n <div class=\"modal-body\">\n {{'Please do not leave or refresh this page...' | translate}}\n <div *ngIf=\"totalImages != 0\">Imported {{imagesProcessed}} out of {{totalImages}} images.</div>\n <div class=\"d-flex justify-content-center\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">{{'Loading' | translate}}...</span>\n </div>\n </div>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-outline-dark\" [disabled]=\"!canCancelImport\"\n (click)=\"modal.close('Cancel click')\">{{'Cancel import of images' | translate}}</button>\n </div>\n </ng-template>\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"] }]
1760
+ }], 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 }, { type: i2.ValidatorsService }, { type: i3.TranslateService }, { type: i2.NavigatorService }, { type: i1.Router }]; }, propDecorators: { content: [{
1761
+ type: ViewChild,
1762
+ args: ['content', { static: false }]
1763
+ }] } });
1764
+
1765
+ class PlanLegendComponent {
1766
+ constructor(translate) {
1767
+ this.translate = translate;
1768
+ this.isAudioZone = false;
1769
+ this.buttonsToRender = [];
1770
+ this.colorToText = {};
1771
+ }
1772
+ ngOnInit() {
1773
+ return __awaiter(this, void 0, void 0, function* () {
1774
+ this.render();
1775
+ });
1776
+ }
1777
+ render() {
1778
+ return __awaiter(this, void 0, void 0, function* () {
1779
+ this.buttonsToRender = [
1780
+ {
1781
+ url: `url("https://api.iconify.design/mdi:adjust.svg?color=green&height=17&width=17")`,
1782
+ text: this.translate.instant("legend.green")
1783
+ },
1784
+ {
1785
+ url: `url("https://api.iconify.design/mdi:close-circle-outline.svg?color=red&height=17&width=17")`,
1786
+ text: this.translate.instant("legend.red")
1787
+ }
1788
+ ];
1789
+ if (this.isAudioZone) {
1790
+ let audioPoints = [{
1791
+ url: `url("https://api.iconify.design/mdi:close-circle-outline.svg?color=black&height=17&width=17")`,
1792
+ text: this.translate.instant("legend.black")
1793
+ },
1794
+ {
1795
+ url: `url("https://api.iconify.design/mdi:adjust.svg?color=orange&height=17&width=17")`,
1796
+ text: this.translate.instant("legend.orange")
1797
+ }];
1798
+ this.buttonsToRender = this.buttonsToRender.concat(audioPoints);
1799
+ }
1800
+ });
1801
+ }
1802
+ }
1803
+ PlanLegendComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: PlanLegendComponent, deps: [{ token: i3.TranslateService }], target: i0.ɵɵFactoryTarget.Component });
1804
+ PlanLegendComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: PlanLegendComponent, selector: "lib-plan-legend", inputs: { isAudioZone: "isAudioZone" }, ngImport: i0, template: "<div class=\"mt-3 ms-3\" class=\"legendContainer\">\n <h5>{{\"legend.title\" | translate}}</h5>\n <div class=\"legendBox\">\n <div class=\"legendRow\" *ngFor=\"let elemnt of buttonsToRender\">\n <button class=\"legendIcon\" [ngStyle] = \"{'background-image': elemnt.url}\"></button>\n <span>{{elemnt.text}}</span>\n </div>\n </div>\n</div>\n", styles: [".legendContainer{padding:1rem;border:solid var(--smarterplan-primary) 2px;border-radius:6px;width:100%;margin-bottom:.5rem;background:#FFF}.legendContainer .legendBox{display:flex;flex-direction:row;justify-content:center;flex-wrap:wrap}.legendContainer .legendBox .legendRow{display:flex;flex-direction:row;align-items:center}.legendContainer .legendBox .legendRow .legendIcon{width:2.5rem;height:2.5rem;background-repeat:no-repeat;background-size:cover;border:none;background-color:transparent;margin-right:.5rem;cursor:auto}.legendContainer .legendBox .legendRow span{margin-right:1rem;cursor:auto}.legendContainer .legendBox .legendRow h5{cursor:auto}\n"], directives: [{ type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i6.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], pipes: { "translate": i3.TranslatePipe } });
1805
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: PlanLegendComponent, decorators: [{
1806
+ type: Component,
1807
+ args: [{ selector: 'lib-plan-legend', template: "<div class=\"mt-3 ms-3\" class=\"legendContainer\">\n <h5>{{\"legend.title\" | translate}}</h5>\n <div class=\"legendBox\">\n <div class=\"legendRow\" *ngFor=\"let elemnt of buttonsToRender\">\n <button class=\"legendIcon\" [ngStyle] = \"{'background-image': elemnt.url}\"></button>\n <span>{{elemnt.text}}</span>\n </div>\n </div>\n</div>\n", styles: [".legendContainer{padding:1rem;border:solid var(--smarterplan-primary) 2px;border-radius:6px;width:100%;margin-bottom:.5rem;background:#FFF}.legendContainer .legendBox{display:flex;flex-direction:row;justify-content:center;flex-wrap:wrap}.legendContainer .legendBox .legendRow{display:flex;flex-direction:row;align-items:center}.legendContainer .legendBox .legendRow .legendIcon{width:2.5rem;height:2.5rem;background-repeat:no-repeat;background-size:cover;border:none;background-color:transparent;margin-right:.5rem;cursor:auto}.legendContainer .legendBox .legendRow span{margin-right:1rem;cursor:auto}.legendContainer .legendBox .legendRow h5{cursor:auto}\n"] }]
1808
+ }], ctorParameters: function () { return [{ type: i3.TranslateService }]; }, propDecorators: { isAudioZone: [{
1809
+ type: Input
1810
+ }] } });
1811
+
1812
+ class CarouselComponent {
1813
+ constructor() {
1814
+ this.currentScan = new EventEmitter();
1815
+ }
1816
+ ngOnInit() {
1817
+ this.currentScan.emit(0);
1818
+ }
1819
+ onSlide(event) {
1820
+ this.dataEvent = JSON.stringify(event);
1821
+ const imageIndex = Number.parseInt(event.current.replace("slideId_", ""), 10);
1822
+ this.currentScan.emit(imageIndex);
1823
+ }
1824
+ }
1825
+ CarouselComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CarouselComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1826
+ 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: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgbSlide, selector: "ng-template[ngbSlide]", inputs: ["id"], outputs: ["slid"] }] });
1827
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CarouselComponent, decorators: [{
1828
+ type: Component,
1829
+ 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: [""] }]
1830
+ }], ctorParameters: function () { return []; }, propDecorators: { images: [{
1831
+ type: Input
1832
+ }], currentScan: [{
1833
+ type: Output
1834
+ }] } });
1835
+
1836
+ var SweepState;
1837
+ (function (SweepState) {
1838
+ SweepState[SweepState["ADDED"] = 0] = "ADDED";
1839
+ SweepState[SweepState["REMOVED"] = 1] = "REMOVED";
1840
+ SweepState[SweepState["DISABLED"] = 2] = "DISABLED";
1841
+ SweepState[SweepState["OCCUPIED"] = 3] = "OCCUPIED";
1842
+ SweepState[SweepState["STARTPOINT"] = 4] = "STARTPOINT";
1843
+ })(SweepState || (SweepState = {}));
1844
+ function isInPolygon(p, polygon) {
1845
+ let isInside = false;
1846
+ let minX = polygon[0].x;
1847
+ let maxX = polygon[0].x;
1848
+ let minY = polygon[0].y;
1849
+ let maxY = polygon[0].y;
1850
+ for (let n = 1; n < polygon.length; n++) {
1851
+ const q = polygon[n];
1852
+ minX = Math.min(q.x, minX);
1853
+ maxX = Math.max(q.x, maxX);
1854
+ minY = Math.min(q.y, minY);
1855
+ maxY = Math.max(q.y, maxY);
1856
+ }
1857
+ if (p.x < minX || p.x > maxX || p.y < minY || p.y > maxY) {
1858
+ return false;
1859
+ }
1860
+ for (let index = 0, index_ = polygon.length - 1; index < polygon.length; index_ = index++) {
1861
+ if (polygon[index].y > p.y !== polygon[index_].y > p.y &&
1862
+ p.x <
1863
+ ((polygon[index_].x - polygon[index].x) *
1864
+ (p.y - polygon[index].y)) /
1865
+ (polygon[index_].y - polygon[index].y) +
1866
+ polygon[index].x) {
1867
+ isInside = !isInside;
1868
+ }
1869
+ }
1870
+ return isInside;
1871
+ }
1872
+ function rotate(point, center, angle) {
1873
+ let xM;
1874
+ let yM;
1875
+ let x;
1876
+ let y;
1877
+ angle *= Math.PI / 180;
1878
+ xM = point.x - center.x;
1879
+ yM = point.y - center.y;
1880
+ x = xM * Math.cos(angle) + yM * Math.sin(angle) + center.x;
1881
+ y = -xM * Math.sin(angle) + yM * Math.cos(angle) + center.y;
1882
+ return { x: Math.round(x), y: Math.round(y) };
1883
+ }
1884
+ /**
1885
+ * Check if an HtmlElement is inside a selection
1886
+ * @param button HTMLElement
1887
+ * @param selection
1888
+ * @returns true if the element is inside the selection, false otherwise
1889
+ */
1890
+ function buttonIsInSelection(button, selection) {
1891
+ const bounds = button.getBoundingClientRect();
1892
+ return (bounds.bottom > selection.top &&
1893
+ bounds.top < selection.top + selection.height &&
1894
+ bounds.right > selection.left &&
1895
+ bounds.left < selection.left + selection.width);
1896
+ }
1897
+ /**
1898
+ * Styles the button that represents a sweep on the plan: green-added to zone, red -not added, gray - disabled, orange - occupied
1899
+ * @param button HTMLButtonElement, button on the plan,
1900
+ * @param isAdded boolean, if the sweep added to the zone
1901
+ * @param isOccupied boolean, if the sweep added to any other zone (but not current)
1902
+ */
1903
+ function styleButton(button, state) {
1904
+ switch (state) {
1905
+ case SweepState.ADDED:
1906
+ button.style.backgroundImage = `url("https://api.iconify.design/mdi:adjust.svg?color=green&height=17&width=17")`;
1907
+ break;
1908
+ case SweepState.DISABLED:
1909
+ button.style.backgroundImage = `url("https://api.iconify.design/mdi:close-circle-outline.svg?color=black&height=17&width=17")`;
1910
+ button.style.cursor = "auto";
1911
+ break;
1912
+ case SweepState.OCCUPIED:
1913
+ button.style.backgroundImage = `url("https://api.iconify.design/mdi:adjust.svg?color=orange&height=17&width=17")`;
1914
+ break;
1915
+ case SweepState.STARTPOINT:
1916
+ button.style.backgroundImage = `url('https://api.iconify.design/ic/baseline-flag-circle.svg?color=white&width=17&height=17')`;
1917
+ break;
1918
+ case SweepState.REMOVED:
1919
+ button.style.backgroundImage = `url("https://api.iconify.design/mdi:close-circle-outline.svg?color=red&height=17&width=17")`;
1920
+ break;
1921
+ default:
1922
+ button.style.backgroundImage = `url("https://api.iconify.design/mdi:close-circle-outline.svg?color=red&height=17&width=17")`;
1923
+ break;
1924
+ }
1925
+ // if (disabled) {
1926
+ // button.style.backgroundImage = `url("https://api.iconify.design/mdi:close-circle-outline.svg?color=#636363&height=17&width=17")`;
1927
+ // button.style.cursor = "auto";
1928
+ // } else if (isOccupied) {
1929
+ // button.style.backgroundImage = `url("https://api.iconify.design/mdi:adjust.svg?color=orange&height=17&width=17")`;
1930
+ // } else {
1931
+ // button.style.backgroundImage = isAdded
1932
+ // ? `url("https://api.iconify.design/mdi:adjust.svg?color=green&height=17&width=17")`
1933
+ // : `url("https://api.iconify.design/mdi:close-circle-outline.svg?color=red&height=17&width=17")`;
1934
+ // }
1935
+ button.style.backgroundColor = "transparent";
1936
+ button.style.position = "absolute";
1937
+ button.style.border = "none";
1938
+ button.style.width = "17px";
1939
+ button.style.height = "17px";
1940
+ button.disabled = false;
1941
+ button.type = "button";
1942
+ }
1943
+ /**
1944
+ * Check if sweep (button) is chosen; it is reprsented by image style "mdi:adjust"
1945
+ * @param button HTMLElement
1946
+ * @returns boolean, if button was selected
1947
+ */
1948
+ function buttonIsChosen(button) {
1949
+ return button.style.backgroundImage.includes("adjust");
1950
+ }
1951
+ /**
1952
+ * Visually change the state of a scan button, a selected button is blue
1953
+ * @param button HTMLElement
1954
+ * @param selected if true the button will be blue, otherwise it will red or green
1955
+ */
1956
+ function setVisuallySelected(button, selected) {
1957
+ if (selected) {
1958
+ /** Color in blue */
1959
+ button.style.backgroundImage = button.style.backgroundImage
1960
+ .replace("red", "blue")
1961
+ .replace("green", "blue");
1962
+ }
1963
+ else {
1964
+ /** Get back in red or green */
1965
+ const color = buttonIsChosen(button) ? "green" : "red";
1966
+ button.style.backgroundImage = button.style.backgroundImage.replace("blue", color);
1967
+ }
1968
+ }
1969
+
1970
+ class SelectionComponent {
1971
+ constructor() {
1972
+ /**Emit a new selection */
1973
+ this.onSelectionChanged = new EventEmitter();
1974
+ this.isMousedown = false;
1975
+ this.selection = { startX: 0, startY: 0, endX: 0, endY: 0 };
1976
+ this.selectionRectangle = { top: 0, left: 0, width: 0, height: 0 };
1977
+ }
1978
+ ngOnInit() {
1979
+ this.selectionableZone = document.querySelector(".selectZone");
1980
+ this.selectionElement = document.querySelector("#selection");
1981
+ this.selectionableZone.addEventListener("mousedown", this.mousedown.bind(this));
1982
+ this.selectionableZone.addEventListener("mousemove", this.mousemove.bind(this));
1983
+ this.selectionableZone.addEventListener("mouseup", this.mouseup.bind(this));
1984
+ }
1985
+ /**
1986
+ * Update the current selection
1987
+ * Will update the selectionRectangle and Selection HTML element
1988
+ * @param shouldEmit if true an event will be emitted through onSelectionChanged (true by default)
1989
+ */
1990
+ updateSelectionElement(shouldEmit = true) {
1991
+ this.selectionRectangle.width = Math.abs(this.selection.endX - this.selection.startX);
1992
+ this.selectionRectangle.height = Math.abs(this.selection.endY - this.selection.startY);
1993
+ this.selectionRectangle.top = Math.min(this.selection.endY, this.selection.startY);
1994
+ this.selectionRectangle.left = Math.min(this.selection.endX, this.selection.startX);
1995
+ this.selectionElement.style.top = `${this.selectionRectangle.top}px`;
1996
+ this.selectionElement.style.left = `${this.selectionRectangle.left}px`;
1997
+ this.selectionElement.style.width = `${this.selectionRectangle.width}px`;
1998
+ this.selectionElement.style.height = `${this.selectionRectangle.height}px`;
1999
+ if (shouldEmit) {
2000
+ this.onSelectionChanged.emit(this.selectionRectangle);
2001
+ }
2002
+ }
2003
+ /**
2004
+ * Trigger when mouse is press down on selectionableZone
2005
+ * @param event
2006
+ */
2007
+ mousedown(event) {
2008
+ if (event.button !== 2) { /**Selection with the right click, so ignore all other event */
2009
+ return;
2010
+ }
2011
+ this.isMousedown = true;
2012
+ this.selection = { startY: event.clientY, startX: event.clientX, endX: event.clientX, endY: event.clientY };
2013
+ this.updateSelectionElement();
2014
+ }
2015
+ /**
2016
+ * Trigger when mouse is release on selectionableZone
2017
+ * @param event
2018
+ */
2019
+ mouseup(event) {
2020
+ this.isMousedown = false;
2021
+ this.selection = { startX: 0, startY: 0, endX: 0, endY: 0 };
2022
+ this.updateSelectionElement(false);
2023
+ }
2024
+ /**
2025
+ * Trigger when mouse is moving on selectionableZone
2026
+ * @param event
2027
+ */
2028
+ mousemove(event) {
2029
+ if (this.isMousedown) {
2030
+ this.selection.endX = event.clientX;
2031
+ this.selection.endY = event.clientY;
2032
+ this.updateSelectionElement();
2033
+ }
2034
+ }
2035
+ }
2036
+ SelectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SelectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2037
+ 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"] });
2038
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SelectionComponent, decorators: [{
2039
+ type: Component,
2040
+ 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"] }]
2041
+ }], ctorParameters: function () { return []; }, propDecorators: { onSelectionChanged: [{
2042
+ type: Output
2043
+ }] } });
2044
+
2045
+ class RadioButtonComponent {
2046
+ constructor() {
2047
+ this.isCheckedEvent = new EventEmitter();
2048
+ }
2049
+ ngOnInit() {
2050
+ this.isChecked = false;
2051
+ }
2052
+ onChecked() {
2053
+ this.isCheckedEvent.emit(this.isChecked);
2054
+ }
2055
+ }
2056
+ RadioButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: RadioButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2057
+ RadioButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: RadioButtonComponent, selector: "lib-radio-button", inputs: { label: "label" }, outputs: { isCheckedEvent: "isCheckedEvent" }, ngImport: i0, template: "<div class=\"checkboxContainer\">\n <div class=\"switchContainer\">\n <label class=\"switch switch-success\">\n <input type=\"checkbox\"[(ngModel)]=\"isChecked\" (change)=\"onChecked()\">\n <span class=\"slider round\"></span>\n </label>\n </div>\n <span class=\"label right\">{{label | translate}}</span>\n</div>\n", styles: [".checkboxContainer{display:flex;flex-direction:row;align-items:center;width:calc(20vw + 1rem)}.checkboxContainer .label{margin-left:1rem}.checkboxContainer .switch{position:relative;display:inline-block;cursor:pointer;width:60px;height:34px;border-radius:34px}.checkboxContainer .switch input{opacity:0;width:0;height:0}.checkboxContainer .switch input:checked+.slider{background-color:#404660;box-shadow:4px 4px 10px #40466080}.checkboxContainer .switch input:checked+.slider:before{background:white;transform:translate(26px)}.checkboxContainer .switch .label{position:absolute;top:7px}.checkboxContainer .switch .label.right{left:60px;margin-left:10px}.checkboxContainer .switch .slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;border:1px solid #404660;transition:.3s;border-radius:34px}.checkboxContainer .switch .slider:before:hover{background-color:#fff}.checkboxContainer .switch .slider:before{position:absolute;content:\"\";height:26px;width:26px;left:4px;bottom:3px;background-color:#404660;transition:.3s;border-radius:50%}.checkboxContainer .switch.switch-success input:checked+.slider{background-color:var(--smarterplan-primary);box-shadow:2px 2px 10px 0 var(--smarterplan-primary)}.checkboxContainer .switch.switch-success .slider{border:1px solid var(--smarterplan-primary)}.checkboxContainer .switch.switch-success .slider:before{background-color:var(--smarterplan-primary);box-shadow:2px 2px 10px 0 var(--smarterplan-primary)}.checkboxContainer .switch.switch-default input:checked+.slider{background-color:#636983;box-shadow:2px 2px 10px #636983}.checkboxContainer .switch.switch-default .slider{border:1px solid #636983}.checkboxContainer .switch.switch-default .slider:before{background-color:#636983;box-shadow:2px 2px 10px #636983}.checkboxContainer .switch.switch-warning input:checked+.slider{background-color:#973c3c;box-shadow:2px 2px 10px #ff9898}.checkboxContainer .switch.switch-warning .slider{border:1px solid #973c3c}.checkboxContainer .switch.switch-warning .slider:before{background-color:#973c3c;box-shadow:2px 2px 10px #ff9898}.checkboxContainer .switch.switch-dark input:checked+.slider{background-color:#505050;box-shadow:2px 2px 10px #9d9d9d}.checkboxContainer .switch.switch-dark .slider{border:1px solid #505050}.checkboxContainer .switch.switch-dark .slider:before{background-color:#505050;box-shadow:2px 2px 10px #9d9d9d}\n"], directives: [{ 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 } });
2058
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: RadioButtonComponent, decorators: [{
2059
+ type: Component,
2060
+ args: [{ selector: 'lib-radio-button', template: "<div class=\"checkboxContainer\">\n <div class=\"switchContainer\">\n <label class=\"switch switch-success\">\n <input type=\"checkbox\"[(ngModel)]=\"isChecked\" (change)=\"onChecked()\">\n <span class=\"slider round\"></span>\n </label>\n </div>\n <span class=\"label right\">{{label | translate}}</span>\n</div>\n", styles: [".checkboxContainer{display:flex;flex-direction:row;align-items:center;width:calc(20vw + 1rem)}.checkboxContainer .label{margin-left:1rem}.checkboxContainer .switch{position:relative;display:inline-block;cursor:pointer;width:60px;height:34px;border-radius:34px}.checkboxContainer .switch input{opacity:0;width:0;height:0}.checkboxContainer .switch input:checked+.slider{background-color:#404660;box-shadow:4px 4px 10px #40466080}.checkboxContainer .switch input:checked+.slider:before{background:white;transform:translate(26px)}.checkboxContainer .switch .label{position:absolute;top:7px}.checkboxContainer .switch .label.right{left:60px;margin-left:10px}.checkboxContainer .switch .slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;border:1px solid #404660;transition:.3s;border-radius:34px}.checkboxContainer .switch .slider:before:hover{background-color:#fff}.checkboxContainer .switch .slider:before{position:absolute;content:\"\";height:26px;width:26px;left:4px;bottom:3px;background-color:#404660;transition:.3s;border-radius:50%}.checkboxContainer .switch.switch-success input:checked+.slider{background-color:var(--smarterplan-primary);box-shadow:2px 2px 10px 0 var(--smarterplan-primary)}.checkboxContainer .switch.switch-success .slider{border:1px solid var(--smarterplan-primary)}.checkboxContainer .switch.switch-success .slider:before{background-color:var(--smarterplan-primary);box-shadow:2px 2px 10px 0 var(--smarterplan-primary)}.checkboxContainer .switch.switch-default input:checked+.slider{background-color:#636983;box-shadow:2px 2px 10px #636983}.checkboxContainer .switch.switch-default .slider{border:1px solid #636983}.checkboxContainer .switch.switch-default .slider:before{background-color:#636983;box-shadow:2px 2px 10px #636983}.checkboxContainer .switch.switch-warning input:checked+.slider{background-color:#973c3c;box-shadow:2px 2px 10px #ff9898}.checkboxContainer .switch.switch-warning .slider{border:1px solid #973c3c}.checkboxContainer .switch.switch-warning .slider:before{background-color:#973c3c;box-shadow:2px 2px 10px #ff9898}.checkboxContainer .switch.switch-dark input:checked+.slider{background-color:#505050;box-shadow:2px 2px 10px #9d9d9d}.checkboxContainer .switch.switch-dark .slider{border:1px solid #505050}.checkboxContainer .switch.switch-dark .slider:before{background-color:#505050;box-shadow:2px 2px 10px #9d9d9d}\n"] }]
2061
+ }], ctorParameters: function () { return []; }, propDecorators: { label: [{
2062
+ type: Input
2063
+ }], isCheckedEvent: [{
2064
+ type: Output
2065
+ }] } });
2066
+
2067
+ class SweepPlanSelectionComponent {
2068
+ constructor(zoneService, navigationService, planService, translate) {
2069
+ this.zoneService = zoneService;
2070
+ this.navigationService = navigationService;
2071
+ this.planService = planService;
2072
+ this.translate = translate;
2073
+ this.chosenScansOnPlan = [];
2074
+ this.navIDsZoneEdit = [];
2075
+ // sweeps belonging to any audio zone
2076
+ this.occupiedSweeps = [];
2077
+ // sweeps unavailable (cannot be chosen)
2078
+ this.unavailableSweeps = [];
2079
+ // if choosing sweeps for audio zone
2080
+ this.editingAudioZone = false;
2081
+ this.multipleFloors = false;
2082
+ /** all scan buttons Element */
2083
+ this.buttonElements = [];
2084
+ /** Scan buttons that are in the current selection */
2085
+ this.buttonsInSelection = [];
2086
+ this.sweepsSelected = new EventEmitter();
2087
+ this.isSettingStartSweep = false;
2088
+ this.chosenSweepsPerFloor = new Map(); // map matching floorID to sweeps selected
2089
+ this.inputSweepsPerFloor = new Map(); // map matching floorID to sweeps selected for zone in edition
2090
+ this.selectionChanged = false;
2091
+ }
2092
+ ngOnInit() {
2093
+ return __awaiter(this, void 0, void 0, function* () {
2094
+ yield this.getPlans();
2095
+ this.setSweepsOfInputZone();
2096
+ });
2097
+ }
2098
+ ngOnChanges() {
2099
+ if (this.chosenPlan) {
2100
+ this.setSweepsOfInputZone();
2101
+ this.chosenScansOnPlan = [];
2102
+ this.clearDivPlan();
2103
+ this.addScanPoints();
2104
+ }
2105
+ }
2106
+ setSweepsOfInputZone() {
2107
+ this.navIDsZoneEdit = this.inputZone ? this.inputZone.sweepIDs : [];
2108
+ if (this.multipleFloors) {
2109
+ this.plans.forEach((plan) => {
2110
+ if (!this.inputSweepsPerFloor.get(plan.zoneID)) {
2111
+ this.inputSweepsPerFloor.set(plan.zoneID, this.navIDsZoneEdit.filter((sweep) => plan.zone.sweepIDs.includes(sweep)));
2112
+ }
2113
+ });
2114
+ }
2115
+ else {
2116
+ if (this.inputZone) {
2117
+ //filter plans only for the parent Zone
2118
+ this.plans = this.plans.filter((p) => p.zoneID === this.inputZone.parentID);
2119
+ }
2120
+ }
2121
+ }
2122
+ getPlans() {
2123
+ return __awaiter(this, void 0, void 0, function* () {
2124
+ this.plans = yield this.planService.getSingedPlansForSpace(this.spaceID);
2125
+ });
2126
+ }
2127
+ onPlanClick(plan) {
2128
+ return __awaiter(this, void 0, void 0, function* () {
2129
+ const switchPlan = () => {
2130
+ this.selectionChanged = false;
2131
+ this.chosenPlan = plan;
2132
+ this.chosenScansOnPlan = [];
2133
+ this.clearDivPlan();
2134
+ this.addScanPoints();
2135
+ };
2136
+ if (this.selectionChanged) {
2137
+ const message = this.translate.instant("confirm.cancelModifZoneSweeps");
2138
+ if (window.confirm(message)) {
2139
+ switchPlan();
2140
+ }
2141
+ }
2142
+ else {
2143
+ switchPlan();
2144
+ }
2145
+ });
2146
+ }
2147
+ addScanPoints() {
2148
+ return __awaiter(this, void 0, void 0, function* () {
2149
+ let wasModified = false;
2150
+ if (this.multipleFloors) {
2151
+ // check if we have already validated buttons for this floor
2152
+ if (this.chosenSweepsPerFloor.get(this.chosenPlan.zoneID)) {
2153
+ this.chosenScansOnPlan = this.chosenSweepsPerFloor.get(this.chosenPlan.zoneID);
2154
+ wasModified = true;
2155
+ }
2156
+ }
2157
+ this.divPlan = document.querySelector("#planDiv");
2158
+ const zoneOfPlan = yield this.zoneService.getZone(this.chosenPlan.zoneID);
2159
+ const navigations = yield this.navigationService.getNavigationsForZone(zoneOfPlan);
2160
+ if (this.newZoneData)
2161
+ yield this.setScanByDraw(navigations);
2162
+ this.buttonElements = yield showScanPointsOnPlanInDiv(this.chosenPlan, this.divPlan, navigations);
2163
+ for (const element of this.buttonElements) {
2164
+ if (this.unavailableSweeps && this.unavailableSweeps.includes(element.id)) {
2165
+ styleButton(element, SweepState.DISABLED);
2166
+ }
2167
+ else {
2168
+ if (wasModified) {
2169
+ if (this.chosenScansOnPlan.includes(element.id)) {
2170
+ styleButton(element, SweepState.ADDED);
2171
+ }
2172
+ else {
2173
+ styleButton(element, SweepState.REMOVED);
2174
+ }
2175
+ }
2176
+ else {
2177
+ if (this.navIDsZoneEdit.length > 0 &&
2178
+ this.navIDsZoneEdit.includes(element.id)) {
2179
+ styleButton(element, SweepState.ADDED);
2180
+ if (!this.chosenScansOnPlan.includes(element.id)) {
2181
+ this.chosenScansOnPlan.push(element.id);
2182
+ }
2183
+ }
2184
+ else if (this.occupiedSweeps && this.occupiedSweeps.includes(element.id)) {
2185
+ styleButton(element, SweepState.OCCUPIED);
2186
+ }
2187
+ else {
2188
+ styleButton(element, SweepState.REMOVED);
2189
+ }
2190
+ }
2191
+ //start point should be last condition
2192
+ if (this.inputZone && this.inputZone.startSweepID === element.id) {
2193
+ console.log("setting start point");
2194
+ styleButton(element, SweepState.STARTPOINT);
2195
+ }
2196
+ element.addEventListener("click", (event) => this.onButtonScanClicked(event.target));
2197
+ }
2198
+ }
2199
+ this.panZoom = panzoom(this.divPlan, {
2200
+ bounds: true,
2201
+ boundsPadding: 0,
2202
+ maxZoom: 3.5,
2203
+ beforeMouseDown(e) {
2204
+ return (e.button === 2); /** Ignore event for right click (use for selecting) */
2205
+ },
2206
+ });
2207
+ if (this.multipleFloors) {
2208
+ this.chosenSweepsPerFloor.set(this.chosenPlan.zoneID, [...this.chosenScansOnPlan]);
2209
+ }
2210
+ });
2211
+ }
2212
+ /** Function if we are coming for svg editor workflow */
2213
+ setScanByDraw(navigations) {
2214
+ return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
2215
+ const rect = {
2216
+ width: this.newZoneData.width,
2217
+ height: this.newZoneData.height,
2218
+ };
2219
+ const img = yield getMetaForImage(this.chosenPlan.filepath);
2220
+ const { coeffX, coeffY } = getCoefficientsForImage(img, rect);
2221
+ const draw = this.newZoneData.elements;
2222
+ draw.map((element) => __awaiter(this, void 0, void 0, function* () {
2223
+ switch (element.nodeName) {
2224
+ case "rect":
2225
+ yield this.setScanInRect(img, coeffX, coeffY, element, navigations);
2226
+ break;
2227
+ case "ellipse":
2228
+ yield this.setScanInCircle(img, coeffX, coeffY, element, navigations);
2229
+ break;
2230
+ case "path":
2231
+ yield this.setScanInPolygon(img, coeffX, coeffY, element, navigations);
2232
+ break;
2233
+ default:
2234
+ break;
2235
+ }
2236
+ }));
2237
+ resolve();
2238
+ }));
2239
+ }
2240
+ setScanInRect(img, coeffX, coeffY, element, navigations) {
2241
+ return __awaiter(this, void 0, void 0, function* () {
2242
+ const calibrage = JSON.parse(this.chosenPlan.calibration);
2243
+ navigations.map((navigation) => {
2244
+ const positionsOnPlan = navigation.positionOnPlan.map((entry) => JSON.parse(entry));
2245
+ const positionOnPlan = positionsOnPlan.find((data) => data.planID === this.chosenPlan.id);
2246
+ if (positionOnPlan) {
2247
+ const realWidth = img.width / coeffX;
2248
+ const realHeight = img.height / coeffY;
2249
+ const navY = (positionOnPlan.y * realHeight) / calibrage.imgHeight;
2250
+ const navX = (positionOnPlan.x * realWidth) / calibrage.imgWidth;
2251
+ if (navX > element.x &&
2252
+ navX < element.x + element.width &&
2253
+ navY > element.y &&
2254
+ navY < element.y + element.height &&
2255
+ !this.navIDsZoneEdit.includes(navigation.id)) {
2256
+ this.navIDsZoneEdit.push(navigation.id);
2257
+ }
2258
+ }
2259
+ // old calibration:
2260
+ // const position = JSON.parse(navigation.position);
2261
+ // let navX = (calibrage.offsetX + position.x * calibrage.x) / coeffX;
2262
+ // let navY = (calibrage.offsetY + position.z * calibrage.y) / coeffY;
2263
+ // if (element.angle) {
2264
+ // const rotatePos = rotate(
2265
+ // { x: navX, y: navY },
2266
+ // { x: element.cx, y: element.cy },
2267
+ // element.angle,
2268
+ // );
2269
+ // navX = rotatePos.x;
2270
+ // navY = rotatePos.y;
2271
+ // }
2272
+ /**
2273
+ * TODO calculer la rotation du rectangle
2274
+ */
2275
+ // if (
2276
+ // navX > element.x &&
2277
+ // navX < element.x + element.width &&
2278
+ // navY > element.y &&
2279
+ // navY < element.y + element.height &&
2280
+ // !this.navIDsZoneEdit.includes(navigation.id)
2281
+ // ) {
2282
+ // this.navIDsZoneEdit.push(navigation.id);
2283
+ // }
2284
+ });
2285
+ });
2286
+ } // EO
2287
+ setScanInCircle(img, coeffX, coeffY, element, navigations) {
2288
+ return __awaiter(this, void 0, void 0, function* () {
2289
+ const calibrage = JSON.parse(this.chosenPlan.calibration);
2290
+ navigations.map(navigation => {
2291
+ const positionsOnPlan = navigation.positionOnPlan.map((entry) => JSON.parse(entry));
2292
+ const positionOnPlan = positionsOnPlan.find((data) => data.planID === this.chosenPlan.id);
2293
+ if (positionOnPlan) {
2294
+ const realWidth = img.width / coeffX;
2295
+ const realHeight = img.height / coeffY;
2296
+ let navY = (positionOnPlan.y * realHeight) / calibrage.imgHeight;
2297
+ let navX = (positionOnPlan.x * realWidth) / calibrage.imgWidth;
2298
+ if (element.angle) {
2299
+ const rotatePos = rotate({ x: navX, y: navY }, { x: element.cx, y: element.cy }, element.angle);
2300
+ navX = rotatePos.x;
2301
+ navY = rotatePos.y;
2302
+ }
2303
+ const valueX = Math.pow(navX - element.cx, 2) / Math.pow(element.rx, 2);
2304
+ const valueY = Math.pow(navY - element.cy, 2) / Math.pow(element.ry, 2);
2305
+ const result = valueX + valueY;
2306
+ if (result <= 1 && !this.navIDsZoneEdit.includes(navigation.id)) {
2307
+ this.navIDsZoneEdit.push(navigation.id);
2308
+ }
2309
+ }
2310
+ // old calibration
2311
+ // const position = JSON.parse(navigation.position);
2312
+ // let navX = (calibrage.offsetX + position.x * calibrage.x) / coeffX;
2313
+ // let navY = (calibrage.offsetY + position.z * calibrage.y) / coeffY;
2314
+ // if (element.angle) {
2315
+ // const rotatePos = rotate(
2316
+ // { x: navX, y: navY },
2317
+ // { x: element.cx, y: element.cy },
2318
+ // element.angle,
2319
+ // );
2320
+ // navX = rotatePos.x;
2321
+ // navY = rotatePos.y;
2322
+ // }
2323
+ // const valueX =
2324
+ // Math.pow(navX - element.cx, 2) / Math.pow(element.rx, 2);
2325
+ // const valueY =
2326
+ // Math.pow(navY - element.cy, 2) / Math.pow(element.ry, 2);
2327
+ // const result = valueX + valueY;
2328
+ // if (result <= 1 && !this.navIDsZoneEdit.includes(navigation.id)) {
2329
+ // this.navIDsZoneEdit.push(navigation.id);
2330
+ // }
2331
+ });
2332
+ });
2333
+ } // EO
2334
+ setScanInPolygon(img, coeffX, coeffY, element, navigations) {
2335
+ return __awaiter(this, void 0, void 0, function* () {
2336
+ const calibrage = JSON.parse(this.chosenPlan.calibration);
2337
+ navigations.map((navigation) => __awaiter(this, void 0, void 0, function* () {
2338
+ const positionsOnPlan = navigation.positionOnPlan.map((entry) => JSON.parse(entry));
2339
+ const positionOnPlan = positionsOnPlan.find((data) => data.planID === this.chosenPlan.id);
2340
+ if (positionOnPlan) {
2341
+ const realWidth = img.width / coeffX;
2342
+ const realHeight = img.height / coeffY;
2343
+ let navY = (positionOnPlan.y * realHeight) / calibrage.imgHeight;
2344
+ let navX = (positionOnPlan.x * realWidth) / calibrage.imgWidth;
2345
+ const p = {
2346
+ x: navX,
2347
+ y: navY,
2348
+ };
2349
+ if (isInPolygon(p, element.segList) &&
2350
+ !this.navIDsZoneEdit.includes(navigation.id)) {
2351
+ this.navIDsZoneEdit.push(navigation.id);
2352
+ }
2353
+ }
2354
+ // old calibration
2355
+ // const position = JSON.parse(navigation.position);
2356
+ // const p = {
2357
+ // x: (calibrage.offsetX + position.x * calibrage.x) / coeffX,
2358
+ // y: (calibrage.offsetY + position.z * calibrage.y) / coeffY,
2359
+ // };
2360
+ // if (element.angle) {
2361
+ // p = this.rotate(
2362
+ // p,
2363
+ // { x: element.cx, y: element.cy },
2364
+ // element.angle,
2365
+ // );
2366
+ // }
2367
+ // if (
2368
+ // isInPolygon(p, element.segList) &&
2369
+ // !this.navIDsZoneEdit.includes(navigation.id)
2370
+ // ) {
2371
+ // this.navIDsZoneEdit.push(navigation.id);
2372
+ // }
2373
+ }));
2374
+ });
2375
+ }
2376
+ clearDivPlan() {
2377
+ if (this.divPlan)
2378
+ this.divPlan.innerHTML = "";
2379
+ }
2380
+ /**
2381
+ * Trigger each by the selectionComponent when selection change
2382
+ * Update the current selected scan buttons
2383
+ * @param selection new selection
2384
+ */
2385
+ onSelectionChanged(selection) {
2386
+ const unselectedButtons = [];
2387
+ const newSelectedButtons = [];
2388
+ /** For each button, decide whether will be add to selected list or unselected list */
2389
+ for (const button of this.buttonElements) {
2390
+ const isSelected = buttonIsInSelection(button, selection);
2391
+ if (this.buttonsInSelection.includes(button)) {
2392
+ /** If the button is already in the selected list, we check if it should be unselect */
2393
+ if (!isSelected) {
2394
+ unselectedButtons.push(button);
2395
+ }
2396
+ }
2397
+ else if (isSelected) {
2398
+ newSelectedButtons.push(button);
2399
+ }
2400
+ }
2401
+ /** Visually Update unselected list */
2402
+ for (const button of unselectedButtons) {
2403
+ setVisuallySelected(button, false);
2404
+ }
2405
+ /** Visually Update selected list */
2406
+ for (const button of newSelectedButtons) {
2407
+ setVisuallySelected(button, true);
2408
+ }
2409
+ /** Remove unselected list */
2410
+ this.buttonsInSelection = this.buttonsInSelection.filter((button) => {
2411
+ return !unselectedButtons.includes(button);
2412
+ });
2413
+ /** Add new selected buttons */
2414
+ this.buttonsInSelection = [
2415
+ ...this.buttonsInSelection,
2416
+ ...newSelectedButtons,
2417
+ ];
2418
+ }
2419
+ /**
2420
+ * Trigger when the user click to add the selected scans
2421
+ */
2422
+ onSelectionAdd() {
2423
+ for (const button of this.buttonsInSelection) {
2424
+ if (!this.chosenScansOnPlan.includes(button.id)) {
2425
+ this.onButtonScanClicked(button);
2426
+ }
2427
+ }
2428
+ this.onSelectionChanged({ top: 0, left: 0, width: 0, height: 0 });
2429
+ }
2430
+ /**
2431
+ * Trigger when the user click to remove the selected scans
2432
+ */
2433
+ onSelectionRemove() {
2434
+ for (const button of this.buttonsInSelection) {
2435
+ if (this.chosenScansOnPlan.includes(button.id)) {
2436
+ this.onButtonScanClicked(button);
2437
+ }
2438
+ }
2439
+ this.onSelectionChanged({ top: 0, left: 0, width: 0, height: 0 });
2440
+ }
2441
+ /**
2442
+ * Trigger when the user click to select all scans
2443
+ */
2444
+ onSelectAll() {
2445
+ this.buttonsInSelection = [...this.buttonElements];
2446
+ for (const button of this.buttonsInSelection) {
2447
+ setVisuallySelected(button, true);
2448
+ }
2449
+ }
2450
+ /**
2451
+ * Trigger when the user change the size of the scan points
2452
+ * @param event
2453
+ */
2454
+ onChangeScanSize(event) {
2455
+ const factor = event.target.value;
2456
+ for (const button of this.buttonElements) {
2457
+ button.style.transform = `scale(${factor})`;
2458
+ }
2459
+ }
2460
+ /**
2461
+ * When a button representing a scan is clicked
2462
+ * @param button
2463
+ */
2464
+ onButtonScanClicked(button) {
2465
+ this.selectionChanged = true;
2466
+ if (this.isSettingStartSweep) {
2467
+ if (this.startSweepID === button.id) {
2468
+ // we deselect the starting point
2469
+ button.style.backgroundImage = `url("https://api.iconify.design/mdi:adjust.svg?color=green&height=17&width=17")`;
2470
+ this.startSweepID = null;
2471
+ return;
2472
+ }
2473
+ button.style.backgroundImage = `url('https://api.iconify.design/ic/baseline-flag-circle.svg?color=white&width=17&height=17')`;
2474
+ if (!this.chosenScansOnPlan.includes(button.id)) {
2475
+ this.chosenScansOnPlan.push(button.id);
2476
+ }
2477
+ if (this.startSweepID) {
2478
+ // we are changing start sweep
2479
+ const btnChanged = this.buttonElements.find((btn) => btn.id === this.startSweepID);
2480
+ btnChanged.style.backgroundImage = `url("https://api.iconify.design/mdi:adjust.svg?color=green&height=17&width=17")`;
2481
+ }
2482
+ this.startSweepID = button.id;
2483
+ return;
2484
+ }
2485
+ if (!this.chosenScansOnPlan.includes(button.id)) {
2486
+ // add to selection
2487
+ button.style.backgroundImage = `url("https://api.iconify.design/mdi:adjust.svg?color=green&height=17&width=17")`;
2488
+ this.chosenScansOnPlan.push(button.id);
2489
+ }
2490
+ else {
2491
+ // remove from selection
2492
+ if (this.occupiedSweeps.includes(button.id) && !this.navIDsZoneEdit.includes(button.id)) {
2493
+ // the sweep belongs to another zone => set orange
2494
+ button.style.backgroundImage = `url("https://api.iconify.design/mdi:adjust.svg?color=orange&height=17&width=17")`;
2495
+ }
2496
+ else {
2497
+ button.style.backgroundImage = `url("https://api.iconify.design/mdi:close-circle-outline.svg?color=red&height=17&width=17")`;
2498
+ }
2499
+ const index = this.chosenScansOnPlan.indexOf(button.id);
2500
+ this.chosenScansOnPlan.splice(index, 1);
2501
+ }
2502
+ }
2503
+ onSaveSelection() {
2504
+ if (this.multipleFloors) {
2505
+ // rassemble all sweeps per floors
2506
+ let finalSweeps = [];
2507
+ Array.from(this.inputSweepsPerFloor.keys()).forEach(floorID => {
2508
+ if (this.chosenSweepsPerFloor.get(floorID)) {
2509
+ // the sweeps for this floor were modified, we take them
2510
+ finalSweeps = [...finalSweeps, ...this.chosenSweepsPerFloor.get(floorID)];
2511
+ }
2512
+ else {
2513
+ // was not modified, we take the previous values
2514
+ finalSweeps = [...finalSweeps, ...this.inputSweepsPerFloor.get(floorID)];
2515
+ }
2516
+ });
2517
+ // console.log("final sweeps", finalSweeps);
2518
+ this.sweepsSelected.emit({ "sweeps": finalSweeps, "startSweepID": this.startSweepID });
2519
+ }
2520
+ else {
2521
+ this.sweepsSelected.emit({ "sweeps": this.chosenScansOnPlan, "startSweepID": this.startSweepID });
2522
+ }
2523
+ }
2524
+ onCancel() {
2525
+ if (this.selectionChanged) {
2526
+ const message = this.translate.instant("confirm.cancelModifZoneSweeps");
2527
+ if (window.confirm(message)) {
2528
+ this.sweepsSelected.emit(null);
2529
+ }
2530
+ }
2531
+ else {
2532
+ this.sweepsSelected.emit(null);
2533
+ }
2534
+ }
2535
+ /**
2536
+ * Adds current selection of sweeps for current floor (plan) for multifloor zone.
2537
+ * It has to be saved anyway with onSaveSelection!
2538
+ */
2539
+ onValidateForFloor() {
2540
+ if (this.multipleFloors) {
2541
+ this.chosenSweepsPerFloor.set(this.chosenPlan.zoneID, [...this.chosenScansOnPlan]);
2542
+ this.selectionChanged = false;
2543
+ }
2544
+ }
2545
+ }
2546
+ SweepPlanSelectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SweepPlanSelectionComponent, deps: [{ token: i2.ZoneService }, { token: i2.NavigationService }, { token: i2.PlanService }, { token: i3.TranslateService }], target: i0.ɵɵFactoryTarget.Component });
2547
+ SweepPlanSelectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: SweepPlanSelectionComponent, selector: "lib-sweep-plan-selection", inputs: { spaceID: "spaceID", chosenScansOnPlan: "chosenScansOnPlan", newZoneData: "newZoneData", occupiedSweeps: "occupiedSweeps", unavailableSweeps: "unavailableSweeps", editingAudioZone: "editingAudioZone", inputZone: "inputZone", multipleFloors: "multipleFloors" }, outputs: { sweepsSelected: "sweepsSelected" }, usesOnChanges: true, ngImport: i0, template: "<div ngbDropdown class=\"sp-row d-inline-block\">\n <div class=\"col-sm-3\" *ngIf=\"plans\">\n <button type=\"button\" class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\"\n ngbDropdownToggle>{{chosenPlan ?\n chosenPlan.name : ('Choose Plan' | translate) }}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\n <button type=\"button\" ngbDropdownItem *ngFor=\"let plan of plans\" (click)=\"onPlanClick(plan)\"\n [disabled]=\"!plan.calibration\">{{ plan.name }}\n </button>\n </div>\n </div>\n</div>\n<div class=\"sp-row\">\n <lib-selection class=\"col-md-8\" (onSelectionChanged)=\"onSelectionChanged($event)\">\n <lib-plan-legend [isAudioZone]=\"editingAudioZone\" *ngIf=\"buttonElements.length > 0\"></lib-plan-legend>\n <div class=\"selectZone\" oncontextmenu=\"return false;\">\n <div class=\"sp-row\">\n <div style=\"overflow: hidden;width:100%;\">\n <div style=\"height: 400px; width: 100%;\" id=\"planDiv\">\n </div>\n </div>\n </div>\n </div>\n </lib-selection>\n \n <div class=\"col-md-4 scanTool\" *ngIf=\"buttonElements.length > 0\">\n <div class=\"sp-row d-inline-block\">\n <h2>{{'selectTool.title' | translate}}</h2>\n <div class=\"protip\">{{'selectTool.tip' | translate}}.</div>\n </div>\n \n <div class=\"sp-row\">\n <div class=\"col-3\" style=\"padding:0px\">\n <label class=\"tool-label\" for=\"scanSize\">{{'selectTool.size' | translate}}</label>\n </div>\n <div class=\"col-9\">\n <input type=\"range\" class=\"form-range\" min=\"0.001\" max=\"5\" step=\"0.01\" value=\"1\"\n id=\"scanSize\" (input)=\"onChangeScanSize($event)\">\n </div>\n </div>\n \n <div class=\"sp-row\">\n <button class=\"btn btn-primary rounded-pill\" (click)=\"onSelectAll()\">{{'selectTool.selectAll' | translate}}</button>\n </div>\n \n <div *ngIf=\"buttonsInSelection.length > 0\" class=\"edit-selected\">\n <span class=\"tool-label\">{{'selectTool.edit' | translate}} : </span>\n <div class=\"sp-row\">\n <button class=\"btn rounded-pill btn-primary ms-3 me-2\" (click)=\"onSelectionAdd()\">{{'selectTool.add' | translate}}</button>\n <button class=\"btn btn-primary rounded-pill\" (click)=\"onSelectionRemove()\">{{'selectTool.undo' | translate}}</button>\n </div>\n </div>\n\n <div class=\"sp-row\">\n <div *ngIf=\"multipleFloors\"> \n {{ chosenSweepsPerFloor.get(chosenPlan.zoneID) ? chosenSweepsPerFloor.get(chosenPlan.zoneID).length : \"0\"}} {{'scan points selected on this floor' | translate}} \n <button class=\"btn btn-primary rounded-pill\" (click)=\"onValidateForFloor()\" [disabled]=\"!selectionChanged\">{{'Update selection for this floor' | translate}}</button>\n </div>\n <div *ngIf=\"!multipleFloors\">\n {{ chosenScansOnPlan.length }} {{'scan points chosen' | translate}} \n </div>\n </div>\n <div *ngIf=\"!editingAudioZone\" class=\"sp-row\">\n <lib-radio-button label=\"{{ 'selectTool.chooseStartPoint' | translate }}\" (isCheckedEvent)=\"isSettingStartSweep=!isSettingStartSweep\"></lib-radio-button>\n </div>\n <div class=\"sp-row\">\n <button class=\"btn btn-primary rounded-pill\" (click)=\"onSaveSelection()\">{{'selectTool.saveSelection' | translate}}</button>\n <button class=\"btn btn-outline-primary rounded-pill\" (click)=\"onCancel()\">{{'selectTool.cancelSelection' | translate}}</button>\n </div>\n </div>\n\n</div>\n \n", styles: [".sp-row{display:flex;margin-bottom:1rem}.selectZone{border-radius:6px;overflow:hidden;background-color:var(--smarterplan-secondary)}.scanTool{margin:0px 1rem}.protip{color:gray;padding:0}.tool-label{font-size:1rem}\n"], components: [{ type: SelectionComponent, selector: "lib-selection", outputs: ["onSelectionChanged"] }, { type: PlanLegendComponent, selector: "lib-plan-legend", inputs: ["isAudioZone"] }, { type: RadioButtonComponent, selector: "lib-radio-button", inputs: ["label"], outputs: ["isCheckedEvent"] }], directives: [{ type: i7.NgbDropdown, selector: "[ngbDropdown]", inputs: ["autoClose", "dropdownClass", "open", "placement", "container", "display"], outputs: ["openChange"], exportAs: ["ngbDropdown"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgbDropdownToggle, selector: "[ngbDropdownToggle]" }, { type: i7.NgbDropdownMenu, selector: "[ngbDropdownMenu]" }, { type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgbDropdownItem, selector: "[ngbDropdownItem]", inputs: ["disabled"] }], pipes: { "translate": i3.TranslatePipe } });
2548
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SweepPlanSelectionComponent, decorators: [{
2549
+ type: Component,
2550
+ args: [{ selector: 'lib-sweep-plan-selection', template: "<div ngbDropdown class=\"sp-row d-inline-block\">\n <div class=\"col-sm-3\" *ngIf=\"plans\">\n <button type=\"button\" class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\"\n ngbDropdownToggle>{{chosenPlan ?\n chosenPlan.name : ('Choose Plan' | translate) }}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\n <button type=\"button\" ngbDropdownItem *ngFor=\"let plan of plans\" (click)=\"onPlanClick(plan)\"\n [disabled]=\"!plan.calibration\">{{ plan.name }}\n </button>\n </div>\n </div>\n</div>\n<div class=\"sp-row\">\n <lib-selection class=\"col-md-8\" (onSelectionChanged)=\"onSelectionChanged($event)\">\n <lib-plan-legend [isAudioZone]=\"editingAudioZone\" *ngIf=\"buttonElements.length > 0\"></lib-plan-legend>\n <div class=\"selectZone\" oncontextmenu=\"return false;\">\n <div class=\"sp-row\">\n <div style=\"overflow: hidden;width:100%;\">\n <div style=\"height: 400px; width: 100%;\" id=\"planDiv\">\n </div>\n </div>\n </div>\n </div>\n </lib-selection>\n \n <div class=\"col-md-4 scanTool\" *ngIf=\"buttonElements.length > 0\">\n <div class=\"sp-row d-inline-block\">\n <h2>{{'selectTool.title' | translate}}</h2>\n <div class=\"protip\">{{'selectTool.tip' | translate}}.</div>\n </div>\n \n <div class=\"sp-row\">\n <div class=\"col-3\" style=\"padding:0px\">\n <label class=\"tool-label\" for=\"scanSize\">{{'selectTool.size' | translate}}</label>\n </div>\n <div class=\"col-9\">\n <input type=\"range\" class=\"form-range\" min=\"0.001\" max=\"5\" step=\"0.01\" value=\"1\"\n id=\"scanSize\" (input)=\"onChangeScanSize($event)\">\n </div>\n </div>\n \n <div class=\"sp-row\">\n <button class=\"btn btn-primary rounded-pill\" (click)=\"onSelectAll()\">{{'selectTool.selectAll' | translate}}</button>\n </div>\n \n <div *ngIf=\"buttonsInSelection.length > 0\" class=\"edit-selected\">\n <span class=\"tool-label\">{{'selectTool.edit' | translate}} : </span>\n <div class=\"sp-row\">\n <button class=\"btn rounded-pill btn-primary ms-3 me-2\" (click)=\"onSelectionAdd()\">{{'selectTool.add' | translate}}</button>\n <button class=\"btn btn-primary rounded-pill\" (click)=\"onSelectionRemove()\">{{'selectTool.undo' | translate}}</button>\n </div>\n </div>\n\n <div class=\"sp-row\">\n <div *ngIf=\"multipleFloors\"> \n {{ chosenSweepsPerFloor.get(chosenPlan.zoneID) ? chosenSweepsPerFloor.get(chosenPlan.zoneID).length : \"0\"}} {{'scan points selected on this floor' | translate}} \n <button class=\"btn btn-primary rounded-pill\" (click)=\"onValidateForFloor()\" [disabled]=\"!selectionChanged\">{{'Update selection for this floor' | translate}}</button>\n </div>\n <div *ngIf=\"!multipleFloors\">\n {{ chosenScansOnPlan.length }} {{'scan points chosen' | translate}} \n </div>\n </div>\n <div *ngIf=\"!editingAudioZone\" class=\"sp-row\">\n <lib-radio-button label=\"{{ 'selectTool.chooseStartPoint' | translate }}\" (isCheckedEvent)=\"isSettingStartSweep=!isSettingStartSweep\"></lib-radio-button>\n </div>\n <div class=\"sp-row\">\n <button class=\"btn btn-primary rounded-pill\" (click)=\"onSaveSelection()\">{{'selectTool.saveSelection' | translate}}</button>\n <button class=\"btn btn-outline-primary rounded-pill\" (click)=\"onCancel()\">{{'selectTool.cancelSelection' | translate}}</button>\n </div>\n </div>\n\n</div>\n \n", styles: [".sp-row{display:flex;margin-bottom:1rem}.selectZone{border-radius:6px;overflow:hidden;background-color:var(--smarterplan-secondary)}.scanTool{margin:0px 1rem}.protip{color:gray;padding:0}.tool-label{font-size:1rem}\n"] }]
2551
+ }], ctorParameters: function () { return [{ type: i2.ZoneService }, { type: i2.NavigationService }, { type: i2.PlanService }, { type: i3.TranslateService }]; }, propDecorators: { spaceID: [{
2552
+ type: Input
2553
+ }], chosenScansOnPlan: [{
2554
+ type: Input
2555
+ }], newZoneData: [{
2556
+ type: Input
2557
+ }], occupiedSweeps: [{
2558
+ type: Input
2559
+ }], unavailableSweeps: [{
2560
+ type: Input
2561
+ }], editingAudioZone: [{
2562
+ type: Input
2563
+ }], inputZone: [{
2564
+ type: Input
2565
+ }], multipleFloors: [{
2566
+ type: Input
2567
+ }], sweepsSelected: [{
2568
+ type: Output
2569
+ }] } });
2570
+
2571
+ class AddZoneComponent {
2572
+ constructor(fb, zoneService, layerService, userService, navigationService) {
2573
+ this.fb = fb;
2574
+ this.zoneService = zoneService;
2575
+ this.layerService = layerService;
2576
+ this.userService = userService;
2577
+ this.navigationService = navigationService;
2578
+ this.updatedZone = new EventEmitter();
2579
+ this.isMuseumVisit = false;
2580
+ this.parentZones = [];
2581
+ this.carouselIsVisible = false;
2582
+ this.isSubmitted = false;
2583
+ this.chosenScans = [];
2584
+ this.fromPlan = false;
2585
+ this.chosenScansOnPlan = [];
2586
+ this.zoneInitialNavCount = 0;
2587
+ this.zoneIsMatterportFloor = false;
2588
+ this.multipleFloors = false;
2589
+ }
2590
+ ngOnInit() {
2591
+ return __awaiter(this, void 0, void 0, function* () {
2592
+ this.parentZones = this.zones.filter((zone) => zone.layer && zone.layer.name === 'FLOOR');
2593
+ if (!this.defaultZone) {
2594
+ this.defaultZone = this.getDefaultZone();
2595
+ }
2596
+ this.parentZones.unshift(this.defaultZone);
2597
+ yield this.updateLayers();
2598
+ this.initZoneForm();
2599
+ });
2600
+ }
2601
+ updateLayers() {
2602
+ return __awaiter(this, void 0, void 0, function* () {
2603
+ this.currentOrgId = this.userService.currentOrganisation(this.spaceID).id;
2604
+ const layers = yield this.layerService.getLayerForOrganisation(this.currentOrgId);
2605
+ // filter out layers created by the system
2606
+ this.layers = layers.filter((l) => l.name !== 'BUILDING' && l.name !== 'FLOOR');
2607
+ });
2608
+ }
2609
+ initZoneForm() {
2610
+ return __awaiter(this, void 0, void 0, function* () {
2611
+ if (this.zoneEdit) {
2612
+ if (this.zoneEdit.metadata) {
2613
+ const metadata = JSON.parse(this.zoneEdit.metadata);
2614
+ this.zoneIsMatterportFloor = metadata.hasOwnProperty('matterportFloorSequence');
2615
+ }
2616
+ const isVirtual = this.zoneService.zoneIsVirtual(this.zoneEdit);
2617
+ if (!isVirtual) {
2618
+ yield this.loadNavigations();
2619
+ }
2620
+ this.isMuseumVisit = this.zoneEdit.isMuseumVisitZone === true;
2621
+ this.multipleFloors = this.zoneEdit.isMultipleFloorZone === true;
2622
+ this.zoneForm = this.fb.group({
2623
+ id: this.zoneEdit.id,
2624
+ name: [this.zoneEdit.name, [Validators.required]],
2625
+ code_ref: this.zoneEdit.code_ref ? this.zoneEdit.code_ref : null,
2626
+ layerID: this.zoneEdit.layer ? this.zoneEdit.layer.id : null,
2627
+ surface: this.zoneEdit.surface ? this.zoneEdit.surface : 0,
2628
+ parentID: this.zoneEdit.parentID,
2629
+ parent: { value: this.zoneEdit.parent.name, disabled: true },
2630
+ newLayer: [null, [this.layerNameValidator()]],
2631
+ isMuseumVisitZone: this.isMuseumVisit,
2632
+ startSweepID: this.zoneEdit.startSweepID,
2633
+ });
2634
+ this.onChangeMultipleFloors();
2635
+ }
2636
+ else {
2637
+ this.zoneForm = this.fb.group({
2638
+ name: [
2639
+ this.newZoneDataFromEditor ? this.newZoneDataFromEditor.name : '',
2640
+ [Validators.required],
2641
+ ],
2642
+ code_ref: null,
2643
+ layerID: null,
2644
+ surface: 0,
2645
+ parentID: this.defaultZone.id,
2646
+ newLayer: [null, [this.layerNameValidator()]],
2647
+ isMuseumVisitZone: this.isMuseumVisit,
2648
+ startSweepID: null,
2649
+ });
2650
+ }
2651
+ });
2652
+ }
2653
+ onSubmitZone() {
2654
+ return __awaiter(this, void 0, void 0, function* () {
2655
+ this.isSubmitted = true;
2656
+ if (!this.zoneForm.valid) {
2657
+ return;
2658
+ }
2659
+ const formValue = this.zoneForm.getRawValue(); //because we need values of disables controls as well
2660
+ if (formValue.newLayer) {
2661
+ yield this.createLayer(formValue.newLayer).then((layer) => {
2662
+ formValue.layerID = layer.id;
2663
+ });
2664
+ }
2665
+ const zoneInput = {
2666
+ name: formValue.name,
2667
+ surface: Math.round(formValue.surface * 100) / 100,
2668
+ spaceID: this.spaceID,
2669
+ layerID: formValue.layerID,
2670
+ parentID: formValue.parentID,
2671
+ isMuseumVisitZone: this.isMuseumVisit,
2672
+ isMultipleFloorZone: this.multipleFloors,
2673
+ sweepIDs: [],
2674
+ startSweepID: formValue.startSweepID,
2675
+ };
2676
+ if (formValue.code_ref) {
2677
+ zoneInput.code_ref = formValue.code_ref;
2678
+ }
2679
+ try {
2680
+ this.zoneForm = null;
2681
+ this.isSubmitted = false;
2682
+ if (this.zoneEdit) {
2683
+ const zoneUpdate = zoneInput;
2684
+ zoneUpdate.sweepIDs = this.zoneEdit.sweepIDs;
2685
+ zoneUpdate.id = formValue.id;
2686
+ yield this.setSweepsAndNodeForZoneInput(zoneUpdate);
2687
+ yield this.zoneService.updateZone(zoneUpdate);
2688
+ this.zoneEdit = null;
2689
+ this.updatedZone.emit(zoneUpdate.id);
2690
+ }
2691
+ else {
2692
+ yield this.setSweepsAndNodeForZoneInput(zoneInput);
2693
+ if (!zoneInput.parentID) {
2694
+ // set building as parent
2695
+ zoneInput.parentID = this.defaultZone.id;
2696
+ }
2697
+ yield this.zoneService.create(zoneInput).then((zoneCreated) => {
2698
+ this.updatedZone.emit(zoneCreated.id);
2699
+ });
2700
+ }
2701
+ }
2702
+ catch (error) {
2703
+ console.error(error);
2704
+ }
2705
+ });
2706
+ }
2707
+ onCancel() {
2708
+ this.isSubmitted = false;
2709
+ this.zoneForm = null;
2710
+ this.chosenScansOnPlan = [];
2711
+ this.chosenScans = [];
2712
+ this.updatedZone.emit(false);
2713
+ }
2714
+ get name() {
2715
+ return this.zoneForm.get('name');
2716
+ }
2717
+ get newLayer() {
2718
+ return this.zoneForm.get('newLayer');
2719
+ }
2720
+ toggleCarousel() {
2721
+ this.carouselIsVisible = true;
2722
+ this.chosenScansOnPlan = [];
2723
+ }
2724
+ togglePlan() {
2725
+ this.fromPlan = true;
2726
+ this.chosenScans = [];
2727
+ }
2728
+ onAddScan() {
2729
+ if (!this.chosenScans.includes(this.currentScanShowing)) {
2730
+ // console.log("adding scan", this.currentScanShowing);
2731
+ this.chosenScans.push(this.currentScanShowing);
2732
+ }
2733
+ else {
2734
+ alert('Scan already added!');
2735
+ }
2736
+ }
2737
+ onRemoveScanImage(scan) {
2738
+ const index = this.chosenScans.indexOf(scan);
2739
+ this.chosenScans.splice(index, 1);
2740
+ }
2741
+ onRemoveScanPlan(scan) {
2742
+ const index = this.chosenScansOnPlan.indexOf(scan);
2743
+ this.chosenScansOnPlan.splice(index, 1);
2744
+ }
2745
+ setSweepsAndNodeForZoneInput(zoneInput) {
2746
+ return __awaiter(this, void 0, void 0, function* () {
2747
+ if (this.chosenScans.length > 0 &&
2748
+ this.chosenScans.length !== this.zoneInitialNavCount &&
2749
+ !this.fromPlan) {
2750
+ // if we chose scans from the carousel
2751
+ const sweepIDs = [];
2752
+ this.chosenScans.map((scan) => __awaiter(this, void 0, void 0, function* () {
2753
+ const imageUuid = this.images360[scan].filename.split('_')[0];
2754
+ const sweepID = this.navigationIDs.find((nav) => {
2755
+ return nav.includes(imageUuid);
2756
+ });
2757
+ if (sweepID) {
2758
+ sweepIDs.push(sweepID);
2759
+ }
2760
+ }));
2761
+ zoneInput.sweepIDs = sweepIDs;
2762
+ }
2763
+ else {
2764
+ // we are not coming from gallery choice
2765
+ if (this.chosenScansOnPlan.length > 0) {
2766
+ zoneInput.sweepIDs = this.chosenScansOnPlan;
2767
+ }
2768
+ }
2769
+ if (zoneInput.sweepIDs && zoneInput.sweepIDs.length > 0) {
2770
+ const navForSweep = yield this.navigationService.getNavigationsForMatterportIDForSpace(zoneInput.sweepIDs[0], this.spaceID);
2771
+ zoneInput.nodeIDs = [navForSweep[0].nodeID];
2772
+ }
2773
+ });
2774
+ }
2775
+ createLayer(name) {
2776
+ return __awaiter(this, void 0, void 0, function* () {
2777
+ return this.layerService.createLayerForOrganisation(name, this.currentOrgId);
2778
+ });
2779
+ }
2780
+ loadNavigations() {
2781
+ return __awaiter(this, void 0, void 0, function* () {
2782
+ if (this.zoneEdit.sweepIDs.length > 0) {
2783
+ this.zoneInitialNavCount = this.zoneEdit.sweepIDs.length;
2784
+ const navList = [];
2785
+ const scansZoneEdit = [];
2786
+ yield Promise.all(this.zoneEdit.sweepIDs.map((sweepID) => __awaiter(this, void 0, void 0, function* () {
2787
+ scansZoneEdit.push(sweepID);
2788
+ const index = this.images360.findIndex((im) => {
2789
+ return im.filename.includes(sweepID.slice(0, 8));
2790
+ });
2791
+ if (index !== -1) {
2792
+ navList.push(index);
2793
+ }
2794
+ })));
2795
+ this.chosenScans = navList;
2796
+ this.chosenScansOnPlan = scansZoneEdit;
2797
+ return Promise.resolve();
2798
+ }
2799
+ return Promise.resolve();
2800
+ });
2801
+ }
2802
+ // iniPlanForDraw() {
2803
+ // this.togglePlan();
2804
+ // setTimeout(() => {
2805
+ // this.onPlanClick();
2806
+ // }, 500);
2807
+ // }
2808
+ /**
2809
+ * Adds all sweeps of the space
2810
+ */
2811
+ onAddAll() {
2812
+ const defaultZone = this.getDefaultZone();
2813
+ if (defaultZone) {
2814
+ this.chosenScansOnPlan = defaultZone.sweepIDs;
2815
+ this.zoneForm.get('parentID').setValue(defaultZone.id);
2816
+ this.zoneForm.get('parentID').disable();
2817
+ this.multipleFloors = true;
2818
+ }
2819
+ }
2820
+ getDefaultZone() {
2821
+ return this.zones.find((zone) => zone.layer &&
2822
+ zone.layer.name === 'BUILDING' &&
2823
+ zone.sweepIDs &&
2824
+ zone.sweepIDs.length > 0);
2825
+ }
2826
+ /**
2827
+ * Multiple floors
2828
+ */
2829
+ onChangeMultipleFloors() {
2830
+ if (this.multipleFloors) {
2831
+ const defaultZone = this.getDefaultZone();
2832
+ if (defaultZone) {
2833
+ this.zoneForm.get('parentID').setValue(defaultZone.id);
2834
+ this.zoneForm.get('parentID').disable();
2835
+ }
2836
+ }
2837
+ else {
2838
+ this.zoneForm.get('parentID').enable();
2839
+ }
2840
+ }
2841
+ onSelectedSweepsFromPlan(result) {
2842
+ if (result) {
2843
+ if (result.sweeps) {
2844
+ this.chosenScansOnPlan = result.sweeps;
2845
+ }
2846
+ if (result.startSweepID) {
2847
+ this.zoneForm.controls.startSweepID.setValue(result.startSweepID);
2848
+ }
2849
+ }
2850
+ this.fromPlan = false;
2851
+ }
2852
+ layerNameValidator() {
2853
+ return (control) => {
2854
+ if (!control.value) {
2855
+ return null;
2856
+ }
2857
+ const forbidden = this.layers
2858
+ .map((l) => l.name.toLowerCase())
2859
+ .includes(control.value.toLowerCase());
2860
+ return forbidden ? { forbiddenName: { value: control.value } } : null;
2861
+ };
2862
+ }
2863
+ }
2864
+ 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 }], target: i0.ɵɵFactoryTarget.Component });
2865
+ 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", newZoneDataFromEditor: "newZoneDataFromEditor", chosenPlan: "chosenPlan", isMuseumVisit: "isMuseumVisit", defaultZone: "defaultZone" }, outputs: { updatedZone: "updatedZone" }, ngImport: i0, template: "<div class=\"main-container\" *ngIf=\"zoneForm\">\n <div class=\"col-7\">\n <form (ngSubmit)=\"onSubmitZone()\" [formGroup]=\"zoneForm\">\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Name' | translate}} *</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" required formControlName=\"name\">\n <!-- <div class=\"invalid-feedback\">\n {{'A name is required' | translate}}\n </div> -->\n </div>\n </div>\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'codeRef' | translate}}</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" formControlName=\"code_ref\">\n </div>\n </div>\n <div class=\"mb-3 row\" *ngIf=\"!isMuseumVisit && !zoneIsMatterportFloor\">\n <label class=\"col-sm-2 col-form-label\">{{'Type of zone' | translate}}</label>\n <div class=\"col-sm-10\">\n <select class=\"form-control\" formControlName=\"layerID\">\n <option value=\"null\" selected disabled hidden> {{ zoneEdit && zoneEdit.layer ?\n zoneEdit.layer.name : 'Choose type'}}</option>\n <option *ngFor=\"let layer of layers\" [value]=\"layer.id\">\n {{ layer.name }}\n </option>\n </select>\n <p class=\"mt-1 new-type-text\">{{'or add new type of zone' | translate }}</p>\n <input type=\"text\" class=\"form-control new-type-input\" formControlName=\"newLayer\">\n <div *ngIf=\"newLayer.invalid && (newLayer.dirty || newLayer.touched)\" class=\"text-danger\">\n <div *ngIf=\"newLayer.errors?.['forbiddenName']\">\n {{'Layer exists already' | translate}}\n </div>\n </div>\n </div>\n </div>\n <!--If Editing Zone possibility to assign it to museum itinerary-->\n <div class=\"mb-3 row\" *ngIf=\"zoneEdit && !zoneIsMatterportFloor\">\n <label class=\"col-sm-2 col-form-label\">{{ 'Museum Itinerary' | translate }}</label>\n <div class=\"col-sm-10\">\n <input class=\"checkbox-apply mt-3\" type=\"checkbox\" [(ngModel)]=\"isMuseumVisit\"\n [ngModelOptions]=\"{standalone: true}\">\n </div>\n </div>\n\n <div class=\"mb-3 row\" *ngIf=\"!zoneEdit || zoneEdit.isMultipleFloorZone\">\n <label class=\"col-sm-2 col-form-label\">{{ 'Multiple Floors' | translate }}</label>\n <div class=\"col-sm-10\">\n <input class=\"checkbox-apply mt-3\" type=\"checkbox\" [(ngModel)]=\"multipleFloors\"\n [disabled]=\"zoneEdit !== undefined && zoneEdit !== null\" (change)=\"onChangeMultipleFloors()\"\n [ngModelOptions]=\"{standalone: true}\">\n <div class='text-danger' *ngIf=\"zoneEdit\">\n {{'cannotChangeMultifloor' | translate}}\n </div>\n </div>\n\n </div>\n\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Surface' | translate}}</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" formControlName=\"surface\">\n </div>\n </div>\n\n <div class=\"mb-3 row\" *ngIf=\"!zoneIsMatterportFloor\">\n <label class=\"col-sm-2 col-form-label\">{{'Parent zone' | translate}}</label>\n <div class=\"col-sm-10\">\n <input *ngIf=\"zoneEdit\" type=\"text\" class=\"form-control\" formControlName=\"parent\">\n <div class=\"text-danger\" *ngIf=\"zoneEdit\">\n {{'cannotChangeParent' | translate}}\n </div>\n <select *ngIf=\"!zoneEdit\" class=\"form-control\" formControlName=\"parentID\">\n <option *ngFor=\"let zone of parentZones\" [ngValue]=\"zone.id\">\n {{ zone.name }}\n </option>\n </select>\n\n </div>\n </div>\n\n <div class=\"mb-3 row\" style=\"max-height: 200px; overflow: auto;\" *ngIf=\"!zoneIsMatterportFloor\">\n <label class=\"col-sm-2 col-form-label\">{{'Scan Points' | translate}}</label>\n <!-- <p class=\"col-sm-2\" *ngIf=\"zoneEdit\">{{ zoneEdit.sweepIDs.length }} scans</p> -->\n <p class=\"col\" *ngIf=\"chosenScansOnPlan.length === 0 && chosenScans.length === 0\">\n {{'No scan points chosen' | translate}}</p>\n <div class=\"col-sm-5\" *ngIf=\"chosenScansOnPlan && chosenScansOnPlan.length > 0\">\n <p>{{ chosenScansOnPlan.length }} {{'scan points chosen' | translate}}</p>\n <!-- <div *ngFor=\"let scan of chosenScansOnPlan\">\n <div class=\"row\">\n <p class=\"me-2\">{{ scan | slice:0:8 }}</p>\n <div (click)=\"onRemoveScanPlan(scan)\" [style.cursor]=\"'pointer'\">\n <span class=\"iconify\" data-icon=\"mdi:trash-can-outline\"></span>\n </div>\n </div>\n </div> -->\n </div>\n <div class=\"col-sm-5\" *ngIf=\"carouselIsVisible && chosenScans && chosenScans.length > 0\">\n <p>{{ chosenScans.length }} {{'scan points chosen' | translate}}</p>\n <div *ngFor=\"let scan of chosenScans\">\n <div class=\"row\">\n <p class=\"me-2\">{{ images360[scan].filename }}</p>\n <div (click)=\"onRemoveScanImage(scan)\" [style.cursor]=\"'pointer'\">\n <span class=\"iconify\" data-icon=\"mdi:trash-can-outline\"></span>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"row mb-3 mt-3\" *ngIf=\"!zoneIsMatterportFloor\">\n <div class=\"col\">\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\n (click)=\"togglePlan()\">{{'Choose scan points on plan' |\n translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"toggleCarousel()\"\n [disabled]=\"fromPlan || !images360 || images360.length === 0\">\n {{'Choose scan points from gallery' | translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddAll()\"\n [disabled]=\"fromPlan || !images360 || images360.length === 0\">\n {{'add-all-scans' | translate}}</button>\n </div>\n </div>\n\n <!-- <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'No visible scan points' | translate}}</label>\n <div class=\"col-sm-3\">\n <input class=\"checkbox-apply mt-3\" type=\"checkbox\" [(ngModel)]=\"noScanPoints\"\n [ngModelOptions]=\"{standalone: true}\">\n </div>\n </div> -->\n\n <div *ngIf=\"carouselIsVisible\" class=\"mb-2\">\n <lib-carousel *ngIf=\"images360 && images360.length > 0\" [images]=\"images360\"\n (currentScan)=\"currentScanShowing=$event\"></lib-carousel>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2 mt-3\"\n (click)=\"onAddScan()\">{{'Add to zone' | translate}}</button>\n </div>\n <div class=\"mt-3\">\n <button type=\"submit\" class=\"btn btn-primary rounded-pill me-2\"\n [disabled]=\"fromPlan || !zoneForm.valid\">{{'Save' | translate}}</button>\n <button type=\"button\" (click)=\"onCancel()\" class=\"btn btn-outline-primary rounded-pill me-2\">\n {{'Cancel' | translate}}</button>\n </div>\n </form>\n </div>\n <div class=\"edit-plan\" *ngIf=\"fromPlan\">\n <lib-sweep-plan-selection style=\"width: 100%;\" [newZoneData]=\"newZoneDataFromEditor\" [spaceID]=\"spaceID\"\n [multipleFloors]=\"multipleFloors\" [inputZone]=\"zoneEdit\"\n (sweepsSelected)=\"onSelectedSweepsFromPlan($event)\"></lib-sweep-plan-selection>\n </div>\n</div>", styles: [".main-container{display:flex;flex-direction:column}.edit-plan{display:flex;margin:8px 0}.form-range{width:100%}h2{color:var(--smarterplan-primary);padding:0}.col-form-label{margin-bottom:1rem}.btn-outline-primary{margin-right:1rem}.new-type-input{margin-bottom:1rem}.new-type-text{margin-bottom:.5rem}.row{margin:0}p{margin:0;padding-top:calc(.375rem + 1px);padding-bottom:calc(.375rem + 1px)}button{min-width:80px}\n"], components: [{ type: CarouselComponent, selector: "lib-carousel", inputs: ["images"], outputs: ["currentScan"] }, { type: SweepPlanSelectionComponent, selector: "lib-sweep-plan-selection", inputs: ["spaceID", "chosenScansOnPlan", "newZoneData", "occupiedSweeps", "unavailableSweeps", "editingAudioZone", "inputZone", "multipleFloors"], outputs: ["sweepsSelected"] }], directives: [{ type: i6.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: i6.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"] }], pipes: { "translate": i3.TranslatePipe } });
2866
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: AddZoneComponent, decorators: [{
2867
+ type: Component,
2868
+ args: [{ selector: 'lib-add-zone', template: "<div class=\"main-container\" *ngIf=\"zoneForm\">\n <div class=\"col-7\">\n <form (ngSubmit)=\"onSubmitZone()\" [formGroup]=\"zoneForm\">\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Name' | translate}} *</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" required formControlName=\"name\">\n <!-- <div class=\"invalid-feedback\">\n {{'A name is required' | translate}}\n </div> -->\n </div>\n </div>\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'codeRef' | translate}}</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" formControlName=\"code_ref\">\n </div>\n </div>\n <div class=\"mb-3 row\" *ngIf=\"!isMuseumVisit && !zoneIsMatterportFloor\">\n <label class=\"col-sm-2 col-form-label\">{{'Type of zone' | translate}}</label>\n <div class=\"col-sm-10\">\n <select class=\"form-control\" formControlName=\"layerID\">\n <option value=\"null\" selected disabled hidden> {{ zoneEdit && zoneEdit.layer ?\n zoneEdit.layer.name : 'Choose type'}}</option>\n <option *ngFor=\"let layer of layers\" [value]=\"layer.id\">\n {{ layer.name }}\n </option>\n </select>\n <p class=\"mt-1 new-type-text\">{{'or add new type of zone' | translate }}</p>\n <input type=\"text\" class=\"form-control new-type-input\" formControlName=\"newLayer\">\n <div *ngIf=\"newLayer.invalid && (newLayer.dirty || newLayer.touched)\" class=\"text-danger\">\n <div *ngIf=\"newLayer.errors?.['forbiddenName']\">\n {{'Layer exists already' | translate}}\n </div>\n </div>\n </div>\n </div>\n <!--If Editing Zone possibility to assign it to museum itinerary-->\n <div class=\"mb-3 row\" *ngIf=\"zoneEdit && !zoneIsMatterportFloor\">\n <label class=\"col-sm-2 col-form-label\">{{ 'Museum Itinerary' | translate }}</label>\n <div class=\"col-sm-10\">\n <input class=\"checkbox-apply mt-3\" type=\"checkbox\" [(ngModel)]=\"isMuseumVisit\"\n [ngModelOptions]=\"{standalone: true}\">\n </div>\n </div>\n\n <div class=\"mb-3 row\" *ngIf=\"!zoneEdit || zoneEdit.isMultipleFloorZone\">\n <label class=\"col-sm-2 col-form-label\">{{ 'Multiple Floors' | translate }}</label>\n <div class=\"col-sm-10\">\n <input class=\"checkbox-apply mt-3\" type=\"checkbox\" [(ngModel)]=\"multipleFloors\"\n [disabled]=\"zoneEdit !== undefined && zoneEdit !== null\" (change)=\"onChangeMultipleFloors()\"\n [ngModelOptions]=\"{standalone: true}\">\n <div class='text-danger' *ngIf=\"zoneEdit\">\n {{'cannotChangeMultifloor' | translate}}\n </div>\n </div>\n\n </div>\n\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Surface' | translate}}</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" formControlName=\"surface\">\n </div>\n </div>\n\n <div class=\"mb-3 row\" *ngIf=\"!zoneIsMatterportFloor\">\n <label class=\"col-sm-2 col-form-label\">{{'Parent zone' | translate}}</label>\n <div class=\"col-sm-10\">\n <input *ngIf=\"zoneEdit\" type=\"text\" class=\"form-control\" formControlName=\"parent\">\n <div class=\"text-danger\" *ngIf=\"zoneEdit\">\n {{'cannotChangeParent' | translate}}\n </div>\n <select *ngIf=\"!zoneEdit\" class=\"form-control\" formControlName=\"parentID\">\n <option *ngFor=\"let zone of parentZones\" [ngValue]=\"zone.id\">\n {{ zone.name }}\n </option>\n </select>\n\n </div>\n </div>\n\n <div class=\"mb-3 row\" style=\"max-height: 200px; overflow: auto;\" *ngIf=\"!zoneIsMatterportFloor\">\n <label class=\"col-sm-2 col-form-label\">{{'Scan Points' | translate}}</label>\n <!-- <p class=\"col-sm-2\" *ngIf=\"zoneEdit\">{{ zoneEdit.sweepIDs.length }} scans</p> -->\n <p class=\"col\" *ngIf=\"chosenScansOnPlan.length === 0 && chosenScans.length === 0\">\n {{'No scan points chosen' | translate}}</p>\n <div class=\"col-sm-5\" *ngIf=\"chosenScansOnPlan && chosenScansOnPlan.length > 0\">\n <p>{{ chosenScansOnPlan.length }} {{'scan points chosen' | translate}}</p>\n <!-- <div *ngFor=\"let scan of chosenScansOnPlan\">\n <div class=\"row\">\n <p class=\"me-2\">{{ scan | slice:0:8 }}</p>\n <div (click)=\"onRemoveScanPlan(scan)\" [style.cursor]=\"'pointer'\">\n <span class=\"iconify\" data-icon=\"mdi:trash-can-outline\"></span>\n </div>\n </div>\n </div> -->\n </div>\n <div class=\"col-sm-5\" *ngIf=\"carouselIsVisible && chosenScans && chosenScans.length > 0\">\n <p>{{ chosenScans.length }} {{'scan points chosen' | translate}}</p>\n <div *ngFor=\"let scan of chosenScans\">\n <div class=\"row\">\n <p class=\"me-2\">{{ images360[scan].filename }}</p>\n <div (click)=\"onRemoveScanImage(scan)\" [style.cursor]=\"'pointer'\">\n <span class=\"iconify\" data-icon=\"mdi:trash-can-outline\"></span>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"row mb-3 mt-3\" *ngIf=\"!zoneIsMatterportFloor\">\n <div class=\"col\">\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\n (click)=\"togglePlan()\">{{'Choose scan points on plan' |\n translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"toggleCarousel()\"\n [disabled]=\"fromPlan || !images360 || images360.length === 0\">\n {{'Choose scan points from gallery' | translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddAll()\"\n [disabled]=\"fromPlan || !images360 || images360.length === 0\">\n {{'add-all-scans' | translate}}</button>\n </div>\n </div>\n\n <!-- <div class=\"mb-3 row\">\n <label class=\"col-sm-3 col-form-label\">{{'No visible scan points' | translate}}</label>\n <div class=\"col-sm-3\">\n <input class=\"checkbox-apply mt-3\" type=\"checkbox\" [(ngModel)]=\"noScanPoints\"\n [ngModelOptions]=\"{standalone: true}\">\n </div>\n </div> -->\n\n <div *ngIf=\"carouselIsVisible\" class=\"mb-2\">\n <lib-carousel *ngIf=\"images360 && images360.length > 0\" [images]=\"images360\"\n (currentScan)=\"currentScanShowing=$event\"></lib-carousel>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2 mt-3\"\n (click)=\"onAddScan()\">{{'Add to zone' | translate}}</button>\n </div>\n <div class=\"mt-3\">\n <button type=\"submit\" class=\"btn btn-primary rounded-pill me-2\"\n [disabled]=\"fromPlan || !zoneForm.valid\">{{'Save' | translate}}</button>\n <button type=\"button\" (click)=\"onCancel()\" class=\"btn btn-outline-primary rounded-pill me-2\">\n {{'Cancel' | translate}}</button>\n </div>\n </form>\n </div>\n <div class=\"edit-plan\" *ngIf=\"fromPlan\">\n <lib-sweep-plan-selection style=\"width: 100%;\" [newZoneData]=\"newZoneDataFromEditor\" [spaceID]=\"spaceID\"\n [multipleFloors]=\"multipleFloors\" [inputZone]=\"zoneEdit\"\n (sweepsSelected)=\"onSelectedSweepsFromPlan($event)\"></lib-sweep-plan-selection>\n </div>\n</div>", styles: [".main-container{display:flex;flex-direction:column}.edit-plan{display:flex;margin:8px 0}.form-range{width:100%}h2{color:var(--smarterplan-primary);padding:0}.col-form-label{margin-bottom:1rem}.btn-outline-primary{margin-right:1rem}.new-type-input{margin-bottom:1rem}.new-type-text{margin-bottom:.5rem}.row{margin:0}p{margin:0;padding-top:calc(.375rem + 1px);padding-bottom:calc(.375rem + 1px)}button{min-width:80px}\n"] }]
2869
+ }], ctorParameters: function () { return [{ type: i1$2.FormBuilder }, { type: i2.ZoneService }, { type: i2.LayerService }, { type: i2.BaseUserService }, { type: i2.NavigationService }]; }, propDecorators: { zoneEdit: [{
2870
+ type: Input
2871
+ }], spaceID: [{
2872
+ type: Input
2873
+ }], images360: [{
2874
+ type: Input
2875
+ }], navigationIDs: [{
2876
+ type: Input
2877
+ }], zones: [{
2878
+ type: Input
2879
+ }], newZoneDataFromEditor: [{
2880
+ type: Input
2881
+ }], updatedZone: [{
2882
+ type: Output
2883
+ }], chosenPlan: [{
2884
+ type: Input
2885
+ }], isMuseumVisit: [{
2886
+ type: Input
2887
+ }], defaultZone: [{
2888
+ type: Input
2889
+ }] } });
2890
+
2891
+ class AddAudioZoneComponent {
2892
+ constructor(fb, zoneService, layerService, userService, navigationService, commentService, translate) {
2893
+ this.fb = fb;
2894
+ this.zoneService = zoneService;
2895
+ this.layerService = layerService;
2896
+ this.userService = userService;
2897
+ this.navigationService = navigationService;
2898
+ this.commentService = commentService;
2899
+ this.translate = translate;
2900
+ this.updatedZone = new EventEmitter();
2901
+ this.isSubmitted = false;
2902
+ this.fromPlan = false;
2903
+ this.chosenScansOnPlan = [];
2904
+ this.isAddingAudio = false;
2905
+ this.scansModified = false;
2906
+ this.occupiedSweeps = [];
2907
+ this.unavailableSweeps = [];
2908
+ this.working = false;
2909
+ this.audioUploaded = false;
2910
+ }
2911
+ ngOnInit() {
2912
+ if (this.currentAudioZone) {
2913
+ // we are editing zone
2914
+ this.chosenAudio = this.currentAudioZone.audio;
2915
+ this.chosenScansOnPlan = this.currentAudioZone.sweepIDs;
2916
+ this.parentZone = this.currentAudioZone.parent;
2917
+ }
2918
+ this.setup();
2919
+ }
2920
+ setup() {
2921
+ return __awaiter(this, void 0, void 0, function* () {
2922
+ const mission = this.userService.currentMission(this.spaceID);
2923
+ this.currentOrgId = mission.organisationID;
2924
+ let layers = yield this.layerService.getLayerForOrganisation(this.currentOrgId);
2925
+ this.audioLayer = layers.find((layer) => layer.name === "AUDIO");
2926
+ if (!this.audioLayer) {
2927
+ // first time creating Audio Zone
2928
+ this.audioLayer = yield this.layerService.createLayerForOrganisation("AUDIO", this.currentOrgId);
2929
+ }
2930
+ if (!this.parentZone) {
2931
+ this.parentZone = this.defaultZone;
2932
+ }
2933
+ this.audioZones = this.zones.filter((zone) => zone.audioID && zone.parentID === this.parentZone.id);
2934
+ this.occupiedSweeps = this.audioZones.flatMap((zone) => zone.sweepIDs);
2935
+ // unavailable sweeps: sweeps that do not belong to parent zone
2936
+ this.unavailableSweeps = this.defaultZone.sweepIDs.filter((sweep) => !this.parentZone.sweepIDs.includes(sweep));
2937
+ yield this.getAudios();
2938
+ this.commentForm = this.fb.group({
2939
+ title: [null, Validators.required],
2940
+ spaceID: this.spaceID,
2941
+ type: CommentType.AUDIO,
2942
+ ownerID: mission.id,
2943
+ });
2944
+ });
2945
+ }
2946
+ onSubmit() {
2947
+ return __awaiter(this, void 0, void 0, function* () {
2948
+ this.isSubmitted = true;
2949
+ this.working = true;
2950
+ if (this.currentAudioZone) {
2951
+ yield this.zoneService.updateZone({
2952
+ id: this.currentAudioZone.id,
2953
+ sweepIDs: this.chosenScansOnPlan,
2954
+ });
2955
+ yield this.removeTakenSweepsFromOtherZones();
2956
+ this.updatedZone.emit(this.currentAudioZone.id);
2957
+ this.working = false;
2958
+ }
2959
+ else {
2960
+ const zoneInput = {
2961
+ name: `${this.parentZone.name} - ${this.chosenAudio.title}`,
2962
+ surface: 0,
2963
+ spaceID: this.spaceID,
2964
+ layerID: this.audioLayer.id,
2965
+ parentID: this.parentZone.id,
2966
+ isMuseumVisitZone: false,
2967
+ isMultipleFloorZone: this.parentZone.isMultipleFloorZone,
2968
+ audioID: this.chosenAudio.id,
2969
+ };
2970
+ try {
2971
+ yield this.setSweepsAndNodeForZoneInput(zoneInput);
2972
+ yield this.zoneService
2973
+ .create(zoneInput)
2974
+ .then((zoneCreated) => __awaiter(this, void 0, void 0, function* () {
2975
+ this.currentAudioZone = zoneCreated;
2976
+ yield this.removeTakenSweepsFromOtherZones();
2977
+ this.updatedZone.emit(zoneCreated.id);
2978
+ }));
2979
+ this.working = false;
2980
+ }
2981
+ catch (error) {
2982
+ console.error(error);
2983
+ this.working = false;
2984
+ }
2985
+ }
2986
+ });
2987
+ }
2988
+ setSweepsAndNodeForZoneInput(zoneInput) {
2989
+ return __awaiter(this, void 0, void 0, function* () {
2990
+ if (this.chosenScansOnPlan.length > 0) {
2991
+ zoneInput.sweepIDs = this.chosenScansOnPlan;
2992
+ }
2993
+ if (zoneInput.sweepIDs && zoneInput.sweepIDs.length > 0) {
2994
+ const navForSweep = yield this.navigationService.getNavigationsForMatterportIDForSpace(zoneInput.sweepIDs[0], this.spaceID);
2995
+ zoneInput.nodeIDs = [navForSweep[0].nodeID];
2996
+ }
2997
+ });
2998
+ }
2999
+ onCancel() {
3000
+ if (this.scansModified) {
3001
+ const message = this.translate.instant("confirm.cancelEditZone");
3002
+ if (!window.confirm(message)) {
3003
+ return;
3004
+ }
3005
+ }
3006
+ this.commentForm = null;
3007
+ this.chosenScansOnPlan = [];
3008
+ this.updatedZone.emit(false);
3009
+ }
3010
+ togglePlan() {
3011
+ this.fromPlan = true;
3012
+ }
3013
+ onSelectedSweepsFromPlan(result) {
3014
+ if (result && result.sweeps) {
3015
+ this.chosenScansOnPlan = result.sweeps;
3016
+ this.scansModified = true;
3017
+ }
3018
+ this.fromPlan = false;
3019
+ }
3020
+ handleFileInput(event) {
3021
+ const target = event.target;
3022
+ this.fileToUpload = target.files[0];
3023
+ }
3024
+ onUploadAudio() {
3025
+ return __awaiter(this, void 0, void 0, function* () {
3026
+ this.working = true;
3027
+ const commentInput = this.commentForm.value;
3028
+ try {
3029
+ const newAudio = yield this.commentService.createCommentWithFile(commentInput, this.fileToUpload);
3030
+ this.audiosForSpace.push(newAudio);
3031
+ this.isAddingAudio = false;
3032
+ this.working = false;
3033
+ this.audioUploaded = true;
3034
+ }
3035
+ catch (e) {
3036
+ this.working = false;
3037
+ this.audioUploaded = false;
3038
+ console.log(e);
3039
+ }
3040
+ });
3041
+ }
3042
+ getAudios() {
3043
+ return __awaiter(this, void 0, void 0, function* () {
3044
+ const attachments = yield this.commentService.getCommentsBySpaceID(this.spaceID);
3045
+ if (attachments) {
3046
+ this.audiosForSpace = attachments.filter((attachment) => attachment.type === CommentType.AUDIO);
3047
+ }
3048
+ });
3049
+ }
3050
+ onCancelAudioUpload() {
3051
+ this.commentForm = null;
3052
+ this.isAddingAudio = false;
3053
+ this.fileToUpload = null;
3054
+ }
3055
+ onChooseAudio(audio) {
3056
+ this.chosenAudio = audio;
3057
+ this.currentAudioZone = this.audioZones.find((zone) => zone.audioID === this.chosenAudio.id);
3058
+ if (this.currentAudioZone) {
3059
+ this.chosenScansOnPlan = this.currentAudioZone.sweepIDs;
3060
+ }
3061
+ else {
3062
+ this.chosenScansOnPlan = [];
3063
+ }
3064
+ }
3065
+ /**
3066
+ * Removes newly selected sweeps for current zone (they are in chosenScansOnPlan) from other audio zones.
3067
+ * Rule: one sweep = one audio.
3068
+ */
3069
+ removeTakenSweepsFromOtherZones() {
3070
+ return __awaiter(this, void 0, void 0, function* () {
3071
+ yield Promise.all(this.audioZones.map((zone) => __awaiter(this, void 0, void 0, function* () {
3072
+ if (zone.id !== this.currentAudioZone.id) {
3073
+ const newSweeps = zone.sweepIDs.filter((sweepID) => !this.chosenScansOnPlan.includes(sweepID));
3074
+ if (newSweeps.length !== zone.sweepIDs.length) {
3075
+ yield this.zoneService.updateZone({ id: zone.id, sweepIDs: newSweeps });
3076
+ }
3077
+ }
3078
+ })));
3079
+ });
3080
+ }
3081
+ /**
3082
+ * Delete audio as Comment, all its audio Zones and file from S3 (using lambda function)
3083
+ */
3084
+ onDeleteAudio() {
3085
+ return __awaiter(this, void 0, void 0, function* () {
3086
+ const message = this.translate.instant("confirm.deleteAudio");
3087
+ if (window.confirm(message)) {
3088
+ yield this.commentService.deleteComment(this.chosenAudio.id);
3089
+ const index = this.audiosForSpace.indexOf(this.chosenAudio);
3090
+ this.audiosForSpace.splice(index, 1);
3091
+ // delete all zones with this comment audio
3092
+ const audioZonesToDelete = this.zones.filter((z) => z.audioID === this.chosenAudio.id);
3093
+ yield Promise.all(audioZonesToDelete.map((zone) => __awaiter(this, void 0, void 0, function* () {
3094
+ yield this.zoneService.deleteZone(zone.id);
3095
+ const indexZone = this.audioZones.indexOf(this.currentAudioZone);
3096
+ if (indexZone !== -1) {
3097
+ this.audioZones.slice(indexZone, 1);
3098
+ }
3099
+ })));
3100
+ this.currentAudioZone = null;
3101
+ this.chosenAudio = null;
3102
+ }
3103
+ });
3104
+ }
3105
+ }
3106
+ AddAudioZoneComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: AddAudioZoneComponent, deps: [{ token: i1$2.FormBuilder }, { token: i2.ZoneService }, { token: i2.LayerService }, { token: i2.BaseUserService }, { token: i2.NavigationService }, { token: i2.CommentService }, { token: i3.TranslateService }], target: i0.ɵɵFactoryTarget.Component });
3107
+ AddAudioZoneComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: AddAudioZoneComponent, selector: "lib-add-audio-zone", inputs: { spaceID: "spaceID", defaultZone: "defaultZone", zones: "zones", parentZone: "parentZone", currentAudioZone: "currentAudioZone" }, outputs: { updatedZone: "updatedZone" }, ngImport: i0, template: "<div class=\"main-container\">\n <div class=\"col-lg-6 col-md-6 col-sm-7\" *ngIf=\"isAddingAudio\">\n <form (ngSubmit)=\"onUploadAudio()\" [formGroup]=\"commentForm\">\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Name' | translate}} *</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" required formControlName=\"title\">\n </div>\n </div>\n <div>\n <label for=\"file\" class=\"btn btn-label-file rounded-pill\">\n <input type=\"file\" id=\"file\" (change)=\"handleFileInput($event)\" />\n {{'Choose File' | translate}}</label>\n <p *ngIf=\"fileToUpload\">{{ fileToUpload.name}}</p>\n </div>\n <div class=\"d-flex justify-content-center\" *ngIf=\"working\">\n <lib-loader></lib-loader>\n </div>\n \n <div class=\"mt-3\">\n <button type=\"submit\" class=\"btn btn-primary rounded-pill me-2\" [disabled]=\"fromPlan || working\">{{'Upload' | translate}}</button>\n <button type=\"button\" (click)=\"onCancelAudioUpload()\" class=\"btn btn-outline-primary rounded-pill me-2\">\n {{'Cancel' | translate}}</button>\n </div>\n </form>\n </div>\n <ngb-alert type=\"success\" [dismissible]=\"true\" *ngIf=\"!working && audioUploaded\" (closed)=\"audioUploaded=false\">\n {{ 'add-audio.success' | translate }} !\n </ngb-alert>\n <div class=\"col-7\" *ngIf=\"!isAddingAudio && audiosForSpace\">\n \n <div class=\"instruction-row\" >\n <p>1.</p>\n <div ngbDropdown class=\"d-inline-block\">\n <div>\n <button type=\"button\" class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\"\n ngbDropdownToggle>{{chosenAudio ?\n chosenAudio.title : ('choose-audio' | translate) }}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\n <button type=\"button\" ngbDropdownItem *ngFor=\"let audio of audiosForSpace\" \n (click)=\"onChooseAudio(audio)\">{{ audio.title }}\n </button>\n </div>\n </div>\n </div>\n <p>{{'or' | translate}}</p>\n <button (click)=\"isAddingAudio=true\" class=\"btn btn-primary rounded-pill me-2\"> {{'add-audio.add' | translate}}</button>\n </div>\n <div class=\"instruction-row\">\n <p>2.</p>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"togglePlan()\" [disabled]=\"!chosenAudio\">\n {{'Choose scan points on plan' | translate}}</button>\n\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onDeleteAudio()\" [disabled]=\"!chosenAudio\">\n {{'Delete audio' | translate}}</button>\n \n </div>\n <div class=\"instruction-row\" *ngIf=\"chosenAudio\">\n <p>{{ chosenScansOnPlan.length }} {{'scans-chosen-audio' | translate}}</p>\n </div>\n\n <div class=\"mt-3\">\n <button class=\"btn btn-primary rounded-pill me-2\" [disabled]=\"fromPlan || !this.chosenAudio\" (click)=\"onSubmit()\">{{'Save' | translate}}</button>\n <button (click)=\"onCancel()\" class=\"btn btn-outline-primary rounded-pill me-2\">\n {{'Cancel' | translate}}</button>\n </div>\n </div>\n <div class=\"edit-plan\" *ngIf=\"fromPlan\">\n <lib-sweep-plan-selection style=\"width: 100%;\" [inputZone]=\"currentAudioZone\" [spaceID]=\"spaceID\" \n [occupiedSweeps]=\"occupiedSweeps\" [unavailableSweeps]=\"unavailableSweeps\" [editingAudioZone]=\"true\"\n (sweepsSelected)=\"onSelectedSweepsFromPlan($event)\"></lib-sweep-plan-selection>\n </div>\n</div>\n", styles: [".instruction-row{display:flex;align-items:center;margin-top:1rem}.instruction-row button{margin-bottom:0}.instruction-row p{margin-bottom:0;margin-left:5px;margin-right:5px}\n"], components: [{ type: i2.LoaderComponent, selector: "lib-loader", inputs: ["useLogo", "color"] }, { type: i7.NgbAlert, selector: "ngb-alert", inputs: ["animation", "dismissible", "type"], outputs: ["closed"], exportAs: ["ngbAlert"] }, { type: SweepPlanSelectionComponent, selector: "lib-sweep-plan-selection", inputs: ["spaceID", "chosenScansOnPlan", "newZoneData", "occupiedSweeps", "unavailableSweeps", "editingAudioZone", "inputZone", "multipleFloors"], outputs: ["sweepsSelected"] }], directives: [{ type: i6.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: 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: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgbDropdownItem, selector: "[ngbDropdownItem]", inputs: ["disabled"] }], pipes: { "translate": i3.TranslatePipe } });
3108
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: AddAudioZoneComponent, decorators: [{
3109
+ type: Component,
3110
+ args: [{ selector: 'lib-add-audio-zone', template: "<div class=\"main-container\">\n <div class=\"col-lg-6 col-md-6 col-sm-7\" *ngIf=\"isAddingAudio\">\n <form (ngSubmit)=\"onUploadAudio()\" [formGroup]=\"commentForm\">\n <div class=\"mb-3 row\">\n <label class=\"col-sm-2 col-form-label\">{{'Name' | translate}} *</label>\n <div class=\"col-sm-10\">\n <input type=\"text\" class=\"form-control\" required formControlName=\"title\">\n </div>\n </div>\n <div>\n <label for=\"file\" class=\"btn btn-label-file rounded-pill\">\n <input type=\"file\" id=\"file\" (change)=\"handleFileInput($event)\" />\n {{'Choose File' | translate}}</label>\n <p *ngIf=\"fileToUpload\">{{ fileToUpload.name}}</p>\n </div>\n <div class=\"d-flex justify-content-center\" *ngIf=\"working\">\n <lib-loader></lib-loader>\n </div>\n \n <div class=\"mt-3\">\n <button type=\"submit\" class=\"btn btn-primary rounded-pill me-2\" [disabled]=\"fromPlan || working\">{{'Upload' | translate}}</button>\n <button type=\"button\" (click)=\"onCancelAudioUpload()\" class=\"btn btn-outline-primary rounded-pill me-2\">\n {{'Cancel' | translate}}</button>\n </div>\n </form>\n </div>\n <ngb-alert type=\"success\" [dismissible]=\"true\" *ngIf=\"!working && audioUploaded\" (closed)=\"audioUploaded=false\">\n {{ 'add-audio.success' | translate }} !\n </ngb-alert>\n <div class=\"col-7\" *ngIf=\"!isAddingAudio && audiosForSpace\">\n \n <div class=\"instruction-row\" >\n <p>1.</p>\n <div ngbDropdown class=\"d-inline-block\">\n <div>\n <button type=\"button\" class=\"btn btn-label-file rounded-pill\" id=\"dropdownBasic1\"\n ngbDropdownToggle>{{chosenAudio ?\n chosenAudio.title : ('choose-audio' | translate) }}</button>\n <div ngbDropdownMenu aria-labelledby=\"dropdownBasic1\">\n <button type=\"button\" ngbDropdownItem *ngFor=\"let audio of audiosForSpace\" \n (click)=\"onChooseAudio(audio)\">{{ audio.title }}\n </button>\n </div>\n </div>\n </div>\n <p>{{'or' | translate}}</p>\n <button (click)=\"isAddingAudio=true\" class=\"btn btn-primary rounded-pill me-2\"> {{'add-audio.add' | translate}}</button>\n </div>\n <div class=\"instruction-row\">\n <p>2.</p>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"togglePlan()\" [disabled]=\"!chosenAudio\">\n {{'Choose scan points on plan' | translate}}</button>\n\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onDeleteAudio()\" [disabled]=\"!chosenAudio\">\n {{'Delete audio' | translate}}</button>\n \n </div>\n <div class=\"instruction-row\" *ngIf=\"chosenAudio\">\n <p>{{ chosenScansOnPlan.length }} {{'scans-chosen-audio' | translate}}</p>\n </div>\n\n <div class=\"mt-3\">\n <button class=\"btn btn-primary rounded-pill me-2\" [disabled]=\"fromPlan || !this.chosenAudio\" (click)=\"onSubmit()\">{{'Save' | translate}}</button>\n <button (click)=\"onCancel()\" class=\"btn btn-outline-primary rounded-pill me-2\">\n {{'Cancel' | translate}}</button>\n </div>\n </div>\n <div class=\"edit-plan\" *ngIf=\"fromPlan\">\n <lib-sweep-plan-selection style=\"width: 100%;\" [inputZone]=\"currentAudioZone\" [spaceID]=\"spaceID\" \n [occupiedSweeps]=\"occupiedSweeps\" [unavailableSweeps]=\"unavailableSweeps\" [editingAudioZone]=\"true\"\n (sweepsSelected)=\"onSelectedSweepsFromPlan($event)\"></lib-sweep-plan-selection>\n </div>\n</div>\n", styles: [".instruction-row{display:flex;align-items:center;margin-top:1rem}.instruction-row button{margin-bottom:0}.instruction-row p{margin-bottom:0;margin-left:5px;margin-right:5px}\n"] }]
3111
+ }], ctorParameters: function () { return [{ type: i1$2.FormBuilder }, { type: i2.ZoneService }, { type: i2.LayerService }, { type: i2.BaseUserService }, { type: i2.NavigationService }, { type: i2.CommentService }, { type: i3.TranslateService }]; }, propDecorators: { spaceID: [{
3112
+ type: Input
3113
+ }], updatedZone: [{
3114
+ type: Output
3115
+ }], defaultZone: [{
3116
+ type: Input
3117
+ }], zones: [{
3118
+ type: Input
3119
+ }], parentZone: [{
3120
+ type: Input
3121
+ }], currentAudioZone: [{
3122
+ type: Input
3123
+ }] } });
3124
+
3125
+ class CountAudioSweepsPipe {
3126
+ constructor(zoneService) {
3127
+ this.zoneService = zoneService;
3128
+ }
3129
+ transform(zone) {
3130
+ return __awaiter(this, void 0, void 0, function* () {
3131
+ let childrenAudioZones = yield this.zoneService.getZonesByParentZone(zone.id);
3132
+ if (childrenAudioZones.length > 0) {
3133
+ childrenAudioZones = childrenAudioZones.filter((zone) => zone.audioID);
3134
+ if (childrenAudioZones.length > 0) {
3135
+ return childrenAudioZones.flatMap((z) => z.sweepIDs).length;
3136
+ }
3137
+ }
3138
+ return 0;
3139
+ });
3140
+ }
3141
+ }
3142
+ CountAudioSweepsPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CountAudioSweepsPipe, deps: [{ token: i2.ZoneService }], target: i0.ɵɵFactoryTarget.Pipe });
3143
+ CountAudioSweepsPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CountAudioSweepsPipe, name: "countAudioSweeps" });
3144
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CountAudioSweepsPipe, decorators: [{
3145
+ type: Pipe,
3146
+ args: [{
3147
+ name: 'countAudioSweeps'
3148
+ }]
3149
+ }], ctorParameters: function () { return [{ type: i2.ZoneService }]; } });
3150
+
3151
+ class ZonesComponent {
3152
+ constructor(route, zoneService, spaceService, visitService, navigationService, userService, planService, translate, navigatorService, router) {
3153
+ this.route = route;
3154
+ this.zoneService = zoneService;
3155
+ this.spaceService = spaceService;
3156
+ this.visitService = visitService;
3157
+ this.navigationService = navigationService;
3158
+ this.userService = userService;
3159
+ this.planService = planService;
3160
+ this.translate = translate;
3161
+ this.navigatorService = navigatorService;
3162
+ this.router = router;
3163
+ this.lotIndexDetails = -1;
3164
+ this.updatedZone = new EventEmitter();
3165
+ this.isEditingZone = false;
3166
+ this.carouselIsVisible = false;
3167
+ this.planIsVisible = false;
3168
+ this.loadingPlan = false;
3169
+ this.menuItems = [];
3170
+ this.isMuseumVisit = false;
3171
+ this.isMuseumModule = false;
3172
+ this.floorZones = [];
3173
+ this.zonesMap = new Map();
3174
+ this.floorDetails = -1;
3175
+ this.defaultShowing = false;
3176
+ this.isAddingAudioTrack = false;
3177
+ this.destroy$ = new Subject();
3178
+ // listen to the change of location via navigation bar dropdown
3179
+ this.navigatorService.locationIDChange
3180
+ .pipe(takeUntil(this.destroy$))
3181
+ .subscribe((spaceID) => {
3182
+ this.router.navigate(["dashboard/localisation", spaceID, "zones"]).catch(e => console.log(e.message));
3183
+ });
3184
+ this.route.params.subscribe((params) => {
3185
+ this.spaceID = params.id;
3186
+ this.resetZones().catch(e => console.log(e.message));
3187
+ });
3188
+ }
3189
+ ngOnInit() {
3190
+ return __awaiter(this, void 0, void 0, function* () {
3191
+ this.isMuseumModule = this.userService.getSpModule() === SpModule.MUSEUM;
3192
+ });
3193
+ }
3194
+ ngOnDestroy() {
3195
+ this.destroy$.next(true);
3196
+ this.destroy$.complete();
3197
+ }
3198
+ setupMenuItems() {
3199
+ this.menuItems = [
3200
+ { label: "Locations", url: "/localisation" },
3201
+ {
3202
+ label: this.currentSpace.name,
3203
+ url: `/localisation/${this.spaceID}`,
3204
+ },
3205
+ {
3206
+ label: "Zones",
3207
+ url: `/localisation/${this.currentSpace.id}/zones`,
3208
+ },
3209
+ ];
3210
+ }
3211
+ onGoBack() {
3212
+ this.editCompleted(null);
3213
+ }
3214
+ ngOnChanges() {
3215
+ this.resetZones().catch(e => console.log(e.message));
3216
+ }
3217
+ resetZones() {
3218
+ return __awaiter(this, void 0, void 0, function* () {
3219
+ this.isMuseumVisit = false;
3220
+ this.currentSpace = yield this.spaceService.getSpace(this.spaceID);
3221
+ this.setupMenuItems();
3222
+ this.allZones = yield this.zoneService.getZonesBySpace(this.spaceID);
3223
+ this.defaultZone = this.allZones.find((zone) => zone.layer && zone.layer.name === "BUILDING" && zone.sweepIDs);
3224
+ this.floorZones = this.allZones.filter((zone) => zone.layer && zone.layer.name === "FLOOR");
3225
+ // sort alphabetically
3226
+ this.floorZones.sort((a, b) => a.name.localeCompare(b.name));
3227
+ // we add only children zones that are not Floors
3228
+ if (!!this.defaultZone) {
3229
+ this.zonesMap.set(this.defaultZone.id, this.allZones.filter((zone) => zone.parentID === this.defaultZone.id && !this.floorZones.includes(zone)));
3230
+ }
3231
+ for (const floor of this.floorZones) {
3232
+ const zonesForFloor = this.allZones.filter((zone) => zone.parentID === floor.id);
3233
+ this.zonesMap.set(floor.id, zonesForFloor.sort((a, b) => a.name.localeCompare(b.name)));
3234
+ }
3235
+ this.resetNavigations();
3236
+ this.images360 = yield this.visitService.loadImagesForSpace(this.currentSpace);
3237
+ this.plans = yield this.planService.getPlansWithZonesForSpace(this.spaceID);
3238
+ this.plans = this.plans.filter((plan) => plan.isCurrentForZone);
3239
+ this.onPlansLoaded().catch(e => console.log(e.message));
3240
+ });
3241
+ }
3242
+ resetNavigations() {
3243
+ this.navigations = [];
3244
+ const zonesWithSweeps = this.allZones.filter((zone) => zone.sweepIDs);
3245
+ this.navigations = [
3246
+ ...new Set(zonesWithSweeps.flatMap((zone) => zone.sweepIDs)),
3247
+ ];
3248
+ }
3249
+ onPlansLoaded() {
3250
+ return __awaiter(this, void 0, void 0, function* () {
3251
+ if (this.planIsVisible && this.currentZone) {
3252
+ this.preparePlan().catch(e => console.log(e.message));
3253
+ }
3254
+ });
3255
+ }
3256
+ /**
3257
+ * onToggleDetail folds/unfolds details for a zone
3258
+ * @param index
3259
+ * @param zone
3260
+ */
3261
+ onToggleDetail(index, zone) {
3262
+ return __awaiter(this, void 0, void 0, function* () {
3263
+ this.lotIndexDetails = index === this.lotIndexDetails ? -1 : index;
3264
+ if (this.lotIndexDetails === -1) {
3265
+ this.currentZone = null;
3266
+ this.planIsVisible = false;
3267
+ return;
3268
+ }
3269
+ this.currentZone = zone;
3270
+ this.planIsVisible = true;
3271
+ if (!this.plans) {
3272
+ return; // wait until the plans are set
3273
+ }
3274
+ if (this.loadingPlan) {
3275
+ // another plan is already loading
3276
+ yield wait(1000);
3277
+ }
3278
+ this.preparePlan().catch(e => console.log(e.message));
3279
+ });
3280
+ }
3281
+ onToggleDetailFloor(index, floor) {
3282
+ this.defaultShowing = false;
3283
+ this.floorDetails = index === this.floorDetails ? -1 : index;
3284
+ if (this.floorDetails === -1) {
3285
+ this.currentZone = null;
3286
+ this.planIsVisible = false;
3287
+ return;
3288
+ }
3289
+ this.currentZone = floor;
3290
+ this.planIsVisible = true;
3291
+ if (!this.plans) {
3292
+ console.log("plans not ready");
3293
+ return; // wait until the plans are set
3294
+ }
3295
+ this.preparePlan().catch(e => console.log(e.message));
3296
+ }
3297
+ onToggleDefaultZone() {
3298
+ this.defaultShowing = !this.defaultShowing;
3299
+ this.currentZone = this.defaultShowing ? this.defaultZone : null;
3300
+ }
3301
+ preparePlan() {
3302
+ return __awaiter(this, void 0, void 0, function* () {
3303
+ this.loadingPlan = true;
3304
+ this.currentPlan = null;
3305
+ if (this.currentZone.virtual) {
3306
+ this.currentPlan = null;
3307
+ this.loadingPlan = false;
3308
+ return;
3309
+ }
3310
+ this.currentPlan = yield this.planService.getCalibratedPlanForZone(this.currentZone);
3311
+ if (this.currentPlan) {
3312
+ const scans = yield this.navigationService.getNavigationsForZone(this.currentZone);
3313
+ yield this.showScanPointsOnPlan(scans);
3314
+ }
3315
+ this.loadingPlan = false;
3316
+ });
3317
+ }
3318
+ toggleCarousel() {
3319
+ this.carouselIsVisible = true;
3320
+ }
3321
+ onEdit(zone) {
3322
+ this.zoneForEdit = zone;
3323
+ if (this.zoneForEdit.layer && this.zoneForEdit.layer.name === "AUDIO") {
3324
+ this.isAddingAudioTrack = true;
3325
+ }
3326
+ else {
3327
+ this.isEditingZone = true;
3328
+ }
3329
+ this.menuItems.push({
3330
+ label: `${zone.name}`,
3331
+ });
3332
+ }
3333
+ onAddLot() {
3334
+ this.isMuseumVisit = false;
3335
+ this.isEditingZone = true;
3336
+ this.menuItems.push({
3337
+ label: "New",
3338
+ });
3339
+ }
3340
+ onAddMuseumZone() {
3341
+ this.isMuseumVisit = true;
3342
+ this.isEditingZone = true;
3343
+ this.menuItems.push({
3344
+ label: "New Museum Itinerary",
3345
+ });
3346
+ }
3347
+ onAddAudioZone(parentZone) {
3348
+ this.parentZoneForAudio = parentZone;
3349
+ this.isAddingAudioTrack = true;
3350
+ this.menuItems.push({
3351
+ label: parentZone.name,
3352
+ });
3353
+ this.menuItems.push({
3354
+ label: "add-audio.add",
3355
+ });
3356
+ }
3357
+ onDelete(zone) {
3358
+ return __awaiter(this, void 0, void 0, function* () {
3359
+ const message = this.translate.instant("confirm.deleteZone");
3360
+ // eslint-disable-next-line no-alert
3361
+ if (window.confirm(message)) {
3362
+ const childrenZones = yield this.zoneService.getZonesByParentZone(zone.id);
3363
+ yield Promise.all(childrenZones.map((childZone) => __awaiter(this, void 0, void 0, function* () {
3364
+ yield this.zoneService.deleteZone(childZone.id);
3365
+ this.allZones.splice(this.allZones.indexOf(childZone), 1);
3366
+ })));
3367
+ yield this.zoneService.deleteZone(zone.id);
3368
+ this.allZones.splice(this.allZones.indexOf(zone), 1);
3369
+ // remove current zone from its parent list
3370
+ if (zone.parentID && Array.from(this.zonesMap.keys()).includes(zone.parentID)) {
3371
+ const zonesForParent = this.zonesMap.get(zone.parentID);
3372
+ zonesForParent.splice(zonesForParent.indexOf(zone), 1);
3373
+ this.zonesMap.set(zone.parentID, zonesForParent);
3374
+ }
3375
+ // we send update of location in order to force update of list of zones in nav bar
3376
+ this.navigatorService.locationIDChange.next(this.spaceID);
3377
+ }
3378
+ });
3379
+ }
3380
+ editCompleted(event) {
3381
+ this.lotIndexDetails = -1;
3382
+ this.currentPlan = null;
3383
+ this.isEditingZone = false;
3384
+ this.isAddingAudioTrack = false;
3385
+ this.zoneForEdit = null;
3386
+ this.planIsVisible = false;
3387
+ this.carouselIsVisible = false;
3388
+ this.setupMenuItems();
3389
+ if (event) {
3390
+ this.resetZones().catch(e => console.log(e.message));
3391
+ // we send update of location in order to force update of list of zones in nav bar
3392
+ this.navigatorService.locationIDChange.next(this.spaceID);
3393
+ }
3394
+ }
3395
+ showScanPointsOnPlan(navigations) {
3396
+ return __awaiter(this, void 0, void 0, function* () {
3397
+ if (this.currentPlan) {
3398
+ const divPlan = document.querySelector("#planDiv");
3399
+ yield showScanPointsOnPlanInDiv(this.currentPlan, divPlan, navigations);
3400
+ panzoom(divPlan, {
3401
+ bounds: true,
3402
+ boundsPadding: 0,
3403
+ maxZoom: 3.5,
3404
+ });
3405
+ }
3406
+ });
3407
+ }
3408
+ }
3409
+ 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 }, { token: i2.NavigatorService }, { token: i1.Router }], target: i0.ɵɵFactoryTarget.Component });
3410
+ 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\">\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"onGoBack()\"></lib-tab-navigation>\n </div>\n <div class=\"row\" *ngIf=\"!isEditingZone && !isAddingAudioTrack\">\n <div class=\"col-md-6\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item default-zone-line-item\">\n <div class=\"d-flex justify-content-between align-items-center zone-name\" *ngIf=\"defaultZone\">\n {{defaultZone.name}}\n <div class=\"default-zone-label\">{{ \"whole space\" | translate }}</div>\n <lib-chevron [conditionShowing]=\"defaultShowing\" (click)=\"onToggleDefaultZone()\"></lib-chevron>\n </div>\n <div *ngIf=\"defaultShowing\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item bg-transparent\">{{'Type of zone' | translate}}:\n {{defaultZone.layer ? defaultZone.layer.name : \"No type\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"defaultZone.surface\">\n {{'Surface' | translate}}, m<sup>2</sup>: {{defaultZone.surface }}\n </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!defaultZone.virtual\">{{'Scan Points' | translate}}:\n {{defaultZone.sweepIDs ? defaultZone.sweepIDs.length : \"No scan points\" | translate}} </li>\n </ul>\n <div *ngFor=\"let pair of zonesMap | keyvalue\">\n <div *ngIf=\"pair.key == defaultZone.id\">\n <h5 style=\"margin: 8px;\" *ngIf=\"pair.value.length > 0\">{{'Children zones'|translate}}</h5>\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item list-group-flush list-group-item-action\"\n *ngFor=\"let lot of pair.value; index as zoneIndex\">\n <div class=\"d-flex justify-content-between align-items-center zone-name\">\n {{lot.name}}\n <div class=\"museum-label\" *ngIf=\"lot.isMuseumVisitZone\">{{ \"itinerary\" | translate }}</div>\n <lib-chevron [conditionShowing]=\"zoneIndex==lotIndexDetails\"\n (click)=\"onToggleDetail(zoneIndex, lot)\"></lib-chevron>\n\n </div>\n <div *ngIf=\"zoneIndex==lotIndexDetails\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.isMuseumVisitZone\">{{'Type of zone' |\n translate}}: {{lot.layer ? lot.layer.name :\n \"No type\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.surface\">\n {{'Surface' | translate}},m<sup>2</sup>: {{lot.surface }}\n </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.virtual\">{{'Scan Points' | translate}}:\n {{lot.sweepIDs ? lot.sweepIDs.length : \"No scan points\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.virtual\">\n {{'Zone not visible in 3D visit' | translate}}</li>\n </ul>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\n (click)=\"onEdit(lot)\">{{'Edit' | translate}}</button>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddAudioZone(lot)\"\n *ngIf=\"isMuseumModule\"> {{'add-audio.add' | translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\"\n (click)=\"onDelete(lot)\">{{'Delete' | translate}}</button>\n </div>\n </li>\n </ul>\n\n </div>\n </div>\n </div>\n </li>\n\n <li class=\"list-group-item\" *ngFor=\"let floor of floorZones; index as index\">\n <div class=\"d-flex justify-content-between align-items-center zone-name\">\n {{floor.name}}\n <!-- <small>({{ lot.metadata ? ('Calibrated' | translate) : ('Not calibrated' | translate)}})</small> -->\n <div class=\"museum-label\" *ngIf=\"floor.isMuseumVisitZone\">{{ \"itinerary\" | translate }}</div>\n <lib-chevron [conditionShowing]=\"index==floorDetails\"\n (click)=\"onToggleDetailFloor(index, floor)\"></lib-chevron>\n </div>\n <div *ngIf=\"index==floorDetails\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item bg-transparent\">{{'Type of zone' | translate}}: {{floor.layer ?\n floor.layer.name :\n \"No type\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"floor.surface\">{{'Surface' | translate}}, m<sup>2</sup>:\n {{floor.surface }}\n </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!floor.virtual\">{{'Scan Points' | translate}}:\n {{floor.sweepIDs ? floor.sweepIDs.length : \"No scan points\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"floor.virtual\">{{'Zone not visible in 3D visit' |\n translate}}</li>\n </ul>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onEdit(floor)\">{{'Edit' |\n translate}}</button>\n\n <!-- List of children zones -->\n\n <div *ngFor=\"let pair of zonesMap | keyvalue\">\n <div *ngIf=\"pair.key == floor.id\">\n <h5 style=\"margin: 8px;\" *ngIf=\"pair.value.length > 0\">{{'Children zones'|translate}}</h5>\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item list-group-flush list-group-item-action\"\n *ngFor=\"let lot of pair.value; index as zoneIndex\">\n <div class=\"d-flex justify-content-between align-items-center zone-name\">\n <div><span *ngIf=\"lot.code_ref\">{{lot.code_ref}}_</span>{{lot.name}}</div>\n <div class=\"museum-label\" *ngIf=\"lot.isMuseumVisitZone\">{{ \"itinerary\" | translate }}</div>\n <lib-chevron [conditionShowing]=\"zoneIndex==lotIndexDetails\"\n (click)=\"onToggleDetail(zoneIndex, lot)\"></lib-chevron>\n\n </div>\n <div *ngIf=\"zoneIndex==lotIndexDetails\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.isMuseumVisitZone\">{{'Type of zone' |\n translate}}: {{lot.layer ? lot.layer.name :\n \"No type\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.surface\">{{'Surface' | translate}},\n m<sup>2</sup>:\n {{lot.surface }}\n </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.virtual\">{{'Scan Points' | translate}}:\n {{lot.sweepIDs ? lot.sweepIDs.length : \"No scan points\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.virtual && lot.isMuseumVisitZone\">\n {{'Scan Points with audio' | translate}}: {{ lot | countAudioSweeps | async}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.virtual\">\n {{'Zone not visible in 3D visit' | translate}}</li> dist\n </ul>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\n (click)=\"onEdit(lot)\">{{'Edit' | translate}}</button>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddAudioZone(lot)\"\n *ngIf=\"isMuseumModule\"> {{'add-audio.add' | translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\"\n (click)=\"onDelete(lot)\">{{'Delete' | translate}}</button>\n </div>\n </li>\n </ul>\n\n </div>\n </div>\n </div>\n </li>\n </ul>\n\n <div>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddLot()\">{{'Add zone' |\n translate}}</button>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddMuseumZone()\" *ngIf=\"isMuseumModule\">\n {{'Add museum itinerary' | translate}}</button>\n </div>\n </div>\n <div class=\"col-md-6\" *ngIf=\"planIsVisible\">\n <div class=\"d-flex justify-content-center\" *ngIf=\"loadingPlan\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n <div class=\"row\" style=\"overflow: hidden; flex-direction: column;\">\n <div *ngIf=\"currentPlan\">\n <lib-plan-legend [isAudioZone]=\"false\"></lib-plan-legend>\n <div class=\"planContainer\">\n <div class=\"mt-3 ms-3\" style=\"height: 500px; width: 100%;\" id=\"planDiv\"></div>\n </div>\n </div>\n\n <div *ngIf=\"!currentPlan && plans && !loadingPlan && currentZone\">\n <div class=\"mt-3 ms-3\" id=\"no-plan\" *ngIf=\"!currentZone.virtual && !currentZone.isMultipleFloorZone\">\n {{ 'Plan is not calibrated' | translate}}\n </div>\n <div class=\"mt-3 ms-3\" id=\"no-plan\" *ngIf=\"currentZone.virtual\">\n {{ 'No scan points chosen' | translate}}\n </div>\n <div class=\"mt-3 ms-3\" id=\"no-plan\" *ngIf=\"currentZone.isMultipleFloorZone\">\n {{ 'The zone is on several floors' | translate}}\n </div>\n </div>\n\n </div>\n </div>\n </div>\n <div class=\"mb-3\" *ngIf=\"isEditingZone\">\n <lib-add-zone [zoneEdit]=\"zoneForEdit\" [spaceID]=\"spaceID\" [images360]=\"images360\" [navigationIDs]=\"navigations\"\n [zones]=\"allZones\" [defaultZone]=\"defaultZone\" (updatedZone)=\"editCompleted($event)\"\n [isMuseumVisit]=\"isMuseumVisit\"></lib-add-zone>\n </div>\n <div class=\"mb-3\" *ngIf=\"isAddingAudioTrack\">\n <lib-add-audio-zone [spaceID]=\"spaceID\" [defaultZone]=\"defaultZone\" [parentZone]=\"parentZoneForAudio\"\n [zones]=\"allZones\" [currentAudioZone]=\"zoneForEdit\" (updatedZone)=\"editCompleted($event)\"></lib-add-audio-zone>\n </div>\n</div>", 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}.planContainer{overflow:hidden;border-radius:6px;background-color:var(--smarterplan-secondary);height:500px}button{min-width:80px}\n"], components: [{ type: TabNavigationComponent, selector: "lib-tab-navigation", inputs: ["menuItems"], outputs: ["onGoBack"] }, { type: ChevronComponent, selector: "lib-chevron", inputs: ["conditionShowing"] }, { type: PlanLegendComponent, selector: "lib-plan-legend", inputs: ["isAudioZone"] }, { type: AddZoneComponent, selector: "lib-add-zone", inputs: ["zoneEdit", "spaceID", "images360", "navigationIDs", "zones", "newZoneDataFromEditor", "chosenPlan", "isMuseumVisit", "defaultZone"], outputs: ["updatedZone"] }, { type: AddAudioZoneComponent, selector: "lib-add-audio-zone", inputs: ["spaceID", "defaultZone", "zones", "parentZone", "currentAudioZone"], outputs: ["updatedZone"] }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "translate": i3.TranslatePipe, "keyvalue": i6.KeyValuePipe, "async": i6.AsyncPipe, "countAudioSweeps": CountAudioSweepsPipe } });
3411
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ZonesComponent, decorators: [{
3412
+ type: Component,
3413
+ args: [{ selector: 'lib-zones', template: "<div class=\"container-fluid\" *ngIf=\"currentSpace\">\n <div class=\"m-3\">\n <lib-tab-navigation [menuItems]='menuItems' (onGoBack)=\"onGoBack()\"></lib-tab-navigation>\n </div>\n <div class=\"row\" *ngIf=\"!isEditingZone && !isAddingAudioTrack\">\n <div class=\"col-md-6\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item default-zone-line-item\">\n <div class=\"d-flex justify-content-between align-items-center zone-name\" *ngIf=\"defaultZone\">\n {{defaultZone.name}}\n <div class=\"default-zone-label\">{{ \"whole space\" | translate }}</div>\n <lib-chevron [conditionShowing]=\"defaultShowing\" (click)=\"onToggleDefaultZone()\"></lib-chevron>\n </div>\n <div *ngIf=\"defaultShowing\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item bg-transparent\">{{'Type of zone' | translate}}:\n {{defaultZone.layer ? defaultZone.layer.name : \"No type\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"defaultZone.surface\">\n {{'Surface' | translate}}, m<sup>2</sup>: {{defaultZone.surface }}\n </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!defaultZone.virtual\">{{'Scan Points' | translate}}:\n {{defaultZone.sweepIDs ? defaultZone.sweepIDs.length : \"No scan points\" | translate}} </li>\n </ul>\n <div *ngFor=\"let pair of zonesMap | keyvalue\">\n <div *ngIf=\"pair.key == defaultZone.id\">\n <h5 style=\"margin: 8px;\" *ngIf=\"pair.value.length > 0\">{{'Children zones'|translate}}</h5>\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item list-group-flush list-group-item-action\"\n *ngFor=\"let lot of pair.value; index as zoneIndex\">\n <div class=\"d-flex justify-content-between align-items-center zone-name\">\n {{lot.name}}\n <div class=\"museum-label\" *ngIf=\"lot.isMuseumVisitZone\">{{ \"itinerary\" | translate }}</div>\n <lib-chevron [conditionShowing]=\"zoneIndex==lotIndexDetails\"\n (click)=\"onToggleDetail(zoneIndex, lot)\"></lib-chevron>\n\n </div>\n <div *ngIf=\"zoneIndex==lotIndexDetails\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.isMuseumVisitZone\">{{'Type of zone' |\n translate}}: {{lot.layer ? lot.layer.name :\n \"No type\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.surface\">\n {{'Surface' | translate}},m<sup>2</sup>: {{lot.surface }}\n </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.virtual\">{{'Scan Points' | translate}}:\n {{lot.sweepIDs ? lot.sweepIDs.length : \"No scan points\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.virtual\">\n {{'Zone not visible in 3D visit' | translate}}</li>\n </ul>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\n (click)=\"onEdit(lot)\">{{'Edit' | translate}}</button>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddAudioZone(lot)\"\n *ngIf=\"isMuseumModule\"> {{'add-audio.add' | translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\"\n (click)=\"onDelete(lot)\">{{'Delete' | translate}}</button>\n </div>\n </li>\n </ul>\n\n </div>\n </div>\n </div>\n </li>\n\n <li class=\"list-group-item\" *ngFor=\"let floor of floorZones; index as index\">\n <div class=\"d-flex justify-content-between align-items-center zone-name\">\n {{floor.name}}\n <!-- <small>({{ lot.metadata ? ('Calibrated' | translate) : ('Not calibrated' | translate)}})</small> -->\n <div class=\"museum-label\" *ngIf=\"floor.isMuseumVisitZone\">{{ \"itinerary\" | translate }}</div>\n <lib-chevron [conditionShowing]=\"index==floorDetails\"\n (click)=\"onToggleDetailFloor(index, floor)\"></lib-chevron>\n </div>\n <div *ngIf=\"index==floorDetails\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item bg-transparent\">{{'Type of zone' | translate}}: {{floor.layer ?\n floor.layer.name :\n \"No type\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"floor.surface\">{{'Surface' | translate}}, m<sup>2</sup>:\n {{floor.surface }}\n </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!floor.virtual\">{{'Scan Points' | translate}}:\n {{floor.sweepIDs ? floor.sweepIDs.length : \"No scan points\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"floor.virtual\">{{'Zone not visible in 3D visit' |\n translate}}</li>\n </ul>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onEdit(floor)\">{{'Edit' |\n translate}}</button>\n\n <!-- List of children zones -->\n\n <div *ngFor=\"let pair of zonesMap | keyvalue\">\n <div *ngIf=\"pair.key == floor.id\">\n <h5 style=\"margin: 8px;\" *ngIf=\"pair.value.length > 0\">{{'Children zones'|translate}}</h5>\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item list-group-flush list-group-item-action\"\n *ngFor=\"let lot of pair.value; index as zoneIndex\">\n <div class=\"d-flex justify-content-between align-items-center zone-name\">\n <div><span *ngIf=\"lot.code_ref\">{{lot.code_ref}}_</span>{{lot.name}}</div>\n <div class=\"museum-label\" *ngIf=\"lot.isMuseumVisitZone\">{{ \"itinerary\" | translate }}</div>\n <lib-chevron [conditionShowing]=\"zoneIndex==lotIndexDetails\"\n (click)=\"onToggleDetail(zoneIndex, lot)\"></lib-chevron>\n\n </div>\n <div *ngIf=\"zoneIndex==lotIndexDetails\">\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.isMuseumVisitZone\">{{'Type of zone' |\n translate}}: {{lot.layer ? lot.layer.name :\n \"No type\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.surface\">{{'Surface' | translate}},\n m<sup>2</sup>:\n {{lot.surface }}\n </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.virtual\">{{'Scan Points' | translate}}:\n {{lot.sweepIDs ? lot.sweepIDs.length : \"No scan points\" | translate}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"!lot.virtual && lot.isMuseumVisitZone\">\n {{'Scan Points with audio' | translate}}: {{ lot | countAudioSweeps | async}} </li>\n <li class=\"list-group-item bg-transparent\" *ngIf=\"lot.virtual\">\n {{'Zone not visible in 3D visit' | translate}}</li> dist\n </ul>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill me-2\"\n (click)=\"onEdit(lot)\">{{'Edit' | translate}}</button>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddAudioZone(lot)\"\n *ngIf=\"isMuseumModule\"> {{'add-audio.add' | translate}}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\"\n (click)=\"onDelete(lot)\">{{'Delete' | translate}}</button>\n </div>\n </li>\n </ul>\n\n </div>\n </div>\n </div>\n </li>\n </ul>\n\n <div>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddLot()\">{{'Add zone' |\n translate}}</button>\n <button class=\"btn btn-outline-primary rounded-pill me-2\" (click)=\"onAddMuseumZone()\" *ngIf=\"isMuseumModule\">\n {{'Add museum itinerary' | translate}}</button>\n </div>\n </div>\n <div class=\"col-md-6\" *ngIf=\"planIsVisible\">\n <div class=\"d-flex justify-content-center\" *ngIf=\"loadingPlan\">\n <div class=\"spinner-border\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n <div class=\"row\" style=\"overflow: hidden; flex-direction: column;\">\n <div *ngIf=\"currentPlan\">\n <lib-plan-legend [isAudioZone]=\"false\"></lib-plan-legend>\n <div class=\"planContainer\">\n <div class=\"mt-3 ms-3\" style=\"height: 500px; width: 100%;\" id=\"planDiv\"></div>\n </div>\n </div>\n\n <div *ngIf=\"!currentPlan && plans && !loadingPlan && currentZone\">\n <div class=\"mt-3 ms-3\" id=\"no-plan\" *ngIf=\"!currentZone.virtual && !currentZone.isMultipleFloorZone\">\n {{ 'Plan is not calibrated' | translate}}\n </div>\n <div class=\"mt-3 ms-3\" id=\"no-plan\" *ngIf=\"currentZone.virtual\">\n {{ 'No scan points chosen' | translate}}\n </div>\n <div class=\"mt-3 ms-3\" id=\"no-plan\" *ngIf=\"currentZone.isMultipleFloorZone\">\n {{ 'The zone is on several floors' | translate}}\n </div>\n </div>\n\n </div>\n </div>\n </div>\n <div class=\"mb-3\" *ngIf=\"isEditingZone\">\n <lib-add-zone [zoneEdit]=\"zoneForEdit\" [spaceID]=\"spaceID\" [images360]=\"images360\" [navigationIDs]=\"navigations\"\n [zones]=\"allZones\" [defaultZone]=\"defaultZone\" (updatedZone)=\"editCompleted($event)\"\n [isMuseumVisit]=\"isMuseumVisit\"></lib-add-zone>\n </div>\n <div class=\"mb-3\" *ngIf=\"isAddingAudioTrack\">\n <lib-add-audio-zone [spaceID]=\"spaceID\" [defaultZone]=\"defaultZone\" [parentZone]=\"parentZoneForAudio\"\n [zones]=\"allZones\" [currentAudioZone]=\"zoneForEdit\" (updatedZone)=\"editCompleted($event)\"></lib-add-audio-zone>\n </div>\n</div>", 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}.planContainer{overflow:hidden;border-radius:6px;background-color:var(--smarterplan-secondary);height:500px}button{min-width:80px}\n"] }]
3414
+ }], 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 }, { type: i2.NavigatorService }, { type: i1.Router }]; }, propDecorators: { updatedZone: [{
3415
+ type: Output
3416
+ }] } });
3417
+
3418
+ class ImagesComponent {
3419
+ constructor(route, spaceService, visitService, nodeService, navigatorService, router) {
3420
+ this.route = route;
3421
+ this.spaceService = spaceService;
3422
+ this.visitService = visitService;
3423
+ this.nodeService = nodeService;
3424
+ this.navigatorService = navigatorService;
3425
+ this.router = router;
3426
+ this.loading = false;
3427
+ this.menuItems = [];
3428
+ this.destroy$ = new Subject();
3429
+ this.navigatorService.locationIDChange
3430
+ .pipe(takeUntil(this.destroy$))
3431
+ .subscribe((spaceID) => {
3432
+ this.router.navigate(["dashboard/localisation", spaceID, "images"]);
3433
+ });
3434
+ this.route.params.subscribe((params) => {
3435
+ this.spaceID = params.id;
3436
+ ;
3437
+ this.loadImages();
3438
+ });
3439
+ }
3440
+ ngOnInit() {
3441
+ }
3442
+ ngOnDestroy() {
3443
+ this.destroy$.next(true);
3444
+ this.destroy$.complete();
3445
+ }
3446
+ setupMenuItems() {
3447
+ this.menuItems = [
3448
+ { label: "Locations", url: "/localisation" },
3449
+ {
3450
+ label: this.currentSpace.name,
3451
+ url: `/localisation/${this.spaceID}`,
3452
+ },
3453
+ { label: "360° Images" },
3454
+ ];
3455
+ if (this.currentVisit) {
3456
+ this.menuItems.push({ label: this.currentVisit.name });
3457
+ }
3458
+ }
3459
+ onGoBack() {
3460
+ this.currentVisit = null;
3461
+ this.currentImages = null;
3462
+ this.setupMenuItems();
3463
+ }
3464
+ loadImages() {
3465
+ return __awaiter(this, void 0, void 0, function* () {
3466
+ this.loading = true;
3467
+ this.currentSpace = yield this.spaceService.getSpace(this.spaceID);
3468
+ this.setupMenuItems();
3469
+ this.images = yield this.visitService.loadImagesForSpace(this.currentSpace);
3470
+ if (this.currentSpace.visits.length === 1) {
3471
+ this.setVisit(this.currentSpace.visits[0]);
3472
+ }
3473
+ this.loading = false;
3474
+ });
3475
+ }
3476
+ setVisit(visit) {
3477
+ this.currentVisit = visit;
3478
+ this.currentImages = this.images.filter((im) => {
3479
+ return im.visit === visit;
3480
+ });
3481
+ this.setupMenuItems();
3482
+ }
3483
+ setCurrentScan(id) {
3484
+ this.currentScanID = id;
3485
+ }
3486
+ onInventoryClick() {
3487
+ return __awaiter(this, void 0, void 0, function* () {
3488
+ const { node } = this.currentVisit;
3489
+ const { filename } = this.currentImages[this.currentScanID]; // 110ee452_sweep.jpeg
3490
+ // check if node has already errors of inventory
3491
+ const missingFilesErrors = [
3492
+ InventoryStatus.ERROR_FILE_JSON_NOT_EXIST,
3493
+ InventoryStatus.ERROR_FILE_MODEL_NOT_EXIST,
3494
+ InventoryStatus.ERROR_FILE_OBJ_NOT_EXIST,
3495
+ ];
3496
+ if (node.inventoryStatus &&
3497
+ missingFilesErrors.includes(node.inventoryStatus)) {
3498
+ alert("Files missing for this visit's inventory. Contact your administrator.");
3499
+ }
3500
+ else {
3501
+ yield this.nodeService.updateNode({
3502
+ id: node.id,
3503
+ inventoryStatus: InventoryStatus.TO_RUN_ONE_IMAGE,
3504
+ navigationForInventory: filename.split("_")[0],
3505
+ });
3506
+ alert("Automatic AI Inventory started! Detected equipments will appear soon in the visit.");
3507
+ }
3508
+ });
3509
+ }
3510
+ }
3511
+ 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 }, { token: i2.NavigatorService }, { token: i1.Router }], target: i0.ɵɵFactoryTarget.Component });
3512
+ 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: i6.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: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgbDropdownItem, selector: "[ngbDropdownItem]", inputs: ["disabled"] }], pipes: { "translate": i3.TranslatePipe } });
3513
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ImagesComponent, decorators: [{
3514
+ type: Component,
3515
+ 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: [""] }]
3516
+ }], ctorParameters: function () { return [{ type: i1.ActivatedRoute }, { type: i2.SpaceService }, { type: i2.VisitService }, { type: i2.NodeService }, { type: i2.NavigatorService }, { type: i1.Router }]; } });
3517
+
3518
+ class EditPlanComponent {
3519
+ constructor(planService, route, router, modalService, zoneService, visitService, spaceService, translate, ngZone) {
3520
+ this.planService = planService;
3521
+ this.route = route;
3522
+ this.router = router;
3523
+ this.modalService = modalService;
3524
+ this.zoneService = zoneService;
3525
+ this.visitService = visitService;
3526
+ this.spaceService = spaceService;
3527
+ this.translate = translate;
3528
+ this.ngZone = ngZone;
3529
+ this.loading = false;
3530
+ this.isNewZone = false;
3531
+ /**
3532
+ * Options for svgEditor
3533
+ */
3534
+ this.config = {
3535
+ noStorageOnLoad: true,
3536
+ forceStorage: true,
3537
+ // imgPath: "/assets/editor/images/",
3538
+ // extPath: "/assets/editor/extensions/",
3539
+ // langPath: "/assets/editor/locale/",
3540
+ // canvgPath: "/assets/editor/canvg/",
3541
+ // jspdfPath: "/assets/editor/jspdf/",
3542
+ // jGraduatePath: "/assets/editor/jgraduate/images/",
3543
+ // extIconsPath: "/assets/editor/extensions/",
3544
+ // stylesheets: [
3545
+ // "/assets/editor/jgraduate/css/jGraduate.css",
3546
+ // "/assets/editor/spinbtn/jQuery.SpinButton.css",
3547
+ // "/assets/editor/jgraduate/css/jPicker.css",
3548
+ // "/assets/editor/svg-editor.css",
3549
+ // ],
3550
+ dimensions: [10000, 10000],
3551
+ showlayers: true,
3552
+ noDefaultExtensions: true,
3553
+ basePath: "/assets/editor/",
3554
+ customExportImage: true,
3555
+ extensions: [
3556
+ "ext-connector",
3557
+ // "ext-eyedropper",
3558
+ // "ext-grid",
3559
+ // "ext-markers",
3560
+ // "ext-overview_window",
3561
+ // "ext-spi-library",
3562
+ // "ext-spi-icon",
3563
+ "ext-sp-zone",
3564
+ // "ext-arrows",
3565
+ // "ext-sp-css",
3566
+ // "ext-placemark",
3567
+ ],
3568
+ };
3569
+ this.menuItems = [];
3570
+ this.chosenPlan = this.planService.getChosenPlan();
3571
+ }
3572
+ ngOnInit() {
3573
+ return __awaiter(this, void 0, void 0, function* () {
3574
+ this.editorUrl = "/assets/editor/main.html";
3575
+ this.spaceID = this.route.snapshot.queryParams.spaceID;
3576
+ this.currentSpace = yield this.spaceService.getSpace(this.spaceID);
3577
+ this.setupMenuItems();
3578
+ if (this.spaceID && !this.planService.getChosenPlan()) {
3579
+ this.router.navigate([
3580
+ "/dashboard/localisation",
3581
+ this.spaceID,
3582
+ "plans",
3583
+ ]);
3584
+ }
3585
+ else if (!this.spaceID && !this.planService.getChosenPlan()) {
3586
+ this.router.navigate(["/dashboard/localisation"]);
3587
+ }
3588
+ });
3589
+ }
3590
+ setupMenuItems() {
3591
+ this.menuItems = [
3592
+ { label: "Locations", url: "/localisation" },
3593
+ {
3594
+ label: this.currentSpace.name,
3595
+ url: `/localisation/${this.spaceID}`,
3596
+ },
3597
+ {
3598
+ label: "Plans",
3599
+ url: `/localisation/${this.currentSpace.id}/plans`,
3600
+ },
3601
+ {
3602
+ label: "Edit",
3603
+ url: `/localisation/${this.currentSpace.id}/plan-edit?spaceID=${this.currentSpace.id}`,
3604
+ },
3605
+ ];
3606
+ }
3607
+ switchAction(event) {
3608
+ return __awaiter(this, void 0, void 0, function* () {
3609
+ if (event.origin === window.location.origin) {
3610
+ switch (event.data.message) {
3611
+ case "save":
3612
+ this.onSave(event.data.redirect);
3613
+ break;
3614
+ case "close":
3615
+ this.onCancel();
3616
+ break;
3617
+ case "new-zone":
3618
+ const modalReference = this.modalService.open(this.loadingModal);
3619
+ const svg = unescape(encodeURIComponent(this.svgEditor.svgCanvas.getSvgString()));
3620
+ const base64 = `data:image/svg+xml;base64,${window.btoa(svg)}`;
3621
+ const currentSpace = yield this.spaceService.getSpace(this.spaceID);
3622
+ this.images360 = yield this.visitService.loadImagesForSpace(currentSpace);
3623
+ this.editedPlan = Object.assign({}, this.chosenPlan);
3624
+ this.editedPlan.filepath = base64;
3625
+ this.newZoneData = event.data.zoneData;
3626
+ if (this.newZoneData.elements.length === 0) {
3627
+ modalReference.close();
3628
+ alert(this.translate.instant("edition.no-zone"));
3629
+ break;
3630
+ }
3631
+ this.zones = yield this.zoneService.getZonesBySpace(this.spaceID);
3632
+ // this.zones = sortAlphabeticallyOnName(this.zones);
3633
+ // console.log("zones", this.zones);
3634
+ // this.editedZone = this.zones.find(
3635
+ // (z) => z.name === this.newZoneData.name,
3636
+ // );
3637
+ this.resetNavigations();
3638
+ modalReference.close();
3639
+ this.modalService.open(this.dialogZone);
3640
+ break;
3641
+ default:
3642
+ break;
3643
+ }
3644
+ }
3645
+ });
3646
+ }
3647
+ resetNavigations() {
3648
+ return __awaiter(this, void 0, void 0, function* () {
3649
+ this.navigations = [];
3650
+ const defaultZone = this.zones.find((zone) => !zone.parentID);
3651
+ if (defaultZone.sweepIDs.length > 0) {
3652
+ this.navigations = defaultZone.sweepIDs;
3653
+ }
3654
+ });
3655
+ }
3656
+ onLoad(svgEditor) {
3657
+ return __awaiter(this, void 0, void 0, function* () {
3658
+ if (svgEditor.contentWindow.SvgEditor) {
3659
+ this.svgEditorIframe = svgEditor;
3660
+ this.svgEditor = new svgEditor.contentWindow.SvgEditor();
3661
+ yield this.svgEditor.init();
3662
+ yield this.svgEditor.setConfig(this.config, {
3663
+ allowInitialUserOverride: true,
3664
+ });
3665
+ if (this.chosenPlan && this.chosenPlan.extension === "svg") {
3666
+ this.loadSvg();
3667
+ }
3668
+ if (this.chosenPlan && this.chosenPlan.extension === "pdf") {
3669
+ this.loadPdf();
3670
+ }
3671
+ if (!this.chosenPlan.calibration || !this.chosenPlan.isModified) {
3672
+ setTimeout(() => {
3673
+ this.svgEditorIframe.contentWindow.postMessage({ action: "disable-zone" }, "*");
3674
+ }, 1000);
3675
+ }
3676
+ this.svgEditor.svgCanvas.setMode('ext-panning');
3677
+ this.svgEditor.bottomPanel.changeZoom(50);
3678
+ }
3679
+ });
3680
+ }
3681
+ onSave(redirect) {
3682
+ return __awaiter(this, void 0, void 0, function* () {
3683
+ const imgBlob = yield new Blob([this.svgEditor.svgCanvas.getSvgString()], {
3684
+ type: "image/svg+xml",
3685
+ });
3686
+ const [name] = this.chosenPlan.name.split(".");
3687
+ const imgFile = new File([imgBlob], `${name}-edited.svg`, {
3688
+ type: "image/svg+xml",
3689
+ lastModified: Date.now(),
3690
+ });
3691
+ this.planService.setPlanFileCache(imgFile);
3692
+ if (this.chosenPlan.isModified) {
3693
+ this.ngZone.run(() => this.modalService.open(this.dialog));
3694
+ }
3695
+ else {
3696
+ this.ngZone.run(() => this.router.navigate([
3697
+ "/dashboard/localisation",
3698
+ this.spaceID,
3699
+ "plans",
3700
+ ]));
3701
+ }
3702
+ });
3703
+ }
3704
+ updateSvg() {
3705
+ return __awaiter(this, void 0, void 0, function* () {
3706
+ const newUrl = yield this.planService.updatePlanFile();
3707
+ yield this.planService.updatePlan({
3708
+ id: this.chosenPlan.id,
3709
+ annexe: newUrl,
3710
+ });
3711
+ this.planService.setPlanFileCache(null);
3712
+ this.ngZone.run(() => this.router.navigate([
3713
+ "/dashboard/localisation",
3714
+ this.spaceID,
3715
+ "plans",
3716
+ ]));
3717
+ });
3718
+ }
3719
+ newSvg() {
3720
+ return __awaiter(this, void 0, void 0, function* () {
3721
+ this.ngZone.run(() => this.router.navigate([
3722
+ "/dashboard/localisation",
3723
+ this.spaceID,
3724
+ "plans",
3725
+ ]));
3726
+ });
3727
+ }
3728
+ onCancel() {
3729
+ return __awaiter(this, void 0, void 0, function* () {
3730
+ if (window.confirm(this.translate.instant("edition.cancel-alert"))) {
3731
+ this.ngZone.run(() => this.router.navigate([
3732
+ "/dashboard/localisation",
3733
+ this.spaceID,
3734
+ "plans",
3735
+ ]));
3736
+ alert(this.translate.instant("edition.cancel"));
3737
+ }
3738
+ });
3739
+ }
3740
+ loadSvg() {
3741
+ return __awaiter(this, void 0, void 0, function* () {
3742
+ const svgRequest = yield downloadFileAsObject(this.chosenPlan.annexe);
3743
+ if (svgRequest) {
3744
+ const svgBlob = yield svgRequest.Body;
3745
+ const reader = new FileReader();
3746
+ reader.onloadend = () => {
3747
+ this.svgEditor.loadFromDataURI(reader.result);
3748
+ };
3749
+ reader.readAsDataURL(svgBlob);
3750
+ }
3751
+ });
3752
+ }
3753
+ loadPdf() {
3754
+ return __awaiter(this, void 0, void 0, function* () {
3755
+ this.svgEditorIframe.contentWindow.postMessage({ action: "disable-zone" }, "*");
3756
+ const canvas = document.querySelector("#canvas4pdf");
3757
+ const context = canvas.getContext("2d");
3758
+ const pdfjs = yield import('pdfjs-dist/build/pdf');
3759
+ const pdfjsWorker = yield import('pdfjs-dist/build/pdf.worker.entry');
3760
+ pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
3761
+ const pdf = yield getDocument(this.chosenPlan.filepath).promise;
3762
+ const page = yield pdf.getPage(1);
3763
+ const viewPortParameters = { scale: 1.5 };
3764
+ const viewport = page.getViewport(viewPortParameters);
3765
+ this.svgEditor.svgCanvas.setResolution(viewport.width, viewport.height);
3766
+ canvas.height = viewport.height;
3767
+ canvas.width = viewport.width;
3768
+ const renderContext = {
3769
+ canvasContext: context,
3770
+ viewport,
3771
+ };
3772
+ const renderTask = page.render(renderContext).promise;
3773
+ renderTask.then(() => {
3774
+ const newImage = this.svgEditor.svgCanvas.addSVGElementFromJson({
3775
+ element: "image",
3776
+ attr: {
3777
+ x: 0,
3778
+ y: 0,
3779
+ width: viewport.width,
3780
+ height: viewport.height,
3781
+ id: this.svgEditor.svgCanvas.getNextId(),
3782
+ style: "pointer-events:inherit",
3783
+ },
3784
+ });
3785
+ this.svgEditor.svgCanvas.setHref(newImage, canvas.toDataURL("image/png"));
3786
+ this.svgEditor.svgCanvas.renameCurrentLayer(this.translate.instant("edition.plan-base"));
3787
+ this.svgEditor.svgCanvas.createLayer(this.translate.instant("edition.personalization"));
3788
+ });
3789
+ });
3790
+ }
3791
+ onLoadImg(img) {
3792
+ return __awaiter(this, void 0, void 0, function* () {
3793
+ this.svgEditorIframe.contentWindow.postMessage({ action: "disable-zone" }, "*");
3794
+ const imgRequest = yield downloadFileAsObject(this.chosenPlan.annexe);
3795
+ if (imgRequest) {
3796
+ const imgBlob = yield imgRequest.Body;
3797
+ const imgWidth = img.naturalWidth;
3798
+ const imgHeight = img.naturalHeight;
3799
+ // await this.svgEditor.setConfig({
3800
+ // dimensions: [imgWidth, imgHeight],
3801
+ // });
3802
+ this.svgEditor.svgCanvas.setResolution(imgWidth, imgHeight);
3803
+ const reader = new FileReader();
3804
+ reader.onloadend = () => {
3805
+ const newImage = this.svgEditor.svgCanvas.addSVGElementFromJson({
3806
+ element: "image",
3807
+ attr: {
3808
+ x: 0,
3809
+ y: 0,
3810
+ width: imgWidth,
3811
+ height: imgHeight,
3812
+ id: this.svgEditor.svgCanvas.getNextId(),
3813
+ style: "pointer-events:inherit",
3814
+ },
3815
+ });
3816
+ this.svgEditor.svgCanvas.setHref(newImage, reader.result);
3817
+ this.svgEditor.svgCanvas.renameCurrentLayer(this.translate.instant("edition.plan-base"));
3818
+ this.svgEditor.svgCanvas.createLayer(this.translate.instant("edition.personalization"));
3819
+ };
3820
+ reader.readAsDataURL(imgBlob);
3821
+ }
3822
+ });
3823
+ }
3824
+ onNewZone(event) {
3825
+ this.isNewZone = false;
3826
+ if (event) {
3827
+ this.svgEditorIframe.contentWindow.postMessage({ action: "rename-layer", name: event }, "*");
3828
+ }
3829
+ else {
3830
+ this.svgEditorIframe.contentWindow.postMessage({ action: "cancel-layer" }, "*");
3831
+ }
3832
+ }
3833
+ }
3834
+ 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 }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
3835
+ 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<lib-add-zone *ngIf=\"isNewZone\" [images360]=\"images360\" [spaceID]=\"spaceID\" [navigationIDs]=\"navigations\"\n [zoneEdit]=\"editedZone\" [zones]=\"zones\" (updatedZone)=\"onNewZone($event)\" [chosenPlan]=\"editedPlan\"\n [newZoneDataFromEditor]=\"newZoneData\"></lib-add-zone>\n<iframe *ngIf=\"editorUrl\" #svgEditor [src]=\"editorUrl | safeUrl\" frameborder=\"0\"\n style=\"height:100%;width:100%;min-height:550px;max-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<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 {{'confirm.new-zone-from-plan' | translate}}\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", "newZoneDataFromEditor", "chosenPlan", "isMuseumVisit", "defaultZone"], outputs: ["updatedZone"] }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "safeUrl": i2.SafeUrlPipe, "translate": i3.TranslatePipe } });
3836
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: EditPlanComponent, decorators: [{
3837
+ type: Component,
3838
+ 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<lib-add-zone *ngIf=\"isNewZone\" [images360]=\"images360\" [spaceID]=\"spaceID\" [navigationIDs]=\"navigations\"\n [zoneEdit]=\"editedZone\" [zones]=\"zones\" (updatedZone)=\"onNewZone($event)\" [chosenPlan]=\"editedPlan\"\n [newZoneDataFromEditor]=\"newZoneData\"></lib-add-zone>\n<iframe *ngIf=\"editorUrl\" #svgEditor [src]=\"editorUrl | safeUrl\" frameborder=\"0\"\n style=\"height:100%;width:100%;min-height:550px;max-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<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 {{'confirm.new-zone-from-plan' | translate}}\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"] }]
3839
+ }], 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 }, { type: i0.NgZone }]; }, propDecorators: { dialog: [{
3840
+ type: ViewChild,
3841
+ args: ["dialog"]
3842
+ }], dialogZone: [{
3843
+ type: ViewChild,
3844
+ args: ["dialogZone"]
3845
+ }], loadingModal: [{
3846
+ type: ViewChild,
3847
+ args: ["preparing"]
3848
+ }], switchAction: [{
3849
+ type: HostListener,
3850
+ args: ["window:message", ["$event"]]
3851
+ }] } });
3852
+
3853
+ const routes = [
3854
+ {
3855
+ path: "",
3856
+ component: LocationsComponent,
3857
+ },
3858
+ {
3859
+ path: ":id",
3860
+ children: [
3861
+ { path: "", component: DetailLocationComponent },
3862
+ { path: "zones", component: ZonesComponent },
3863
+ { path: "visits", component: VisitsComponent },
3864
+ { path: "plans", component: PlansComponent },
3865
+ {
3866
+ path: "plan-calibration",
3867
+ component: CalibrationComponent,
3868
+ },
3869
+ {
3870
+ path: "plan-edit",
3871
+ component: EditPlanComponent,
3872
+ },
3873
+ { path: "images", component: ImagesComponent },
3874
+ ],
3875
+ },
3876
+ ];
3877
+ class LocationsRoutingModule {
3878
+ }
3879
+ LocationsRoutingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocationsRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3880
+ LocationsRoutingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocationsRoutingModule, imports: [i1.RouterModule], exports: [RouterModule] });
3881
+ LocationsRoutingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocationsRoutingModule, imports: [[RouterModule.forChild(routes)], RouterModule] });
3882
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocationsRoutingModule, decorators: [{
3883
+ type: NgModule,
3884
+ args: [{
3885
+ imports: [RouterModule.forChild(routes)],
3886
+ exports: [RouterModule],
3887
+ }]
3888
+ }] });
3889
+
3890
+ class NgxSmarterplanLocationsModule {
3891
+ }
3892
+ NgxSmarterplanLocationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3893
+ NgxSmarterplanLocationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsModule, declarations: [LocationsComponent,
3894
+ DetailLocationComponent,
3895
+ CalibrationComponent,
3896
+ PlansComponent,
3897
+ VisitsComponent,
3898
+ ZonesComponent,
3899
+ ImagesComponent,
3900
+ EditPlanComponent,
3901
+ TabNavigationComponent,
3902
+ MapComponent,
3903
+ MapPopupComponent,
3904
+ FormLocationComponent,
3905
+ ChevronComponent,
3906
+ AddZoneComponent,
3907
+ SelectionComponent,
3908
+ CarouselComponent,
3909
+ SweepPlanSelectionComponent,
3910
+ AddAudioZoneComponent,
3911
+ RadioButtonComponent,
3912
+ PlanLegendComponent,
3913
+ CountAudioSweepsPipe], imports: [PdfViewerModule,
3914
+ ClipboardModule,
3915
+ NgbModule,
3916
+ NgbAlertModule,
3917
+ CommonModule, i3.TranslateModule, LeafletModule,
3918
+ FormsModule,
3919
+ ReactiveFormsModule,
3920
+ NgxSmarterplanCoreModule,
3921
+ LocationsRoutingModule], exports: [MapComponent, TabNavigationComponent] });
3922
+ NgxSmarterplanLocationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsModule, imports: [[
3923
+ PdfViewerModule,
3924
+ ClipboardModule,
3925
+ NgbModule,
3926
+ NgbAlertModule,
3927
+ CommonModule,
3928
+ TranslateModule.forChild({
3929
+ extend: true
3930
+ }),
3931
+ LeafletModule,
3932
+ FormsModule,
3933
+ ReactiveFormsModule,
3934
+ NgxSmarterplanCoreModule,
3935
+ LocationsRoutingModule,
3936
+ ]] });
3937
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: NgxSmarterplanLocationsModule, decorators: [{
3938
+ type: NgModule,
3939
+ args: [{
3940
+ declarations: [
3941
+ LocationsComponent,
3942
+ DetailLocationComponent,
3943
+ CalibrationComponent,
3944
+ PlansComponent,
3945
+ VisitsComponent,
3946
+ ZonesComponent,
3947
+ ImagesComponent,
3948
+ EditPlanComponent,
3949
+ TabNavigationComponent,
3950
+ MapComponent,
3951
+ MapPopupComponent,
3952
+ FormLocationComponent,
3953
+ ChevronComponent,
3954
+ AddZoneComponent,
3955
+ SelectionComponent,
3956
+ CarouselComponent,
3957
+ SweepPlanSelectionComponent,
3958
+ AddAudioZoneComponent,
3959
+ RadioButtonComponent,
3960
+ PlanLegendComponent,
3961
+ CountAudioSweepsPipe,
3962
+ ],
3963
+ imports: [
3964
+ PdfViewerModule,
3965
+ ClipboardModule,
3966
+ NgbModule,
3967
+ NgbAlertModule,
3968
+ CommonModule,
3969
+ TranslateModule.forChild({
3970
+ extend: true
3971
+ }),
3972
+ LeafletModule,
3973
+ FormsModule,
3974
+ ReactiveFormsModule,
3975
+ NgxSmarterplanCoreModule,
3976
+ LocationsRoutingModule,
3977
+ ],
3978
+ exports: [MapComponent, TabNavigationComponent]
3979
+ }]
3980
+ }] });
3981
+
3982
+ /*
3983
+ * Public API Surface of ngx-smarterplan-locations
3984
+ */
3985
+
3986
+ /**
3987
+ * Generated bundle index. Do not edit.
3988
+ */
3989
+
3990
+ export { MapComponent, NgxSmarterplanLocationsModule, NgxSmarterplanLocationsService, TabNavigationComponent };
3991
+ //# sourceMappingURL=smarterplan-ngx-smarterplan-locations.mjs.map