Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
web-et-numerique
web-et-numerique-internet
data.grandlyon.com
web-portal
components
custom-apps
web-app
Commits
7db09737
Commit
7db09737
authored
Apr 29, 2020
by
FORESTIER Fabien
Browse files
Improve error handling on download button
parent
9ca9bfab
Pipeline
#5081
passed with stage
in 3 minutes and 26 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.ts
View file @
7db09737
...
...
@@ -262,13 +262,19 @@ export class ResourceDownloadItemComponent implements OnInit {
transformObjectToArray
(
object
)
{
const
array
=
[];
const
keys
=
Object
.
keys
(
object
);
keys
.
forEach
((
key
)
=>
{
array
.
push
({
name
:
key
,
bbox
:
object
[
key
],
let
keys
;
if
(
object
)
{
keys
=
Object
.
keys
(
object
);
keys
.
forEach
((
key
)
=>
{
array
.
push
({
name
:
key
,
bbox
:
object
[
key
],
});
});
});
}
return
array
;
}
...
...
src/app/shared/components/download-button/download-button.component.ts
View file @
7db09737
...
...
@@ -27,7 +27,7 @@ export class DownloadButtonComponent implements OnInit, OnDestroy {
private
_http
:
HttpClient
,
)
{
}
ngOnInit
()
{}
ngOnInit
()
{
}
download
()
{
this
.
loading
=
true
;
...
...
@@ -35,7 +35,6 @@ export class DownloadButtonComponent implements OnInit, OnDestroy {
takeUntil
(
this
.
ngUnsubscribe
),
).
subscribe
(
(
response
)
=>
{
console
.
log
(
'
Reponse
'
);
// Create a temporary link and click on it to launch the blob download
const
url
=
window
.
URL
.
createObjectURL
(
response
.
body
);
const
a
=
document
.
createElement
(
'
a
'
);
...
...
@@ -50,23 +49,23 @@ export class DownloadButtonComponent implements OnInit, OnDestroy {
(
err
)
=>
{
let
message
=
notificationMessages
.
general
.
failedDownloadFile
;
if
(
err
&&
err
.
status
)
{
switch
(
err
.
status
)
{
case
401
:
message
=
notificationMessages
.
general
.
failedDownloadFileUnauthenticated
;
break
;
case
403
:
message
=
notificationMessages
.
general
.
failedDownloadFileUnauthorized
;
break
;
}
this
.
abortDownload
();
this
.
_notificationService
.
notify
(
{
message
,
type
:
'
error
'
,
},
);
if
(
err
&&
err
.
status
===
401
)
{
message
=
notificationMessages
.
general
.
failedDownloadFileUnauthenticated
;
}
if
(
err
&&
err
.
status
===
403
)
{
message
=
notificationMessages
.
general
.
failedDownloadFileUnauthorized
;
}
this
.
_notificationService
.
notify
(
{
message
,
type
:
'
error
'
,
},
);
this
.
abortDownload
();
},
);
}
...
...
Write
Preview
Supports
Markdown
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