Skip to content
This repository was archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
[#25] schema based forms
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Pozzi committed Sep 24, 2020
1 parent ee8903c commit 26102cb
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/source/labels.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* **capability** The capability the service provides for the business, or in case of infrastructure the technical capability like enabling service discovery, configuration, secrets or persistence.
* **costs** Running costs of the item.
* **fill** Background image (for displaying purposes)
* **health** description of the item's health status
* **layer** a technical layer
* **lifecycle** A lifecycle phase (PLANNED|plan, INTEGRATION|int, PRODUCTION|prod, END_OF_LIFE|eol|end)
Expand Down
2 changes: 2 additions & 0 deletions src/main/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@rjsf/core": "^2.4.0",
"@rjsf/material-ui": "^2.4.0",
"@stomp/stompjs": "^5.4.4",
"@types/dateformat": "^3.0.1",
"@types/jest": "^26.0.5",
Expand Down
2 changes: 2 additions & 0 deletions src/main/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Routes } from './interfaces';
import './App.scss';
import { ThemeProvider } from '@material-ui/core/styles';
import theme from './Ressources/styling/theme';
import NivioEditor from "./Components/Editor/NivioEditor";

const App: React.FC = () => {
return (
Expand All @@ -21,6 +22,7 @@ const App: React.FC = () => {
<Layout>
<Route exact path='/' component={LandscapeOverview} />
<Route exact path='/events' component={Events} />
<Route exact path='/editor' component={NivioEditor} />
<Route exact path={Routes.MAP_ROUTE} component={LandscapeMap} />
<Route exact path='/man/:usage' component={Man} />
<Route exact path={Routes.DASHBOARD_ROUTE} component={LandscapeDashboard} />
Expand Down
9 changes: 9 additions & 0 deletions src/main/app/src/Components/Editor/Editor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

$dotSize: 170px;
$smallDotSize: 30px;

.editor {
background-color: white;
text-shadow: none;
color: black;
}
25 changes: 25 additions & 0 deletions src/main/app/src/Components/Editor/NivioEditor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { useState, useEffect } from 'react';
import { withTheme } from '@rjsf/core';
import { Theme as MaterialUITheme } from '@rjsf/material-ui';
import './Editor.scss';

const Form = withTheme(MaterialUITheme);
const schema = require('./nivio_schema.json');

const NivioEditor = () => {
const [yourJson, setYourJson] = useState<any | null>({ identifier: null });

const onSubmit = (val: any) => {
setYourJson(val);
console.log(val);
};

//https://github.com/vankop/jsoneditor-react/blob/master/src/Editor.jsx
return (
<div className={'editor'}>
<Form schema={schema} onSubmit={(val) => onSubmit(val)} />
</div>
);
};

export default NivioEditor;
47 changes: 47 additions & 0 deletions src/main/app/src/Components/Editor/nivio_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$id": "https://dedica.team/nivio.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Nivio DSL",
"description": "A landscape configuration",
"definitions": {
"Item": {
"type": "object",
"properties": {
"identifier": {
"type": "string",
"description": "Identifier (must be unique in a group)"
},
"name": {
"type": "string",
"description": "Common name"
},
"group": {
"type": "string",
"description": "The name of the group the item belongs to."
}
}
}
},
"required": [ "identifier", "items" ],
"type": "object",
"properties": {
"identifier": {
"type": "string",
"description": "A unique identifier of the landscape"
},
"description": {
"type": "string",
"description": "A short description of the landscape"
},
"contact": {
"type": "string",
"description": "A contact address, preferably email."
},
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/Item"
}
}
}
}
3 changes: 3 additions & 0 deletions src/main/app/src/Components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ const Navigation: React.FC = () => {
<Button data-testid='EventsButton' component={Link} to={`/events`}>
Events
</Button>
<Button data-testid='EventsButton' component={Link} to={`/editor`}>
Editor
</Button>
</ButtonGroup>
<div className={classes.grow} />
</Toolbar>
Expand Down
2 changes: 1 addition & 1 deletion src/main/app/src/labels.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"capability":"The capability the service provides for the business, or in case of infrastructure the technical capability like enabling service discovery, configuration, secrets or persistence.","costs":"Running costs of the item.","health":"description of the item's health status","layer":"a technical layer","lifecycle":"A lifecycle phase (PLANNED|plan, INTEGRATION|int, PRODUCTION|prod, END_OF_LIFE|eol|end)","note":"a custom note","scale":"number of instances","security":"description of the item's security status","shortname":"abbreviated name","software":"Software/OS name","stability":"description of the item's stability","team":"Name of the responsible team (e.g. technical owner)","type":"the type (service, database, queue, loadbalancer...)","version":"The version (e.g. software version, protocol version)","visibility":"visibility to other items"}
{"capability":"The capability the service provides for the business, or in case of infrastructure the technical capability like enabling service discovery, configuration, secrets or persistence.","costs":"Running costs of the item.","fill":"Background image (for displaying purposes)","health":"description of the item's health status","layer":"a technical layer","lifecycle":"A lifecycle phase (PLANNED|plan, INTEGRATION|int, PRODUCTION|prod, END_OF_LIFE|eol|end)","note":"a custom note","scale":"number of instances","security":"description of the item's security status","shortname":"abbreviated name","software":"Software/OS name","stability":"description of the item's stability","team":"Name of the responsible team (e.g. technical owner)","type":"the type (service, database, queue, loadbalancer...)","version":"The version (e.g. software version, protocol version)","visibility":"visibility to other items"}
133 changes: 130 additions & 3 deletions src/main/app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,14 @@
"@babel/helper-plugin-utils" "^7.8.3"
"@babel/plugin-transform-typescript" "^7.9.0"

"@babel/runtime-corejs2@^7.8.7":
version "7.11.2"
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs2/-/runtime-corejs2-7.11.2.tgz#700a03945ebad0d31ba6690fc8a6bcc9040faa47"
integrity sha512-AC/ciV28adSSpEkBglONBWq4/Lvm6GAZuxIoyVtsnUpZMl0bxLtoChEnYAkP+47KyOCayZanojtflUEUJtR/6Q==
dependencies:
core-js "^2.6.5"
regenerator-runtime "^0.13.4"

"@babel/runtime-corejs3@^7.10.2", "@babel/runtime-corejs3@^7.8.3":
version "7.10.5"
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.10.5.tgz#a57fe6c13045ca33768a2aa527ead795146febe1"
Expand Down Expand Up @@ -1415,6 +1423,28 @@
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==

"@rjsf/core@^2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@rjsf/core/-/core-2.4.0.tgz#c50bcff0d8178948ce08123177399d8816d51929"
integrity sha512-8zlydBkGldOxGXFEwNGFa1gzTxpcxaYn7ofegcu8XHJ7IKMCfpnU3ABg+H3eml1KZCX3FODmj1tHFJKuTmfynw==
dependencies:
"@babel/runtime-corejs2" "^7.8.7"
"@types/json-schema" "^7.0.4"
ajv "^6.7.0"
core-js "^2.5.7"
json-schema-merge-allof "^0.6.0"
jsonpointer "^4.0.1"
lodash "^4.17.15"
prop-types "^15.7.2"
react-app-polyfill "^1.0.4"
react-is "^16.9.0"
shortid "^2.2.14"

"@rjsf/material-ui@^2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@rjsf/material-ui/-/material-ui-2.4.0.tgz#1b5859298bf3f61137d7b05084f058a775d6fd73"
integrity sha512-U8F/suzg4MuV+8mK1/ufs0Y6c3O8hc1wnuD2IKoOVJvegGfz5JCafyoyGAW6iyuT1DZBMPzVWEqfiuYPmoE7pw==

"@stomp/stompjs@^5.4.4":
version "5.4.4"
resolved "https://registry.yarnpkg.com/@stomp/stompjs/-/stompjs-5.4.4.tgz#f51d2edf9a00fac645dde3a494738d96ca17e5aa"
Expand Down Expand Up @@ -2096,6 +2126,16 @@ ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.2, ajv@^6.5.5:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"

ajv@^6.7.0:
version "6.12.5"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.5.tgz#19b0e8bae8f476e5ba666300387775fb1a00a4da"
integrity sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag==
dependencies:
fast-deep-equal "^3.1.1"
fast-json-stable-stringify "^2.0.0"
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"

alphanum-sort@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3"
Expand Down Expand Up @@ -3329,6 +3369,25 @@ compression@^1.7.4:
safe-buffer "5.1.2"
vary "~1.1.2"

compute-gcd@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/compute-gcd/-/compute-gcd-1.2.0.tgz#fc1ede5b65001e950226502f46543863e4fea10e"
integrity sha1-/B7eW2UAHpUCJlAvRlQ4Y+T+oQ4=
dependencies:
validate.io-array "^1.0.3"
validate.io-function "^1.0.2"
validate.io-integer-array "^1.0.0"

compute-lcm@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/compute-lcm/-/compute-lcm-1.1.0.tgz#abd96d040b41b0a166f89944b5c8b7c511e21ad5"
integrity sha1-q9ltBAtBsKFm+JlEtci3xRHiGtU=
dependencies:
compute-gcd "^1.2.0"
validate.io-array "^1.0.3"
validate.io-function "^1.0.2"
validate.io-integer-array "^1.0.0"

[email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
Expand Down Expand Up @@ -3438,7 +3497,7 @@ core-js-pure@^3.0.0:
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.6.5.tgz#c79e75f5e38dbc85a662d91eea52b8256d53b813"
integrity sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA==

core-js@^2.4.0:
core-js@^2.4.0, core-js@^2.5.7, core-js@^2.6.5:
version "2.6.11"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.11.tgz#38831469f9922bded8ee21c9dc46985e0399308c"
integrity sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg==
Expand Down Expand Up @@ -6786,6 +6845,22 @@ json-parse-better-errors@^1.0.1, json-parse-better-errors@^1.0.2:
resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"
integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==

json-schema-compare@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/json-schema-compare/-/json-schema-compare-0.2.2.tgz#dd601508335a90c7f4cfadb6b2e397225c908e56"
integrity sha512-c4WYmDKyJXhs7WWvAWm3uIYnfyWFoIp+JEoX34rctVvEkMYCPGhXtvmFFXiffBbxfZsvQ0RNnV5H7GvDF5HCqQ==
dependencies:
lodash "^4.17.4"

json-schema-merge-allof@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/json-schema-merge-allof/-/json-schema-merge-allof-0.6.0.tgz#64d48820fec26b228db837475ce3338936bf59a5"
integrity sha512-LEw4VMQVRceOPLuGRWcxW5orTTiR9ZAtqTAe4rQUjNADTeR81bezBVFa0MqIwp0YmHIM1KkhSjZM7o+IQhaPbQ==
dependencies:
compute-lcm "^1.1.0"
json-schema-compare "^0.2.2"
lodash "^4.17.4"

json-schema-traverse@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
Expand Down Expand Up @@ -6844,6 +6919,11 @@ jsonify@~0.0.0:
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
integrity sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=

jsonpointer@^4.0.1:
version "4.1.0"
resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.1.0.tgz#501fb89986a2389765ba09e6053299ceb4f2c2cc"
integrity sha512-CXcRvMyTlnR53xMcKnuMzfCA5i/nfblTnnr74CZb6C4vG39eu6w51t7nKmU5MfLfbTgGItliNyjO/ciNPDqClg==

jsprim@^1.2.2:
version "1.4.1"
resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2"
Expand Down Expand Up @@ -7153,6 +7233,11 @@ lodash.uniq@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==

lodash@^4.17.4:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==

loglevel@^1.6.6:
version "1.6.8"
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.8.tgz#8a25fb75d092230ecd4457270d80b54e28011171"
Expand Down Expand Up @@ -7561,6 +7646,11 @@ nan@^2.12.1, nan@^2.13.2:
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.1.tgz#d7be34dfa3105b91494c3147089315eff8874b01"
integrity sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==

nanoid@^2.1.0:
version "2.1.11"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.1.11.tgz#ec24b8a758d591561531b4176a01e3ab4f0f0280"
integrity sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==

nanomatch@^1.2.9:
version "1.2.13"
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
Expand Down Expand Up @@ -9319,7 +9409,7 @@ [email protected]:
iconv-lite "0.4.24"
unpipe "1.0.0"

react-app-polyfill@^1.0.6:
react-app-polyfill@^1.0.4, react-app-polyfill@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/react-app-polyfill/-/react-app-polyfill-1.0.6.tgz#890f8d7f2842ce6073f030b117de9130a5f385f0"
integrity sha512-OfBnObtnGgLGfweORmdZbyEz+3dgVePQBb3zipiaDsMHV1NpWm0rDFYIVXFV/AK+x4VIIfWHhrdMIeoTLyRr2g==
Expand Down Expand Up @@ -9376,7 +9466,7 @@ react-error-overlay@^6.0.7:
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.7.tgz#1dcfb459ab671d53f660a991513cb2f0a0553108"
integrity sha512-TAv1KJFh3RhqxNvhzxj6LeT5NWklP6rDr2a0jaTfsZ5wSZWHOGeqQyejUp3xxLfPt2UpyJEcVQB/zyPcmonNFA==

react-is@^16.12.0, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.0, react-is@^16.8.1, react-is@^16.8.4:
react-is@^16.12.0, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.9.0:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
Expand Down Expand Up @@ -10295,6 +10385,13 @@ shellwords@^0.1.1:
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==

shortid@^2.2.14:
version "2.2.15"
resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.15.tgz#2b902eaa93a69b11120373cd42a1f1fe4437c122"
integrity sha512-5EaCy2mx2Jgc/Fdn9uuDuNIIfWBpzY4XIlhoqtXF6qsf+/+SGZ+FxDdX/ZsMZiWupIWNqAEmiNY4RC+LSmCeOw==
dependencies:
nanoid "^2.1.0"

side-channel@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.2.tgz#df5d1abadb4e4bf4af1cd8852bf132d2f7876947"
Expand Down Expand Up @@ -11366,6 +11463,36 @@ validate-npm-package-license@^3.0.1:
spdx-correct "^3.0.0"
spdx-expression-parse "^3.0.0"

validate.io-array@^1.0.3:
version "1.0.6"
resolved "https://registry.yarnpkg.com/validate.io-array/-/validate.io-array-1.0.6.tgz#5b5a2cafd8f8b85abb2f886ba153f2d93a27774d"
integrity sha1-W1osr9j4uFq7L4hroVPy2Tond00=

validate.io-function@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/validate.io-function/-/validate.io-function-1.0.2.tgz#343a19802ed3b1968269c780e558e93411c0bad7"
integrity sha1-NDoZgC7TsZaCaceA5VjpNBHAutc=

validate.io-integer-array@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/validate.io-integer-array/-/validate.io-integer-array-1.0.0.tgz#2cabde033293a6bcbe063feafe91eaf46b13a089"
integrity sha1-LKveAzKTpry+Bj/q/pHq9GsToIk=
dependencies:
validate.io-array "^1.0.3"
validate.io-integer "^1.0.4"

validate.io-integer@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/validate.io-integer/-/validate.io-integer-1.0.5.tgz#168496480b95be2247ec443f2233de4f89878068"
integrity sha1-FoSWSAuVviJH7EQ/IjPeT4mHgGg=
dependencies:
validate.io-number "^1.0.3"

validate.io-number@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/validate.io-number/-/validate.io-number-1.0.3.tgz#f63ffeda248bf28a67a8d48e0e3b461a1665baf8"
integrity sha1-9j/+2iSL8opnqNSODjtGGhZluvg=

value-equal@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-1.0.1.tgz#1e0b794c734c5c0cade179c437d356d931a34d6c"
Expand Down

0 comments on commit 26102cb

Please sign in to comment.