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
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
18 changes: 12 additions & 6 deletions src/app/core/substance/substance.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { HttpClient, HttpParams, HttpClientJsonpModule, HttpParameterCodec } from '@angular/common/http';
import { BehaviorSubject, concatMap, filter, interval, Observable, Observer, Subject, throwError } from 'rxjs';
import { ConfigService } from '../config/config.service';
Expand All @@ -25,9 +25,12 @@ import {Facet, FacetQueryResponse} from '@gsrs-core/facets-manager';
import { StructuralUnit } from '@gsrs-core/substance';
import {HierarchyNode} from '@gsrs-core/substances-browse/substance-hierarchy/hierarchy.model';
import { SubstanceDependenciesImageNode } from '@gsrs-core/substance-details/substance-dependencies-image/substance-dependencies-image.model';

import { AuthService } from "@gsrs-core/auth";
import { SubstancesBrowseComponent } from '@gsrs-core/substances-browse/substances-browse.component';

class CustomEncoder implements HttpParameterCodec {


encodeKey(key: string): string {
return encodeURIComponent(key);
}
Expand Down Expand Up @@ -61,7 +64,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 +811,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 @@ -816,17 +820,18 @@ export class SubstanceService extends BaseHttpService {
if (version !== undefined && version !== null) {
const v = String(version);
const editurl = `${this.apiBaseUrl}substances(${id})/@edits`;

return this.http.get<any[]>(editurl, { withCredentials: true }).pipe(
switchMap((response: any[]) => {
const match = (response ?? []).find(resp => String(resp?.version) === v);

if(!match?.oldValue) {
return throwError(() => new Error(
`No @edits entry found for version=${v} on substance(${id}).`
));
}
return this.http.get<SubstanceDetail>(match.oldValue, options);
// /api/v1/substances
// /ginas/app/api/v1/substances
const _matchOldValue = this.utilsService.adjustBackendUrlWithRestApiPrefix('/api/v1', restApiPrefix, match.oldValue);
return this.http.get<SubstanceDetail>(_matchOldValue, options);
}));

} else {
Expand Down Expand Up @@ -1099,6 +1104,7 @@ export class SubstanceService extends BaseHttpService {
search = 'substances';
}
const url = `${this.configService.configData.apiBaseUrl}api/v1/${search}/export/${etag}`;
console.log("this is the url:" + url);
return this.http.get< any>(url);
}

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 @@ -726,6 +726,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