Commit 7cea4f3b776726dc14dad52324e2de2daab6fbfc

Authored by trainee
1 parent 2eac6113
Exists in master

เสริชข้อมูล active ด้วย ชื่อ team อย่างเดียว

src/app/app.module.ts
@@ -14,13 +14,16 @@ import { AppComponent } from './app.component'; @@ -14,13 +14,16 @@ import { AppComponent } from './app.component';
14 import { LayoutComponent } from './layout/layout.component'; 14 import { LayoutComponent } from './layout/layout.component';
15 import { DashboardComponent } from './dashboard/dashboard.component'; 15 import { DashboardComponent } from './dashboard/dashboard.component';
16 import { ShortPipe } from './dashboard/short'; 16 import { ShortPipe } from './dashboard/short';
  17 +import { FilterPipe } from './dashboard/filter.pipe';
  18 +
17 19
18 @NgModule({ 20 @NgModule({
19 declarations: [ 21 declarations: [
20 AppComponent, 22 AppComponent,
21 ShortPipe, 23 ShortPipe,
22 LayoutComponent, 24 LayoutComponent,
23 - DashboardComponent 25 + DashboardComponent,
  26 + FilterPipe
24 ], 27 ],
25 imports: [ 28 imports: [
26 BrowserModule, 29 BrowserModule,
src/app/dashboard/dashboard.component.html
@@ -23,7 +23,11 @@ @@ -23,7 +23,11 @@
23 <div class="input-icon right" style="margin-left: 820px; margin-top: -20px;" > 23 <div class="input-icon right" style="margin-left: 820px; margin-top: -20px;" >
24 <i class="icon-magnifier"> 24 <i class="icon-magnifier">
25 </i> 25 </i>
26 - <input type="text" placeholder="Search.." class="form-control sbold font"> 26 + <input
  27 + type="text"
  28 + placeholder="Search.."
  29 + class="form-control sbold font"
  30 + [(ngModel)]="FilterSearch">
27 </div> 31 </div>
28 </h1> 32 </h1>
29 <hr> 33 <hr>
@@ -31,7 +35,7 @@ @@ -31,7 +35,7 @@
31 </div> 35 </div>
32 <div class="panel-body"> 36 <div class="panel-body">
33 <div class="row"> 37 <div class="row">
34 - <div class="col-lg-4 col-md-3 col-sm-6 col-xs-12" *ngFor="let item of resultData"> 38 + <div class="col-lg-4 col-md-3 col-sm-6 col-xs-12" *ngFor="let item of resultData | filter:FilterSearch: 'team'">
35 <a class="dashboard-stat dashboard-stat-v2 red " 39 <a class="dashboard-stat dashboard-stat-v2 red "
36 href="{{item.link}}" 40 href="{{item.link}}"
37 target="_blank" 41 target="_blank"
src/app/dashboard/dashboard.component.spec.ts
@@ -1,28 +0,0 @@ @@ -1,28 +0,0 @@
1 -/* tslint:disable:no-unused-variable */  
2 -import { async, ComponentFixture, TestBed } from '@angular/core/testing';  
3 -import { By } from '@angular/platform-browser';  
4 -import { DebugElement } from '@angular/core';  
5 -  
6 -import { DashboardComponent } from './dashboard.component';  
7 -  
8 -describe('DashboardComponent', () => {  
9 - let component: DashboardComponent;  
10 - let fixture: ComponentFixture<DashboardComponent>;  
11 -  
12 - beforeEach(async(() => {  
13 - TestBed.configureTestingModule({  
14 - declarations: [ DashboardComponent ]  
15 - })  
16 - .compileComponents();  
17 - }));  
18 -  
19 - beforeEach(() => {  
20 - fixture = TestBed.createComponent(DashboardComponent);  
21 - component = fixture.componentInstance;  
22 - fixture.detectChanges();  
23 - });  
24 -  
25 - it('should create', () => {  
26 - expect(component).toBeTruthy();  
27 - });  
28 -});  
src/app/dashboard/dashboard.component.ts
@@ -11,6 +11,7 @@ import { async } from &#39;rxjs/internal/scheduler/async&#39;; @@ -11,6 +11,7 @@ import { async } from &#39;rxjs/internal/scheduler/async&#39;;
11 }) 11 })
12 export class DashboardComponent implements OnInit { 12 export class DashboardComponent implements OnInit {
13 13
  14 + FilterSearch = '';
14 15
15 16
16 getColorDay(days){ 17 getColorDay(days){
src/app/dashboard/filter.pipe.ts 0 → 100644
@@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
  1 +import { Pipe, PipeTransform } from '@angular/core';
  2 +
  3 +@Pipe({
  4 + name: 'filter'
  5 +})
  6 +export class FilterPipe implements PipeTransform {
  7 +
  8 + transform(value: any, filterString: string, propName: string): any {
  9 + if (value.length === 0) {
  10 + return value;
  11 + }
  12 +
  13 + const resultArray = [];
  14 + for (const item of value) {
  15 + if (item[propName] === filterString) {
  16 + resultArray.push(item);
  17 + }
  18 +
  19 + }
  20 + return resultArray;
  21 + }
  22 +
  23 +}