Giter VIP home page Giter VIP logo

argus-frontend's Introduction

Argus - Frontend

build codecov

The Argus-frontend provides a graphical web interface to use with Argus. It has been built using React with TypeScript. The backend can be found at https://github.com/Uninett/Argus.

Here's how to get started with development.

Requirements

  • Argus backend
  • Node.js with npm

Set up the Argus backend according to the instructions in its repository (https://github.com/Uninett/Argus).

Furthermore, Node.js is required. We also use the Node Package Manager (npm), which comes bundled with Node.js.

Optionally, you can forego a full installation of Node.js and npm on your local system, and instead opt to run a complete Argus setup using Docker Compose. If so, skip directly to the Install and startup section.

Installation procedures are as follows:

Install Node.js

OS X

Use the Terminal app (located at /Applications/Utilities/Terminal.app).

Install Homebrew with the following command.

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Then run

brew install node

to start the installation.

Ubuntu Linux

Open a terminal and run the following commands:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

Windows

Download the Node.js installer from http://nodejs.org/ and follow the installation instructions provided on the website. Make sure that the git command is available in your PATH.


After installation, test your Node.js with the following commands:

$ node --version
v10.11.0

$ npm --version
6.4.1

You successfully installed Node.js! Now let's continue to Argus frontend.

Install and startup Argus frontend

To download Argus frontend and install all required dependencies, run

git clone https://github.com/Uninett/Argus-frontend
cd Argus-frontend
npm install

Afterwards, use

npm start

to start the app in development mode. This will open your browser at http://localhost:3000 or similar.

Congrats, you now have the Argus frontend up and running!

Note that the website will automatically reload as you edit the code.

Configuration

Default configuration options for the Argus frontend are located in src/config.tsx. All of these options can be set using environment variables when running the frontend under the Node server (or in Docker Compose), or by providing configuration variables in runtime-config.json file.

Configuration variables can be provided by adding a public/runtime-config.json file when in development environment, or by serving a /runtime-config.json file when in production environment. Example configuration file looks like this:

{
  "backendUrl": "http://localhost:8000",
  "enableWebsocketSupport": true,
  "backendWSUrl": "ws://localhost:8000/ws",
  "useSecureCookie": true,
  "debug": true,
  "cookieDomain": "localhost",
  "defaultAutoRefreshInterval": 40,
  "realtimeServiceMaxRetries": 7,
  "use24hTime": true,
  "timestampDateFormat": "yyyy-MM-dd",
  "timestampTimeFormat": "HH:mm:ss",
  "timestampTimeNoSeconds": "HH:mm",
  "timestampTimezoneOffsetFormat": "xxx",
  "timestampFormat": "{date} {time}{timezone_offset}",
  "showSeverityLevels": true
}

Development environment

Either provide environment variables when running the frontend under the Node server (or in Docker Compose), or add runtime-config.json file with the configuration variables to the /public folder.

Production environment

Serve runtime-config.json file with the configuration variables. It must be accessible as %YOUR_FRONTEND_BASE_URL%/runtime-config.json.

Alternatively, you can configure the application via environment variables if using the production-oriented Docker image defined in ./docker/Dockerfile. This image will automatically produce a runtime-config.json from the environment variables exported to the container, as well as other variables provided in the ./docker/runtime-config-template.json. Read more in the docker/README.md.

Variables

These environment variables are available:

REACT_APP_BACKEND_URL
The base URL to the Argus API server
REACT_APP_ENABLE_WEBSOCKETS_SUPPORT
Set to true to enable subscriptions to realtime incident updates
REACT_APP_BACKEND_WS_URL
If you enable websocket support, this must be set to the backend's websocket URL. This value may depend on whether your deployment splits the HTTP server and the Web Socket servers into two components. Typically, if the backend HTTP server is https://argus-api.example.org/, this value could be wss://argus-api.example.org/ws.
REACT_APP_USE_SECURE_COOKIE
Set explicitly to false to disable the use of secure cookies. Typically only useful when deploying the development environment using non-TLS servers/regular HTTP.
REACT_APP_DEBUG
Set to true if you want debug output from the application.
REACT_APP_DEFAULT_AUTO_REFRESH_INTERVAL
Set to the default number of seconds between each auto refresh

These environment variables are optional:

REACT_APP_COOKIE_DOMAIN
Ignore it if Argus frontend and backend are deployed on the same domain. Otherwise, set it to the same value as ARGUS_COOKIE_DOMAIN variable on the backend.

Configuration variables can be provided in runtime-config.json file and will take precedence over the environment variables. These configuration variables are available:

backendUrl
Format: string. The base URL to the Argus API server. MUST be provided in production environment, optional otherwise.
cookieDomain
Format: string. MUST be provided in production environment, optional otherwise.
enableWebsocketSupport
Format: boolean. Set to true to enable subscriptions to realtime incident updates.
backendWSUrl
Format: string. If you enable websocket support, this must be set to the backend's websocket URL. This value may depend on whether your deployment splits the HTTP server and the Web Socket servers into two components. Typically, if the backend HTTP server is https://argus-api.example.org/, this value could be wss://argus-api.example.org/ws.
realtimeServiceMaxRetries
Format: integer. If you enable websocket support, and it fails, this specifies how many times the application will retry connection before closing the socket.
defaultAutoRefreshInterval
Format: integer. Set to the default number of seconds between each auto refresh.
debug
Format: boolean. Set to true if you want debug output from the application.
showSeverityLevels/dt>
Format: boolean. Set to true if you want to enable filtering of incidents by severity levels.
useSecureCookie
Format: boolean. Set explicitly to false to disable the use of secure cookies. Typically only useful when deploying the development environment using non-TLS servers/regular HTTP.
timestampFormat
Format: string (valid ISO timestamp format). Specifies how a complete timestamp should be displayed.
timestampDateFormat
Format: string (valid ISO timestamp format). Specifies how dates should be displayed.
timestampTimeFormat
Format: string (valid ISO timestamp format). Specifies how time values should be displayed.
timestampTimeNoSeconds
Format: string (valid ISO timestamp format). Specifies how time values without seconds should be displayed.
timestampTimezoneOffsetFormat
Format: string (valid ISO timestamp format). Specifies how timezone should be displayed.
use24hTime
Format: boolean. Set to true if you want time values to be displayed in 24-hours-day format.

Using Docker Compose

This repository contains a docker-compose.yml definition to run all the backend components as services, while the Argus frontend runs directly off the checked out source code using npm. If you have Docker Compose on your system, run these commands to get everything up and running:

export UID
docker-compose up

(the export UID step is to ensure the Argus frontend container runs using your system UID, so it doesn't produce root-owned files in the mounted source code directory).

Your Argus frontend should now be served on http://localhost:8080, while your Argus API server should be served on http://localhost:8000. As with running npm locally, the website should automatically reload as you edit the code.

The default setup will install the latest version of the Argus API server from the master branch. If you need to customize which tag or branch to install, you can change the BRANCH argument in docker-compose.yml (or preferably implement your own docker-compose.override.yml).

Running tests

Given that Argus-frontend is installed and configured as described above, the following command can be used to run all the tests:

npm test

To run test files individually the following command can be used:

npm test -- nameOfTestFile

To run a single test and skip all the others, the following command can be used:

npm test -- -t "testName"

Fixes for known annoyances, Linux

If you get the error message "React Native Error: ENOSPC: System limit for number of file watchers reached" (the code will still run, but tests might not), your version of React is probably not cleaning up its inotify watchers properly.

A temporary fix that always works is to reset the node_modules directory:

rm -rf node_modules
npm install

.. but the error will eventually be back.

A permanent fix for some Linuxes is to increase the value of fs.inotify.max_user_watches in /etc/sysctl.conf. It's a number that is divisible by 540 on 32bit systems and 1024 on 64bit-systems. The max is 524288.

Coding guidelines

Code structure

The folder structure of this project consists of components and views. Each view component consists of other components. App.js handles the routing to each view component that is displayed on the web app.

Coding style

We use prettier for JavaScript auto-formatting.

We recommend using an editor plugin to automatically format code on save, like prettier-atom or vim-prettier.

Another option to format the code is the yarn prettier command.

Lint errors will be displayed on the console while the app is running.

CSS

The file ColorScheme.css defines the colors used in the project. Additionally, there is one CSS file for each component.

Using towncrier to automatically produce the changelog

To install towncrier using pip run

$ pip install towncrier

Alternatively you can also use pipx and run

$ pipx install towncrier

Or for Ubuntu 22.04 LTS or later run

$ sudo apt-get update
$ sudo apt-get install towncrier

If it is not possible to install towncrier in the desired environment the files needed to later automatically generate the changelog from can also be created using the editor of one's choice as long as the naming conventions are followed.

Before merging a pull request

To be able to automatically produce the changelog for a release one file for each pull request (also called news fragment) needs to be added to the folder changelog.d/.

The name of the file consists of three parts separated by a period:

  1. The identifier: either the issue number (in case the pull request fixes that issue) or the pull request number. If we don't want to add a link to the resulting changelog entry then a + followed by a unique short description.
  2. The type of the change: we use security, removed, deprecated, added, changed and fixed.
  3. The file suffix, e.g. .md, towncrier does not care which suffix a fragment has.

So an example for a file name related to an issue/pull request would be 214.added.md or for a file without corresponding issue +fixed-pagination-bug.fixed.md.

This file can either be created manually with a file name as specified above and the changelog text as content or one can use towncrier to create such a file as following:

$ towncrier create -c "Changelog content" 214.added.md

When opening a pull request there will be a check to make sure that a news fragment is added and it will fail if it is missing.

Before a release

To add all content from the changelog.d/ folder to the changelog file simply run

$ towncrier build --version {version}

This will also delete all files in changelog.d/.

To preview what the addition to the changelog file would look like add the flag --draft. This will not delete any files or change CHANGELOG.md. It will only output the preview in the terminal.

A few other helpful flags:

  • date DATE - set the date of the release, default is today
  • keep - do not delete the files in changelog.d/

More information about towncrier.

argus-frontend's People

Contributors

akrimelzer avatar alexmstaff avatar ddabble avatar dependabot[bot] avatar havfo avatar hermar98 avatar hmpf avatar ingriddraagen avatar johannaengland avatar jorgenbele avatar karolbon avatar katsel avatar lunkwill42 avatar podliashanyk avatar stveit avatar tjedor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

argus-frontend's Issues

Do not linkify relative details_urls

Closes #125.

Once Uninett/Argus#161 is merged, the filterable incident endpoints will send three different types of details_urls:

  • Empty string
  • Relative url, because the source system does not have base_url set, and the source sends relative urls
  • Absolute url

Relative urls should not be turned into links.

Code formatting does not reflect description in README.md

The current README.md describes the use of the formatting tool prettier as if it is used uniformly throughout the project. This does not seem like it is the case, because running the formatter using default settings on src/ results in +887, -842 (32 files) and a modified version as described in #68 results in +796, -949 (32 files).

There is no description of a configuration, so I conclude that the README.md description is invalid. Use of a formatter is desirable, so how should the project move forward. Should we use it on only new code, on all files we modify, on the entire source tree, or something else?

Polish: Remove any mention of slack

We're not supporting Slack yet, so remove it everywhere.

Problem: ProfileList.mediaOptions is hard coded. For media where everything can be configured simply (like for email or sms since there is table support for these) these should be looked up via an endpoint. If the configuration of media is made very dynamic and possible via this front-end, a new front-end must be released for every new notification media. Something to keep in mind for Uninett/Argus#121.

Incident details dialog/modal

Clicking on an Incident description in the incident list should open a modal showing fuller details of the incident. I.e. the modal should repeat the information from the incident table entry, but also "everything else" related to the Incident, such as:

  • A list/table summarizing the Incident's related Events.
  • A list of tags attached to the Incident.
    • Any tag value that can be parsed as an URL should be clickable.
  • An interface to add/edit/hyperlink the ticket url of the Incident.

Add UI to enable manual linking of Incidents

The Argus data model supports the notion of registering relations between alerts. The nature of a relation is entirely up to the user, which can add new relation types.

We need to discuss how to build a UI to enable manually adding relations between alerts.

Examples could be:

  • Selecting a set of individual Incidents, and relate them all to each other, to describe, e.g., that these Incidents really are the same thing from different subsystems
  • Saying one Incident is caused by another.
  • Grouping Incidents to say that they have the same root cause.

Add interface to manually resolve an open Incident

Once Uninett/Argus#73 is implemented, the frontend must provide the user with a function to manually resolve an open Incident.

For individual Incidents, this can be made accessible through the Incident details dialog box.

Manually closing an incident should not be easy to do by accident. There should also be the option to add a message string, explaining why an Incident was resolved manually.

Filters should be testable against specific incidents

A suggestion from SUNET is to be able to test filters against specific incidents (not just as a preview filter on all incidents), from within the interface where they are built.

Not entirely sure whether this belongs in the frontend or backend, so please move at will.

Fix HTML title of app

The HTML title of the app reads React app. This needs to be updated to the proper name of the app, once the new official name has beed decided.

New logo

Attached is a proposal for a new logo. The zip file contains the svg.
argus

argus.zip

Add interface to submit Incident Acknowledgements

Once Uninett/Argus#72 is implemented, the Incident details dialog box must implement an action button to create and submit a new acknowledgement.

  • A user should potentially always be allowed to change the expiry time of a previous acknowledgement, but only if it has not already expired (if an ack has expired, make a new one!).

Fix problems with frontend not recognizing when an authentication token is no longer valid

The frontend fails to recognize when a token that is stored in LocalStorage is no longer valid.

Proposed solution:

  • Check for 401 Unauthorized return codes when accessing the API by using a wrapper function for for all API calls

Downsides with this solution:

  • May need to create a wrapper function for all API requests. This will probably require lots of small changes in the codebase.

Feature: Filter incidents by source system type

We need to be able to make notification filters based on source type (just all navs). I suggest reusing tag-filters, by sending tags of the type source_system_type=nav. (Or maybe source_type=nav?)

Later, it would be useful to filter the table on source type as well.

See Uninett/Argus#117 for relevant backend issue.

User names on Acks and Events are missing from the Incident details modal

The acknowledgement and event lists in the Incident details modal only display the integer user id, which is opaque and useless for an end user. These components should both display user names.

ATM, user data is not inlined by the API endpoints used to fetch event logs and incident acknowledgements, so that the user details need to be fetched from the /api/v1/auth/users/<int:pk>/ endpoint.

However, it is reasonable to assume that the username is always interesting for most consumers of the API, so we should post a corresponding issue for the backend to inline these details in the mentioned endpoints.

timeslots view fails to properly handle multiple days with same start and end time

When you are creating a time-slot that has more than one day with the same start and end time, for example the following:
image

You get the following result:
image

Problem:

  • Instead of creating a "time interval" with multiple days for the same interval, for example; every mon, tue, wed from 08:15 - 12:00, it will create a new "time interval" for each day resulting in every mon 08:15-12:00, tue 08:15-12:00, wed 08:15-12:00.

Use of TypeScript features should be increased

While the current (f7ca589) code base utilizes TypeScript, the use of TypeScript-specific features could probably improve the quality of the codebase.

As an example we get the following result when running ripgrep with the --count flag searching for instances of the Any type in src/:

$ rg -c ':[ ]*any'
components/dialogue/Dialogue.tsx:1
components/profile/Profile.tsx:19
components/profileList/ProfileList.tsx:28
components/time-slot/TimeSlot.tsx:15
components/header/Header.tsx:2
components/time-interval/TimeIntervals.tsx:25
components/react-table/Table.tsx:3
components/filterBuilder/filterBuilder.tsx:6
components/time-interval-select/TimeInterval.tsx:7
auth.tsx:2
handleFeide.tsx:1
views/loginView/LoginView.tsx:1
views/filterBuildingView/filterBuildingView.tsx:1
protected.route.tsx:1
store.tsx:2
views/alertView/AlertView.tsx:

It's not like using Any should be banned, but it's usage could certainly be reduced. It seems like it's used a lot when handling results from the backend api, which could be fixed by creating TypeScript interfaces.

As the codebase matures I think it would be useful to use static typing, in addition to other features of TypeScript, to a greater extent than it is now.

Add acknowledgements list to incident details dialog box

Once Uninett/Argus#72 is implemented, the Incident details dialog box should also display a list/table of known acknowledgments related to the Incident.

This list/table should contain:

  • Who made the ack
  • When the ack was made
  • The message string of the ack
  • The expiry time of the ack, if set

Expired acks should be distinguished. Suggestion: Use a strikethrough for all text on the ack line.

Hyperlink to source system incident details is broken

As mentioned in #93 (comment), the hyperlink to the source system's incident details on the incident details model is broken.

The Incident record itself may contain relative URLs. If a URL is not a fully qualified URL, the hyperlink should be constructed using the base_url present in the source system definition as a prefix. Example output from the Incident endpoint:

[
  {
    "pk": 18,
    "start_time": "2020-09-14T17:06:49.983721+02:00",
    "end_time": "infinity",
    "source": {
      "pk": 1,
      "name": "testnav",
      "type": {
        "name": "nav"
      },
      "user": 2,
      "base_url": "http://localhost:9080/"
    },
    "source_incident_id": "199420",
    "details_url": "/search/event/199420",
    "description": "Link DOWN on A1 at example-sw.example.org (4.kx042)",
    "ticket_url": "",
    "tags": []
  }
]

The URL may also be a fully qualified URL, in which case it is ok to use it unchanged.

Columns in alert-overview should not be equal width

For instance "source" should be no wider than the widest possible source + padding for readability. The timestamp has an absolute fixed size and should not ever be wider than it needs to be. "Description" needs the most space and should be wider than all the rest.

Polish: ticket url in details-box

  1. When opening the details box, the ticket url is highlighted in red and marked as invalid. Not having a ticket-url is perfectly valid!
  2. Clicking on the red line moves "ticket" up and down.
  3. It looks like it is possible to edit the ticket without clicking "Edit" first. Fixing 1 might also fix this.

Support bulk operations on open Incidents list

The page that lists open incidents should have UI elements to mark multiple Incidents and run various bulk operations against them:

  • Manually resolve the selected Incidents, as described in #96
  • Post the same Acknowledgment for each of the selected Incidents, as described in #95

Use consistent DateTimes

The datepicker for setting an ack's expiry date is hardcoded to US dates.
It is hard-coded to MM/dd/yyyy. It should use whatever the locale uses. (Preferably by something looking up the locale's date-format and storing it in a variable so that it can be overridden by the members of the Church of ISO 8601 later =) )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.