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
Titouan Soulard
slapos.core
Commits
724f3ab3
Commit
724f3ab3
authored
May 09, 2023
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Plain Diff
slapos_jio: Improve intent gadget to be handle Error better
See merge request
nexedi/slapos.core!523
parents
0d691d7f
25ec1d12
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
142 additions
and
89 deletions
+142
-89
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSCodingStyle.py
...Item/portal_components/test.erp5.testSlapOSCodingStyle.py
+0
-1
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_intent_html.html
...eb_page_module/rjs_gadget_erp5_page_slap_intent_html.html
+4
-2
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_intent_html.xml
...web_page_module/rjs_gadget_erp5_page_slap_intent_html.xml
+2
-2
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_intent_js.js
...em/web_page_module/rjs_gadget_erp5_page_slap_intent_js.js
+63
-76
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_intent_js.xml
...m/web_page_module/rjs_gadget_erp5_page_slap_intent_js.xml
+2
-2
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/SoftwareProduct_getSoftwareReleaseAsHateoas.py
...json_style/SoftwareProduct_getSoftwareReleaseAsHateoas.py
+10
-5
master/bt5/slapos_jio/TestTemplateItem/portal_components/test.erp5.testSlapOSHalJsonStyleSkins.py
...ortal_components/test.erp5.testSlapOSHalJsonStyleSkins.py
+61
-1
No files found.
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSCodingStyle.py
View file @
724f3ab3
...
@@ -259,7 +259,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
...
@@ -259,7 +259,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_hal_json_style/SaleInvoiceTransaction_getRelatedPaymentTransactionIntegrationId'
,
'slapos_hal_json_style/SaleInvoiceTransaction_getRelatedPaymentTransactionIntegrationId'
,
'slapos_hal_json_style/SoftwareInstallation_getSoftwareReleaseInformation'
,
'slapos_hal_json_style/SoftwareInstallation_getSoftwareReleaseInformation'
,
'slapos_hal_json_style/SoftwareInstance_getReportedState'
,
'slapos_hal_json_style/SoftwareInstance_getReportedState'
,
'slapos_hal_json_style/SoftwareProduct_getSoftwareReleaseAsHateoas'
,
'slapos_hal_json_style/SoftwareRelease_requestInstanceTree'
,
'slapos_hal_json_style/SoftwareRelease_requestInstanceTree'
,
'slapos_hal_json_style/SoftwareRelease_requestSoftwareInstallation'
,
'slapos_hal_json_style/SoftwareRelease_requestSoftwareInstallation'
,
'slapos_hal_json_style/SupportRequest_close'
,
'slapos_hal_json_style/SupportRequest_close'
,
...
...
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_intent_html.html
View file @
724f3ab3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<head>
<head>
<meta
http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
/>
<meta
http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no"
/>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no"
/>
<title>
Site List
</title>
<title>
Intent page
</title>
<!-- renderjs -->
<!-- renderjs -->
<script
src=
"rsvp.js"
type=
"text/javascript"
></script>
<script
src=
"rsvp.js"
type=
"text/javascript"
></script>
...
@@ -19,7 +19,9 @@
...
@@ -19,7 +19,9 @@
</head>
</head>
<body>
<body>
<p>
Wait, you are going to be redirected automatically.
</p>
<div
class=
"message"
>
<p>
Wait, you are going to be redirected automatically.
</p>
</div>
<form
class=
"save_form ui-body-c"
novalidate
>
<form
class=
"save_form ui-body-c"
novalidate
>
<button
type=
"submit"
class=
"ui-btn ui-btn-b ui-btn-inline
<button
type=
"submit"
class=
"ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"
></button>
ui-icon-edit ui-btn-icon-right ui-screen-hidden"
></button>
...
...
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_intent_html.xml
View file @
724f3ab3
...
@@ -242,7 +242,7 @@
...
@@ -242,7 +242,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
982.16656.9604.44475
</string>
</value>
<value>
<string>
1008.12324.34619.3993
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -262,7 +262,7 @@
...
@@ -262,7 +262,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1
583501586.1
7
</float>
<float>
1
683223974.8
7
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_intent_js.js
View file @
724f3ab3
...
@@ -27,32 +27,6 @@
...
@@ -27,32 +27,6 @@
return
this
.
triggerSubmit
();
return
this
.
triggerSubmit
();
})
})
.
onEvent
(
'
submit
'
,
function
()
{
var
gadget
=
this
;
return
gadget
.
notifySubmitting
()
.
push
(
function
()
{
return
gadget
.
getDeclaredGadget
(
'
form_view
'
);
})
.
push
(
function
(
form_gadget
)
{
return
form_gadget
.
getContent
();
})
.
push
(
function
(
doc
)
{
return
gadget
.
getSetting
(
"
hateoas_url
"
)
.
push
(
function
(
url
)
{
return
gadget
.
jio_putAttachment
(
doc
.
relative_url
,
url
+
doc
.
relative_url
+
"
/SoftwareRelease_requestInstanceTree
"
,
doc
);
});
})
.
push
(
function
()
{
return
gadget
.
notifySubmitted
({
message
:
gadget
.
message_tranlation
,
status
:
'
success
'
})
.
push
(
function
()
{
// Workaround, find a way to open document without break gadget.
return
gadget
.
redirect
({
"
command
"
:
"
change
"
,
"
options
"
:
{
"
jio_key
"
:
"
/
"
,
"
page
"
:
"
slap_service_list
"
}});
});
});
})
.
declareMethod
(
"
triggerSubmit
"
,
function
()
{
.
declareMethod
(
"
triggerSubmit
"
,
function
()
{
return
this
.
element
.
querySelector
(
'
button[type="submit"]
'
).
click
();
return
this
.
element
.
querySelector
(
'
button[type="submit"]
'
).
click
();
})
})
...
@@ -90,7 +64,7 @@
...
@@ -90,7 +64,7 @@
});
});
})
})
.
onStateChange
(
function
(
options
)
{
.
onStateChange
(
function
(
options
)
{
this
.
deferRender
(
options
);
return
this
.
deferRender
(
options
);
})
})
.
declareJob
(
"
deferRender
"
,
function
(
options
)
{
.
declareJob
(
"
deferRender
"
,
function
(
options
)
{
var
gadget
=
this
;
var
gadget
=
this
;
...
@@ -99,9 +73,13 @@
...
@@ -99,9 +73,13 @@
}
}
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
updateHeader
({
return
gadget
.
getUrlFor
({
command
:
'
history_previous
'
})
page_title
:
gadget
.
page_title_translation
.
push
(
function
(
selection_url
)
{
});
return
gadget
.
updateHeader
({
page_title
:
gadget
.
page_title_translation
,
selection_url
:
selection_url
});
});
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
getSetting
(
"
hateoas_url
"
)
return
gadget
.
getSetting
(
"
hateoas_url
"
)
...
@@ -114,6 +92,12 @@
...
@@ -114,6 +92,12 @@
});
});
})
})
.
push
(
function
(
jio_key
)
{
.
push
(
function
(
jio_key
)
{
var
div
;
if
((
jio_key
===
undefined
)
||
(
jio_key
===
""
))
{
div
=
gadget
.
element
.
querySelector
(
"
div.message
"
);
div
.
textContent
=
gadget
.
error_translation
+
"
: could not find software release
"
;
return
div
;
}
if
(
options
.
auto
===
undefined
)
{
if
(
options
.
auto
===
undefined
)
{
return
gadget
.
redirect
({
"
command
"
:
"
change
"
,
return
gadget
.
redirect
({
"
command
"
:
"
change
"
,
"
options
"
:
{
"
jio_key
"
:
jio_key
,
"
page
"
:
"
slap_add_instance_tree
"
,
"
options
"
:
{
"
jio_key
"
:
jio_key
,
"
page
"
:
"
slap_add_instance_tree
"
,
...
@@ -121,58 +105,61 @@
...
@@ -121,58 +105,61 @@
}
}
// The auto is set, so we move foward to auto request the SR
// The auto is set, so we move foward to auto request the SR
options
.
jio_key
=
jio_key
;
options
.
jio_key
=
jio_key
;
return
RSVP
.
all
([
return
new
RSVP
.
Queue
()
gadget
.
getDeclaredGadget
(
'
form_view
'
),
gadget
.
jio_get
(
jio_key
),
gadget
.
getSetting
(
"
hateoas_url
"
)
]);
})
.
push
(
function
(
result
)
{
var
software_release
=
result
[
1
],
url
=
result
[
2
],
doc
=
{
url_string
:
software_release
.
url_string
,
title
:
options
.
software_title
?
options
.
software_title
:
gadget
.
software_title_translation
+
"
{uid}
"
,
relative_url
:
options
.
jio_key
};
if
(
options
.
software_type
)
{
doc
.
software_type
=
options
.
software_type
;
}
if
(
options
.
text_content
)
{
doc
.
text_content
=
options
.
text_content
;
}
if
(
options
.
shared
)
{
doc
.
shared
=
options
.
shared
;
}
if
(
options
.
sla_xml
)
{
doc
.
sla_xml
=
options
.
sla_xml
;
}
return
gadget
.
notifySubmitting
()
.
push
(
function
()
{
.
push
(
function
()
{
var
query
=
[];
return
RSVP
.
all
([
query
.
push
(
"
title=
"
+
encodeURIComponent
(
doc
.
title
));
gadget
.
getDeclaredGadget
(
'
form_view
'
),
gadget
.
jio_get
(
jio_key
),
if
(
doc
.
software_type
)
{
gadget
.
getSetting
(
"
hateoas_url
"
)
query
.
push
(
"
software_type=
"
+
encodeURIComponent
(
doc
.
software_type
));
]);
})
.
push
(
function
(
result
)
{
var
software_release
=
result
[
1
],
url
=
result
[
2
],
doc
=
{
url_string
:
software_release
.
url_string
,
title
:
options
.
software_title
?
options
.
software_title
:
gadget
.
software_title_translation
+
"
{uid}
"
,
relative_url
:
options
.
jio_key
};
if
(
options
.
software_type
)
{
doc
.
software_type
=
options
.
software_type
;
}
}
if
(
doc
.
shared
)
{
if
(
options
.
text_content
)
{
query
.
push
(
"
shared:int=
"
+
encodeURIComponent
(
doc
.
shared
))
;
doc
.
text_content
=
options
.
text_content
;
}
}
if
(
doc
.
text_content
)
{
if
(
options
.
shared
)
{
query
.
push
(
"
text_content=
"
+
encodeURIComponent
(
doc
.
text_content
))
;
doc
.
shared
=
options
.
shared
;
}
}
if
(
doc
.
sla_xml
)
{
if
(
options
.
sla_xml
)
{
query
.
push
(
"
sla_xml=
"
+
encodeURIComponent
(
doc
.
sla_xml
))
;
doc
.
sla_xml
=
options
.
sla_xml
;
}
}
return
gadget
.
jio_getAttachment
(
doc
.
relative_url
,
return
gadget
.
notifySubmitting
()
url
+
doc
.
relative_url
+
"
/SoftwareRelease_requestInstanceTree?
"
+
query
.
join
(
"
&
"
));
})
.
push
(
function
(
key
)
{
return
gadget
.
notifySubmitted
({
message
:
gadget
.
message_tranlation
,
status
:
'
success
'
})
.
push
(
function
()
{
.
push
(
function
()
{
// Workaround, find a way to open document without break gadget.
var
query
=
[];
return
gadget
.
redirect
({
"
command
"
:
"
change
"
,
query
.
push
(
"
title=
"
+
encodeURIComponent
(
doc
.
title
));
"
options
"
:
{
"
jio_key
"
:
key
,
"
page
"
:
"
slap_controller
"
}});
if
(
doc
.
software_type
)
{
query
.
push
(
"
software_type=
"
+
encodeURIComponent
(
doc
.
software_type
));
}
if
(
doc
.
shared
)
{
query
.
push
(
"
shared:int=
"
+
encodeURIComponent
(
doc
.
shared
));
}
if
(
doc
.
text_content
)
{
query
.
push
(
"
text_content=
"
+
encodeURIComponent
(
doc
.
text_content
));
}
if
(
doc
.
sla_xml
)
{
query
.
push
(
"
sla_xml=
"
+
encodeURIComponent
(
doc
.
sla_xml
));
}
return
gadget
.
jio_getAttachment
(
doc
.
relative_url
,
url
+
doc
.
relative_url
+
"
/SoftwareRelease_requestInstanceTree?
"
+
query
.
join
(
"
&
"
));
})
.
push
(
function
(
key
)
{
return
gadget
.
notifySubmitted
({
message
:
gadget
.
message_tranlation
,
status
:
'
success
'
})
.
push
(
function
()
{
// Workaround, find a way to open document without break gadget.
return
gadget
.
redirect
({
"
command
"
:
"
change
"
,
"
options
"
:
{
"
jio_key
"
:
key
,
"
page
"
:
"
slap_controller
"
}});
});
});
});
});
});
});
});
...
...
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_intent_js.xml
View file @
724f3ab3
...
@@ -283,7 +283,7 @@
...
@@ -283,7 +283,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
986.45437.22132.61764
</string>
</value>
<value>
<string>
1008.12332.26729.18090
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -303,7 +303,7 @@
...
@@ -303,7 +303,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
16
02259520.17
</float>
<float>
16
83224657.13
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/SoftwareProduct_getSoftwareReleaseAsHateoas.py
View file @
724f3ab3
import
json
import
json
software_release_relative_url
=
""
kw
=
{
"software_release_url"
:
software_release
,
"strict"
:
strict
}
if
software_release
.
startswith
(
"product."
):
if
software_release
.
startswith
(
"product."
):
software_release_list
=
context
.
SoftwareProduct_getSortedSoftwareReleaseList
(
software_product_reference
=
software_release
[
8
:])
kw
=
{
"software_product_reference"
:
software_release
[
8
:]}
else
:
software_release_list
=
context
.
SoftwareProduct_getSortedSoftwareReleaseList
(
software_release_url
=
software_release
,
strict
=
strict
)
software_release_list
=
context
.
SoftwareProduct_getSortedSoftwareReleaseList
(
**
kw
)
if
len
(
software_release_list
):
if
len
(
software_release_list
):
software_release_
document
=
software_release_list
[
0
]
software_release_
relative_url
=
software_release_list
[
0
].
getRelativeUrl
()
return
json
.
dumps
(
software_release_
document
.
getRelativeUrl
()
)
return
json
.
dumps
(
software_release_
relative_url
)
master/bt5/slapos_jio/TestTemplateItem/portal_components/test.erp5.testSlapOSHalJsonStyleSkins.py
View file @
724f3ab3
...
@@ -1739,4 +1739,64 @@ class TestInstanceTree_getFastInputDict(TestSlapOSHalJsonStyleMixin):
...
@@ -1739,4 +1739,64 @@ class TestInstanceTree_getFastInputDict(TestSlapOSHalJsonStyleMixin):
self
.
assertEqual
({
self
.
assertEqual
({
'enabled'
:
True
,
'enabled'
:
True
,
'sla_xml'
:
'<parameter id="instance_guid">%s</parameter>'
%
software_instance
.
getReference
()
'sla_xml'
:
'<parameter id="instance_guid">%s</parameter>'
%
software_instance
.
getReference
()
},
self
.
instance_tree
.
InstanceTree_getFastInputDict
())
},
self
.
instance_tree
.
InstanceTree_getFastInputDict
())
\ No newline at end of file
class
TestSoftwareProduct_getSoftwareReleaseAsHateoas
(
TestSlapOSHalJsonStyleMixin
):
@
simulate
(
'SoftwareProduct_getSortedSoftwareReleaseList'
,
'software_product_reference=None, software_release_url=None, strict=None'
,
"""
assert software_product_reference == 'fake'
assert software_release_url is None
assert strict is None
return context.REQUEST['test_software_release_list']"""
)
def
test_product_reference
(
self
):
sr
=
self
.
_makeSoftwareRelease
()
self
.
changeSkin
(
'RJS'
)
self
.
portal
.
REQUEST
[
'test_software_release_list'
]
=
[
sr
]
self
.
assertEqual
(
sr
.
getRelativeUrl
(),
json
.
loads
(
self
.
portal
.
SoftwareProduct_getSoftwareReleaseAsHateoas
(
"product.fake"
))
)
@
simulate
(
'SoftwareProduct_getSortedSoftwareReleaseList'
,
'software_product_reference=None, software_release_url=None, strict=None'
,
"""
assert software_product_reference is None
assert software_release_url == 'fake'
assert strict is False
return context.REQUEST['test_software_release_list']"""
)
def
test_software_release
(
self
):
sr
=
self
.
_makeSoftwareRelease
()
self
.
changeSkin
(
'RJS'
)
self
.
portal
.
REQUEST
[
'test_software_release_list'
]
=
[
sr
]
self
.
assertEqual
(
sr
.
getRelativeUrl
(),
json
.
loads
(
self
.
portal
.
SoftwareProduct_getSoftwareReleaseAsHateoas
(
"fake"
))
)
@
simulate
(
'SoftwareProduct_getSortedSoftwareReleaseList'
,
'software_product_reference=None, software_release_url=None, strict=None'
,
"""
assert software_product_reference is None
assert software_release_url == 'fake'
assert strict is True
return []"""
)
def
test_software_release_not_found
(
self
):
self
.
changeSkin
(
'RJS'
)
self
.
assertEqual
(
''
,
json
.
loads
(
self
.
portal
.
SoftwareProduct_getSoftwareReleaseAsHateoas
(
"fake"
,
True
))
)
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