Commit 61232465 authored by rajkumar's avatar rajkumar
Browse files

New Webin Portal changes :

1) Remove the async methods that was used before
2) Updating Study Management screens
3) Updating Webin-rest to handle xml editing from screen
parent b851acde
......@@ -161,54 +161,53 @@ updateEmailsArray(){
}
}
async submitAccount(form){
var submissionAccount=form.value;
submissionAccount["submissionContacts"]=this.contactArray;
this.deleteServerContacts();
this.saveNewContacts();
(await this.util.saveSubmissionAccount(submissionAccount,this.editMode)).
subscribe((data:any) => {
this.deletedContacts=[];
this.openDialog('Success',data);
},(error) => {
this.openDialog('Error',error);
});
submitAccount(form){
var submissionAccount=form.value;
submissionAccount["submissionContacts"]=this.contactArray;
this.deleteServerContacts();
this.saveNewContacts();
this.util.saveSubmissionAccount(submissionAccount,this.editMode).
subscribe((data:any) => {
this.deletedContacts=[];
this.openDialog('Success',data);
},(error) => {
this.openDialog('Error',error);
});
}
async getCountries(prefix){
(await this.util.getCountries(prefix)).
subscribe((data:any) => {
this.countries=data;
});
getCountries(prefix){
this.util.getCountries(prefix).
subscribe((data:any) => {
this.countries=data;
});
}
async loadUserInfo(username){
(await this.util.getAccountDetails()).
subscribe((data:any) => {
this.setAccountInformation(data);
});
loadUserInfo(username){
this.util.getAccountDetails().
subscribe((data:any) => {
this.setAccountInformation(data);
});
}
async saveNewContacts(){
saveNewContacts(){
for (const contact of this.newContacts) {
(await this.util.saveNewContact(contact)).
subscribe((data:any) => {
if(data){
console.log("Created "+contact.emailAddress)
}
});
this.util.saveNewContact(contact).
subscribe((data:any) => {
if(data){
console.log("Created "+contact.emailAddress)
}
});
};
}
async deleteServerContacts(){
deleteServerContacts(){
for (const contact of this.deletedContacts) {
(await this.util.deleteContact(contact)).
subscribe((data:any) => {
if(data){
console.log("Deleted "+contact.emailAddress)
}
});
this.util.deleteContact(contact).
subscribe((data:any) => {
if(data){
console.log("Deleted "+contact.emailAddress)
}
});
};
}
......
......@@ -128,8 +128,9 @@ export class ReportEditDialogComponent implements OnInit {
}
save() {
var action={name:"Edit"};
const observable: Observable<string> = this._webinRestService.updateXml(
this.data.reportType, new Blob([ this.xml ]),'Edit',null);
this.data.reportType, new Blob([ this.xml ]),action,null);
this.submissionResult.submit(observable);
}
......
......@@ -36,14 +36,13 @@ export class ResetPasswordPageComponent implements OnInit {
ngOnInit() {
}
async resetPassword(form){
(await this.util.resetPassword(form.value,this.token)).
subscribe((data:any) => {
this.openDialog('Reset-Password-Success',data);
},(error) => {
this.openDialog('Reset-Password-Error',error);
});
resetPassword(form){
(this.util.resetPassword(form.value,this.token)).
subscribe((data:any) => {
this.openDialog('Reset-Password-Success',data);
},(error) => {
this.openDialog('Reset-Password-Error',error);
});
}
openDialog(action,obj): void {
......
......@@ -32,16 +32,16 @@ export class ResetPasswordRequestDialogComponent implements OnInit {
ngOnInit() {
}
async doAction(form){
doAction(form){
var resetPassReq=form.value;
(await this.util.sendResetPasswordRequest(resetPassReq)).
subscribe((data:any) => {
this.closePopup();
data={"emailAddress": resetPassReq.emailAddress}
this.openDialog('Success',data);
},(error) => {
this.openDialog('Error',error);
});
this.util.sendResetPasswordRequest(resetPassReq).
subscribe((data:any) => {
this.closePopup();
data={"emailAddress": resetPassReq.emailAddress}
this.openDialog('Success',data);
},(error) => {
this.openDialog('Error',error);
});
}
openDialog(action,obj): void {
......
......@@ -10,6 +10,10 @@
float: left;
width: 50%;
}
.column3{
float: left;
width: 33.3%;
}
mat-form-field {
width: 100%;
......@@ -41,7 +45,11 @@ mat-icon{
}
.centred{
position: fixed; /* or absolute */
top: 50%;
left: 50%;
}
.back-div{
......
......@@ -36,11 +36,11 @@
</div>
</mat-card>
<!-- #################### P U B M E D R E G I S T R A T I O N #################### -->
<mat-card class="mat-body">
<mat-card-subtitle>PubMed Registration</mat-card-subtitle>
<a (click)="addPubMed()">Add PubMed <mat-icon>add_circle</mat-icon></a>
<div *ngIf="showPubMedSearch">
<div *ngIf="showPubMedSearch" >
<mat-form-field class="app-field-padding">
<input matInput placeholder="Search PubMedId" [matAutocomplete]="auto" name="pubMedSearch" #pubMedSearchVal="ngModel" [(ngModel)]="pubMedSearch" (ngModelChange)="getPubMed(pubMedSearch)">
</mat-form-field>
......@@ -62,7 +62,6 @@
<td mat-cell *matCellDef="let element"> {{element.title}} </td>
</ng-container>
<ng-container matColumnDef="remove">
<th mat-header-cell *matHeaderCellDef> Remove </th>
<td mat-cell *matCellDef="let element">
......@@ -70,22 +69,106 @@
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-error *ngIf="mainContact <= 0 ">
Please enter atlease one primary contact to save the account.
</mat-error>
</mat-card>
<!-- #################### A T T R I B U T E R G I S T R A T I O N #################### -->
<mat-card class="mat-body">
<mat-card-subtitle>Project Attributes</mat-card-subtitle>
<a (click)="showAttributeAddPanel()">Add Attribute <mat-icon>add_circle</mat-icon></a>
<div *ngIf="showAttributeAdd">
<div class="row">
<div class="column3">
<mat-form-field class="app-field-padding">
<input matInput placeholder="Tag" name="tag" [(ngModel)]="tag" required>
</mat-form-field>
</div>
<div class="column3">
<mat-form-field class="app-field-padding">
<input matInput placeholder="Value" name="tagValue" [(ngModel)]="tagValue" required>
</mat-form-field>
</div>
<div class="column3">
<button mat-raised-button color="primary" [disabled]="!tag || !tagValue" (click)="addAttribute()">Add</button>
</div>
</div>
</div>
<table mat-table *ngIf="attributeDataSource" #table [dataSource]="attributeDataSource" class="mat-elevation-z8">
<ng-container matColumnDef="tag">
<th mat-header-cell *matHeaderCellDef> Tag </th>
<td mat-cell *matCellDef="let element"> {{element.tag}} </td>
</ng-container>
<ng-container matColumnDef="tagValue">
<th mat-header-cell *matHeaderCellDef> Value </th>
<td mat-cell *matCellDef="let element"> {{element.tagValue}} </td>
</ng-container>
<ng-container matColumnDef="remove">
<th mat-header-cell *matHeaderCellDef> Remove </th>
<td mat-cell *matCellDef="let element">
<mat-icon (click)="removeAttribute(element)">delete</mat-icon>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="attributeDisplayColumn"></tr>
<tr mat-row *matRowDef="let row; columns: attributeDisplayColumn;"></tr>
</table>
</mat-card>
<!-- #################### L O C U S - T A G R G I S T R A T I O N #################### -->
<mat-card class="mat-body" >
<mat-card-subtitle>Locus Tag Registration</mat-card-subtitle>
<a (click)="showLocusTagAddPanel()">Add Locus Tag <mat-icon>add_circle</mat-icon></a>
<div *ngIf="showLocusTagAdd">
<div class="row">
<div class="column">
<mat-form-field class="app-field-padding">
<input matInput placeholder="Locus Tag" name="locustag" [(ngModel)]="locustag" required>
</mat-form-field>
</div>
<div class="column">
<button mat-raised-button color="primary" [disabled]="!locustag" (click)="addlocusTag()">Add</button>
</div>
</div>
</div>
<table mat-table *ngIf="locusTagDataSource" #table [dataSource]="locusTagDataSource" class="mat-elevation-z8">
<ng-container matColumnDef="locusTag">
<th mat-header-cell *matHeaderCellDef> Locus Tag </th>
<td mat-cell *matCellDef="let element"> {{element.locusTag}} </td>
</ng-container>
<ng-container matColumnDef="remove">
<th mat-header-cell *matHeaderCellDef> Remove </th>
<td mat-cell *matCellDef="let element">
<mat-icon (click)="removeLocusTag(element)">delete</mat-icon>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="locusTagDisplayColumn"></tr>
<tr mat-row *matRowDef="let row; columns: locusTagDisplayColumn;"></tr>
</table>
</mat-card>
</div>
<div class="centred" *ngIf="showLoadingFlag" style="height:70px;">
<mat-spinner [diameter]="50" [strokeWidth]="5" style="margin:0 auto;">
</mat-spinner>
</div>
<div style="text-align:Center">
<button mat-raised-button color="accent" [disabled]="f.invalid || mainContact <= 0">Save</button>
<button mat-raised-button style="margin-left: 5px;" routerLink="">Cancel</button>
<button mat-raised-button style="margin-left: 5px;" routerLink="/report/studies">Cancel</button>
</div>
</form>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { StudyManagementComponent } from './study-management.component';
import { MatInputModule,MatFormFieldModule , MatIconModule, MatDividerModule,MatCardSubtitle, MatFormField,MatLabel,MatDatepickerModule, MatCardModule,MatAutocompleteModule, MatTableModule, MatError } from '@angular/material'
import { MatInputModule,MatFormFieldModule , MatIconModule, MatDividerModule,MatCardSubtitle, MatFormField,MatLabel,MatDatepickerModule, MatCardModule,MatAutocompleteModule, MatTableModule, MatError, MatProgressSpinnerModule } from '@angular/material'
import {FormControl, FormGroupDirective, NgForm, Validators, FormGroup, FormBuilder, FormsModule} from '@angular/forms';
import { CanActivate, Router, ActivatedRouteSnapshot, RouterStateSnapshot, ActivatedRoute } from '@angular/router';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
......@@ -22,7 +22,7 @@ describe('StudyManagementComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [BrowserAnimationsModule, MatInputModule,MatFormFieldModule , HttpClientModule ,ObserversModule, FormsModule, MatIconModule, MatDividerModule,MatDatepickerModule, MatCardModule, MatAutocompleteModule ,MatTableModule],
imports: [BrowserAnimationsModule, MatInputModule,MatFormFieldModule , HttpClientModule ,ObserversModule, FormsModule, MatIconModule, MatDividerModule,MatDatepickerModule, MatCardModule, MatAutocompleteModule ,MatTableModule, MatProgressSpinnerModule],
declarations: [ StudyManagementComponent ],
providers:[WebinAuthenticationService,WebinRestService,
{provide: ActivatedRoute, useValue: fakeActivatedRoute},]
......
......@@ -45,17 +45,30 @@ export class StudyManagementComponent implements OnInit {
description:string;
releaseStatus: string;
xmlString: string;
tag: string;
tagValue: string;
locustag: string;
pubMedArray: [];
attributeArray= [];
locusTagArray=[];
selectedPubMedArray= [];
dataSource: MatTableDataSource<any>;
displayedColumns: string[] = ['id', 'title','remove'];
attributeDataSource: MatTableDataSource<any>;
attributeDisplayColumn: string[] = ['tag','tagValue','remove']
locusTagDataSource: MatTableDataSource<any>;
locusTagDisplayColumn: string[] = ['locusTag','remove']
showPubMedSearch = false;
showAttributeAdd = false;
showLocusTagAdd = false;
pubMedSearch="";
today=new Date();
maxDate: any;
id: any;
action: string;
showLoadingFlag=false;
constructor(private util: UtilService,private xmlUtil: XmlService,private activatedRoute: ActivatedRoute,) {
var date=new Date();
......@@ -72,15 +85,17 @@ export class StudyManagementComponent implements OnInit {
}
async getPubMed(searchVal){
(await this.util.getPubMed(searchVal)).
getPubMed(searchVal){
this.showLoading();
this.util.getPubMed(searchVal).
subscribe((data:any) => {
this.pubMedArray=data.resultList.result;
this.hideLoading();
});
}
async showExistingPubMed(id){
(await this.util.getPubMedById(id)).
showExistingPubMed(id){
(this.util.getPubMedById(id)).
subscribe((data:any) => {
if(data.resultList.result.length>0){
this.selectedPubMedArray.push(data.resultList.result[0]);
......@@ -108,6 +123,14 @@ export class StudyManagementComponent implements OnInit {
this.showPubMedSearch=true;
}
showAttributeAddPanel(){
this.showAttributeAdd=true;
}
showLocusTagAddPanel(){
this.showLocusTagAdd=true;
}
removePubMed(pubMedObj){
var index = this.selectedPubMedArray.map(function(item) { return item.id; }).indexOf(pubMedObj.id);
this.selectedPubMedArray.splice(index, 1);
......@@ -115,23 +138,29 @@ export class StudyManagementComponent implements OnInit {
}
submitStudy(form){
this.showLoading()
if(this.action!="Edit"){
this.xmlUtil.generateStudyXml(form.value,this.selectedPubMedArray);
this.xmlUtil.generateStudyXml(form.value,this.selectedPubMedArray,this.attributeArray,this.locusTagArray);
}else{
this.xmlUtil.updateProjectXml(this.xmlString,form.value,this.selectedPubMedArray);
this.xmlUtil.updateProjectXml(this.xmlString,form.value,this.selectedPubMedArray,this.attributeArray,this.locusTagArray);
}
this.hideLoading()
}
async initEdit(id){
(await this.util.getProjectDetails(id)).
initEdit(id){
this.showLoading();
this.util.getProjectDetails(id).
subscribe((data:any) => {
this.setPageValuesfromReport(data[0].report);
});
(await this.util.getProjectXml(id)).
this.util.getProjectXml(id).
subscribe((xmlString:any) => {
this.xmlString=xmlString;
this.setPageValuesfromXml();
this.hideLoading();
});
}
......@@ -151,11 +180,13 @@ export class StudyManagementComponent implements OnInit {
this.description=descriptionTag.hasChildNodes() ? descriptionTag.childNodes[0].nodeValue : "";
this.setPubMedDetails(xmlDoc);
this.setAttributeDetails(xmlDoc);
this.setLocusTagDetails(xmlDoc);
}
setPubMedDetails(xmlDoc){
var projectLinks=xmlDoc.getElementsByTagName("PROJECT_LINKS").childNodes;
projectLinks = xmlDoc.getElementsByTagName("PROJECT_LINKS")[0];
var projectLinks = xmlDoc.getElementsByTagName("PROJECT_LINKS")[0];
if(projectLinks){
var xRefLink=projectLinks.getElementsByTagName("XREF_LINK");
length=xRefLink.length
......@@ -168,6 +199,65 @@ export class StudyManagementComponent implements OnInit {
}
}
}
setAttributeDetails(xmlDoc){
var projectAttributes=xmlDoc.getElementsByTagName("PROJECT_ATTRIBUTE");
var projAttrLen=projectAttributes.length;
for(var i=0;i<projAttrLen;i++){
var tag=projectAttributes[i].getElementsByTagName("TAG")[0].childNodes[0].nodeValue;
var tagValue=projectAttributes[i].getElementsByTagName("VALUE")[0].childNodes[0].nodeValue;
this.attributeArray.push({id:this.util.getId(),tag:tag,tagValue:tagValue});
}
if(this.attributeArray.length>0){
this.attributeDataSource = new MatTableDataSource<any>(this.attributeArray);
}
}
setLocusTagDetails(xmlDoc){
var locusTagPrefix=xmlDoc.getElementsByTagName("LOCUS_TAG_PREFIX");
var locusTagPrefixLen=locusTagPrefix.length;
for(var i=0;i<locusTagPrefixLen;i++){
var locusTag=locusTagPrefix[i].childNodes[0].nodeValue;
this.locusTagArray.push({id:this.util.getId(),locusTag:locusTag});
}
if(this.locusTagArray.length>0){
this.locusTagDataSource = new MatTableDataSource<any>(this.locusTagArray);
}
}
addAttribute(){
this.attributeArray.push({id:this.util.getId(),tag:this.tag,tagValue:this.tagValue});
this.attributeDataSource = new MatTableDataSource<any>(this.attributeArray);
this.tag="";
this.tagValue="";
this.showAttributeAdd=false;
}
addlocusTag(){
this.locusTagArray.push({id:this.util.getId,locusTag:this.locustag});
this.locusTagDataSource = new MatTableDataSource<any>(this.locusTagArray);
this.locustag="";
this.showLocusTagAdd=false;
}
removeAttribute(attr){
var index = this.attributeArray.map(function(item) { return item.id; }).indexOf(attr.id);
this.attributeArray.splice(index, 1);
this.attributeDataSource = new MatTableDataSource<any>(this.attributeArray);
}
removeLocusTag(element){
var index = this.attributeArray.map(function(item) { return item.id; }).indexOf(element.id);
this.locusTagArray.splice(index, 1);
this.locusTagDataSource = new MatTableDataSource<any>(this.locusTagArray);
}
showLoading(){
this.showLoadingFlag=true;
}
hideLoading(){
this.showLoadingFlag=false;
}
}
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { environment } from '../../environments/environment';
import { tap, startWith, map,debounceTime, catchError } from 'rxjs/operators';
import { throwError } from 'rxjs';
import { throwError, Observable } from 'rxjs';
import { HttpHeaders } from '../../../node_modules/@angular/common/http';
......@@ -13,103 +13,55 @@ import { HttpHeaders } from '../../../node_modules/@angular/common/http';
export class UtilService {
constructor(private httpClient: HttpClient) { }
async getCountries(prefix) {
getCountries(prefix) {
var url=environment.webinAdminServiceUrl+"/country" +"?partialCountry="+prefix;
return this.httpClient.get<string[]>(url,{responseType: 'json' }).pipe(map((data:any) => {
return data;
}));
return this.httpClient.get<string[]>(url,{responseType: 'json' });
}
async saveSubmissionAccount(payload,editMode){
saveSubmissionAccount(payload,editMode){
if(editMode){
return this.httpClient.put(environment.webinAdminServiceUrl+'/'+'submission-account', payload).
pipe(
map((data: Response) => {
return data;
})
)
return this.httpClient.put(environment.webinAdminServiceUrl+'/'+'submission-account', payload);
}else{
return this.httpClient.post(environment.webinAdminServiceUrl+'/'+'submission-account', payload).
pipe(
map((data: Response) => {
return data;
})
)
return this.httpClient.post(environment.webinAdminServiceUrl+'/'+'submission-account', payload);
}
}
async getAccountDetails(){
return this.httpClient.get(environment.webinAdminServiceUrl+'/'+'submission-account').
pipe(
map((data: Response) => {
return data;
})
)
getAccountDetails(){
return this.httpClient.get(environment.webinAdminServiceUrl+'/'+'submission-account');
}
async deleteContact(contact){
return this.httpClient.delete(environment.webinAdminServiceUrl+'/'+'submission-contact/' + contact["emailAddress"]).