Skip to content

Commit

Permalink
Add small sized toolbar toggle for embedded applications (#163)
Browse files Browse the repository at this point in the history
* Add customization to switch to the small toolbar

* Create a small toolbar style

* Fix duplicate icons names

* Remove faulty border radius

* Brign back the background light for the small toolbar

* Update documentation with more clear sturcuture

* Add documentation on the compact modes

* Switch NodePort to ClusterIP

* Fix Raspberry Pi naming
  • Loading branch information
rick-nu committed Feb 18, 2020
1 parent d94da0d commit 2d3fa34
Show file tree
Hide file tree
Showing 22 changed files with 455 additions and 91 deletions.
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ init: intro do-pre-init do-run-updates do-show-commands outro
update: intro do-switch-branch do-run-updates outro
pr: intro do-checkout-pr do-run-updates outro

build-production: intro do-build-production outro
build-docs: intro do-build-docs outro
preview-docs: intro do-preview-docs outro

dev-server: intro do-dev-server outro
dev-module-client: intro do-dev-module-client outro
dev-dashboard: intro do-dev-dashboard outro
build-production: intro do-build-production outro
dev-docs: intro do-preview-docs outro

build-containers: intro do-backup-dependencies do-build-production do-build-containers do-restore-dependencies outro
run-container: intro do-run-container outro
Expand Down Expand Up @@ -65,13 +65,12 @@ do-show-commands:
@echo " make fix Fix most of the codestyle errors."
@echo "\nLocal installation:"
@echo " make build-production Build all the files required for production."
@echo "\nDocumentation:"
@echo " make build-docs Build the documentation."
@echo " make preview-docs Run a live preview of the documentation."
@echo "\nDevelopment:"
@echo " make dev-server Run the development server."
@echo " make dev-module-client Run the development module client, listening to a master."
@echo " make dev-dashboard Build, run and watch the development dashboard."
@echo " make dev-docs Run a live preview of the documentation."
@echo "\nDocker containers:"
@echo " make build-containers Builds the Docker containers."
@echo " make run-container Run the built Docker container."
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions docs/feature/compact-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Compact mode

The compact modus is very interesting if you want to run CIMonitor in an iframe for a dashboard or
any other webpage.

## Preview

![](../img/compact-mode.gif)

## Embedding

```html
<iframe src="YOUR CI MONITOR URL">
<p>Your browser does not support iframes.</p>
</iframe>
```

**Note:** If your CIMonitor is running on an insecure http page, a page with your iframe with https will not
be able to display your CIMonitor. Make sure both are running on a secure https URL.
4 changes: 2 additions & 2 deletions docs/module-client.md → docs/feature/linking-cimonitors.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Module client
# Linking CIMonitors together

@todo: Explain that you can run a `back-end/module-client.js` application that connects to the `back-end/server.js` application socket

![](img/master-slave-setup.png)
![](../img/master-slave-setup.png)

@todo: Explain that the slave can have its own configuration, with its own modules and triggers.
Binary file added docs/img/compact-mode.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions docs/run/as-service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Requirements

Setting up CIMonitor is quick and easy. You need to have the following packages before we can get started:

- [make](https://www.gnu.org/software/make/) (should already be present on linux and osx in developers mode)
- [yarn](https://yarnpkg.com/): alternative to NPM
- [node](https://nodejs.org/en/download/): version 10 or higher (recommended
to install via [NVM](https://github.com/creationix/nvm#installation))

# Download and prepare

Clone or download the latest CIMonitor via [github.com/cimonitor/cimonitor](https://github.com/cimonitor/cimonitor)
(press the green button).

## Configuration

In the folder you just downloaded, you need to create the primary config file. Create the file
`config/config.json` in the project directory. You could also copy the `config.example.json` file
you find there.

Make sure at least the following configuration is in your config file:

```json
{
"server": {
"port": 9999
},
"triggers": [],
"events": [],
"modules": []
}
```

For advanced configuration options, check out [the configuration page](configuration.md).
To store the config in Google Firebase instead of a local JSON file, see [the Firebase page](../advanced/firebase.md).

Open your terminal in the folder you just downloaded, and run the following command:

```sh
$ make build-production
```

This will download the required dependencies, and build the project files.

# Run the server application

Now that you have everything prepared, you can start the server application with the following command:

```sh
$ node server/server.js
```

You can now visit the dashboard via the browser at the given URL, or push statuses directly to the configured port.

If you want to run the application as a service, check out the [run as a service page](../run/run-as-service.md). This way the
monitor will keep running without having to keep a terminal open.

# Updating server application

Easiest update would be using git, where you can just pull the latest version from master. If you downloaded a zip
file, make sure you copy the following files to the new files:

- `config/config.json`
- `config/saved-statuses.json`

**Note:** After you pulled the updates, always run the production build again:

```sh
$ make build-production
```

Restart your server application and that's it!


# Keep it running

@todo: Explain [pm2](http://pm2.keymetrics.io/).
2 changes: 1 addition & 1 deletion docs/setup/run-with-docker.md → docs/run/on-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ find all available tags on the [docker hub](https://hub.docker.com/u/cimonitor/)
## Running the docker container

To run CIMonitor there is one file you need to prepare, being the config file. Make sure you've set up the configuration file
as described on [the configuration page](./configuration.md).
as described on [the configuration page](../setup/configuration.md).

Optionally, you can provide another json file to store CIMonitor's statuses in. This can be an empty json file, that will be filled
by the container once it's running. This way the statuses won't be lost when you restart the container.
Expand Down
156 changes: 156 additions & 0 deletions docs/run/on-kubernetes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Run on Kubernetes

## Run directly

Note: If you want to customize the configuration, you are required to link Firebase. See the
[firebase documentation](../advanced/firebase.md) on how to do that.

Note that you shouldn't be running more than 1 replica.

```yml
kind: Namespace
apiVersion: v1
metadata:
name: cimonitor

---

apiVersion: apps/v1
kind: Deployment
metadata:
name: cimonitor-server
namespace: cimonitor
labels:
app: cimonitor-server
spec:
replicas: 1
selector:
matchLabels:
app: cimonitor-server
template:
metadata:
labels:
app: cimonitor-server
spec:
containers:
- image: cimonitor/server:latest
name: cimonitor-server-container
imagePullPolicy: Always
resources:
requests:
memory: "16Mi"
cpu: "10m"
limits:
memory: "256Mi"
cpu: "500m"
ports:
- containerPort: 9999
env:
- name: APP_ENV
value: production

---

apiVersion: v1
kind: Service
metadata:
name: cimonitor-server-service
namespace: cimonitor
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 9999
selector:
app: cimonitor-server

---

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: cimonitor-server-ingress
namespace: cimonitor
annotations:
kubernetes.io/tls-acme: "true"
kubernetes.io/ingress.class: "nginx"
cert-manager.io/cluster-issuer: "letsencrypt-prod"
cert-manager.io/acme-challenge-type: http01
spec:
tls:
- secretName: cimonitor-server-tls
hosts:
- YOUR_HOST_ADDRESS
rules:
- host: YOUR_HOST_ADDRESS
http:
paths:
- path: /
backend:
serviceName: cimonitor-server-service
servicePort: 80
```
## With firebase config
Create a firebase secret, containing your firebase service account private key json:
```
export FIREBASE_PRIVATE_KEY=$(cat/YOUR-FIREBASE-ACCOUNT-PRIVATE-KEY-FILE.json)

kubectl create secret generic firebase-private-key \
--namespace cimonitor \
--from-file=firebase-private-key.json=$FIREBASE_PRIVATE_KEY
```

Use the top example, except replace the deployment:

```yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: cimonitor-server
namespace: cimonitor
labels:
app: cimonitor-server
spec:
replicas: 1
selector:
matchLabels:
app: cimonitor-server
template:
metadata:
labels:
app: cimonitor-server
spec:
volumes:
- name: firebase-private-key
secret:
secretName: firebase-private-key
containers:
- image: cimonitor/server:latest
name: cimonitor-server-container
imagePullPolicy: Always
resources:
requests:
memory: "16Mi"
cpu: "10m"
limits:
memory: "256Mi"
cpu: "500m"
ports:
- containerPort: 9999
env:
- name: FIREBASE_PRIVATE_KEY_FILE
value: "/etc/firebase-secrets/firebase-private-key.json"
- name: FIREBASE_URL
value: "https://YOUR_UNIQUE_FIREBASE_SLUG.firebaseio.com/"
- name: STORAGE
value: "firebase"
- name: APP_ENV
value: production
volumeMounts:
- name: firebase-private-key
readOnly: true
mountPath: "/etc/firebase-secrets"
```
2 changes: 1 addition & 1 deletion docs/setup/Raspberry.md → docs/run/on-raspberry.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Installing raspberry PI 3 model B
# Installing Raspberry Pi 3 model B

To start off, we expect you to have Raspbian installed. This can easily be done via
NOOBS from https://www.raspberrypi.org/downloads/noobs/. Handy video for that:
Expand Down
77 changes: 14 additions & 63 deletions docs/setup/CIMonitor.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,23 @@
# Requirements
# Setup CIMonitor

Setting up CIMonitor is quick and easy. You need to have the following packages before we can get started:
There are multiple ways you can run CIMonitor. The quickest and easiest is running it via docker.

- [make](https://www.gnu.org/software/make/) (should already be present on linux and osx in developers mode)
- [yarn](https://yarnpkg.com/): alternative to npm
- [node](https://nodejs.org/en/download/): version 8 or higher (recommended
to install via [NVM](https://github.com/creationix/nvm#installation))
## Run on Docker (quickest)

# Download and prepare
You can very easily run CIMonitor if you have docker installed. See how to do that at
[running CIMonitor on docker](../run/on-docker.md).

Clone or download the latest CIMonitor via [github.com/cimonitor/cimonitor](https://github.com/cimonitor/cimonitor)
(press the green button).
## Run on a Raspberry Pi (recommended when using modules)

## Configuration
If you want to use some of the awesome modules that are build for CIMonitor, then
[running CIMonitor on a Raspberry Pi](../run/on-raspberry.md) is most suited for you.

In the folder you just downloaded, you need to create the primary config file. Create the file
`config/config.json` in the project directory. You could also copy the `config.example.json` file
you find there.
## Run as a service (build it yourself)

Make sure at least the following configuration is in your config file:
If you want to run the projects from its source code, take a look at
[running CIMonitor as a service](../run/as-service.md).

```json
{
"server": {
"port": 9999
},
"triggers": [],
"events": [],
"modules": []
}
```
## Run on Kubernetes

For advanced configuration options, check out [the configuration page](configuration.md).
To store the config in Google Firebase instead of a local JSON file, see [the Firebase page](Firebase.md).

Open your terminal in the folder you just downloaded, and run the following command:

```sh
$ make build-production
```

This will download the required dependencies, and build the project files.

# Run the server application

Now that you have everything prepared, you can start the server application with the following command:

```sh
$ node server/server.js
```

You can now visit the dashboard via the browser at the given URL, or push statuses directly to the configured port.

If you want to run the application as a service, check out the [run as a service page](run-as-service.md). This way the
monitor will keep running without having to keep a terminal open.

# Updating server application

Easiest update would be using git, where you can just pull the latest version from master. If you downloaded a zip
file, make sure you copy the following files to the new files:

- `config/config.json`
- `config/saved-statuses.json`

**Note:** After you pulled the updates, always run the production build again:

```sh
$ make build-production
```

Restart your server application and that's it!
If you want to run CIMonitor in your Kubernetes cluster, see how to do that at
[running CIMonitor on Kubernetes](../run/on-kubernetes.md).
Loading

0 comments on commit 2d3fa34

Please sign in to comment.