Commit d675b82368686e21527e70853b9dffb6b5a63606

Authored by Yarik
2 parents cb21b064 7117accf

Merge

src/app/pages/statements/components/busStop2/busStop2.component.ts
1 import { Component, ViewEncapsulation } from '@angular/core'; 1 import { Component, ViewEncapsulation } from '@angular/core';
2 2
3 import { BusStop2Service } from './busStop2.service'; 3 import { BusStop2Service } from './busStop2.service';
4 - 4 +import { busStop2 } from './busStop2';
5 import { LocalDataSource } from 'ng2-smart-table'; 5 import { LocalDataSource } from 'ng2-smart-table';
6 import { GridOptions } from 'ag-grid/main'; 6 import { GridOptions } from 'ag-grid/main';
7 7
8 @Component({ 8 @Component({
9 selector: 'statement-table', 9 selector: 'statement-table',
10 encapsulation: ViewEncapsulation.None, 10 encapsulation: ViewEncapsulation.None,
11 - styleUrls: ['./busStop2.scss'], 11 + styleUrls: ['./busStop2.scss',
  12 + '../../../../../../node_modules/ag-grid/dist/styles/ag-grid.css',
  13 + '../../../../../../node_modules/ag-grid/dist/styles/theme-dark.css'],
12 templateUrl: './busStop2.html', 14 templateUrl: './busStop2.html',
13 }) 15 })
14 export class BusStop2 { 16 export class BusStop2 {
15 - source: LocalDataSource = new LocalDataSource(); 17 + // source: LocalDataSource = new LocalDataSource();
16 18
17 public showGrid: boolean; 19 public showGrid: boolean;
18 public rowData: any[]; 20 public rowData: any[];
@@ -25,8 +27,14 @@ export class BusStop2 { @@ -25,8 +27,14 @@ export class BusStop2 {
25 this.gridOptions = <GridOptions>{}; 27 this.gridOptions = <GridOptions>{};
26 // this.gridOptions.rowModelType = 'virtual'; 28 // this.gridOptions.rowModelType = 'virtual';
27 this.service.getData().then((data) => { 29 this.service.getData().then((data) => {
28 - this.source.load(data);  
29 - this.rowData = data; 30 + console.log(data);
  31 + if(data.length){
  32 + // this.source.load(data);
  33 + this.rowData = data;
  34 + } else {
  35 + this.rowData = [new busStop2]
  36 + }
  37 +
30 }); 38 });
31 this.createColumnDefs(); 39 this.createColumnDefs();
32 this.showGrid = true; 40 this.showGrid = true;
src/app/pages/statements/components/busStop2/busStop2.html
1 <div class="widgets"> 1 <div class="widgets">
2 2
3 - <div class="row">  
4 - <ba-card title="Автобусні зупинки" baCardClass="with-scroll">  
5 - <ag-grid-ng2 #agGrid style="width: 100%; height: 350px;" class="ag-bootstrap"  
6 - [gridOptions]="gridOptions"  
7 - [columnDefs]="columnDefs"  
8 - [rowData]="rowData" 3 + <div class="row">
  4 + <ba-card title="Автобусні зупинки" baCardClass="with-scroll">
  5 + <ag-grid-ng2 #agGrid style="width: 100%; height: 350px;" class="ag-dark" [gridOptions]="gridOptions" [columnDefs]="columnDefs" [rowData]="rowData" enableColResize enableSorting enableFilter groupHeaders suppressRowClickSelection toolPanelSuppressGroups
  6 + toolPanelSuppressValues debug rowHeight="22" rowSelection="multiple">
  7 + </ag-grid-ng2>
  8 + </ba-card>
  9 + </div>
9 10
10 - enableColResize  
11 - enableSorting  
12 - enableFilter  
13 - groupHeaders  
14 - suppressRowClickSelection  
15 - toolPanelSuppressGroups  
16 - toolPanelSuppressValues  
17 - debug  
18 - rowHeight="22"  
19 - rowSelection="multiple"  
20 - >  
21 - </ag-grid-ng2>  
22 - </ba-card>  
23 - </div>  
24 -  
25 -</div> 11 +</div>
26 \ No newline at end of file 12 \ No newline at end of file
src/app/pages/statements/components/busStop2/busStop2.service.ts
@@ -3,34 +3,27 @@ import { Headers, Http } from &#39;@angular/http&#39;; @@ -3,34 +3,27 @@ import { Headers, Http } from &#39;@angular/http&#39;;
3 3
4 import 'rxjs/add/operator/toPromise'; 4 import 'rxjs/add/operator/toPromise';
5 5
6 -import { BusStop2 } from './busStop2'; 6 +import { busStop2 } from './busStop2';
7 7
8 @Injectable() 8 @Injectable()
9 export class BusStop2Service { 9 export class BusStop2Service {
10 private url = 'http://localhost:5000/busstop'; 10 private url = 'http://localhost:5000/busstop';
11 private headers = new Headers({'Content-Type': 'application/json'}); 11 private headers = new Headers({'Content-Type': 'application/json'});
12 constructor(private http: Http) { } 12 constructor(private http: Http) { }
13 - getData(): Promise<BusStop2[]> {  
14 - let busStops: BusStop2[] = [{  
15 - id: 1,  
16 - road: 'Test',  
17 - region: 'Test',  
18 - locationLeft: '1',  
19 - locationRight: '1',  
20 - state: 'Test'  
21 - }, {  
22 - id: 2,  
23 - road: 'Test2',  
24 - region: 'Test2',  
25 - locationLeft: '2',  
26 - locationRight: '2',  
27 - state: 'Test2'  
28 - }];  
29 - return Promise.resolve(busStops);  
30 - // return this.http.get(this.url)  
31 - // .toPromise()  
32 - // .then(response => response.json().busStopListDsM as BusStop2[])  
33 - // .catch(this.handleError); 13 + getData(): Promise<busStop2[]> {
  14 + // let busStops: BusStop2[] = [{
  15 + // id: 1,
  16 + // road: 'Test',
  17 + // region: 'Test',
  18 + // locationLeft: '1',
  19 + // locationRight: '1',
  20 + // state: 'Test'
  21 + // }];
  22 + // return Promise.resolve(busStops);
  23 + return this.http.get(this.url)
  24 + .toPromise()
  25 + .then(response => response.json().busStopEditDsM as busStop2[])
  26 + .catch(this.handleError);
34 } 27 }
35 private handleError(error: any): Promise<any> { 28 private handleError(error: any): Promise<any> {
36 console.error('An error occured', error); 29 console.error('An error occured', error);
src/app/pages/statements/components/busStop2/busStop2.ts
1 -export class BusStop2 {  
2 - id: number;  
3 - road: string;  
4 - region: string;  
5 - locationRight: string;  
6 - locationLeft: string;  
7 - state: string; 1 +export class busStop2 {
  2 + RoadId: number;
  3 + RegionId: number;
  4 + SettlementId: number;
  5 + LocationLeft: string;
  6 + LocationRight: string;
  7 + SurfaceTypeId: string;
  8 + AreaStopAvailability: string;
  9 + AreaLandAvailability: string;
  10 + PocketAvailability: string;
  11 + ToiletAvailability: string;
  12 + YearBuild: string;
  13 + YearRepair: string;
  14 + StateCommonId: number;
8 } 15 }
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html lang="en"> 2 <html lang="en">
3 -<head>  
4 - <meta charset="utf-8">  
5 - <meta http-equiv="x-ua-compatible" content="ie=edge">  
6 - <meta name="viewport" content="width=device-width, initial-scale=1">  
7 -  
8 - <title><%= htmlWebpackPlugin.options.title %></title>  
9 3
  4 +<head>
  5 + <meta charset="utf-8">
  6 + <meta http-equiv="x-ua-compatible" content="ie=edge">
  7 + <meta name="viewport" content="width=device-width, initial-scale=1">
  8 +
  9 + <title>
  10 + <%= htmlWebpackPlugin.options.title %>
  11 + </title>
  12 + <!--
10 <link rel="stylesheet" href="/app/pages/statements/ag-grid.css"> 13 <link rel="stylesheet" href="/app/pages/statements/ag-grid.css">
11 - <link rel="stylesheet" href="/app/pages/statements/theme-bootstrap.css">  
12 - <meta name="description" content="<%= htmlWebpackPlugin.options.metadata.description %>">  
13 - <% if (webpackConfig.htmlElements.headTags) { %>  
14 - <!-- Configured Head Tags -->  
15 - <%= webpackConfig.htmlElements.headTags %>  
16 - <% } %> 14 + <link rel="stylesheet" href="/app/pages/statements/theme-bootstrap.css">-->
  15 + <meta name="description" content="<%= htmlWebpackPlugin.options.metadata.description %>">
  16 + <% if (webpackConfig.htmlElements.headTags) { %>
  17 + <!-- Configured Head Tags -->
  18 + <%= webpackConfig.htmlElements.headTags %>
  19 + <% } %>
17 20
18 - <!-- base url -->  
19 - <base href="<%= htmlWebpackPlugin.options.metadata.baseUrl %>"> 21 + <!-- base url -->
  22 + <base href="<%= htmlWebpackPlugin.options.metadata.baseUrl %>">
20 23
21 24
22 </head> 25 </head>
23 26
24 <body> 27 <body>
25 -<app>  
26 -</app> 28 + <app>
  29 + </app>
27 30
28 -<div id="preloader">  
29 - <div></div>  
30 -</div> 31 + <div id="preloader">
  32 + <div></div>
  33 + </div>
31 34
32 -<% if (htmlWebpackPlugin.options.metadata.isDevServer && htmlWebpackPlugin.options.metadata.HMR !== true) { %>  
33 -<!-- Webpack Dev Server reload -->  
34 -<script src="/webpack-dev-server.js"></script>  
35 -<% } %> 35 + <% if (htmlWebpackPlugin.options.metadata.isDevServer && htmlWebpackPlugin.options.metadata.HMR !== true) { %>
  36 + <!-- Webpack Dev Server reload -->
  37 + <script src="/webpack-dev-server.js"></script>
  38 + <% } %>
36 39
37 -<link  
38 - href='https://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900italic,900&subset=latin,greek,greek-ext,vietnamese,cyrillic-ext,latin-ext,cyrillic'  
39 - rel='stylesheet' type='text/css'> 40 + <link href='https://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900italic,900&subset=latin,greek,greek-ext,vietnamese,cyrillic-ext,latin-ext,cyrillic' rel='stylesheet' type='text/css'>
40 </body> 41 </body>
41 -</html> 42 +
  43 +</html>
42 \ No newline at end of file 44 \ No newline at end of file