From 9be859a22a094ba4b750b2cc35daeca5230a0ec2 Mon Sep 17 00:00:00 2001 From: Martin Karkowski Date: Thu, 21 Jan 2021 15:32:51 +0100 Subject: [PATCH] adding docker files --- .dockerignore | 3 + 05-WAMO-Demo.bat | 4 + Dockerfile | 13 +++ resources/admin-shell/host.tsx | 173 +++++++++++++++++++++++++++++++++ 4 files changed, 193 insertions(+) create mode 100644 .dockerignore create mode 100644 05-WAMO-Demo.bat create mode 100644 Dockerfile create mode 100644 resources/admin-shell/host.tsx diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..649fffa --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +npm-debug.log +.git \ No newline at end of file diff --git a/05-WAMO-Demo.bat b/05-WAMO-Demo.bat new file mode 100644 index 0000000..7c242ef --- /dev/null +++ b/05-WAMO-Demo.bat @@ -0,0 +1,4 @@ +set DIR=%~dp0 +cd "%DIR%" +node .\dist\lib\cli\runNopeBackend.js -c io-server -l info -f ./config/settings_wamo_ips.json +pause \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b7fab11 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:latest + +RUN mkdir /nope +COPY . /nope/ + +# Create a Volume containg the configuration +WORKDIR /nope + +# Install Binaries +RUN npm install + +# Execute the Kernel +CMD ["node","./dist/lib/cli/runNopeBackend.js", "-c","io-server","-l","info","-f","./config/settings_wamo_ips.json"] diff --git a/resources/admin-shell/host.tsx b/resources/admin-shell/host.tsx new file mode 100644 index 0000000..ecaf97a --- /dev/null +++ b/resources/admin-shell/host.tsx @@ -0,0 +1,173 @@ +/** + * @author Martin Karkowski + * @email m.karkowski@zema.de + * @create date 2021-01-12 16:44:15 + * @modify date 2021-01-12 16:44:15 + * @desc [description] + */ + +import React from "react"; +import { Badge, Card, ProgressBar, Table } from "react-bootstrap"; +import { ENopeDispatcherStatus } from "../../lib/types/nope/nopeDispatcher.interface"; + +/** + * Component used to render the Status of the Memory of a Host. + */ +export class MemoryStatusOfHostComponent extends React.Component< + { + value: number; + }, + {} +> { + render() { + // Determine the Now Value. + const now = Math.round(1000 - this.props.value * 1000) / 10; + const colorRange = { + "0": "success", + "30": "success", + "75": "warning", + "90": "danger", + "101": "danger" + }; + + // Determine the Color, Therefore filter the "keys" based on the now Value. + const color = + colorRange[ + Object.getOwnPropertyNames(colorRange).filter( + (value) => now < parseFloat(value) + )[0] + ]; + + // Render + return ( + <> + + + ); + } +} + +export class HostStatusComponent extends React.Component< + { + status: { + cpu: string; + cores: number; + os: string; + ram: number; + name: string; + pids: { + pid: number; + dispatchers: { + id: string; + status: ENopeDispatcherStatus; + timestamp: number; + }[]; + }[]; + status: ENopeDispatcherStatus; + timestamp: number; + }; + }, + { + lastUpdate: string; + variant: "success" | "warning" | "danger"; + badge: boolean; + badgeText: string; + } +> { + protected _intervall: any = null; + + get _state() { + const dict = { + 0: "success", + 1: "info", + 2: "warning", + 3: "danger" + }; + + return { + lastUpdate: new Date(this.props.status.timestamp).toISOString(), + variant: dict[this.props.status.status], + badge: this.props.status.status !== ENopeDispatcherStatus.HEALTHY, + badgeText: ENopeDispatcherStatus[this.props.status.status] + }; + } + + constructor(props) { + super(props); + this.state = this._state; + } + + componentDidMount(): void { + const _this = this; + this._intervall = setInterval(() => { + _this.setState(this._state); + }, 200); + } + + componentWillUnmount(): void { + if (this._intervall) { + clearInterval(this._intervall); + } + } + + render(): JSX.Element { + return ( + + + + {" "} + {this.state.badge ? ( + <> + {this.props.status.name}{" "} + + ELEMENT {this.state.badgeText} ! + {" "} + + ) : ( + <>{this.props.status.name} + )}{" "} + + + + {this.props.status.ram > 0 ? ( + + + + + ) : ( + <> + )} + + + + + + + + + + + + + + + + + +
RAM + {" "} + {/* Rendert the Memory */} + +
CPU{this.props.status.cpu}
Cores{this.props.status.cores}
Platform{this.props.status.os}
Nope-Processes{this.props.status.pids.length}
+
+ + + Last updated {this.state.lastUpdate} + + +
+ ); + } +}