Skip to content
Web

Layouts

A Layout describes a set of visualizations and the necessary AMIScript for transforming data to be shown on the visualizations. This information is stored as JSON with the extension .ami

Multiple Layouts

AMI has two ways to use multiple layouts:

  1. Included layouts

  2. Importing layout JSON

Included Layouts

Included layouts are a powerful tool for breaking layouts into separate files. This can increase reusability and make files easier to manage. Layouts take on a parent/child relationship, if a parent layout includes 3 child layouts.

Note

A user can only have 4 layers of included layouts e.g. Current layout -> included layout1 -> ... -> included layout4

In order to reference child layouts, click on the Included Layouts window found under the Dashboard menu:

This will open the Included Layouts window:

The <root> entry listed is the current parent layout. This window is used to include (add) child layouts to this parent layout. In order to add layouts, right click on the <root> entry and use the menu in order to select the child layout you would like the include:

  • Existing File: layouts which are saved as Absolute Files (File > Absolute File - Save As)
  • File in the cloud: layouts saved to the cloud (File > Cloud - Save As)
  • File in my layouts: layouts saved locally (File > My Layouts - Save As)

Once you have selected the layout to include, it will appear under the <root>. You can either include more layouts to the <root> or you can actually include a layout into the child layout by following the same steps above.

After you click submit, the child layout with its panels and datamodels will be available for use. Opening the datamodeler (Dashboard > Datamodeler), you will find the datamodel from the child layout with the name of the child layout preceding its Datamodel Name (for example: ChildLayout.Country)

In order to use a panel from the child layout, first create a blank panel (Windows > New Window). From the panel menu, hover over Unhide Panel to see all of the panels that are now included and available for use in the current layout. As seen in the datamodeler, the child components will be named in a similar manner (name of layout.panel ID)

On the left-hand side of the datamodeler, you will find a list of all the included layouts (along with the parent). Unchecking/checking a layout here will filter out the associated datamodels and panels. This will come in handy when working with many layouts and their components.

Note:Deleting the panel and then saving will also delete the panel from the child layout. To avoid losing layout components, use the hide option in order to no longer use the child panel.

In order to completely disassociate a child layout from the parent layout, return to the Included Layouts window and click Unlink in the right click menu. Make sure to save in order to remember this change.

Note: When you make a change in a child layout and then save it, it will be reflected on any layouts that has included this child layout.

Importing layout JSON

Another approach is to import the JSON that represents a part of a layout. Below is a guide for importing a datamodel.

  1. Create a /myConfigs (can be any name you want) directory local to your AMI installation and put the configuration files (usually in the format of JSON) in it

    The example below has the configuration file named CountryTemplate.json. You can have multiple configuration files

  2. Read, Parse the config files and import the data model and panel to the AMI session

    Also additionally, you can configure data model's WHERE variable.

    The amiScript below show how to achieve these where each visualization panel has exactly one underlying data model:

    filesystem fs=session.getFileSystem();
    String Panelconfig = fs.readFile("myConfigs/testPanelConfig.json");
    String DMconfig = fs.readFile("myConfigs/testDMConfig.json");
    map Panelparsed = parseJson(Panelconfig);
    map DMparsed = parseJson(DMconfig);
    datamodel dm=session.importDatamodel(DMparsed);
    map m = Panelparsed.jsonPath("portletConfigs.0.portletConfig.dm.0"); //get the id from the data model that we imported
    m.put("dmadn", dm.getId()); //put the id above into the panel's configuration
    dm.process(new map("WHERE", "Code=\"ABW\"")); // configure WHERE variable
    session.importWindow("newWindow1", Panelparsed); //import the window