]> ToastFreeware Gitweb - philipp/winterrodeln/wradmin.git/blob - wradmin/templates/json_editor.html
Json is now loaded with Ajax.
[philipp/winterrodeln/wradmin.git] / wradmin / templates / json_editor.html
1 {% extends "master.html" %}
2 {% block head %}
3     <meta charset="utf-8" />
4     <title>{% block title %}JSON Editor{% endblock %}</title>
5     <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
6     <meta name="robots" content="noindex, nofollow" />
7     <link rel="shortcut icon" href="{{url_for('static', filename='favicon.png')}}" />
8     <script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script>
9     <link rel="stylesheet" type="text/css" media="screen" href="{{url_for('static', filename='style.css')}}" />
10 {% endblock %}
11
12 {% block content %}
13 <div id='editor_holder'></div>
14 <button id='submit'>Submit (console.log)</button>
15
16 <script>
17     JSONEditor.defaults.options = {simplemde: {spellChecker: false}};
18     JSONEditor.defaults.languages.de = {
19     error_notset: 'Eigenschaft ist nicht gesetzt',
20     error_notempty: 'Wert erforderlich',
21     error_enum: 'Wert muss einem der vorgegebenen entsprechen',
22     error_anyOf: 'Wert muss mindestens nach einem der vorgegebenen Schemas gültig sein',
23     error_oneOf: 'Wert muss genau einem der vorgegebenen Schemas entsprechen. Derzeit ist es nach {{0}} Schemas gültig.',
24     error_not: 'Wert darf nach dem vorgegebenen Schema nicht gültig sein',
25     error_type_union: 'Wert muss einer der vorgegebenen Typen entsprechen',
26     error_type: 'Wert muss vom Typ {{0}} sein',
27     error_disallow_union: 'Wert darf nicht einer der vorgegebenen unerlaubten Typen sein',
28     error_disallow: 'Wert darf nicht vom Typ {{0}} sein',
29     error_multipleOf: 'Wert muss das vielfache von {{0}} sein',
30     error_maximum_excl: 'Wert muss kleiner sein als {{0}}',
31     error_maximum_incl: 'Wert darf maximal {{0}} sein',
32     error_minimum_excl: 'Wert muss größer sein als {{0}}',
33     error_minimum_incl: 'Wert muss mindestens {{0}} sein',
34     error_maxLength: 'Wert darf maximal {{0}} Zeichen lang sein',
35     error_minLength: 'Wert muss mindestens {{0}} Zeichen lang sein',
36     error_pattern: 'Wert muss dem vorgegebenen Muster {{0}} entsprechen',
37     error_additionalItems: 'In der Liste sind keine zusätzlichen Einträge erlaubt',
38     /**
39      * When there are to many items in an array
40      * @variables This key takes one variable: The maximum item count
41      */
42     error_maxItems: 'Value must have at most {{0}} items',
43     /**
44      * When there are not enough items in an array
45      * @variables This key takes one variable: The minimum item count
46      */
47     error_minItems: 'Value must have at least {{0}} items',
48     /**
49      * When an array is supposed to have unique items but has duplicates
50      */
51     error_uniqueItems: 'Array must have unique items',
52     /**
53      * When there are too many properties in an object
54      * @variables This key takes one variable: The maximum property count
55      */
56     error_maxProperties: 'Object must have at most {{0}} properties',
57     /**
58      * When there are not enough properties in an object
59      * @variables This key takes one variable: The minimum property count
60      */
61     error_minProperties: 'Object must have at least {{0}} properties',
62     /**
63      * When a required property is not defined
64      * @variables This key takes one variable: The name of the missing property
65      */
66     error_required: "Object is missing the required property '{{0}}'",
67     /**
68      * When there is an additional property is set whereas there should be none
69      * @variables This key takes one variable: The name of the additional property
70      */
71     error_additional_properties: 'No additional properties allowed, but property {{0}} is set',
72     /**
73      * When there is a propertyName that sets a max length and a property name exceeds the max length
74      * @variables This key takes one variable: The name of the invalid property
75      */
76     error_property_names_exceeds_maxlength: 'Property name {{0}} exceeds maxLength',
77     /**
78      * When there is a propertyName that sets an enum and a property name matches none of the possible enum
79      * @variables This key takes one variable: The name of the invalid property
80      */
81     error_property_names_enum_mismatch: 'Property name {{0}} does not match any enum values',
82     /**
83      * When there is a propertyName that sets a pattern and a property name does not match the pattern
84      * @variables This key takes one variable: The name of the invalid property
85      */
86     error_property_names_pattern_mismatch: 'Property name {{0}} does not match pattern',
87     /**
88      * When the propertyName is set to false and there is at least one property
89      * @variables This key takes one variable: The name of the invalid property
90      */
91     error_property_names_false: 'Property name {{0}} fails when propertyName is false',
92     /**
93      * When the propertyName specifies a maxLength that is not a number
94      * @variables This key takes one variable: The name of the current property
95      */
96     error_property_names_maxlength: 'Property name {{0}} cannot match invalid maxLength',
97     /**
98      * When the propertyName specifies an enum that is not an array
99      * @variables This key takes one variable: The name of the current property
100      */
101     error_property_names_enum: 'Property name {{0}} cannot match invalid enum',
102     /**
103      * When the propertyName specifies a pattern that is not a string
104      * @variables This key takes one variable: The name of the current property
105      */
106     error_property_names_pattern: 'Property name {{0}} cannot match invalid pattern',
107     /**
108      * When the propertyName is unsupported
109      * @variables This key takes one variable: The name of the invalid propertyName
110      */
111     error_property_names_unsupported: 'Unsupported propertyName {{0}}',
112     /**
113      * When a dependency is not resolved
114      * @variables This key takes one variable: The name of the missing property for the dependency
115      */
116     error_dependency: 'Must have property {{0}}',
117     /**
118      * When a date is in incorrect format
119      * @variables This key takes one variable: The valid format
120      */
121     error_date: 'Date must be in the format {{0}}',
122     /**
123      * When a time is in incorrect format
124      * @variables This key takes one variable: The valid format
125      */
126     error_time: 'Time must be in the format {{0}}',
127     /**
128      * When a datetime-local is in incorrect format
129      * @variables This key takes one variable: The valid format
130      */
131     error_datetime_local: 'Datetime must be in the format {{0}}',
132     /**
133      * When a integer date is less than 1 January 1970
134      */
135     error_invalid_epoch: 'Date must be greater than 1 January 1970',
136     /**
137      * When an IPv4 is in incorrect format
138      */
139     error_ipv4: 'Value must be a valid IPv4 address in the form of 4 numbers between 0 and 255, separated by dots',
140     /**
141      * When an IPv6 is in incorrect format
142      */
143     error_ipv6: 'Value must be a valid IPv6 address',
144     /**
145      * When a hostname is in incorrect format
146      */
147     error_hostname: 'The hostname has the wrong format',
148     /**
149      * Text on Delete All buttons
150      */
151     button_delete_all: 'All',
152     /**
153      * Title on Delete All buttons
154      */
155     button_delete_all_title: 'Delete All',
156     /**
157      * Text on Delete Last buttons
158      * @variable This key takes one variable: The title of object to delete
159      */
160     button_delete_last: 'Last {{0}}',
161     /**
162      * Title on Delete Last buttons
163      * @variable This key takes one variable: The title of object to delete
164      */
165     button_delete_last_title: 'Delete Last {{0}}',
166     /**
167      * Title on Add Row buttons
168      * @variable This key takes one variable: The title of object to add
169      */
170     button_add_row_title: 'Add {{0}}',
171     /**
172      * Title on Move Down buttons
173      */
174     button_move_down_title: 'Move down',
175     /**
176      * Title on Move Up buttons
177      */
178     button_move_up_title: 'Move up',
179     /**
180      * Title on Object Properties buttons
181      */
182     button_object_properties: 'Object Properties',
183     /**
184      * Title on Delete Row buttons
185      * @variable This key takes one variable: The title of object to delete
186      */
187     button_delete_row_title: '{{0}} löschen',
188     /**
189      * Title on Delete Row buttons, short version (no parameter with the object title)
190      */
191     button_delete_row_title_short: 'Löschen',
192     /**
193      * Title on Copy Row buttons, short version (no parameter with the object title)
194      */
195     button_copy_row_title_short: 'Copy',
196     /**
197      * Title on Collapse buttons
198      */
199     button_collapse: 'Collapse',
200     /**
201      * Title on Expand buttons
202      */
203     button_expand: 'Expand',
204     /**
205      * Title on Flatpickr toggle buttons
206      */
207     flatpickr_toggle_button: 'Toggle',
208     /**
209      * Title on Flatpickr clear buttons
210      */
211     flatpickr_clear_button: 'Clear',
212     /**
213      * Choices input field placeholder text
214      */
215     choices_placeholder_text: 'Start typing to add value',
216     /**
217      * Default title for array items
218      */
219     default_array_item_title: 'item',
220     /**
221      * Warning when deleting a node
222      */
223     button_delete_node_warning: 'Are you sure you want to remove this node?'
224 }
225
226
227
228
229
230     JSONEditor.defaults.language = "de";
231
232
233     // Initialize the editor with a JSON schema
234     var editor = new JSONEditor(document.getElementById('editor_holder'), {
235         schema: {"$ref": {{schema_url|tojson}}},
236         theme: 'bootstrap4',
237         ajax: true
238     });
239
240     editor.on('ready',() => {
241         fetch({{json_url|tojson}}).then(
242             function(response) {
243                 return response.json();
244             }).then(
245                 function(data) {
246                     editor.setValue(data);
247                 }
248             ).catch(function (err) {
249                 console.log(err);
250             })
251     });
252
253
254     // Hook up the submit button to log to the console
255     document.getElementById('submit').addEventListener('click',function() {
256         // Get the value from the editor
257         console.log(editor.getValue());
258     });
259 </script>
260 {% endblock %}