alfresco-ng2-components/docs/core/services/saved-searches.service.md
MichalKinas 35aec24c0f
Revert "Revert "[ACS-9166] Migrate Saved Searches to preferences API from con…" (#10594)
This reverts commit fcd6e25dc65b83929c1dbed4121c929eef666910.
2025-01-28 08:41:23 +01:00

1.9 KiB

Saved Searches Service

Manages operations related to saving and retrieving user-defined searches.

Class members

Properties

  • savedSearches$: ReplaySubject<SavedSearch[]>
    Stores the list of saved searches and emits new value whenever there is a change.

Methods

getSavedSearches(): Observable<SavedSearch[]>

Fetches the file with list of saved searches either from a locally cached node ID or by querying the ACS server. Then it reads the file and maps JSON objects into SavedSearches

  • Returns:
    • Observable<SavedSearch[]> - An observable that emits the list of saved searches.

saveSearch(newSaveSearch: Pick<SavedSearch, 'name' | 'description' | 'encodedUrl'>): Observable<NodeEntry>

Saves a new search and updates the existing list of saved searches stored in file and in service property savedSearches$.

  • Parameters:

    • newSaveSearch: An object containing the name, description, and encodedUrl of the new search.
  • Returns:

    • Observable<NodeEntry> - An observable that emits the response of the node entry after saving.

Usage Examples

Fetching Saved Searches

The following example shows how to fetch saved searches:

this.savedSearchService.getSavedSearches().subscribe((searches: SavedSearch[]) => {
    console.log('Saved searches:', searches);
});

To save a new search:

const newSearch = { name: 'New Search', description: 'A sample search', encodedUrl: 'url3' };
this.savedSearchService.saveSearch(newSearch).subscribe((response) => {
    console.log('Saved new search:', response);
});