Skip to content
Permalink
Browse files
refactor: refactors upload-file service to use the string generated i…
…n the iiif-config file and changes the public class members in app-init service to private with getters. (#573)
  • Loading branch information
mdelez committed Nov 3, 2021
1 parent fb55fd7 commit c39ca5bcee02eca52ea17f660cc83670fec0d86a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
@@ -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
@@ -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,
@@ -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,
@@ -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,
@@ -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;

0 comments on commit c39ca5b

Please sign in to comment.