config-editor-base 1.5.7 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +20 -20
- package/README.md +165 -165
- package/dist/index.js +24103 -2670
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +23166 -1732
- package/dist/index.modern.js.map +1 -1
- package/dist/schema/Advanced/uischema-01.04.json +618 -618
- package/dist/schema/Advanced/uischema-01.06.json +618 -618
- package/dist/schema/CANedge1/schema-01.06.json +2049 -2049
- package/dist/schema/CANedge2/schema-01.06.json +2482 -2482
- package/dist/schema/Simple/uischema-01.04.json +665 -665
- package/dist/schema/Simple/uischema-01.06.json +665 -665
- package/package.json +66 -65
package/LICENSE.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 CSS-Electronics
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 CSS-Electronics
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,165 +1,165 @@
|
|
|
1
|
-
# Config Editor - Base Module
|
|
2
|
-
|
|
3
|
-
This project includes a React based JSON Schema editor.
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/config-editor-base) [](https://standardjs.com)
|
|
6
|
-
|
|
7
|
-
### Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install --save config-editor-base
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
### Development testing
|
|
16
|
-
|
|
17
|
-
You can directly test the "raw" configuration editor by cloning this repository and running below `npm install` in root and in the `example/` folder. After this, run `npm start` in the root as well as in the `example/` folder.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
### Publishing a new package via npm
|
|
22
|
-
|
|
23
|
-
To publish your own custom version as an npm package, you can modify the `package.json` and run `npm publish`. You'll need to be logged in first.
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
### Usage in a parent app
|
|
28
|
-
|
|
29
|
-
The module uses redux, hence you'll need to import the base module and the `reducer` as follows:
|
|
30
|
-
|
|
31
|
-
```jsx
|
|
32
|
-
// reducers.js
|
|
33
|
-
|
|
34
|
-
import { combineReducers } from 'redux'
|
|
35
|
-
import alert from './alert/reducer'
|
|
36
|
-
|
|
37
|
-
import { editor } from 'config-editor-base'
|
|
38
|
-
|
|
39
|
-
const rootReducer = combineReducers({
|
|
40
|
-
alert,
|
|
41
|
-
editor
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
export default rootReducer
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
In the parent App we can load an Editor module, which can be constructed as below:
|
|
48
|
-
|
|
49
|
-
```jsx
|
|
50
|
-
import React from 'react'
|
|
51
|
-
import { connect } from 'react-redux'
|
|
52
|
-
|
|
53
|
-
import { EncryptionModal } from 'config-editor-tools'
|
|
54
|
-
import { EditorSection } from 'config-editor-base'
|
|
55
|
-
|
|
56
|
-
import * as actionsAlert from '../alert/actions'
|
|
57
|
-
import AlertContainer from '../alert/AlertContainer'
|
|
58
|
-
|
|
59
|
-
class Editor extends React.Component {
|
|
60
|
-
render() {
|
|
61
|
-
let editorTools = [
|
|
62
|
-
{
|
|
63
|
-
name: 'encryption-modal',
|
|
64
|
-
comment: 'Encryption tool',
|
|
65
|
-
class: 'fa fa-lock',
|
|
66
|
-
modal: <EncryptionModal showAlert={this.props.showAlert} />
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<div className='file-explorer'>
|
|
72
|
-
<div className='fe-body fe-body-offline'>
|
|
73
|
-
<AlertContainer />
|
|
74
|
-
<EditorSection
|
|
75
|
-
editorTools={editorTools}
|
|
76
|
-
showAlert={this.props.showAlert}
|
|
77
|
-
/>
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const mapDispatchToProps = (dispatch) => {
|
|
85
|
-
return {
|
|
86
|
-
showAlert: (type, message) =>
|
|
87
|
-
dispatch(actionsAlert.set({ type: type, message: message }))
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export default connect(null, mapDispatchToProps)(Editor)
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
## Parsing embedded Rule Schema and UISchema files
|
|
97
|
-
|
|
98
|
-
The [config editor](https://github.com/CSS-Electronics/config-editor) can take a list of UIschema and Rule Schema files. This enables the editor to "auto-load" the UIschemas upon initial load, as well as "auto-load" the Rule Schema files matching the revision of the loaded Configuration File.
|
|
99
|
-
|
|
100
|
-
Note that the parsed list of files should match the actual files that are included in the config-editor-base `dist/` folder.
|
|
101
|
-
|
|
102
|
-
For example, the Rule Schema for `"schema-01.02.json | CANedge2"` should be contained in `dist/schema/CANedge2/schema-01.02.json`.
|
|
103
|
-
|
|
104
|
-
The syntax for parsing these lists is as below (in the [config-editor](https://github.com/CSS-Electronics/config-editor) repo `Editor.js` file):
|
|
105
|
-
|
|
106
|
-
```jsx
|
|
107
|
-
|
|
108
|
-
// define UIschema and Rule Schema names for auto-loading embedded schema files
|
|
109
|
-
export const uiSchemaAry = [
|
|
110
|
-
"uischema-01.02.json | Simple",
|
|
111
|
-
"uischema-01.02.json | Advanced",
|
|
112
|
-
];
|
|
113
|
-
|
|
114
|
-
export const schemaAry = [
|
|
115
|
-
"schema-01.02.json | CANedge2",
|
|
116
|
-
"schema-01.02.json | CANedge1",
|
|
117
|
-
"schema-00.07.json | CANedge2",
|
|
118
|
-
"schema-00.07.json | CANedge1",
|
|
119
|
-
];
|
|
120
|
-
|
|
121
|
-
...
|
|
122
|
-
|
|
123
|
-
<EditorSection
|
|
124
|
-
editorTools={editorTools}
|
|
125
|
-
showAlert={this.props.showAlert}
|
|
126
|
-
uiSchemaAry={uiSchemaAry}
|
|
127
|
-
schemaAry={schemaAry}
|
|
128
|
-
/>
|
|
129
|
-
...
|
|
130
|
-
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
Note that the code distinguishes between a `config-XX.YY.json` file loaded from a CANedge1 and CANedge2 unit. This is done by evaluating whether a `connect` section exists or not in the Configuration File. Based on this test, the editor either loads the Rule Schema for the CANedge2 (if `connect` exists) or the CANedge1.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
## Parsing S3 functionality
|
|
139
|
-
|
|
140
|
-
The config editor also supports various S3 calls, e.g. for loading Rule Schema and Configuration Files from a device S3 folder - as well as submitting updated Configuration Files to S3. See the [CANcloud](https://github.com/CSS-Electronics/cancloud) repository for an example of this implementation.
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
## Regarding styling
|
|
145
|
-
|
|
146
|
-
The config editor relies on styling from the parent application. For examples of styling, see the CANedge configuration editor.
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
## Regarding JSON Schema files
|
|
150
|
-
|
|
151
|
-
The module expects to find JSON Schema files in the structure below to facilitate auto-loading of these:
|
|
152
|
-
|
|
153
|
-
```
|
|
154
|
-
/
|
|
155
|
-
|-- dist/
|
|
156
|
-
|-- schema/
|
|
157
|
-
|-- Advanced/
|
|
158
|
-
|-- uischema-XX.YY.json
|
|
159
|
-
|-- Simple/
|
|
160
|
-
|-- uischema-XX.YY.json
|
|
161
|
-
|-- CANedge1/
|
|
162
|
-
|-- schema-XX.YY.json
|
|
163
|
-
|-- CANedge2/
|
|
164
|
-
|-- schema-XX.YY.json
|
|
165
|
-
```
|
|
1
|
+
# Config Editor - Base Module
|
|
2
|
+
|
|
3
|
+
This project includes a React based JSON Schema editor.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/config-editor-base) [](https://standardjs.com)
|
|
6
|
+
|
|
7
|
+
### Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save config-editor-base
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
### Development testing
|
|
16
|
+
|
|
17
|
+
You can directly test the "raw" configuration editor by cloning this repository and running below `npm install` in root and in the `example/` folder. After this, run `npm start` in the root as well as in the `example/` folder.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
### Publishing a new package via npm
|
|
22
|
+
|
|
23
|
+
To publish your own custom version as an npm package, you can modify the `package.json` and run `npm publish`. You'll need to be logged in first.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### Usage in a parent app
|
|
28
|
+
|
|
29
|
+
The module uses redux, hence you'll need to import the base module and the `reducer` as follows:
|
|
30
|
+
|
|
31
|
+
```jsx
|
|
32
|
+
// reducers.js
|
|
33
|
+
|
|
34
|
+
import { combineReducers } from 'redux'
|
|
35
|
+
import alert from './alert/reducer'
|
|
36
|
+
|
|
37
|
+
import { editor } from 'config-editor-base'
|
|
38
|
+
|
|
39
|
+
const rootReducer = combineReducers({
|
|
40
|
+
alert,
|
|
41
|
+
editor
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
export default rootReducer
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
In the parent App we can load an Editor module, which can be constructed as below:
|
|
48
|
+
|
|
49
|
+
```jsx
|
|
50
|
+
import React from 'react'
|
|
51
|
+
import { connect } from 'react-redux'
|
|
52
|
+
|
|
53
|
+
import { EncryptionModal } from 'config-editor-tools'
|
|
54
|
+
import { EditorSection } from 'config-editor-base'
|
|
55
|
+
|
|
56
|
+
import * as actionsAlert from '../alert/actions'
|
|
57
|
+
import AlertContainer from '../alert/AlertContainer'
|
|
58
|
+
|
|
59
|
+
class Editor extends React.Component {
|
|
60
|
+
render() {
|
|
61
|
+
let editorTools = [
|
|
62
|
+
{
|
|
63
|
+
name: 'encryption-modal',
|
|
64
|
+
comment: 'Encryption tool',
|
|
65
|
+
class: 'fa fa-lock',
|
|
66
|
+
modal: <EncryptionModal showAlert={this.props.showAlert} />
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div className='file-explorer'>
|
|
72
|
+
<div className='fe-body fe-body-offline'>
|
|
73
|
+
<AlertContainer />
|
|
74
|
+
<EditorSection
|
|
75
|
+
editorTools={editorTools}
|
|
76
|
+
showAlert={this.props.showAlert}
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const mapDispatchToProps = (dispatch) => {
|
|
85
|
+
return {
|
|
86
|
+
showAlert: (type, message) =>
|
|
87
|
+
dispatch(actionsAlert.set({ type: type, message: message }))
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default connect(null, mapDispatchToProps)(Editor)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Parsing embedded Rule Schema and UISchema files
|
|
97
|
+
|
|
98
|
+
The [config editor](https://github.com/CSS-Electronics/config-editor) can take a list of UIschema and Rule Schema files. This enables the editor to "auto-load" the UIschemas upon initial load, as well as "auto-load" the Rule Schema files matching the revision of the loaded Configuration File.
|
|
99
|
+
|
|
100
|
+
Note that the parsed list of files should match the actual files that are included in the config-editor-base `dist/` folder.
|
|
101
|
+
|
|
102
|
+
For example, the Rule Schema for `"schema-01.02.json | CANedge2"` should be contained in `dist/schema/CANedge2/schema-01.02.json`.
|
|
103
|
+
|
|
104
|
+
The syntax for parsing these lists is as below (in the [config-editor](https://github.com/CSS-Electronics/config-editor) repo `Editor.js` file):
|
|
105
|
+
|
|
106
|
+
```jsx
|
|
107
|
+
|
|
108
|
+
// define UIschema and Rule Schema names for auto-loading embedded schema files
|
|
109
|
+
export const uiSchemaAry = [
|
|
110
|
+
"uischema-01.02.json | Simple",
|
|
111
|
+
"uischema-01.02.json | Advanced",
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
export const schemaAry = [
|
|
115
|
+
"schema-01.02.json | CANedge2",
|
|
116
|
+
"schema-01.02.json | CANedge1",
|
|
117
|
+
"schema-00.07.json | CANedge2",
|
|
118
|
+
"schema-00.07.json | CANedge1",
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
...
|
|
122
|
+
|
|
123
|
+
<EditorSection
|
|
124
|
+
editorTools={editorTools}
|
|
125
|
+
showAlert={this.props.showAlert}
|
|
126
|
+
uiSchemaAry={uiSchemaAry}
|
|
127
|
+
schemaAry={schemaAry}
|
|
128
|
+
/>
|
|
129
|
+
...
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Note that the code distinguishes between a `config-XX.YY.json` file loaded from a CANedge1 and CANedge2 unit. This is done by evaluating whether a `connect` section exists or not in the Configuration File. Based on this test, the editor either loads the Rule Schema for the CANedge2 (if `connect` exists) or the CANedge1.
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Parsing S3 functionality
|
|
139
|
+
|
|
140
|
+
The config editor also supports various S3 calls, e.g. for loading Rule Schema and Configuration Files from a device S3 folder - as well as submitting updated Configuration Files to S3. See the [CANcloud](https://github.com/CSS-Electronics/cancloud) repository for an example of this implementation.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Regarding styling
|
|
145
|
+
|
|
146
|
+
The config editor relies on styling from the parent application. For examples of styling, see the CANedge configuration editor.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
## Regarding JSON Schema files
|
|
150
|
+
|
|
151
|
+
The module expects to find JSON Schema files in the structure below to facilitate auto-loading of these:
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
/
|
|
155
|
+
|-- dist/
|
|
156
|
+
|-- schema/
|
|
157
|
+
|-- Advanced/
|
|
158
|
+
|-- uischema-XX.YY.json
|
|
159
|
+
|-- Simple/
|
|
160
|
+
|-- uischema-XX.YY.json
|
|
161
|
+
|-- CANedge1/
|
|
162
|
+
|-- schema-XX.YY.json
|
|
163
|
+
|-- CANedge2/
|
|
164
|
+
|-- schema-XX.YY.json
|
|
165
|
+
```
|