@smarterplan/ngx-smarterplan-core 1.4.28 → 1.4.29

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.
@@ -14303,6 +14303,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
14303
14303
  }]
14304
14304
  }], ctorParameters: () => [{ type: PoiService }, { type: NavigationService }, { type: VisitService }] });
14305
14305
 
14306
+ /**
14307
+ * What the API says when it refuses a request for coming too fast, in an Error or in the errors of a
14308
+ * GraphQL answer: the request was not done, and can be sent again a little later.
14309
+ */
14310
+ const THROTTLED = /rate exceeded|throttl|too many requests|status code 429|throughput exceeds|provisionedthroughputexceeded|requestlimitexceeded/i;
14311
+ function isThrottled(error) {
14312
+ const texts = [
14313
+ error?.message,
14314
+ error?.name,
14315
+ error?.code,
14316
+ ...(Array.isArray(error?.errors) ? error.errors : []).flatMap((e) => [e?.message, e?.errorType]),
14317
+ ];
14318
+ return texts.some((text) => typeof text === "string" && THROTTLED.test(text));
14319
+ }
14320
+ /** How long to wait before each new try, give or take half, so that requests do not come back together. */
14321
+ const THROTTLED_WAITS_MS = [500, 1000, 2000, 4000];
14322
+ /** Sends the request again, a little later each time, while the API refuses it for coming too fast. */
14323
+ async function retryWhenThrottled(request, waitsMs = THROTTLED_WAITS_MS) {
14324
+ for (let attempt = 0;; attempt++) {
14325
+ try {
14326
+ return await request();
14327
+ }
14328
+ catch (error) {
14329
+ if (attempt >= waitsMs.length || !isThrottled(error)) {
14330
+ throw error;
14331
+ }
14332
+ await new Promise((resolve) => setTimeout(resolve, waitsMs[attempt] * (0.5 + Math.random())));
14333
+ }
14334
+ }
14335
+ }
14336
+
14306
14337
  class OperationService {
14307
14338
  API; //AWS
14308
14339
  /** Equipments linked to a ticket in this session: their loaded `operations` may be outdated. */
@@ -14321,16 +14352,30 @@ class OperationService {
14321
14352
  const tickets = operations.map((operation) => operation.ticket);
14322
14353
  return tickets;
14323
14354
  }
14324
- /** Tickets of a loaded equipment, without a request when its list query shows it has no operation. */
14325
- async getTicketsForEquipment(equip) {
14355
+ /** Whether a loaded equipment's list query shows it has no operation, none linked since. */
14356
+ loadedWithoutOperations(equip) {
14326
14357
  const operations = equip.operations;
14327
- if (operations?.items?.length === 0
14358
+ return operations?.items?.length === 0
14328
14359
  && !operations.nextToken
14329
- && !this.linkedEquipmentIDs.has(equip.id)) {
14360
+ && !this.linkedEquipmentIDs.has(equip.id);
14361
+ }
14362
+ /** Tickets of a loaded equipment, without a request when its list query shows it has no operation. */
14363
+ async getTicketsForEquipment(equip) {
14364
+ if (this.loadedWithoutOperations(equip)) {
14330
14365
  return [];
14331
14366
  }
14332
14367
  return this.getTicketsByEquipmentID(equip.id);
14333
14368
  }
14369
+ /**
14370
+ * Deletes a loaded equipment's operations, without a request when its list query shows it has
14371
+ * none: for an equipment loaded just before, as one loaded long ago may have some since.
14372
+ */
14373
+ async deleteOperationsForLoadedEquipment(equip) {
14374
+ if (this.loadedWithoutOperations(equip)) {
14375
+ return [];
14376
+ }
14377
+ return this.deleteOperationsForEquipment(equip.id);
14378
+ }
14334
14379
  async deleteOperationsForEquipment(equipID) {
14335
14380
  const deleted = [];
14336
14381
  await this.getOperationsByEquipmentID(equipID)
@@ -15922,29 +15967,35 @@ class EquipmentService extends BaseObjectService {
15922
15967
  return null;
15923
15968
  });
15924
15969
  }
15925
- async deleteEquipment(equip) {
15926
- const deleted = await this.API.__proto__.DeleteEquipment({ id: equip.id });
15927
- console.log('Deleted equipment', deleted);
15928
- // delete POI
15929
- const [poi] = equip.pois.items;
15930
- if (poi) {
15931
- await this.poiService.deletePoi(poi.id);
15932
- }
15933
- // delete notes related
15934
- if (equip.notes.items.length > 0) {
15935
- await Promise.all(equip.notes.items.map(async (note) => {
15936
- // delete files from S3
15937
- /** Not shared with other equipment */
15938
- if (note.attachment &&
15939
- !note.attachment.split('/').pop().startsWith('BATCH_')) {
15940
- await deleteFromS3(note.attachment);
15941
- }
15942
- await this.API.__proto__.DeleteNote({ id: note.id });
15943
- }));
15970
+ /**
15971
+ * Deletes an equipment with what hangs on it: every one of its POIs (its tags in the visits), its
15972
+ * notes and their files, its operations. Those go first: when one of them fails, the equipment is
15973
+ * still there to be deleted again, instead of tags left pointing at an equipment that is gone.
15974
+ * A request the API refuses for coming too fast is sent again a little later. justLoaded: the
15975
+ * equipment comes from a list loaded just before, whose operations can be trusted, so none there
15976
+ * means no request for them.
15977
+ */
15978
+ async deleteEquipment(equip, justLoaded = false) {
15979
+ for (const poi of equip.pois?.items ?? []) {
15980
+ if (poi) {
15981
+ await retryWhenThrottled(() => this.poiService.deletePoi(poi.id));
15982
+ }
15944
15983
  }
15945
- // delete operations (remove from linked tickets)
15946
- await this.operationService.deleteOperationsForEquipment(equip.id);
15947
- return deleted;
15984
+ await Promise.all((equip.notes?.items ?? [])
15985
+ .filter((note) => !!note)
15986
+ .map(async (note) => {
15987
+ // Its file, unless a batch edit shares it with other equipment.
15988
+ if (note.attachment &&
15989
+ !note.attachment.split('/').pop().startsWith('BATCH_')) {
15990
+ await deleteFromS3(note.attachment);
15991
+ }
15992
+ await retryWhenThrottled(() => this.API.__proto__.DeleteNote({ id: note.id }));
15993
+ }));
15994
+ // Its operations, which also takes it off the tickets linked to it.
15995
+ await retryWhenThrottled(() => justLoaded
15996
+ ? this.operationService.deleteOperationsForLoadedEquipment(equip)
15997
+ : this.operationService.deleteOperationsForEquipment(equip.id));
15998
+ return retryWhenThrottled(() => this.API.__proto__.DeleteEquipment({ id: equip.id }));
15948
15999
  }
15949
16000
  async updateEquipmentLocation(equip, tagData) {
15950
16001
  const poiInput = {
@@ -19101,6 +19152,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
19101
19152
  args: ['window:message', ['$event']]
19102
19153
  }] } });
19103
19154
 
19155
+ /**
19156
+ * Deletes one file of a visit's AI inventory, and nothing outside it.
19157
+ *
19158
+ * The inventory's only S3 delete. It lives here, out of the library's public API, rather than as a
19159
+ * generic helper beside the other S3 functions, so that no other code picks it up for something
19160
+ * else: it refuses any key outside `visits/<model3D>/inventory/`, and logs every deletion with the
19161
+ * reason its caller gives. Rejects when the key is refused or the file could not be deleted.
19162
+ */
19163
+ async function removeInventoryFile(model3D, key, reason) {
19164
+ const folder = `visits/${model3D}/inventory/`;
19165
+ const segments = key.split("/");
19166
+ const inside = !!model3D && key.startsWith(folder) && key.length > folder.length
19167
+ && !segments.includes("..") && !segments.includes(".");
19168
+ if (!inside || !reason?.trim()) {
19169
+ throw new Error(`Refused to delete "${key}": only a file of the inventory of visit "${model3D}", with a reason, can be deleted here.`);
19170
+ }
19171
+ console.info(`Inventory: deleting ${key} (${reason})`);
19172
+ await Storage.remove(key, { level: "public" });
19173
+ }
19174
+
19104
19175
  /**
19105
19176
  * The minimum scores a detection can be asked to beat. The model keeps those scoring strictly more
19106
19177
  * (yolact's postprocess: score > threshold), and a score is at most 1: 1.0 would keep none.
@@ -19115,6 +19186,8 @@ const PANORAMA = /\.(png|jpg|jpeg|tiff|bmp|gif)$/;
19115
19186
  * so: it no longer keeps another from being launched.
19116
19187
  */
19117
19188
  const INVENTORY_STALE_AFTER_MS = 3 * 60 * 60 * 1000;
19189
+ /** How many kept detection files are deleted at a time: a visit can have thousands. */
19190
+ const DISCARD_AT_ONCE = 20;
19118
19191
  /**
19119
19192
  * What is asked of each inventory: the most the API has of these, an environment whose backend
19120
19193
  * predates a field refusing any query that asks for it.
@@ -19192,6 +19265,47 @@ class InventoryService {
19192
19265
  isComplete(files) {
19193
19266
  return !!files && files.panoramas > 0 && files.dataJson && files.modelObj;
19194
19267
  }
19268
+ /**
19269
+ * How many panoramas' detections each inventory of the visit kept in the bucket, by inventory
19270
+ * (machine-learning: inventory_job.py); null when the bucket could not be read.
19271
+ */
19272
+ async keptDetections(model3D) {
19273
+ const files = await listFilesInFolder(`visits/${model3D}/inventory/runs/`);
19274
+ if (!files) {
19275
+ return null;
19276
+ }
19277
+ const kept = {};
19278
+ for (const file of files) {
19279
+ const run = /\/runs\/([^/]+)\/detections\/[^/]+\.json$/.exec(file.key ?? "")?.[1];
19280
+ if (run) {
19281
+ kept[run] = (kept[run] ?? 0) + 1;
19282
+ }
19283
+ }
19284
+ return kept;
19285
+ }
19286
+ /**
19287
+ * Deletes all the detections kept for the visit, going on past a file that fails, and says how
19288
+ * many could not be deleted. The equipment placed from them stays.
19289
+ */
19290
+ async discardDetections(model3D) {
19291
+ const files = await listFilesInFolder(`visits/${model3D}/inventory/runs/`);
19292
+ if (!files) {
19293
+ throw new Error(`Detections of ${model3D} not listed`);
19294
+ }
19295
+ const keys = files.map((file) => file.key).filter((key) => !!key);
19296
+ let failed = 0;
19297
+ for (let start = 0; start < keys.length; start += DISCARD_AT_ONCE) {
19298
+ const batch = keys.slice(start, start + DISCARD_AT_ONCE);
19299
+ const results = await Promise.allSettled(batch.map((key) => removeInventoryFile(model3D, key, "saved detections discarded")));
19300
+ results.forEach((result, i) => {
19301
+ if (result.status === "rejected") {
19302
+ failed += 1;
19303
+ console.error("Detection not deleted", batch[i], result.reason);
19304
+ }
19305
+ });
19306
+ }
19307
+ return failed;
19308
+ }
19195
19309
  /** The latest inventory of each visit, the latest first. */
19196
19310
  latestOfEachVisit(runs) {
19197
19311
  const latest = new Map();
@@ -19299,9 +19413,11 @@ class InventoryService {
19299
19413
  /**
19300
19414
  * Launches an inventory of each of the visits, unless one is already running in the space:
19301
19415
  * of all their panoramas, or of the one of `sweep` (the first 8 characters of its sweep, as
19302
- * the panoramas are named) when it is given.
19416
+ * the panoramas are named) when it is given. A visit given an inventory in `resumeFrom` starts
19417
+ * from that one's detections: with all its panoramas analysed, only the placing is done again,
19418
+ * with this cutoff.
19303
19419
  */
19304
- async launch(spaceID, nodeIDs, model, cutoffScore, sweep) {
19420
+ async launch(spaceID, nodeIDs, model, cutoffScore, sweep, resumeFrom = {}) {
19305
19421
  const runs = await this.getRuns(spaceID);
19306
19422
  if (runs.some((run) => this.isRunning(run))) {
19307
19423
  return "ALREADY_RUNNING";
@@ -19330,6 +19446,7 @@ class InventoryService {
19330
19446
  status: sweep
19331
19447
  ? InventoryStatus.TO_RUN_ONE_IMAGE
19332
19448
  : InventoryStatus.TO_RUN,
19449
+ ...(resumeFrom[nodeID] ? { resumeFrom: resumeFrom[nodeID] } : {}),
19333
19450
  });
19334
19451
  }));
19335
19452
  return "LAUNCHED";
@@ -19367,6 +19484,8 @@ class InventoryRunsComponent {
19367
19484
  /** Whether one of the inventories shown is running: said when it changes. */
19368
19485
  runningChange = new EventEmitter();
19369
19486
  runs = [];
19487
+ /** Every inventory of the space by its id, for where one that places detections again took them. */
19488
+ byId = new Map();
19370
19489
  /** The inventory whose cancelling waits for its confirmation. */
19371
19490
  confirmingCancel = null;
19372
19491
  /** The inventory being cancelled or resumed, its buttons disabled meanwhile. */
@@ -19402,6 +19521,7 @@ class InventoryRunsComponent {
19402
19521
  this.stopPolling();
19403
19522
  return;
19404
19523
  }
19524
+ this.byId = new Map(runs.map((run) => [run.id, run]));
19405
19525
  this.runs = this.inventoryService
19406
19526
  .latestOfEachVisit(runs)
19407
19527
  .filter((run) => !this.nodeIDs || this.nodeIDs.includes(run.nodeID));
@@ -19423,6 +19543,14 @@ class InventoryRunsComponent {
19423
19543
  this.stopPolling();
19424
19544
  }
19425
19545
  }
19546
+ /**
19547
+ * The finished inventory whose detections this one places again with its own cutoff, analysing
19548
+ * no panorama; null when it analyses them, resuming a stopped one included.
19549
+ */
19550
+ reusedFrom(run) {
19551
+ const source = run.resumeFrom ? this.byId.get(run.resumeFrom) : null;
19552
+ return source && this.inventoryService.state(source) === "done" ? source : null;
19553
+ }
19426
19554
  /**
19427
19555
  * About how many minutes the panoramas left will take, at the pace seen since the inventory
19428
19556
  * was first seen analysing them; null until a panorama has been done meanwhile.
@@ -19477,11 +19605,11 @@ class InventoryRunsComponent {
19477
19605
  }
19478
19606
  }
19479
19607
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: InventoryRunsComponent, deps: [{ token: InventoryService }], target: i0.ɵɵFactoryTarget.Component });
19480
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: InventoryRunsComponent, selector: "lib-inventory-runs", inputs: { spaceID: "spaceID", nodeIDs: "nodeIDs", labels: "labels" }, outputs: { runningChange: "runningChange" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"inventory-runs\" *ngIf=\"runs.length\">\n <h5>{{'Last inventory' | translate}}</h5>\n <div class=\"inventory-run\" *ngFor=\"let run of runs\">\n <div class=\"inventory-run-header\">\n <span class=\"no-lowercase\">{{ labels?.[run.nodeID] ?? run.nodeID }}</span>\n <span class=\"inventory-run-date\">{{ run.createdAt | date:'short' }}</span>\n </div>\n <ng-container [ngSwitch]=\"inventoryService.state(run)\">\n <div *ngSwitchCase=\"'waiting'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{'Waiting for the analysis to start\u2026' | translate}}\n </div>\n <div *ngSwitchCase=\"'running'\">\n <ng-container [ngSwitch]=\"run.step\">\n <div *ngSwitchCase=\"'DOWNLOADING'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{'Downloading the files of the visit\u2026' | translate}}\n </div>\n <div *ngSwitchCase=\"'PLACING'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{'Placing the objects in 3D\u2026' | translate}}\n </div>\n <div *ngSwitchCase=\"'SAVING'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{'Saving the equipment\u2026' | translate}}\n </div>\n <div *ngSwitchDefault>\n <ng-container *ngTemplateOutlet=\"panoramas; context: { $implicit: run }\"></ng-container>\n <span class=\"inventory-run-detail\" *ngIf=\"minutesLeft(run) as minutes\">\n {{'About' | translate}} {{ minutes }} {{'min left' | translate}}\n </span>\n </div>\n </ng-container>\n <ng-container *ngIf=\"inventoryService.canCancel(run)\">\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill mt-2\"\n *ngIf=\"confirmingCancel !== run.id\" (click)=\"confirmingCancel = run.id\">\n {{'Cancel the inventory' | translate}}</button>\n <div class=\"inventory-run-confirm\" *ngIf=\"confirmingCancel === run.id\">\n <span>{{'It stops after the panorama it is on. Those analysed are kept, to resume from there.' | translate}}</span>\n <div class=\"mt-1\">\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill me-2\"\n [disabled]=\"busy === run.id\" (click)=\"onConfirmCancel(run)\">\n {{'Yes, cancel' | translate}}</button>\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill\"\n [disabled]=\"busy === run.id\" (click)=\"confirmingCancel = null\">\n {{'No, go on' | translate}}</button>\n </div>\n </div>\n </ng-container>\n </div>\n <div *ngSwitchCase=\"'cancelling'\" class=\"text-warning\">\n <ng-container *ngTemplateOutlet=\"panoramas; context: { $implicit: run }\"></ng-container>\n {{'Cancelling: it stops after the panorama it is on\u2026' | translate}}\n </div>\n <div *ngSwitchCase=\"'cancelled'\">\n <span class=\"text-warning\">{{'Cancelled' | translate}}.</span>\n <span class=\"inventory-run-detail\" *ngIf=\"run.imagesTotal\">\n {{'Panoramas analysed' | translate}}: {{ run.imagesDone ?? 0 }} / {{ run.imagesTotal }}\n </span>\n </div>\n <div *ngSwitchCase=\"'done'\" class=\"text-success\">\n <!-- How many, when the task says so: the image before inventory_job.py does not. -->\n <ng-container *ngIf=\"run.objectsFound != null; else doneOnly\">\n {{'Done' | translate}}: {{ run.objectsFound }} {{'equipment added' | translate}}.\n </ng-container>\n <ng-template #doneOnly>{{'Done' | translate}}.</ng-template>\n <span class=\"inventory-run-detail\">{{'Reload the page to see them in the list.' | translate}}</span>\n </div>\n <div *ngSwitchCase=\"'failed'\" class=\"text-danger\">\n {{ inventoryService.failure(run) | translate }}\n <span class=\"inventory-run-detail\" *ngIf=\"run.errorMessage\">{{ run.errorMessage }}</span>\n </div>\n <div *ngSwitchCase=\"'stale'\" class=\"text-warning\">\n {{'No news since' | translate}} {{ run.updatedAt | date:'short' }}:\n {{'the analysis has probably stopped.' | translate}}\n </div>\n </ng-container>\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill mt-2\"\n *ngIf=\"inventoryService.canResume(run)\" [disabled]=\"busy === run.id\" (click)=\"onResume(run)\">\n {{'Resume from where it stopped' | translate}} ({{ run.imagesDone }} / {{ run.imagesTotal }})</button>\n </div>\n <div class=\"text-danger\" *ngIf=\"message\">{{ message | translate }}</div>\n</div>\n\n<!-- Something is being done, of which there is nothing to count. -->\n<ng-template #busyBar>\n <div class=\"progress mb-1\" role=\"progressbar\" aria-label=\"\u2026\">\n <div class=\"progress-bar progress-bar-striped progress-bar-animated\" style=\"width: 100%\"></div>\n </div>\n</ng-template>\n\n<ng-template #panoramas let-run>\n <div class=\"progress\" role=\"progressbar\" [attr.aria-valuenow]=\"inventoryService.percent(run)\"\n aria-valuemin=\"0\" aria-valuemax=\"100\">\n <div class=\"progress-bar\" [style.width.%]=\"inventoryService.percent(run)\"></div>\n </div>\n <div class=\"inventory-run-detail\">\n {{'Panoramas analysed' | translate}}: {{ run.imagesDone ?? 0 }} / {{ run.imagesTotal }}\n ({{ inventoryService.percent(run) }}%)\n </div>\n</ng-template>\n", styles: [".inventory-runs{margin-top:1em}.inventory-runs h5{color:var(--smarterplan-primary)}.inventory-runs .inventory-run{background-color:#fff;border-radius:.25rem;padding:.5rem;margin-bottom:.5rem}.inventory-runs .inventory-run .inventory-run-header{display:flex;justify-content:space-between;gap:.5rem;margin-bottom:.25rem}.inventory-runs .inventory-run .inventory-run-date,.inventory-runs .inventory-run .inventory-run-detail{font-size:.8rem;color:#6c757d}.inventory-runs .inventory-run .inventory-run-detail{display:block}.inventory-runs .inventory-run .progress-bar{background-color:var(--smarterplan-primary)}.inventory-runs .inventory-run .inventory-run-confirm{margin-top:.5rem;font-size:.85rem}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i2.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i2.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "pipe", type: i2.DatePipe, name: "date" }, { kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] });
19608
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: InventoryRunsComponent, selector: "lib-inventory-runs", inputs: { spaceID: "spaceID", nodeIDs: "nodeIDs", labels: "labels" }, outputs: { runningChange: "runningChange" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"inventory-runs\" *ngIf=\"runs.length\">\n <h5>{{'Last inventory' | translate}}</h5>\n <div class=\"inventory-run\" *ngFor=\"let run of runs\">\n <div class=\"inventory-run-header\">\n <span class=\"no-lowercase\">{{ labels?.[run.nodeID] ?? run.nodeID }}</span>\n <span class=\"inventory-run-date\">{{ run.createdAt | date:'short' }}</span>\n </div>\n <!-- One that places a finished inventory's detections again: no panorama is analysed. -->\n <div class=\"inventory-run-reused\" *ngIf=\"reusedFrom(run) as source\">\n {{ 'Detections of {{date}} placed again with another cutoff: no panorama is analysed.' | translate: { date: (source.createdAt | date:'short') } }}\n <span class=\"inventory-run-detail\">\n {{ 'Cutoff {{before}} \u2192 {{now}}' | translate: { before: source.cutoffScore, now: run.cutoffScore } }}<ng-container\n *ngIf=\"source.objectsFound != null\">. {{ 'Equipment before' | translate }}: {{ source.objectsFound }}</ng-container>\n </span>\n </div>\n <ng-container [ngSwitch]=\"inventoryService.state(run)\">\n <div *ngSwitchCase=\"'waiting'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{ (reusedFrom(run) ? 'Starting the task on AWS\u2026' : 'Waiting for the analysis to start\u2026') | translate }}\n </div>\n <div *ngSwitchCase=\"'running'\">\n <ng-container [ngSwitch]=\"run.step\">\n <div *ngSwitchCase=\"'DOWNLOADING'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{ (reusedFrom(run) ? 'Taking the saved detections and the panoramas\u2026' : 'Downloading the files of the visit\u2026') | translate }}\n </div>\n <div *ngSwitchCase=\"'PLACING'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{'Placing the objects in 3D\u2026' | translate}}\n </div>\n <div *ngSwitchCase=\"'SAVING'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{'Saving the equipment\u2026' | translate}}\n </div>\n <!-- Nothing to analyse: the objects above the new cutoff are counted at once. -->\n <div *ngSwitchDefault>\n <ng-container *ngIf=\"reusedFrom(run); else analysing\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n <span *ngIf=\"run.objectsFound != null\">\n {{ 'Objects above the cutoff of {{cutoff}}' | translate: { cutoff: run.cutoffScore } }}: {{ run.objectsFound }}\n </span>\n </ng-container>\n </div>\n <ng-template #analysing>\n <ng-container *ngTemplateOutlet=\"panoramas; context: { $implicit: run }\"></ng-container>\n <span class=\"inventory-run-detail\" *ngIf=\"minutesLeft(run) as minutes\">\n {{'About' | translate}} {{ minutes }} {{'min left' | translate}}\n </span>\n <!-- Counted by the image that detects down to a floor; null from older ones. -->\n <span class=\"inventory-run-detail\" *ngIf=\"run.objectsFound != null\">\n {{ 'Objects above the cutoff of {{cutoff}} so far' | translate: { cutoff: run.cutoffScore } }}: {{ run.objectsFound }}\n </span>\n </ng-template>\n </ng-container>\n <ng-container *ngIf=\"inventoryService.canCancel(run)\">\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill mt-2\"\n *ngIf=\"confirmingCancel !== run.id\" (click)=\"confirmingCancel = run.id\">\n {{'Cancel the inventory' | translate}}</button>\n <div class=\"inventory-run-confirm\" *ngIf=\"confirmingCancel === run.id\">\n <span>{{'It stops after the panorama it is on. Those analysed are kept, to resume from there.' | translate}}</span>\n <div class=\"mt-1\">\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill me-2\"\n [disabled]=\"busy === run.id\" (click)=\"onConfirmCancel(run)\">\n {{'Yes, cancel' | translate}}</button>\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill\"\n [disabled]=\"busy === run.id\" (click)=\"confirmingCancel = null\">\n {{'No, go on' | translate}}</button>\n </div>\n </div>\n </ng-container>\n </div>\n <div *ngSwitchCase=\"'cancelling'\" class=\"text-warning\">\n <ng-container *ngTemplateOutlet=\"panoramas; context: { $implicit: run }\"></ng-container>\n {{'Cancelling: it stops after the panorama it is on\u2026' | translate}}\n </div>\n <div *ngSwitchCase=\"'cancelled'\">\n <span class=\"text-warning\">{{'Cancelled' | translate}}.</span>\n <span class=\"inventory-run-detail\" *ngIf=\"run.imagesTotal\">\n {{'Panoramas analysed' | translate}}: {{ run.imagesDone ?? 0 }} / {{ run.imagesTotal }}\n </span>\n </div>\n <div *ngSwitchCase=\"'done'\" class=\"text-success\">\n <!-- How many, when the task says so: the image before inventory_job.py does not. -->\n <ng-container *ngIf=\"run.objectsFound != null; else doneOnly\">\n {{'Done' | translate}}: {{ run.objectsFound }} {{'equipment added' | translate}}.\n </ng-container>\n <ng-template #doneOnly>{{'Done' | translate}}.</ng-template>\n <span class=\"inventory-run-detail\">{{'Reload the page to see them in the list.' | translate}}</span>\n </div>\n <div *ngSwitchCase=\"'failed'\" class=\"text-danger\">\n {{ inventoryService.failure(run) | translate }}\n <span class=\"inventory-run-detail\" *ngIf=\"run.errorMessage\">{{ run.errorMessage }}</span>\n </div>\n <div *ngSwitchCase=\"'stale'\" class=\"text-warning\">\n {{'No news since' | translate}} {{ run.updatedAt | date:'short' }}:\n {{'the analysis has probably stopped.' | translate}}\n </div>\n </ng-container>\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill mt-2\"\n *ngIf=\"inventoryService.canResume(run)\" [disabled]=\"busy === run.id\" (click)=\"onResume(run)\">\n {{'Resume from where it stopped' | translate}} ({{ run.imagesDone }} / {{ run.imagesTotal }})</button>\n </div>\n <div class=\"text-danger\" *ngIf=\"message\">{{ message | translate }}</div>\n</div>\n\n<!-- Something is being done, of which there is nothing to count. -->\n<ng-template #busyBar>\n <div class=\"progress mb-1\" role=\"progressbar\" aria-label=\"\u2026\">\n <div class=\"progress-bar progress-bar-striped progress-bar-animated\" style=\"width: 100%\"></div>\n </div>\n</ng-template>\n\n<ng-template #panoramas let-run>\n <div class=\"progress\" role=\"progressbar\" [attr.aria-valuenow]=\"inventoryService.percent(run)\"\n aria-valuemin=\"0\" aria-valuemax=\"100\">\n <div class=\"progress-bar\" [style.width.%]=\"inventoryService.percent(run)\"></div>\n </div>\n <div class=\"inventory-run-detail\">\n {{'Panoramas analysed' | translate}}: {{ run.imagesDone ?? 0 }} / {{ run.imagesTotal }}\n ({{ inventoryService.percent(run) }}%)\n </div>\n</ng-template>\n", styles: [".inventory-runs{margin-top:1em}.inventory-runs h5{color:var(--smarterplan-primary)}.inventory-runs .inventory-run{background-color:#fff;border-radius:.25rem;padding:.5rem;margin-bottom:.5rem}.inventory-runs .inventory-run .inventory-run-header{display:flex;justify-content:space-between;gap:.5rem;margin-bottom:.25rem}.inventory-runs .inventory-run .inventory-run-date,.inventory-runs .inventory-run .inventory-run-detail{font-size:.8rem;color:#6c757d}.inventory-runs .inventory-run .inventory-run-detail{display:block}.inventory-runs .inventory-run .inventory-run-reused{font-size:.85rem;margin-bottom:.25rem}.inventory-runs .inventory-run .progress-bar{background-color:var(--smarterplan-primary)}.inventory-runs .inventory-run .inventory-run-confirm{margin-top:.5rem;font-size:.85rem}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i2.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i2.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "pipe", type: i2.DatePipe, name: "date" }, { kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] });
19481
19609
  }
19482
19610
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: InventoryRunsComponent, decorators: [{
19483
19611
  type: Component,
19484
- args: [{ selector: "lib-inventory-runs", template: "<div class=\"inventory-runs\" *ngIf=\"runs.length\">\n <h5>{{'Last inventory' | translate}}</h5>\n <div class=\"inventory-run\" *ngFor=\"let run of runs\">\n <div class=\"inventory-run-header\">\n <span class=\"no-lowercase\">{{ labels?.[run.nodeID] ?? run.nodeID }}</span>\n <span class=\"inventory-run-date\">{{ run.createdAt | date:'short' }}</span>\n </div>\n <ng-container [ngSwitch]=\"inventoryService.state(run)\">\n <div *ngSwitchCase=\"'waiting'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{'Waiting for the analysis to start\u2026' | translate}}\n </div>\n <div *ngSwitchCase=\"'running'\">\n <ng-container [ngSwitch]=\"run.step\">\n <div *ngSwitchCase=\"'DOWNLOADING'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{'Downloading the files of the visit\u2026' | translate}}\n </div>\n <div *ngSwitchCase=\"'PLACING'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{'Placing the objects in 3D\u2026' | translate}}\n </div>\n <div *ngSwitchCase=\"'SAVING'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{'Saving the equipment\u2026' | translate}}\n </div>\n <div *ngSwitchDefault>\n <ng-container *ngTemplateOutlet=\"panoramas; context: { $implicit: run }\"></ng-container>\n <span class=\"inventory-run-detail\" *ngIf=\"minutesLeft(run) as minutes\">\n {{'About' | translate}} {{ minutes }} {{'min left' | translate}}\n </span>\n </div>\n </ng-container>\n <ng-container *ngIf=\"inventoryService.canCancel(run)\">\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill mt-2\"\n *ngIf=\"confirmingCancel !== run.id\" (click)=\"confirmingCancel = run.id\">\n {{'Cancel the inventory' | translate}}</button>\n <div class=\"inventory-run-confirm\" *ngIf=\"confirmingCancel === run.id\">\n <span>{{'It stops after the panorama it is on. Those analysed are kept, to resume from there.' | translate}}</span>\n <div class=\"mt-1\">\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill me-2\"\n [disabled]=\"busy === run.id\" (click)=\"onConfirmCancel(run)\">\n {{'Yes, cancel' | translate}}</button>\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill\"\n [disabled]=\"busy === run.id\" (click)=\"confirmingCancel = null\">\n {{'No, go on' | translate}}</button>\n </div>\n </div>\n </ng-container>\n </div>\n <div *ngSwitchCase=\"'cancelling'\" class=\"text-warning\">\n <ng-container *ngTemplateOutlet=\"panoramas; context: { $implicit: run }\"></ng-container>\n {{'Cancelling: it stops after the panorama it is on\u2026' | translate}}\n </div>\n <div *ngSwitchCase=\"'cancelled'\">\n <span class=\"text-warning\">{{'Cancelled' | translate}}.</span>\n <span class=\"inventory-run-detail\" *ngIf=\"run.imagesTotal\">\n {{'Panoramas analysed' | translate}}: {{ run.imagesDone ?? 0 }} / {{ run.imagesTotal }}\n </span>\n </div>\n <div *ngSwitchCase=\"'done'\" class=\"text-success\">\n <!-- How many, when the task says so: the image before inventory_job.py does not. -->\n <ng-container *ngIf=\"run.objectsFound != null; else doneOnly\">\n {{'Done' | translate}}: {{ run.objectsFound }} {{'equipment added' | translate}}.\n </ng-container>\n <ng-template #doneOnly>{{'Done' | translate}}.</ng-template>\n <span class=\"inventory-run-detail\">{{'Reload the page to see them in the list.' | translate}}</span>\n </div>\n <div *ngSwitchCase=\"'failed'\" class=\"text-danger\">\n {{ inventoryService.failure(run) | translate }}\n <span class=\"inventory-run-detail\" *ngIf=\"run.errorMessage\">{{ run.errorMessage }}</span>\n </div>\n <div *ngSwitchCase=\"'stale'\" class=\"text-warning\">\n {{'No news since' | translate}} {{ run.updatedAt | date:'short' }}:\n {{'the analysis has probably stopped.' | translate}}\n </div>\n </ng-container>\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill mt-2\"\n *ngIf=\"inventoryService.canResume(run)\" [disabled]=\"busy === run.id\" (click)=\"onResume(run)\">\n {{'Resume from where it stopped' | translate}} ({{ run.imagesDone }} / {{ run.imagesTotal }})</button>\n </div>\n <div class=\"text-danger\" *ngIf=\"message\">{{ message | translate }}</div>\n</div>\n\n<!-- Something is being done, of which there is nothing to count. -->\n<ng-template #busyBar>\n <div class=\"progress mb-1\" role=\"progressbar\" aria-label=\"\u2026\">\n <div class=\"progress-bar progress-bar-striped progress-bar-animated\" style=\"width: 100%\"></div>\n </div>\n</ng-template>\n\n<ng-template #panoramas let-run>\n <div class=\"progress\" role=\"progressbar\" [attr.aria-valuenow]=\"inventoryService.percent(run)\"\n aria-valuemin=\"0\" aria-valuemax=\"100\">\n <div class=\"progress-bar\" [style.width.%]=\"inventoryService.percent(run)\"></div>\n </div>\n <div class=\"inventory-run-detail\">\n {{'Panoramas analysed' | translate}}: {{ run.imagesDone ?? 0 }} / {{ run.imagesTotal }}\n ({{ inventoryService.percent(run) }}%)\n </div>\n</ng-template>\n", styles: [".inventory-runs{margin-top:1em}.inventory-runs h5{color:var(--smarterplan-primary)}.inventory-runs .inventory-run{background-color:#fff;border-radius:.25rem;padding:.5rem;margin-bottom:.5rem}.inventory-runs .inventory-run .inventory-run-header{display:flex;justify-content:space-between;gap:.5rem;margin-bottom:.25rem}.inventory-runs .inventory-run .inventory-run-date,.inventory-runs .inventory-run .inventory-run-detail{font-size:.8rem;color:#6c757d}.inventory-runs .inventory-run .inventory-run-detail{display:block}.inventory-runs .inventory-run .progress-bar{background-color:var(--smarterplan-primary)}.inventory-runs .inventory-run .inventory-run-confirm{margin-top:.5rem;font-size:.85rem}\n"] }]
19612
+ args: [{ selector: "lib-inventory-runs", template: "<div class=\"inventory-runs\" *ngIf=\"runs.length\">\n <h5>{{'Last inventory' | translate}}</h5>\n <div class=\"inventory-run\" *ngFor=\"let run of runs\">\n <div class=\"inventory-run-header\">\n <span class=\"no-lowercase\">{{ labels?.[run.nodeID] ?? run.nodeID }}</span>\n <span class=\"inventory-run-date\">{{ run.createdAt | date:'short' }}</span>\n </div>\n <!-- One that places a finished inventory's detections again: no panorama is analysed. -->\n <div class=\"inventory-run-reused\" *ngIf=\"reusedFrom(run) as source\">\n {{ 'Detections of {{date}} placed again with another cutoff: no panorama is analysed.' | translate: { date: (source.createdAt | date:'short') } }}\n <span class=\"inventory-run-detail\">\n {{ 'Cutoff {{before}} \u2192 {{now}}' | translate: { before: source.cutoffScore, now: run.cutoffScore } }}<ng-container\n *ngIf=\"source.objectsFound != null\">. {{ 'Equipment before' | translate }}: {{ source.objectsFound }}</ng-container>\n </span>\n </div>\n <ng-container [ngSwitch]=\"inventoryService.state(run)\">\n <div *ngSwitchCase=\"'waiting'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{ (reusedFrom(run) ? 'Starting the task on AWS\u2026' : 'Waiting for the analysis to start\u2026') | translate }}\n </div>\n <div *ngSwitchCase=\"'running'\">\n <ng-container [ngSwitch]=\"run.step\">\n <div *ngSwitchCase=\"'DOWNLOADING'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{ (reusedFrom(run) ? 'Taking the saved detections and the panoramas\u2026' : 'Downloading the files of the visit\u2026') | translate }}\n </div>\n <div *ngSwitchCase=\"'PLACING'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{'Placing the objects in 3D\u2026' | translate}}\n </div>\n <div *ngSwitchCase=\"'SAVING'\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n {{'Saving the equipment\u2026' | translate}}\n </div>\n <!-- Nothing to analyse: the objects above the new cutoff are counted at once. -->\n <div *ngSwitchDefault>\n <ng-container *ngIf=\"reusedFrom(run); else analysing\">\n <ng-container *ngTemplateOutlet=\"busyBar\"></ng-container>\n <span *ngIf=\"run.objectsFound != null\">\n {{ 'Objects above the cutoff of {{cutoff}}' | translate: { cutoff: run.cutoffScore } }}: {{ run.objectsFound }}\n </span>\n </ng-container>\n </div>\n <ng-template #analysing>\n <ng-container *ngTemplateOutlet=\"panoramas; context: { $implicit: run }\"></ng-container>\n <span class=\"inventory-run-detail\" *ngIf=\"minutesLeft(run) as minutes\">\n {{'About' | translate}} {{ minutes }} {{'min left' | translate}}\n </span>\n <!-- Counted by the image that detects down to a floor; null from older ones. -->\n <span class=\"inventory-run-detail\" *ngIf=\"run.objectsFound != null\">\n {{ 'Objects above the cutoff of {{cutoff}} so far' | translate: { cutoff: run.cutoffScore } }}: {{ run.objectsFound }}\n </span>\n </ng-template>\n </ng-container>\n <ng-container *ngIf=\"inventoryService.canCancel(run)\">\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill mt-2\"\n *ngIf=\"confirmingCancel !== run.id\" (click)=\"confirmingCancel = run.id\">\n {{'Cancel the inventory' | translate}}</button>\n <div class=\"inventory-run-confirm\" *ngIf=\"confirmingCancel === run.id\">\n <span>{{'It stops after the panorama it is on. Those analysed are kept, to resume from there.' | translate}}</span>\n <div class=\"mt-1\">\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill me-2\"\n [disabled]=\"busy === run.id\" (click)=\"onConfirmCancel(run)\">\n {{'Yes, cancel' | translate}}</button>\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill\"\n [disabled]=\"busy === run.id\" (click)=\"confirmingCancel = null\">\n {{'No, go on' | translate}}</button>\n </div>\n </div>\n </ng-container>\n </div>\n <div *ngSwitchCase=\"'cancelling'\" class=\"text-warning\">\n <ng-container *ngTemplateOutlet=\"panoramas; context: { $implicit: run }\"></ng-container>\n {{'Cancelling: it stops after the panorama it is on\u2026' | translate}}\n </div>\n <div *ngSwitchCase=\"'cancelled'\">\n <span class=\"text-warning\">{{'Cancelled' | translate}}.</span>\n <span class=\"inventory-run-detail\" *ngIf=\"run.imagesTotal\">\n {{'Panoramas analysed' | translate}}: {{ run.imagesDone ?? 0 }} / {{ run.imagesTotal }}\n </span>\n </div>\n <div *ngSwitchCase=\"'done'\" class=\"text-success\">\n <!-- How many, when the task says so: the image before inventory_job.py does not. -->\n <ng-container *ngIf=\"run.objectsFound != null; else doneOnly\">\n {{'Done' | translate}}: {{ run.objectsFound }} {{'equipment added' | translate}}.\n </ng-container>\n <ng-template #doneOnly>{{'Done' | translate}}.</ng-template>\n <span class=\"inventory-run-detail\">{{'Reload the page to see them in the list.' | translate}}</span>\n </div>\n <div *ngSwitchCase=\"'failed'\" class=\"text-danger\">\n {{ inventoryService.failure(run) | translate }}\n <span class=\"inventory-run-detail\" *ngIf=\"run.errorMessage\">{{ run.errorMessage }}</span>\n </div>\n <div *ngSwitchCase=\"'stale'\" class=\"text-warning\">\n {{'No news since' | translate}} {{ run.updatedAt | date:'short' }}:\n {{'the analysis has probably stopped.' | translate}}\n </div>\n </ng-container>\n <button type=\"button\" class=\"btn btn-sm btn-outline-primary rounded-pill mt-2\"\n *ngIf=\"inventoryService.canResume(run)\" [disabled]=\"busy === run.id\" (click)=\"onResume(run)\">\n {{'Resume from where it stopped' | translate}} ({{ run.imagesDone }} / {{ run.imagesTotal }})</button>\n </div>\n <div class=\"text-danger\" *ngIf=\"message\">{{ message | translate }}</div>\n</div>\n\n<!-- Something is being done, of which there is nothing to count. -->\n<ng-template #busyBar>\n <div class=\"progress mb-1\" role=\"progressbar\" aria-label=\"\u2026\">\n <div class=\"progress-bar progress-bar-striped progress-bar-animated\" style=\"width: 100%\"></div>\n </div>\n</ng-template>\n\n<ng-template #panoramas let-run>\n <div class=\"progress\" role=\"progressbar\" [attr.aria-valuenow]=\"inventoryService.percent(run)\"\n aria-valuemin=\"0\" aria-valuemax=\"100\">\n <div class=\"progress-bar\" [style.width.%]=\"inventoryService.percent(run)\"></div>\n </div>\n <div class=\"inventory-run-detail\">\n {{'Panoramas analysed' | translate}}: {{ run.imagesDone ?? 0 }} / {{ run.imagesTotal }}\n ({{ inventoryService.percent(run) }}%)\n </div>\n</ng-template>\n", styles: [".inventory-runs{margin-top:1em}.inventory-runs h5{color:var(--smarterplan-primary)}.inventory-runs .inventory-run{background-color:#fff;border-radius:.25rem;padding:.5rem;margin-bottom:.5rem}.inventory-runs .inventory-run .inventory-run-header{display:flex;justify-content:space-between;gap:.5rem;margin-bottom:.25rem}.inventory-runs .inventory-run .inventory-run-date,.inventory-runs .inventory-run .inventory-run-detail{font-size:.8rem;color:#6c757d}.inventory-runs .inventory-run .inventory-run-detail{display:block}.inventory-runs .inventory-run .inventory-run-reused{font-size:.85rem;margin-bottom:.25rem}.inventory-runs .inventory-run .progress-bar{background-color:var(--smarterplan-primary)}.inventory-runs .inventory-run .inventory-run-confirm{margin-top:.5rem;font-size:.85rem}\n"] }]
19485
19613
  }], ctorParameters: () => [{ type: InventoryService }], propDecorators: { spaceID: [{
19486
19614
  type: Input
19487
19615
  }], nodeIDs: [{
@@ -19492,52 +19620,110 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
19492
19620
  type: Output
19493
19621
  }] } });
19494
19622
 
19623
+ const INVENTORY_MESH_FILE = {
19624
+ name: "model.obj",
19625
+ field: "modelObj",
19626
+ accept: ".obj",
19627
+ extension: /\.obj$/i,
19628
+ type: "text/plain",
19629
+ send: "Send the .obj",
19630
+ wrongFile: "Choose the .obj file of the MatterPak.",
19631
+ };
19632
+ const INVENTORY_POSITIONS_FILE = {
19633
+ name: "data.json",
19634
+ field: "dataJson",
19635
+ accept: ".json",
19636
+ extension: /\.json$/i,
19637
+ type: "application/json",
19638
+ send: "Send the .json",
19639
+ wrongFile: "Choose a .json file.",
19640
+ };
19495
19641
  /**
19496
19642
  * What a visit has of what its AI inventory needs (InventoryService.checkFiles), and where what is
19497
- * missing comes from, for the screens to show before launching one. The mesh, which nothing else
19498
- * puts in the bucket, can be sent from here: the .obj of the visit's MatterPak, as it is.
19643
+ * missing comes from, for the screens to show before launching one. The mesh and the panoramas'
19644
+ * positions can be sent, replaced or deleted from here; the panoramas come from the visit's import.
19499
19645
  */
19500
19646
  class InventoryFilesComponent {
19501
19647
  files;
19502
- /** Said when the visit gets a file from here: [(files)]. */
19648
+ /** Said when a file of the visit is sent, replaced or deleted from here: [(files)]. */
19503
19649
  filesChange = new EventEmitter();
19504
19650
  /** The visit's Matterport model, the folder of its files. */
19505
19651
  model3D;
19506
- /** How much of the .obj is sent, from 0 to 100, while it is. */
19652
+ /** While an inventory runs or is launched: it reads these files, which must not change. */
19653
+ disabled = false;
19654
+ meshFile = INVENTORY_MESH_FILE;
19655
+ positionsFile = INVENTORY_POSITIONS_FILE;
19656
+ /** The file being sent. */
19657
+ sending = null;
19658
+ /** How much of it is sent, from 0 to 100. */
19507
19659
  uploadPercent = null;
19508
19660
  uploadName = null;
19509
- /** Why the .obj was not sent, as a key to translate. */
19510
- uploadError = null;
19511
- async onModelObjSelected(event) {
19661
+ /** The file whose deletion is waiting to be confirmed. */
19662
+ confirmingDelete = null;
19663
+ deletingFile = null;
19664
+ /** What went wrong, as a key to translate, and with which file. */
19665
+ error = null;
19666
+ errorFile = null;
19667
+ /** Whether the files cannot be changed for now. */
19668
+ get locked() {
19669
+ return this.disabled || !!this.sending || !!this.deletingFile;
19670
+ }
19671
+ fail(file, error) {
19672
+ this.errorFile = file;
19673
+ this.error = error;
19674
+ }
19675
+ async onFileSelected(target, event) {
19512
19676
  const input = event.target;
19513
19677
  const file = input.files?.[0];
19514
19678
  input.value = "";
19515
- if (!file) {
19679
+ // An inventory may have started while the file dialog was open.
19680
+ if (!file || this.locked) {
19516
19681
  return;
19517
19682
  }
19518
- if (!/\.obj$/i.test(file.name)) {
19519
- this.uploadError = "Choose the .obj file of the MatterPak.";
19683
+ if (!target.extension.test(file.name)) {
19684
+ this.fail(target, target.wrongFile);
19520
19685
  return;
19521
19686
  }
19522
- this.uploadError = null;
19687
+ this.fail(null, null);
19688
+ this.sending = target;
19523
19689
  this.uploadName = file.name;
19524
19690
  this.uploadPercent = 0;
19525
19691
  try {
19526
- // Where the inventory's task looks for it, whatever the file was called.
19527
- await uploadFileToS3WithProgress(`visits/${this.model3D}/inventory/`, new File([file], "model.obj", { type: "text/plain" }), (fraction) => (this.uploadPercent = Math.round(fraction * 100)));
19528
- this.files = { ...this.files, modelObj: true };
19692
+ await uploadFileToS3WithProgress(`visits/${this.model3D}/inventory/`, new File([file], target.name, { type: target.type }), (fraction) => (this.uploadPercent = Math.round(fraction * 100)));
19693
+ this.files = { ...this.files, [target.field]: true };
19529
19694
  this.filesChange.emit(this.files);
19530
19695
  }
19531
19696
  catch (error) {
19532
- console.error("model.obj not sent", error);
19533
- this.uploadError = "The file could not be sent.";
19697
+ console.error(`${target.name} not sent`, error);
19698
+ this.fail(target, "The file could not be sent.");
19534
19699
  }
19535
19700
  finally {
19701
+ this.sending = null;
19536
19702
  this.uploadPercent = null;
19537
19703
  }
19538
19704
  }
19705
+ async onDeleteConfirmed(target) {
19706
+ if (this.locked) {
19707
+ return;
19708
+ }
19709
+ this.fail(null, null);
19710
+ this.deletingFile = target;
19711
+ try {
19712
+ await removeInventoryFile(this.model3D, `visits/${this.model3D}/inventory/${target.name}`, `${target.name} deleted from the inventory files panel`);
19713
+ this.files = { ...this.files, [target.field]: false };
19714
+ this.filesChange.emit(this.files);
19715
+ }
19716
+ catch (error) {
19717
+ console.error(`${target.name} not deleted`, error);
19718
+ this.fail(target, "The file could not be deleted.");
19719
+ }
19720
+ finally {
19721
+ this.deletingFile = null;
19722
+ this.confirmingDelete = null;
19723
+ }
19724
+ }
19539
19725
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: InventoryFilesComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
19540
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: InventoryFilesComponent, selector: "lib-inventory-files", inputs: { files: "files", model3D: "model3D" }, outputs: { filesChange: "filesChange" }, ngImport: i0, template: `
19726
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: InventoryFilesComponent, selector: "lib-inventory-files", inputs: { files: "files", model3D: "model3D", disabled: "disabled" }, outputs: { filesChange: "filesChange" }, ngImport: i0, template: `
19541
19727
  <ul class="inventory-files" *ngIf="files; else unknown">
19542
19728
  <li [class.missing]="!files.panoramas">
19543
19729
  {{ files.panoramas ? "✓" : "✗" }} {{ "Panoramas" | translate }}: {{ files.panoramas }}
@@ -19546,29 +19732,42 @@ class InventoryFilesComponent {
19546
19732
  <li [class.missing]="!files.dataJson">
19547
19733
  {{ files.dataJson ? "✓" : "✗" }} {{ "Panorama positions" | translate }} (data.json)
19548
19734
  <span class="hint" *ngIf="!files.dataJson">{{ "Import all the images of the visit again (Virtual Visits): the import writes it." | translate }}</span>
19735
+ <ng-container *ngTemplateOutlet="actions; context: { $implicit: positionsFile }"></ng-container>
19549
19736
  </li>
19550
19737
  <li [class.missing]="!files.modelObj">
19551
19738
  {{ files.modelObj ? "✓" : "✗" }} {{ "3D mesh" | translate }} (model.obj)
19552
- <span class="hint" *ngIf="!files.modelObj">
19553
- {{ "The .obj of the visit's MatterPak, from Matterport. Its textures are not needed." | translate }}
19554
- <label class="btn btn-sm btn-outline-primary rounded-pill upload" *ngIf="uploadPercent === null">
19555
- <input type="file" accept=".obj" (change)="onModelObjSelected($event)">
19556
- {{ "Send the .obj" | translate }}
19557
- </label>
19558
- <span *ngIf="uploadPercent !== null" class="sending">
19559
- <span class="progress" role="progressbar" [attr.aria-valuenow]="uploadPercent" aria-valuemin="0" aria-valuemax="100">
19560
- <span class="progress-bar" [style.width.%]="uploadPercent"></span>
19561
- </span>
19562
- {{ "Sending" | translate }} {{ uploadName }} — {{ uploadPercent }}%
19563
- </span>
19564
- <span class="error" *ngIf="uploadError">{{ uploadError | translate }}</span>
19565
- </span>
19739
+ <span class="hint" *ngIf="!files.modelObj">{{ "The .obj of the visit's MatterPak, from Matterport. Its textures are not needed." | translate }}</span>
19740
+ <ng-container *ngTemplateOutlet="actions; context: { $implicit: meshFile }"></ng-container>
19566
19741
  </li>
19567
19742
  </ul>
19743
+ <ng-template #actions let-file>
19744
+ <span class="file-actions" *ngIf="sending !== file && confirmingDelete !== file">
19745
+ <label class="btn btn-sm btn-outline-primary rounded-pill upload" [class.disabled]="locked">
19746
+ <input type="file" [accept]="file.accept" [disabled]="locked" (change)="onFileSelected(file, $event)">
19747
+ {{ (files[file.field] ? "Replace" : file.send) | translate }}
19748
+ </label>
19749
+ <button type="button" class="btn btn-sm btn-outline-danger rounded-pill delete" *ngIf="files[file.field]"
19750
+ [disabled]="locked" (click)="confirmingDelete = file">{{ "Delete" | translate }}</button>
19751
+ </span>
19752
+ <span class="file-actions" *ngIf="confirmingDelete === file">
19753
+ <span>{{ "Delete this file?" | translate }}</span>
19754
+ <button type="button" class="btn btn-sm btn-danger rounded-pill confirm" [disabled]="locked"
19755
+ (click)="onDeleteConfirmed(file)">{{ "Yes, delete" | translate }}</button>
19756
+ <button type="button" class="btn btn-sm btn-outline-secondary rounded-pill" [disabled]="deletingFile === file"
19757
+ (click)="confirmingDelete = null">{{ "No" | translate }}</button>
19758
+ </span>
19759
+ <span *ngIf="sending === file" class="sending">
19760
+ <span class="progress" role="progressbar" [attr.aria-valuenow]="uploadPercent" aria-valuemin="0" aria-valuemax="100">
19761
+ <span class="progress-bar" [style.width.%]="uploadPercent"></span>
19762
+ </span>
19763
+ {{ "Sending" | translate }} {{ uploadName }}: {{ uploadPercent }}%
19764
+ </span>
19765
+ <span class="error" *ngIf="errorFile === file">{{ error | translate }}</span>
19766
+ </ng-template>
19568
19767
  <ng-template #unknown>
19569
19768
  <p class="hint">{{ "The files of the visit could not be checked." | translate }}</p>
19570
19769
  </ng-template>
19571
- `, isInline: true, styles: [".inventory-files{list-style:none;padding-left:0;margin-bottom:.5rem}.missing{color:var(--bs-danger, #dc3545)}.hint{display:block;font-size:.8rem;color:#6c757d;margin-left:1.2rem}.upload{margin-top:.25rem}.upload input{display:none}.sending{display:block;margin-top:.25rem}.progress{display:flex;height:6px;margin-bottom:.25rem}.progress-bar{transition:none;background-color:var(--smarterplan-primary)}.error{display:block;color:var(--bs-danger, #dc3545)}\n"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] });
19770
+ `, isInline: true, styles: [".inventory-files{list-style:none;padding-left:0;margin-bottom:.5rem}.missing{color:var(--bs-danger, #dc3545)}.hint{display:block;font-size:.8rem;color:#6c757d;margin-left:1.2rem}.file-actions{display:flex;flex-wrap:wrap;align-items:center;gap:.25rem;margin:.25rem 0 0 1.2rem;font-size:.8rem}.upload{margin-bottom:0}.upload input{display:none}.sending{display:block;margin:.25rem 0 0 1.2rem;font-size:.8rem;color:#6c757d}.progress{display:flex;height:6px;margin-bottom:.25rem}.progress-bar{transition:none;background-color:var(--smarterplan-primary)}.error{display:block;margin-left:1.2rem;font-size:.8rem;color:var(--bs-danger, #dc3545)}\n"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] });
19572
19771
  }
19573
19772
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: InventoryFilesComponent, decorators: [{
19574
19773
  type: Component,
@@ -19581,35 +19780,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
19581
19780
  <li [class.missing]="!files.dataJson">
19582
19781
  {{ files.dataJson ? "✓" : "✗" }} {{ "Panorama positions" | translate }} (data.json)
19583
19782
  <span class="hint" *ngIf="!files.dataJson">{{ "Import all the images of the visit again (Virtual Visits): the import writes it." | translate }}</span>
19783
+ <ng-container *ngTemplateOutlet="actions; context: { $implicit: positionsFile }"></ng-container>
19584
19784
  </li>
19585
19785
  <li [class.missing]="!files.modelObj">
19586
19786
  {{ files.modelObj ? "✓" : "✗" }} {{ "3D mesh" | translate }} (model.obj)
19587
- <span class="hint" *ngIf="!files.modelObj">
19588
- {{ "The .obj of the visit's MatterPak, from Matterport. Its textures are not needed." | translate }}
19589
- <label class="btn btn-sm btn-outline-primary rounded-pill upload" *ngIf="uploadPercent === null">
19590
- <input type="file" accept=".obj" (change)="onModelObjSelected($event)">
19591
- {{ "Send the .obj" | translate }}
19592
- </label>
19593
- <span *ngIf="uploadPercent !== null" class="sending">
19594
- <span class="progress" role="progressbar" [attr.aria-valuenow]="uploadPercent" aria-valuemin="0" aria-valuemax="100">
19595
- <span class="progress-bar" [style.width.%]="uploadPercent"></span>
19596
- </span>
19597
- {{ "Sending" | translate }} {{ uploadName }} — {{ uploadPercent }}%
19598
- </span>
19599
- <span class="error" *ngIf="uploadError">{{ uploadError | translate }}</span>
19600
- </span>
19787
+ <span class="hint" *ngIf="!files.modelObj">{{ "The .obj of the visit's MatterPak, from Matterport. Its textures are not needed." | translate }}</span>
19788
+ <ng-container *ngTemplateOutlet="actions; context: { $implicit: meshFile }"></ng-container>
19601
19789
  </li>
19602
19790
  </ul>
19791
+ <ng-template #actions let-file>
19792
+ <span class="file-actions" *ngIf="sending !== file && confirmingDelete !== file">
19793
+ <label class="btn btn-sm btn-outline-primary rounded-pill upload" [class.disabled]="locked">
19794
+ <input type="file" [accept]="file.accept" [disabled]="locked" (change)="onFileSelected(file, $event)">
19795
+ {{ (files[file.field] ? "Replace" : file.send) | translate }}
19796
+ </label>
19797
+ <button type="button" class="btn btn-sm btn-outline-danger rounded-pill delete" *ngIf="files[file.field]"
19798
+ [disabled]="locked" (click)="confirmingDelete = file">{{ "Delete" | translate }}</button>
19799
+ </span>
19800
+ <span class="file-actions" *ngIf="confirmingDelete === file">
19801
+ <span>{{ "Delete this file?" | translate }}</span>
19802
+ <button type="button" class="btn btn-sm btn-danger rounded-pill confirm" [disabled]="locked"
19803
+ (click)="onDeleteConfirmed(file)">{{ "Yes, delete" | translate }}</button>
19804
+ <button type="button" class="btn btn-sm btn-outline-secondary rounded-pill" [disabled]="deletingFile === file"
19805
+ (click)="confirmingDelete = null">{{ "No" | translate }}</button>
19806
+ </span>
19807
+ <span *ngIf="sending === file" class="sending">
19808
+ <span class="progress" role="progressbar" [attr.aria-valuenow]="uploadPercent" aria-valuemin="0" aria-valuemax="100">
19809
+ <span class="progress-bar" [style.width.%]="uploadPercent"></span>
19810
+ </span>
19811
+ {{ "Sending" | translate }} {{ uploadName }}: {{ uploadPercent }}%
19812
+ </span>
19813
+ <span class="error" *ngIf="errorFile === file">{{ error | translate }}</span>
19814
+ </ng-template>
19603
19815
  <ng-template #unknown>
19604
19816
  <p class="hint">{{ "The files of the visit could not be checked." | translate }}</p>
19605
19817
  </ng-template>
19606
- `, styles: [".inventory-files{list-style:none;padding-left:0;margin-bottom:.5rem}.missing{color:var(--bs-danger, #dc3545)}.hint{display:block;font-size:.8rem;color:#6c757d;margin-left:1.2rem}.upload{margin-top:.25rem}.upload input{display:none}.sending{display:block;margin-top:.25rem}.progress{display:flex;height:6px;margin-bottom:.25rem}.progress-bar{transition:none;background-color:var(--smarterplan-primary)}.error{display:block;color:var(--bs-danger, #dc3545)}\n"] }]
19818
+ `, styles: [".inventory-files{list-style:none;padding-left:0;margin-bottom:.5rem}.missing{color:var(--bs-danger, #dc3545)}.hint{display:block;font-size:.8rem;color:#6c757d;margin-left:1.2rem}.file-actions{display:flex;flex-wrap:wrap;align-items:center;gap:.25rem;margin:.25rem 0 0 1.2rem;font-size:.8rem}.upload{margin-bottom:0}.upload input{display:none}.sending{display:block;margin:.25rem 0 0 1.2rem;font-size:.8rem;color:#6c757d}.progress{display:flex;height:6px;margin-bottom:.25rem}.progress-bar{transition:none;background-color:var(--smarterplan-primary)}.error{display:block;margin-left:1.2rem;font-size:.8rem;color:var(--bs-danger, #dc3545)}\n"] }]
19607
19819
  }], propDecorators: { files: [{
19608
19820
  type: Input
19609
19821
  }], filesChange: [{
19610
19822
  type: Output
19611
19823
  }], model3D: [{
19612
19824
  type: Input
19825
+ }], disabled: [{
19826
+ type: Input
19613
19827
  }] } });
19614
19828
 
19615
19829
  /**
@@ -19642,6 +19856,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
19642
19856
  type: Output
19643
19857
  }] } });
19644
19858
 
19859
+ /**
19860
+ * How many equipment of the previous inventory are deleted at a time. All at once, hundreds of them
19861
+ * at three or more requests each, the API refused part of them and the launch stopped half way; a
19862
+ * request it refuses for coming too fast is now sent again (EquipmentService.deleteEquipment).
19863
+ */
19864
+ const INVENTORY_DELETE_AT_ONCE = 15;
19865
+ /** Where the panel keeps the model and the cutoff score last launched with, in the browser. */
19866
+ const LAST_SETTINGS_KEY = "inventory-launch.last-settings";
19645
19867
  /**
19646
19868
  * Launches an AI inventory, of the visits given or of one panorama of the visit, saying first what
19647
19869
  * it will do: what each visit has of what the inventory needs, and how many equipment the AI added
@@ -19651,6 +19873,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
19651
19873
  class InventoryLaunchComponent {
19652
19874
  inventoryService;
19653
19875
  equipmentService;
19876
+ navigationService;
19654
19877
  spaceID;
19655
19878
  visits = [];
19656
19879
  /** Only this panorama of the visit, as it is named: 110ee452_sweep.jpeg. */
@@ -19668,26 +19891,195 @@ class InventoryLaunchComponent {
19668
19891
  deletePrevious = false;
19669
19892
  /** How many of the location's equipment the AI added, which deletePrevious deletes. */
19670
19893
  aiEquipmentCount = null;
19894
+ /** While the previous inventory is deleted: how many of its equipment are done, of how many. */
19895
+ deleting = null;
19896
+ /** How many equipment of the previous inventory could not be deleted, for the message. */
19897
+ notDeleted = 0;
19898
+ /** Each visit's latest inventory when it is done and all its detections are still kept. */
19899
+ reusable = {};
19900
+ /**
19901
+ * The visits with detections kept that nothing is waiting for: their latest inventory is done.
19902
+ * A stopped one needs them to resume.
19903
+ */
19904
+ discardable = [];
19905
+ confirmingDiscard = false;
19906
+ discarding = false;
19907
+ /** Whether the saved detections were just discarded, for the panel to say so. */
19908
+ discarded = false;
19909
+ /** The latest reading of the kept detections: an older one answering late is ignored. */
19910
+ keptCheck = 0;
19911
+ /** The latest count of the previous inventory, for the same reason. */
19912
+ countCheck = 0;
19913
+ /**
19914
+ * Whether the launch places the latest inventories' detections again, with the cutoff chosen,
19915
+ * instead of analysing the panoramas: minutes instead of hours.
19916
+ */
19917
+ reuseDetections = false;
19671
19918
  /** What each visit has of what the inventory needs, by its node; null when the bucket could not be read. */
19672
19919
  visitFiles = {};
19673
19920
  checkingFiles = false;
19674
19921
  launching = false;
19675
19922
  /** What went wrong, or why nothing was launched, as a key to translate. */
19676
19923
  message = null;
19677
- constructor(inventoryService, equipmentService) {
19924
+ constructor(inventoryService, equipmentService, navigationService) {
19678
19925
  this.inventoryService = inventoryService;
19679
19926
  this.equipmentService = equipmentService;
19927
+ this.navigationService = navigationService;
19680
19928
  }
19681
19929
  async ngOnInit() {
19930
+ const last = this.lastSettings();
19931
+ if (last?.cutoffScore && this.cutoffScores.includes(last.cutoffScore)) {
19932
+ this.cutoffScore = last.cutoffScore;
19933
+ }
19682
19934
  this.models = await this.inventoryService.getModels();
19683
- if (!this.model && this.models.length === 1) {
19684
- this.model = this.models[0];
19935
+ if (!this.model) {
19936
+ // The one launched with last, from either screen, while it is still offered.
19937
+ this.model = this.models.find((model) => model.id === last?.modelID)
19938
+ ?? (this.models.length === 1 ? this.models[0] : undefined);
19939
+ }
19940
+ }
19941
+ /** The model and the cutoff score last launched with, from either screen; null when unknown. */
19942
+ lastSettings() {
19943
+ try {
19944
+ return JSON.parse(localStorage.getItem(LAST_SETTINGS_KEY)) ?? null;
19945
+ }
19946
+ catch {
19947
+ return null;
19948
+ }
19949
+ }
19950
+ keepSettings() {
19951
+ try {
19952
+ localStorage.setItem(LAST_SETTINGS_KEY,
19953
+ // Reusing, none may be selected: the detections keep their own.
19954
+ JSON.stringify({ modelID: this.model?.id, cutoffScore: this.cutoffScore }));
19955
+ }
19956
+ catch {
19957
+ // Storage blocked or full: the next launch starts from the defaults.
19685
19958
  }
19686
19959
  }
19687
19960
  ngOnChanges(changes) {
19688
19961
  if (changes.visits) {
19689
19962
  this.checkFiles();
19690
19963
  }
19964
+ if (changes.visits || changes.spaceID || changes.panorama || changes.running) {
19965
+ this.findReusable();
19966
+ }
19967
+ }
19968
+ /** Whether the inventory's detections of all its panoramas are among those kept. */
19969
+ keptAll(run, kept) {
19970
+ return run.imagesTotal > 0 && (kept?.[run.id] ?? 0) >= run.imagesTotal;
19971
+ }
19972
+ /** What the bucket has of the visits' detections, for their latest inventories that are done. */
19973
+ async readKept() {
19974
+ const reusable = {};
19975
+ const discardable = [];
19976
+ // One panorama is analysed in a minute or two: nothing to gain.
19977
+ if (!this.spaceID || this.panorama) {
19978
+ return { reusable, discardable };
19979
+ }
19980
+ const latest = this.inventoryService.latestOfEachVisit(await this.inventoryService.getRuns(this.spaceID));
19981
+ const done = new Map(latest
19982
+ .filter((run) => this.inventoryService.state(run) === "done")
19983
+ .map((run) => [run.nodeID, run]));
19984
+ const visits = (this.visits ?? []).filter((visit) => done.has(visit.nodeID));
19985
+ const kept = await Promise.all(visits.map((visit) => this.inventoryService.keptDetections(visit.model3D)));
19986
+ visits.forEach((visit, index) => {
19987
+ if (Object.keys(kept[index] ?? {}).length === 0) {
19988
+ return;
19989
+ }
19990
+ discardable.push(visit);
19991
+ const run = done.get(visit.nodeID);
19992
+ if (this.keptAll(run, kept[index])) {
19993
+ reusable[visit.nodeID] = run;
19994
+ }
19995
+ });
19996
+ return { reusable, discardable };
19997
+ }
19998
+ async findReusable() {
19999
+ const check = ++this.keptCheck;
20000
+ let found = {
20001
+ reusable: {},
20002
+ discardable: [],
20003
+ };
20004
+ try {
20005
+ found = await this.readKept();
20006
+ }
20007
+ catch (error) {
20008
+ console.warn("Inventories not read", error);
20009
+ }
20010
+ if (check !== this.keptCheck) {
20011
+ return;
20012
+ }
20013
+ this.reusable = found.reusable;
20014
+ this.discardable = found.discardable;
20015
+ if (this.discardable.length === 0) {
20016
+ this.confirmingDiscard = false;
20017
+ }
20018
+ if (!this.canReuse) {
20019
+ this.reuseDetections = false;
20020
+ }
20021
+ }
20022
+ /**
20023
+ * Every visit to analyse has a finished inventory of all its panoramas, with all its detections
20024
+ * kept: placing them again takes minutes, and analyses nothing. They are placed again under one
20025
+ * model, so all must come from the same.
20026
+ */
20027
+ get canReuse() {
20028
+ const visits = this.launchableVisits;
20029
+ const model = this.reusable[visits[0]?.nodeID]?.MLInventoryModelID;
20030
+ return visits.length > 0 && visits.every((visit) => {
20031
+ const run = this.reusable[visit.nodeID];
20032
+ return !!run && run.imagesTotal === this.visitFiles[visit.nodeID]?.panoramas
20033
+ && run.MLInventoryModelID === model;
20034
+ });
20035
+ }
20036
+ /** The model of the detections placed again: the one the launch uses when it reuses them. */
20037
+ get reusedModelName() {
20038
+ return this.reusable[this.launchableVisits[0]?.nodeID]?.MLInventoryModelName ?? "";
20039
+ }
20040
+ onFilesChange(visit, files) {
20041
+ this.visitFiles[visit.nodeID] = files;
20042
+ if (!this.canReuse) {
20043
+ this.reuseDetections = false;
20044
+ }
20045
+ if (this.deletePrevious) {
20046
+ // A visit gained or lost a file: what gets deleted depends on the visits analysed.
20047
+ this.countPrevious();
20048
+ }
20049
+ }
20050
+ /** Deletes the detections kept for the visits whose inventory is done. The equipment stays. */
20051
+ async onConfirmDiscard() {
20052
+ this.discarding = true;
20053
+ this.message = null;
20054
+ this.discarded = false;
20055
+ try {
20056
+ // Read again: an inventory launched since, from here or elsewhere, may need them.
20057
+ const { discardable } = await this.readKept();
20058
+ const failed = await Promise.all(discardable.map((visit) => this.inventoryService.discardDetections(visit.model3D)));
20059
+ this.notDeleted = failed.reduce((total, count) => total + count, 0);
20060
+ if (this.notDeleted > 0) {
20061
+ this.message = "{{count}} saved detections could not be discarded: try again.";
20062
+ }
20063
+ else {
20064
+ this.discarded = discardable.length > 0;
20065
+ }
20066
+ }
20067
+ catch (error) {
20068
+ console.error("Detections not discarded", error);
20069
+ this.message = "The saved detections could not be discarded.";
20070
+ }
20071
+ finally {
20072
+ this.discarding = false;
20073
+ this.confirmingDiscard = false;
20074
+ await this.findReusable();
20075
+ }
20076
+ }
20077
+ onReuseChange(reuse) {
20078
+ this.reuseDetections = reuse;
20079
+ if (reuse && !this.deletePrevious) {
20080
+ // Placed again beside those placed before, every object would be there twice.
20081
+ this.onDeletePreviousChange(true);
20082
+ }
19691
20083
  }
19692
20084
  async checkFiles() {
19693
20085
  const visits = this.visits ?? [];
@@ -19697,6 +20089,9 @@ class InventoryLaunchComponent {
19697
20089
  // Other visits may have come meanwhile, checked by their own call.
19698
20090
  if (visits === this.visits) {
19699
20091
  this.visitFiles = Object.fromEntries(visits.map((visit, index) => [visit.nodeID, files[index]]));
20092
+ if (this.deletePrevious) {
20093
+ this.countPrevious();
20094
+ }
19700
20095
  }
19701
20096
  }
19702
20097
  finally {
@@ -19713,35 +20108,129 @@ class InventoryLaunchComponent {
19713
20108
  });
19714
20109
  }
19715
20110
  get canLaunch() {
19716
- return !!this.model && !this.running && !this.launching && !this.checkingFiles
19717
- && this.launchableVisits.length > 0;
20111
+ // Reusing, the model is the one of the detections, whatever is selected.
20112
+ return (!!this.model || (this.reuseDetections && this.canReuse))
20113
+ && !this.running && !this.launching && !this.discarding
20114
+ && !this.checkingFiles && this.launchableVisits.length > 0;
19718
20115
  }
19719
20116
  async onDeletePreviousChange(deletePrevious) {
20117
+ if (!deletePrevious && this.reuseDetections) {
20118
+ // Placed again beside those placed before, every object would be there twice.
20119
+ return;
20120
+ }
19720
20121
  this.deletePrevious = deletePrevious;
19721
- if (deletePrevious && this.aiEquipmentCount === null) {
19722
- this.aiEquipmentCount = (await this.aiEquipments()).length;
20122
+ if (deletePrevious) {
20123
+ await this.countPrevious();
20124
+ }
20125
+ }
20126
+ /** Counts what the launch would delete: it depends on the visits analysed. */
20127
+ async countPrevious() {
20128
+ const check = ++this.countCheck;
20129
+ this.aiEquipmentCount = null;
20130
+ let count = null;
20131
+ try {
20132
+ count = (await this.aiEquipments()).length;
20133
+ }
20134
+ catch (error) {
20135
+ console.warn("Previous inventory not counted", error);
20136
+ }
20137
+ if (check === this.countCheck) {
20138
+ this.aiEquipmentCount = count;
19723
20139
  }
19724
20140
  }
20141
+ /**
20142
+ * The equipment the AI added to the visits analysed, known by the panoramas their tags are at:
20143
+ * a visit left out, for a missing file, keeps its own. One whose tag has no panorama cannot be
20144
+ * told apart, and is deleted only when every visit is analysed again.
20145
+ */
19725
20146
  async aiEquipments() {
19726
- const equipments = await this.equipmentService.getEquipmentsForSpace(this.spaceID);
19727
- return equipments.filter((equip) => equip.isCreatedByAI);
20147
+ const visits = this.launchableVisits;
20148
+ const everyVisit = visits.length === (this.visits ?? []).length;
20149
+ const [equipments, navigations] = await Promise.all([
20150
+ this.equipmentService.getEquipmentsForSpace(this.spaceID),
20151
+ Promise.all(visits.map((visit) => this.navigationService.getNavigationsForNode(visit.nodeID))),
20152
+ ]);
20153
+ const sweeps = new Set(navigations.flat().map((navigation) => navigation?.matterportSweepID).filter((sweep) => !!sweep));
20154
+ return equipments.filter((equip) => {
20155
+ if (!equip.isCreatedByAI) {
20156
+ return false;
20157
+ }
20158
+ const placedAt = (equip.pois?.items ?? [])
20159
+ .map((poi) => poi?.matterportSweepID)
20160
+ .filter((sweep) => !!sweep);
20161
+ return placedAt.length === 0 ? everyVisit : placedAt.some((sweep) => sweeps.has(sweep));
20162
+ });
20163
+ }
20164
+ /**
20165
+ * Deletes the equipment a few at a time, going on past one that fails (its error logged), and
20166
+ * says how many could not be deleted.
20167
+ */
20168
+ async deleteFewAtATime(equipments) {
20169
+ let failed = 0;
20170
+ this.deleting = { done: 0, total: equipments.length };
20171
+ try {
20172
+ for (let start = 0; start < equipments.length; start += INVENTORY_DELETE_AT_ONCE) {
20173
+ const batch = equipments.slice(start, start + INVENTORY_DELETE_AT_ONCE);
20174
+ const results = await Promise.allSettled(
20175
+ // Just loaded: an operation-less equipment's operations are not looked for again.
20176
+ batch.map((equip) => this.equipmentService.deleteEquipment(equip, true)));
20177
+ results.forEach((result, i) => {
20178
+ if (result.status === "rejected") {
20179
+ failed += 1;
20180
+ console.error("Equipment not deleted", batch[i].id, result.reason);
20181
+ }
20182
+ });
20183
+ this.deleting.done += batch.length;
20184
+ }
20185
+ }
20186
+ finally {
20187
+ this.deleting = null;
20188
+ }
20189
+ return failed;
19728
20190
  }
19729
20191
  async onLaunchClick() {
19730
20192
  this.launching = true;
19731
20193
  this.message = null;
20194
+ this.discarded = false;
19732
20195
  try {
19733
- if (this.deletePrevious) {
19734
- const previous = await this.aiEquipments();
19735
- await Promise.all(previous.map((equip) => this.equipmentService.deleteEquipment(equip)));
20196
+ const visits = this.launchableVisits;
20197
+ const reuse = this.reuseDetections && this.canReuse;
20198
+ const reusedRuns = reuse ? visits.map((visit) => this.reusable[visit.nodeID]) : [];
20199
+ if (reuse) {
20200
+ // Checked before deleting anything: without them, the previous equipment would be
20201
+ // gone and every panorama analysed again, for hours.
20202
+ const kept = await Promise.all(visits.map((visit) => this.inventoryService.keptDetections(visit.model3D)));
20203
+ if (!reusedRuns.every((run, index) => this.keptAll(run, kept[index]))) {
20204
+ this.message = "The saved detections are no longer available.";
20205
+ this.reuseDetections = false;
20206
+ this.findReusable();
20207
+ return;
20208
+ }
20209
+ }
20210
+ // Reusing always deletes them: placed again beside them, every object would be there twice.
20211
+ if (this.deletePrevious || reuse) {
20212
+ this.notDeleted = await this.deleteFewAtATime(await this.aiEquipments());
19736
20213
  this.aiEquipmentCount = null;
20214
+ if (this.notDeleted > 0) {
20215
+ // Launched anyway, the new equipment would sit beside what is left of the old.
20216
+ this.message = "{{count}} equipment of the previous inventory could not be deleted: launch again to retry.";
20217
+ return;
20218
+ }
19737
20219
  }
19738
- const launched = await this.inventoryService.launch(this.spaceID, this.launchableVisits.map((visit) => visit.nodeID), this.model, Number(this.cutoffScore),
20220
+ // Placed again, the detections keep the model that made them.
20221
+ const reused = reusedRuns[0];
20222
+ const launched = await this.inventoryService.launch(this.spaceID, visits.map((visit) => visit.nodeID), reused
20223
+ ? { id: reused.MLInventoryModelID, name: reused.MLInventoryModelName }
20224
+ : this.model, Number(this.cutoffScore),
19739
20225
  // Panoramas are named after their sweep's first 8 characters.
19740
- this.panorama ? this.panorama.split("_")[0] : undefined);
20226
+ this.panorama ? this.panorama.split("_")[0] : undefined, Object.fromEntries(reusedRuns.map((run) => [run.nodeID, run.id])));
19741
20227
  if (launched === "ALREADY_RUNNING") {
19742
20228
  this.message = "An inventory is already running for this location.";
19743
20229
  return;
19744
20230
  }
20231
+ this.reuseDetections = false;
20232
+ this.findReusable();
20233
+ this.keepSettings();
19745
20234
  this.launched.emit();
19746
20235
  }
19747
20236
  catch (error) {
@@ -19752,13 +20241,13 @@ class InventoryLaunchComponent {
19752
20241
  this.launching = false;
19753
20242
  }
19754
20243
  }
19755
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: InventoryLaunchComponent, deps: [{ token: InventoryService }, { token: EquipmentService }], target: i0.ɵɵFactoryTarget.Component });
19756
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: InventoryLaunchComponent, selector: "lib-inventory-launch", inputs: { spaceID: "spaceID", visits: "visits", panorama: "panorama", running: "running" }, outputs: { cancelled: "cancelled", launched: "launched" }, usesOnChanges: true, ngImport: i0, template: "<!-- What the inventory will do, before it is done: it adds equipment to the location. -->\n<p *ngIf=\"panorama\">{{ 'The AI will look for equipment in this panorama and add what it finds to the location.' | translate }}</p>\n<p *ngIf=\"!panorama\">{{ 'The AI will look for equipment in the visits of this location and add what it finds to it.' | translate }}</p>\n\n<ul class=\"inventory-launch-summary\" *ngIf=\"panorama\">\n <li>{{ 'Visit' | translate }}: <strong class=\"no-lowercase\">{{ visits?.[0]?.label }}</strong></li>\n <li>{{ 'Panorama' | translate }}: <strong class=\"no-lowercase\">{{ panorama }}</strong></li>\n</ul>\n<ul class=\"inventory-launch-summary\" *ngIf=\"!panorama && visits?.length > 0\">\n <li>{{ 'Visits to analyse' | translate }}:\n <strong>{{ checkingFiles ? '\u2026' : launchableVisits.length + ' / ' + visits.length }}</strong></li>\n</ul>\n<p class=\"text-danger\" *ngIf=\"visits?.length === 0\">\n {{ 'This location has no Matterport visit for the AI to analyse.' | translate }}</p>\n\n<lib-loader *ngIf=\"checkingFiles\"></lib-loader>\n<ng-container *ngIf=\"!checkingFiles\">\n <div *ngFor=\"let visit of visits\">\n <strong class=\"no-lowercase\" *ngIf=\"!panorama\">{{ visit.label }}</strong>\n <lib-inventory-files [(files)]=\"visitFiles[visit.nodeID]\" [model3D]=\"visit.model3D\"></lib-inventory-files>\n </div>\n</ng-container>\n\n<div class=\"inventory-launch-delete\">\n <lib-checkbox-slider label=\"Delete previous inventory ?\" [checked]=\"deletePrevious\" [disabled]=\"launching\"\n (checkedChange)=\"onDeletePreviousChange($event)\"></lib-checkbox-slider>\n <span class=\"inventory-launch-hint\" *ngIf=\"deletePrevious\">\n {{ 'Equipment added by the AI before, deleted first' | translate }}: <strong>{{ aiEquipmentCount ?? '\u2026' }}</strong>\n </span>\n</div>\n\n<div class=\"inventory-launch-settings\">\n <select class=\"no-lowercase form-select\" [(ngModel)]=\"model\">\n <option [ngValue]=\"undefined\">{{ 'Select model' | translate }}</option>\n <option *ngFor=\"let option of models\" [ngValue]=\"option\">{{ option.name | translate }}</option>\n </select>\n <select class=\"form-select\" [(ngModel)]=\"cutoffScore\" [title]=\"'Cutoff score' | translate\">\n <option *ngFor=\"let score of cutoffScores\" [ngValue]=\"score\">{{ 'Cutoff score' | translate }} {{ score }}</option>\n </select>\n</div>\n\n<div class=\"inventory-launch-buttons\">\n <button type=\"button\" class=\"btn btn-outline-secondary rounded-pill\" [disabled]=\"launching\"\n (click)=\"cancelled.emit()\">{{ 'Cancel' | translate }}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" [disabled]=\"!canLaunch\"\n [title]=\"running ? ('An inventory is already running for this location.' | translate) : ''\"\n (click)=\"onLaunchClick()\">{{ 'Launch inventory' | translate }}</button>\n</div>\n\n<div class=\"text-danger mt-2\" *ngIf=\"message\">{{ message | translate }}</div>\n", styles: [":host{display:block}.inventory-launch-summary{padding-left:1.2rem;margin-bottom:.5rem}.inventory-launch-delete{margin:.75rem 0}.inventory-launch-hint{display:block;margin-top:.25rem;font-size:.8rem;color:#6c757d}.inventory-launch-settings{display:flex;flex-wrap:wrap;gap:.5rem}.inventory-launch-settings select{flex:1 1 10rem}.inventory-launch-buttons{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.75rem}\n"], dependencies: [{ kind: "directive", type: i3.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: LoaderComponent, selector: "lib-loader", inputs: ["useLogo", "color"] }, { kind: "component", type: InventoryFilesComponent, selector: "lib-inventory-files", inputs: ["files", "model3D"], outputs: ["filesChange"] }, { kind: "component", type: CheckboxSliderComponent, selector: "lib-checkbox-slider", inputs: ["label", "checked", "disabled"], outputs: ["checkedChange"] }, { kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] });
20244
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: InventoryLaunchComponent, deps: [{ token: InventoryService }, { token: EquipmentService }, { token: NavigationService }], target: i0.ɵɵFactoryTarget.Component });
20245
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: InventoryLaunchComponent, selector: "lib-inventory-launch", inputs: { spaceID: "spaceID", visits: "visits", panorama: "panorama", running: "running" }, outputs: { cancelled: "cancelled", launched: "launched" }, usesOnChanges: true, ngImport: i0, template: "<!-- What the inventory will do, before it is done: it adds equipment to the location. -->\n<p *ngIf=\"panorama\">{{ 'The AI will look for equipment in this panorama and add what it finds to the location.' | translate }}</p>\n<p *ngIf=\"!panorama\">{{ 'The AI will look for equipment in the visits of this location and add what it finds to it.' | translate }}</p>\n\n<ul class=\"inventory-launch-summary\" *ngIf=\"panorama\">\n <li>{{ 'Visit' | translate }}: <strong class=\"no-lowercase\">{{ visits?.[0]?.label }}</strong></li>\n <li>{{ 'Panorama' | translate }}: <strong class=\"no-lowercase\">{{ panorama }}</strong></li>\n</ul>\n<ul class=\"inventory-launch-summary\" *ngIf=\"!panorama && visits?.length > 0\">\n <li>{{ 'Visits to analyse' | translate }}:\n <strong>{{ checkingFiles ? '\u2026' : launchableVisits.length + ' / ' + visits.length }}</strong></li>\n</ul>\n<p class=\"text-danger\" *ngIf=\"visits?.length === 0\">\n {{ 'This location has no Matterport visit for the AI to analyse.' | translate }}</p>\n\n<lib-loader *ngIf=\"checkingFiles\"></lib-loader>\n<ng-container *ngIf=\"!checkingFiles\">\n <div *ngFor=\"let visit of visits\">\n <strong class=\"no-lowercase\" *ngIf=\"!panorama\">{{ visit.label }}</strong>\n <lib-inventory-files [files]=\"visitFiles[visit.nodeID]\" (filesChange)=\"onFilesChange(visit, $event)\"\n [model3D]=\"visit.model3D\" [disabled]=\"running || launching || discarding\"></lib-inventory-files>\n </div>\n</ng-container>\n\n<div class=\"inventory-launch-delete\">\n <lib-checkbox-slider label=\"Delete previous inventory ?\" [checked]=\"deletePrevious\"\n [disabled]=\"launching || reuseDetections\" (checkedChange)=\"onDeletePreviousChange($event)\"></lib-checkbox-slider>\n <span class=\"inventory-launch-hint\" *ngIf=\"deletePrevious\">\n {{ 'Equipment the AI added to these visits, deleted first' | translate }}: <strong>{{ aiEquipmentCount ?? '\u2026' }}</strong>\n </span>\n <span class=\"inventory-launch-hint\" *ngIf=\"reuseDetections\">\n {{ 'Needed to reuse the detections, or every object would be there twice.' | translate }}\n </span>\n <span class=\"inventory-launch-hint\" *ngIf=\"deleting\">\n {{ 'Deleting the previous inventory' | translate }}: {{ deleting.done }} / {{ deleting.total }}\n </span>\n</div>\n\n<!-- The last inventories' detections placed again with another cutoff: no panorama analysed again. -->\n<div class=\"inventory-launch-delete\" *ngIf=\"canReuse\">\n <lib-checkbox-slider label=\"Reuse the detections of the last inventory\" [checked]=\"reuseDetections\"\n [disabled]=\"launching\" (checkedChange)=\"onReuseChange($event)\"></lib-checkbox-slider>\n <span class=\"inventory-launch-hint\" *ngIf=\"reuseDetections\">\n {{ 'Only the placing is done again, with the cutoff chosen: a few minutes.' | translate }}\n </span>\n</div>\n\n<!-- Once the cutoff is chosen, the detections kept to change it can go. -->\n<div class=\"inventory-launch-delete\" *ngIf=\"discardable.length > 0 || discarded\">\n <ng-container *ngIf=\"discardable.length > 0 && !confirmingDiscard\">\n <button type=\"button\" class=\"btn btn-sm btn-outline-danger rounded-pill inventory-launch-discard\"\n [disabled]=\"running || launching\" (click)=\"confirmingDiscard = true\">\n {{ 'Discard the saved detections' | translate }}</button>\n <span class=\"inventory-launch-hint\">\n {{ 'Once the cutoff is chosen, this frees the space they take. The equipment stays.' | translate }}\n </span>\n </ng-container>\n <ng-container *ngIf=\"discardable.length > 0 && confirmingDiscard\">\n <span class=\"inventory-launch-hint\">\n {{ 'The equipment stays. To change the cutoff later, the panoramas will have to be analysed again.' | translate }}\n </span>\n <div class=\"inventory-launch-confirm\">\n <button type=\"button\" class=\"btn btn-sm btn-danger rounded-pill\" [disabled]=\"running || launching || discarding\"\n (click)=\"onConfirmDiscard()\">{{ (discarding ? 'Discarding\u2026' : 'Yes, discard') | translate }}</button>\n <button type=\"button\" class=\"btn btn-sm btn-outline-secondary rounded-pill\" [disabled]=\"discarding\"\n (click)=\"confirmingDiscard = false\">{{ 'No, keep them' | translate }}</button>\n </div>\n </ng-container>\n <span class=\"inventory-launch-hint\" *ngIf=\"discarded\">{{ 'The saved detections were discarded.' | translate }}</span>\n</div>\n\n<div class=\"inventory-launch-settings\">\n <select class=\"no-lowercase form-select\" [(ngModel)]=\"model\" *ngIf=\"!reuseDetections\">\n <option [ngValue]=\"undefined\">{{ 'Select model' | translate }}</option>\n <option *ngFor=\"let option of models\" [ngValue]=\"option\">{{ option.name | translate }}</option>\n </select>\n <!-- Reusing, the detections keep the model that made them. -->\n <select class=\"no-lowercase form-select inventory-launch-reused-model\" *ngIf=\"reuseDetections\" disabled\n [title]=\"'The detections keep the model that made them.' | translate\">\n <option>{{ reusedModelName | translate }}</option>\n </select>\n <select class=\"form-select\" [(ngModel)]=\"cutoffScore\" [title]=\"'Cutoff score' | translate\">\n <option *ngFor=\"let score of cutoffScores\" [ngValue]=\"score\">{{ 'Cutoff score' | translate }} {{ score }}</option>\n </select>\n</div>\n\n<div class=\"inventory-launch-buttons\">\n <!-- Closes the panel only: \"Cancel the inventory\", below, is what stops one. -->\n <button type=\"button\" class=\"btn btn-outline-secondary rounded-pill inventory-launch-close\" [disabled]=\"launching\"\n (click)=\"cancelled.emit()\">{{ 'Close' | translate }}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill inventory-launch-go\" [disabled]=\"!canLaunch\"\n [title]=\"running ? ('An inventory is already running for this location.' | translate) : ''\"\n (click)=\"onLaunchClick()\">{{ (reuseDetections && canReuse ? 'Update' : 'Launch inventory') | translate }}</button>\n</div>\n\n<div class=\"text-danger mt-2\" *ngIf=\"message\">{{ message | translate: { count: notDeleted } }}</div>\n", styles: [":host{display:block}.inventory-launch-summary{padding-left:1.2rem;margin-bottom:.5rem}.inventory-launch-delete{margin:.75rem 0}.inventory-launch-hint{display:block;margin-top:.25rem;font-size:.8rem;color:#6c757d}.inventory-launch-confirm{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.25rem}.inventory-launch-settings{display:flex;flex-wrap:wrap;gap:.5rem}.inventory-launch-settings select{flex:1 1 10rem}.inventory-launch-buttons{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.75rem}\n"], dependencies: [{ kind: "directive", type: i3.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: LoaderComponent, selector: "lib-loader", inputs: ["useLogo", "color"] }, { kind: "component", type: InventoryFilesComponent, selector: "lib-inventory-files", inputs: ["files", "model3D", "disabled"], outputs: ["filesChange"] }, { kind: "component", type: CheckboxSliderComponent, selector: "lib-checkbox-slider", inputs: ["label", "checked", "disabled"], outputs: ["checkedChange"] }, { kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] });
19757
20246
  }
19758
20247
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: InventoryLaunchComponent, decorators: [{
19759
20248
  type: Component,
19760
- args: [{ selector: "lib-inventory-launch", template: "<!-- What the inventory will do, before it is done: it adds equipment to the location. -->\n<p *ngIf=\"panorama\">{{ 'The AI will look for equipment in this panorama and add what it finds to the location.' | translate }}</p>\n<p *ngIf=\"!panorama\">{{ 'The AI will look for equipment in the visits of this location and add what it finds to it.' | translate }}</p>\n\n<ul class=\"inventory-launch-summary\" *ngIf=\"panorama\">\n <li>{{ 'Visit' | translate }}: <strong class=\"no-lowercase\">{{ visits?.[0]?.label }}</strong></li>\n <li>{{ 'Panorama' | translate }}: <strong class=\"no-lowercase\">{{ panorama }}</strong></li>\n</ul>\n<ul class=\"inventory-launch-summary\" *ngIf=\"!panorama && visits?.length > 0\">\n <li>{{ 'Visits to analyse' | translate }}:\n <strong>{{ checkingFiles ? '\u2026' : launchableVisits.length + ' / ' + visits.length }}</strong></li>\n</ul>\n<p class=\"text-danger\" *ngIf=\"visits?.length === 0\">\n {{ 'This location has no Matterport visit for the AI to analyse.' | translate }}</p>\n\n<lib-loader *ngIf=\"checkingFiles\"></lib-loader>\n<ng-container *ngIf=\"!checkingFiles\">\n <div *ngFor=\"let visit of visits\">\n <strong class=\"no-lowercase\" *ngIf=\"!panorama\">{{ visit.label }}</strong>\n <lib-inventory-files [(files)]=\"visitFiles[visit.nodeID]\" [model3D]=\"visit.model3D\"></lib-inventory-files>\n </div>\n</ng-container>\n\n<div class=\"inventory-launch-delete\">\n <lib-checkbox-slider label=\"Delete previous inventory ?\" [checked]=\"deletePrevious\" [disabled]=\"launching\"\n (checkedChange)=\"onDeletePreviousChange($event)\"></lib-checkbox-slider>\n <span class=\"inventory-launch-hint\" *ngIf=\"deletePrevious\">\n {{ 'Equipment added by the AI before, deleted first' | translate }}: <strong>{{ aiEquipmentCount ?? '\u2026' }}</strong>\n </span>\n</div>\n\n<div class=\"inventory-launch-settings\">\n <select class=\"no-lowercase form-select\" [(ngModel)]=\"model\">\n <option [ngValue]=\"undefined\">{{ 'Select model' | translate }}</option>\n <option *ngFor=\"let option of models\" [ngValue]=\"option\">{{ option.name | translate }}</option>\n </select>\n <select class=\"form-select\" [(ngModel)]=\"cutoffScore\" [title]=\"'Cutoff score' | translate\">\n <option *ngFor=\"let score of cutoffScores\" [ngValue]=\"score\">{{ 'Cutoff score' | translate }} {{ score }}</option>\n </select>\n</div>\n\n<div class=\"inventory-launch-buttons\">\n <button type=\"button\" class=\"btn btn-outline-secondary rounded-pill\" [disabled]=\"launching\"\n (click)=\"cancelled.emit()\">{{ 'Cancel' | translate }}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill\" [disabled]=\"!canLaunch\"\n [title]=\"running ? ('An inventory is already running for this location.' | translate) : ''\"\n (click)=\"onLaunchClick()\">{{ 'Launch inventory' | translate }}</button>\n</div>\n\n<div class=\"text-danger mt-2\" *ngIf=\"message\">{{ message | translate }}</div>\n", styles: [":host{display:block}.inventory-launch-summary{padding-left:1.2rem;margin-bottom:.5rem}.inventory-launch-delete{margin:.75rem 0}.inventory-launch-hint{display:block;margin-top:.25rem;font-size:.8rem;color:#6c757d}.inventory-launch-settings{display:flex;flex-wrap:wrap;gap:.5rem}.inventory-launch-settings select{flex:1 1 10rem}.inventory-launch-buttons{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.75rem}\n"] }]
19761
- }], ctorParameters: () => [{ type: InventoryService }, { type: EquipmentService }], propDecorators: { spaceID: [{
20249
+ args: [{ selector: "lib-inventory-launch", template: "<!-- What the inventory will do, before it is done: it adds equipment to the location. -->\n<p *ngIf=\"panorama\">{{ 'The AI will look for equipment in this panorama and add what it finds to the location.' | translate }}</p>\n<p *ngIf=\"!panorama\">{{ 'The AI will look for equipment in the visits of this location and add what it finds to it.' | translate }}</p>\n\n<ul class=\"inventory-launch-summary\" *ngIf=\"panorama\">\n <li>{{ 'Visit' | translate }}: <strong class=\"no-lowercase\">{{ visits?.[0]?.label }}</strong></li>\n <li>{{ 'Panorama' | translate }}: <strong class=\"no-lowercase\">{{ panorama }}</strong></li>\n</ul>\n<ul class=\"inventory-launch-summary\" *ngIf=\"!panorama && visits?.length > 0\">\n <li>{{ 'Visits to analyse' | translate }}:\n <strong>{{ checkingFiles ? '\u2026' : launchableVisits.length + ' / ' + visits.length }}</strong></li>\n</ul>\n<p class=\"text-danger\" *ngIf=\"visits?.length === 0\">\n {{ 'This location has no Matterport visit for the AI to analyse.' | translate }}</p>\n\n<lib-loader *ngIf=\"checkingFiles\"></lib-loader>\n<ng-container *ngIf=\"!checkingFiles\">\n <div *ngFor=\"let visit of visits\">\n <strong class=\"no-lowercase\" *ngIf=\"!panorama\">{{ visit.label }}</strong>\n <lib-inventory-files [files]=\"visitFiles[visit.nodeID]\" (filesChange)=\"onFilesChange(visit, $event)\"\n [model3D]=\"visit.model3D\" [disabled]=\"running || launching || discarding\"></lib-inventory-files>\n </div>\n</ng-container>\n\n<div class=\"inventory-launch-delete\">\n <lib-checkbox-slider label=\"Delete previous inventory ?\" [checked]=\"deletePrevious\"\n [disabled]=\"launching || reuseDetections\" (checkedChange)=\"onDeletePreviousChange($event)\"></lib-checkbox-slider>\n <span class=\"inventory-launch-hint\" *ngIf=\"deletePrevious\">\n {{ 'Equipment the AI added to these visits, deleted first' | translate }}: <strong>{{ aiEquipmentCount ?? '\u2026' }}</strong>\n </span>\n <span class=\"inventory-launch-hint\" *ngIf=\"reuseDetections\">\n {{ 'Needed to reuse the detections, or every object would be there twice.' | translate }}\n </span>\n <span class=\"inventory-launch-hint\" *ngIf=\"deleting\">\n {{ 'Deleting the previous inventory' | translate }}: {{ deleting.done }} / {{ deleting.total }}\n </span>\n</div>\n\n<!-- The last inventories' detections placed again with another cutoff: no panorama analysed again. -->\n<div class=\"inventory-launch-delete\" *ngIf=\"canReuse\">\n <lib-checkbox-slider label=\"Reuse the detections of the last inventory\" [checked]=\"reuseDetections\"\n [disabled]=\"launching\" (checkedChange)=\"onReuseChange($event)\"></lib-checkbox-slider>\n <span class=\"inventory-launch-hint\" *ngIf=\"reuseDetections\">\n {{ 'Only the placing is done again, with the cutoff chosen: a few minutes.' | translate }}\n </span>\n</div>\n\n<!-- Once the cutoff is chosen, the detections kept to change it can go. -->\n<div class=\"inventory-launch-delete\" *ngIf=\"discardable.length > 0 || discarded\">\n <ng-container *ngIf=\"discardable.length > 0 && !confirmingDiscard\">\n <button type=\"button\" class=\"btn btn-sm btn-outline-danger rounded-pill inventory-launch-discard\"\n [disabled]=\"running || launching\" (click)=\"confirmingDiscard = true\">\n {{ 'Discard the saved detections' | translate }}</button>\n <span class=\"inventory-launch-hint\">\n {{ 'Once the cutoff is chosen, this frees the space they take. The equipment stays.' | translate }}\n </span>\n </ng-container>\n <ng-container *ngIf=\"discardable.length > 0 && confirmingDiscard\">\n <span class=\"inventory-launch-hint\">\n {{ 'The equipment stays. To change the cutoff later, the panoramas will have to be analysed again.' | translate }}\n </span>\n <div class=\"inventory-launch-confirm\">\n <button type=\"button\" class=\"btn btn-sm btn-danger rounded-pill\" [disabled]=\"running || launching || discarding\"\n (click)=\"onConfirmDiscard()\">{{ (discarding ? 'Discarding\u2026' : 'Yes, discard') | translate }}</button>\n <button type=\"button\" class=\"btn btn-sm btn-outline-secondary rounded-pill\" [disabled]=\"discarding\"\n (click)=\"confirmingDiscard = false\">{{ 'No, keep them' | translate }}</button>\n </div>\n </ng-container>\n <span class=\"inventory-launch-hint\" *ngIf=\"discarded\">{{ 'The saved detections were discarded.' | translate }}</span>\n</div>\n\n<div class=\"inventory-launch-settings\">\n <select class=\"no-lowercase form-select\" [(ngModel)]=\"model\" *ngIf=\"!reuseDetections\">\n <option [ngValue]=\"undefined\">{{ 'Select model' | translate }}</option>\n <option *ngFor=\"let option of models\" [ngValue]=\"option\">{{ option.name | translate }}</option>\n </select>\n <!-- Reusing, the detections keep the model that made them. -->\n <select class=\"no-lowercase form-select inventory-launch-reused-model\" *ngIf=\"reuseDetections\" disabled\n [title]=\"'The detections keep the model that made them.' | translate\">\n <option>{{ reusedModelName | translate }}</option>\n </select>\n <select class=\"form-select\" [(ngModel)]=\"cutoffScore\" [title]=\"'Cutoff score' | translate\">\n <option *ngFor=\"let score of cutoffScores\" [ngValue]=\"score\">{{ 'Cutoff score' | translate }} {{ score }}</option>\n </select>\n</div>\n\n<div class=\"inventory-launch-buttons\">\n <!-- Closes the panel only: \"Cancel the inventory\", below, is what stops one. -->\n <button type=\"button\" class=\"btn btn-outline-secondary rounded-pill inventory-launch-close\" [disabled]=\"launching\"\n (click)=\"cancelled.emit()\">{{ 'Close' | translate }}</button>\n <button type=\"button\" class=\"btn btn-outline-primary rounded-pill inventory-launch-go\" [disabled]=\"!canLaunch\"\n [title]=\"running ? ('An inventory is already running for this location.' | translate) : ''\"\n (click)=\"onLaunchClick()\">{{ (reuseDetections && canReuse ? 'Update' : 'Launch inventory') | translate }}</button>\n</div>\n\n<div class=\"text-danger mt-2\" *ngIf=\"message\">{{ message | translate: { count: notDeleted } }}</div>\n", styles: [":host{display:block}.inventory-launch-summary{padding-left:1.2rem;margin-bottom:.5rem}.inventory-launch-delete{margin:.75rem 0}.inventory-launch-hint{display:block;margin-top:.25rem;font-size:.8rem;color:#6c757d}.inventory-launch-confirm{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.25rem}.inventory-launch-settings{display:flex;flex-wrap:wrap;gap:.5rem}.inventory-launch-settings select{flex:1 1 10rem}.inventory-launch-buttons{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.75rem}\n"] }]
20250
+ }], ctorParameters: () => [{ type: InventoryService }, { type: EquipmentService }, { type: NavigationService }], propDecorators: { spaceID: [{
19762
20251
  type: Input
19763
20252
  }], visits: [{
19764
20253
  type: Input
@@ -24308,5 +24797,5 @@ function floatValidator() {
24308
24797
  * Generated bundle index. Do not edit.
24309
24798
  */
24310
24799
 
24311
- export { AffectationService, AvatarComponent, BaseLateralTabService, BaseTagService, BaseUserService, BaseVisibilityService, CameraMode, CaptureService, CaptureViewer, CheckboxSliderComponent, CommentService, CommentType, Config, ContentService, CsvExportComponent, DomainService, DomainType, DurationToStringPipe, EmailStatus, EquipmentService, EventService, EventStatus, EventType, FeatureService, FeatureType, FilterService, GAUSSIAN_SPLAT_PLY_SUFFIX, HashtagFromIdPipe, HashtagService, INVENTORY_CUTOFF_SCORES, INVENTORY_DEFAULT_CUTOFF, INVENTORY_STALE_AFTER_MS, InterventionService, InventoryFilesComponent, InventoryLaunchComponent, InventoryRunsComponent, InventoryService, InventoryStatus, LayerService, LevelStatus, LoaderComponent, Locale, LocaleService, MATTERPORT_SDK_KEY, MatterportImportService, MatterportService, MatterportTagCopyService, MatterportViewType, MattertagActionMode, MattertagData, MeasurementService, MenuBarComponent, MissionService, NavigationService, NavigatorService, NgxSmarterplanCoreModule, NgxSmarterplanCoreService, NodeService, Object3DService, OperationService, OrganisationService, PLAN_ICONS, PaymentStatus, PlanService, PoiService, PoiType, ProfileEntity, ProfileService, ProfileStatus, PropertyService, PropertyType, RoleStatus, SafeUrlPipe, SearchBarComponent, SearchObjectType, SearchService, SpModule, SpaceService, SpaceStatus, SplatViewerComponent, StatusEquipment, SupportModalComponent, SupportService, SweepLocatorService, THREEJS_MODEL_UP_OPTIONS, TagAction, TemplateService, ThreeJsImportService, ThreeJsService, TicketPriority, TicketStatus, TicketType, TicketsService, TimeDateToLocalStringPipe, TypeNote, UsernameFromIdPipe, VIEWER_BACKGROUND, ValidatorsService, ViewerInteractions, ViewerService, VisitService, ZoneChangeService, ZoneService, applyRigidTransformToDirection, applyRigidTransformToPoint, applyRigidTransformToYRotationDeg, arraysContainSameElements, checkElementById, computeRigidTransform, convertObjToGlb, convertTimestampToLocalZone, copyFileInS3, copyFileInS3ViaDownload, dateHasExpired, dateTimeToLocalString, deleteFromS3, distance, downloadBlob, downloadEquipmentDocument, downloadFile, downloadFileAsObject, durationToString, emailValidator, enumToArray, filterUniqueArrayByID, floatValidator, getBufferForFileFromS3, getCoefficientsForImage, getCurrentLang, getDistanceBetweenTwoPoints, getHighestLevelForMissions, getHighestRoleForMissions, getLevelsBelow, getLocaleLong, getLocaleShort, getMetaForImage, getRolesBelowForManager, getSignedFile, getSignedImageUrlForEquipment, getSignedImageUrlForProfile, getSignedImageUrlForSpace, getSpaceIDFromUrl, getThreeJsPoiOrigin, getVisitUrl, hasObjModel, iconData, iconToDataUrl, isEmptyObject, isGaussianSplatFile, isGaussianSplatPly, isStreamedSplatFile, listFilesInFolder, mean, noEmptyValidator, numberToDateString, openDocument, openModalForVisitSwitch, parseThreeJsPlacement, poiTypeToString, pointToString, readObj, removeAllFilesFromFolderS3, removeNullKeysFromObject, showScanPointsOnPlanInDiv, shuffleArray, solveThreeJsAlignment, sortAlphabeticallyOnName, stringLocaleToEnum, stringToLowercaseNoSpaces, styleButton, svgToDataUrl, textValidator, translateDatePeriod, uploadBase64Image, uploadBase64ImageWithRetry, uploadFileToS3, uploadFileToS3WithProgress, uploadJsonToS3, validEmail, wait, waitUntil };
24800
+ export { AffectationService, AvatarComponent, BaseLateralTabService, BaseTagService, BaseUserService, BaseVisibilityService, CameraMode, CaptureService, CaptureViewer, CheckboxSliderComponent, CommentService, CommentType, Config, ContentService, CsvExportComponent, DomainService, DomainType, DurationToStringPipe, EmailStatus, EquipmentService, EventService, EventStatus, EventType, FeatureService, FeatureType, FilterService, GAUSSIAN_SPLAT_PLY_SUFFIX, HashtagFromIdPipe, HashtagService, INVENTORY_CUTOFF_SCORES, INVENTORY_DEFAULT_CUTOFF, INVENTORY_DELETE_AT_ONCE, INVENTORY_MESH_FILE, INVENTORY_POSITIONS_FILE, INVENTORY_STALE_AFTER_MS, InterventionService, InventoryFilesComponent, InventoryLaunchComponent, InventoryRunsComponent, InventoryService, InventoryStatus, LayerService, LevelStatus, LoaderComponent, Locale, LocaleService, MATTERPORT_SDK_KEY, MatterportImportService, MatterportService, MatterportTagCopyService, MatterportViewType, MattertagActionMode, MattertagData, MeasurementService, MenuBarComponent, MissionService, NavigationService, NavigatorService, NgxSmarterplanCoreModule, NgxSmarterplanCoreService, NodeService, Object3DService, OperationService, OrganisationService, PLAN_ICONS, PaymentStatus, PlanService, PoiService, PoiType, ProfileEntity, ProfileService, ProfileStatus, PropertyService, PropertyType, RoleStatus, SafeUrlPipe, SearchBarComponent, SearchObjectType, SearchService, SpModule, SpaceService, SpaceStatus, SplatViewerComponent, StatusEquipment, SupportModalComponent, SupportService, SweepLocatorService, THREEJS_MODEL_UP_OPTIONS, TagAction, TemplateService, ThreeJsImportService, ThreeJsService, TicketPriority, TicketStatus, TicketType, TicketsService, TimeDateToLocalStringPipe, TypeNote, UsernameFromIdPipe, VIEWER_BACKGROUND, ValidatorsService, ViewerInteractions, ViewerService, VisitService, ZoneChangeService, ZoneService, applyRigidTransformToDirection, applyRigidTransformToPoint, applyRigidTransformToYRotationDeg, arraysContainSameElements, checkElementById, computeRigidTransform, convertObjToGlb, convertTimestampToLocalZone, copyFileInS3, copyFileInS3ViaDownload, dateHasExpired, dateTimeToLocalString, deleteFromS3, distance, downloadBlob, downloadEquipmentDocument, downloadFile, downloadFileAsObject, durationToString, emailValidator, enumToArray, filterUniqueArrayByID, floatValidator, getBufferForFileFromS3, getCoefficientsForImage, getCurrentLang, getDistanceBetweenTwoPoints, getHighestLevelForMissions, getHighestRoleForMissions, getLevelsBelow, getLocaleLong, getLocaleShort, getMetaForImage, getRolesBelowForManager, getSignedFile, getSignedImageUrlForEquipment, getSignedImageUrlForProfile, getSignedImageUrlForSpace, getSpaceIDFromUrl, getThreeJsPoiOrigin, getVisitUrl, hasObjModel, iconData, iconToDataUrl, isEmptyObject, isGaussianSplatFile, isGaussianSplatPly, isStreamedSplatFile, listFilesInFolder, mean, noEmptyValidator, numberToDateString, openDocument, openModalForVisitSwitch, parseThreeJsPlacement, poiTypeToString, pointToString, readObj, removeAllFilesFromFolderS3, removeNullKeysFromObject, showScanPointsOnPlanInDiv, shuffleArray, solveThreeJsAlignment, sortAlphabeticallyOnName, stringLocaleToEnum, stringToLowercaseNoSpaces, styleButton, svgToDataUrl, textValidator, translateDatePeriod, uploadBase64Image, uploadBase64ImageWithRetry, uploadFileToS3, uploadFileToS3WithProgress, uploadJsonToS3, validEmail, wait, waitUntil };
24312
24801
  //# sourceMappingURL=smarterplan-ngx-smarterplan-core.mjs.map