Commit 8b447131 authored by Simone Vuotto's avatar Simone Vuotto

Project service update

parent 7fc8a255
......@@ -30,6 +30,8 @@ import {AuthGuard} from './auth.guard';
// Http Interceptor
import { JwtInterceptor } from './jwt.interceptor.js';
import { PatternWizardComponent } from './pattern-wizard/pattern-wizard.component';
import { ExpressionWizardComponent } from './pattern-wizard/expression-wizard/expression-wizard.component';
@NgModule({
......@@ -43,6 +45,8 @@ import { JwtInterceptor } from './jwt.interceptor.js';
RequirementDetailsComponent,
RequirementsTabComponent,
TasksTabComponent,
PatternWizardComponent,
ExpressionWizardComponent,
],
imports: [
BrowserModule,
......
......@@ -20,9 +20,6 @@
<p class="card-text">{{ project.description }}</p>
<p class="card-text"><b>Type:</b> {{ project.type.name }}</p>
</div>
<div class="card-footer text-right">
<a href="#" class="card-link text-primary">Edit</a>
</div>
</div>
</div>
</div>
......
......@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { ProjectType, Project } from '../models/project';
import { catchError } from 'rxjs/operators';
import { catchError, tap } from 'rxjs/operators';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' })
......@@ -15,13 +15,15 @@ export class ProjectService {
private projectsUrl = 'api/projects';
private projectTypesUrl = 'api/projects/types';
private projects: Project[];
constructor(private http: HttpClient) { }
/** GET project types */
getProjectTypes(): Observable<ProjectType[]> {
return this.http.get<ProjectType[]>(this.projectTypesUrl, httpOptions)
.pipe(
catchError(this.handleError('getProjectsType', []))
catchError(this.handleError('getProjectsType', [])),
);
}
......@@ -29,12 +31,21 @@ export class ProjectService {
getProjects(): Observable<Project[]> {
return this.http.get<Project[]>(this.projectsUrl, httpOptions)
.pipe(
catchError(this.handleError('getProjects', []))
catchError(this.handleError('getProjects', [])),
tap(projects => this.projects = projects),
);
}
/** GET project */
getProject(id): Observable<Project> {
if (this.projects != null) {
const project = this.projects.find(prj => prj.id = id);
if (project) {
return of(project);
}
}
return this.http.get<Project>(this.projectsUrl + '/' + id, httpOptions)
.pipe(
catchError(this.handleError('getProjects', null))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment