Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
87045a15
Commit
87045a15
authored
Jun 01, 2022
by
Cédric Le Ninivin
Committed by
Titouan Soulard
Nov 15, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_api_style: Add view API call as cURL in API view gadget
parent
29448c5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
12 deletions
+72
-12
bt5/erp5_api_style/PathTemplateItem/web_page_module/gadget_erp5_page_json_form_schema_api_js.js
...b_page_module/gadget_erp5_page_json_form_schema_api_js.js
+70
-10
bt5/erp5_api_style/PathTemplateItem/web_page_module/gadget_erp5_page_json_form_schema_api_js.xml
..._page_module/gadget_erp5_page_json_form_schema_api_js.xml
+2
-2
No files found.
bt5/erp5_api_style/PathTemplateItem/web_page_module/gadget_erp5_page_json_form_schema_api_js.js
View file @
87045a15
...
@@ -68,6 +68,52 @@
...
@@ -68,6 +68,52 @@
}
}
function
renderCurlCall
(
gadget
,
data
,
element
)
{
var
curl_call
;
curl_call
=
"
curl -X 'POST'
\\\n
"
+
"
"
+
gadget
.
state
.
api_url
+
"
\\\n
"
+
"
-H 'accept: application/json'
\\\n
"
+
"
-H 'Content-Type: application/json'
\\\n
"
+
"
-d '
"
+
data
+
"
'
\\\n
"
+
"
-u your_username:your_password
"
;
domsugar
(
element
,
[
domsugar
(
"
section
"
,
{
"
class
"
:
"
ui-content-header-plain
"
},
[
domsugar
(
"
br
"
),
domsugar
(
"
h3
"
,
[
"
Curl Call
"
]),
domsugar
(
"
br
"
)]),
domsugar
(
"
p
"
,
[
domsugar
(
"
code
"
,
[
domsugar
(
"
pre
"
,
[
curl_call
])])])
]
);
}
function
displayCurlContent
(
gadget
)
{
var
form_gadget
;
return
gadget
.
getDeclaredGadget
(
"
form_schema
"
)
.
push
(
function
(
result
)
{
form_gadget
=
result
;
return
form_gadget
.
checkValidity
()
.
push
(
function
(
is_valid
)
{
if
(
!
is_valid
)
{
return
gadget
.
notifySubmitted
({
"
message
"
:
"
Data is not Valid, please make sure no error is left.
"
,
"
status
"
:
"
failed
"
});
}
return
form_gadget
.
getContent
()
.
push
(
function
(
content_dict
)
{
var
json_data
=
content_dict
.
my_key
;
return
renderCurlCall
(
gadget
,
json_data
,
gadget
.
element
.
querySelector
(
'
.data-response
'
)
);
});
});
});
}
function
sendContent
(
gadget
,
data
)
{
function
sendContent
(
gadget
,
data
)
{
var
url
=
gadget
.
state
.
api_url
,
var
url
=
gadget
.
state
.
api_url
,
http_method
;
http_method
;
...
@@ -128,7 +174,6 @@
...
@@ -128,7 +174,6 @@
var
json_data
=
content_dict
.
my_key
,
var
json_data
=
content_dict
.
my_key
,
status
,
status
,
message
;
message
;
console
.
log
(
json_data
);
return
sendContent
(
gadget
,
json_data
)
return
sendContent
(
gadget
,
json_data
)
.
push
(
function
(
response
)
{
.
push
(
function
(
response
)
{
enableButton
();
enableButton
();
...
@@ -289,15 +334,26 @@
...
@@ -289,15 +334,26 @@
domsugar
(
domsugar
(
gadget
.
element
gadget
.
element
.
querySelector
(
'
.dialog_button_container
'
),
.
querySelector
(
'
.dialog_button_container
'
),
[
domsugar
(
[
'
input
'
,
domsugar
(
{
'
input
'
,
name
:
'
action_confirm
'
,
{
'
class
'
:
'
dialogconfirm
'
,
name
:
'
action_confirm
'
,
type
:
'
submit
'
,
'
class
'
:
'
dialogconfirm
'
,
value
:
"
Send
"
type
:
'
submit
'
,
}
value
:
"
Send
"
)]
}
),
domsugar
(
'
input
'
,
{
name
:
'
get_curl
'
,
'
class
'
:
'
dialogconfirm
'
,
type
:
'
submit
'
,
value
:
"
Generate Curl
"
}
)
]
);
);
displayAPIInformation
(
gadget
);
displayAPIInformation
(
gadget
);
return
gadget
.
getUrlFor
({
command
:
'
display
'
,
options
:
{
return
gadget
.
getUrlFor
({
command
:
'
display
'
,
options
:
{
...
@@ -319,6 +375,10 @@
...
@@ -319,6 +375,10 @@
evt
.
preventDefault
();
evt
.
preventDefault
();
return
submitDialog
(
this
);
return
submitDialog
(
this
);
}
}
if
(
evt
.
target
.
name
===
"
get_curl
"
)
{
evt
.
preventDefault
();
return
displayCurlContent
(
this
);
}
},
false
,
false
)
},
false
,
false
)
.
onEvent
(
'
submit
'
,
function
submit
()
{
.
onEvent
(
'
submit
'
,
function
submit
()
{
return
submitDialog
(
this
);
return
submitDialog
(
this
);
...
...
bt5/erp5_api_style/PathTemplateItem/web_page_module/gadget_erp5_page_json_form_schema_api_js.xml
View file @
87045a15
...
@@ -242,7 +242,7 @@
...
@@ -242,7 +242,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
1000.3
76.45673.9557
</string>
</value>
<value>
<string>
1000.3
573.16294.22084
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -260,7 +260,7 @@
...
@@ -260,7 +260,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1651
654628.56
</float>
<float>
1651
846416.67
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
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