Add jsoneditor and schema validation
This commit is contained in:
Родитель
5d4c4986f7
Коммит
cd4d2f4c55
|
@ -0,0 +1,2 @@
|
|||
declare module 'jsoneditor-react';
|
||||
declare module 'jsoneditor-react';
|
|
@ -4,6 +4,7 @@
|
|||
"private": true,
|
||||
"dependencies": {
|
||||
"@types/prop-types": "^15.5.3",
|
||||
"ajv": "^6.5.2",
|
||||
"autoprefixer": "7.1.6",
|
||||
"babel-jest": "^22.1.0",
|
||||
"babel-loader": "^7.1.2",
|
||||
|
@ -20,6 +21,8 @@
|
|||
"fs-extra": "3.0.1",
|
||||
"html-webpack-plugin": "2.29.0",
|
||||
"jest": "22.4.2",
|
||||
"jsoneditor": "^5.18.0",
|
||||
"jsoneditor-react": "^0.1.9",
|
||||
"object-assign": "4.1.1",
|
||||
"office-ui-fabric-react": "^6.23.0",
|
||||
"postcss-flexbugs-fixes": "3.2.0",
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||
import { Label } from 'office-ui-fabric-react/lib/Label';
|
||||
import { Pivot, PivotItem } from 'office-ui-fabric-react/lib/Pivot';
|
||||
|
||||
import EditTab from './view/Edit/View';
|
||||
import EditView from './view/edit/View';
|
||||
|
||||
import './App.css';
|
||||
|
||||
|
@ -12,7 +12,7 @@ class App extends React.Component<any, any> {
|
|||
<div className="App">
|
||||
<Pivot>
|
||||
<PivotItem headerText="Edit">
|
||||
<EditTab />
|
||||
<EditView />
|
||||
</PivotItem>
|
||||
<PivotItem headerText="Convert">
|
||||
<Label>TODO</Label>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
export default {
|
||||
// https://github.com/onnx/onnx/blob/master/docs/MetadataProps.md
|
||||
// FIXME be case insensitive
|
||||
type: 'object',
|
||||
properties: {
|
||||
model_author: {
|
||||
type: 'string',
|
||||
},
|
||||
model_license: {
|
||||
type: 'string',
|
||||
},
|
||||
'Image.BitmapPixelFormat': {
|
||||
type: 'string',
|
||||
enum: [
|
||||
'Gray8',
|
||||
'Rgb8',
|
||||
'Bgr8',
|
||||
'Rgba8',
|
||||
'Bgra8',
|
||||
],
|
||||
},
|
||||
'Image.ColorSpaceGamma': {
|
||||
type: 'string',
|
||||
enum: [
|
||||
'Linear',
|
||||
'SRGB',
|
||||
],
|
||||
},
|
||||
'Image.NominalPixelRange': {
|
||||
type: 'string',
|
||||
enum: [
|
||||
'NominalRange_0_255',
|
||||
'Normalized_0_1',
|
||||
'Normalized_1_1',
|
||||
'NominalRange_16_235',
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
|
@ -0,0 +1,29 @@
|
|||
import * as Ajv from 'ajv';
|
||||
import { JsonEditor } from 'jsoneditor-react';
|
||||
import 'jsoneditor-react/es/editor.min.css';
|
||||
import { Label } from 'office-ui-fabric-react/lib/Label';
|
||||
import * as React from 'react';
|
||||
|
||||
import MetadataSchema from '../../schema/Metadata';
|
||||
|
||||
const ajv = new Ajv({ allErrors: true, verbose: true });
|
||||
|
||||
export default class RightPanel extends React.Component {
|
||||
render() {
|
||||
console.warn(MetadataSchema);
|
||||
return (
|
||||
<div>
|
||||
<Label>Right panel</Label>
|
||||
<JsonEditor
|
||||
ajv={ajv}
|
||||
schema={MetadataSchema}
|
||||
value={{
|
||||
a: 'string',
|
||||
b: 2,
|
||||
}}
|
||||
// onChange={this.handleChange}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
import * as React from 'react';
|
||||
import { Label } from 'office-ui-fabric-react/lib/Label';
|
||||
|
||||
import Resizable from '../../components/Resizable';
|
||||
import RightPanel from './RightPanel';
|
||||
|
||||
import './View.css';
|
||||
|
||||
|
@ -22,8 +24,7 @@ export default class EditView extends React.Component {
|
|||
Netron visualization
|
||||
</object>
|
||||
<Resizable>
|
||||
<Label>Right panel</Label>
|
||||
|
||||
<RightPanel />
|
||||
</Resizable>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -122,7 +122,7 @@ ajv-keywords@^3.1.0:
|
|||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.2.0.tgz#e86b819c602cf8821ad637413698f1dec021847a"
|
||||
|
||||
ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5:
|
||||
ajv@5.5.2, ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5:
|
||||
version "5.5.2"
|
||||
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965"
|
||||
dependencies:
|
||||
|
@ -131,7 +131,7 @@ ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5:
|
|||
fast-json-stable-stringify "^2.0.0"
|
||||
json-schema-traverse "^0.3.0"
|
||||
|
||||
ajv@^6.1.0:
|
||||
ajv@^6.1.0, ajv@^6.5.2:
|
||||
version "6.5.2"
|
||||
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.5.2.tgz#678495f9b82f7cca6be248dd92f59bff5e1f4360"
|
||||
dependencies:
|
||||
|
@ -1116,6 +1116,10 @@ brace-expansion@^1.0.0, brace-expansion@^1.1.7:
|
|||
balanced-match "^1.0.0"
|
||||
concat-map "0.0.1"
|
||||
|
||||
brace@0.11.0:
|
||||
version "0.11.0"
|
||||
resolved "https://registry.yarnpkg.com/brace/-/brace-0.11.0.tgz#155cd80607687dc8cb908f0df94e62a033c1d563"
|
||||
|
||||
braces@^1.8.2:
|
||||
version "1.8.5"
|
||||
resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7"
|
||||
|
@ -3777,6 +3781,10 @@ istanbul-reports@^1.3.0:
|
|||
dependencies:
|
||||
handlebars "^4.0.3"
|
||||
|
||||
javascript-natural-sort@0.7.1:
|
||||
version "0.7.1"
|
||||
resolved "https://registry.yarnpkg.com/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz#f9e2303d4507f6d74355a73664d1440fb5a0ef59"
|
||||
|
||||
jest-changed-files@^22.2.0:
|
||||
version "22.4.3"
|
||||
resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-22.4.3.tgz#8882181e022c38bd46a2e4d18d44d19d90a90fb2"
|
||||
|
@ -4036,6 +4044,10 @@ jest@22.4.2:
|
|||
import-local "^1.0.0"
|
||||
jest-cli "^22.4.2"
|
||||
|
||||
jmespath@0.15.0:
|
||||
version "0.15.0"
|
||||
resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.15.0.tgz#a3f222a9aae9f966f5d27c796510e28091764217"
|
||||
|
||||
js-base64@^2.1.9:
|
||||
version "2.4.5"
|
||||
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.5.tgz#e293cd3c7c82f070d700fc7a1ca0a2e69f101f92"
|
||||
|
@ -4135,6 +4147,23 @@ json5@^0.5.0, json5@^0.5.1:
|
|||
version "0.5.1"
|
||||
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
|
||||
|
||||
jsoneditor-react@^0.1.9:
|
||||
version "0.1.9"
|
||||
resolved "https://registry.yarnpkg.com/jsoneditor-react/-/jsoneditor-react-0.1.9.tgz#2c36f3b579aceed526a61ca88b13cca911e53766"
|
||||
dependencies:
|
||||
jsoneditor "^5.13.2"
|
||||
prop-types "^15.6.0"
|
||||
|
||||
jsoneditor@^5.13.2, jsoneditor@^5.18.0:
|
||||
version "5.18.0"
|
||||
resolved "https://registry.yarnpkg.com/jsoneditor/-/jsoneditor-5.18.0.tgz#b0692c952b41442ef63b72a019d17255df154f02"
|
||||
dependencies:
|
||||
ajv "5.5.2"
|
||||
brace "0.11.0"
|
||||
javascript-natural-sort "0.7.1"
|
||||
jmespath "0.15.0"
|
||||
picomodal "3.0.0"
|
||||
|
||||
jsonfile@^2.1.0:
|
||||
version "2.4.0"
|
||||
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
|
||||
|
@ -5159,6 +5188,10 @@ performance-now@^2.1.0:
|
|||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
||||
|
||||
picomodal@3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/picomodal/-/picomodal-3.0.0.tgz#facd30f4fbf34a809c1e04ea525f004f399c0b82"
|
||||
|
||||
pify@^2.0.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
|
||||
|
|
Загрузка…
Ссылка в новой задаче