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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gabriel Monnerat
erp5
Commits
c171e108
Commit
c171e108
authored
Mar 15, 2023
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_web_renderjs_ui: Move functions that build error_text from error to global gadget
parent
817bf6bf
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
166 additions
and
135 deletions
+166
-135
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_global_js.js
...TemplateItem/web_page_module/rjs_gadget_erp5_global_js.js
+122
-3
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_global_js.xml
...emplateItem/web_page_module/rjs_gadget_erp5_global_js.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.js
...mplateItem/web_page_module/rjs_gadget_erp5_launcher_js.js
+40
-128
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.xml
...plateItem/web_page_module/rjs_gadget_erp5_launcher_js.xml
+2
-2
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_global_js.js
View file @
c171e108
/*global window, RSVP, SimpleQuery, ComplexQuery, Query,
ensureArray, Array*/
ensureArray, Array
, domsugar, Event, XMLHttpRequest, navigator
*/
/*jslint indent: 2, maxerr: 3, nomen: true, unparam: true, continue: true */
(
function
(
window
,
RSVP
,
SimpleQuery
,
ComplexQuery
,
Query
,
ensureArray
,
Array
)
{
ensureArray
,
Array
,
domsugar
,
Event
,
XMLHttpRequest
,
navigator
)
{
"
use strict
"
;
///////////////////////////////
...
...
@@ -292,6 +292,122 @@
return
url_mapping
;
}
function
convertOriginalErrorToErrorDataList
(
original_error
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
var
error_list
=
[
original_error
],
i
,
error
,
error_response
,
error_text
=
""
;
// Do not break the application in case of errors.
// Display it to the user for now,
// and allow user to go back to the frontpage
// Add error handling stack
error_list
.
push
(
new
Error
(
'
stopping ERP5JS
'
));
for
(
i
=
0
;
i
<
error_list
.
length
;
i
+=
1
)
{
error
=
error_list
[
i
];
if
(
error
instanceof
Event
)
{
error
=
{
string
:
error
.
toString
(),
message
:
error
.
message
,
type
:
error
.
type
,
target
:
error
.
target
};
if
(
error
.
target
!==
undefined
)
{
error_list
.
splice
(
i
+
1
,
0
,
error
.
target
);
}
}
if
(
error
instanceof
XMLHttpRequest
)
{
if
((
error
.
getResponseHeader
(
'
Content-Type
'
)
||
""
)
.
indexOf
(
'
text/
'
)
===
0
)
{
error_response
=
error
.
response
;
}
error
=
{
message
:
error
.
toString
(),
readyState
:
error
.
readyState
,
status
:
error
.
status
,
statusText
:
error
.
statusText
,
response
:
error
.
response
,
responseUrl
:
error
.
responseUrl
,
response_headers
:
(
error
.
getAllResponseHeaders
()
?
error
.
getAllResponseHeaders
().
split
(
'
\r\n
'
)
:
null
)
};
}
if
(
error
.
constructor
===
Array
||
error
.
constructor
===
String
||
error
.
constructor
===
Object
)
{
try
{
error
=
JSON
.
stringify
(
error
,
null
,
'
'
);
}
catch
(
ignore
)
{
}
}
error_text
+=
error
.
message
||
error
;
error_text
+=
'
\n
'
;
if
(
error
.
fileName
!==
undefined
)
{
error_text
+=
'
File:
'
+
error
.
fileName
+
'
:
'
+
error
.
lineNumber
+
'
\n
'
;
}
if
(
error
.
stack
!==
undefined
)
{
error_text
+=
'
Stack:
'
+
error
.
stack
+
'
\n
'
;
}
error_text
+=
'
---
\n
'
;
}
if
(
error_response
&&
!
error
.
response
)
{
error
.
response
=
error_response
;
}
return
[
error
,
error_text
];
});
}
function
buildErrorElementFromErrorText
(
error_text
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
domsugar
(
"
section
"
,
[
domsugar
(
"
p
"
,
{
"
text
"
:
'
Please report this unhandled error to the support
'
+
'
team, and go back to the
'
},
[
domsugar
(
"
a
"
,
{
"
href
"
:
"
#
"
,
"
text
"
:
"
homepage
"
})
]),
domsugar
(
"
br
"
),
domsugar
(
"
p
"
,
{
"
text
"
:
'
Location:
'
},
[
domsugar
(
"
a
"
,
{
"
href
"
:
window
.
location
.
toString
(),
"
text
"
:
window
.
location
.
toString
()
})
]),
domsugar
(
"
p
"
,
{
"
text
"
:
'
User-agent:
'
+
navigator
.
userAgent
}),
domsugar
(
"
p
"
,
{
"
text
"
:
'
Date:
'
+
new
Date
(
Date
.
now
()).
toISOString
()
}),
domsugar
(
"
p
"
,
{
"
text
"
:
'
Online:
'
+
navigator
.
onLine
}),
domsugar
(
"
br
"
),
domsugar
(
"
pre
"
,
[
domsugar
(
"
code
"
,
{
"
text
"
:
error_text
})
])
]);
});
}
function
getListboxClipboardActionList
()
{
var
action_list
=
ensureArray
(
this
.
state
.
erp5_document
.
_links
.
action_object_list_action
||
[]),
i
,
...
...
@@ -441,7 +557,10 @@
}
window
.
mergeGlobalActionWithRawActionList
=
mergeGlobalActionWithRawActionList
;
window
.
triggerListboxClipboardAction
=
triggerListboxClipboardAction
;
window
.
convertOriginalErrorToErrorDataList
=
convertOriginalErrorToErrorDataList
;
window
.
buildErrorElementFromErrorText
=
buildErrorElementFromErrorText
;
window
.
declareGadgetClassCanHandleListboxClipboardAction
=
declareGadgetClassCanHandleListboxClipboardAction
;
}(
window
,
RSVP
,
SimpleQuery
,
ComplexQuery
,
Query
,
ensureArray
,
Array
));
\ No newline at end of file
}(
window
,
RSVP
,
SimpleQuery
,
ComplexQuery
,
Query
,
ensureArray
,
Array
,
domsugar
,
Event
,
XMLHttpRequest
,
navigator
));
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_global_js.xml
View file @
c171e108
...
...
@@ -236,7 +236,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
991.63236.62412.49203
</string>
</value>
<value>
<string>
1007.4418.49274.62395
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>
16
20739824.54
</float>
<float>
16
78908170.99
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.js
View file @
c171e108
/*globals window, document, RSVP, rJS,
URI, location, XMLHttpRequest, console, navigator, Event,
URL, domsugar*/
URL, domsugar, convertOriginalErrorToErrorDataList,
buildErrorElementFromErrorText*/
/*jslint indent: 2, maxlen: 80, unparam: true*/
(
function
(
window
,
document
,
RSVP
,
rJS
,
XMLHttpRequest
,
location
,
console
,
navigator
,
Event
,
URL
,
domsugar
)
{
URL
,
domsugar
,
convertOriginalErrorToErrorDataList
,
buildErrorElementFromErrorText
)
{
"
use strict
"
;
var
MAIN_SCOPE
=
"
m
"
,
...
...
@@ -130,71 +132,10 @@
}
function
displayErrorContent
(
gadget
,
original_error
)
{
var
error_list
=
[
original_error
],
i
,
error
,
error_response
,
error_text
=
""
;
// Do not break the application in case of errors.
// Display it to the user for now,
// and allow user to go back to the frontpage
// Add error handling stack
error_list
.
push
(
new
Error
(
'
stopping ERP5JS
'
));
for
(
i
=
0
;
i
<
error_list
.
length
;
i
+=
1
)
{
error
=
error_list
[
i
];
if
(
error
instanceof
Event
)
{
error
=
{
string
:
error
.
toString
(),
message
:
error
.
message
,
type
:
error
.
type
,
target
:
error
.
target
};
if
(
error
.
target
!==
undefined
)
{
error_list
.
splice
(
i
+
1
,
0
,
error
.
target
);
}
}
if
(
error
instanceof
XMLHttpRequest
)
{
if
((
error
.
getResponseHeader
(
'
Content-Type
'
)
||
""
)
.
indexOf
(
'
text/
'
)
===
0
)
{
error_response
=
error
.
response
;
}
error
=
{
message
:
error
.
toString
(),
readyState
:
error
.
readyState
,
status
:
error
.
status
,
statusText
:
error
.
statusText
,
response
:
error
.
response
,
responseUrl
:
error
.
responseUrl
,
response_headers
:
(
error
.
getAllResponseHeaders
()
?
error
.
getAllResponseHeaders
().
split
(
'
\r\n
'
)
:
null
)
};
}
if
(
error
.
constructor
===
Array
||
error
.
constructor
===
String
||
error
.
constructor
===
Object
)
{
try
{
error
=
JSON
.
stringify
(
error
,
null
,
'
'
);
}
catch
(
ignore
)
{
}
}
error_text
+=
error
.
message
||
error
;
error_text
+=
'
\n
'
;
if
(
error
.
fileName
!==
undefined
)
{
error_text
+=
'
File:
'
+
error
.
fileName
+
'
:
'
+
error
.
lineNumber
+
'
\n
'
;
}
if
(
error
.
stack
!==
undefined
)
{
error_text
+=
'
Stack:
'
+
error
.
stack
+
'
\n
'
;
}
error_text
+=
'
---
\n
'
;
}
return
convertOriginalErrorToErrorDataList
(
original_error
)
.
push
(
function
(
error_list
)
{
var
error
=
error_list
[
0
],
error_text
=
error_list
[
1
];
console
.
error
(
original_error
);
if
(
original_error
instanceof
Error
)
{
...
...
@@ -204,8 +145,8 @@
// Gadget has not yet been correctly initialized
throw
error
;
}
if
(
error_response
&&
error_
response
.
text
)
{
return
error_
response
.
text
().
then
(
if
(
error
.
response
&&
error
.
response
.
text
)
{
return
error
.
response
.
text
().
then
(
function
(
request_error_text
)
{
return
gadget
.
changeState
({
error_text
:
error_text
,
...
...
@@ -217,10 +158,10 @@
}
return
gadget
.
changeState
({
error_text
:
error_text
,
request_error_text
:
error_
response
,
request_error_text
:
error
.
response
,
url
:
undefined
});
});
}
function
displayError
(
gadget
,
error
)
{
...
...
@@ -788,44 +729,13 @@
return
;
})
.
push
(
function
()
{
var
element
=
gadget
.
props
.
content_element
,
container
;
container
=
domsugar
(
"
section
"
,
[
domsugar
(
"
p
"
,
{
"
text
"
:
'
Please report this unhandled error to the support
'
+
'
team, and go back to the
'
},
[
domsugar
(
"
a
"
,
{
"
href
"
:
"
#
"
,
"
text
"
:
"
homepage
"
})
]),
domsugar
(
"
br
"
),
domsugar
(
"
p
"
,
{
"
text
"
:
'
Location:
'
},
[
domsugar
(
"
a
"
,
{
"
href
"
:
window
.
location
.
toString
(),
"
text
"
:
window
.
location
.
toString
()
})
]),
domsugar
(
"
p
"
,
{
"
text
"
:
'
User-agent:
'
+
navigator
.
userAgent
}),
domsugar
(
"
p
"
,
{
"
text
"
:
'
Date:
'
+
new
Date
(
Date
.
now
()).
toISOString
()
}),
domsugar
(
"
p
"
,
{
"
text
"
:
'
Online:
'
+
navigator
.
onLine
}),
domsugar
(
"
br
"
),
domsugar
(
"
pre
"
,
[
domsugar
(
"
code
"
,
{
"
text
"
:
gadget
.
state
.
error_text
return
buildErrorElementFromErrorText
(
gadget
.
state
.
error_text
);
})
])
]);
.
push
(
function
(
container
)
{
var
element
=
gadget
.
props
.
content_element
;
// Remove the content
while
(
element
.
firstChild
)
{
...
...
@@ -1068,4 +978,6 @@
}(
window
,
document
,
RSVP
,
rJS
,
XMLHttpRequest
,
location
,
console
,
navigator
,
Event
,
URL
,
domsugar
));
XMLHttpRequest
,
location
,
console
,
navigator
,
Event
,
URL
,
domsugar
,
convertOriginalErrorToErrorDataList
,
buildErrorElementFromErrorText
));
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.xml
View file @
c171e108
...
...
@@ -236,7 +236,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
100
5.39881.44610.14899
</string>
</value>
<value>
<string>
100
7.4476.40395.38075
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>
167
3426576.41
</float>
<float>
167
8908218.84
</float>
<string>
UTC
</string>
</tuple>
</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