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
Carlos Ramos Carreño
slapos.core
Commits
114d59fa
Commit
114d59fa
authored
May 16, 2022
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Plain Diff
Fixup for Parameter Editor
See merge request
nexedi/slapos.core!385
parents
41cbe596
a3651c60
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
261 additions
and
27 deletions
+261
-27
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
+48
-25
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/simplebaddemo.xml
...s_hal_json_style/sample-software-schema/simplebaddemo.xml
+26
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simplebaddemo/instance-input-schema.json.json
...ware-schema/simplebaddemo/instance-input-schema.json.json
+24
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simplebaddemo/instance-input-schema.json.xml
...tware-schema/simplebaddemo/instance-input-schema.json.xml
+28
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simplebaddemo/software.cfg.json.json
...mple-software-schema/simplebaddemo/software.cfg.json.json
+14
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simplebaddemo/software.cfg.json.xml
...ample-software-schema/simplebaddemo/software.cfg.json.xml
+28
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simplebaddemo/software.cfg.txt
...yle/sample-software-schema/simplebaddemo/software.cfg.txt
+1
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simplebaddemo/software.cfg.xml
...yle/sample-software-schema/simplebaddemo/software.cfg.xml
+28
-0
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
+56
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simpledemo/instance-input-schema.json.json
...oftware-schema/simpledemo/instance-input-schema.json.json
+6
-0
No files found.
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js.js
View file @
114d59fa
...
@@ -46,26 +46,40 @@
...
@@ -46,26 +46,40 @@
selected
:
(
default_value
===
undefined
)
selected
:
(
default_value
===
undefined
)
})],
})],
option_index
,
option_index
,
selected
,
is_selected
=
(
default_value
===
undefined
),
data_format
=
"
string
"
;
data_format
=
"
string
"
;
if
(
json_field
.
type
===
"
integer
"
||
json_field
.
type
===
"
number
"
)
{
if
(
json_field
.
type
===
"
integer
"
||
json_field
.
type
===
"
number
"
)
{
data_format
=
"
number
"
;
data_format
=
"
number
"
;
}
else
if
(
json_field
.
type
===
"
boolean
"
)
{
data_format
=
"
boolean
"
;
}
}
if
(
default_value
===
undefined
)
{
if
(
default_value
===
undefined
)
{
default_value
=
""
default_value
=
""
;
}
}
for
(
option_index
in
json_field
[
'
enum
'
])
{
for
(
option_index
in
json_field
[
'
enum
'
])
{
if
(
json_field
[
'
enum
'
].
hasOwnProperty
(
option_index
))
{
if
(
json_field
[
'
enum
'
].
hasOwnProperty
(
option_index
))
{
selected
=
(
json_field
[
'
enum
'
][
option_index
].
toString
()
===
default_value
.
toString
());
is_selected
=
(
is_selected
||
selected
);
option_list
.
push
(
domsugar
(
'
option
'
,
{
option_list
.
push
(
domsugar
(
'
option
'
,
{
value
:
json_field
[
'
enum
'
][
option_index
],
value
:
json_field
[
'
enum
'
][
option_index
],
text
:
json_field
[
'
enum
'
][
option_index
],
text
:
json_field
[
'
enum
'
][
option_index
],
"
data-format
"
:
data_format
,
"
data-format
"
:
data_format
,
selected
:
(
selected
:
true
json_field
[
'
enum
'
][
option_index
].
toString
()
===
default_value
.
toString
()
)
}));
}));
}
}
}
}
if
(
!
is_selected
)
{
// The default value should be included even if it is
// outside the enum.
option_list
.
push
(
domsugar
(
'
option
'
,
{
value
:
default_value
,
text
:
default_value
,
"
data-format
"
:
data_format
,
selected
:
selected
}));
}
return
domsugar
(
'
select
'
,
{
return
domsugar
(
'
select
'
,
{
size
:
1
,
size
:
1
,
"
data-format
"
:
data_format
"
data-format
"
:
data_format
...
@@ -344,20 +358,16 @@
...
@@ -344,20 +358,16 @@
entry_list
,
entry_list
,
multi_level_dict
=
{};
multi_level_dict
=
{};
$
(
element
.
querySelectorAll
(
"
.slapos-parameter
"
)).
each
(
function
(
key
,
input
)
{
$
(
element
.
querySelectorAll
(
"
.slapos-parameter
"
)).
each
(
function
(
key
,
input
)
{
var
index_e
;
var
index_e
,
data_format
=
input
.
getAttribute
(
"
data-format
"
)
;
if
(
input
.
value
!==
""
)
{
if
(
input
.
value
!==
""
)
{
if
(
input
.
type
===
'
number
'
)
{
if
(
input
.
type
===
'
number
'
)
{
json_dict
[
input
.
name
]
=
parseFloat
(
input
.
value
);
json_dict
[
input
.
name
]
=
parseFloat
(
input
.
value
);
}
else
if
(
input
.
value
===
"
true
"
)
{
json_dict
[
input
.
name
]
=
true
;
}
else
if
(
input
.
value
===
"
false
"
)
{
json_dict
[
input
.
name
]
=
false
;
}
else
if
(
input
.
tagName
===
"
TEXTAREA
"
)
{
}
else
if
(
input
.
tagName
===
"
TEXTAREA
"
)
{
if
(
input
.
getAttribute
(
"
data-format
"
)
===
"
string
"
)
{
if
(
data_format
===
"
string
"
)
{
json_dict
[
input
.
name
]
=
input
.
value
;
json_dict
[
input
.
name
]
=
input
.
value
;
}
else
if
(
input
.
getAttribute
(
"
data-format
"
)
===
"
array
"
)
{
}
else
if
(
data_format
===
"
array
"
)
{
json_dict
[
input
.
name
]
=
input
.
value
.
split
(
'
\n
'
);
json_dict
[
input
.
name
]
=
input
.
value
.
split
(
'
\n
'
);
}
else
if
(
input
.
getAttribute
(
"
data-format
"
)
===
"
array-number
"
)
{
}
else
if
(
data_format
===
"
array-number
"
)
{
json_dict
[
input
.
name
]
=
[];
json_dict
[
input
.
name
]
=
[];
entry_list
=
input
.
value
.
split
(
"
\n
"
);
entry_list
=
input
.
value
.
split
(
"
\n
"
);
for
(
index_e
in
entry_list
)
{
for
(
index_e
in
entry_list
)
{
...
@@ -373,12 +383,20 @@
...
@@ -373,12 +383,20 @@
json_dict
[
input
.
name
]
=
input
.
value
.
split
(
'
\n
'
);
json_dict
[
input
.
name
]
=
input
.
value
.
split
(
'
\n
'
);
}
}
}
else
if
(
input
.
tagName
===
"
SELECT
"
)
{
}
else
if
(
input
.
tagName
===
"
SELECT
"
)
{
if
(
input
.
getAttribute
(
"
data-format
"
)
===
"
number
"
)
{
if
(
data_format
===
"
number
"
||
data_format
===
"
integer
"
)
{
json_dict
[
input
.
name
]
=
parseFloat
(
input
.
value
);
// Integer must use parseFloat, otherwise the value is rounded
}
else
if
(
input
.
getAttribute
(
"
data-format
"
)
===
"
integer
"
)
{
// loosing user's input.
// Don't use parseInt since it will round the value, modifing the
if
(
isNaN
(
parseFloat
(
input
.
value
)))
{
// use input. So we keep it the value.
json_dict
[
input
.
name
]
=
input
.
value
;
}
else
{
json_dict
[
input
.
name
]
=
parseFloat
(
input
.
value
);
json_dict
[
input
.
name
]
=
parseFloat
(
input
.
value
);
}
}
else
if
(
input
.
getAttribute
(
"
data-format
"
)
===
"
boolean
"
)
{
if
(
input
.
value
===
"
true
"
||
input
.
value
===
"
false
"
)
{
json_dict
[
input
.
name
]
=
Boolean
(
input
.
value
);
}
else
{
json_dict
[
input
.
name
]
=
input
.
value
;
}
}
else
{
}
else
{
json_dict
[
input
.
name
]
=
input
.
value
;
json_dict
[
input
.
name
]
=
input
.
value
;
}
}
...
@@ -585,10 +603,10 @@
...
@@ -585,10 +603,10 @@
for
(
error_index
in
validation
.
errors
)
{
for
(
error_index
in
validation
.
errors
)
{
if
(
validation
.
errors
.
hasOwnProperty
(
error_index
))
{
if
(
validation
.
errors
.
hasOwnProperty
(
error_index
))
{
field_name
=
validation
.
errors
[
error_index
].
dataPath
;
field_name
=
validation
.
errors
[
error_index
].
dataPath
;
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
field_name
+
"
']
"
)
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
field_name
+
"
']
"
)
;
if
(
input_field
===
null
)
{
if
(
input_field
===
null
)
{
field_name
=
field_name
.
split
(
"
/
"
).
slice
(
0
,
-
1
).
join
(
"
/
"
)
field_name
=
field_name
.
split
(
"
/
"
).
slice
(
0
,
-
1
).
join
(
"
/
"
)
;
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
field_name
+
"
']
"
)
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
field_name
+
"
']
"
)
;
}
}
div
=
input_field
.
parentNode
;
div
=
input_field
.
parentNode
;
div
.
setAttribute
(
"
class
"
,
"
slapos-parameter error-input
"
);
div
.
setAttribute
(
"
class
"
,
"
slapos-parameter error-input
"
);
...
@@ -599,17 +617,17 @@
...
@@ -599,17 +617,17 @@
for
(
missing_index
in
validation
.
missing
)
{
for
(
missing_index
in
validation
.
missing
)
{
if
(
validation
.
missing
.
hasOwnProperty
(
missing_index
))
{
if
(
validation
.
missing
.
hasOwnProperty
(
missing_index
))
{
missing_field_name
=
validation
.
missing
[
missing_index
].
dataPath
;
missing_field_name
=
validation
.
missing
[
missing_index
].
dataPath
;
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
missing_field_name
+
"
']
"
)
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
missing_field_name
+
"
']
"
)
;
if
(
input_field
===
null
)
{
if
(
input_field
===
null
)
{
missing_field_name
=
field_name
.
split
(
"
/
"
).
slice
(
0
,
-
1
).
join
(
"
/
"
)
missing_field_name
=
field_name
.
split
(
"
/
"
).
slice
(
0
,
-
1
).
join
(
"
/
"
)
;
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
missing_field_name
+
"
']
"
)
input_field
=
g
.
element
.
querySelector
(
"
.slapos-parameter[name='/
"
+
missing_field_name
+
"
']
"
)
;
}
}
divm
=
input_field
.
parentNode
;
divm
=
input_field
.
parentNode
;
divm
.
setAttribute
(
"
class
"
,
"
error-input
"
);
divm
.
setAttribute
(
"
class
"
,
"
error-input
"
);
divm
.
querySelector
(
"
span.error
"
).
textContent
=
validation
.
missing
[
missing_index
].
message
;
divm
.
querySelector
(
"
span.error
"
).
textContent
=
validation
.
missing
[
missing_index
].
message
;
}
}
}
}
return
"
ERROR
"
;
return
xml_output
;
});
});
}
}
...
@@ -1058,6 +1076,11 @@
...
@@ -1058,6 +1076,11 @@
content_dict
.
shared
=
1
;
content_dict
.
shared
=
1
;
}
}
if
(
text_content
!==
null
)
{
if
(
text_content
!==
null
)
{
// Don't provide blank string since the parameter will not able to load
// itself. If the user removed the values, provide an empty parameter default.
if
(
text_content
.
value
===
""
)
{
return
'
<?xml version="1.0" encoding="utf-8" ?><instance></instance>
'
;
}
return
text_content
.
value
;
return
text_content
.
value
;
}
}
return
checkValidity
(
gadget
);
return
checkValidity
(
gadget
);
...
...
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js.xml
View file @
114d59fa
...
@@ -280,7 +280,7 @@
...
@@ -280,7 +280,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1000.
9806.10724.60689
</string>
</value>
<value>
<string>
1000.
14042.12571.63982
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -298,7 +298,7 @@
...
@@ -298,7 +298,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1652
220502.37
</float>
<float>
1652
712920.56
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simplebaddemo.xml
0 → 100644
View file @
114d59fa
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Folder"
module=
"OFS.Folder"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_objects
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
simplebaddemo
</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/simplebaddemo/instance-input-schema.json.json
0 → 100644
View file @
114d59fa
{
"$schema"
:
"http://json-schema.org/draft-04/schema#"
,
"type"
:
"object"
,
"description"
:
"Sample paremeters for a Simple Demo with broken or bad standards"
,
"additionalProperties"
:
false
,
"properties"
:
{
"simple-boolean-as-string"
:
{
"title"
:
"Example of Boolean defined as String (WORKS BUT BAD PATTERN)"
,
"description"
:
"Example of Boolean defined as String (WORKS BUT BAD PATTERN)"
,
"enum"
:
[
"false"
,
"true"
],
"type"
:
"string"
},
"simple-boolean"
:
{
"title"
:
"Correct Boolean definition"
,
"description"
:
"Correct Boolean definition"
,
"type"
:
"boolean"
,
"default"
:
true
}
}
}
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simplebaddemo/instance-input-schema.json.xml
0 → 100644
View file @
114d59fa
<?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-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/simplebaddemo/software.cfg.json.json
0 → 100644
View file @
114d59fa
{
"name"
:
"Simple Demo following bad parameters"
,
"description"
:
"Demo Simple following bad parameters"
,
"serialisation"
:
"xml"
,
"software-type"
:
{
"default"
:
{
"title"
:
"Default"
,
"description"
:
"Default reference parameters"
,
"request"
:
"instance-input-schema.json"
,
"response"
:
"instance-output-schema.json"
,
"index"
:
0
}
}
}
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simplebaddemo/software.cfg.json.xml
0 → 100644
View file @
114d59fa
<?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>
software.cfg.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/simplebaddemo/software.cfg.txt
0 → 100644
View file @
114d59fa
# Required to mimic software releases
\ No newline at end of file
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simplebaddemo/software.cfg.xml
0 → 100644
View file @
114d59fa
<?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>
software.cfg
</string>
</value>
</item>
<item>
<key>
<string>
content_type
</string>
</key>
<value>
<string>
text/plain
</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/instance-input-json-in-xml-schema.json.json
View file @
114d59fa
...
@@ -26,6 +26,62 @@
...
@@ -26,6 +26,62 @@
"description"
:
"Example of Array of Numbers"
,
"description"
:
"Example of Array of Numbers"
,
"type"
:
"array"
,
"type"
:
"array"
,
"items"
:
{
"type"
:
"number"
}
"items"
:
{
"type"
:
"number"
}
},
"simple-object"
:
{
"title"
:
"Example of Single Object"
,
"description"
:
"Example of Single Object"
,
"type"
:
"object"
,
"properties"
:
{
"sample-object-string"
:
{
"title"
:
"Example of Simple String on an object"
,
"description"
:
"Example of Simple String"
,
"type"
:
"string"
,
"default"
:
"Simple string "
},
"simple-object-with-integer"
:
{
"title"
:
"Example of Simple Integer"
,
"description"
:
"Example of Simple Integer"
,
"type"
:
"integer"
,
"default"
:
1
},
"simple-object-with-integer-with-enum"
:
{
"title"
:
"Example of Simple Integer with enum"
,
"description"
:
"Example of Simple Integer with enum"
,
"type"
:
"integer"
,
"default"
:
1
,
"enum"
:
[
1
,
2
]
}
}
},
"simple-object-dict"
:
{
"title"
:
"Example of multi objects as a Dict"
,
"description"
:
"Example of multi objects as a Dict"
,
"type"
:
"object"
,
"patternProperties"
:
{
".*"
:
{
"properties"
:
{
"simple-object-dict-string-example"
:
{
"title"
:
"Example of the String as part of Object"
,
"description"
:
"Example of the String as part of Object"
,
"type"
:
"string"
,
"default"
:
""
},
"simple-object-dict-string-with-enum"
:
{
"title"
:
"Example of the String as part of Object with Enum"
,
"description"
:
"Example of the String as part of Object with Enum"
,
"type"
:
"string"
,
"default"
:
"String Sample A"
,
"enum"
:
[
"String Sample A"
,
"String Sample B"
]
}
}
}
}
}
}
}
}
}
}
...
...
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/sample-software-schema/simpledemo/instance-input-schema.json.json
View file @
114d59fa
...
@@ -21,6 +21,12 @@
...
@@ -21,6 +21,12 @@
],
],
"default"
:
"simple string A"
"default"
:
"simple string A"
},
},
"simple-boolean"
:
{
"title"
:
"Example of Simple String"
,
"description"
:
"Example of Simple String"
,
"type"
:
"boolean"
,
"default"
:
true
},
"simple-string-with-text-area"
:
{
"simple-string-with-text-area"
:
{
"title"
:
"Example of Simple String with textarea"
,
"title"
:
"Example of Simple String with textarea"
,
"description"
:
"Example of Simple String with text area"
,
"description"
:
"Example of Simple String with text area"
,
...
...
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