Commit 689bab58 authored by Rajkumar-D's avatar Rajkumar-D
Browse files

Dac policy changes

parent 8061d8a7
......@@ -63,6 +63,7 @@ import { UniqueNameByArrayDirective } from './directives/unique-name-by-array.di
import { NonSubmissionResultDialogComponent } from './non-submission-result-dialog/non-submission-result-dialog.component';
import { AceEditorModule } from 'ng2-ace-editor';
import { DacManagementComponent } from './dac-management/dac-management.component';
import { DacPolicyManagementComponent } from './dac-policy-management/dac-policy-management.component';
const appRoutes: Routes = [
......@@ -141,6 +142,14 @@ const appRoutes: Routes = [
path: 'dac',
component: DacManagementComponent,
},
{
path: 'dac/:id',
component: DacManagementComponent,
},
{
path: 'dac-policy',
component: DacPolicyManagementComponent,
},
{
path: '**',
component: DashboardComponent,
......@@ -201,6 +210,7 @@ const appRoutes: Routes = [
UniqueNameByArrayDirective,
NonSubmissionResultDialogComponent,
DacManagementComponent,
DacPolicyManagementComponent,
],
......
.body{
padding:10px 20px 10px 10px;
}
.container{
padding: 10px 0px 0px 0px;
}
.mat-row:nth-child(even){
background-color:#f8f8f8;
}
.mat-header-cell{
font-weight: bold;
font-size: 14px;
color: #000000c7;
}
mat-form-field {
width: 100%;
}
mat-card{
margin:10px;
}
mat-form-field.mat-form-field {
font-size: 14px;
font-family: Roboto;
}
mat-icon {
cursor: pointer;
}
\ No newline at end of file
<form (ngSubmit)="submitDacPolicy(f)" #f="ngForm">
<div class="body">
<div>
<div class="mat-h3 mat-tittle">Register Data access policy</div>
</div>
<mat-divider></mat-divider>
<div class="container">
<mat-card>
<mat-vertical-stepper #stepper>
<mat-step label="Select an existing DAC">
<app-report (selectedRecord)="getSelectedDac($event,stepper)" [reportType]="reportType"
[embDefaultSearch]="true" [embeded]="true"></app-report>
</mat-step>
<mat-step label="Submit policy">
</mat-step>
</mat-vertical-stepper>
</mat-card>
</div>
</div>
</form>
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DacPolicyManagementComponent } from './dac-policy-management.component';
describe('DacPolicyManagementComponent', () => {
let component: DacPolicyManagementComponent;
let fixture: ComponentFixture<DacPolicyManagementComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DacPolicyManagementComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DacPolicyManagementComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { MatStepper } from '@angular/material';
import { getEnabledCategories } from 'trace_events';
import { ReportType } from '../report-type.enum';
@Component({
selector: 'app-dac-policy-management',
templateUrl: './dac-policy-management.component.html',
styleUrls: ['./dac-policy-management.component.css']
})
export class DacPolicyManagementComponent implements OnInit {
constructor() { }
reportType = ReportType.dacs;
selectedDAC: string;
ngOnInit() {
}
getSelectedDac(studyAlias: object, stepper: MatStepper) {
this.selectedDAC = studyAlias["accession"];
stepper.next();
}
}
......@@ -36,12 +36,11 @@
<mat-icon class="note_add">add_box</mat-icon>
<p class="mat-small mat-caption">Register taxonomy</p>
</span>
<span *ngIf="isEga()" [routerLink]="['/dac']">
<mat-icon class="note_add">add_box</mat-icon>
<p class="mat-small mat-caption">Register data access committee</p>
</span>
<span *ngIf="isEga()" [routerLink]="['/taxonomy']">
<span *ngIf="isEga()" [routerLink]="['/dac-policy']">
<mat-icon class="note_add">add_box</mat-icon>
<p class="mat-small mat-caption">Register data access policy</p>
</span>
......
......@@ -28,12 +28,13 @@
</mat-expansion-panel-header>
<mat-vertical-stepper #stepper>
<!--<mat-step label="Please select a study">
<app-report (selectedStudyAlias)="getSelectedStudy($event,stepper)" [reportType]="reportType" [embDefaultSearch]="true" [embeded]="true"></app-report>
<div>
<button mat-button matStepperNext [disabled]="!this.selectedStudy">Next</button>
</div>
</mat-step> -->
<mat-step label="Please select a study">
<app-report (selectedRecord)="getSelectedStudy($event,stepper)" [reportType]="reportType"
[embDefaultSearch]="true" [embeded]="true"></app-report>
<div>
<button mat-button matStepperNext [disabled]="!this.selectedStudy">Next</button>
</div>
</mat-step>
<mat-step label="Please select a file format">
<div class="mat-elevation-z8">
<mat-accordion>
......@@ -117,7 +118,8 @@
</mat-panel-title>
</mat-expansion-panel-header>
<p>If you have downloaded and filled a Read submission template spreadsheet please upload it using the
<b>Submit Completed Spreadsheet button</b>.</p>
<b>Submit Completed Spreadsheet button</b>.
</p>
<form (ngSubmit)="uploadFile(form)" #form="ngForm">
<input type="file" required name="spreadSheet" [(ngModel)]="form.spreadSheet" observeFiles />
<button mat-raised-button color="accent" [disabled]="form.invalid ">Submit Completed
......
......@@ -38,8 +38,8 @@ export class ReadSubmissionComponent implements OnInit {
this.getReadFileDetails();
}
getSelectedStudy(studyAlias: string, stepper: MatStepper) {
this.selectedStudy = studyAlias;
getSelectedStudy(studyAlias: object, stepper: MatStepper) {
this.selectedStudy = studyAlias["alias"];
stepper.next();
}
......
......@@ -35,6 +35,7 @@
<div *ngIf="isEditXmlAction(ReportType.dacs)">
<button mat-menu-item (click)="editXmlAction(ReportType.dacs)"><i class="material-icons">mode_edit</i>Edit dac
XML</button>
<button mat-menu-item (click)="editDacAction(reportData)"><i class="material-icons">mode_edit</i>Edit dac</button>
</div>
<div *ngIf="isEditXmlAction(ReportType.policies)">
<button mat-menu-item (click)="editXmlAction(ReportType.policies)"><i class="material-icons">mode_edit</i>Edit
......
......@@ -69,4 +69,9 @@ export class ReportActionComponent {
console.log(projObj);
this.router.navigate(['/study', projObj.report.id]);
}
editDacAction(dacObj) {
console.log(dacObj);
this.router.navigate(['/dac', dacObj.report.id]);
}
}
<div class="body">
<div>
<div *ngIf="!embeded" class="mat-h3 mat-tittle">{{ ReportType.getPluralName(reportType) | titlecase }} Report</div>
<div *ngIf="!embeded" class="mat-h3 mat-tittle">{{ ReportType.getPluralName(reportType) | titlecase }} Report</div>
</div>
<mat-divider *ngIf="!embeded"></mat-divider>
<div class="container">
......@@ -50,7 +50,7 @@
<p class="mat-body-strong" *ngIf="!embeded">Please click search to see the results.</p>
<mat-card class="mat-body">
<mat-card-subtitle>Search {{ ReportType.getPluralName(reportType) | titlecase }}</mat-card-subtitle>
<mat-card-subtitle>Search {{ ReportType.getPluralName(reportType) | titlecase }}</mat-card-subtitle>
<div fxLayout="row wrap" fxLayoutAlign="start center">
......@@ -224,8 +224,8 @@
<ng-container *ngIf="col=='Select'">
<td cdk-cell *cdkCellDef="let element">
<span class=edit-icon-span *ngIf="!isEga() && embeded">
<mat-radio-button value="{{getElementValue(element, col)}}" (click)='selectStudy(element)'>
<span class=edit-icon-span *ngIf="embeded">
<mat-radio-button value="{{getElementValue(element, col)}}" (click)='selectRow(element)'>
</mat-radio-button>
</span>
</td>
......@@ -253,17 +253,20 @@
<td cdk-cell *cdkCellDef="let element">
<ng-container *ngIf="getElementValue(element, col)=='File archived'">
<span class="action-completed"
matTooltip="The file has been included in the permanent archive.">{{getElementValue(element, col)}}</span>
matTooltip="The file has been included in the permanent archive.">{{getElementValue(element,
col)}}</span>
</ng-container>
<ng-container
*ngIf="getElementValue(element, col)=='Processing file' || getElementValue(element, col)=='File submitted'">
<span class="action-active"
matTooltip="The file is waiting to be included in the permanent archive.">{{getElementValue(element, col)}}</span>
matTooltip="The file is waiting to be included in the permanent archive.">{{getElementValue(element,
col)}}</span>
</ng-container>
<ng-container
*ngIf="getElementValue(element, col)!='File archived' && getElementValue(element, col)!='Processing file' && getElementValue(element, col)!='File submitted'">
<span class="action-failed"
matTooltip="The file has failed to be included in the permanent archived.">{{getElementValue(element, col)}}</span>
matTooltip="The file has failed to be included in the permanent archived.">{{getElementValue(element,
col)}}</span>
</ng-container>
</td>
......@@ -276,16 +279,19 @@
<ng-container
*ngIf="getElementValue(element, col)=='COMPLETED' || getElementValue(element, col)=='CANCELLED'">
<span class="action-completed"
matTooltip="The post-archival processing of the file has finished.">{{getElementValue(element, col)}}</span>
matTooltip="The post-archival processing of the file has finished.">{{getElementValue(element,
col)}}</span>
</ng-container>
<ng-container *ngIf="getElementValue(element, col)=='FAILED'">
<span class="action-failed"
matTooltip="The post-archival processing of the file has failed.">{{getElementValue(element, col)}}</span>
matTooltip="The post-archival processing of the file has failed.">{{getElementValue(element,
col)}}</span>
</ng-container>
<ng-container
*ngIf="getElementValue(element, col)!='COMPLETED' && getElementValue(element, col)!='CANCELLED' && getElementValue(element, col)!='FAILED'">
<span class="action-active"
matTooltip="The post-archival processing of the file is ongoing.">{{getElementValue(element, col)}}</span>
matTooltip="The post-archival processing of the file is ongoing.">{{getElementValue(element,
col)}}</span>
</ng-container>
</td>
......
......@@ -43,7 +43,7 @@ export class ReportComponent implements OnInit {
@Input() embDefaultSearch: boolean;
@Input() embeded: boolean;
@Output() reportChange = new EventEmitter<ReportActionInterface>();
@Output() selectedStudyAlias = new EventEmitter<string>();
@Output() selectedRecord = new EventEmitter<string>();
@ViewChild(MatPaginator, { static: true }) dataPaginator: MatPaginator;
private _id: string;
......@@ -923,8 +923,8 @@ export class ReportComponent implements OnInit {
})
}
selectStudy(element) {
this.selectedStudyAlias.emit(element.report.alias);
selectRow(element) {
this.selectedRecord.emit(element.report);
}
......
......@@ -45,7 +45,11 @@
<div class="submenu" [ngClass]="{'expanded' : showSubmenu}">
<a mat-list-item [routerLink]="['/study']" (click)="snav.toggle()">Register study (project)</a>
<a mat-list-item [routerLink]="['/app-checklist','sample',true]" (click)="snav.toggle()">Register sample</a>
<a mat-list-item [routerLink]="['/taxonomy']" (click)="snav.toggle()">Register taxonomy</a>
<ng-container *ngIf="isEga()">
<a mat-list-item [routerLink]="['/dac']" (click)="snav.toggle()">Register data access committee</a>
<a mat-list-item [routerLink]="['/dac-policy']" (click)="snav.toggle()">Register data access policy</a>
<a mat-list-item [routerLink]="['/taxonomy']" (click)="snav.toggle()">Register taxonomy</a>
</ng-container>
</div>
<mat-list-item class="parent">
<mat-icon style="padding-right: 35px;">note_add</mat-icon>
......
......@@ -68,6 +68,11 @@ export class UtilService {
return this.httpClient.get(url, { responseType: 'text' })
}
getDacXml(dacId) {
var url = environment.webinReportServiceUrl + "/dacs/xml/" + dacId;
return this.httpClient.get(url, { responseType: 'text' })
}
downloadExcelTemplate(checklistJson) {
return this.httpClient.post(environment.webinXmlReportServiceUrl + '/tab/spreadsheet', checklistJson, { responseType: 'arraybuffer' });
}
......
......@@ -47,6 +47,23 @@ export class XmlService {
return observable;
}
generateDacXml(form, contactArray) {
let contactXml = this.getContactXmlTags(contactArray);
let alias = uuid();
let dacXml = new Blob(['<?xml version = "1.0" encoding = "UTF-8"?>' +
'<DAC_SET>' +
'<DAC alias="' + alias + '">' +
'<TITLE>' + form.title + '</TITLE>' +
contactXml +
'</DAC>' +
'</DAC_SET>'])
var action = { name: "add" };
//let dateStr = this.getFormatedReleseDate(new Date(form.releaseDate));
const observable: Observable<string> = this._webinRestService.updateXml(ReportType.dacs, dacXml, 'Add')
return observable;
}
getPubMedXmlTags(selectedPubMedArray) {
......@@ -86,6 +103,18 @@ export class XmlService {
return locusTagXml;
}
getContactXmlTags(contactArray) {
let contactXml = "<CONTACTS>";
contactArray.forEach(element => {
//contactXml += '<CONTACT name="' + element.name + '" email="' + element.emailAddress + '" organisation="' + element.organization + '" telephone="' + element.telephone + '"/>';
contactXml += '<CONTACT name="' + element.name + '" email="' + element.emailAddress + '" organisation="' + element.organization + '"/>';
});
contactXml += "</CONTACTS>"
return contactXml;
}
updateProjectXml(orginalXml, form, pubMedArray, attributeArray, locusTagArray) {
var pubMedXmlStr = this.getPubMedXmlTags(pubMedArray);
var attributeXmlStr = this.getAttributeXmlTags(attributeArray);
......@@ -131,6 +160,32 @@ export class XmlService {
return observable;
}
updateDacXml(orginalXml, form, contactArray) {
var contactXmlStr = this.getContactXmlTags(contactArray);
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(orginalXml, "text/xml");
var contactXml = parser.parseFromString(contactXmlStr, "text/xml");
var titleTag = xmlDoc.getElementsByTagName("TITLE")[0];
/** Check if the tag is empty and set the values accordingly */
if (titleTag) {
titleTag.hasChildNodes() ? titleTag.childNodes[0].nodeValue = form.title : titleTag.appendChild(xmlDoc.createTextNode(form.title));
}
/** Update project attributes */
this.updateDacContacts(xmlDoc, contactXml);
var xmlDocStr = new XMLSerializer().serializeToString(xmlDoc.documentElement);
//console.log(xmlDocStr);
let dateStr = this.getFormatedReleseDate(new Date(form.releaseDate))
var action = { name: "Edit", id: form.id };
const observable: Observable<string> = this._webinRestService.updateXml(ReportType.dacs, new Blob([xmlDocStr]), action, dateStr)
return observable;
}
updateProjectReleaseDate(orginalXml, form) {
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(orginalXml, "text/xml");
......@@ -176,6 +231,12 @@ export class XmlService {
}
}
updateDacContacts(xmlDoc, contactsXml) {
if (xmlDoc.getElementsByTagName("CONTACTS")[0]) {
xmlDoc.getElementsByTagName("CONTACTS")[0].replaceWith(contactsXml.getElementsByTagName("CONTACTS")[0]);
}
}
updateProjectLocasTags(xmlDoc, locusTagXml) {
var oldlocusTagPrefixLength = xmlDoc.getElementsByTagName("LOCUS_TAG_PREFIX").length;
......
......@@ -13,7 +13,7 @@ import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { environment } from '../environments/environment';
import { Observable } from 'rxjs';
import { tap, startWith, map,debounceTime, catchError } from 'rxjs/operators';
import { tap, startWith, map, debounceTime, catchError } from 'rxjs/operators';
import { ReportType } from './report-type.enum';
......@@ -29,7 +29,7 @@ export class WebinRestService implements WebinRestServiceInterface {
private _xmlParser = new DOMParser();
constructor(private _http: HttpClient,
private _webinAuthenticationService:WebinAuthenticationService) { }
private _webinAuthenticationService: WebinAuthenticationService) { }
private headers() {
return new HttpHeaders();
......@@ -52,105 +52,108 @@ export class WebinRestService implements WebinRestServiceInterface {
private postTaxon(formData: FormData): Observable<string> {
const headers = this.headers();
return this._http.post(environment.webinXmlReportServiceUrl+"/portal/register/taxonomy", formData, { headers, responseType: 'text' });
return this._http.post(environment.webinXmlReportServiceUrl + "/portal/register/taxonomy", formData, { headers, responseType: 'text' });
}
private postEmail(mail) {
return this._http.post(environment.webinXmlReportServiceUrl+'/email',mail);
return this._http.post(environment.webinXmlReportServiceUrl + '/email', mail);
}
submitProjectXml(formData){
submitProjectXml(formData) {
const headers = this.headers();
return this._http.post(this._baseUrl, formData, { headers, responseType: 'text' }).
pipe(
map((data: any) => {
return data;
})
map((data: any) => {
return data;
})
)
}
updateXml(
reportType: ReportType,
xml: Blob,
action: Object,
releaseDate: any): Observable<string> {
console.log('** Update XML **');
const formData: FormData = new FormData();
var mode=action["name"];
var releaseDateStr=this.getReleaseDateStr(action,mode,releaseDate)
var actionString=this.getActionStr(action,mode);
let submissionXml: Blob = new Blob([
'<SUBMISSION_SET>' +
' <SUBMISSION>' +
' <ACTIONS>' +
actionString +
releaseDateStr +
' </ACTIONS>' +
' </SUBMISSION>' +
'</SUBMISSION_SET>']);
if(this._webinAuthenticationService.ega) {
submissionXml=new Blob([
'<SUBMISSION_SET>' +
' <SUBMISSION broker_name="EGA">' +
' <ACTIONS>' +
actionString +
' <ACTION>' +
' <PROTECT/>' +
' </ACTION>' +
releaseDateStr +
' </ACTIONS>' +
' </SUBMISSION>' +
'</SUBMISSION_SET>']);
releaseDate?: any): Observable<string> {
console.log('** Update XML **');
const formData: FormData = new FormData();
var mode = action["name"];
var releaseDateStr = this.getReleaseDateStr(action, mode, releaseDate)
var actionString = this.getActionStr(action, mode);
var submissionAttr = this.getSubmissionAttrStr();
let submissionXml: Blob = new Blob([
'<SUBMISSION_SET>' +
' <SUBMISSION>' +
' <ACTIONS>' +
actionString +
releaseDateStr +
' </ACTIONS>' +
submissionAttr +
' </SUBMISSION>' +
'</SUBMISSION_SET>']);
if (this._webinAuthenticationService.ega) {
submissionXml = new Blob([
'<SUBMISSION_SET>' +
' <SUBMISSION broker_name="EGA">' +
' <ACTIONS>' +
actionString +
' <ACTION>' +
' <PROTECT/>' +
' </ACTION>' +
releaseDateStr +
' </ACTIONS>' +
submissionAttr +
' </SUBMISSION>' +
'</SUBMISSION_SET>']);
}
this.appendXml(formData, 'SUBMISSION', submissionXml);
this.appendXml(formData, 'SUBMISSION', submissionXml);
switch (reportType) {
case ReportType.studies: {
this.appendXml(formData, 'STUDY', xml);
break;
}
case ReportType.projects: {
this.appendXml(formData, 'PROJECT', xml);
break;
}
case ReportType.samples: {
this.appendXml(formData, 'SAMPLE', xml);
break;
}
case ReportType.experiments: {
this.appendXml(formData, 'EXPERIMENT', xml);
break;
}
case ReportType.runs: {
this.appendXml(formData, 'RUN', xml);
break;
}
case ReportType.analyses: {
this.appendXml(formData, 'ANALYSIS', xml);
break;
}
case ReportType.dacs: {
this.appendXml(formData, 'DAC', xml);
break;
}
case ReportType.policies: {
this.appendXml(formData, 'POLICY', xml);
break;
}
case ReportType.datasets: {
this.appendXml(formData, 'DATASET', xml);
break;
}
switch (reportType) {
case ReportType.studies: {
this.appendXml(formData, 'STUDY', xml);
break;
}
case ReportType.projects: {
this.appendXml(formData, 'PROJECT', xml);
break;
}
case ReportType.samples: {