Skip to content

Commit

Permalink
Merge pull request #454 from ncats/momentCheck
Browse files Browse the repository at this point in the history
SR2 changes for staging area
  • Loading branch information
NikoAnderson authored Aug 29, 2023
2 parents 6fd257f + 4a63252 commit 267128e
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 47 deletions.
2 changes: 1 addition & 1 deletion package.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"helmet": "3.21.2",
"lodash": "4.17.21",
"lucene-query-parser": "1.2.0",
"moment": "2.29.4",
"moment": "2.29.2",
"ng-multiselect-dropdown": "0.2.10",
"ngx-json-viewer": "2.4.0",
"ngx-moment": "3.5.0",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"ketcher-wrapper": "file:dist/ketcher-wrapper/ketcher-wrapper-0.0.1.tgz",
"lodash": "4.17.21",
"lucene-query-parser": "1.2.0",
"moment": "2.29.2",
"moment": "2.29.4",
"ng-multiselect-dropdown": "0.2.10",
"ngx-json-viewer": "2.4.0",
"ngx-moment": "3.5.0",
Expand Down Expand Up @@ -106,7 +106,7 @@
"husky": "7.0.4",
"jasmine-core": "4.0.0",
"jasmine-spec-reporter": "7.0.0",
"karma": "6.3.15",
"karma": "6.4.2",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-jasmine": "4.0.1",
Expand Down
2 changes: 1 addition & 1 deletion package.real.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"ketcher-wrapper": "file:dist/ketcher-wrapper/ketcher-wrapper-0.0.1.tgz",
"lodash": "4.17.21",
"lucene-query-parser": "1.2.0",
"moment": "2.29.4",
"moment": "2.29.2",
"ng-multiselect-dropdown": "0.2.10",
"ngx-json-viewer": "2.4.0",
"ngx-moment": "3.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ImportDialogComponent } from '@gsrs-core/admin/import-management/import
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { LoadingService } from '@gsrs-core/loading';
import { AdminService } from '@gsrs-core/admin/admin.service';
import { ConfigService } from '@gsrs-core/config';

@Component({
selector: 'app-bulk-action-dialog',
Expand All @@ -21,11 +22,13 @@ export class BulkActionDialogComponent implements OnInit {
deleteStaged = true;
altStatusCount = 0;
completedRecordCount = 0;
showMerge = false;
constructor(

public dialogRef: MatDialogRef<ImportDialogComponent>,
public loadingService: LoadingService,
private adminService: AdminService,
private configService: ConfigService,


@Inject(MAT_DIALOG_DATA) public data: any
Expand All @@ -40,7 +43,12 @@ export class BulkActionDialogComponent implements OnInit {
this.altStatusCount = 0;
Object.keys(this.records).forEach(record => {
if(this.records[record].checked) {
const temp = {"ID": record, "checked": true, "name": this.records[record].name};
let temp = {};
if (this.records[record].substance) {
temp = {"ID": record, "checked": true, "name": this.records[record].substance._name};
} else {
temp = {"ID": record, "checked": true, "name": this.records[record].name};
}
this.filtered.push(temp);
/*f (this.records[record].substance && this.records[record].substance._metadata && this.records[record].substance._metadata.importStatus
&& this.records[record].substance._metadata.importStatus !== 'staged') {
Expand All @@ -55,6 +63,11 @@ export class BulkActionDialogComponent implements OnInit {


ngOnInit(): void {
if (this.configService.configData && this.configService.configData.stagingArea) {
if (this.configService.configData.stagingArea.mergeAction) {
this.showMerge = this.configService.configData.stagingArea.mergeAction
}
}
}

deleteStagedRecords(): void {
Expand Down
5 changes: 2 additions & 3 deletions src/app/core/admin/import-browse/import-browse.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,10 @@ export class ImportBrowseComponent implements OnInit, AfterViewInit, OnDestroy {
});
} else {
this.substances.forEach(record => {
console.log(record);
if (this.bulkList[record.id]) {
if (record.id && this.bulkList[record.id]) {
this.bulkList[record.id].checked = true;
} else {
this.bulkList[record.id.recordId] = {"checked": true, "name": record.name, "id": record.id};
this.bulkList[record.id] = {"checked": true, "name": record.name, "id": record.id};
}

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
<span><a class ="action-button" color = "primary" [disabled] = "disabled" mat-button mat-flat-button mat-primary-button
[routerLink]="['/substances/register']"
[queryParams]="{stagingID : substance._metadata.recordId}">Edit</a></span>
<span ><button class ="action-button" [disabled] = "disabled" color = "primary" mat-button mat-flat-button mat-primary-button
<span ><button *ngIf = "showMerge" class ="action-button" [disabled] = "disabled || !showMerge" color = "primary" mat-button mat-flat-button mat-primary-button
(click) = "openMergeModal()">Merge</button></span>
<span><button class ="action-button" color = "primary" [disabled] = "disabled" mat-button mat-flat-button mat-primary-button
(click) = "doAction('reject')">Reject</button></span>
Expand Down Expand Up @@ -411,7 +411,7 @@
</ng-container>-->
<ng-container matColumnDef="merge">
<th mat-header-cell *matHeaderCellDef> </th>
<td mat-cell *matCellDef="let record"> <span ><button class = "action-button" color = "primary" (click) = "openMergeModal(record)" mat-button mat-flat-button mat-primary-button [disabled] = "disabled" >Merge</button></span></td>
<td mat-cell *matCellDef="let record"> <span ><button class = "action-button" *ngIf = "showMerge" color = "primary" (click) = "openMergeModal(record)" mat-button mat-flat-button mat-primary-button [disabled] = "disabled || !showMerge" >Merge</button></span></td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class ImportSummaryComponent implements OnInit {
displayedColumns2 = ['type', 'message'];
message = "";
private privateMatches: any;
showMerge = false;

disabled = false;
performedAction: string;
Expand Down Expand Up @@ -130,11 +131,18 @@ export class ImportSummaryComponent implements OnInit {
if (this.configService.configData && this.configService.configData.molWeightRounding) {
this.rounding = '1.0-' + this.configService.configData.molWeightRounding;
}

if (this.configService.configData && this.configService.configData.stagingArea) {
if (this.configService.configData.stagingArea.mergeAction) {
this.showMerge = this.configService.configData.stagingArea.mergeAction
}
}
// this.privateMatches = JSON.parse(JSON.stringify(this.substance.matchedRecords)).slice(0, 5);
}


matchFieldsToCount(matches: any) {
console.log(matches);
matches.forEach(match => {
let newArr: Array<any> = [];
match.records.forEach(record => {
Expand Down Expand Up @@ -180,21 +188,34 @@ export class ImportSummaryComponent implements OnInit {
return this.privateBulkAction;
}

getMatchSummary() {
this.substance.matchedRecords.forEach(record => {
console.log(record);
changePage(event: PageEvent) {
this.pageSize = event.pageSize;
this.pageIndex = event.pageIndex;
const skip = event.pageSize * event.pageIndex;
this.privateMatches = JSON.parse(JSON.stringify(this.substance.matchedRecords)).slice(skip, (this.pageSize + skip));
this.matchFieldsToCount(this.privateMatches);

this.getMatchSummary();

}

getMatchSummary(skip?: any) {
if (!skip) {
this.privateMatches = JSON.parse(JSON.stringify(this.substance.matchedRecords)).slice(0, 5);
this.matchFieldsToCount(this.privateMatches);
}

this.privateMatches.forEach(record => {
if (record.source && record.source === 'Staging Area'){
this.adminService.GetStagedRecord(record.ID).subscribe(response => {
record._name = response._name;
this.privateMatches = JSON.parse(JSON.stringify(this.substance.matchedRecords)).slice(0, 5);
}, error => {
console.log(error);
})
} else {
this.substanceService.getSubstanceSummary(record.ID).subscribe(response => {
record.uuid = response.uuid;
record._name = response._name;
this.privateMatches = JSON.parse(JSON.stringify(this.substance.matchedRecords)).slice(0, 5);
}, error => {
console.log(error);
});
Expand Down Expand Up @@ -284,14 +305,14 @@ export class ImportSummaryComponent implements OnInit {
}

doAction(action: string, mergeID?: string) {

console.log(action);
this.displayAction = action;
this.loadingService.setLoading(true);
this.adminService.stagedRecordSingleAction(this.privateSubstance._metadata.recordId, action).subscribe(result => {
if (result.jobStatus === 'completed') {
this.loadingService.setLoading(false);
this.doneAction.emit(this.privateSubstance.uuid);
this.message = "Record " + action + " successful";
this.message = this.displayAction + " record action completed successfully";
if (result) {
this.disabled = true;
this.performedAction = action;
Expand Down Expand Up @@ -328,8 +349,8 @@ export class ImportSummaryComponent implements OnInit {
if (response.jobStatus === 'completed') {
this.loadingService.setLoading(false);
this.doneAction.emit(this.privateSubstance.uuid);
this.message = "Record " + action + " successful";
if (result) {
this.message = this.displayAction + " record action completed successfully";
if (result) {
this.disabled = true;
this.performedAction = action;
}
Expand Down Expand Up @@ -476,7 +497,8 @@ export class ImportSummaryComponent implements OnInit {
const dialogRef = this.dialog.open(MergeActionDialogComponent, {
minWidth: '50%',
maxWidth: '90%',
height: '80%',
minHeight: '600px',
maxHeight: '90%',
data: temp
});
this.overlayContainer.style.zIndex = '1002';
Expand All @@ -502,13 +524,7 @@ export class ImportSummaryComponent implements OnInit {
this.showLessCodes = !this.showLessCodes;
}

changePage(event: PageEvent) {
this.pageSize = event.pageSize;
this.pageIndex = event.pageIndex;
const skip = event.pageSize * event.pageIndex;
this.privateMatches = JSON.parse(JSON.stringify(this.substance.matchedRecords)).slice(skip, (this.pageSize + skip));

}



}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h3 mat-dialog-header>Staging Record Merge</h3>
<div mat-dialog-content style = "min-height:525px" >
<h3 mat-dialog-header>Staging Record Merge <span class = "experimental-label">(experimental)</span></h3>
<div mat-dialog-content style = "min-height:500px" >
<div *ngIf = "!loading && !completed">
<sf-form [schema]="mergeSchema" [model]="mergeModel" (onChange)="checkValue($event.value)" class = "top-margin"></sf-form>
<div style = "margin-top:25px;" *ngIf = "!data.mergeRecord"><b>Select a record to merge into</b>
Expand Down Expand Up @@ -37,18 +37,18 @@ <h3 mat-dialog-header>Staging Record Merge</h3>
</div>


<div mat-dialog-actions style = "height: 50px;">
<div mat-dialog-actions style = "min-height: 50px;">
<div *ngIf = "success" style = "display:flex;width:100%">
<span class = "middle-fill"></span>

<button mat-button mat-flat-button color = "primary" [disabled] = "!(toMerge && toMerge !== null) || completed" (click) = "submit()">Submit</button> &nbsp;
<button mat-button mat-flat-button color = "primary" mat-dialog-close>Cancel</button>
<button mat-button mat-flat-button color = "primary" mat-dialog-close (click) = "dialogRef.close()">Cancel</button>
</div>
<div *ngIf = "!success" style = "display:flex;width:100%">
<button mat-button mat-flat-button color = "primary" (click) ="restart()" >Restart</button>

<span class = "middle-fill"></span>

<button mat-button mat-flat-button color = "primary" mat-dialog-close>Close</button>
<button mat-button mat-flat-button color = "primary" mat-dialog-close (click) = "dialogRef.close()">Close</button>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
margin-top: 20px;
}

.experimental-action-label {
font-weight:500;
margin-left: 25px;
}

.spinner {
width: 100px !important;
height: 100px !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export class MergeActionDialogComponent implements OnInit {
) {
console.log(data);
if(data.recordId) {
console.log(data.recordId);

this.entity = data.recordId;
this.matches = data.matches;
Expand All @@ -47,7 +46,6 @@ export class MergeActionDialogComponent implements OnInit {
getMergeSchema() {
this.adminService.getMergeActionSchema().subscribe(response => {
this.mergeSchema = response;
console.log(response);
});
}

Expand Down Expand Up @@ -77,8 +75,9 @@ export class MergeActionDialogComponent implements OnInit {
refresh(id: string): void {
this.adminService.processingstatus(id).subscribe(response => {
if (response.results) {
this.success = response.completeSuccess;
response.results.forEach(result => {
this.success = result.success;


if(!this.success) {
let temp = result.message;
Expand Down
5 changes: 5 additions & 0 deletions src/app/core/config/config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export interface Config {
bulkSearch?: any
useDataUrl?: any;
userProfile?: any;
stagingArea?: StagingAreaSettings;
}

export interface StagingAreaSettings {
mergeAction?: boolean;
}

export interface LoadedComponents {
Expand Down
6 changes: 3 additions & 3 deletions src/app/core/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ <h2 class = "quick-links">Quick Links</h2>
<a mat-list-item routerLink="/browse-adverse-events">
<mat-icon matListIcon svgIcon="glasses"></mat-icon>
Browse Adverse Events
</a>Other
</span>Other
</a>
</span>
<div *ngIf="adverseEventShOtherinyHomepageDisplay === true">
<mat-divider></mat-divider>
<a mat-list-item [href]="adverseEventShinyHomepageURL" target="_blank">
Expand Down Expand Up @@ -364,7 +364,7 @@ <h3 class = "resource-link">
</div>
<div mat-dialog-actions>
<span class="middle-fill"></span>
<button class="mat-raised-button mat-primary" mat-dialog-close>Close</button>
<button class="mat-raised-button mat-primary" (click) = "dialogRef.close()" mat-dialog-close>Close</button>
</div>
</ng-template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<ng-container matColumnDef="comments">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Comments </th>
<td mat-cell *matCellDef="let code">
<button class = "mat-button mat-raised-button" color = "primary" (click)="openModal(commentTemplate)"
<button class = "mat-button mat-primary mat-raised-button" color = "primary" (click)="openModal(commentTemplate)"
[ngClass] = "(!code.comments && !code.codeText) ? 'mat-button-disabled':''"
[disabled] = "!code.comments && !code.codeText" >{{!code.comments && !code.codeText ? 'None' : 'View'}}</button>
<ng-template #commentTemplate>
Expand All @@ -108,7 +108,7 @@ <h2 mat-dialog-title>Code Comments</h2>
</div>
<div mat-dialog-actions>
<span class="middle-fill"></span>
<button class="mat-raised-button mat-primary" mat-dialog-close>Close</button>
<button class="mat-raised-button mat-primary" (click) = "close()" mat-dialog-close>Close</button>
</div>

</ng-template>
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/substance-form/substance-form.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

<div mat-dialog-actions>
<span class="middle-fill"></span>
<button class="mat-raised-button mat-primary" mat-dialog-close>Close</button>
<button class="mat-raised-button mat-primary" mat-dialog-close (click) = "dialogRef.close()">Close</button>
</div>
</ng-template>

Expand Down
4 changes: 4 additions & 0 deletions src/app/core/substance-form/substance-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,14 @@ export class SubstanceFormComponent implements OnInit, AfterViewInit, OnDestroy
this.status = response.status;
this.substanceFormService.loadSubstance(response.substanceClass, response).pipe(take(1)).subscribe(() => {
this.setFormSections(formSections[response.substanceClass]);
this.isLoading = false;
this.loadingService.setLoading(false);
});

}
}, error => {
this.isLoading = false;
this.loadingService.setLoading(false);
});
} else {
this.copy = this.activatedRoute.snapshot.queryParams['copy'] || null;
Expand Down
12 changes: 7 additions & 5 deletions src/app/core/substance-form/substance-form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1305,11 +1305,13 @@ export class SubstanceFormService implements OnDestroy {
for (let i = 0; i < substanceCopy.modifications.physicalModifications.length; i++) {
const prop = substanceCopy.modifications.physicalModifications[i];
let present = false;
prop.parameters.forEach(param => {
if (param.parameterName) {
present = true;
}
});
if (prop && prop.parameters){
prop.parameters.forEach(param => {
if (param.parameterName) {
present = true;
}
});
}

if (!prop.physicalModificationRole && !present) {
const invalidPropertyMessage: ValidationMessage = {
Expand Down
Loading

0 comments on commit 267128e

Please sign in to comment.