@sinequa/atomic-angular 1.0.4 → 1.0.5

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.
@@ -1551,6 +1551,16 @@ function withThemes(app, themes) {
1551
1551
  return app;
1552
1552
  }
1553
1553
 
1554
+ /**
1555
+ * Signs in the user by checking the global configuration for authentication method and acting accordingly.
1556
+ *
1557
+ * This function first clears any existing session tokens to ensure a clean authentication state. It then checks the
1558
+ * global configuration to determine whether to use credentials-based authentication or Single Sign-On (SSO). If
1559
+ * credentials are used, it redirects the user to the login page. If SSO is enabled, it reloads the page to trigger
1560
+ * the SSO login process. If neither method is specified, it attempts a standard login and handles any errors that
1561
+ * may occur during the process.
1562
+ * @returns A promise resolving to a boolean indicating the success of the sign-in operation.
1563
+ */
1554
1564
  async function signIn() {
1555
1565
  assertInInjectionContext(signIn);
1556
1566
  const router = inject(Router);
@@ -1561,21 +1571,24 @@ async function signIn() {
1561
1571
  // If credentials are used and user override is not active, redirect to the login page
1562
1572
  if (useCredentials) {
1563
1573
  router.navigate([loginPath], { queryParams: { returnUrl: lastUrlAfterNavigation } });
1564
- return; // prevent further execution
1574
+ return false; // prevent further execution
1565
1575
  }
1566
1576
  // SSO is set to true when the browser handles authentication automatically
1567
1577
  // If SSO is used, reload the page to trigger SSO login
1568
1578
  if (useSSO) {
1569
1579
  // reload the page to trigger SSO login
1570
1580
  window.location.reload();
1571
- return; // prevent further execution
1581
+ return false; // prevent further execution
1572
1582
  }
1573
1583
  // Otherwise, perform a standard login
1574
1584
  try {
1575
1585
  const response = await login();
1576
- info("Response from login", response);
1577
- if (!response) {
1578
- warn("No response from login, redirecting to login page", response);
1586
+ if (response) {
1587
+ info("Response from login", response);
1588
+ return true;
1589
+ }
1590
+ else {
1591
+ warn("Response from login", response);
1579
1592
  }
1580
1593
  }
1581
1594
  catch (err) {
@@ -1586,7 +1599,7 @@ async function signIn() {
1586
1599
  }
1587
1600
  throw err;
1588
1601
  }
1589
- return; // prevent further execution
1602
+ return false; // prevent further execution
1590
1603
  }
1591
1604
 
1592
1605
  /**
@@ -1607,24 +1620,28 @@ async function withBootstrapApp(applicationService, { createRoutes = true }) {
1607
1620
  return new Promise(resolve => {
1608
1621
  // Check if the user is authenticated
1609
1622
  signIn()
1610
- .then(() => {
1611
- info('User authenticated, initializing application...');
1612
- // Initialize the application
1613
- applicationService
1614
- .initialize(createRoutes)
1615
- .then(() => {
1616
- info(`Application initialized with routes: ${createRoutes} successfully.`);
1617
- resolve();
1618
- })
1619
- .catch(err => {
1620
- error(`Error initializing application with routes: ${createRoutes}:`, err);
1621
- resolve();
1622
- });
1623
+ .then((response) => {
1624
+ if (response) {
1625
+ info('User authenticated, initializing application...');
1626
+ // Initialize the application
1627
+ applicationService
1628
+ .initialize(createRoutes)
1629
+ .then(() => {
1630
+ info(`Application initialized with routes: ${createRoutes} successfully.`);
1631
+ })
1632
+ .catch(err => {
1633
+ error(`Error initializing application with routes: ${createRoutes}:`, err);
1634
+ });
1635
+ }
1636
+ else {
1637
+ info('User not authenticated, skipping application initialization.');
1638
+ }
1639
+ ;
1623
1640
  })
1624
1641
  .catch(err => {
1625
1642
  error('Error while signing in:', err);
1626
- resolve();
1627
- });
1643
+ })
1644
+ .finally(() => resolve());
1628
1645
  });
1629
1646
  }
1630
1647
 
@@ -7896,11 +7913,16 @@ class AdvancedFiltersComponent {
7896
7913
  }, ...(ngDevMode ? [{ debugName: "allowEmptySearch" }] : []));
7897
7914
  text = "";
7898
7915
  constructor() {
7899
- this.getFirstPageQuery();
7916
+ effect(() => {
7917
+ getState(this.appStore);
7918
+ const query = this.appStore.getDefaultQuery();
7919
+ if (query?.name) {
7920
+ this.getFirstPageQuery(query?.name);
7921
+ }
7922
+ });
7900
7923
  }
7901
- async getFirstPageQuery() {
7902
- const query = this.appStore.getDefaultQuery() || { name: "_default" };
7903
- const response = await fetchQuery({ isFirstPage: true, name: query.name });
7924
+ async getFirstPageQuery(queryName) {
7925
+ const response = await fetchQuery({ isFirstPage: true, name: queryName });
7904
7926
  this.aggregations.set(response.aggregations);
7905
7927
  }
7906
7928
  onTabChange(tab) {
@@ -11860,11 +11882,16 @@ class DrawerAdvancedFiltersComponent extends DrawerComponent {
11860
11882
  text = "";
11861
11883
  constructor() {
11862
11884
  super();
11863
- this.getFirstPageQuery();
11885
+ effect(() => {
11886
+ getState(this.appStore);
11887
+ const query = this.appStore.getDefaultQuery();
11888
+ if (query?.name) {
11889
+ this.getFirstPageQuery(query?.name);
11890
+ }
11891
+ });
11864
11892
  }
11865
- async getFirstPageQuery() {
11866
- const query = this.appStore.getDefaultQuery() || { name: "_default" };
11867
- const response = await fetchQuery({ isFirstPage: true, name: query.name });
11893
+ async getFirstPageQuery(queryName) {
11894
+ const response = await fetchQuery({ isFirstPage: true, name: queryName });
11868
11895
  this.aggregations.set(response.aggregations);
11869
11896
  }
11870
11897
  onTabChange(tab) {