prometheus/web/ui/react-app
Boyko 315b28439f Graph multi series select (#6391)
* adding graph series multi select support

Signed-off-by: Boyko Lalov <boiskila@gmail.com>
Signed-off-by: blalov <boiskila@gmail.com>

* skip inital plot draw from ResizeDetector

Signed-off-by: Boyko Lalov <boiskila@gmail.com>
Signed-off-by: blalov <boiskila@gmail.com>

* fix unit tests

Signed-off-by: blalov <boiskila@gmail.com>

* extract Legend as component

Signed-off-by: blalov <boiskila@gmail.com>

* create legend state interface

Signed-off-by: blalov <boiskila@gmail.com>

* fix click selection issue

Signed-off-by: blalov <boiskila@gmail.com>

* fix single series select bug

Signed-off-by: Boyko Lalov <boiskila@gmail.com>

* review changes

Signed-off-by: blalov <boiskila@gmail.com>
2019-12-03 20:20:45 +01:00
..
public React UI: Support custom path prefixes (#6264) 2019-11-04 09:17:50 +01:00
src Graph multi series select (#6391) 2019-12-03 20:20:45 +01:00
.eslintrc.json WIP: React UI Linting rules (#6206) 2019-10-28 15:02:42 +01:00
.gitignore
README.md React UI: Clarify VSCode usage requirements (#6357) 2019-11-22 14:55:32 +01:00
package.json WIP: status page - API and UI (#6243) 2019-11-02 16:53:32 +01:00
tsconfig.json WIP: status page - API and UI (#6243) 2019-11-02 16:53:32 +01:00
yarn.lock React UI: Fix build (#6312) 2019-11-13 13:36:43 +01:00

README.md

Working with the React UI

This file explains how to work with the React-based Prometheus UI.

Introduction

The React-based Prometheus UI was was bootstrapped using Create React App, a popular toolkit for generating React application setups. You can find general information about Create React App on their documentation site.

Instead of plain JavaScript, we use TypeScript to ensure typed code.

Development environment

To work with the React UI code, you will need to have the following tools installed:

NOTE: When using Visual Studio Code, be sure to open the web/ui/react-app directory in the editor instead of the root of the repository. This way, the right ESLint and TypeScript configuration will be picked up from the React workspace.

Installing npm dependencies

The React UI depends on a large number of npm packages. These are not checked in, so you will need to download and install them locally via the Yarn package manager:

yarn

Yarn consults the package.json and yarn.lock files for dependencies to install. It creates a node_modules directory with all installed dependencies.

Running a local development server

You can start a development server for the React UI outside of a running Prometheus server by running:

yarn start

This will open a browser window with the React app running on http://localhost:3000/. The page will reload if you make edits to the source code. You will also see any lint errors in the console.

Due to a "proxy": "http://localhost:9090" setting in the package.json file, any API requests from the React UI are proxied to localhost on port 9090 by the development server. This allows you to run a normal Prometheus server to handle API requests, while iterating separately on the UI.

[browser] ----> [localhost:3000 (dev server)] --(proxy API requests)--> [localhost:9090 (Prometheus)]

Running tests

Create React App uses the Jest framework for running tests. To run tests in interactive watch mode:

yarn test

To generate an HTML-based test coverage report, run:

CI=true yarn test --coverage

This creates a coverage subdirectory with the generated report. Open coverage/lcov-report/index.html in the browser to view it.

The CI=true environment variable prevents the tests from being run in interactive / watching mode.

See the Create React App documentation for more information about running tests.

Linting

We define linting rules for the ESLint linter. We recommend integrating automated linting and fixing into your editor (e.g. upon save), but you can also run the linter separately from the command-line.

To detect and automatically fix lint errors, run:

yarn lint

This is also available via the react-app-lint-fix target in the main Prometheus Makefile.

Building the app for production

To build a production-optimized version of the React app to a build subdirectory, run:

yarn build

NOTE: You will likely not need to do this directly. Instead, this is taken care of by the build target in the main Prometheus Makefile when building the full binary.

Integration into Prometheus

To build a Prometheus binary that includes a compiled-in version of the production build of the React app, change to the root of the repository and run:

make build

This installs npm dependencies via Yarn, builds a production build of the React app, and then finally compiles in all web assets into the Prometheus binary.