started implementation of projects page. currently need to work out cors
This commit is contained in:
parent
9d568df286
commit
9a1d147073
@ -8,8 +8,8 @@ import { Pages } from './shared/models/pages.model';
|
|||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: Pages.HOME, component: HomeComponent },
|
{ path: Pages.HOME, component: HomeComponent },
|
||||||
{ path: Pages.PROJECTS, component: ProjectsComponent },
|
{ 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
|
// { path: AppRoutes.CORE, loadChildren: () => import('./galler/gallery.module').then((m) => m.GalleryModule) }, // for future use maybe
|
||||||
{ path: Pages.LINKS, component: LinksComponent },
|
{ path: Pages.LINKS, component: LinksComponent },
|
||||||
{ path: Pages.PET, component: PetComponent },
|
{ path: Pages.PET, component: PetComponent },
|
||||||
{ path: '**', redirectTo: Pages.HOME, pathMatch: 'full' }];
|
{ path: '**', redirectTo: Pages.HOME, pathMatch: 'full' }];
|
||||||
|
|||||||
@ -9,8 +9,8 @@ import { FooterComponent } from './footer/footer.component';
|
|||||||
import { SharedModule } from './shared/shared.module';
|
import { SharedModule } from './shared/shared.module';
|
||||||
import { HomeComponent } from './home/home.component';
|
import { HomeComponent } from './home/home.component';
|
||||||
import { LinksComponent } from './links/links.component';
|
import { LinksComponent } from './links/links.component';
|
||||||
import { ProjectsComponent } from './projects/projects.component';
|
|
||||||
import { PetComponent } from './pet/pet.component';
|
import { PetComponent } from './pet/pet.component';
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -20,13 +20,13 @@ import { PetComponent } from './pet/pet.component';
|
|||||||
FooterComponent,
|
FooterComponent,
|
||||||
HomeComponent,
|
HomeComponent,
|
||||||
LinksComponent,
|
LinksComponent,
|
||||||
ProjectsComponent,
|
|
||||||
PetComponent
|
PetComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
SharedModule,
|
SharedModule,
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
AppRoutingModule
|
AppRoutingModule,
|
||||||
|
HttpClientModule
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
<p>project-card works!</p>
|
||||||
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
15
src/app/projects/project-card/project-card.component.ts
Normal file
15
src/app/projects/project-card/project-card.component.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-project-card',
|
||||||
|
templateUrl: './project-card.component.html',
|
||||||
|
styleUrls: ['./project-card.component.scss']
|
||||||
|
})
|
||||||
|
export class ProjectCardComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
1
src/app/projects/project/project.component.html
Normal file
1
src/app/projects/project/project.component.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p>project works!</p>
|
||||||
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
15
src/app/projects/project/project.component.ts
Normal file
15
src/app/projects/project/project.component.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-project',
|
||||||
|
templateUrl: './project.component.html',
|
||||||
|
styleUrls: ['./project.component.scss']
|
||||||
|
})
|
||||||
|
export class ProjectComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
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,5 @@
|
|||||||
<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>
|
||||||
@ -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 { NavService } from '../nav/nav.service';
|
||||||
import { Pages } from '../shared/models/pages.model';
|
import { Pages } from '../shared/models/pages.model';
|
||||||
|
import { Project } from '../shared/models/project.model';
|
||||||
|
import { ProjectsService } from './projects.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-projects',
|
selector: 'app-projects',
|
||||||
templateUrl: './projects.component.html',
|
templateUrl: './projects.component.html',
|
||||||
styleUrls: ['./projects.component.scss']
|
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 {
|
ngOnInit(): void {
|
||||||
this.navService.setPageTitle(Pages.PROJECTS);
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
60
src/app/projects/projects.service.ts
Normal file
60
src/app/projects/projects.service.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
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 _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) { }
|
||||||
|
|
||||||
|
httpOptions = {
|
||||||
|
headers: new HttpHeaders({
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
getInvoicesToApprove(): void {
|
||||||
|
this.http
|
||||||
|
.get(`${this.PROJECT_API_URL}`, this.httpOptions)
|
||||||
|
.subscribe(
|
||||||
|
(response: Project[]) => {
|
||||||
|
if (response) {
|
||||||
|
this.allProjects = response;
|
||||||
|
// filter out different categories here currently only one
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
this.apiErrored = true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
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 {
|
||||||
|
title: string,
|
||||||
|
description: string,
|
||||||
|
ct: string,
|
||||||
|
body: string
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user