Skip to content
Open
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
29 changes: 29 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,32 @@
"with": "src/environments/environment.fda.local.ts"
}
]
},
"fda.local3x": {
"baseHref": "/ginas/app/ui/",
"assets": [
{
"glob": "**/*",
"input": "src/app/core/assets/",
"output": "/assets/"
},
{
"glob": "config.json",
"input": "src/app/fda/config/",
"output": "/assets/data/"
},
{
"glob": "**/*",
"input": "src/app/fda/assets",
"output": "/assets/"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.fda.local3x.ts"
}
]
}
}
},
Expand All @@ -250,6 +276,9 @@
"fda.local": {
"buildTarget": "gsrs-client:build:fda.local"
},
"fda.local3x": {
"buildTarget": "gsrs-client:build:fda.local3x"
},
"fda.pre-prod": {
"buildTarget": "gsrs-client:build:fda.pre-prod"
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"build:gsrs:prod": "npm run clear-libs-src && ng build --base-href=/ginas/app/ui/ --configuration=fda.prod && node process-index.js && cd lib && extract-zip dojo-custom-jsdraw.zip && cd .. && npm run copy-libs-dist && npm run build-server",
"start:fda:dev": "npm run process-dojo && ng serve --configuration=fda.dev --sourceMap=true",
"start:fda:local": "npm run process-dojo && ng serve --configuration=fda.local",
"start:fda:local3x": "npm run process-dojo && ng serve --host 0.0.0.0 --configuration=fda.local3x",
"start:fda:pre-prod": "npm run process-dojo && ng serve --configuration=fda.pre-prod --sourceMap=true",
"start:fda:prod": "npm run process-dojo && ng serve --configuration=fda.prod --sourceMap=true",
"build:fda:pre-prod": "npm run clear-libs-src && ng build --base-href=/ginas/app/beta/ --configuration=fda.pre-prod --sourceMap=true && node process-index.js && cd lib && extract-zip dojo-custom-jsdraw.zip && cd .. && npm run copy-libs-dist && npm run build-server",
Expand Down
11 changes: 9 additions & 2 deletions src/app/core/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Injectable, PLATFORM_ID, Inject } from "@angular/core";
import { ConfigService } from "../config/config.service";
import { Auth, Privilege, Role, UserGroup } from "./auth.model";

import {
interval,
from,
Expand All @@ -27,6 +28,7 @@ import {
UserDownload,
AllUserDownloads,
} from "@gsrs-core/auth/user-downloads/download.model";
import { UtilsService } from "@gsrs-core/utils/utils.service";

@Injectable({
providedIn: "root",
Expand All @@ -41,6 +43,7 @@ export class AuthService {
public configService: ConfigService,
private http: HttpClient,
@Inject(PLATFORM_ID) private platformId: any,
private utilsService: UtilsService
) {
this.isLoading = true;
configService.afterLoad().then((cs) => {
Expand Down Expand Up @@ -380,7 +383,9 @@ export class AuthService {

getUpdateStatus(id: string): Observable<UserDownload> {
const url = `${(this.configService.configData && this.configService.configData.apiBaseUrl) || "/"}api/v1/`;
return this.http.get<any>(`${url}profile/downloads/${id}`);
const restApiPrefix = this.configService.configData.restApiPrefix || '';
const adjustedUrl = this.utilsService.adjustBackendUrlWithRestApiPrefix('/api/v1', restApiPrefix, url);
return this.http.get<any>(`${adjustedUrl}profile/downloads/${id}`);
}

changeDownload(url: string): Observable<UserDownload> {
Expand All @@ -393,7 +398,9 @@ export class AuthService {

getAllDownloads(): Observable<AllUserDownloads> {
const url = `${(this.configService.configData && this.configService.configData.apiBaseUrl) || "/"}api/v1/`;
return this.http.get<any>(`${url}profile/downloads`);
const restApiPrefix = this.configService.configData.restApiPrefix || '';
const adjustedUrl = this.utilsService.adjustBackendUrlWithRestApiPrefix('/api/v1', restApiPrefix, url);
return this.http.get<any>(`${adjustedUrl}profile/downloads`);
}

private fetchAuth(): Observable<Auth> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import * as moment from 'moment';
import { take } from 'rxjs/operators';
import { ConfigService } from '@gsrs-core/config';
import { NavigationExtras } from '@angular/router';
import { UtilsService } from '@gsrs-core/utils';
import { remove } from 'lodash';

@Component({
selector: 'app-download-monitor',
Expand All @@ -25,7 +27,9 @@ export class DownloadMonitorComponent implements OnInit, OnDestroy {
type?: string;
killed = false;
constructor(
private authService: AuthService
private authService: AuthService,
private utilsService: UtilsService,
private configService: ConfigService
) { }

ngOnInit() {
Expand All @@ -37,10 +41,19 @@ export class DownloadMonitorComponent implements OnInit, OnDestroy {
this.authService.getUpdateStatus(this.id).pipe(take(1)).subscribe(response => {
// console.log((this.exists? this.exists : 't') + '---' + this.download.status);
this.download = response;
const restApiPrefix = this.configService.configData.restApiPrefix || '';

if (this.download?.downloadUrl?.url !== undefined) {
this.download.downloadUrl.url = this.utilsService.adjustBackendUrlWithRestApiPrefix('/api/v1', restApiPrefix, this.download.downloadUrl.url);
}

if (this.download?.removeUrl?.url !== undefined) {
this.download.removeUrl.url = this.utilsService.adjustBackendUrlWithRestApiPrefix('/api/v1', restApiPrefix, this.download.removeUrl.url);
}

if (response.originalQuery) {
this.processQuery(response.originalQuery);
}

this.exists = true;
if (this.download.started) {
this.download.startedHuman = moment(this.download.started).fromNow();
Expand Down Expand Up @@ -68,11 +81,16 @@ export class DownloadMonitorComponent implements OnInit, OnDestroy {
}

cancel() {
const restApiPrefix = this.configService.configData.restApiPrefix || '';
if(this.download?.cancelUrl?.url !== undefined) {
this.download.cancelUrl.url=this.utilsService.adjustBackendUrlWithRestApiPrefix('/api/v1', restApiPrefix, this.download.cancelUrl.url);
}
this.authService.changeDownload(this.download.cancelUrl.url).pipe(take(1)).subscribe(response => {
this.refresh();
});
}

// seems like this is not used
downloadExport() {
this.authService.changeDownload(this.download.downloadUrl).pipe(take(1)).subscribe(response => {
this.refresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</mat-option>
</mat-select>
</mat-form-field>
<button *ngIf="versionControl.value && substance.version?.toString() !== versionControl.value"
<button *ngIf="versionControl.value && substance.version?.toString() !== versionControl.value.toString()"
mat-raised-button color="primary" class="view-version" (click)="changeVersion()">View</button>
</div>
<div *ngIf="substance.version && latestVersion && +substance.version < latestVersion && !substance.$$source" class="indent">
Expand Down
13 changes: 7 additions & 6 deletions src/app/core/substance/substance.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams, HttpErrorResponse, HttpClientJsonpModule, HttpParameterCodec } from '@angular/common/http';
import { BehaviorSubject, concatMap, filter, interval, Observable, Observer, Subject, throwError } from 'rxjs';
import { HttpClient, HttpParams, HttpErrorResponse, HttpParameterCodec } from '@angular/common/http';
import { BehaviorSubject, concatMap, Observable, Observer, Subject, throwError } from 'rxjs';
import { ConfigService } from '../config/config.service';
import { BaseHttpService } from '../base/base-http.service';
import {
Expand All @@ -11,7 +11,6 @@ import {
SubstanceCode,
SubstanceRelationship,
SubstanceRelated,
SubstanceReference,
SubstanceDiff
} from './substance.model';
import { PagingResponse, ShortResult } from '../utils/paging-response.model';
Expand Down Expand Up @@ -61,7 +60,7 @@ export class SubstanceService extends BaseHttpService {
private authService: AuthService,
public configService: ConfigService,
private sanitizer: DomSanitizer,
private utilsService: UtilsService,
private utilsService: UtilsService
) {
super(configService);
}
Expand Down Expand Up @@ -808,6 +807,7 @@ export class SubstanceService extends BaseHttpService {

getSubstanceDetails(id: string, version?: string | number): Observable<SubstanceDetail> {
const url = `${this.apiBaseUrl}substances(${id})`;
const restApiPrefix = this.configService.configData.restApiPrefix || '';
let params = new HttpParams();
params = params.append('view', 'internal');
const options = {
Expand All @@ -826,7 +826,8 @@ export class SubstanceService extends BaseHttpService {
`No @edits entry found for version=${v} on substance(${id}).`
));
}
return this.http.get<SubstanceDetail>(match.oldValue, options);
const _matchOldValue = this.utilsService.adjustBackendUrlWithRestApiPrefix('/api/v1', restApiPrefix, match.oldValue);
return this.http.get<SubstanceDetail>(_matchOldValue, options);
}));

} else {
Expand Down Expand Up @@ -902,7 +903,7 @@ export class SubstanceService extends BaseHttpService {

const url = `${this.apiBaseUrl}substances?view=internal`;
if (!this.configService.configData.isPfdaVersion) {
return this.http.request(method, url, options);
return this.http.request(method, url, options);
} else {
return this.authService.getAuth().pipe(
concatMap(auth =>
Expand Down
8 changes: 8 additions & 0 deletions src/app/core/substances-browse/substances-browse.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,14 @@ export class SubstancesBrowseComponent implements OnInit, AfterViewInit, OnDestr
}
this.substanceService.getExportOptions(pagingResponse.etag).subscribe(response => {
this.exportOptions = response.filter(exp => {
// this is experimental, pending discussion on how gateway works
if (exp?.link?.url) {
exp.link.url = this.utilsService.adjustBackendUrlWithRestApiPrefix(
"/api/v1",
this.configService.configData.restApiPrefix||'',
exp.link.url
);
}
if (exp.extension) {
//TODO Make this generic somehow, so addditional-type exports are isolated
if ((exp.extension === 'appxlsx') || (exp.extension === 'prodxlsx') ||
Expand Down
18 changes: 18 additions & 0 deletions src/app/core/utils/utils.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,22 @@ export class UtilsService {
const lq =targetField + ':"^' + s +'"';
return lq;
}

adjustBackendUrlWithRestApiPrefix(searchFragment: string, restPrefix: string, url: string) {
// Consider instead to decompose and recompose the url in case search
// terms appear in query params, etc.
// Consider making global function that can be used
// in lots of places
if (!restPrefix) { return url; }
if (!searchFragment) { return url; }
if (!url) { return url; }
const _restPrefix = restPrefix.trim();
const _searchFragment = searchFragment.trim();
if( _restPrefix.trim().length == 0) { return url; }
if( _searchFragment.trim().length == 0) { return url; }
if (url.indexOf(_restPrefix) > -1) { return url; }
if (!(url.indexOf(_searchFragment) > -1)) { return url; }
url = url.replace(_searchFragment, _restPrefix + _searchFragment);
return url;
}
}
13 changes: 13 additions & 0 deletions src/environments/environment.fda.local3x.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { baseEnvironment } from 'src/environments';

export const environment = baseEnvironment;
environment.appId = 'fda';
environment.clasicBaseHref = '/ginas/app/';
environment.baseHref = '/ginas/app/ui/';
environment.baseHref = '';

environment.appId = 'fda';
environment.isAnalyticsPrivate = true;
environment.structureEditor = 'jsdraw';

export { FdaModule as EnvironmentModule } from '../app/fda/fda.module';
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<meta charset="utf-8">
<title>GSRS</title>
<base href="/ginas/app/ui/">
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" sizes="57x57" href="/assets/favicon/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/assets/favicon/apple-icon-60x60.png">
Expand Down
Loading