Revize e63c2d6c
Přidáno uživatelem castic96 před téměř 5 roky(ů)
fe/fulltextsearch/src/app/app-routing.module.ts | ||
---|---|---|
1 | 1 |
import { NgModule } from '@angular/core'; |
2 | 2 |
import { Routes, RouterModule } from '@angular/router'; |
3 |
import { HomeComponent } from './components/pages/home/home.component'; |
|
3 | 4 |
|
4 | 5 |
|
5 |
const routes: Routes = []; |
|
6 |
const routes: Routes = [ |
|
7 |
{ path: '', component: HomeComponent } |
|
8 |
]; |
|
6 | 9 |
|
7 | 10 |
@NgModule({ |
8 | 11 |
imports: [RouterModule.forRoot(routes)], |
fe/fulltextsearch/src/app/app.component.css | ||
---|---|---|
1 |
.test { |
|
2 |
width: 80%; |
|
3 |
height: 80%; |
|
4 |
margin: 10%; |
|
5 |
border: 3px solid grey; |
|
6 |
padding: 10px; |
|
7 |
} |
|
1 |
|
fe/fulltextsearch/src/app/app.component.html | ||
---|---|---|
1 |
<div class="test"> |
|
2 |
<h1 style="text-align: center">Hello in {{title}} frontend</h1> |
|
3 |
<form #queryForm="ngForm" (ngSubmit)="sendQuery(queryForm.value)"> |
|
4 |
<span><b>Object query:</b> </span>{{ queryForm.value | json }} |
|
5 |
<div class="input-group mb-3"> |
|
6 |
<input type="text" class="form-control" placeholder="Query" aria-describedby="basic-addon2" ngModel name="query"> |
|
7 |
<div class="input-group-append"> |
|
8 |
<button class="btn btn-outline-secondary" type="submit">Search</button> |
|
9 |
</div> |
|
10 |
</div> |
|
11 |
|
|
12 |
<div class="form-group"> |
|
13 |
<label for="exampleFormControlTextarea1">Response:</label> |
|
14 |
<textarea readonly class="form-control" id="exampleFormControlTextarea1" rows="10">{{response.response}}</textarea> |
|
15 |
</div> |
|
16 |
</form> |
|
1 |
<div> |
|
2 |
<app-header></app-header> |
|
3 |
<router-outlet></router-outlet> |
|
17 | 4 |
</div> |
18 |
|
|
19 |
<!-- Routing --> |
|
20 |
<router-outlet></router-outlet> |
fe/fulltextsearch/src/app/app.component.ts | ||
---|---|---|
1 | 1 |
import { Component } from '@angular/core'; |
2 |
import { Query } from './model/Query'; |
|
3 |
import { QueryService} from './services/query.service'; |
|
4 |
import { QueryResponse } from './model/QueryResponse'; |
|
5 | 2 |
|
6 | 3 |
@Component({ |
7 | 4 |
selector: 'app-root', |
... | ... | |
9 | 6 |
styleUrls: ['./app.component.css'] |
10 | 7 |
}) |
11 | 8 |
export class AppComponent { |
12 |
title = 'Fulltext search'; |
|
13 |
response: QueryResponse = new QueryResponse(); |
|
14 |
|
|
15 |
constructor(private queryService: QueryService) { } |
|
16 |
|
|
17 |
sendQuery(temp: Query) { |
|
18 |
console.log(temp); |
|
19 |
temp.date = new Date(); |
|
20 |
this.queryService.sendQuery(temp).subscribe( response => { |
|
21 |
this.response = response; |
|
22 |
}); |
|
23 |
} |
|
24 | 9 |
} |
fe/fulltextsearch/src/app/app.module.ts | ||
---|---|---|
5 | 5 |
import { AppRoutingModule } from './app-routing.module'; |
6 | 6 |
import { AppComponent } from './app.component'; |
7 | 7 |
import { FormsModule } from '@angular/forms'; |
8 |
import { SearchComponentComponent } from './components/shared-components/search-component/search-component.component'; |
|
9 |
import { HomeComponent } from './components/pages/home/home.component'; |
|
10 |
import { HeaderComponent } from './components/layout/header/header.component'; |
|
8 | 11 |
|
9 | 12 |
@NgModule({ |
10 | 13 |
declarations: [ |
11 |
AppComponent |
|
14 |
AppComponent, |
|
15 |
SearchComponentComponent, |
|
16 |
HomeComponent, |
|
17 |
HeaderComponent |
|
12 | 18 |
], |
13 | 19 |
imports: [ |
14 | 20 |
BrowserModule, |
fe/fulltextsearch/src/app/components/layout/header/header.component.html | ||
---|---|---|
1 |
<p>header works!</p> |
fe/fulltextsearch/src/app/components/layout/header/header.component.spec.ts | ||
---|---|---|
1 |
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
|
2 |
|
|
3 |
import { HeaderComponent } from './header.component'; |
|
4 |
|
|
5 |
describe('HeaderComponent', () => { |
|
6 |
let component: HeaderComponent; |
|
7 |
let fixture: ComponentFixture<HeaderComponent>; |
|
8 |
|
|
9 |
beforeEach(async(() => { |
|
10 |
TestBed.configureTestingModule({ |
|
11 |
declarations: [ HeaderComponent ] |
|
12 |
}) |
|
13 |
.compileComponents(); |
|
14 |
})); |
|
15 |
|
|
16 |
beforeEach(() => { |
|
17 |
fixture = TestBed.createComponent(HeaderComponent); |
|
18 |
component = fixture.componentInstance; |
|
19 |
fixture.detectChanges(); |
|
20 |
}); |
|
21 |
|
|
22 |
it('should create', () => { |
|
23 |
expect(component).toBeTruthy(); |
|
24 |
}); |
|
25 |
}); |
fe/fulltextsearch/src/app/components/layout/header/header.component.ts | ||
---|---|---|
1 |
import { Component, OnInit } from '@angular/core'; |
|
2 |
|
|
3 |
@Component({ |
|
4 |
selector: 'app-header', |
|
5 |
templateUrl: './header.component.html', |
|
6 |
styleUrls: ['./header.component.css'] |
|
7 |
}) |
|
8 |
export class HeaderComponent implements OnInit { |
|
9 |
|
|
10 |
constructor() { } |
|
11 |
|
|
12 |
ngOnInit() { |
|
13 |
} |
|
14 |
|
|
15 |
} |
fe/fulltextsearch/src/app/components/pages/home/home.component.css | ||
---|---|---|
1 |
.test { |
|
2 |
width: 80%; |
|
3 |
height: 80%; |
|
4 |
margin: 10%; |
|
5 |
border: 3px solid grey; |
|
6 |
padding: 10px; |
|
7 |
} |
fe/fulltextsearch/src/app/components/pages/home/home.component.html | ||
---|---|---|
1 |
<div class="test"> |
|
2 |
<h1 style="text-align: center">Hello in {{title}} frontend</h1> |
|
3 |
<form #queryForm="ngForm" (ngSubmit)="sendQuery(queryForm.value)"> |
|
4 |
<span><b>Object query:</b> </span>{{ queryForm.value | json }} |
|
5 |
<div class="input-group mb-3"> |
|
6 |
<input type="text" class="form-control" placeholder="Query" aria-describedby="basic-addon2" ngModel name="query"> |
|
7 |
<div class="input-group-append"> |
|
8 |
<button class="btn btn-outline-secondary" type="submit">Search</button> |
|
9 |
</div> |
|
10 |
</div> |
|
11 |
|
|
12 |
<div class="form-group"> |
|
13 |
<label for="exampleFormControlTextarea1">Response:</label> |
|
14 |
<textarea readonly class="form-control" id="exampleFormControlTextarea1" rows="10">{{response.response}}</textarea> |
|
15 |
</div> |
|
16 |
</form> |
|
17 |
</div> |
|
18 |
|
|
19 |
<!-- Routing --> |
|
20 |
<router-outlet></router-outlet> |
fe/fulltextsearch/src/app/components/pages/home/home.component.spec.ts | ||
---|---|---|
1 |
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
|
2 |
|
|
3 |
import { HomeComponent } from './home.component'; |
|
4 |
|
|
5 |
describe('HomeComponent', () => { |
|
6 |
let component: HomeComponent; |
|
7 |
let fixture: ComponentFixture<HomeComponent>; |
|
8 |
|
|
9 |
beforeEach(async(() => { |
|
10 |
TestBed.configureTestingModule({ |
|
11 |
declarations: [ HomeComponent ] |
|
12 |
}) |
|
13 |
.compileComponents(); |
|
14 |
})); |
|
15 |
|
|
16 |
beforeEach(() => { |
|
17 |
fixture = TestBed.createComponent(HomeComponent); |
|
18 |
component = fixture.componentInstance; |
|
19 |
fixture.detectChanges(); |
|
20 |
}); |
|
21 |
|
|
22 |
it('should create', () => { |
|
23 |
expect(component).toBeTruthy(); |
|
24 |
}); |
|
25 |
}); |
fe/fulltextsearch/src/app/components/pages/home/home.component.ts | ||
---|---|---|
1 |
import { Component, OnInit } from '@angular/core'; |
|
2 |
import { QueryResponse } from "../../../model/QueryResponse"; |
|
3 |
import { QueryService } from "../../../services/query.service"; |
|
4 |
import { Query } from "../../../model/Query"; |
|
5 |
|
|
6 |
|
|
7 |
@Component({ |
|
8 |
selector: 'app-home', |
|
9 |
templateUrl: './home.component.html', |
|
10 |
styleUrls: ['./home.component.css'] |
|
11 |
}) |
|
12 |
export class HomeComponent implements OnInit { |
|
13 |
title = 'Fulltext search'; |
|
14 |
response: QueryResponse = new QueryResponse(); |
|
15 |
|
|
16 |
constructor(private queryService: QueryService) { } |
|
17 |
|
|
18 |
sendQuery(temp: Query) { |
|
19 |
console.log(temp); |
|
20 |
temp.date = new Date(); |
|
21 |
this.queryService.sendQuery(temp).subscribe( response => { |
|
22 |
this.response = response; |
|
23 |
}); |
|
24 |
} |
|
25 |
|
|
26 |
ngOnInit() { |
|
27 |
|
|
28 |
} |
|
29 |
|
|
30 |
} |
fe/fulltextsearch/src/app/components/shared-components/search-component/search-component.component.html | ||
---|---|---|
1 |
<p>search-component works!</p> |
fe/fulltextsearch/src/app/components/shared-components/search-component/search-component.component.spec.ts | ||
---|---|---|
1 |
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
|
2 |
|
|
3 |
import { SearchComponentComponent } from './search-component.component'; |
|
4 |
|
|
5 |
describe('SearchComponentComponent', () => { |
|
6 |
let component: SearchComponentComponent; |
|
7 |
let fixture: ComponentFixture<SearchComponentComponent>; |
|
8 |
|
|
9 |
beforeEach(async(() => { |
|
10 |
TestBed.configureTestingModule({ |
|
11 |
declarations: [ SearchComponentComponent ] |
|
12 |
}) |
|
13 |
.compileComponents(); |
|
14 |
})); |
|
15 |
|
|
16 |
beforeEach(() => { |
|
17 |
fixture = TestBed.createComponent(SearchComponentComponent); |
|
18 |
component = fixture.componentInstance; |
|
19 |
fixture.detectChanges(); |
|
20 |
}); |
|
21 |
|
|
22 |
it('should create', () => { |
|
23 |
expect(component).toBeTruthy(); |
|
24 |
}); |
|
25 |
}); |
fe/fulltextsearch/src/app/components/shared-components/search-component/search-component.component.ts | ||
---|---|---|
1 |
import { Component, OnInit } from '@angular/core'; |
|
2 |
|
|
3 |
@Component({ |
|
4 |
selector: 'app-search-component', |
|
5 |
templateUrl: './search-component.component.html', |
|
6 |
styleUrls: ['./search-component.component.css'] |
|
7 |
}) |
|
8 |
export class SearchComponentComponent implements OnInit { |
|
9 |
|
|
10 |
constructor() { } |
|
11 |
|
|
12 |
ngOnInit() { |
|
13 |
} |
|
14 |
|
|
15 |
} |
Také k dispozici: Unified diff
Re #7724: Implementace architektury FE
- počáteční inicializace home page
- počáteční inicializace shared-components/search-component
- úprava routing modulu