Revize 443415f5
Přidáno uživatelem castic96 před téměř 5 roky(ů)
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 | 8 |
import { HomeComponent } from './components/pages/home/home.component'; |
10 | 9 |
import { HeaderComponent } from './components/layout/header/header.component'; |
11 | 10 |
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; |
12 | 11 |
import { MatToolbarModule } from '@angular/material/toolbar'; |
13 |
import {MatButtonModule} from '@angular/material/button';
|
|
14 |
import {MatIconModule} from '@angular/material/icon';
|
|
12 |
import { MatButtonModule } from '@angular/material/button';
|
|
13 |
import { MatIconModule } from '@angular/material/icon';
|
|
15 | 14 |
import { SearchComponent } from './components/pages/search/search.component'; |
16 | 15 |
import { BrowseComponent } from './components/pages/browse/browse.component'; |
17 | 16 |
import { UploadComponent } from './components/pages/upload/upload.component'; |
18 | 17 |
import { HelpComponent } from './components/pages/help/help.component'; |
19 |
import {MatSelectModule} from '@angular/material/select'; |
|
18 |
import { MatSelectModule } from '@angular/material/select'; |
|
19 |
import { SearchBoxComponent } from './components/shared-components/search-box/search-box.component'; |
|
20 | 20 |
|
21 | 21 |
@NgModule({ |
22 | 22 |
declarations: [ |
23 | 23 |
AppComponent, |
24 |
SearchComponentComponent, |
|
25 | 24 |
HomeComponent, |
26 | 25 |
HeaderComponent, |
27 | 26 |
SearchComponent, |
28 | 27 |
BrowseComponent, |
29 | 28 |
UploadComponent, |
30 |
HelpComponent |
|
29 |
HelpComponent, |
|
30 |
SearchBoxComponent |
|
31 | 31 |
], |
32 | 32 |
imports: [ |
33 | 33 |
BrowserModule, |
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; |
|
1 |
body { |
|
2 |
background-image: url("../../../../assets/img/img1.jpg"); |
|
7 | 3 |
} |
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> |
|
1 |
<app-search-box></app-search-box> |
|
11 | 2 |
|
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.ts | ||
---|---|---|
1 | 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 | 2 |
|
7 | 3 |
@Component({ |
8 | 4 |
selector: 'app-home', |
... | ... | |
10 | 6 |
styleUrls: ['./home.component.css'] |
11 | 7 |
}) |
12 | 8 |
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 | 9 |
|
26 | 10 |
ngOnInit() { |
27 |
|
|
28 | 11 |
} |
29 | 12 |
|
30 | 13 |
} |
fe/fulltextsearch/src/app/components/shared-components/search-box/search-box.component.css | ||
---|---|---|
1 |
button { |
|
2 |
font-weight: bold; |
|
3 |
font-size: large; |
|
4 |
background-color: var(--primary-color); |
|
5 |
color: var(--search-text-color); |
|
6 |
border-style: none; |
|
7 |
border-radius: 0; |
|
8 |
min-width: 80pt; |
|
9 |
} |
|
10 |
|
|
11 |
button:hover { |
|
12 |
background-color: var(--primary-color-dark); |
|
13 |
} |
|
14 |
|
|
15 |
.input-group-text { |
|
16 |
background-color: var(--search-background-color); |
|
17 |
color: grey; |
|
18 |
border-style: none; |
|
19 |
} |
|
20 |
|
|
21 |
.form-control { |
|
22 |
height: 35pt; |
|
23 |
border-style: none; |
|
24 |
} |
fe/fulltextsearch/src/app/components/shared-components/search-box/search-box.component.html | ||
---|---|---|
1 |
<div class="container"> |
|
2 |
|
|
3 |
<div class="row justify-content-center align-items-center" style="height: 500px"> |
|
4 |
|
|
5 |
<div class="col-sm-10 col-md-8 col-lg-6"> |
|
6 |
<div class="input-group mb-3"> |
|
7 |
<div class="input-group-prepend"> |
|
8 |
<span class="input-group-text"> |
|
9 |
<mat-icon>search</mat-icon> |
|
10 |
</span> |
|
11 |
</div> |
|
12 |
<input type="text" class="form-control" [(ngModel)]="expression" placeholder="Enter text to search..." aria-label="Search" aria-describedby="basic-addon2"> |
|
13 |
<div class="input-group-append"> |
|
14 |
<button class="btn btn-outline-secondary" type="button" (click)="onSubmit()">Search</button> |
|
15 |
</div> |
|
16 |
</div> |
|
17 |
</div> |
|
18 |
|
|
19 |
</div> |
|
20 |
|
|
21 |
</div> |
fe/fulltextsearch/src/app/components/shared-components/search-box/search-box.component.spec.ts | ||
---|---|---|
1 |
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
|
2 |
|
|
3 |
import { SearchBoxComponent } from './search-box.component'; |
|
4 |
|
|
5 |
describe('SearchBoxComponent', () => { |
|
6 |
let component: SearchBoxComponent; |
|
7 |
let fixture: ComponentFixture<SearchBoxComponent>; |
|
8 |
|
|
9 |
beforeEach(async(() => { |
|
10 |
TestBed.configureTestingModule({ |
|
11 |
declarations: [ SearchBoxComponent ] |
|
12 |
}) |
|
13 |
.compileComponents(); |
|
14 |
})); |
|
15 |
|
|
16 |
beforeEach(() => { |
|
17 |
fixture = TestBed.createComponent(SearchBoxComponent); |
|
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-box/search-box.component.ts | ||
---|---|---|
1 |
import { Component, OnInit } from '@angular/core'; |
|
2 |
import { SearchRequest } from '../../../model/SearchRequest'; |
|
3 |
import { QueryService } from '../../../services/query.service'; |
|
4 |
import { Router } from '@angular/router'; |
|
5 |
|
|
6 |
@Component({ |
|
7 |
selector: 'app-search-box', |
|
8 |
templateUrl: './search-box.component.html', |
|
9 |
styleUrls: ['./search-box.component.css'] |
|
10 |
}) |
|
11 |
export class SearchBoxComponent implements OnInit { |
|
12 |
expression: string |
|
13 |
|
|
14 |
constructor(private queryService: QueryService, private router: Router) { } |
|
15 |
|
|
16 |
ngOnInit(): void { |
|
17 |
} |
|
18 |
|
|
19 |
onSubmit() { |
|
20 |
const searchRequest: SearchRequest = new SearchRequest(this.expression, new Date()); |
|
21 |
|
|
22 |
//TODO: naimplementovat searchPost |
|
23 |
/* |
|
24 |
this.queryService.searchPost(searchRequest).subscribe (() => { |
|
25 |
//TODO: ulozit objekt SearchResponse[] |
|
26 |
this.router.navigate(['/search']); |
|
27 |
}); |
|
28 |
*/ |
|
29 |
} |
|
30 |
|
|
31 |
} |
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 |
} |
fe/fulltextsearch/src/app/model/SearchRequest.ts | ||
---|---|---|
1 | 1 |
export class SearchRequest { |
2 | 2 |
public expression: string; |
3 | 3 |
public timestamp: Date; |
4 |
|
|
5 |
constructor(expression: string, timestamp: Date) { |
|
6 |
this.expression = expression; |
|
7 |
this.timestamp = timestamp; |
|
8 |
} |
|
4 | 9 |
} |
fe/fulltextsearch/src/theme.css | ||
---|---|---|
2 | 2 |
:root { |
3 | 3 |
--primary-color: #AD2624; |
4 | 4 |
--primary-color-dark: #932523; |
5 |
--search-text-color: #ffffff; |
|
6 |
--search-background-color: #ffffff; |
|
5 | 7 |
--navbar-text-color: #ffffff; |
6 | 8 |
} |
Také k dispozici: Unified diff
Feature #7724: Implementace architektury FE
- přidání search-box component