Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: osd navigator 401 issue (DEV-4317) #1886

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('Check project admin existing resource functionality', () => {
before(() => {
cy.resetDatabase();
Cypress.env('skipDatabaseCleanup', true);
cy.loginAdmin();
project0001Page = new Project0001Page();
cy.uploadFile(<Cypress.IUploadFileParameters>{
filePath: `../${uploadedImageFilePath}`,
Expand All @@ -33,6 +34,7 @@ describe('Check project admin existing resource functionality', () => {
thingPictureData.file = (response as UploadedFileResponse).internalFilename;
cy.createResource(project0001Page.payloads.picture(thingPictureData));
});
cy.logout();

cy.readFile('cypress/fixtures/user_profiles.json').then((json: UserProfiles) => {
const users: UserProfiles = json;
Expand All @@ -46,10 +48,11 @@ describe('Check project admin existing resource functionality', () => {
mimeType: 'image/png',
}).then(response => {
resourceToDelete.file = (response as UploadedFileResponse).internalFilename;
cy.createResource(project0001Page.payloads.picture(resourceToDelete), true);
cy.createResource(project0001Page.payloads.picture(resourceToDelete));
});
});
});
cy.logout();
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('Check project admin existing resource functionality', () => {
before(() => {
cy.resetDatabase();
Cypress.env('skipDatabaseCleanup', true);
cy.loginAdmin();
project0001Page = new Project0001Page();
cy.uploadFile(<Cypress.IUploadFileParameters>{
filePath: `../${uploadedImageFilePath}`,
Expand Down Expand Up @@ -57,6 +58,7 @@ describe('Check project admin existing resource functionality', () => {
resourceToErase.file = (response as UploadedFileResponse).internalFilename;
cy.createResource(project0001Page.payloads.picture(resourceToErase));
});
cy.logout();
});

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion apps/dsp-app/cypress/support/commands/api-commands.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { uploadProjectFile } from '../helpers/file-uploader';

function getJwt(isAuthenticated?: boolean) {
return isAuthenticated === true ? localStorage.getItem('ACCESS_TOKEN') : Cypress.env('authToken');
return isAuthenticated === true ? Cypress.env('authToken') : localStorage.getItem('ACCESS_TOKEN');
}

function getRequestOptions(params: Cypress.IRequestAuthenticatedParameters): Cypress.RequestOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export class StillImageHelper {
return createResource;
}

static prepareTileSourcesFromFileValues(images: ReadStillImageFileValue[], pngFormat = false): object[] {
static prepareTileSourcesFromFileValues(
images: ReadStillImageFileValue[],
ajaxHeaders: any,
pngFormat = false
): object[] {
let imageXOffset = 0;
const imageYOffset = 0;
const tileSources = [];
Expand Down Expand Up @@ -94,6 +98,7 @@ export class StillImageHelper {
x: imageXOffset,
y: imageYOffset,
preload: true,
ajaxHeaders,
});

imageXOffset++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { StillImageHelper } from './still-image-helper';
selector: 'app-still-image',
template: ` <div
class="osd-container"
[class.drawing]="isViewInitialized && !osd.viewer.isMouseNavEnabled()"
[class.drawing]="isViewInitialized && !osdService.viewer.isMouseNavEnabled()"
#osdViewer>
<div *ngIf="compoundMode">
<app-compound-arrow-navigation [forwardNavigation]="false" class="arrow" />
Expand Down Expand Up @@ -50,13 +50,13 @@ export class StillImageComponent implements AfterViewInit, OnDestroy {
isPng = false;

constructor(
protected osd: OpenSeaDragonService,
protected osdService: OpenSeaDragonService,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this protected? Shouldn't also be private?

private _osdDrawerService: OsdDrawerService,
private _cdr: ChangeDetectorRef
) {}

ngAfterViewInit() {
this.osd.onInit(this.osdViewerElement.nativeElement);
this.osdService.onInit(this.osdViewerElement.nativeElement);
this._osdDrawerService.onInit(this.resource);
this.isViewInitialized = true;
this._cdr.detectChanges();
Expand All @@ -69,7 +69,7 @@ export class StillImageComponent implements AfterViewInit, OnDestroy {
}

ngOnDestroy() {
this.osd.viewer.destroy();
this.osdService.viewer.destroy();
}

private _loadImages() {
Expand All @@ -88,8 +88,12 @@ export class StillImageComponent implements AfterViewInit, OnDestroy {
}

private _openInternalImage(image: ReadStillImageFileValue): void {
const tiles = StillImageHelper.prepareTileSourcesFromFileValues([image], this.isPng);
this.osd.viewer.open(tiles);
const tiles = StillImageHelper.prepareTileSourcesFromFileValues(
[image],
(this.osdService.viewer as any).ajaxHeaders,
this.isPng
);
this.osdService.viewer.open(tiles);
}

private _openExternal3iFImage(image: ReadStillImageExternalFileValue) {
Expand All @@ -98,6 +102,6 @@ export class StillImageComponent implements AfterViewInit, OnDestroy {
throw new AppError('Error with IIIF URL');
}

this.osd.viewer.open(i3f.infoJsonUrl);
this.osdService.viewer.open(i3f.infoJsonUrl);
}
}
Loading