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>
|
||||
<ul class="dropdown-menu">
|
||||
<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>
|
||||
</li>
|
||||
|
||||
|
|
|
@ -6,22 +6,23 @@ import {Pipe, PipeTransform} from "@angular/core";
|
|||
})
|
||||
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 (
|
||||
|
||||
row.label.indexOf(query) > -1
|
||||
|
||||
//|| row.version == query
|
||||
//|| row.id.indexOf(query) > -1
|
||||
)
|
||||
if(onlyMyProjects){
|
||||
return (row.label.indexOf(query) > -1) && (row.creationUser==userid);
|
||||
}
|
||||
else{
|
||||
return row.label.indexOf(query) > -1;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,16 +1,21 @@
|
|||
<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">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="1">
|
||||
<input class="form-control" [(ngModel)]="filterQuery" placeholder='Filter' />
|
||||
</th>
|
||||
<th>
|
||||
<th style="width:50px;">
|
||||
<button class="btn btn-default" (click)="getProjects('false')">
|
||||
<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>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -59,6 +59,8 @@ export class ProjectsComponent implements OnInit{
|
|||
|
||||
project: any;
|
||||
|
||||
whoami: any;
|
||||
onlyMyProjects : boolean = false;
|
||||
|
||||
options: DatepickerOptions = {
|
||||
minYear: 1900,
|
||||
|
@ -101,11 +103,22 @@ getEmptyProject(){
|
|||
|
||||
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){
|
||||
this.serverService.getProjectsOfUser().subscribe(
|
||||
//this.serverService.getProjectsOfUser().subscribe(
|
||||
this.serverService.getAllProjects().subscribe(
|
||||
response => {
|
||||
this.tableData = response;
|
||||
if(muted && muted!=true)
|
||||
|
|
|
@ -99,7 +99,6 @@ export class ServerService {
|
|||
return this.restBase.get("dmp/getofuser");
|
||||
}
|
||||
|
||||
|
||||
public createDmpForCurrentUser(data:any){
|
||||
return this.restBase.post("dmp/createofuser", data);
|
||||
}
|
||||
|
@ -140,6 +139,10 @@ public deleteDataset(dataset: any){
|
|||
return this.restBase.post("dataset/softdelete", dataset);
|
||||
}
|
||||
|
||||
public whoami(){
|
||||
return this.restBase.get("user/whoami");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
logOut() {
|
||||
|
|
|
@ -55,7 +55,7 @@ export class BreadcrumbComponent implements OnInit {
|
|||
let label = null;
|
||||
|
||||
if(componentName == "ProjectsComponent") {
|
||||
label = "My Projects";
|
||||
label = "Projects";
|
||||
}
|
||||
if(componentName == "DmpComponent"){
|
||||
label = "My Data Management Plans";
|
||||
|
|
Loading…
Reference in New Issue