Skip to content
Snippets Groups Projects
Commit 9c9f3d63 authored by Gaëlle FOURNIER's avatar Gaëlle FOURNIER
Browse files

Fix rebase and TUs

parent 87902f0b
No related branches found
No related tags found
No related merge requests found
Showing
with 33 additions and 26 deletions
......@@ -56,7 +56,14 @@ import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import java.util.Optional;
......
......@@ -52,11 +52,16 @@ import fr.gouv.vitamui.iam.security.service.InternalSecurityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.Response;
......
......@@ -69,8 +69,6 @@ public class CommonConstants {
public static final String PATH_ANALYTICS = "/analytics";
public static final String PATH_OBJECTS = "/objects";
public static final String X_TENANT_ID_HEADER = "X-Tenant-Id";
public static final String X_XSRF_TOKEN_HEADER = "X-XSRF-Token";
......
......@@ -52,7 +52,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import java.util.Optional;
......
......@@ -166,14 +166,9 @@ export class LogbookDownloadService extends SearchService<Event> {
downloadReport(event: Event, tenantIdentifier: number) {
if (this.isOperationInProgress(event)) {
console.log('Nothing to download');
return;
}
console.log('Trying to download...');
console.log(event);
console.log(tenantIdentifier);
const id = event.id;
this.snackBar.openFromComponent(VitamUISnackBarComponent, {
......@@ -188,21 +183,12 @@ export class LogbookDownloadService extends SearchService<Event> {
var eventType = event.type.toUpperCase();
var downloadType = this.getDownloadType(eventTypeProc, eventType);
console.log('Download type');
console.log(downloadType);
if(downloadType) {
const headers = new HttpHeaders({
'X-Tenant-Id': tenantIdentifier.toString(),
'X-Access-Contract-Id': contractId
});
console.log('headers');
console.log(headers);
console.log('id ' + id);
console.log('downloadType ' + downloadType);
this.logbookApiService.downloadReport(id, downloadType, headers).subscribe((response) => {
const element = document.createElement('a');
const blob = new Blob([response.body], {type: 'octet/stream'});
......
......@@ -43,6 +43,7 @@ import { ActivatedRoute } from '@angular/router';
import { EventTypeBadgeClassPipe } from '../logbook-operation-list/event-type-badge-class.pipe';
import { LastEventPipe } from '../logbook-operation-list/last-event.pipe';
import { LogbookOperationDetailComponent } from './logbook-operation-detail.component';
import {LogbookDownloadService} from '../logbook-download.service';
describe('LogbookOperationDetailComponent', () => {
let component: LogbookOperationDetailComponent;
......@@ -53,6 +54,7 @@ describe('LogbookOperationDetailComponent', () => {
declarations: [LogbookOperationDetailComponent, EventTypeBadgeClassPipe, LastEventPipe ],
providers: [
{ provide: LogbookService, useValue: {} },
{ provide: LogbookDownloadService, useValue: {} },
{ provide: AuthService, useValue: {} },
{ provide: ActivatedRoute, useValue: {} },
],
......
......@@ -93,14 +93,11 @@ export class LogbookOperationDetailComponent implements OnInit, OnChanges {
downloadReports() {
console.log('download report');
this.logbookDownloadService.downloadReport(this.event, this.tenantIdentifier);
}
updateCanDownload(event: Event) {
const canDownloadReports = this.logbookDownloadService.canDownloadReports(event);
console.log("BONJOUR");
console.log(canDownloadReports);
this.hideDownload = canDownloadReports.length < 1;
if (!this.hideDownload) {
this.canDownload = canDownloadReports.includes('download');
......
......@@ -40,10 +40,11 @@ import { ENVIRONMENT, GlobalEventService, InjectorModule, LoggerModule } from 'u
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { MatMenuModule } from '@angular/material/menu';
import { ActivatedRoute, Router } from '@angular/router';
import { EMPTY } from 'rxjs';
import { EMPTY, of } from 'rxjs';
import { environment } from '../../environments/environment';
import { LogbookOperationComponent } from './logbook-operation.component';
import { LogbookSearchService } from './logbook-search.service';
......@@ -53,6 +54,8 @@ describe('LogbookOperationComponent', () => {
let fixture: ComponentFixture<LogbookOperationComponent>;
beforeEach(waitForAsync(() => {
const matDialogSpy = jasmine.createSpyObj('MatDialog', ['open']);
matDialogSpy.open.and.returnValue({ afterClosed: () => of(true) });
TestBed.configureTestingModule({
imports: [
MatMenuModule,
......@@ -62,6 +65,7 @@ describe('LogbookOperationComponent', () => {
],
declarations: [LogbookOperationComponent],
providers: [
{ provide: MatDialog, useValue: matDialogSpy },
{ provide: ActivatedRoute, useValue: { paramMap: EMPTY, data: EMPTY } },
{ provide: LogbookSearchService, useValue: { search: () => EMPTY } },
{ provide: Router, useValue: { navigate: () => { } } },
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment