moved interface to common place
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { Component, input } from '@angular/core';
|
import { Component, input } from '@angular/core';
|
||||||
import { Artist } from '../comic-artists/artist.model';
|
import { Artist } from '../comic.model';
|
||||||
import { RouterLink, RouterLinkActive } from '@angular/router';
|
import { RouterLink, RouterLinkActive } from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
import { Component, DestroyRef, inject, OnInit, signal } from '@angular/core';
|
import { Component, DestroyRef, inject, OnInit, signal } from '@angular/core';
|
||||||
import { Artist } from '../comic-artists/artist.model';
|
import { Artist } from '../comic.model';
|
||||||
import { ComicArtistComponent } from '../comic-artist/comic-artist.component';
|
import { ComicArtistComponent } from '../comic-artist/comic-artist.component';
|
||||||
import { ArtistService } from '../comic-artists/artist.service';
|
import { ArtistService } from '../comic-artists/artist.service';
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
export interface Artist {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ArtistDetails {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
weblink: string;
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@ import { inject, Injectable, signal } from "@angular/core";
|
|||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import { catchError, map, throwError } from "rxjs";
|
import { catchError, map, throwError } from "rxjs";
|
||||||
import { ErrorService } from "../../../shared/error.service";
|
import { ErrorService } from "../../../shared/error.service";
|
||||||
import { Artist, ArtistDetails } from "./artist.model";
|
import { Artist, ArtistDetails } from "../comic.model";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
|
|||||||
@@ -3,3 +3,11 @@
|
|||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
grid-gap: 20px;
|
grid-gap: 20px;
|
||||||
}
|
}
|
||||||
|
section {
|
||||||
|
margin-left: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
article {
|
||||||
|
margin-left: 10px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
@@ -7,6 +7,16 @@
|
|||||||
@if (artist()) {
|
@if (artist()) {
|
||||||
<h2>{{ artist().name }}</h2>
|
<h2>{{ artist().name }}</h2>
|
||||||
<a href="{{ artist().weblink }}">{{ artist().name }}</a>
|
<a href="{{ artist().weblink }}">{{ artist().name }}</a>
|
||||||
|
@for (work of artist().works; track work.worktype.id) {
|
||||||
|
<section>
|
||||||
|
<app-comic-worktype [worktype]="work.worktype"/>
|
||||||
|
@for (comic of work.comics; track comic.id) {
|
||||||
|
<article>
|
||||||
|
<app-comic-comic [comic]="comic"/>
|
||||||
|
</article>
|
||||||
|
}
|
||||||
|
</section>
|
||||||
|
}
|
||||||
} @else {
|
} @else {
|
||||||
<h2>Artist Details</h2>
|
<h2>Artist Details</h2>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import { Component, inject, input } from '@angular/core';
|
import { Component, inject, input } from '@angular/core';
|
||||||
import { ComicArtistsListComponent } from '../comic-artists-list/comic-artists-list.component';
|
import { ComicArtistsListComponent } from '../comic-artists-list/comic-artists-list.component';
|
||||||
import { ArtistDetails } from './artist.model';
|
|
||||||
import { ActivatedRouteSnapshot, ResolveFn, RouterStateSnapshot } from '@angular/router';
|
import { ActivatedRouteSnapshot, ResolveFn, RouterStateSnapshot } from '@angular/router';
|
||||||
import { ArtistService } from './artist.service';
|
import { ArtistService } from './artist.service';
|
||||||
|
import { ComicComicComponent } from "../comic-comic/comic-comic.component";
|
||||||
|
import { ComicWorktypeComponent } from "../comic-worktype/comic-worktype.component";
|
||||||
|
import { ArtistDetails } from '../comic.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-comic-artists',
|
selector: 'app-comic-artists',
|
||||||
imports: [ComicArtistsListComponent],
|
imports: [ComicArtistsListComponent, ComicComicComponent, ComicWorktypeComponent],
|
||||||
templateUrl: './comic-artists.component.html',
|
templateUrl: './comic-artists.component.html',
|
||||||
styleUrl: './comic-artists.component.css'
|
styleUrl: './comic-artists.component.css'
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Component, input } from '@angular/core';
|
import { Component, input } from '@angular/core';
|
||||||
import { Comic } from '../comic-comics/comic.model';
|
import { Comic } from '../comic.model';
|
||||||
import { RouterLink, RouterLinkActive } from '@angular/router';
|
import { RouterLink, RouterLinkActive } from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
import { Component, DestroyRef, inject, OnInit, signal } from '@angular/core';
|
import { Component, DestroyRef, inject, OnInit, signal } from '@angular/core';
|
||||||
import { Comic } from '../comic-comics/comic.model';
|
import { Comic } from '../comic.model';
|
||||||
import { ComicService } from '../comic-comics/comic.service';
|
import { ComicService } from '../comic-comics/comic.service';
|
||||||
import { ComicComicComponent } from "../comic-comic/comic-comic.component";
|
import { ComicComicComponent } from "../comic-comic/comic-comic.component";
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Component, inject, input } from '@angular/core';
|
import { Component, inject, input } from '@angular/core';
|
||||||
import { ComicComicsListComponent } from "../comic-comics-list/comic-comics-list.component";
|
import { ComicComicsListComponent } from "../comic-comics-list/comic-comics-list.component";
|
||||||
import { ComicDetails } from './comic.model';
|
import { ComicDetails } from '../comic.model';
|
||||||
import { ActivatedRouteSnapshot, ResolveFn, RouterStateSnapshot } from '@angular/router';
|
import { ActivatedRouteSnapshot, ResolveFn, RouterStateSnapshot } from '@angular/router';
|
||||||
import { ComicService } from './comic.service';
|
import { ComicService } from './comic.service';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import { inject, Injectable, signal } from "@angular/core";
|
import { inject, Injectable, signal } from "@angular/core";
|
||||||
import { Comic, ComicDetails } from "./comic.model";
|
import { Comic, ComicDetails } from "../comic.model";
|
||||||
import { catchError, map, throwError } from "rxjs";
|
import { catchError, map, throwError } from "rxjs";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<div>
|
||||||
|
<a [routerLink]="['/', 'comic', 'worktype', worktype().id]" routerLinkActive="active">
|
||||||
|
<span>{{ worktype().name }}</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ComicWorktypeComponent } from './comic-worktype.component';
|
||||||
|
|
||||||
|
describe('ComicWorktypeComponent', () => {
|
||||||
|
let component: ComicWorktypeComponent;
|
||||||
|
let fixture: ComponentFixture<ComicWorktypeComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [ComicWorktypeComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ComicWorktypeComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { Component, input } from '@angular/core';
|
||||||
|
import { RouterLink, RouterLinkActive } from '@angular/router';
|
||||||
|
import { Worktype } from '../comic.model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-comic-worktype',
|
||||||
|
imports: [RouterLink, RouterLinkActive],
|
||||||
|
templateUrl: './comic-worktype.component.html',
|
||||||
|
styleUrl: './comic-worktype.component.css'
|
||||||
|
})
|
||||||
|
export class ComicWorktypeComponent {
|
||||||
|
worktype = input.required<Worktype>();
|
||||||
|
}
|
||||||
+24
@@ -1,3 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
export interface Artist {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Worktype {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface Comic {
|
export interface Comic {
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
@@ -20,3 +32,15 @@ export interface ComicDetails {
|
|||||||
name: string,
|
name: string,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ArtistWorktypeComics {
|
||||||
|
worktype: Worktype;
|
||||||
|
comics: Comic[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ArtistDetails {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
weblink: string;
|
||||||
|
works: ArtistWorktypeComics[];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user