Fetching Dashboards

Initialization

To fetch user's dashboards, you must first initiate the Vizzly SDK.

Initializing the Vizzly SDK

Ensure you have loaded the Vizzly package by following the prerequisite steps in our initializing guide.

If needed, you will also then be able to fetch the Vizzly instance using the following code.

const vizzly = Vizzly.use();

Usage

Once the SDK has been initiated, you fetch the user's dashboards.

Fetching

You can fetch all dashboards that are available to the current user.

const doFetchDashboards = async () => {
  const vizzly = Vizzly.use();
 
  // Returns a list of all dashboards a user has read or read_write access too.
  return await vizzly.getDashboards();
};

Filtering

To select specific dashboards from all the dashboards available to the user, you can use the Vizzly.filterDashboards function.

It takes a list of dashboards as the first argument, and filter options as the second. For example;

const doFetchDashboards = async () => {
  const vizzly = Vizzly.use();
 
  let allDashboards = await vizzly.getDashboards();
 
  // Returns a list of all dashboards a user has read or read_write access too.
  return Vizzly.filterDashboards(allDashboards, {
    /*
      // Return dashboards with the scope specified here.
      onlyAllowScope?: 'read' | 'read_write';
    */
 
    /*
      // Return child dashboards which are related to a specific parent
      onlyChildDashboardsForParent?: string;
    */
 
    /*
      // Return all child dashboards for the user.
      onlyChildDashboards?: boolean;
    */
 
    
    /*
      // Return only parent dashboards.
      onlyParentDashboards?: boolean;
    */
 
   /*
     // Provide an object, that returns only the dashboards 
     // that contain the same values in their metadata.
     onlyDashboardsIncludingMetadata?: Object
   */
  })
};

To learn more about child and parent dashboards, read the documentation here!.