Skip to content

Commit

Permalink
Merge pull request #1141 from deNBI/feature/facility_member_filter
Browse files Browse the repository at this point in the history
feature(Facility):filter groups by member id
  • Loading branch information
dweinholz authored Feb 27, 2020
2 parents 01ddc31 + 5d3dc83 commit 4af1ba7
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/app/api-connector/facility.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ export class FacilityService {

}

getFacilityGroupsByMemberElixirId(facility: number | string, elixir_id: string): Observable<any> {

return this.http.get(`${ApiSettings.getApiBaseURL()}computecenters/${facility}/projects/filter/`, {
withCredentials: true,
params: {elixir_id: elixir_id.toString()}

})

}

/**
* Get all resources assigned to a facility.
* @param {number} facility id of the facility
Expand Down
69 changes: 69 additions & 0 deletions src/app/facility_manager/facilityprojectsoverview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,76 @@ export class FacilityProjectsOverviewComponent extends FilterBaseClass implement
});
}

getProjectsByMemberElixirId(): void {
// tslint:disable-next-line:max-line-length
this.facilityservice.getFacilityGroupsByMemberElixirId(this.managerFacilities[0]['FacilityId'], this.filter).subscribe((result: any) => {
this.projects_filtered = [];
const facility_projects: any = result;
const is_pi: boolean = false;
const is_admin: boolean = false;
for (const group of facility_projects) {
const dateCreated: moment.Moment = moment.unix(group['createdAt']);
const dateDayDifference: number = Math.ceil(moment().diff(dateCreated, 'days', true));
const groupid: string = group['id'];

const currentCredits: number = Number(group['current_credits']);
const approvedCredits: number = Number(group['approved_credits']);
const tmp_facility: any = group['compute_center'];
let shortname: string = group['shortname'];
let compute_center: ComputecenterComponent = null;
const lifetime: number = group['lifetime'];

if (!shortname) {
shortname = group['name']
}
if (tmp_facility) {
compute_center = new ComputecenterComponent(
tmp_facility['compute_center_facility_id'],
tmp_facility['compute_center_name'],
tmp_facility['compute_center_login'],
tmp_facility['compute_center_support_mail']);
}

const newProject: Project = new Project(
Number(groupid),
shortname,
group['description'],
`${dateCreated.date()}.${(dateCreated.month() + 1)}.${dateCreated.year()}`,
dateDayDifference,
is_pi,
is_admin,
compute_center,
currentCredits,
approvedCredits);
newProject.Status = group['status'];

if (lifetime !== -1) {
const expirationDate: string = moment(moment(dateCreated).add(lifetime, 'months').toDate()).format('DD.MM.YYYY');
const lifetimeDays: number = Math.abs(moment(moment(expirationDate, 'DD.MM.YYYY')
.toDate()).diff(moment(dateCreated), 'days'));

newProject.LifetimeDays = lifetimeDays;
newProject.DateEnd = expirationDate;
newProject.LifetimeReached = this.lifeTimeReached(lifetimeDays, dateDayDifference)

}
newProject.RealName = group['name'];
newProject.Lifetime = lifetime;
newProject.OpenStackProject = group['openstack_project'];

this.projects_filtered.push(newProject);
}
})
}

applyFilter(): void {
if (this.filter) {
this.filter = this.filter.trim()
}
if (this.filter && this.filter.includes('@elixir-europe')) {
this.getProjectsByMemberElixirId();

}

this.projects_filtered = this.projects.filter((project: Project) => this.checkFilter(project));

Expand Down

0 comments on commit 4af1ba7

Please sign in to comment.