11import { APP_CONFIG , AppConfig } from "app-config.module" ;
2- import { Dataset } from "shared/sdk/models" ;
32import {
43 Component ,
54 OnInit ,
@@ -20,10 +19,13 @@ import {
2019 PageChangeEvent ,
2120 CheckboxEvent ,
2221} from "shared/modules/table/table.component" ;
23- import { selectIsLoading } from "state-management/selectors/user.selectors" ;
24- import { Datablock , UserApi } from "shared/sdk" ;
22+ import { selectIsLoading , selectIsLoggedIn } from "state-management/selectors/user.selectors" ;
23+ import { Dataset , Job , UserApi } from "shared/sdk" ;
2524import { FileSizePipe } from "shared/pipes/filesize.pipe" ;
2625import { MatCheckboxChange } from "@angular/material/checkbox" ;
26+ import { MatDialog } from "@angular/material/dialog" ;
27+ import { PublicDownloadDialogComponent } from "datasets/public-download-dialog/public-download-dialog.component" ;
28+ import { submitJobAction } from "state-management/actions/jobs.actions" ;
2729
2830export interface File {
2931 path : string ;
@@ -46,7 +48,7 @@ export class DatafilesComponent
4648 datablocks$ = this . store . select ( selectCurrentOrigDatablocks ) ;
4749 dataset$ = this . store . select ( selectCurrentDataset ) ;
4850 loading$ = this . store . select ( selectIsLoading ) ;
49-
51+ isLoggedIn$ = this . store . select ( selectIsLoggedIn ) ;
5052 tooLargeFile = false ;
5153 totalFileSize = 0 ;
5254 selectedFileSize = 0 ;
@@ -58,14 +60,18 @@ export class DatafilesComponent
5860
5961 files : Array < any > = [ ] ;
6062 sourcefolder = "" ;
63+ datasetPid = "" ;
6164
6265 count = 0 ;
6366 pageSize = 25 ;
6467 currentPage = 0 ;
6568
6669 fileDownloadEnabled : boolean = this . appConfig . fileDownloadEnabled ;
6770 multipleDownloadEnabled : boolean = this . appConfig . multipleDownloadEnabled ;
68- multipleDownloadAction : string | null = this . appConfig . multipleDownloadAction ;
71+ fileserverBaseURL : string | null = this . appConfig . fileserverBaseURL ;
72+ fileserverButtonLabel : string | null = this . appConfig . fileserverButtonLabel ;
73+ multipleDownloadAction : string | null = this . appConfig
74+ . multipleDownloadAction ;
6975 maxFileSize : number | null = this . appConfig . maxDirectDownloadSize ;
7076 sftpHost : string | null = this . appConfig . sftpHost ;
7177 jwt : any ;
@@ -99,6 +105,7 @@ export class DatafilesComponent
99105 private store : Store < Dataset > ,
100106 private cdRef : ChangeDetectorRef ,
101107 private userApi : UserApi ,
108+ private dialog : MatDialog ,
102109 @Inject ( APP_CONFIG ) public appConfig : AppConfig
103110 ) { }
104111
@@ -193,6 +200,7 @@ export class DatafilesComponent
193200 this . dataset$ . subscribe ( ( dataset ) => {
194201 if ( dataset ) {
195202 this . sourcefolder = dataset . sourceFolder ;
203+ this . datasetPid = dataset . pid ;
196204 }
197205 } )
198206 ) ;
@@ -223,4 +231,29 @@ export class DatafilesComponent
223231 ngOnDestroy ( ) {
224232 this . subscriptions . forEach ( ( subscription ) => subscription . unsubscribe ( ) ) ;
225233 }
234+ openDialog ( ) : void {
235+ const dialogRef = this . dialog . open ( PublicDownloadDialogComponent , {
236+ width : "500px" ,
237+ data : { email : "" }
238+ } ) ;
239+ dialogRef . afterClosed ( ) . subscribe ( ( email ) => {
240+ if ( email ) {
241+ this . getSelectedFiles ( ) ;
242+ const data = {
243+ emailJobInitiator : email ,
244+ creationTime : new Date ( ) ,
245+ type : "public" ,
246+ datasetList : [ {
247+ pid : this . datasetPid ,
248+ files : this . getSelectedFiles ( )
249+ } ]
250+ } ;
251+ const job = new Job ( data ) ;
252+ this . store . dispatch ( submitJobAction ( { job } ) ) ;
253+ }
254+ } ) ;
255+ }
256+ getFileTransferLink ( ) {
257+ return this . fileserverBaseURL + "&origin_path=" + encodeURIComponent ( this . sourcefolder ) ;
258+ }
226259}
0 commit comments