Skip to content

Commit

Permalink
Merge branch 'dev' into dataview-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcelfrueh committed Nov 16, 2023
2 parents ea5529c + 7b6a12f commit 1c2b922
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
<httpcore.version>4.4.9</httpcore.version>
<influxdb.version>2.23</influxdb.version>
<inlong.version>1.9.0</inlong.version>
<jackson.version>2.15.0</jackson.version>
<jackson.databind.version>2.15.0</jackson.databind.version>
<jackson.version>2.16.0</jackson.version>
<jackson.databind.version>2.16.0</jackson.databind.version>
<jakarta-annotation.version>2.1.1</jakarta-annotation.version>
<jakarta-activation-api.version>2.0.1</jakarta-activation-api.version>
<jakarta-inject-api.version>2.0.1</jakarta-inject-api.version>
Expand Down
14 changes: 14 additions & 0 deletions ui/cypress/support/utils/FileManagementUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,18 @@ export class FileManagementUtils {
cy.dataCy('confirm-delete').click();
cy.dataCy('delete').should('have.length', 0);
}

public static downloadFile(expectedFilename: string) {
const downloadsFolder = Cypress.config('downloadsFolder');

// Go to StreamPipes file management
cy.visit('#/files');
// Check if file was uploaded
cy.dataCy('download').should('have.length', 1);

// Download file and verify it was downloaded
cy.dataCy('download').click();
cy.dataCy('download').should('have.length', 1);
cy.readFile(downloadsFolder + '/' + expectedFilename);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('Test File Management', () => {

it('Perform Test', () => {
FileManagementUtils.addFile('fileTest/test.csv');
FileManagementUtils.downloadFile('test.csv');
FileManagementUtils.deleteFile();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,13 @@ export class FilesService {
this.platformServicesCommons.apiBasePath + '/files/' + fileId,
);
}

getFile(filename: string): Observable<Blob> {
return this.http.get(
this.platformServicesCommons.apiBasePath + '/files/' + filename,
{
responseType: 'blob',
},
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ <h5>
>
<i class="material-icons">delete</i>
</button>
<button
color="accent"
mat-icon-button
matTooltip="Download File"
matTooltipPosition="above"
(click)="downloadFile(fileMetadata)"
data-cy="download"
>
<i class="material-icons">download</i>
</button>
</td>
</ng-container>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { MatTableDataSource } from '@angular/material/table';
import { MatPaginator } from '@angular/material/paginator';
import { ConfirmDialogComponent } from '@streampipes/shared-ui';
import { MatDialog } from '@angular/material/dialog';
import { saveAs } from 'file-saver';

@Component({
selector: 'sp-file-overview',
Expand Down Expand Up @@ -80,6 +81,14 @@ export class FileOverviewComponent implements OnInit {
});
}

downloadFile(fileMetadata: FileMetadata) {
this.filesService
.getFile(fileMetadata.internalFilename)
.subscribe(response => {
saveAs(response, fileMetadata.originalFilename);
});
}

@ViewChild(MatPaginator) set content(paginator: MatPaginator) {
this.paginator = paginator;
}
Expand Down

0 comments on commit 1c2b922

Please sign in to comment.