diff --git a/bin/deploy-greenplum.py b/bin/deploy-greenplum.py index 0138d159c..ce1a8c4d1 100755 --- a/bin/deploy-greenplum.py +++ b/bin/deploy-greenplum.py @@ -21,8 +21,8 @@ # pylint: disable=invalid-name from argparse import ArgumentParser -from jproperties import Properties import os +import json import tempfile from hillviewCommon import ClusterConfiguration, get_config, get_logger, execute_command @@ -41,17 +41,17 @@ def main(): web.run_remote_shell_command("cd bin; ./redeploy.sh -s config-greenplum.json") web.copy_file_to_remote("../repository/PROGRESS_DATADIRECT_JDBC_DRIVER_PIVOTAL_GREENPLUM_5.1.4.000275.jar", config.service_folder + "/" + config.tomcat + "/lib", "") - # Generate properties file - with open("greenplum.properties", "rb") as f: - p = Properties() - p.load(f, "utf-8") - p["greenplumMoveScript"] = config.service_folder + "/move-greenplum.sh" - p["hideDemoMenu"] = "true" - p["enableSaveAs"] = "true" + # Generate configuration file + with open("greenplum.json", "rb") as f: + dict = json.load(f) + dict["greenplumMoveScript"] = config.service_folder + "/move-greenplum.sh" + dict["hideDemoMenu"] = "true" + dict["enableSaveAs"] = "true" tmp = tempfile.NamedTemporaryFile(mode="w", delete=False) - p.store(tmp, encoding="utf-8") + j = json.dumps(dict) + tmp.write(j) tmp.close() - web.copy_file_to_remote(tmp.name, config.service_folder + "/hillview.properties", "") + web.copy_file_to_remote(tmp.name, config.service_folder + "/hillview.json", "") os.remove(tmp.name) if __name__ == "__main__": diff --git a/bin/greenplum.json b/bin/greenplum.json new file mode 100644 index 000000000..1316cb0c1 --- /dev/null +++ b/bin/greenplum.json @@ -0,0 +1,7 @@ +{ + "hideSuggestions": true, + "greenplumScript": "/home/gpdamin/hillview/move-greenplum.sh", + // This directory is used to store the exchanged between Greenplum before and Hillview. + // The directory must be readable/writable by the segment hosts and Hillview workers. + "greenplumDumpDirectory": "/tmp" +} diff --git a/bin/greenplum.properties b/bin/greenplum.properties deleted file mode 100644 index 2b3cea402..000000000 --- a/bin/greenplum.properties +++ /dev/null @@ -1,13 +0,0 @@ -# This properties file is a blueprint for a hillview.properties file -# used with a Greenplum installation. - -########################################################### -# Parameters interfacing Hillview with a Greenplum database - -hideSuggestions = true - -# This script is invoked when data is moved between greenplum and files -greenplumScript = /home/gpdamin/hillview/move-greenplum.sh -# This directory is used to store the exchanged between Greenplum before and Hillview. -# The directory must be readable/writable by the segment hosts and Hillview workers. -greenplumDumpDirectory = /tmp diff --git a/bin/install-dependencies.sh b/bin/install-dependencies.sh index 53c70dd01..cf50df994 100755 --- a/bin/install-dependencies.sh +++ b/bin/install-dependencies.sh @@ -30,7 +30,7 @@ esac ${SUDO} ${INSTALL} install wget maven ${NODEJS} ${LIBFORTRAN} unzip gzip python3 echo "Installing typescript compiler" ${SUDO} npm install -g typescript@3.9.7 -pip install jproperties +pip install json # Download apache if not there. pushd .. diff --git a/docs/userManual.md b/docs/userManual.md index 359df7233..df92fba4e 100644 --- a/docs/userManual.md +++ b/docs/userManual.md @@ -26,7 +26,7 @@ one row for an airline flight. Columns in this dataset include: the date of the the origin and destination cities, the origin and destination states, the origin airport code, the distance flown, the departure and arrival delay. -Updated on 2021 May 11. +Updated on 2021 May 24. # Contents * 1 [Basic concepts](#1-basic-concepts) @@ -39,12 +39,13 @@ Updated on 2021 May 11. * 2.4 [Data conversions](#24-data-conversions) * 2.4.1 [JavaScript conversions](#241-javascript-conversions) * 2.4.2 [JDBC conversions](#242-jdbc-conversions) - * 2.5 [Metadata](#25-metadata) - * 2.5.1 [Mapping a dataset to a metadata directory](#251-mapping-a-dataset-to-a-metadata-directory) - * 2.5.2 [Data schema](#252-data-schema) - * 2.5.3 [Differentially-private metadata](#253-differentially-private-metadata) - * 2.5.4 [Geographic metadata](#254-geographic-metadata) - * 2.5.4.1 [Connecting dataset features to geographic metadata](#2541-connecting-dataset-features-to-geographic-metadata) + * 2.5 [Service configuration](#25-service-configuration) + * 2.6 [Metadata](#26-metadata) + * 2.6.1 [Mapping a dataset to a metadata directory](#261-mapping-a-dataset-to-a-metadata-directory) + * 2.6.2 [Data schema](#262-data-schema) + * 2.6.3 [Differentially-private metadata](#263-differentially-private-metadata) + * 2.6.4 [Geographic metadata](#264-geographic-metadata) + * 2.6.4.1 [Connecting dataset features to geographic metadata](#2641-connecting-dataset-features-to-geographic-metadata) * 3 [Interacting with data](#3-interacting-with-data) * 3.1 [Error display](#31-error-display) * 3.2 [Mouse-based selection](#32-mouse-based-selection) @@ -130,7 +131,7 @@ it receives small results from these. The data on the workers is never sent over the network; the worker locally compute all views that are needed to produce the final result. The root node can store optional metadata information. This is described below in the -[metadata](#25-metadata) section. +[metadata](#26-metadata) section. ### 1.2 Streaming interaction @@ -249,7 +250,66 @@ When reading data from a JDBC source Hillview applies the following conversions: |`NULL`|`None`| |Other|Error: not supported| -### 2.5 Metadata +### 2.5 Service configuration + +The root node will look for a file named `hillview.json` in the working directory. +If found, this file can influence the service behavior. The file can contain +comments, starting with double slashes `//`; these must occur on a line +starting with spaces and containing nothing except the comment. Here is an example +for this file: + +``` +{ + // "Parameters influencing the display of the UI" + // If true the 'saveAs' menu is enabled + "enableSaveAs": true, + // If true the menu to read from a local database is enabled + "localDbMenu": true, + // If true the 'Test' menu for UI testing is displayed + "showTestMenu": true, + // If true the 'Manage' menu for managing the installation is displayed + "enableManagement": true, + // If true the 'Suggestions' in the UI are not displayed + "hideSuggestions": true, + + // Files to show in the Demo datasets menu + "defaultFiles": [{ + fileNamePattern: "data/ontime/????_*.csv*", + schemaFile: "short.schema", + schema: null, + headerRow: true, + name: "Flights (15 columns, CSV)", + fileKind: "csv" + }, { + fileNamePattern: "data/ontime_small_orc/*.orc", + schemaFile: "schema", + schema: null, + name: "Flights (15 columns, ORC)", + fileKind: "orc" + }, { + fileNamePattern: "data/ontime_private/????_*.csv*", + schemaFile: "short.schema", + schema: null, + headerRow: true, + name: "Flights (15 columns, CSV, private)", + fileKind: "csv" + }], + + /////////////////////////////////////////////////////////////////////////////////// + ////////////////// Configuration options used with Greenplum ////////////////////// + // This script is invoked when data is dumped from an external web table + "greenplumDumpScript": "/home/gpdamin/hillview/dump-greenplum.sh", + // This directory is used to store the data dumped from Greenplum before it's parsed by Hillview. + // The directory must be writable by the segment hosts. + "greenplumDumpDirectory": "/tmp" +} +``` + +The property `defaultFiles` of the configuration describes a set of data +files residing on the workers which are used to populate the "Demo datasets" +Hillview menu. Currently only files are supported. + +### 2.6 Metadata This section describes various kinds of metadata manipulated by Hillview. The hillview root node stores the optional metadata in a directory called @@ -262,7 +322,7 @@ The hillview root node stores the optional metadata in a directory called |`data/metadata/differential-privacy`|Root directory for differentially-private metadata; has one subdirectory for each dataset| |`data/metadata/geo`|Root directory for geographic metadata; has one subdirectory for each dataset| -#### 2.5.1 Mapping a dataset to a metadata directory +#### 2.6.1 Mapping a dataset to a metadata directory Hillview uses some conventions in the structuring of directories on the root note in order to associate metadata information on the @@ -278,7 +338,7 @@ associated with this dataset on the root node: metadata describing the differential privacy parameters a dataset that only supports only private visualizations -#### 2.5.2 Data schema +#### 2.6.2 Data schema For some file formats that are not self-describing Hillview uses a `schema` file to specify the format of the data. The following is an @@ -305,11 +365,11 @@ column description has two fields: * kind: A string describing the type of data in the column, corresponding to the types in the [data model](#21-data-model-and-supported-data-types). -#### 2.5.3 Differentially-private metadata +#### 2.6.3 Differentially-private metadata TODO -#### 2.5.4 Geographic metadata +#### 2.6.4 Geographic metadata The directory `data/geo` on the root node can contain various with geographic information data. We currently support @@ -317,7 +377,7 @@ with geographic information data. We currently support The organization of these files on disk is not mandated by Hillview. -##### 2.5.4.1 Connecting dataset features to geographic metadata +##### 2.6.4.1 Connecting dataset features to geographic metadata For each dataset that contains columns that can be mapped to a geographic feature a metadata file can describe the connection between the values in the @@ -526,7 +586,7 @@ is deployed*. * File name pattern: A shell expansion pattern that names the files to load. Multiple files may be loaded on each machine. -* Schema file: An optional [schema file](#252-data-schema) +* Schema file: An optional [schema file](#262-data-schema) in JSON format that describes the schema of the data. In the absence of a schema file Hillview attempts to guess the type of data in each column. The schema file must reside in same folder. @@ -584,7 +644,7 @@ is an ORC struct with scalar types as fields. * File name pattern: A shell expansion pattern that names the files to load. Multiple files may be loaded on each machine. -* Schema file: An optional [schema file](#252-data-schema) +* Schema file: An optional [schema file](#262-data-schema) in JSON format that describes the schema of the data. The schema file must reside in same folder, and it must be compatible with the ORC schema. @@ -731,6 +791,9 @@ The interaction between Hillview and Greenplum proceeds as follows: 5. From this point on Hillview no longer needs to interact with Greenplum. +The [configuration section](#25-service-configuration) shows two configuration +variables that mediate the interaction between Greenplum and Hillview. + ##### 3.3.8.2 Reading from a federated set of MySQL databases The image below shows a system where Hillview reads directly from a set of @@ -1999,7 +2062,7 @@ Selection is done as in heatmaps, but selection is restricted to a single heatma Plotting geographic views require the presence of some geographic metadata on the Hillview root node, and also some dataset-specific metadata that ties a column to a specific geographic feature. This is documented in the -[Geographic metadata](#254-geographic-metadata) section. +[Geographic metadata](#264-geographic-metadata) section. ![Geographic views](geographic-views.png) diff --git a/docs/userManual.src b/docs/userManual.src index 54bcaa601..811079fdf 100644 --- a/docs/userManual.src +++ b/docs/userManual.src @@ -171,6 +171,65 @@ When reading data from a JDBC source Hillview applies the following conversions: |`NULL`|`None`| |Other|Error: not supported| +### Service configuration + +The root node will look for a file named `hillview.json` in the working directory. +If found, this file can influence the service behavior. The file can contain +comments, starting with double slashes `//`; these must occur on a line +starting with spaces and containing nothing except the comment. Here is an example +for this file: + +``` +{ + // "Parameters influencing the display of the UI" + // If true the 'saveAs' menu is enabled + "enableSaveAs": true, + // If true the menu to read from a local database is enabled + "localDbMenu": true, + // If true the 'Test' menu for UI testing is displayed + "showTestMenu": true, + // If true the 'Manage' menu for managing the installation is displayed + "enableManagement": true, + // If true the 'Suggestions' in the UI are not displayed + "hideSuggestions": true, + + // Files to show in the Demo datasets menu + "defaultFiles": [{ + fileNamePattern: "data/ontime/????_*.csv*", + schemaFile: "short.schema", + schema: null, + headerRow: true, + name: "Flights (15 columns, CSV)", + fileKind: "csv" + }, { + fileNamePattern: "data/ontime_small_orc/*.orc", + schemaFile: "schema", + schema: null, + name: "Flights (15 columns, ORC)", + fileKind: "orc" + }, { + fileNamePattern: "data/ontime_private/????_*.csv*", + schemaFile: "short.schema", + schema: null, + headerRow: true, + name: "Flights (15 columns, CSV, private)", + fileKind: "csv" + }], + + /////////////////////////////////////////////////////////////////////////////////// + ////////////////// Configuration options used with Greenplum ////////////////////// + // This script is invoked when data is dumped from an external web table + "greenplumDumpScript": "/home/gpdamin/hillview/dump-greenplum.sh", + // This directory is used to store the data dumped from Greenplum before it's parsed by Hillview. + // The directory must be writable by the segment hosts. + "greenplumDumpDirectory": "/tmp" +} +``` + +The property `defaultFiles` of the configuration describes a set of data +files residing on the workers which are used to populate the "Demo datasets" +Hillview menu. Currently only files are supported. + ### Metadata This section describes various kinds of metadata manipulated by Hillview. @@ -653,6 +712,9 @@ The interaction between Hillview and Greenplum proceeds as follows: 5. From this point on Hillview no longer needs to interact with Greenplum. +The [configuration section](#service-configuration) shows two configuration +variables that mediate the interaction between Greenplum and Hillview. + ##### Reading from a federated set of MySQL databases The image below shows a system where Hillview reads directly from a set of diff --git a/hillview.json b/hillview.json new file mode 100644 index 000000000..e107833be --- /dev/null +++ b/hillview.json @@ -0,0 +1,52 @@ +{ + // "Parameters influencing the display of the UI" + // If true the 'saveAs' menu is enabled + "enableSaveAs": true, + // If true the menu to read from a local database is enabled + "localDbMenu": true, + // If true the 'Test' menu for UI testing is displayed + "showTestMenu": true, + // If true the 'Manage' menu for managing the installation is displayed + "enableManagement": true, + // If true the 'Suggestions' in the UI are not displayed + "hideSuggestions": true, + + // Files to show in the Demo datasets menu + "defaultFiles": [{ + fileNamePattern: "data/ontime/????_*.csv*", + schemaFile: "short.schema", + schema: null, + headerRow: true, + name: "Flights (15 columns, CSV)", + fileKind: "csv" + }, { + fileNamePattern: "data/ontime_small_orc/*.orc", + schemaFile: "schema", + schema: null, + name: "Flights (15 columns, ORC)", + fileKind: "orc" + }, { + fileNamePattern: "data/ontime_private/????_*.csv*", + schemaFile: "short.schema", + schema: null, + headerRow: true, + name: "Flights (15 columns, CSV, private)", + fileKind: "csv" + } + // { + // fileNamePattern: "data/ontime_small_private/*.orc", + // schemaFile: "schema", + // schema: null, + // name: "Flights (15 columns, ORC, private)", + // fileKind: "orc", + // } + ], + + /////////////////////////////////////////////////////////////////////////////////// + ////////////////// Configuration options used with Greenplum ////////////////////// + // This script is invoked when data is dumped from an external web table + "greenplumDumpScript": "/home/gpdamin/hillview/dump-greenplum.sh", + // This directory is used to store the data dumped from Greenplum before it's parsed by Hillview. + // The directory must be writable by the segment hosts. + "greenplumDumpDirectory": "/tmp" +} diff --git a/platform/src/main/java/org/hillview/utils/JsonValue.java b/platform/src/main/java/org/hillview/utils/JsonValue.java new file mode 100644 index 000000000..264be97fa --- /dev/null +++ b/platform/src/main/java/org/hillview/utils/JsonValue.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2021 VMware Inc. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.hillview.utils; + +import com.google.gson.JsonElement; +import org.hillview.dataset.api.IJson; + +public class JsonValue implements IJson { + private final JsonElement value; + public JsonValue(JsonElement element) { + this.value = element; + } + + @Override + public JsonElement toJsonTree() { + return this.value; + } +} diff --git a/web/src/main/java/org/hillview/Configuration.java b/web/src/main/java/org/hillview/Configuration.java index 47137102d..7f8a3d5e3 100644 --- a/web/src/main/java/org/hillview/Configuration.java +++ b/web/src/main/java/org/hillview/Configuration.java @@ -17,12 +17,14 @@ package org.hillview; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.hillview.utils.HillviewLogger; +import org.hillview.utils.JsonValue; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Properties; +import java.io.File; +import java.util.Scanner; /** * This class manages configuration of the global root node of a Hillview deployment. @@ -32,26 +34,42 @@ public class Configuration { * This file contains the global properties that control hillview. * This file is read by the root node. */ - static final String propertiesFile = "hillview.properties"; - + static final String propertiesFile = "hillview.json"; public static final Configuration instance = new Configuration(); // Global application properties - public final Properties properties; + private final JsonObject properties; private Configuration() { - this.properties = new Properties(); - try (FileInputStream prop = new FileInputStream(propertiesFile)) { - this.properties.load(prop); - } catch (FileNotFoundException ex) { - HillviewLogger.instance.info("No properties file found", "{0}", propertiesFile); - } catch (IOException ex) { + JsonObject result = null; + StringBuilder str = new StringBuilder(); + File file = new File(propertiesFile); + try (Scanner prop = new Scanner(file)) { + while (prop.hasNextLine()) { + String line = prop.nextLine(); + if (line.matches("\\s+//.*")) + // Strip comments, not json conformant. + continue; + str.append(line); + } + result = JsonParser.parseString(str.toString()).getAsJsonObject(); + } catch (Exception ex) { HillviewLogger.instance.error("Error while loading properties from file", ex); } + if (result == null) + result = new JsonObject(); + this.properties = result; + } + + public JsonValue getAsJson() { + return new JsonValue(this.properties); } public String getProperty(String propertyName, String defaultValue) { - return this.properties.getProperty(propertyName, defaultValue); + JsonElement el = this.properties.get(propertyName); + if (el == null) + return defaultValue; + return el.getAsString(); } public String getGreenplumMoveScript() { @@ -63,9 +81,4 @@ public String getGreenplumMoveScript() { public String getGreenplumDumpDirectory() { return this.getProperty("greenplumDumpDirectory", "/tmp"); } - - public boolean getBooleanProperty(String prop) { - String value = this.getProperty(prop, "false"); - return !value.trim().toLowerCase().equals("false"); - } } diff --git a/web/src/main/java/org/hillview/targets/InitialObjectTarget.java b/web/src/main/java/org/hillview/targets/InitialObjectTarget.java index 811ecb5c3..dbfb8e0e9 100644 --- a/web/src/main/java/org/hillview/targets/InitialObjectTarget.java +++ b/web/src/main/java/org/hillview/targets/InitialObjectTarget.java @@ -92,16 +92,8 @@ private void initialize(final HostList description) { @HillviewRpc public void getUIConfig(RpcRequest request, RpcRequestContext context) { - UIConfig config = new UIConfig(); - config.enableSaveAs = Configuration.instance.getBooleanProperty("enableSaveAs"); - config.localDbMenu = Configuration.instance.getBooleanProperty("localDbMenu"); - config.showTestMenu = Configuration.instance.getBooleanProperty("showTestMenu"); - config.enableManagement = Configuration.instance.getBooleanProperty("enableManagement"); - config.privateIsCsv = Configuration.instance.getBooleanProperty("privateIsCsv"); - config.hideSuggestions = Configuration.instance.getBooleanProperty("hideSuggestions"); - config.hideDemoMenu = Configuration.instance.getBooleanProperty("hideDemoMenu"); Converters.checkNull(this.emptyDataset); - this.returnResult(config, request, context); + this.returnResult(Configuration.instance.getAsJson(), request, context); } @HillviewRpc diff --git a/web/src/main/webapp/dataViews/schemaView.ts b/web/src/main/webapp/dataViews/schemaView.ts index dad8ba6bb..6c4022533 100644 --- a/web/src/main/webapp/dataViews/schemaView.ts +++ b/web/src/main/webapp/dataViews/schemaView.ts @@ -64,9 +64,13 @@ export class SchemaView extends TSViewBase { this.defaultProvenance = "Schema view"; this.contextMenu = new ContextMenu(this.topLevel); const viewMenu = new SubMenu([{ - text: "Selected columns", + text: "Table of selected columns", action: () => this.showTable(), - help: "Show the data using a tabular view containing the selected columns.", + help: "Show the data using a tabular view containing the selected columns (or all columns if none is selected).", + }, { + text: "Table of all columns", + action: () => this.showTable(), + help: "Show all columns in a tabular view.", }]); /* Dialog box for selecting columns based on name */ @@ -463,7 +467,11 @@ export class SchemaView extends TSViewBase { private showTable(): void { const newPage = this.dataset.newPage(new PageTitle("Selected columns", "Schema view"), this.page); const selected = this.display.getSelectedRows(); - const newSchema = this.meta.schema.filter((c) => selected.has(this.meta.schema.columnIndex(c.name))); + let newSchema: SchemaClass; + if (selected.size == 0) + newSchema = this.meta.schema; + else + newSchema = this.meta.schema.filter((c) => selected.has(this.meta.schema.columnIndex(c.name))); const tv = new TableView(this.getRemoteObjectId()!, {rowCount: this.meta.rowCount, schema: newSchema, geoMetadata: this.meta.geoMetadata }, newPage); newPage.setDataView(tv); diff --git a/web/src/main/webapp/javaBridge.ts b/web/src/main/webapp/javaBridge.ts index be3ad935d..f08ade4fd 100644 --- a/web/src/main/webapp/javaBridge.ts +++ b/web/src/main/webapp/javaBridge.ts @@ -88,9 +88,9 @@ export interface UIConfig { localDbMenu?: boolean; // show the local db connection showTestMenu?: boolean; // the test menu is shown enableManagement?: boolean; // management menu enabled - privateIsCsv?: boolean; // the private dataset is in csv form hideSuggestions?: boolean; // do not display the suggestions hideDemoMenu?: boolean; // do not show the "demo" menu + defaultFiles?: FileSetDescription[]; // Files to show in the default menu. } export interface ColumnQuantization { diff --git a/web/src/main/webapp/loadView.ts b/web/src/main/webapp/loadView.ts index 787934450..4cd904c38 100644 --- a/web/src/main/webapp/loadView.ts +++ b/web/src/main/webapp/loadView.ts @@ -74,99 +74,22 @@ export class LoadView extends RemoteObject implements IDataView { disableSuggestions(false); } - private createMenus(): void { - const testitems: MenuItem[] = []; - testitems.push( - { text: "Flights (15 columns, CSV)", - action: () => { - const files: FileSetDescription = { - fileNamePattern: "data/ontime/????_*.csv*", - schemaFile: "short.schema", - schema: null, - headerRow: true, - name: "Flights (15 columns)", - fileKind: "csv", - }; - this.init.loadFiles(files, this.page); - }, - help: "The US flights dataset.", - }, - { text: "Flights (15 columns, ORC)", - action: () => { - const files: FileSetDescription = { - fileNamePattern: "data/ontime_small_orc/*.orc", - schemaFile: "schema", - schema: null, - name: "Flights (15 columns, ORC)", - fileKind: "orc", - }; - this.init.loadFiles(files, this.page); - }, - help: "The US flights dataset.", - }, - { text: "Flights (all columns, ORC)", - action: () => { - const files: FileSetDescription = { - fileNamePattern: "data/ontime_big_orc/*.orc", - schemaFile: "schema", - schema: null, - name: "Flights (ORC)", - fileKind: "orc", - }; - this.init.loadFiles(files, this.page); - }, - help: "The US flights dataset -- all 110 columns." }); - if (HillviewToplevel.instance.uiconfig.privateIsCsv) { - testitems.push({ - text: "Flights (15 columns, CSV, private)", - action: () => { - const files: FileSetDescription = { - fileNamePattern: "data/ontime_private/????_*.csv*", - schemaFile: "short.schema", - schema: null, - headerRow: true, - name: "Flights (private)", - fileKind: "csv", - }; - this.init.loadFiles(files, this.page); - }, - help: "The US flights dataset.", - }); - } else { - testitems.push({ - text: "Flights (15 columns, ORC, private)", - action: () => { - const files: FileSetDescription = { - fileNamePattern: "data/ontime_private/*.orc", - schemaFile: "schema", - schema: null, - name: "Flights (private)", - fileKind: "orc", - }; - this.init.loadFiles(files, this.page); - }, - help: "The US flights dataset.", - }); - } - /* - // TODO: Delete - testitems.push({ - text: "Flights (15 columns, ORC, private)", - action: () => { - const files: FileSetDescription = { - fileNamePattern: "data/ontime_small_private/*.orc", - schemaFile: "schema", - schema: null, - name: "Flights (private)", - fileKind: "orc", - }; - this.init.loadFiles(files, this.page); - }, - help: "The US flights dataset.", - }); - */ - this.testDatasetsMenu = new SubMenu(testitems); + public convertToMenu(data: FileSetDescription[]): MenuItem[] { + const convert: ((d: FileSetDescription) => MenuItem) = (d: FileSetDescription) => { + return { + text: d.name || d.fileNamePattern, + help: d.name || "Data to load", + action: () => this.init.loadFiles(d, this.page) + } + }; + return data.map(convert); + } + private createMenus(): void { + const demoItems: FileSetDescription[] = []; + HillviewToplevel.instance.uiconfig.defaultFiles?.forEach( + e => demoItems.push(e)); + this.testDatasetsMenu = new SubMenu(this.convertToMenu(demoItems)); const loadMenuItems: MenuItem[] = []; loadMenuItems.push({ text: "Hillview logs", diff --git a/web/src/main/webapp/test.ts b/web/src/main/webapp/test.ts index 8b9669d8f..848b72b5f 100644 --- a/web/src/main/webapp/test.ts +++ b/web/src/main/webapp/test.ts @@ -264,7 +264,7 @@ export class Test { const row3 = findElement("#hillviewPage2 #row3"); row3.dispatchEvent(controlClickEvent()); // Select menu item to show the associated table - findElement("#hillviewPage2 .topMenu #Selected_columns").click(); + findElement("#hillviewPage2 .topMenu #Table_of_selected_columns").click(); this.next(); // no rpc } }, {