From 9e12a95bfe51a318ea71980c45291880b8eefd28 Mon Sep 17 00:00:00 2001 From: Solomon Laing Date: Wed, 7 Jul 2021 14:52:51 +0930 Subject: [PATCH] added basic filter to projects so gitlab and uncategorized are separate --- src/app/projects/projects.component.html | 4 +++- src/app/projects/projects.component.ts | 29 ++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/app/projects/projects.component.html b/src/app/projects/projects.component.html index 4a04f43..4611afb 100644 --- a/src/app/projects/projects.component.html +++ b/src/app/projects/projects.component.html @@ -1,8 +1,10 @@

Projects on git

These are my projects as can be found on my gitlab. Mainly my programming projects that are quality enough for me to be happy for the world to see them. There are more in the works but they are currently private.

+ +

Projects of a personal nature

This is (will be) a summary of my personal projects be they my homelab, general electronics projects, or anything else.

- + \ No newline at end of file diff --git a/src/app/projects/projects.component.ts b/src/app/projects/projects.component.ts index 6da1e8b..cc5c319 100644 --- a/src/app/projects/projects.component.ts +++ b/src/app/projects/projects.component.ts @@ -14,7 +14,9 @@ import { ProjectsService } from './projects.service'; export class ProjectsComponent implements OnInit, OnDestroy { _unsubscribe$: Subject = new Subject(); - uncategorizedProjects: Array; + allProjects: Array; + private _gitlabProjects: Array = new Array(); + private _uncategorizedProjects: Array = new Array(); constructor(private navService: NavService, private projectsService: ProjectsService) { } @@ -24,8 +26,9 @@ export class ProjectsComponent implements OnInit, OnDestroy { this.projectsService.allProjects$ .pipe(takeUntil(this._unsubscribe$)) .subscribe((result: Project[]) => { - this.uncategorizedProjects = result; + this.allProjects = result; }); + this.projectsService.getProjects(); } @@ -34,4 +37,26 @@ export class ProjectsComponent implements OnInit, OnDestroy { this._unsubscribe$.complete(); } + filterProjects(): void { + this._gitlabProjects = []; + this._uncategorizedProjects = []; + this.allProjects.forEach((project) => { + if (project.category === 'gitlab') { + this._gitlabProjects.push(project); + } else { + this._uncategorizedProjects.push(project); + } + }) + } + + gitlabProjects(): Array { + this.filterProjects(); + return this._gitlabProjects; + } + + uncategorizedProjects(): Array { + this.filterProjects(); + return this._uncategorizedProjects; + } + }