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

refactor: iiif config refactor (DEV-162) #573

Merged
merged 1 commit into from Nov 3, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 27 additions & 9 deletions src/app/app-init.service.ts
Expand Up @@ -11,10 +11,29 @@ import { APP_CONFIG } from './main/declarations/dsp-api-tokens';
})
export class AppInitService {

public dspApiConfig: KnoraApiConfig | null;
public dspIiifConfig: DspIiifConfig | null;
public dspAppConfig: DspAppConfig | null;
public dspInstrumentationConfig: DspInstrumentationConfig | null;
private _dspApiConfig: KnoraApiConfig;

get dspApiConfig(): KnoraApiConfig {
return this._dspApiConfig;
}

private _dspIiifConfig: DspIiifConfig;

get dspIiifConfig(): DspIiifConfig {
return this._dspIiifConfig;
}

private _dspAppConfig: DspAppConfig;

get dspAppConfig(): DspAppConfig {
return this._dspAppConfig;
}

private _dspInstrumentationConfig: DspInstrumentationConfig;

get dspInstrumentationConfig(): DspInstrumentationConfig {
return this._dspInstrumentationConfig;
}

constructor(
@Inject(APP_CONFIG) private _config: IConfig
Expand All @@ -30,8 +49,7 @@ export class AppInitService {
const jsonWebToken = (typeof this._config.jsonWebToken === 'string' ? this._config.jsonWebToken : '');
const logErrors = (typeof this._config.logErrors === 'boolean' ? this._config.logErrors : false);

// init dsp-api configuration
this.dspApiConfig = new KnoraApiConfig(
this._dspApiConfig = new KnoraApiConfig(
this._config.apiProtocol,
this._config.apiHost,
apiPort,
Expand All @@ -44,20 +62,20 @@ export class AppInitService {
const iiifPath = (typeof this._config.iiifPath === 'string' ? this._config.iiifPath : '');

// init iiif configuration
this.dspIiifConfig = new DspIiifConfig(
this._dspIiifConfig = new DspIiifConfig(
this._config.iiifProtocol,
this._config.iiifHost,
iiifPort,
iiifPath
);

// init dsp app extended configuration
this.dspAppConfig = new DspAppConfig(
this._dspAppConfig = new DspAppConfig(
this._config.geonameToken
);

// init instrumentation configuration
this.dspInstrumentationConfig = new DspInstrumentationConfig(
this._dspInstrumentationConfig = new DspInstrumentationConfig(
this._config.instrumentation.environment,
new DspDataDogConfig(
this._config.instrumentation.dataDog.enabled,
Expand Down
Expand Up @@ -20,9 +20,6 @@ export interface UploadedFileResponse {
})
export class UploadFileService {

// fIXME: DEV-162
iiifUrl: string = (this._init.dspIiifConfig.iiifUrl.substr(-1) === '/') ? this._init.dspIiifConfig.iiifUrl : this._init.dspIiifConfig.iiifUrl + '/';

constructor(
private readonly _init: AppInitService,
private readonly _http: HttpClient,
Expand All @@ -35,7 +32,7 @@ export class UploadFileService {
*/
upload(file: FormData): Observable<UploadedFileResponse> {

const uploadUrl = `${this.iiifUrl}upload`;
const uploadUrl = `${this._init.dspIiifConfig.iiifUrl}/upload`;

// checks if user is logged in
const jwt = this._session.getSession()?.user.jwt;
Expand Down