| References |
-
diff --git a/src/app/core/substance-details/substance-names/substance-names.component.html b/src/app/core/substance-details/substance-names/substance-names.component.html
index 2dc7a32c0..b8b5876b1 100644
--- a/src/app/core/substance-details/substance-names/substance-names.component.html
+++ b/src/app/core/substance-details/substance-names/substance-names.component.html
@@ -14,7 +14,7 @@
'>Both
-
+
{{showHideFilterText}}
@@ -162,22 +162,22 @@
| Details |
-
Details
-
+
0">
- Naming organizations:
+ Naming organizations:
- {{org.nameOrg}}{{!last? ', ':''}}
+ {{org.nameOrg}}{{!last? ', ':''}}
0">
diff --git a/src/app/core/substance-details/substance-references/substance-references.component.html b/src/app/core/substance-details/substance-references/substance-references.component.html
index e33d554d8..9ec599324 100644
--- a/src/app/core/substance-details/substance-references/substance-references.component.html
+++ b/src/app/core/substance-details/substance-references/substance-references.component.html
@@ -97,7 +97,7 @@
Access |
-
+ |
diff --git a/src/app/core/substance-details/substance-relationships/substance-relationships.component.html b/src/app/core/substance-details/substance-relationships/substance-relationships.component.html
index d213b4b8b..3798f0ea2 100644
--- a/src/app/core/substance-details/substance-relationships/substance-relationships.component.html
+++ b/src/app/core/substance-details/substance-relationships/substance-relationships.component.html
@@ -33,12 +33,12 @@
| Details |
-
+
Advanced Features
@@ -59,7 +59,7 @@
Switch primary and alt definitions
-
+
Predict N-Glycosylation Sites
@@ -212,8 +212,7 @@ {{ section.menuLabel }}
{{ validationMessages && validationMessages.length > 0 ? 'Dismiss All and ' : '' }}
- Submit
+ [disabled]="isLoading || (this.validationResult === false)">{{ getSubmitButtonText() }}
Cancel
diff --git a/src/app/core/substance-form/substance-form.component.ts b/src/app/core/substance-form/substance-form.component.ts
index 4dc39a717..9d1c47f9a 100644
--- a/src/app/core/substance-form/substance-form.component.ts
+++ b/src/app/core/substance-form/substance-form.component.ts
@@ -92,6 +92,7 @@ export class SubstanceFormComponent implements OnInit, AfterViewInit, OnDestroy
isAdmin: boolean;
isUpdater: boolean;
messageField: string;
+ isPfdaVersion: boolean = false;
uuid: string;
substanceClass: string;
drafts: Array;
@@ -236,6 +237,36 @@ export class SubstanceFormComponent implements OnInit, AfterViewInit, OnDestroy
});
}
+ processImportedSubstance(response?: string): void {
+ if (response) {
+ // this.overlayContainer.style.zIndex = null;
+ this.loadingService.setLoading(true);
+
+ // attempting to reload a substance without a router refresh has proven to cause issues with the relationship dropdowns
+ // There are probably other components affected. There is an issue with subscriptions likely due to some OnInit not firing
+
+ const read = JSON.parse(response);
+ if (this.id && read.uuid && this.id === read.uuid) {
+ this.substanceFormService.importSubstance(read, 'update');
+ this.submissionMessage = null;
+ this.validationMessages = [];
+ this.showSubmissionMessages = false;
+ setTimeout(() => {
+ this.loadingService.setLoading(false);
+ this.isLoading = false;
+ this.overlayContainer.style.zIndex = null;
+ }, 1000);
+ } else {
+ setTimeout(() => {
+ this.overlayContainer.style.zIndex = null;
+ this.router.onSameUrlNavigation = 'reload';
+ this.loadingService.setLoading(false);
+ this.router.navigateByUrl('/substances/register?action=import', {state: {record: response}});
+
+ }, 1000);
+ }
+ }
+ }
importDialog(): void {
const dialogRef = this.dialog.open(SubstanceEditImportDialogComponent, {
@@ -245,46 +276,7 @@ export class SubstanceFormComponent implements OnInit, AfterViewInit, OnDestroy
});
this.overlayContainer.style.zIndex = '1002';
- const dialogSubscription = dialogRef.afterClosed().pipe(take(1)).subscribe(response => {
- if (response) {
- // this.overlayContainer.style.zIndex = null;
- this.loadingService.setLoading(true);
-
- // attempting to reload a substance without a router refresh has proven to cause issues with the relationship dropdowns
- // There are probably other components affected. There is an issue with subscriptions likely due to some OnInit not firing
-
- const read = JSON.parse(response);
- if (this.id && read.uuid && this.id === read.uuid) {
- this.substanceFormService.importSubstance(read, 'update');
- this.submissionMessage = null;
- this.validationMessages = [];
- this.showSubmissionMessages = false;
- setTimeout(() => {
- this.loadingService.setLoading(false);
- this.isLoading = false;
- this.overlayContainer.style.zIndex = null;
- }, 1000);
- /* } else {
- if ( read.substanceClass === this.substanceClass) {
- this.imported = true;
- this.substanceFormService.importSubstance(read);
- this.submissionMessage = null;
- this.validationMessages = [];
- this.showSubmissionMessages = false;
- this.loadingService.setLoading(false);
- this.isLoading = false;*/
- } else {
- setTimeout(() => {
- this.overlayContainer.style.zIndex = null;
- this.router.onSameUrlNavigation = 'reload';
- this.loadingService.setLoading(false);
- this.router.navigateByUrl('/substances/register?action=import', {state: {record: response}});
-
- }, 1000);
- }
- }
- // }
- });
+ const dialogSubscription = dialogRef.afterClosed().pipe(take(1)).subscribe(response => this.processImportedSubstance(response));
}
@@ -313,6 +305,7 @@ export class SubstanceFormComponent implements OnInit, AfterViewInit, OnDestroy
}
this.isAdmin = this.authService.hasRoles('admin');
this.isUpdater = this.authService.hasAnyRoles('Updater', 'SuperUpdater');
+ this.isPfdaVersion = this.configService.configData.isPfdaVersion;
this.overlayContainer = this.overlayContainerService.getContainerElement();
this.imported = false;
if(this.location.path().includes('chemical-simplified')) {
@@ -327,6 +320,9 @@ export class SubstanceFormComponent implements OnInit, AfterViewInit, OnDestroy
.subscribe(params => {
const action = this.activatedRoute.snapshot.queryParams['action'] || null;
+ if (action && action === 'pfda-file-import') {
+ this.importFromUriParam();
+ }
if (params['id']) {
@@ -448,6 +444,35 @@ export class SubstanceFormComponent implements OnInit, AfterViewInit, OnDestroy
});
}
+ // Load file from URI (as passed in file-uri URL parameter) and try to import it into a submission form
+ private importFromUriParam() {
+ const fileUri = this.activatedRoute.snapshot.queryParams['file-uri'] || null;
+ if (!fileUri) {
+ this.isLoading = false;
+ this.loadingService.setLoading(false);
+ return this.mainNotificationService.setErrorNotification('File URI was not specified');
+ }
+ this.mainNotificationService.setSuccessNotification('Loading file...', 0);
+ fetch(fileUri).then((response) => {
+ if (response.status === 200) {
+ response.json().then(responseJson => {
+ this.mainNotificationService.setSuccessNotification('Processing imported substance...');
+ this.processImportedSubstance(JSON.stringify(responseJson));
+ }).catch(reason => {
+ this.mainNotificationService.setErrorNotification(`Error while parsing imported file: ${reason.message}`);
+ })
+ } else {
+ const errMsg = response.status === 401 ? `Your session expired. Please login and try again.` : `Error while loading file: ${response.status}`;
+ this.mainNotificationService.setErrorNotification(errMsg);
+ }
+ }).catch(reason => {
+ this.mainNotificationService.setErrorNotification(`Error while importing file: ${reason.message}`);
+ })
+ this.isLoading = false;
+ this.loadingService.setLoading(false);
+ return;
+ }
+
isBase64(str) {
let base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
let result = decodeURIComponent(str);
@@ -1039,6 +1064,21 @@ export class SubstanceFormComponent implements OnInit, AfterViewInit, OnDestroy
})
}
+ getSubmitButtonText(): string {
+ const parts = [];
+ if (this.validationMessages && this.validationMessages.length > 0) {
+ parts.push('Dismiss all');
+ }
+ if (!this.authService.getUser()) {
+ parts.push('Login');
+ }
+ parts.push('Submit');
+
+ if (parts.length === 0) return '';
+ if (parts.length === 1) return parts[0];
+ return parts.slice(0, -1).join(', ') + ' and ' + parts[parts.length - 1];
+ }
+
submit(): void {
this.isLoading = true;
this.approving = false;
@@ -1100,7 +1140,9 @@ export class SubstanceFormComponent implements OnInit, AfterViewInit, OnDestroy
messageType: 'ERROR',
message: 'Unknown Server Error'
};
- if (error && error.error && error.error.message) {
+ if (error && error.type === 'AUTH') {
+ message.message = `Authentication Error: ${error.message}`;
+ } else if (error && error.error && error.error.message) {
message.message = 'Server Error ' + (error.status + ': ' || ': ') + error.error.message;
} else if (error && error.error && (typeof error.error) === 'string') {
message.message = 'Server Error ' + (error.status + ': ' || '') + error.error;
diff --git a/src/app/core/substance/substance.service.ts b/src/app/core/substance/substance.service.ts
index 36fd85f7b..0d0ae7fd9 100644
--- a/src/app/core/substance/substance.service.ts
+++ b/src/app/core/substance/substance.service.ts
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams, HttpClientJsonpModule, HttpParameterCodec } from '@angular/common/http';
-import { BehaviorSubject, interval, Observable, Observer, Subject } from 'rxjs';
+import { BehaviorSubject, concatMap, filter, interval, Observable, Observer, Subject, throwError } from 'rxjs';
import { ConfigService } from '../config/config.service';
import { BaseHttpService } from '../base/base-http.service';
import {
@@ -27,6 +27,7 @@ import {HierarchyNode} from '@gsrs-core/substances-browse/substance-hierarchy/hi
import { SubstanceDependenciesImageNode } from '@gsrs-core/substance-details/substance-dependencies-image/substance-dependencies-image.model';
import { stringify } from 'querystring';
+import { AuthService } from "@gsrs-core/auth";
class CustomEncoder implements HttpParameterCodec {
encodeKey(key: string): string {
return encodeURIComponent(key);
@@ -58,6 +59,7 @@ export class SubstanceService extends BaseHttpService {
tempObject: any;
constructor(
public http: HttpClient,
+ private authService: AuthService,
public configService: ConfigService,
private sanitizer: DomSanitizer,
private utilsService: UtilsService,
@@ -775,15 +777,30 @@ export class SubstanceService extends BaseHttpService {
}
saveSubstance(substance: SubstanceDetail, type?: string): Observable {
+ const method = type === 'import' || !substance.uuid ? 'POST' : 'PUT';
+ const options = { body: substance };
+
const url = `${this.apiBaseUrl}substances?view=internal`;
- let method = substance.uuid ? 'PUT' : 'POST';
- if (type && type === 'import') {
- method = 'POST';
+ if (!this.configService.configData.isPfdaVersion) {
+ return this.http.request(method, url, options);
+ } else {
+ return this.authService.getAuth().pipe(
+ concatMap(auth =>
+ auth
+ ? this.http.request(method, url, options)
+ : this.authService.pfdaLogin().pipe(
+ concatMap(success =>
+ success
+ ? this.http.request(method, url, options)
+ : throwError(() => ({
+ type: 'AUTH',
+ message: 'Authentication failed',
+ }))
+ )
+ )
+ )
+ );
}
- const options = {
- body: substance
- };
- return this.http.request(method, url, options);
}
saveSubstanceWithoutValidation(substance: SubstanceDetail, type?: string): Observable {
@@ -1050,7 +1067,7 @@ export class SubstanceService extends BaseHttpService {
public GetStagedRecord(id:string) {
let url = `${(this.configService.configData && this.configService.configData.apiBaseUrl) || '/' }api/v1/substances/stagingArea/${id}`;
-
+
return this.http.get< any >(`${url}`);
}
diff --git a/src/app/core/substances-browse/substances-browse.component.html b/src/app/core/substances-browse/substances-browse.component.html
index b25f6cdb5..16f41ef9f 100644
--- a/src/app/core/substances-browse/substances-browse.component.html
+++ b/src/app/core/substances-browse/substances-browse.component.html
@@ -741,5 +741,3 @@ {{privateSearchType | titlecase }} Search is Processing...
Close dialog
-
-
diff --git a/src/app/core/substances-browse/substances-browse.component.scss b/src/app/core/substances-browse/substances-browse.component.scss
index 2dc2787d1..e9f8acdd8 100644
--- a/src/app/core/substances-browse/substances-browse.component.scss
+++ b/src/app/core/substances-browse/substances-browse.component.scss
@@ -347,7 +347,7 @@ display: flex;
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
color: var(--pink-span-color);
}
-
+
.similarity-label {
font-style: italic;
}
@@ -627,7 +627,7 @@ display: flex;
::ng-deep .mat-select-value {
max-width: 100%;
width: auto;
- }
+ }
}
.page-label {
@@ -776,14 +776,14 @@ margin-left: 20px;
font-size: 14px;
height: 35px;
}
-
+
.structure-dialog-content {
line-height: 28px;
margin-left: 20px;
}
.fieldset-crosssearch {
- border: 1px solid --var(--regular-lightgray-color);
+ border: 1px solid --var(--regular-lightgray-color);
display: inline-block;
padding-left: 0px;
margin-left: 2px;
@@ -797,7 +797,7 @@ margin-left: 20px;
width: 100%;
min-width: 100%;
}
-
+
.margintop10px {
margin-top: 10px;
}
@@ -816,4 +816,4 @@ margin-left: 20px;
.marginbottom20px {
margin-bottom: 20px;
-}
\ No newline at end of file
+}
diff --git a/src/app/core/substances-browse/substances-browse.component.ts b/src/app/core/substances-browse/substances-browse.component.ts
index 7d865b711..8fc067967 100644
--- a/src/app/core/substances-browse/substances-browse.component.ts
+++ b/src/app/core/substances-browse/substances-browse.component.ts
@@ -257,7 +257,7 @@ export class SubstancesBrowseComponent implements OnInit, AfterViewInit, OnDestr
this.smiles = this.activatedRoute.snapshot.queryParams['smiles'] || '';
// the sort order should be set to default (similarity) for structure searches, last edited for all others
this.order = this.activatedRoute.snapshot.queryParams['order'] ||
- (this.privateStructureSearchTerm && this.privateStructureSearchTerm !== '' ? 'default' : '$root_lastEdited');
+ (this.privateStructureSearchTerm && this.privateStructureSearchTerm !== '' ? 'default' : '$root_lastEdited');
this.view = this.activatedRoute.snapshot.queryParams['view'] || 'cards';
this.pageSize = parseInt(this.activatedRoute.snapshot.queryParams['pageSize'], null) || 10;
const deprecated = this.activatedRoute.snapshot.queryParams['showDeprecated'];
@@ -1377,7 +1377,7 @@ export class SubstancesBrowseComponent implements OnInit, AfterViewInit, OnDestr
} else {
this.idLists = [];
}
- } // pagingResponse
+ } // pagingResponse
}, error => {
console.log('Error during search substance');
}, () => {
@@ -1418,7 +1418,7 @@ export class SubstancesBrowseComponent implements OnInit, AfterViewInit, OnDestr
this.subEntity = searchParamItems['subEntity'];
this.subEntityDisplayFacets = searchParamItems['subEntityDisplayFacets'];
}
- }
+ }
*/
let randomInteger = Math.floor(Math.random() * 100000000);
// Using random number to create different value, so it will trigger change Detection for Input
@@ -1455,7 +1455,7 @@ export class SubstancesBrowseComponent implements OnInit, AfterViewInit, OnDestr
localStorage.setItem(this.searchTermHash.toString(), queryStatementHashesString);
}
-
+
// ** END: Store in Local Storage
*/
@@ -1477,4 +1477,4 @@ export class SubstancesBrowseComponent implements OnInit, AfterViewInit, OnDestr
// this.router.navigate(['/advanced-search'], navigationExtras);
}
-}
\ No newline at end of file
+}
diff --git a/src/app/fda/fda.module.ts b/src/app/fda/fda.module.ts
index 897f2d27e..f80423e16 100644
--- a/src/app/fda/fda.module.ts
+++ b/src/app/fda/fda.module.ts
@@ -27,7 +27,6 @@ import { SubstanceApplicationMatchListComponent} from './substance-browse/substa
import { ApplicationsBrowseComponent } from './application/applications-browse/applications-browse.component';
import { ClinicalTrialsBrowseComponent } from './clinical-trials/clinical-trials-browse/clinical-trials-browse.component';
import { fdaSubstanceCardsFilters } from './substance-details/fda-substance-cards-filters.constant';
-import { SsoRefreshService } from './service/sso-refresh.service';
import { ProductService } from './product/service/product.service';
import { GeneralService} from './service/general.service';
import { ShowApplicationToggleComponent } from './substance-browse/show-application-toggle/show-application-toggle.component';
@@ -59,12 +58,6 @@ const fdaRoutes: Routes = [
}
];
-export function init_sso_refresh_service(ssoService: SsoRefreshService) {
- return() => {
- ssoService.init();
- };
-}
-
@NgModule({
imports: [
CommonModule,
@@ -104,15 +97,6 @@ export function init_sso_refresh_service(ssoService: SsoRefreshService) {
SubstanceCountsComponent,
ShowApplicationToggleComponent
- ],
- providers: [
- SsoRefreshService,
- {
- provide: APP_INITIALIZER,
- useFactory: init_sso_refresh_service,
- deps: [SsoRefreshService],
- multi: true
- }
]
})
export class FdaModule {
diff --git a/src/app/fda/service/sso-refresh.service.spec.ts b/src/app/fda/service/sso-refresh.service.spec.ts
deleted file mode 100644
index ca2f068f5..000000000
--- a/src/app/fda/service/sso-refresh.service.spec.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { TestBed } from '@angular/core/testing';
-
-import { SsoRefreshService } from './sso-refresh.service';
-
-describe('SsoRefreshService', () => {
- beforeEach(() => TestBed.configureTestingModule({}));
-
- it('should be created', () => {
- const service: SsoRefreshService = TestBed.get(SsoRefreshService);
- expect(service).toBeTruthy();
- });
-});
diff --git a/src/app/fda/service/sso-refresh.service.ts b/src/app/fda/service/sso-refresh.service.ts
deleted file mode 100644
index aa97fb0a4..000000000
--- a/src/app/fda/service/sso-refresh.service.ts
+++ /dev/null
@@ -1,87 +0,0 @@
-import { Injectable, Inject, PLATFORM_ID, OnDestroy } from '@angular/core';
-import { Router, NavigationExtras, ActivatedRoute } from '@angular/router';
-import { isPlatformBrowser } from '@angular/common';
-import { take } from 'rxjs/operators';
-import { AuthService } from '@gsrs-core/auth';
-import { UtilsService } from '@gsrs-core/utils';
-import { ConfigService } from '@gsrs-core/config/config.service';
-
-@Injectable()
-export class SsoRefreshService implements OnDestroy {
- private iframe: HTMLIFrameElement;
- private refreshInterval: any;
- private baseHref: string;
- private showHeaderBar = 'true';
-
- constructor(
- @Inject(PLATFORM_ID) private platformId: Object,
- private utilsService: UtilsService,
- private configService: ConfigService,
- private authService: AuthService,
- private activatedRoute: ActivatedRoute
- ) {
- if (isPlatformBrowser(this.platformId)) {
-
- if (window.location.pathname.indexOf('/ginas/app/ui/') > -1) {
- this.baseHref = '/ginas/app/';
- }
- }
- }
-
- updateIframe(): any {
- if (!this.iframe) {
- this.iframe = document.createElement('IFRAME') as HTMLIFrameElement;
- this.iframe.title = 'page refresher';
- this.iframe.name = 'refresher';
- this.iframe.style.height = '0';
- this.iframe.style.opacity = '0';
- this.iframe.src = `${this.baseHref || ''}api/v1/whoami?key=${this.utilsService.newUUID()}&noWarningBox=true`;
- document.body.appendChild(this.iframe);
- } else {
- this.iframe.src = `${this.baseHref || ''}api/v1/whoami?key=${this.utilsService.newUUID()}&noWarningBox=true`;
- }
- }
-
- setup() {
- this.configService.afterLoad().then(cd => {
- // Session auto refresh can be explicitly disabled in config file
- if (this.configService.configData.disableSessionRefresh) {
- return;
- }
- const homeBaseUrl = this.configService.configData && this.configService.configData.gsrsHomeBaseUrl || null;
- if (homeBaseUrl) {
- this.baseHref = homeBaseUrl;
- this.updateIframe();
- }
- clearInterval(this.refreshInterval);
- this.refreshInterval = setInterval(() => {
- console.log("REFRESHING iFrame");
- this.updateIframe();
- }, 600000);
- });
- }
-
- init(): any {
- if(new URLSearchParams(window.location.search).get("noWarningBox") === 'true'){
- //do not do sso refresher recursively
- return;
- }
- if (new URLSearchParams(window.location.search).get("header") === 'false') {
- this.setup();
- } else {
- this.authService.getAuth().subscribe(auth => {
- if (auth != null && this.refreshInterval == null) {
- this.setup();
- } else if (auth === null){
- clearInterval(this.refreshInterval);
- this.refreshInterval = null;
- }
- });
- } //else
- }
-
- ngOnDestroy() {
- clearInterval(this.refreshInterval);
- this.refreshInterval = null;
- }
-}
| | | |