Compare commits
4 Commits
master
...
feature/pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
525e055d60 | ||
|
|
fd1df6e2af | ||
|
|
6750247f66 | ||
|
|
9a1d147073 |
@ -2,16 +2,18 @@ import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { LinksComponent } from './links/links.component';
|
||||
import { Page404Component } from './page404/page404.component';
|
||||
import { PetComponent } from './pet/pet.component';
|
||||
import { ProjectsComponent } from './projects/projects.component';
|
||||
import { Pages } from './shared/models/pages.model';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: Pages.HOME, component: HomeComponent },
|
||||
{ path: Pages.PROJECTS, component: ProjectsComponent },
|
||||
// { path: AppRoutes.CORE, loadChildren: () => import('./galler/gallery.module').then((m) => m.GalleryModule) }, // for future use
|
||||
{ path: Pages.PROJECTS, loadChildren: () => import('./projects/projects.module').then((m) => m.ProjectsModule) },
|
||||
// { path: AppRoutes.CORE, loadChildren: () => import('./galler/gallery.module').then((m) => m.GalleryModule) }, // for future use maybe
|
||||
{ path: Pages.LINKS, component: LinksComponent },
|
||||
{ path: Pages.PET, component: PetComponent },
|
||||
{ path: Pages.PAGE_404, component: Page404Component },
|
||||
{ path: '**', redirectTo: Pages.HOME, pathMatch: 'full' }];
|
||||
|
||||
@NgModule({
|
||||
|
||||
@ -9,8 +9,9 @@ import { FooterComponent } from './footer/footer.component';
|
||||
import { SharedModule } from './shared/shared.module';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { LinksComponent } from './links/links.component';
|
||||
import { ProjectsComponent } from './projects/projects.component';
|
||||
import { PetComponent } from './pet/pet.component';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { Page404Component } from './page404/page404.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
@ -20,13 +21,14 @@ import { PetComponent } from './pet/pet.component';
|
||||
FooterComponent,
|
||||
HomeComponent,
|
||||
LinksComponent,
|
||||
ProjectsComponent,
|
||||
PetComponent
|
||||
PetComponent,
|
||||
Page404Component
|
||||
],
|
||||
imports: [
|
||||
SharedModule,
|
||||
BrowserModule,
|
||||
AppRoutingModule
|
||||
AppRoutingModule,
|
||||
HttpClientModule
|
||||
],
|
||||
providers: [],
|
||||
bootstrap: [AppComponent]
|
||||
|
||||
2
src/app/page404/page404.component.html
Normal file
2
src/app/page404/page404.component.html
Normal file
@ -0,0 +1,2 @@
|
||||
<h1>Page Not Found?</h1>
|
||||
<h3>Sorry.</h3>
|
||||
5
src/app/page404/page404.component.scss
Normal file
5
src/app/page404/page404.component.scss
Normal file
@ -0,0 +1,5 @@
|
||||
:host {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
25
src/app/page404/page404.component.spec.ts
Normal file
25
src/app/page404/page404.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { Page404Component } from './page404.component';
|
||||
|
||||
describe('Page404Component', () => {
|
||||
let component: Page404Component;
|
||||
let fixture: ComponentFixture<Page404Component>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ Page404Component ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(Page404Component);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
15
src/app/page404/page404.component.ts
Normal file
15
src/app/page404/page404.component.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-page404',
|
||||
templateUrl: './page404.component.html',
|
||||
styleUrls: ['./page404.component.scss']
|
||||
})
|
||||
export class Page404Component implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
<a routerLink="{{project.slug}}">
|
||||
<h2>{{project.title}}</h2>
|
||||
<p>{{project.description}}</p>
|
||||
</a>
|
||||
22
src/app/projects/project-card/project-card.component.scss
Normal file
22
src/app/projects/project-card/project-card.component.scss
Normal file
@ -0,0 +1,22 @@
|
||||
@use 'src/app/shared/styles/_variables.color' as colors;
|
||||
|
||||
:host {
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
background-color: colors.$inklets-color-bg;
|
||||
margin-bottom: 20px;
|
||||
|
||||
a {
|
||||
color: colors.$inklets-color-white;
|
||||
border: colors.$inklets-color-highlight-bg 2px dashed;
|
||||
background-color: colors.$inklets-color-fg;
|
||||
text-decoration: none;
|
||||
padding: 0 20px 0 20px;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
background-color: colors.$inklets-color-highlight-fg;
|
||||
color: colors.$inklets-color-black;
|
||||
}
|
||||
|
||||
}
|
||||
25
src/app/projects/project-card/project-card.component.spec.ts
Normal file
25
src/app/projects/project-card/project-card.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProjectCardComponent } from './project-card.component';
|
||||
|
||||
describe('ProjectCardComponent', () => {
|
||||
let component: ProjectCardComponent;
|
||||
let fixture: ComponentFixture<ProjectCardComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ProjectCardComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ProjectCardComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
19
src/app/projects/project-card/project-card.component.ts
Normal file
19
src/app/projects/project-card/project-card.component.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { Project } from 'src/app/shared/models/project.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-project-card',
|
||||
templateUrl: './project-card.component.html',
|
||||
styleUrls: ['./project-card.component.scss']
|
||||
})
|
||||
export class ProjectCardComponent implements OnInit {
|
||||
|
||||
@Input()
|
||||
project: Project;
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
||||
2
src/app/projects/project/project.component.html
Normal file
2
src/app/projects/project/project.component.html
Normal file
@ -0,0 +1,2 @@
|
||||
<p>project works!</p>
|
||||
{{project.title}}
|
||||
0
src/app/projects/project/project.component.scss
Normal file
0
src/app/projects/project/project.component.scss
Normal file
25
src/app/projects/project/project.component.spec.ts
Normal file
25
src/app/projects/project/project.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProjectComponent } from './project.component';
|
||||
|
||||
describe('ProjectComponent', () => {
|
||||
let component: ProjectComponent;
|
||||
let fixture: ComponentFixture<ProjectComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ProjectComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ProjectComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
52
src/app/projects/project/project.component.ts
Normal file
52
src/app/projects/project/project.component.ts
Normal file
@ -0,0 +1,52 @@
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { Project } from 'src/app/shared/models/project.model';
|
||||
import { ProjectsService } from '../projects.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-project',
|
||||
templateUrl: './project.component.html',
|
||||
styleUrls: ['./project.component.scss']
|
||||
})
|
||||
export class ProjectComponent implements OnInit, OnDestroy {
|
||||
_unsubscribe$: Subject<boolean> = new Subject();
|
||||
|
||||
project: Project = {
|
||||
title: '',
|
||||
description: '',
|
||||
slug: '',
|
||||
ct: '',
|
||||
body: '',
|
||||
};
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private projectsService: ProjectsService
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
let id: string;
|
||||
this.route.paramMap.subscribe((params) => {
|
||||
id = params.get('id');
|
||||
});
|
||||
|
||||
this.projectsService.getProject(id);
|
||||
|
||||
this.projectsService.currentProject$
|
||||
.pipe(takeUntil(this._unsubscribe$))
|
||||
.subscribe((result: Project) => {
|
||||
if (!!result) {
|
||||
this.project = result;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this._unsubscribe$.next(false);
|
||||
this._unsubscribe$.complete();
|
||||
}
|
||||
|
||||
}
|
||||
21
src/app/projects/projects-routing.module.ts
Normal file
21
src/app/projects/projects-routing.module.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { ProjectComponent } from './project/project.component';
|
||||
import { ProjectsComponent } from './projects.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: ProjectsComponent
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: ProjectComponent
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class ProjectsRoutingModule {}
|
||||
@ -1 +1,8 @@
|
||||
<p>projects works!</p>
|
||||
<h2>Projects on git</h2>
|
||||
<p>These are my projects as can be found on my <a href="https://gitlab.inkletblot.com/explore">gitlab</a>. 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.</p>
|
||||
|
||||
<h2>Projects of a personal nature</h2>
|
||||
<p>This is (will be) a summary of my personal projects be they my homelab, general electronics projects, or anything else.</p>
|
||||
|
||||
<app-project-card *ngFor="let project of uncategorizedProjects" [project]="project">
|
||||
</app-project-card>
|
||||
@ -1,18 +1,37 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Subject } from 'rxjs/internal/Subject';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { NavService } from '../nav/nav.service';
|
||||
import { Pages } from '../shared/models/pages.model';
|
||||
import { Project } from '../shared/models/project.model';
|
||||
import { ProjectsService } from './projects.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-projects',
|
||||
templateUrl: './projects.component.html',
|
||||
styleUrls: ['./projects.component.scss']
|
||||
})
|
||||
export class ProjectsComponent implements OnInit {
|
||||
export class ProjectsComponent implements OnInit, OnDestroy {
|
||||
_unsubscribe$: Subject<boolean> = new Subject();
|
||||
|
||||
constructor(private navService:NavService) { }
|
||||
uncategorizedProjects: Array<Project>;
|
||||
|
||||
constructor(private navService: NavService, private projectsService: ProjectsService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.navService.setPageTitle(Pages.PROJECTS);
|
||||
|
||||
this.projectsService.allProjects$
|
||||
.pipe(takeUntil(this._unsubscribe$))
|
||||
.subscribe((result: Project[]) => {
|
||||
this.uncategorizedProjects = result;
|
||||
});
|
||||
this.projectsService.getInvoicesToApprove();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this._unsubscribe$.next(false);
|
||||
this._unsubscribe$.complete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
16
src/app/projects/projects.module.ts
Normal file
16
src/app/projects/projects.module.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ProjectCardComponent } from './project-card/project-card.component';
|
||||
import { ProjectComponent } from './project/project.component';
|
||||
import { ProjectsComponent } from './projects.component';
|
||||
import { ProjectsRoutingModule } from './projects-routing.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [ProjectsComponent, ProjectCardComponent, ProjectComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
ProjectsRoutingModule
|
||||
],
|
||||
providers: []
|
||||
})
|
||||
export class ProjectsModule { }
|
||||
16
src/app/projects/projects.service.spec.ts
Normal file
16
src/app/projects/projects.service.spec.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProjectsService } from './projects.service';
|
||||
|
||||
describe('ProjectsService', () => {
|
||||
let service: ProjectsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ProjectsService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
91
src/app/projects/projects.service.ts
Normal file
91
src/app/projects/projects.service.ts
Normal file
@ -0,0 +1,91 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { Project } from '../shared/models/project.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ProjectsService {
|
||||
|
||||
private _allProjects = new BehaviorSubject<Array<Project>>([]);
|
||||
readonly allProjects$ = this._allProjects.asObservable();
|
||||
|
||||
private set allProjects(projects: Array<Project>) {
|
||||
this._allProjects.next(projects);
|
||||
}
|
||||
private get allProjects(): Array<Project> {
|
||||
return this._allProjects.getValue();
|
||||
}
|
||||
|
||||
private _currentProject = new BehaviorSubject<Project>(null);
|
||||
readonly currentProject$ = this._currentProject.asObservable();
|
||||
|
||||
private set currentProject(project: Project) {
|
||||
this._currentProject.next(project);
|
||||
}
|
||||
private get currentProject(): Project {
|
||||
return this._currentProject.getValue();
|
||||
}
|
||||
|
||||
private _apiErrored = new BehaviorSubject<boolean>(false);
|
||||
readonly apiErrored$ = this._apiErrored.asObservable();
|
||||
|
||||
private set apiErrored(errored: boolean) {
|
||||
this._apiErrored.next(errored);
|
||||
}
|
||||
private get apiErrored(): boolean {
|
||||
return this._apiErrored.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* I am actively avoiding any kind of environment management, this is a very basic site and currently this is the only api call.
|
||||
*/
|
||||
|
||||
private PROJECT_API_URL = "https://cms.inkletblot.com/"
|
||||
|
||||
constructor(private http: HttpClient, private router: Router) { }
|
||||
|
||||
httpOptions = {
|
||||
headers: new HttpHeaders({
|
||||
'Content-Type': 'text/plain'
|
||||
})
|
||||
};
|
||||
|
||||
getInvoicesToApprove(): void {
|
||||
this.http
|
||||
.get(`${this.PROJECT_API_URL}`, this.httpOptions)
|
||||
.subscribe(
|
||||
(response: Project[]) => {
|
||||
if (response) {
|
||||
// using text/plain so as to not get the preflight options request
|
||||
// as such : Project[] does not work as expected and objects must be parsed.
|
||||
this.allProjects = response;
|
||||
// filter out different categories here currently only one
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
this.apiErrored = true;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is not very efficient code but I'm not planning on having that many projects and (if this turns into a blog) blog posts
|
||||
* If this does become a general blog, then I will make this a bit more efficient.
|
||||
* @param id slug of project to get
|
||||
*/
|
||||
getProject(id: string): void {
|
||||
let found = false;
|
||||
this.allProjects.forEach((project) => {
|
||||
if (project.slug === id) {
|
||||
found = true;
|
||||
this.currentProject = project;
|
||||
}
|
||||
})
|
||||
if (!found) {
|
||||
this.router.navigate(['not-found'])
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,5 +6,6 @@ export enum Pages {
|
||||
PROJECTS = 'projects',
|
||||
GALLERY = 'gallery',
|
||||
LINKS = 'links',
|
||||
PET = 'pet'
|
||||
PET = 'pet',
|
||||
PAGE_404 = 'not-found'
|
||||
}
|
||||
6
src/app/shared/models/project.model.ts
Normal file
6
src/app/shared/models/project.model.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export interface Project {
|
||||
slug: string,
|
||||
date: string,
|
||||
category: string,
|
||||
content: string
|
||||
}
|
||||
Reference in New Issue
Block a user