Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions models/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Deebot Models Editor</title>
<script src="jsoneditor.min.js"></script>
<link rel='stylesheet' href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel='stylesheet' href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
</head>
<body>
<h1>Editor</h1>
<p>Below is the editor generated from the JSON Schema.</p>
<div id="json-editor-form"></div>

<script>
var data = {
iconlib: 'fontawesome5',
object_layout: 'normal',
show_errors: 'always',
theme: 'bootstrap4',
disable_properties: true,
no_additional_properties: true,
disable_collapse: true
}

var jsoneditor = null;

/* --------------------------------------------------------- initJsoneditor */

var initJsonEditor = function (schema) {
// destroy old JSONEditor instance if exists
if (jsoneditor) {
jsoneditor.destroy();
}

data.schema = schema;

// new instance of JSONEditor
jsoneditor = new window.JSONEditor(document.querySelector('#json-editor-form'), data);

// listen for changes
/*jsoneditor.on('change', function () {
// output
var json = jsoneditor.getValue()
outputTextarea.value = JSON.stringify(json, null, 2)

// validate
var validationErrors = jsoneditor.validate()
if (validationErrors.length) {
validateTextarea.value = JSON.stringify(validationErrors, null, 2)
} else {
validateTextarea.value = 'valid'
}
});*/
}

//load schema
fetch('v1/schema.json')
.then(response => response.json())
.then(schema => initJsonEditor(schema));

</script>
</body>
</html>
14 changes: 14 additions & 0 deletions models/jsoneditor.min.js

Large diffs are not rendered by default.

102 changes: 102 additions & 0 deletions models/v1/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Deebot model",
"description": "Describe a deebot model",
"type": "object",
"required": ["name", "class", "protocol"],
"properties": {
"name": {
"type": "string",
"description": "Name of the model",
"minLength": 1
},
"class": {
"type": "string",
"description": "Class of the model",
"minLength": 1
},
"protocol": {
"enum": ["mqtt/json", "mqtt/xml", "xmpp"],
"type": "string",
"description": "Protocol used by the robot"
},
"components": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"enum": ["main_brush", "side_brush", "filter"],
"options": {
"enum_titles": ["Main brush", "Side brush", "Filter"]
}
},
"description": "Available components",
"title": "Components"
},
"features": {
"type": "array",
"uniqueItems": true,
"title": "Features",
"description": "Avialable features",
"items": {
"type": "string",
"enum": [
"advanced_mode",
"mop_reminder",
"carpet_auto_fan_speed_boost",
"continuous_cleaning",
"do_not_disturb",
"cleaning_schedule",
"voice_report"
],
"options": {
"enum_titles": [
"Advanced mode",
"Mop reminder",
"Carpet auto fan speed boost",
"Continuous cleaning",
"Do not disturb",
"Cleaning schedule",
"Voice report/volume"
]
}
}
},
"cleaning_modes": {
"type": "array",
"uniqueItems": true,
"description": "Available cleaning types",
"items": {
"enum": ["spot_area", "custom_area"],
"type": "string"
},
"title": "Cleaning modes"
},
"water_levels": {
"type": "array",
"uniqueItems": true,
"title": "Water level",
"description": "Avialable water levels",
"items": {
"type": "string",
"enum": ["low", "medium", "high", "ultra_high"],
"options": {
"enum_titles": ["Low", "Medium", "High", "Ultra high"]
}
}
},
"fan_speeds": {
"title": "Fan speed",
"type": "array",
"description": "Available fan speeds",
"items": {
"type": "string",
"enum": ["quiet", "standard", "max", "max+"],
"options": {
"enum_titles": ["Quiet", "Standard", "Max", "Max+"]
}
},
"uniqueItems": true
}
}
}