@sinequa/atomic-angular 1.0.0 → 1.0.4

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.
@@ -7,7 +7,7 @@ import highlightWords from 'highlight-words';
7
7
  import { ActivatedRoute, Router, NavigationEnd, RouterLink, RouterModule } from '@angular/router';
8
8
  import { withDevtools } from '@angular-architects/ngrx-toolkit';
9
9
  import { signalStore, signalStoreFeature, withState, withMethods, patchState, getState, withComputed } from '@ngrx/signals';
10
- import { globalConfig, EngineType, extraColumns, sysLang, getQueryParamsFromUrl, logout, login, info, warn, error, setGlobalConfig, notify, addConcepts, queryParamsFromUrl, patchUserSettings, deleteUserSettings, fetchUserSettings, buildPathsAndLevels, escapeExpr, isAuthenticated, isExpired, debug, fetchSuggest, isObject, Audit, getMetadata, bisect, isNotInputEvent, fetchSponsoredLinks, fetchQuery, translateAggregationToDateOptions, aggItemRegex, parseValueAndOperatorFromItem, fetchSuggestField, fetchSimilarDocuments, fetchChangePassword, fetchSendPasswordResetEmail, expiresSoon, suggestionsToTreeAggregationNodes, labels, fetchLabels, guid, getRelativeDate, createUserProfile, deleteUserProfileProperty, patchUserProfile, isJsonable, addAuditAdditionalInfo, getToken, setToken, createHeaders } from '@sinequa/atomic';
10
+ import { globalConfig, EngineType, extraColumns, sysLang, getQueryParamsFromUrl, clearSessionTokens, login, info, warn, error, setGlobalConfig, notify, addConcepts, queryParamsFromUrl, patchUserSettings, deleteUserSettings, fetchUserSettings, buildPathsAndLevels, escapeExpr, isAuthenticated, isExpired, debug, AuditEventType, fetchSuggest, isObject, Audit, getMetadata, bisect, isNotInputEvent, fetchSponsoredLinks, fetchQuery, translateAggregationToDateOptions, aggItemRegex, parseValueAndOperatorFromItem, fetchSuggestField, fetchSimilarDocuments, logout, fetchChangePassword, fetchSendPasswordResetEmail, expiresSoon, suggestionsToTreeAggregationNodes, labels, fetchLabels, guid, getRelativeDate, createUserProfile, deleteUserProfileProperty, patchUserProfile, isJsonable, addAuditAdditionalInfo, getToken, setToken, createHeaders } from '@sinequa/atomic';
11
11
  import { HttpClient, HttpParams, httpResource, HttpResponse, HttpHeaders, HttpContextToken } from '@angular/common/http';
12
12
  import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
13
13
  import { DatePipe, DATE_PIPE_DEFAULT_TIMEZONE, DATE_PIPE_DEFAULT_OPTIONS, Location, NgTemplateOutlet, NgStyle, NgClass, NgComponentOutlet } from '@angular/common';
@@ -1556,8 +1556,8 @@ async function signIn() {
1556
1556
  const router = inject(Router);
1557
1557
  const lastUrlAfterNavigation = inject(NavigationService).urlAfterNavigation;
1558
1558
  const { useCredentials, loginPath, useSSO } = globalConfig;
1559
- // Always log out first to clear any existing session
1560
- await logout();
1559
+ // Always clear authentication tokens first to clear any existing session
1560
+ clearSessionTokens();
1561
1561
  // If credentials are used and user override is not active, redirect to the login page
1562
1562
  if (useCredentials) {
1563
1563
  router.navigate([loginPath], { queryParams: { returnUrl: lastUrlAfterNavigation } });
@@ -3745,6 +3745,8 @@ class AuditService {
3745
3745
  * @param auditEvents The audit events
3746
3746
  */
3747
3747
  notify(auditEvents) {
3748
+ if (!isAuthenticated())
3749
+ return; // Don't send audit events if the user is not authenticated
3748
3750
  this.http
3749
3751
  .post(this.API_URL + '/audit.notify', {
3750
3752
  event: 'None', // AuditEventType.None,
@@ -3819,7 +3821,7 @@ class AuditService {
3819
3821
  // Second event triggered when we come back
3820
3822
  document.addEventListener('visibilitychange', () => {
3821
3823
  if (document.visibilityState === 'visible') {
3822
- this.notify({ type: "Navigation_Return" /* AuditEventType.Navigation_Return */ });
3824
+ this.notify({ type: AuditEventType.Navigation_Return });
3823
3825
  }
3824
3826
  }, { once: true });
3825
3827
  }
@@ -4189,7 +4191,7 @@ class PreviewService {
4189
4191
  this.passageOffset.set(undefined);
4190
4192
  const detail = this.getAuditPreviewDetail(id, query);
4191
4193
  const auditEvent = {
4192
- type: "Preview_Close" /* AuditEventType.Preview_Close */,
4194
+ type: AuditEventType.Preview_Close,
4193
4195
  detail
4194
4196
  };
4195
4197
  Audit.notify(auditEvent);
@@ -5783,7 +5785,7 @@ class ExportService {
5783
5785
  exportedColumns: exportedColumns,
5784
5786
  selection: (selection ?? []).length > 0 ? selection : undefined,
5785
5787
  $auditRecord: {
5786
- type: "Search_ExportCSV" /* AuditEventType.Search_ExportCSV */,
5788
+ type: AuditEventType.Search_ExportCSV,
5787
5789
  detail: {
5788
5790
  resultid: results ? results.id : undefined
5789
5791
  }
@@ -9077,6 +9079,9 @@ class AggregationDateComponent extends AggregationListComponent {
9077
9079
  };
9078
9080
  this.form.setValue(formValue);
9079
9081
  }
9082
+ toEndOfDay(dateStr) {
9083
+ return `${new Date(dateStr).toLocaleDateString("en-CA", options)} 23:59:59`;
9084
+ }
9080
9085
  getFormValueFilter() {
9081
9086
  const value = this.form.value;
9082
9087
  // value.option is null
@@ -9129,7 +9134,7 @@ class AggregationDateComponent extends AggregationListComponent {
9129
9134
  {
9130
9135
  field: column,
9131
9136
  operator: "lte",
9132
- value: new Date(value.customRange.to).toLocaleDateString("en-CA", options)
9137
+ value: this.toEndOfDay(value.customRange.to)
9133
9138
  }
9134
9139
  ];
9135
9140
  }
@@ -9139,7 +9144,7 @@ class AggregationDateComponent extends AggregationListComponent {
9139
9144
  }
9140
9145
  else if (value.customRange.to) {
9141
9146
  filter.operator = "lte";
9142
- filter.value = new Date(value.customRange.to).toLocaleDateString("en-CA", options);
9147
+ filter.value = this.toEndOfDay(value.customRange.to);
9143
9148
  }
9144
9149
  else {
9145
9150
  throw new Error("filters.customRangeInvalid");
@@ -13312,8 +13317,8 @@ class AggregationTreeComponent {
13312
13317
  });
13313
13318
  this.destroyRef.onDestroy(() => {
13314
13319
  // If the popover is closed with unapplied selections, reset state so it doesn't persist when reopening
13320
+ sessionStorage.removeItem(`agg-${this.aggregation()?.column}`);
13315
13321
  if (this.selection()) {
13316
- sessionStorage.removeItem(`agg-${this.aggregation()?.column}`);
13317
13322
  const unselect = (items) => {
13318
13323
  items.forEach((item) => {
13319
13324
  item.$selected = false;