forked from amarinafarias/bookshelf_v1
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from FelipeMarques06/buscaCriticas
Construção da busca na página de críticas literárias
- Loading branch information
Showing
11 changed files
with
196 additions
and
26 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/app/criticas/critica-dialogo/critica-dialogo.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<h1 mat-dialog-title>Resenha Crítica:</h1> | ||
<div mat-dialog-content *ngIf="resenhas$ | async as resenhas"> | ||
<p *ngFor="let resenha of resenhas">{{resenha.completo}}</p> | ||
</div> | ||
<div mat-dialog-actions> | ||
<button mat-button mat-dialog-close>Fechar</button> | ||
</div> | ||
|
Empty file.
25 changes: 25 additions & 0 deletions
25
src/app/criticas/critica-dialogo/critica-dialogo.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { CriticaDialogoComponent } from './critica-dialogo.component'; | ||
|
||
describe('CriticaDialogoComponent', () => { | ||
let component: CriticaDialogoComponent; | ||
let fixture: ComponentFixture<CriticaDialogoComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ CriticaDialogoComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(CriticaDialogoComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
src/app/criticas/critica-dialogo/critica-dialogo.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Critica } from './../modelos/critica'; | ||
import { Component, Inject, OnInit } from '@angular/core'; | ||
import { CriticaDialogoService } from '../service/critica-dialogo.service'; | ||
import { MAT_DIALOG_DATA } from '@angular/material/dialog'; | ||
import { Observable, of } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'app-critica-dialogo', | ||
templateUrl: './critica-dialogo.component.html', | ||
styleUrls: ['./critica-dialogo.component.scss'] | ||
}) | ||
export class CriticaDialogoComponent { | ||
|
||
resenhas$!: Observable<Critica[]>; | ||
|
||
constructor( | ||
private criticaDialogoService: CriticaDialogoService, | ||
|
||
@Inject(MAT_DIALOG_DATA) public resenhas: Critica[] | ||
) { | ||
this.resenhas$ = of (resenhas) | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,55 @@ | ||
<div class="grid-container" *ngIf="criticas$ | async as critica; else loading"> | ||
<mat-toolbar color="accent"> | ||
<div class="titulo"> | ||
<h1 class="mat-h1"> CRÍTICAS LITERÁRIAS</h1> | ||
<div> | ||
<!-- Resultado de busca --> | ||
<div> | ||
<div class="grid-container"> | ||
<mat-form-field appearance="fill" style="width: 100%; text-align: center;" > | ||
<mat-label>Busque uma crítica literária</mat-label> | ||
<input matInput #searchInput /> | ||
<mat-icon matSuffix>search</mat-icon> | ||
</mat-form-field> | ||
</div> | ||
</mat-toolbar> | ||
<mat-grid-list cols="2" rowHeight="180px"> | ||
<mat-grid-tile *ngFor="let critica of criticas$ | async" [colspan]="critica.cols" [rowspan]="critica.rows"> | ||
<mat-card class="dashboard-card"> | ||
<mat-card-title-group> | ||
<mat-card-title>{{critica.titulo}}</mat-card-title> | ||
<mat-card-subtitle>{{critica.subtitulo}}</mat-card-subtitle> | ||
<img mat-card-image class="imgcard" [src]="critica.img" [alt]="critica.titulo"> | ||
</mat-card-title-group> | ||
<mat-card-content> | ||
{{critica.resumo}} | ||
</mat-card-content> | ||
</mat-card> | ||
</mat-grid-tile> | ||
</mat-grid-list> | ||
<div class="grid-container" *ngIf="result$ | async as busca"> | ||
<mat-grid-list cols="2" rowHeight="180px"> | ||
<mat-grid-tile *ngFor="let busca of result$| async" [colspan]="busca.cols" [rowspan]="busca.rows"> | ||
<mat-card class="dashboard-card"> | ||
<mat-card-title-group> | ||
<mat-card-title>{{busca.titulo}}</mat-card-title> | ||
<mat-card-subtitle>{{busca.subtitulo}}</mat-card-subtitle> | ||
<img mat-card-image class="imgcard" [src]="busca.img" [alt]="busca.titulo" (click)="abrirCriticas(busca.completo)"> | ||
</mat-card-title-group> | ||
<mat-card-content> | ||
{{busca.resumo}} | ||
</mat-card-content> | ||
</mat-card> | ||
</mat-grid-tile> | ||
</mat-grid-list> | ||
</div> | ||
</div> | ||
|
||
<div class="grid-container" *ngIf="criticas$ | async as critica; else loading"> | ||
<mat-toolbar color="accent"> | ||
<div class="titulo"> | ||
<h1 class="mat-h1"> CRÍTICAS LITERÁRIAS</h1> | ||
</div> | ||
</mat-toolbar> | ||
<mat-grid-list cols="2" rowHeight="180px"> | ||
<mat-grid-tile *ngFor="let critica of criticas$ | async" [colspan]="critica.cols" [rowspan]="critica.rows"> | ||
<mat-card class="dashboard-card"> | ||
<mat-card-title-group> | ||
<mat-card-title>{{critica.titulo}}</mat-card-title> | ||
<mat-card-subtitle>{{critica.subtitulo}}</mat-card-subtitle> | ||
<img mat-card-image class="imgcard" [src]="critica.img" [alt]="critica.titulo" (click)="abrirCriticas(critica.completo)"> | ||
</mat-card-title-group> | ||
<mat-card-content> | ||
{{critica.resumo}} | ||
</mat-card-content> | ||
</mat-card> | ||
</mat-grid-tile> | ||
</mat-grid-list> | ||
</div> | ||
</div> | ||
<ng-template #loading> | ||
<div class="loading-spinner"> | ||
<mat-spinner></mat-spinner> | ||
</div> | ||
</ng-template> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { CriticaDialogoService } from './critica-dialogo.service'; | ||
|
||
describe('CriticaDialogoService', () => { | ||
let service: CriticaDialogoService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(CriticaDialogoService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Critica } from './../modelos/critica'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
import { first, tap } from 'rxjs'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class CriticaDialogoService { | ||
|
||
private readonly uriApi ="../../assets/critica.json" | ||
|
||
constructor(private criticasDashboard: HttpClient) { } | ||
|
||
listagemCriticas () { | ||
return this.criticasDashboard.get<Critica[]>(this.uriApi) | ||
.pipe( | ||
first(), | ||
tap(apiCriticas => console.log(apiCriticas)) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters