Commit 33718e2f authored by Rainer Türner's avatar Rainer Türner
Browse files

MVP v1 developments by Net Group

parent 8544dc74
Pipeline #3774 failed with stages
in 0 seconds
ARG node_version=node:lts
ARG nginx_version=nginx:1.21.6-alpine
ARG sonarscanner_version=sonarsource/sonar-scanner-cli
FROM $node_version as image
WORKDIR /usr/monitoring
COPY ./package*.json ./
FROM image AS build
RUN npm ci
COPY . .
RUN npm run test:coverage
RUN npm run build
FROM $sonarscanner_version as sonar
COPY --from=build ./usr/monitoring .
RUN sonar-scanner $sonarscanner_params
FROM $nginx_version
COPY ./nginx/https-nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build ./usr/monitoring/build /usr/share/nginx/html/monitoring
CMD ["nginx", "-g", "daemon off;"]
# monitoring-module
# Getting Started with Create React App
This project was bootstrapped with [Create React App](
## Available Scripts
## Getting started
In the project directory, you can run:
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
### `npm start`
Already a pro? Just edit this and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
## Add your files
The page will reload if you make edits.\
You will also see any lint errors in the console.
- [ ] [Create]( or [upload]( files
- [ ] [Add files using the command line]( or push an existing Git repository with the following command:
### `npm test`
cd existing_repo
git remote add origin
git branch -M main
git push -uf origin main
Launches the test runner in the interactive watch mode.\
See the section about [running tests]( for more information.
## Integrate with your tools
### `npm run build`
- [ ] [Set up project integrations](
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
## Collaborate with your team
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
- [ ] [Invite team members and collaborators](
- [ ] [Create a new merge request](
- [ ] [Automatically close issues from merge requests](
- [ ] [Enable merge request approvals](
- [ ] [Automatically merge when pipeline succeeds](
See the section about [deployment]( for more information.
## Test and Deploy
### `npm run eject`
Use the built-in continuous integration in GitLab.
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
- [ ] [Get started with GitLab CI/CD](
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](
- [ ] [Use pull-based deployments for improved Kubernetes management](
- [ ] [Set up protected environments](
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
# Editing this README
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to []( for this template.
## Learn More
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
You can learn more in the [Create React App documentation](
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
To learn React, check out the [React documentation](
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
\ No newline at end of file
server {
server_name localhost;
listen 8443;
server_tokens off;
add_header Access-Control-Allow-Origin *;
location / {
root /usr/share/nginx/html/monitoring;
try_files $uri /index.html;
location /status {
access_log off;
default_type text/plain;
add_header Content-Type text/plain;
return 200 "alive";
server {
listen 80;
server_name localhost;
return 301 https://$host$request_uri;
server {
server_name localhost;
listen 8443 ssl;
ssl_certificate /etc/tls/tls.crt;
ssl_certificate_key /etc/tls/tls.key;
server_tokens off;
location / {
root /usr/share/nginx/html/monitoring;
try_files $uri /index.html;
location /status {
access_log off;
default_type text/plain;
add_header Content-Type text/plain;
return 200 "alive";
server {
listen 80;
server_name localhost;
return 301 https://$host$request_uri;
This diff is collapsed.
"name": "byk-monitoring",
"version": "0.1.0",
"private": true,
"dependencies": {
"@reduxjs/toolkit": "^1.6.1",
"@types/jest": "^24.9.1",
"@types/node": "^12.20.27",
"@types/react": "^16.14.16",
"@types/react-dom": "^16.9.14",
"@types/react-redux": "^7.1.18",
"@types/react-router-dom": "^5.3.0",
"@types/styled-components": "^5.1.18",
"axios": "^0.22.0",
"classnames": "^2.3.1",
"cross-env": "^7.0.3",
"framer-motion": "4.1.17",
"i18next": "^21.2.4",
"i18next-browser-languagedetector": "^6.1.2",
"linkify-react": "^3.0.3",
"linkifyjs": "^3.0.4",
"luxon": "^2.2.0",
"primeflex": "^3.1.2",
"primeicons": "^5.0.0",
"primereact": "^7.2.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-i18next": "^11.12.0",
"react-redux": "^7.2.5",
"react-router": "5.2.1",
"react-router-dom": "^5.3.0",
"react-transition-group": "^4.4.2",
"rxjs": "^7.5.5",
"sass": "^1.42.1",
"styled-components": "^5.3.3",
"timeago.js": "^4.0.2"
"devDependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^10.4.9",
"@testing-library/user-event": "^7.2.1",
"@types/luxon": "^2.0.8",
"react-scripts": "5.0.1",
"eslint": "^8.15.0",
"eslint-config-react-app": "^7.0.1",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.3.0",
"history": "^5.1.0",
"husky": "^7.0.0",
"msw": "^0.36.3",
"prettier": "2.4.1",
"typescript": "^4.4.4"
"scripts": {
"start": "cross-env PORT=3003 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --watchAll=false",
"test:watch": "react-scripts test",
"test:coverage": "cross-env CI=true npm run test -- --env=jsdom --coverage",
"lint": "eslint src --ext .js,.ts,.jsx,.tsx",
"lint:fix": "npm run lint -- --fix",
"prettier:check": "prettier --check \"{,src/**/,webpack/}*.{json,yml,html,js,ts,tsx,css,scss}\"",
"prettier:format": "prettier --write \"{,src/**/,webpack/}*.{json,yml,html,js,ts,tsx,css,scss}\"",
"prepare": "husky install"
"browserslist": {
"production": [
"not dead",
"not op_mini all"
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
"jest": {
"collectCoverageFrom": [
"coveragePathIgnorePatterns": [
"coverageThreshold": {
"global": {
"functions": 70,
"lines": 70
"coverageReporters": [
window._env_ = {
RUUTER_API_URL: 'http://localhost:8443',
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<script src="%PUBLIC_URL%/env-config.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
content="Bürokrati seiremoodul"
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
User-agent: *
.App {
text-align: center;
.App-logo {
height: 40vmin;
pointer-events: none;
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
.App-link {
color: #61dafb;
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
to {
transform: rotate(360deg);
import React from 'react';
import { render } from '@testing-library/react';
import { Provider } from "react-redux";
import { configureStore, EnhancedStore } from "@reduxjs/toolkit";
import App from './App';
import componentsReducer, { ComponentsState } from './slices/components.slice';
let testStore: EnhancedStore;
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: (str: string) => str,
i18n: {
language: 'et',
options: {
supportedLngs: ['et'],
const componentsState: ComponentsState = {
components: [],
requestFailed: false,
describe('App component', () => {
beforeEach(() => {
testStore = configureStore({
reducer: {
components: componentsReducer
preloadedState: {
components: componentsState
it('should render', () => {
<Provider store={testStore}>
<App />
import React, { ReactElement, useEffect } from 'react';
import './App.css';
import styled from 'styled-components';
import { useTranslation } from 'react-i18next';
import ComponentItem from './components/component-item';
import TopBar from './components/top-bar';
import { FETCH_INTERVAL_MS } from './utils/constants';
import { getComponentHealthzStatus } from './slices/components.slice';
import { useAppDispatch, useAppSelector } from './store';
import { Component } from './model/component.model';
declare global {
interface Window {
_env_: {
const App = (): ReactElement => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const components = useAppSelector((state) => state.components.components);
const requestFailed = useAppSelector((state) => state.components.requestFailed);
useEffect(() => {
setInterval(() => dispatch(getComponentHealthzStatus()), FETCH_INTERVAL_MS);
}, [dispatch]);
return (
<TopBar />
{!requestFailed ? Component) =>
<ComponentItem key={} name={} version={module.version}/>) :
<div className="fetchError">{t('app.requestFailed')}</div>
const AppStyles = styled.div`
.fetchError {
display: flex;
flex-direction: row;
width: 30%;
margin: 1rem auto;
justify-content: center;
font-size: medium;
export default App;
import React from 'react';
import { render, screen } from '@testing-library/react';
import ComponentItem from "./component-item";
describe('Component item component', () => {
it('should render component name and version', () => {
render(<ComponentItem name="ruuter" version="1.3" />);
screen.getByText('@ version 1.3');
import React from 'react';
import styled from 'styled-components';
import { COMPONENT_STATUS } from '../utils/constants';
const ComponentItem = (props: { name: string, version: string }): JSX.Element => {
const { name, version } = props;
return (
<div className="left-container">
<div className="name">{name}</div>&nbsp;
{version && <div className="version">{` @ version ${ version}`}</div>}
<div className={version ? 'status ok' : 'status not-ok'}>{version ? COMPONENT_STATUS.OPERATIONAL : COMPONENT_STATUS.NON_OPERATIONAL}</div>
const ComponentItemStyles = styled.div`
display: flex;
flex-direction: row;
border: 1.5px solid #003cff;
box-shadow: 2px 2px 4px #adc0ff;
width: 50%;
height: 3.5rem;
margin: 0.8rem auto;
justify-content: space-between;
align-items: center;
.left-container {
display: flex;
flex-direction: row;
margin: 1rem;
.status {
margin: 1rem;
.status {
font-size: larger;
.ok {
color: #52a980;
.not-ok {
color: #FF6130;
export default ComponentItem;
import React from 'react';
import { render, screen } from '@testing-library/react';
import TopBar from "./top-bar";
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: (str: string) => str,
i18n: {
language: 'et',
options: {
supportedLngs: ['et'],
describe('Top bar component', () => {
it('should render header text', () => {
render(<TopBar />);
import React from 'react';
import styled from 'styled-components';
import { useTranslation } from 'react-i18next';
import logo from '../static/buerokratt.svg';
const TopBar = (): JSX.Element => {
const { t } = useTranslation();
return (
<img className="logo" alt="logo" src={logo} width="40px"/>
<p className="header">{t('topBar.header')}</p>
const TopBarStyles = styled.div`
background-color: #003cff;
border: 0;
border-radius: 0;
min-height: 50px;
max-height: 50px;
padding: 0;
position: sticky;
top: 0;
z-index: 900;
display: flex;
flex-direction: row;
align-items: center;
.logo {
padding: 0.25em;
margin-left: 1em;
margin-right: 0.8em;
.header {