Skip to content

Commit a22fd73

Browse files
Yasir.ShabbirYasir.Shabbir
Yasir.Shabbir
authored and
Yasir.Shabbir
committed
First Commit
1 parent a7026b8 commit a22fd73

33 files changed

+211
-523
lines changed

Diff for: package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"zone.js": "^0.8.14"
3434
},
3535
"devDependencies": {
36-
"@angular/cli": "1.4.5",
36+
"@angular/cli": "1.5.0",
3737
"@angular/compiler-cli": "^4.2.4",
3838
"@angular/language-service": "^4.2.4",
3939
"@types/jasmine": "~2.5.53",

Diff for: src/app/app.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div style="padding: 25px">
22
<data-table-demo-1></data-table-demo-1>
3-
<data-table-demo-2></data-table-demo-2>
4-
<data-table-demo-3></data-table-demo-3>
3+
4+
55
</div>

Diff for: src/app/app.component.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component } from '@angular/core';
1+
import {Component} from '@angular/core';
22

33
@Component({
44
selector: 'app-root',
@@ -7,4 +7,8 @@ import { Component } from '@angular/core';
77
})
88
export class AppComponent {
99
title = 'app';
10+
11+
ngOnInit(): void {
12+
}
13+
1014
}

Diff for: src/app/app.module.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
import { BrowserModule } from '@angular/platform-browser';
2-
import { NgModule } from '@angular/core';
3-
import { CommonModule } from '@angular/common';
4-
import { FormsModule } from '@angular/forms';
1+
import {BrowserModule} from '@angular/platform-browser';
2+
import {NgModule} from '@angular/core';
3+
import {CommonModule} from '@angular/common';
4+
import {FormsModule} from '@angular/forms';
55

6-
import { AppComponent } from './app.component';
6+
import {AppComponent} from './app.component';
77

8-
import {DataTableModule } from 'angular-4-data-table-bootstrap-4';
8+
import {DataTableModule} from 'angular-4-data-table-bootstrap-4';
9+
10+
import {DataTableDemo1} from './data-table/data-table-demo1';
11+
import {HttpClientModule} from "@angular/common/http";
912

10-
import { DataTableDemo1 } from './demo1/data-table-demo1';
11-
import { DataTableDemo2 } from './demo2/data-table-demo2';
12-
import { DataTableDemo3 } from './demo3/data-table-demo3';
1313

1414
@NgModule({
1515
declarations: [
1616
AppComponent,
17-
DataTableDemo1,
18-
DataTableDemo2,
19-
DataTableDemo3
17+
DataTableDemo1
2018
],
2119
imports: [
2220
BrowserModule,
2321
CommonModule,
2422
FormsModule,
25-
DataTableModule
23+
DataTableModule,
24+
HttpClientModule
2625
],
2726
providers: [],
2827
bootstrap: [AppComponent]
2928
})
30-
export class AppModule { }
29+
export class AppModule {
30+
}

Diff for: src/app/data-table/data-table-demo1-data.js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/app/data-table/data-table-demo1-data.js.map

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/app/data-table/data-table-demo1-data.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default []
File renamed without changes.

Diff for: src/app/data-table/data-table-demo1.html

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<div style="margin: auto; max-width: 1000px; margin-bottom: 50px;">
2+
3+
<div>
4+
<span>Name: </span>
5+
<input type="text" (keyup)="onNameSearch($event)" class="form-control input-sm" style="display: inline-block; width: 100px">
6+
7+
<span>Country: </span>
8+
<input type="text" (keyup)="onCountrySearch($event)" class="form-control input-sm" style="display: inline-block; width: 100px">
9+
10+
<span>City: </span>
11+
<input type="text" (keyup)="onCitySearch($event)" class="form-control input-sm" style="display: inline-block; width: 100px">
12+
13+
14+
15+
<input type="button" class="btn btn-outline-primary" (click)="getData()" value="CLick to Get Result">
16+
17+
</div>
18+
<data-table id="persons-grid"
19+
headerTitle="Facebook Graph API Result"
20+
[items]="items"
21+
[itemCount]="itemCount"
22+
(reload)="reloadItems($event)"
23+
(rowClick)="rowClick($event)"
24+
(rowDoubleClick)="rowDoubleClick($event)"
25+
[rowTooltip]="rowTooltip"
26+
27+
>
28+
<data-table-column
29+
[property]="'name'"
30+
[header]="'Name'"
31+
[sortable]="true"
32+
[resizable]="true"
33+
>
34+
</data-table-column>
35+
<data-table-column
36+
[property]="'country'"
37+
[header]="'Country'"
38+
[sortable]="true">
39+
</data-table-column>
40+
<data-table-column
41+
property="city"
42+
header="City"
43+
width="150px">
44+
</data-table-column>
45+
46+
47+
</data-table>
48+
49+
50+
51+
</div>

Diff for: src/app/demo1/data-table-demo1.js renamed to src/app/data-table/data-table-demo1.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

Diff for: src/app/data-table/data-table-demo1.ts

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import {Component, OnInit} from '@angular/core';
2+
import {DataTableResource} from 'angular-4-data-table-bootstrap-4';
3+
import {HttpClient, HttpParams} from "@angular/common/http";
4+
5+
6+
@Component({
7+
selector: 'data-table-demo-1',
8+
templateUrl: './data-table-demo1.html',
9+
styleUrls: ['./data-table-demo1.css']
10+
})
11+
export class DataTableDemo1 implements OnInit {
12+
13+
14+
ngOnInit(): void {
15+
this.http.get('https://api.github.com/users/seeschweiler').subscribe(data => {
16+
console.log(data);
17+
});
18+
19+
}
20+
21+
itemResource;
22+
items = [];
23+
itemCount = 0;
24+
25+
readonly ROOT_URL = "http://localhost:8080/facebookData";
26+
readonly NAME_SEARCH_URL = "http://localhost:8080/searchByName";
27+
28+
SEARCH_NAME_URL: String = "http://localhost:8080/searchByName";
29+
SEARCH_COUNTRY_URL: String = "http://localhost:8080/searchByCountry";
30+
SEARCH_CITY_URL: String = "http://localhost:8080/searchByCity";
31+
32+
33+
constructor(private http: HttpClient) {
34+
// this.itemResource.count().then(count => this.itemCount = count);
35+
}
36+
37+
reloadItems(params) {
38+
this.itemResource.query(params).then(items => this.items = items);
39+
}
40+
41+
getData() {
42+
this.extractFacebookResult();
43+
}
44+
45+
46+
onNameSearch(event: any) {
47+
48+
let params = new HttpParams().set("name", event.target.value);
49+
this.onStringSearch(params, this.SEARCH_NAME_URL)
50+
}
51+
52+
53+
onCountrySearch(event: any) {
54+
55+
let params = new HttpParams().set("countryName", event.target.value);
56+
this.onStringSearch(params, this.SEARCH_COUNTRY_URL)
57+
}
58+
59+
60+
onCitySearch(event: any) {
61+
62+
let params = new HttpParams().set("cityName", event.target.value);
63+
this.onStringSearch(params, this.SEARCH_CITY_URL)
64+
}
65+
66+
67+
onStringSearch(params: any, url) {
68+
this.http.get(url, {params: params})
69+
.subscribe(
70+
(data) => {
71+
const helperArray = [];
72+
73+
for (let key in data) {
74+
helperArray.push(data[key]);
75+
}
76+
77+
this.items = helperArray;
78+
79+
this.itemResource = new DataTableResource(helperArray);
80+
this.itemResource.count().then(count => this.itemCount = count);
81+
82+
console.log(helperArray)
83+
console.log(JSON.stringify(data))
84+
});
85+
}
86+
87+
// special properties:
88+
rowClick(rowEvent) {
89+
console.log('Clicked: ' + rowEvent.row.item.name);
90+
}
91+
92+
rowDoubleClick(rowEvent) {
93+
alert('Double clicked: ' + rowEvent.row.item.name);
94+
}
95+
96+
rowTooltip(item) {
97+
return item.jobTitle;
98+
}
99+
100+
private extractFacebookResult() {
101+
this.http.get(this.ROOT_URL)
102+
.subscribe(
103+
(data) => {
104+
const helperArray = [];
105+
for (let key in data) {
106+
helperArray.push(data[key]);
107+
}
108+
109+
110+
this.items = helperArray;
111+
this.itemResource = new DataTableResource(helperArray);
112+
this.itemResource.count().then(count => this.itemCount = count);
113+
114+
console.log(helperArray)
115+
console.log(JSON.stringify(data))
116+
});
117+
}
118+
}

Diff for: src/app/demo1/data-table-demo1-data.js

-30
This file was deleted.

Diff for: src/app/demo1/data-table-demo1-data.js.map

-1
This file was deleted.

0 commit comments

Comments
 (0)