Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Multiple Datasource] Add data source selection service to support storing and getting selected data source updates #6825

Closed
raintygao opened this issue May 24, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request multiple datasource multiple datasource project v2.15.0

Comments

@raintygao
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Some plugins may need to get data source selected info through data source selector components, there isn't a centralized way to record or manage this.

Describe the solution you'd like

We plan to add a service named DataSourceSelection in DSM to support this. In setup stage of DSM, a instance of DataSourceSelectionService would be generated and this instance will be passed to each data source selector or menu component and returned to other plugin. Selector component can stored selected data source through this instance and other plugin can subscribe or get selected data source through this instance.

 class DataSourceSelection {

 // This is an observable map to record all selected data sources in OSD.
 // This data is stored in memory and will be cleared with OSD context and reset if page reloads.
 // The key of map is the id of each selector component.Since DSM provides several components and there can be many components on the page at the same time,the component needs to generate an unique ID to specify itself when mounted.
 // The value would be the detail info of selected data source.
  private selectedDataSource$ = new BehaviorSubject(new Map<string, DataSourceOption[]>());
  
  // When users select data source through component, component will call this function to set selected data source.
  public selectDataSource = (componentId: string, dataSource: DataSourceOption[]) => {
  };

  // When component unmounts, it will call this function to delete stored selected data source.
  public remove = (componentId: string) => {
  };

  // Other plugins can call this function to get all selected data source value.
  public getSelectionValue = () => {
  };

  // Other plugins can call this function to get observable subject, component can use this value to subscribe update.
  public getSelection$ = () => {
  };
}
@BionIT
Copy link
Collaborator

BionIT commented May 31, 2024

@raintygao Do we have all PRs merged for this feature?

@raintygao
Copy link
Contributor Author

raintygao commented Jun 3, 2024

Sure, will close as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request multiple datasource multiple datasource project v2.15.0
Projects
None yet
Development

No branches or pull requests

2 participants