Projects are now fetched for all, plus the option to filter for current user
This commit is contained in:
parent
eabb3b7022
commit
14280f0a2d
|
@ -22,7 +22,7 @@
|
||||||
<span class="caret"></span></a>
|
<span class="caret"></span></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a class="cursor" (click)="goToDMPs()">My DMPs</a></li>
|
<li><a class="cursor" (click)="goToDMPs()">My DMPs</a></li>
|
||||||
<li><a class="cursor" (click)="goToProjects()">My Projects</a></li>
|
<li><a class="cursor" (click)="goToProjects()">Projects</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
|
@ -6,22 +6,23 @@ import {Pipe, PipeTransform} from "@angular/core";
|
||||||
})
|
})
|
||||||
export class ProjectTableFilterPipe implements PipeTransform {
|
export class ProjectTableFilterPipe implements PipeTransform {
|
||||||
|
|
||||||
transform(array: any[], query: string): any {
|
transform(array: any[], query: string, userid : string, onlyMyProjects : boolean): any {
|
||||||
|
|
||||||
if (query) {
|
if (query || userid) {
|
||||||
|
|
||||||
return _.filter(array, row => {
|
return _.filter(array, row => {
|
||||||
|
|
||||||
return (
|
|
||||||
|
|
||||||
row.label.indexOf(query) > -1
|
|
||||||
|
|
||||||
//|| row.version == query
|
if(onlyMyProjects){
|
||||||
//|| row.id.indexOf(query) > -1
|
return (row.label.indexOf(query) > -1) && (row.creationUser==userid);
|
||||||
)
|
}
|
||||||
|
else{
|
||||||
|
return row.label.indexOf(query) > -1;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,16 +1,21 @@
|
||||||
<meta name="google-signin-client_id" content="524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com">
|
<meta name="google-signin-client_id" content="524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com">
|
||||||
|
|
||||||
<table class="table table-striped" [mfData]="tableData | projectTableFilter : filterQuery"
|
<table class="table table-striped" [mfData]="tableData | projectTableFilter : filterQuery : whoami?.id : onlyMyProjects"
|
||||||
#mf="mfDataTable" [mfRowsOnPage]="rowsOnPage" [(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder">
|
#mf="mfDataTable" [mfRowsOnPage]="rowsOnPage" [(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="1">
|
<th colspan="1">
|
||||||
<input class="form-control" [(ngModel)]="filterQuery" placeholder='Filter' />
|
<input class="form-control" [(ngModel)]="filterQuery" placeholder='Filter' />
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th style="width:50px;">
|
||||||
<button class="btn btn-default" (click)="getProjects('false')">
|
<button class="btn btn-default" (click)="getProjects('false')">
|
||||||
<span class="glyphicon glyphicon-refresh"></span>
|
<span class="glyphicon glyphicon-refresh"></span>
|
||||||
</button>
|
</button>
|
||||||
|
</th>
|
||||||
|
<th colspan="1">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label><input type="checkbox" [(ngModel)]="onlyMyProjects" >Show only my projects</label>
|
||||||
|
</div>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -59,6 +59,8 @@ export class ProjectsComponent implements OnInit{
|
||||||
|
|
||||||
project: any;
|
project: any;
|
||||||
|
|
||||||
|
whoami: any;
|
||||||
|
onlyMyProjects : boolean = false;
|
||||||
|
|
||||||
options: DatepickerOptions = {
|
options: DatepickerOptions = {
|
||||||
minYear: 1900,
|
minYear: 1900,
|
||||||
|
@ -101,11 +103,22 @@ getEmptyProject(){
|
||||||
|
|
||||||
this.getProjects();
|
this.getProjects();
|
||||||
|
|
||||||
|
this.serverService.whoami().subscribe(
|
||||||
|
response => {
|
||||||
|
this.whoami = response;
|
||||||
|
console.log(this.whoami)
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
simple_notifier("danger",null,"Could not retrieve user config");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getProjects(muted? : boolean){
|
getProjects(muted? : boolean){
|
||||||
this.serverService.getProjectsOfUser().subscribe(
|
//this.serverService.getProjectsOfUser().subscribe(
|
||||||
|
this.serverService.getAllProjects().subscribe(
|
||||||
response => {
|
response => {
|
||||||
this.tableData = response;
|
this.tableData = response;
|
||||||
if(muted && muted!=true)
|
if(muted && muted!=true)
|
||||||
|
|
|
@ -99,7 +99,6 @@ export class ServerService {
|
||||||
return this.restBase.get("dmp/getofuser");
|
return this.restBase.get("dmp/getofuser");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public createDmpForCurrentUser(data:any){
|
public createDmpForCurrentUser(data:any){
|
||||||
return this.restBase.post("dmp/createofuser", data);
|
return this.restBase.post("dmp/createofuser", data);
|
||||||
}
|
}
|
||||||
|
@ -140,6 +139,10 @@ public deleteDataset(dataset: any){
|
||||||
return this.restBase.post("dataset/softdelete", dataset);
|
return this.restBase.post("dataset/softdelete", dataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public whoami(){
|
||||||
|
return this.restBase.get("user/whoami");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
logOut() {
|
logOut() {
|
||||||
|
|
|
@ -55,7 +55,7 @@ export class BreadcrumbComponent implements OnInit {
|
||||||
let label = null;
|
let label = null;
|
||||||
|
|
||||||
if(componentName == "ProjectsComponent") {
|
if(componentName == "ProjectsComponent") {
|
||||||
label = "My Projects";
|
label = "Projects";
|
||||||
}
|
}
|
||||||
if(componentName == "DmpComponent"){
|
if(componentName == "DmpComponent"){
|
||||||
label = "My Data Management Plans";
|
label = "My Data Management Plans";
|
||||||
|
|
Loading…
Reference in New Issue