Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
anis-next
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
anis
anis-next
Merge requests
!32
Resolve "Télécharger une archive"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Télécharger une archive"
23-telecharger-une-archive
into
develop
Overview
0
Commits
10
Pipelines
0
Changes
54
Merged
François Agneray
requested to merge
23-telecharger-une-archive
into
develop
3 years ago
Overview
0
Commits
10
Pipelines
0
Changes
54
Expand
Closes
#23 (closed)
0
0
Merge request reports
Compare
develop
develop (base)
and
latest version
latest version
60f9f73e
10 commits,
3 years ago
54 files
+
2075
−
244
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
54
Search (e.g. *.vue) (Ctrl+P)
client/src/app/instance/search/components/result/renderer/download-renderer.component.ts
+
16
−
14
Options
@@ -7,8 +7,7 @@
* file that was distributed with this source code.
*/
import
{
Component
,
Input
,
ChangeDetectionStrategy
}
from
'
@angular/core
'
;
import
{
HttpClient
}
from
'
@angular/common/http
'
;
import
{
Component
,
Input
,
Output
,
EventEmitter
,
ChangeDetectionStrategy
}
from
'
@angular/core
'
;
import
{
DownloadRendererConfig
}
from
'
src/app/metamodel/models/renderers/download-renderer-config.model
'
;
import
{
getHost
}
from
'
src/app/shared/utils
'
;
@@ -28,8 +27,9 @@ export class DownloadRendererComponent {
@
Input
()
datasetName
:
string
;
@
Input
()
datasetPublic
:
boolean
;
@
Input
()
config
:
DownloadRendererConfig
;
@
Output
()
downloadFile
:
EventEmitter
<
{
url
:
string
,
fileId
:
string
,
datasetName
:
string
,
filename
:
string
}
>
=
new
EventEmitter
();
constructor
(
private
appConfig
:
AppConfigService
,
private
http
:
HttpClient
)
{
}
constructor
(
private
appConfig
:
AppConfigService
)
{
}
/**
* Returns link href.
@@ -50,21 +50,23 @@ export class DownloadRendererComponent {
}
/**
*
D
ownload
s
file on click.
*
Starts d
ownload
ing
file on click.
*/
click
(
event
):
void
{
event
.
preventDefault
();
const
url
=
this
.
getHref
();
const
filename
=
url
.
substring
(
url
.
lastIndexOf
(
'
/
'
)
+
1
);
const
href
=
this
.
getHref
();
this
.
http
.
get
(
href
,
{
responseType
:
"
blob
"
}).
subscribe
(
data
=>
{
const
filename
=
href
.
substring
(
href
.
lastIndexOf
(
'
/
'
)
+
1
);
const
n
=
Math
.
floor
(
Math
.
random
()
*
11
);
const
k
=
Math
.
floor
(
Math
.
random
()
*
1000000
);
const
m
=
String
.
fromCharCode
(
n
)
+
k
;
let
downloadLink
=
document
.
createElement
(
'
a
'
);
downloadLink
.
href
=
window
.
URL
.
createObjectURL
(
data
);
downloadLink
.
setAttribute
(
'
download
'
,
filename
);
downloadLink
.
click
();
}
);
this
.
downloadFile
.
emit
({
url
,
fileId
:
m
,
datasetName
:
this
.
datasetName
,
filename
}
);
}
}
Loading