Skip to content

Commit 2490be0

Browse files
committed
add company search
1 parent 443773d commit 2490be0

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3.7'
22
services:
33
app:
4-
image: registry.gitlab.com/dotterbear/service-jobad-reader
4+
image: registry.gitlab.com/dotterbear/service-search-ui
55
ports:
66
- '8768:80'
77
expose:

src/app/app.component.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,14 @@ mat-sidenav {
122122
}
123123

124124
.form {
125-
min-width: 100%;
126-
max-width: 100%;
127125
padding: .5rem;
128-
width: 100%;
129126
}
130127

131128
.full-width {
132129
width: 100%;
130+
}
131+
132+
.company-name:hover {
133+
text-decoration: underline;
134+
cursor: pointer;
133135
}

src/app/app.component.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@
88
</div>
99
-->
1010

11-
<form class="form">
12-
<mat-form-field class="full-width">
13-
<input matInput placeholder="Text" value="" (keyup.enter)="search($event.target.value)">
11+
<form class="form" [formGroup]="searchForm" (submit)="search()">
12+
<mat-form-field class="full-width" appearance="outline">
13+
<mat-label>Keyword</mat-label>
14+
<input matInput id="query" placeholder="Keyword" value="" formControlName="query" (keyup.enter)="search()">
15+
</mat-form-field>
16+
<mat-form-field class="full-width" appearance="outline">
17+
<mat-label>Company Name</mat-label>
18+
<input matInput id="company-name" placeholder="Company Name" value="" formControlName="company-name" (keyup.enter)="search()">
1419
</mat-form-field>
1520
</form>
1621

@@ -28,7 +33,7 @@
2833
<ng-container matColumnDef="summary">
2934
<td mat-cell *matCellDef="let item">
3035
<h1>{{item.title}}</h1>
31-
<h3>{{item.companyName}}<span>{{item.location? ' - ' + item.location : ''}}</span></h3>
36+
<h3 class="company-name" (click)="searchForm.controls['company-name'].setValue(item.companyName); search()">{{item.companyName}}<span>{{item.location? ' - ' + item.location : ''}}</span></h3>
3237
<h5>{{item.postedDate}}</h5>
3338
</td>
3439
</ng-container>

src/app/app.component.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { APIResponse } from '../entity/APIResponse';
55
import { Item } from '../entity/Item';
66
import { environment } from '../environments/environment';
77
import { HttpParams } from "@angular/common/http";
8-
import { FormControl } from '@angular/forms';
8+
import { FormControl, FormGroup, FormBuilder } from '@angular/forms';
99
import { MediaMatcher } from '@angular/cdk/layout';
1010
import { getListeners } from '@angular/core/src/render3/discovery_utils';
1111

@@ -17,6 +17,8 @@ import { getListeners } from '@angular/core/src/render3/discovery_utils';
1717
export class AppComponent {
1818
mode = 'determinate';
1919

20+
searchForm: FormGroup;
21+
2022
// for search
2123
placeholder: string = 'New Items';
2224
allItems: string[] = ['Apple', 'Lemon', 'Lime', 'Orange', 'Strawberry'];
@@ -58,10 +60,14 @@ export class AppComponent {
5860

5961
private mobileQueryListener: () => void;
6062

61-
constructor(private httpService: HttpService, changeDetectorRef: ChangeDetectorRef, media: MediaMatcher) {
63+
constructor(private httpService: HttpService, changeDetectorRef: ChangeDetectorRef, media: MediaMatcher, formBuilder: FormBuilder) {
6264
this.mobileQuery = media.matchMedia('(max-width: 768px)');
6365
this.mobileQueryListener = () => changeDetectorRef.detectChanges();
6466
this.mobileQuery.addListener(this.mobileQueryListener);
67+
this.searchForm = formBuilder.group({
68+
query: '',
69+
'company-name': ''
70+
});
6571
}
6672

6773
ngOnInit(): void {
@@ -88,14 +94,15 @@ export class AppComponent {
8894
this.mode = 'determinate';
8995
}
9096

91-
getList(page: any, size: any, orderBy?: string, order?: string, text?: string) {
97+
getList(page: any, size: any, orderBy?: string, order?: string, formValue?: any) {
9298
this.startProgress();
9399
const params = new HttpParams()
94100
.set('page', page)
95101
.set('size', size)
96102
.set('orderBy', orderBy || this.defaultSoredColumn)
97103
.set('direction', order || this.sortedAsc)
98-
.set('query', text || '');
104+
.set('query', formValue && formValue.query || '')
105+
.set('company-name', formValue && formValue['company-name']);
99106
this.httpService
100107
.get<APIResponse<Item>>(environment.getAll, params)
101108
.subscribe((response: any) => {
@@ -124,11 +131,11 @@ export class AppComponent {
124131
}
125132
this.sortedColumnKey = column.key;
126133
this.sortedColumn = column.value;
127-
this.getList(1, this.pageSize, this.sortedColumn, this.sortedOrder);
134+
this.getList(1, this.pageSize, this.sortedColumn, this.sortedOrder, this.searchForm.value);
128135
}
129136

130-
search(text: string) {
131-
this.getList(1, this.pageSize, this.sortedColumn, this.sortedOrder, text);
137+
search() {
138+
this.getList(1, this.pageSize, this.sortedColumn, this.sortedOrder, this.searchForm.value);
132139
}
133140

134141
}

src/environments/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
export const environment = {
66
production: false,
7-
getAll: 'http://localhost:8767/rest/api/v1/jobad/list'
7+
getAll: 'http://34.73.206.62:8767/rest/api/v1/jobad/list'
88
};
99

1010
/*

0 commit comments

Comments
 (0)