Commit 61b5ffbb authored by Rajkumar-D's avatar Rajkumar-D
Browse files

Add umbrella project changes

parent 3ace54fa
......@@ -65,6 +65,7 @@ import { AceEditorModule } from 'ng2-ace-editor';
import { DacManagementComponent } from './dac-management/dac-management.component';
import { DacPolicyManagementComponent } from './dac-policy-management/dac-policy-management.component';
import { DacDatasetManagementComponent } from './dac-dataset-management/dac-dataset-management.component';
import { UmbrellaManagementComponent } from './umbrella-management/umbrella-management.component';
const appRoutes: Routes = [
......@@ -134,6 +135,16 @@ const appRoutes: Routes = [
component: StudyManagementComponent,
canActivate: [WebinAuthenticationGuardService],
},
{
path: 'umbrella',
component: UmbrellaManagementComponent,
canActivate: [WebinAuthenticationGuardService],
},
{
path: 'umbrella/:id',
component: UmbrellaManagementComponent,
canActivate: [WebinAuthenticationGuardService],
},
{
path: 'read-submission',
component: ReadSubmissionComponent,
......@@ -236,6 +247,7 @@ const appRoutes: Routes = [
DacManagementComponent,
DacPolicyManagementComponent,
DacDatasetManagementComponent,
UmbrellaManagementComponent,
],
......
......@@ -28,6 +28,10 @@
<mat-icon class=note_add>add_box</mat-icon>
<p class="mat-small mat-caption">Register study (project)</p>
</span>
<span *ngIf="isSuperUser()" [routerLink]="['/umbrella']">
<mat-icon class=note_add>add_box</mat-icon>
<p class="mat-small mat-caption">Register umbrella project</p>
</span>
<span [routerLink]="['/app-checklist','sample',true]">
<mat-icon class="note_add">add_box</mat-icon>
<p class="mat-small mat-caption">Register samples</p>
......@@ -102,6 +106,11 @@
<p class="mat-small mat-caption">Studies Report</p>
</span>
<span *ngIf="isSuperUser()" [routerLink]="['/report',ReportType.umbrellaProjects,{defaultSearch: true}]">
<mat-icon class=insert_chart>insert_chart</mat-icon>
<p class="mat-small mat-caption">Umbrella Project Report</p>
</span>
<span [routerLink]="['/report',ReportType.samples,{defaultSearch: true}]">
<mat-icon class=insert_chart>insert_chart</mat-icon>
<p class="mat-small mat-caption">Samples Report</p>
......
......@@ -42,4 +42,8 @@ export class DashboardComponent implements OnInit {
isEga(): boolean {
return this._webinAuthenticationService.ega;
}
isSuperUser(): boolean {
return this._webinAuthenticationService.superUser;
}
}
......@@ -58,6 +58,7 @@ export class LoginComponent implements OnInit {
mergeMap(data => {
// console.log('WebinAuthenticationService.login succeeded');
this._webinAuthenticationService.ega = data.roles.EGA;
this._webinAuthenticationService.superUser = data.roles.SUPER_USER;
this._webinAuthenticationService.account = data.principle;
return this._webinAuthenticationService.loginToken(this.username, this.password);
})
......
......@@ -12,6 +12,12 @@
<button mat-menu-item (click)="editProjectAction(reportData)"><i class="material-icons">mode_edit</i>Edit study
(project)</button>
</div>
<div *ngIf="isEditXmlAction(ReportType.umbrellaProjects)">
<button mat-menu-item (click)="editXmlAction(ReportType.umbrellaProjects)"><i
class="material-icons">mode_edit</i>Edit umbrella project XML</button>
<button mat-menu-item (click)="editUmbrellaProjectAction(reportData)"><i class="material-icons">mode_edit</i>Edit
umbrella project</button>
</div>
<div *ngIf="isEditXmlAction(ReportType.studies)">
<button mat-menu-item (click)="editXmlAction(ReportType.studies)"><i class="material-icons">mode_edit</i>Edit study
XML</button>
......
......@@ -70,6 +70,11 @@ export class ReportActionComponent {
this.router.navigate(['/study', projObj.report.id]);
}
editUmbrellaProjectAction(umbrellaProjObj) {
console.log(umbrellaProjObj);
this.router.navigate(['/umbrella', umbrellaProjObj.report.id]);
}
editDacAction(dacObj) {
console.log(dacObj);
this.router.navigate(['/dac', dacObj.report.id]);
......
......@@ -78,6 +78,10 @@ export class ReportEditDialogComponent implements OnInit {
observable = this._webinXmlReportService.getProjectXml(id);
break;
}
case ReportType.umbrellaProjects: {
observable = this._webinXmlReportService.getProjectXml(id);
break;
}
case ReportType.samples: {
observable = this._webinXmlReportService.getSampleXml(id);
break;
......
......@@ -23,109 +23,116 @@ export enum ReportType {
unsubmittedFiles = 'unsubmittedFiles',
dacs = 'dacs',
policies = 'policies',
datasets = 'datasets'
datasets = 'datasets',
umbrellaProjects = 'umbrellaProjects'
}
export namespace ReportType {
export function getCapitalisedSingularName(reportType: ReportType): string {
switch (reportType) {
case ReportType.studies: {
return 'Study';
}
case ReportType.projects: {
return 'Project';
}
case ReportType.samples: {
return 'Sample';
}
case ReportType.experiments: {
return 'Experiment';
}
case ReportType.runs: {
return 'Run';
}
case ReportType.analyses: {
return 'Analysis';
}
case ReportType.runFiles: {
return 'Submitted files for run';
}
case ReportType.analysisFiles: {
return 'Submitted files for analysis';
}
case ReportType.runProcess: {
return 'Run processing status';
}
case ReportType.analysisProcess: {
return 'Analysis processing status';
}
case ReportType.unsubmittedFiles: {
return 'Unsubmitted files';
}
case ReportType.dacs: {
return 'Dac';
}
case ReportType.policies: {
return 'Policy';
}
case ReportType.datasets: {
return 'Dataset';
}
default: {
return '';
}
case ReportType.studies: {
return 'Study';
}
case ReportType.projects: {
return 'Project';
}
case ReportType.samples: {
return 'Sample';
}
case ReportType.experiments: {
return 'Experiment';
}
case ReportType.runs: {
return 'Run';
}
case ReportType.analyses: {
return 'Analysis';
}
case ReportType.runFiles: {
return 'Submitted files for run';
}
case ReportType.analysisFiles: {
return 'Submitted files for analysis';
}
case ReportType.runProcess: {
return 'Run processing status';
}
case ReportType.analysisProcess: {
return 'Analysis processing status';
}
case ReportType.unsubmittedFiles: {
return 'Unsubmitted files';
}
case ReportType.dacs: {
return 'Dac';
}
case ReportType.policies: {
return 'Policy';
}
case ReportType.datasets: {
return 'Dataset';
}
case ReportType.umbrellaProjects: {
return 'Umbrella projects';
}
default: {
return '';
}
}
}
export function getPluralName(reportType: ReportType): string {
switch (reportType) {
case ReportType.studies: {
return 'studies';
}
case ReportType.projects: {
return 'projects';
}
case ReportType.samples: {
return 'samples';
}
case ReportType.experiments: {
return 'experiments';
}
case ReportType.runs: {
return 'runs';
}
case ReportType.analyses: {
return 'analyses';
}
case ReportType.runFiles: {
return 'run files';
}
case ReportType.analysisFiles: {
return 'analyses files';
}
case ReportType.runProcess: {
return 'processing status of archived run files';
}
case ReportType.analysisProcess: {
return 'processing status of archived analysis files';
}
case ReportType.unsubmittedFiles: {
return 'unsubmitted files';
}
case ReportType.dacs: {
return 'dacs';
}
case ReportType.policies: {
return 'policies';
}
case ReportType.datasets: {
return 'datasets';
}
default: {
return '';
}
case ReportType.studies: {
return 'studies';
}
case ReportType.projects: {
return 'projects';
}
case ReportType.samples: {
return 'samples';
}
case ReportType.experiments: {
return 'experiments';
}
case ReportType.runs: {
return 'runs';
}
case ReportType.analyses: {
return 'analyses';
}
case ReportType.runFiles: {
return 'run files';
}
case ReportType.analysisFiles: {
return 'analyses files';
}
case ReportType.runProcess: {
return 'processing status of archived run files';
}
case ReportType.analysisProcess: {
return 'processing status of archived analysis files';
}
case ReportType.unsubmittedFiles: {
return 'unsubmitted files';
}
case ReportType.dacs: {
return 'dacs';
}
case ReportType.policies: {
return 'policies';
}
case ReportType.datasets: {
return 'datasets';
}
case ReportType.umbrellaProjects: {
return 'Umbrella projects';
}
default: {
return '';
}
}
}
}
......@@ -183,6 +183,31 @@ export class ReportComponent implements OnInit {
};
}
setUmbrellaProjectReportColumns() {
this.displayedColumns = [
this._showAlias ? 'Unique name' : 'Accession',
'Title',
'Submission date',
'Release date',
'Status',
'Action', // No callback for Action column
];
if (this.embeded) {
this.displayedColumns.splice(-1, 1);
this.displayedColumns.unshift('Select')
}
this.displayedColumnsCallback = {
'Select': this.accessionColumnCallback.bind(this),
Accession: this.accessionColumnCallback.bind(this),
'Unique name': this.aliasColumnCallback.bind(this),
'Secondary Accession': this.secondaryIdColumnCallback.bind(this),
Title: this.titleColumnCallback.bind(this),
'Submission date': this.submissionDateColumnCallback.bind(this),
'Release date': this.releaseDateColumnCallback.bind(this),
Status: this.statusColumnCallback.bind(this)
};
}
setSampleReportColumns() {
this.displayedColumns = [
this._showAlias ? 'Unique name' : 'Accession',
......@@ -454,16 +479,13 @@ export class ReportComponent implements OnInit {
// Allow navigation to run report.
if (this.reportType === ReportType.studies) {
actions.push(ReportActionType.createChangeReportAction(ReportType.runs, this.getSecondaryId(result)));
actions.push(ReportActionType.createChangeReportAction(ReportType.analyses, this.getSecondaryId(result)));
}
if (this.reportType === ReportType.samples ||
this.reportType === ReportType.runFiles) {
actions.push(ReportActionType.createChangeReportAction(ReportType.runs, this.getId(result)));
}
// Allow navigation to analysis report.
if (this.reportType === ReportType.studies) {
actions.push(ReportActionType.createChangeReportAction(ReportType.analyses, this.getSecondaryId(result)));
}
if (this.reportType === ReportType.samples ||
this.reportType === ReportType.analysisFiles) {
actions.push(ReportActionType.createChangeReportAction(ReportType.analyses, this.getId(result)));
......@@ -515,8 +537,6 @@ export class ReportComponent implements OnInit {
// console.log('** change report action **', action);
//this.reportChange.emit(action);
this.router.navigate(['/report', action.reportType, action.id]);
}
if (action && action.reportActionType === ReportActionType.editXml) {
......@@ -567,6 +587,14 @@ export class ReportComponent implements OnInit {
data => {
// console.log('** Webin reports service **', data);
this.data = data;
// Filtering umbrella projects using study_id (secondaryId === null) because study_id will be null for umbrella projects.
if (this.reportType === ReportType.umbrellaProjects) {
this.data = data.filter((record) => record.report.secondaryId === null)
}
if (this.reportType === ReportType.projects || this.reportType === ReportType.studies) {
this.data = data.filter((record) => record.report.secondaryId != null)
}
this.dataSource = new MatTableDataSource<any>(this.data);
this.dataSource.paginator = this.dataPaginator;
},
......@@ -610,6 +638,8 @@ export class ReportComponent implements OnInit {
this.setPolicyReportColumns();
} else if (this.reportType === ReportType.datasets) {
this.setDatasetReportColumns();
} else if (this.reportType === ReportType.umbrellaProjects) {
this.setUmbrellaProjectReportColumns();
}
}
......@@ -628,6 +658,15 @@ export class ReportComponent implements OnInit {
// return this._webinReportService.getStudiesAll(this._status, rows, format);
}
if (this.reportType === ReportType.umbrellaProjects) {
if (this.id) {
return this._webinReportService.getProjects(this.id, rows, format);
// return this._webinReportService.getStudies(this.id, rows, format);
}
return this._webinReportService.getProjectsAll(this._status, rows, format);
// return this._webinReportService.getStudiesAll(this._status, rows, format);
}
if (this.reportType === ReportType.samples) {
if (this.id) {
return this._webinReportService.getSamples(this.id, rows, format);
......
......@@ -44,12 +44,16 @@
</mat-list-item>
<div class="submenu" [ngClass]="{'expanded' : showSubmenu}">
<a mat-list-item [routerLink]="['/study']" (click)="snav.toggle()">Register study (project)</a>
<a mat-list-item *ngIf="isSuperUser()" [routerLink]="['/umbrella']" (click)="snav.toggle()">Register umbrella
project</a>
<a mat-list-item [routerLink]="['/app-checklist','sample',true]" (click)="snav.toggle()">Register sample</a>
<ng-container *ngIf="!isEga()">
<a mat-list-item [routerLink]="['/taxonomy']" (click)="snav.toggle()">Register taxonomy</a>
</ng-container>
<ng-container *ngIf="isEga()">
<a mat-list-item [routerLink]="['/dac']" (click)="snav.toggle()">Register Dacs</a>
<a mat-list-item [routerLink]="['/dac-policy']" (click)="snav.toggle()">Register policy</a>
<a mat-list-item [routerLink]="['/dac-dataset']" (click)="snav.toggle()">Register dataset</a>
</ng-container>
</div>
<mat-list-item class="parent">
......@@ -69,6 +73,10 @@
<div class="submenu" [ngClass]="{'expanded' : showSubmenu}">
<a mat-list-item [routerLink]="['/report',ReportType.studies,{defaultSearch: true}]"
(click)="snav.toggle()">Studies</a>
<a mat-list-item *ngIf="isSuperUser()"
[routerLink]="['/report',ReportType.umbrellaProjects,{defaultSearch: true}]"
(click)="snav.toggle()">Umbrella
Project</a>
<a mat-list-item [routerLink]="['/report',ReportType.samples,{defaultSearch: true}]"
(click)="snav.toggle()">Samples</a>
<a mat-list-item [routerLink]="['/report',ReportType.analyses,{defaultSearch: true}]"
......
......@@ -68,4 +68,8 @@ export class SidenavComponent implements OnDestroy, AfterViewChecked {
return this._webinAuthenticationService.ega;
}
isSuperUser(): boolean {
return this._webinAuthenticationService.superUser;
}
}
......@@ -24,6 +24,11 @@ export class SubmissionResultDialogComponent implements OnInit {
submissionResult: SubmissionResultComponent;
redirectPath: string;
data: Observable<string>;
//Only for umbrella project.
projectLinkJsonForUpdate: object;
projectLinkJsonForDelete: object;
constructor(
public dialogRef: MatDialogRef<SubmissionResultDialogComponent>,
@Inject(MAT_DIALOG_DATA) public popupData: Observable<string>,
......@@ -31,9 +36,19 @@ export class SubmissionResultDialogComponent implements OnInit {
) {
this.data = popupData["observable"];
this.redirectPath = popupData["redirectPath"];
// Only for umbrella project.
this.projectLinkJsonForUpdate = popupData["projectLinkJsonForUpdate"];
this.projectLinkJsonForDelete = popupData["projectLinkJsonForDelete"];
}
ngOnInit() {
this.submissionResult.submit(this.data);
if (this.projectLinkJsonForUpdate) {
this.submissionResult.submitUmbrellaProject(this.data, this.projectLinkJsonForUpdate, this.projectLinkJsonForDelete)
} else {
this.submissionResult.submit(this.data);
}
}
}
.centred {
position: fixed; /* or absolute */
top: 50%;
left: 50%;
height:70px;
}
\ No newline at end of file
<div *ngIf="active" style="height:70px;">
<div class="centred" *ngIf="active">
<mat-spinner [diameter]="50" [strokeWidth]="5" style="margin:0 auto;">
</mat-spinner>
</div>
......@@ -49,6 +49,20 @@
</div>
<!-- Message specific to Project link -->
<!--<div *ngIf="projectLinkMessage">
<div class="app-success">
<i class="material-icons">done</i>
{{projectLinkMessage}}
</div>
</div>-->
<div *ngIf="projectLinkError">
<div class="app-error">
<i class="material-icons">error</i>
{{projectLinkError}}
</div>
</div>
<div *ngIf="showReceipt()">
<!-- Show receipt -->
......
......@@ -48,6 +48,8 @@ export class SubmissionResultComponent {
message;
errorMessage;
resultError;
projectLinkError;
projectLinkMessage;
showReceiptXml = false;
@Input() showReceiptSuccess = true;
active: boolean;
......@@ -114,6 +116,127 @@ export class SubmissionResultComponent {
}
}
submitUmbrellaProject(observable: Observable<string>, projectLinkJsonForUpdate: object, projectLinkJsonForDelete: object) {
if (observable) {
this.reset();
this.active = true;
let calledProjectLink = false;
observable.pipe(
retry(3)
).subscribe(
data => {
// HttpResponse when using {observe: 'response'}
this.result = this._webinRestService.parseResult(data);
// console.log('** Webin submission **', this.result);
if (this.result.isError) {
this.webinErrorDataSource = new MatTableDataSource<WebinError>(this.result.errors);
this.webinErrorDataSource.paginator = this.webinErrorPaginator;
} else {
// For project linking
var projectAccession = this.result.accessions.find(element => element.type === "PROJECT").accession;
projectLinkJsonForUpdate["projectId"] = projectAccession;
// Delete projectLink before insert / update
if (projectLinkJsonForDelete["parentId"] || projectLinkJsonForDelete["childIds"].length > 0) {
projectLinkJsonForDelete["projectId"] = projectAccession;
console.log("Delete project link: " + JSON.stringify(projectLinkJsonForDelete))
this.deleteProjectLink(projectLinkJsonForDelete);
}
// create project link if parentId or childId is added.
if (projectLinkJsonForUpdate["parentId"] || projectLinkJsonForUpdate["childIds"].length > 0) {
calledProjectLink = true;
console.log("Insert / update project link: " + JSON.stringify(projectLinkJsonForUpdate))
this.createProjectLink(projectLinkJsonForUpdate, this.result.accessions);
}
// If project link insertion is not called then show project submission success message here.
if (!calledProjectLink) {
this.displayUmbrelaProjectSucccess(this.result.accessions);
}
}
},
(err: HttpErrorResponse) => {
console.error('** Webin submission service failed **' + err);
const msg = 'Webin submission service failed. Please try again later. If the problem persists please contact the helpdesk.';
this.resultError = msg;
},
() => {
if (!calledProjectLink) {
this.active = false;
}
});
}
}