Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
slapos.core
Commits
8400195a
Commit
8400195a
authored
May 10, 2022
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_jio: Implement proper array of numbers
Include more sample data.
parent
a468149b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
11 deletions
+98
-11
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js.js
...age_module/rjs_gadget_erp5_page_slap_parameter_form_js.js
+38
-6
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js.xml
...ge_module/rjs_gadget_erp5_page_slap_parameter_form_js.xml
+2
-2
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simpledemo/instance-input-json-in-xml-schema.json.json
...ma/simpledemo/instance-input-json-in-xml-schema.json.json
+27
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simpledemo/instance-input-json-in-xml-schema.json.xml
...ema/simpledemo/instance-input-json-in-xml-schema.json.xml
+28
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simpledemo/software.cfg.json.json
.../sample-software-schema/simpledemo/software.cfg.json.json
+3
-3
No files found.
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js.js
View file @
8400195a
...
...
@@ -116,6 +116,7 @@
}
function
render_field
(
json_field
,
default_value
)
{
var
data_format
,
domsugar_input_dict
=
{};
if
(
json_field
[
'
enum
'
]
!==
undefined
)
{
return
render_selection
(
json_field
,
default_value
);
}
...
...
@@ -136,15 +137,19 @@
}
if
(
json_field
.
type
===
"
array
"
)
{
return
render_textarea
(
json_field
,
default_value
,
"
array
"
);
data_format
=
json_field
.
type
;
if
(
json_field
.
items
!==
undefined
)
{
if
(
json_field
.
items
.
type
===
"
number
"
||
json_field
.
items
.
type
===
"
integer
"
)
{
data_format
=
"
array-number
"
;
}
}
return
render_textarea
(
json_field
,
default_value
,
data_format
);
}
if
(
json_field
.
type
===
"
string
"
&&
json_field
.
textarea
===
true
)
{
return
render_textarea
(
json_field
,
default_value
,
"
string
"
);
}
var
domsugar_input_dict
=
{};
if
(
default_value
!==
undefined
)
{
domsugar_input_dict
.
value
=
default_value
;
}
...
...
@@ -336,8 +341,10 @@
function
getFormValuesAsJSONDict
(
element
)
{
var
json_dict
=
{},
entry
,
entry_list
,
multi_level_dict
=
{};
$
(
element
.
querySelectorAll
(
"
.slapos-parameter
"
)).
each
(
function
(
key
,
input
)
{
var
index_e
;
if
(
input
.
value
!==
""
)
{
if
(
input
.
type
===
'
number
'
)
{
json_dict
[
input
.
name
]
=
parseFloat
(
input
.
value
);
...
...
@@ -348,6 +355,20 @@
}
else
if
(
input
.
tagName
===
"
TEXTAREA
"
)
{
if
(
input
.
getAttribute
(
"
data-format
"
)
===
"
string
"
)
{
json_dict
[
input
.
name
]
=
input
.
value
;
}
else
if
(
input
.
getAttribute
(
"
data-format
"
)
===
"
array
"
)
{
json_dict
[
input
.
name
]
=
input
.
value
.
split
(
'
\n
'
);
}
else
if
(
input
.
getAttribute
(
"
data-format
"
)
===
"
array-number
"
)
{
json_dict
[
input
.
name
]
=
[];
entry_list
=
input
.
value
.
split
(
"
\n
"
);
for
(
index_e
in
entry_list
)
{
if
(
entry_list
.
hasOwnProperty
(
index_e
))
{
if
(
isNaN
(
parseFloat
(
entry_list
[
index_e
])))
{
json_dict
[
input
.
name
].
push
(
entry_list
[
index_e
]);
}
else
{
json_dict
[
input
.
name
].
push
(
parseFloat
(
entry_list
[
index_e
]));
}
}
}
}
else
{
json_dict
[
input
.
name
]
=
input
.
value
.
split
(
'
\n
'
);
}
...
...
@@ -539,7 +560,8 @@
divm
,
missing_index
,
missing_field_name
,
xml_output
;
xml_output
,
input_field
;
$
(
g
.
element
.
querySelectorAll
(
"
span.error
"
)).
each
(
function
(
i
,
span
)
{
span
.
textContent
=
""
;
...
...
@@ -563,7 +585,12 @@
for
(
error_index
in
validation
.
errors
)
{
if
(
validation
.
errors
.
hasOwnProperty
(
error_index
))
{
field_name
=
validation
.
errors
[
error_index
].
dataPath
;
div
=
$
(
"
.slapos-parameter[name='/
"
+
field_name
+
"
']
"
)[
0
].
parentNode
;
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
field_name
+
"
']
"
)
if
(
input_field
===
null
)
{
field_name
=
field_name
.
split
(
"
/
"
).
slice
(
0
,
-
1
).
join
(
"
/
"
)
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
field_name
+
"
']
"
)
}
div
=
input_field
.
parentNode
;
div
.
setAttribute
(
"
class
"
,
"
slapos-parameter error-input
"
);
div
.
querySelector
(
"
span.error
"
).
textContent
=
validation
.
errors
[
error_index
].
message
;
}
...
...
@@ -572,7 +599,12 @@
for
(
missing_index
in
validation
.
missing
)
{
if
(
validation
.
missing
.
hasOwnProperty
(
missing_index
))
{
missing_field_name
=
validation
.
missing
[
missing_index
].
dataPath
;
divm
=
$
(
'
.slapos-parameter[name=/
'
+
missing_field_name
+
"
']
"
)[
0
].
parentNode
;
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
missing_field_name
+
"
']
"
)
if
(
input_field
===
null
)
{
missing_field_name
=
field_name
.
split
(
"
/
"
).
slice
(
0
,
-
1
).
join
(
"
/
"
)
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
missing_field_name
+
"
']
"
)
}
divm
=
input_field
.
parentNode
;
divm
.
setAttribute
(
"
class
"
,
"
error-input
"
);
divm
.
querySelector
(
"
span.error
"
).
textContent
=
validation
.
missing
[
missing_index
].
message
;
}
...
...
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js.xml
View file @
8400195a
...
...
@@ -280,7 +280,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1000.9
503.46381.7543
</string>
</value>
<value>
<string>
1000.9
806.10724.60689
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -298,7 +298,7 @@
</tuple>
<state>
<tuple>
<float>
16522
04027.96
</float>
<float>
16522
20502.37
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simpledemo/instance-input-json-in-xml-schema.json.json
0 → 100644
View file @
8400195a
{
"$schema"
:
"http://json-schema.org/draft-04/schema#"
,
"type"
:
"object"
,
"description"
:
"Extend simple parameter extension with extra only supported on json-in-xml"
,
"additionalProperties"
:
false
,
"allOf"
:
[
{
"$ref"
:
"instance-input-schema.json#/"
},
{
"properties"
:
{
"simple-array-of-string"
:
{
"title"
:
"Example of Simple array of String"
,
"description"
:
"Example of Array of String"
,
"type"
:
"array"
,
"items"
:
{
"type"
:
"string"
}
},
"simple-array-of-integer"
:
{
"title"
:
"Example of Simple array of Integer"
,
"description"
:
"Example of Array of Interger"
,
"type"
:
"array"
,
"items"
:
{
"type"
:
"integer"
}
}
}
}
]
}
\ No newline at end of file
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simpledemo/instance-input-json-in-xml-schema.json.xml
0 → 100644
View file @
8400195a
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"File"
module=
"OFS.Image"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
__name__
</string>
</key>
<value>
<string>
instance-input-json-in-xml-schema.json
</string>
</value>
</item>
<item>
<key>
<string>
content_type
</string>
</key>
<value>
<string>
text/x-json
</string>
</value>
</item>
<item>
<key>
<string>
precondition
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simpledemo/software.cfg.json.json
View file @
8400195a
...
...
@@ -5,7 +5,7 @@
"software-type"
:
{
"default"
:
{
"title"
:
"Default"
,
"description"
:
"Default"
,
"description"
:
"Default
reference parameters
"
,
"request"
:
"instance-input-schema.json"
,
"response"
:
"instance-output-schema.json"
,
"index"
:
0
...
...
@@ -13,8 +13,8 @@
"jsondefault"
:
{
"title"
:
"JSON in XML"
,
"serialisation"
:
"json-in-xml"
,
"description"
:
"Default"
,
"request"
:
"instance-input-schema.json"
,
"description"
:
"Default
reference parameters under json-in-xml
"
,
"request"
:
"instance-input-
json-in-xml-
schema.json"
,
"response"
:
"instance-output-schema.json"
,
"index"
:
1
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment